00001
00002
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;
00039 Int_t UpdateEvGap = 100;
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);
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);
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();
00063
00064 if(geb_run->GetOnlFlag()) geb_run->HandleConsumerActions(1);
00065 delete geb_run;
00066 gROOT->Info("geb2hdt.C (Producer)","All processes completed");
00067 TFndGeb2hdtMan::KillYourself();
00068 return 0;
00069 }
00070
00071
00072
00073
00074
00075 void geb2hdt(TString msqlhost="$MSQL_DB_HOST", TString fpth="$RDT", TString fnam="FINU02181", Int_t nevts = 1000,Int_t gebip=0) {
00076
00077
00078
00079
00080
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 }