mcr_called/geb2hdt.C

00001 // @(#) 05/06/2006 - Diego Faso
00002 // Author: Piergiorgio Cerello <mailto:cerello@to.infn.it>, Diego Faso <mailto:faso@to.infn.it>
00003 
00004 #define USE_GEB2HDT_GUI
00005 
00006 #ifdef USE_GEB2HDT_GUI
00007 #include "TFndGeb2hdtGUI.h"
00008 #endif
00009 #include "TFndGeb2hdtMan.h"
00010 
00011 #ifdef USE_GEB2HDT_GUI
00012 static TCondition *CondProdReady;
00013 static TCondition *CondGuiReady;
00014 #endif
00015 
00016 //________________________
00017 #ifdef USE_GEB2HDT_GUI
00018 void *HandleGUI(void *ptr){
00019 
00020   TFndGeb2hdtGUI *gebgui = new TFndGeb2hdtGUI((TFndGeb2hdtMan *)ptr);
00021   CondProdReady->Wait();
00022   gebgui->BuildGUI();
00023   Printf("GUI built");
00024   CondGuiReady->Signal();
00025   Printf(".................signal emitted");
00026   TThread::Join(TThread::GetThread("geb2hdt_prod_thread")->GetId());
00027   gSystem->Sleep(500);
00028   delete gebgui;
00029   return 0;
00030 
00031 }
00032 #endif
00033 
00034 //________________________
00035 void *HandleProducer(void *ptr){
00036   
00037   TFndGeb2hdtMan *geb_run = (TFndGeb2hdtMan *)(ptr);
00038   Int_t TimeLimit = -1; // seconds ("-1" means "unlimited")
00039   Int_t UpdateEvGap = 100; // update interval (number of events)
00040   
00041   geb_run->SetUpdateEvGap(UpdateEvGap);
00042   geb_run->SetTimeLimit(TimeLimit);
00043   
00044   geb_run->InitRun();
00045   
00046   if(geb_run->GetOnlFlag()){
00047     geb_run->HandleConsumerActions(0); // inhibit consumer(s) actions
00048     // ---
00049     Printf("... removing old shared memories...");
00050     gSystem->Exec("rm -f $FND_SHR/*.map");
00051     Printf("...done.");
00052     geb_run->TouchMapFiles();
00053     geb_run->HandleConsumerActions(1); // allow consumer(s) actions
00054   }
00055   
00056 #ifdef USE_GEB2HDT_GUI
00057   CondProdReady->Signal();
00058   CondGuiReady->Wait();
00059 #endif
00060   Printf("starting event loop.......");
00061   geb_run->EventLoop();
00062   geb_run->FinishRun(); // post-processing operations
00063   
00064   if(geb_run->GetOnlFlag()) geb_run->HandleConsumerActions(1);  // allow consumer(s)  
00065   delete geb_run;   
00066   gROOT->Info("geb2hdt.C (Producer)","All processes completed");
00067   TFndGeb2hdtMan::KillYourself(); // must call the static method.
00068   return 0;
00069 }
00070 
00071 //___________________________________________________
00072 //___________________________________________________
00073 //___________________________________________________
00074 //void geb2hdt(TString msqlhost="$MSQL_DB_HOST", TString fpth="$RDT", TString fnam="ONLM00000", Int_t nevts = 100,Int_t gebip=0) {
00075 void geb2hdt(TString msqlhost="$MSQL_DB_HOST", TString fpth="$RDT", TString fnam="FINU02181", Int_t nevts = 1000,Int_t gebip=0) {
00076   // Online monitor main-macro management:
00077   //            - GUI support (start/stop/pause/reset) (check if the USE_GEB2HDT_GUI symbol is defined)
00078   //            - producer->consumer(s) communication support (shared hidden text file)
00079   //
00080   // Montecarlo and analysis not supported
00081 
00082 #ifdef USE_GEB2HDT_GUI
00083   CondProdReady = new TCondition(0);
00084   CondGuiReady = new TCondition(0);
00085 #endif
00086 
00087   if(!gebip) gebip = FROOT::Ip2Int(gSystem->Getenv("FND_GEBIP"));
00088   TFndGeb2hdtMan *geb_run = new TFndGeb2hdtMan(msqlhost,fpth,fnam,nevts,gebip);
00089   TThread *ProdThread = new TThread("geb2hdt_prod_thread",HandleProducer,(void *)geb_run);
00090   ProdThread->Run();
00091 
00092 #ifdef USE_GEB2HDT_GUI
00093   TThread *GUIThread = new TThread("gui_thread",HandleGUI,(void *)geb_run);
00094   GUIThread->Run();
00095 #endif
00096 }

Generated on Tue Oct 16 15:40:47 2007 by  doxygen 1.5.2