00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "TRint.h"
00017 #include "TFndGeb2hdtGUI.h"
00018 #include "TFndGeb2hdtMan.h"
00019
00020 TRint *theApp = 0;
00021
00022 TFndGeometry *fingeo;
00023
00024 TFndGeb2hdtMan *geb_run = 0;
00025 TThread *ProdThread = 0;
00026 TThread *GUIThread = 0;
00027
00028 static TCondition *CondProdReady;
00029 static TCondition *CondGuiReady;
00030
00031 TFndGeb2hdtGUI *gebgui = 0;
00032
00033 static Bool_t USING_GEB2HDT_GUI;
00034
00035
00036 void *HandleGUI(void *ptr){
00037
00038 gebgui = new TFndGeb2hdtGUI((TFndGeb2hdtMan *)ptr);
00039 CondProdReady->Wait();
00040 gebgui->BuildGUI();
00041 cout << "GUI built" << endl;
00042 CondGuiReady->Signal();
00043 cout << ".................signal emitted" << endl;
00044 TThread::Join(TThread::GetThread("geb2hdt_prod_thread")->GetId());
00045 gSystem->Sleep(500);
00046 delete gebgui;
00047 return 0;
00048
00049 }
00050
00051
00052 void *HandleProducer(void *ptr){
00053
00054 TFndGeb2hdtMan *geb_run = (TFndGeb2hdtMan *)(ptr);
00055 Int_t TimeLimit = -1;
00056 geb_run->SetTimeLimit(TimeLimit);
00057
00058 geb_run->InitRun();
00059
00060 if(USING_GEB2HDT_GUI){
00061 CondProdReady->Signal();
00062 CondGuiReady->Wait();
00063 }
00064
00065 cout << "starting event loop......." << endl;
00066 geb_run->EventLoop();
00067 geb_run->FinishRun();
00068
00069 if(geb_run->GetOnlFlag()) geb_run->HandleConsumerActions(1);
00070 delete geb_run;
00071 gROOT->Info("geb2hdt.C (Producer)","All processes completed");
00072
00073 delete fingeo;
00074 gApplication->Terminate();
00075 return 0;
00076 }
00077
00078
00079
00080
00081
00082 void geb2hdt(const TString &msqlhost, const TString &fpth, const TString &run_type, const Int_t &run_num,const Int_t &nevts,Int_t gebip) {
00083
00084
00085
00086
00087
00088
00089 CondProdReady = new TCondition(0);
00090 CondGuiReady = new TCondition(0);
00091
00092 fingeo = new TFndGeometry();
00093 fingeo->LoadGeometry("$FROOTSYS/geom/fin_spec_geom_2006.root");
00094
00095 if(!gebip) gebip = FROOT::Ip2Int(gSystem->Getenv("FND_GEBIP"));
00096 geb_run = new TFndGeb2hdtMan(msqlhost,fpth,run_type,run_num,nevts,gebip);
00097 ProdThread = new TThread("geb2hdt_prod_thread",HandleProducer,(void *)geb_run);
00098
00099 geb_run->ReadConfFile();
00100 USING_GEB2HDT_GUI = geb_run->UsingGUI();
00101 gROOT->Info("geb2hdt","USING_GEB2HDT_GUI = %d",USING_GEB2HDT_GUI);
00102
00103 ProdThread->Run();
00104
00105 if(USING_GEB2HDT_GUI){
00106 GUIThread = new TThread("gui_thread",HandleGUI,(void *)geb_run);
00107 GUIThread->Run();
00108 }
00109 }
00110
00111
00112 void PrintUsage(){
00113 cout << endl << " -----------------------------------" << endl;
00114 cout << " --- geb2hdt usage:" << endl;
00115 cout << " - argument 1: database-host." << endl;
00116 cout << " - argument 2: path to raw-data." << endl;
00117 cout << " - argument 3: requested run type." << endl;
00118 cout << " - argument 4: requested run number." << endl;
00119 cout << " - argument 5: requested number of events." << endl;
00120 cout << " - argument 6: requested Geb-IP (may use defaults)." << endl << endl;
00121 cout << " EXAMPLE: geb2hdt $MSQL_DB_HOST $RDT FINU 4372 10000000" << endl;
00122 cout << " -----------------------------------" << endl;
00123 }
00124
00125
00126 int main(int argc, char **argv)
00127 {
00128
00129 cout << "geb2hdt executable started: number of arguments: " << argc << endl;
00130
00131 if(argc < 2){
00132 PrintUsage();
00133 return 0;
00134 }
00135
00136 TString str1 = "$MSQL_DB_HOST";
00137 if(argc > 1) str1 = TString(argv[1]);
00138
00139 TString str2 = "$RDT";
00140 if(argc > 2) str2 = TString(argv[2]);
00141
00142 TString str3 = "ONLM";
00143 if(argc > 3) str3 = TString(argv[3]);
00144
00145 Int_t arg_4 = 0;
00146 if(argc > 4) arg_4 = atoi(argv[4]);
00147
00148 Int_t nevts = std::numeric_limits<Int_t>::max();
00149 if(argc > 5) nevts = atoi(argv[5]);
00150
00151 Int_t gebip = 0;
00152 if(argc > 6) gebip = atoi(argv[6]);
00153
00154 cout << "str1: \"" << str1
00155 << "\"; str2: \"" << str2
00156 << "\"; str3: \"" << str3
00157 << "\"; arg_4: \"" << arg_4
00158 << "\"," << nevts << "; " << gebip << endl;
00159
00160 argc = 0;
00161 for(Int_t ar=0;ar<argc;ar++)argv[ar] = '\0';
00162
00163 for(Int_t ar=0;ar<argc;ar++) cout << "arg[" << ar << "]: \"" << argv[ar] << "\"." << endl;
00164 cout << endl;
00165
00166 cout << " -------------> \"" << *(argv+2) << "\"" << endl;
00167 theApp = new TRint("geb2hdt run application", &argc,argv,NULL,0,1);
00168
00169 theApp->ProcessFile("$FROOTSYS/mcr_called/frootlogon.C");
00170 theApp->SetPrompt("# froot > ");
00171
00172 geb2hdt(str1,str2,str3,arg_4,nevts,gebip);
00173
00174 theApp->Run();
00175 theApp->Terminate(0);
00176 delete theApp;
00177 return 0;
00178 }
00179
00180
00181
00182
00183