mcr/debug/DebugRawRead.C

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 //void DebugRawRead(Char_t *msql_host = "$MSQL_DB_HOST",Char_t *data_path = "$RDT",Char_t *fFileName = "COSM05398",Int_t nevents=10000){
00013 
00014 //void DebugRawRead(const TString &msql_host="$MSQL_DB_HOST",const TString &data_path="$RDT",const TString &run_type="ONLM",const Int_t &cur_run = -1,Int_t nevents=10000){
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   //void DebugRawRead(const TString &msql_host="$MSQL_DB_HOST",const TString &data_path="$RDT",const TString &run_type="COSM",const Int_t &cur_run = 5398,Int_t nevents=10000){
00019 
00020 #ifdef __CINT__
00021   cout << "This script can only be executed via ACliC:" << endl;
00022   gApplication->Terminate();
00023   return;
00024 #endif
00025 
00026   // fFileName = "ONLM00000";
00027   // fFileName = "COSM04898"; // break due to DAQ-write failure
00028   // fFileName = "COSM05013"; // Tofino Night (Ped-subtr:OFF; Zero-suppr:OFF)
00029   // fFileName = "COSM04899"; // should not break
00030   // fFileName = "PEDE01161"; // all TOF TDCs active
00031 
00032   // digits: STB = 4, LMD = 3, SIL = 2, TOF = 1, GTS = 0
00033   //Int_t debug_raw = 0x00000; // (NONE)
00034   //Int_t debug_raw = 0x00003; // (GTS)
00035   //Int_t debug_raw = 0x00030; // (TOF)
00036   //  Int_t debug_raw = 0x00100; // (SIL)
00037   Int_t debug_raw = 0x03000; // (LMD)
00038   //  Int_t debug_raw = 0x30000; // (STB)
00039   //Int_t debug_raw = 0x33333; // (ALL)
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   // --- run initialization
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   //   TFndRun *fRun = new TFndRun(msql_host,data_path,fFileName,nevents,fGebIp);
00058   //   fRun->SetDebugLevel(debug_froot);
00059   //   fRun->SetDebugRawEv(debug_raw);
00060   //  fRun->ConnectToDB(msql_host); 
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; // number of events to be processed in the following step
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 }

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