00001 #include "Riostream.h"
00002 #include "TSystem.h"
00003 #include "TApplication.h"
00004 #include "TROOT.h"
00005 #include "TInterpreter.h"
00006 #include "TThread.h"
00007 #include "TString.h"
00008
00009 #include "TFndRun.h"
00010
00011
00012
00013
00014
00015
00016 void DebugRawRead(const TString &msql_host="$MSQL_DB_HOST",const TString &data_path="$RDT",const TString &run_type="FINU",const Int_t &cur_run = 4106,Int_t nevents=10000){
00017
00018
00019
00020 #ifdef __CINT__
00021 cout << "This script can only be executed via ACliC:" << endl;
00022 gApplication->Terminate();
00023 return;
00024 #endif
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 Int_t debug_raw = 0x03000;
00038
00039
00040
00041 TFndRun *fRun = new TFndRun();
00042 fRun->ReadConfigFile();
00043 fRun->SetDBHost(msql_host);
00044 fRun->SetDataPath(data_path);
00045 fRun->SetMaxNumberOfEvents(nevents);
00046
00047 fRun->SetDebugRawEv(debug_raw);
00048
00049
00050 cout << "***********************************************" << fRun->GetDebug() << endl;
00051 Int_t in_val = fRun->InitNewRun(run_type,cur_run);
00052 if (in_val == -3) FROOT::TerminateFroot(0,TString("wrong argument received as \"run-type\" (\""+run_type)+"\").");
00053 if (in_val) gROOT->Warning("DebugRawRead","in_val = %d",in_val);
00054 cout << "***********************************************" << endl;
00055
00056
00057
00058
00059
00060
00061 Int_t fOnlFlg = fRun->Onlflg();
00062 Printf("New run initialized: online flag is: %d",fOnlFlg);
00063
00064 cerr << endl << endl << endl;
00065 cerr << "Starting the froot \"event read\" debugger" << endl;
00066 cerr << "RunType: " << fndrun->GetRunType() << endl;
00067 cerr << "RunNumber: " << fndrun->GetRunNumber() << endl;
00068 cerr << " (Note: Event numbering starts from \'1\')" << endl;
00069 cerr << " - Insert the number of events to be processed or just type \"q\" to exit" << endl;
00070 cerr << " (Note: a carriage-return is required)" << endl;
00071
00072 TString inp;
00073 Int_t step = 0;
00074 Int_t cur_evt_limit = -1;
00075 Int_t exit_val = 0;
00076
00077 while(fRun->GetNofProcessedEvents() > -1){
00078 gSystem->Sleep(100);
00079 if(fRun->GetNofProcessedEvents() >= cur_evt_limit){
00080 if(fRun->GetNofProcessedEvents()>0){
00081 cerr << endl;
00082 cerr << endl;
00083 cerr << endl;
00084 gROOT->Info("DebugRawRead"," --- --- Last processed event was \"%d\" --- ---",fRun->GetNofProcessedEvents());
00085 }
00086 gROOT->Info("DebugRawRead"," --- --- Insert the number of events to be processed now --- ---");
00087 cin >> inp;
00088 if(!inp.CompareTo("q")) break;
00089 step = inp.Atoi();
00090 if(!step){
00091 gROOT->Info("DebugRawRead","Warning: \"%d\" is not a valid entry.",step);
00092 continue;
00093 }
00094 gROOT->Info("DebugRawRead"," ****************** Next step: %d number of events ******************",step);
00095 cur_evt_limit=fRun->GetNofProcessedEvents() + step;
00096 }
00097
00098 if(debug_raw){
00099 gROOT->Info("DebugRawRead"," ****************** Now processing event %d",fRun->GetNofProcessedEvents()+1);
00100 Printf(" ****************** Now processing event %d",fRun->GetNofProcessedEvents()+1);
00101 }
00102 else if(fRun->GetNofProcessedEvents() % 50 == 0) gROOT->Info("DebugRawRead"," ****************** Now processing event %d",fRun->GetNofProcessedEvents());
00103
00104 exit_val = fRun->GetNextEvent(kTRUE);
00105
00106 if(exit_val!= 0){
00107 fRun->ClearEvent();
00108 break;
00109 }
00110 fRun->ClearEvent();
00111 }
00112 fRun->FinishRun(kTRUE);
00113
00114 Printf("deleting current fndrun...");
00115 delete fRun;
00116 Printf("...done. Now exiting...bye bye ;)");
00117 gROOT->ProcessLine(".q");
00118 }