#include <TRootanaEventLoop.hxx>
Public Member Functions | |
virtual | ~TRootanaEventLoop () |
TDataContainer * | GetDataContainer () |
Method to get the data container that event loop owns. | |
virtual bool | ProcessMidasEvent (TDataContainer &dataContainer)=0 |
virtual void | Initialize (void) |
virtual void | BeginRun (int transition, int run, int time) |
virtual void | EndRun (int transition, int run, int time) |
virtual void | Finalize () |
virtual void | Usage (void) |
virtual bool | CheckOption (std::string option) |
virtual bool | PreFilter (TDataContainer &dataContainer) |
bool | IsOnline () const |
Are we processing online data? | |
bool | IsOffline () const |
Are we processing offline data? | |
int | GetCurrentRunNumber () const |
Current Run Number. | |
void | SetCurrentRunNumber (int run) |
Current Run Number. | |
int | ExecuteLoop (int argc, char *argv[]) |
Method to actually process the Midas information, either as file or online. | |
int | ProcessMidasFile (TApplication *app, const char *fname) |
void | DisableAutoMainWindow () |
Disable automatic creation of MainWindow. | |
void | UseBatchMode () |
Use a batch mode, where we don't check ROOT status. | |
VirtualOdb * | GetODB () |
Get pointer to ODB variables. | |
void | OpenRootFile (int run, std::string midasFilename=std::string("")) |
Open output ROOT file. | |
void | CloseRootFile () |
Cloe output ROOT file. | |
bool | IsRootFileValid () |
Check if output ROOT file is valid and open. | |
void | DisableRootOutput (bool disable=true) |
int | IsRootOutputEnabled () |
void | SetOutputFilename (std::string name) |
virtual std::string | SetFullOutputFileName (int run, std::string midasFilename) |
void | SetOnlineName (std::string name) |
void | ProcessThisEventID (int eventID) |
bool | CheckEventID (int eventId) |
Little helper method to check if EventID matchs requested EventID list. | |
void | SuppressTimestampWarnings () |
bool | GetSuppressTimestampWarnings () |
Suppress timestamp warnings? true = suppress warnings. | |
void | UseOnlyRecent (bool setting=true) |
Static Public Member Functions | |
static TRootanaEventLoop & | Get (void) |
template<typename T > | |
static void | CreateSingleton () |
Protected Member Functions | |
bool | CreateOutputFile (std::string name, std::string options="RECREATE") |
TRootanaEventLoop () | |
virtual bool | CheckOptionRAD (std::string option) |
virtual void | UsageRAD (void) |
Also a special version of usage for TRootanaDisplay. See CheckOptionRAD. | |
Protected Attributes | |
TDirectory * | fOnlineHistDir |
TDirectory for online histograms. | |
Static Protected Attributes | |
static TRootanaEventLoop * | fTRootanaEventLoop = NULL |
The static pointer to the singleton instance. | |
Private Member Functions | |
void | PrintHelp () |
Help Message. | |
Private Attributes | |
TFile * | fOutputFile |
Output ROOT file. | |
std::string | fOutputFilename |
bool | fDisableRootOutput |
Variable for disabling/enabling Root output. | |
VirtualOdb * | fODB |
Pointer to the ODB access instance. | |
bool | fIsOffline |
Are we processing offline or online data? | |
int | fCurrentRunNumber |
Current run number. | |
TDataContainer * | fDataContainer |
std::vector< int > | fProcessEventIDs |
This is the set of eventIDs to process. | |
std::string | fBufferName |
Buffer to connect to. | |
std::string | fOnlineName |
Name of program, as seen by MIDAS. | |
bool | fSuppressTimestampWarnings |
Bool for suppressing the warnings about old timestamps. | |
int | fMaxEvents |
TApplication * | fApp |
bool | fCreateMainWindow |
bool | fUseBatchMode |
This is a base class for event loops that are derived from rootana.
The user should create a class that derives from this TRootanaEventLoop class and then fill in the methods that they want to implement.
The user must implement the method ProcessMidasEvent(), which will get executed on each event.
The user can also implement methods like Initialize, BeginRun, EndRun, Finalize if there are actions they want to execute at certain points.
The event loop will work in both offline and online mode (online only if the user has MIDAS installed).
In example of this type of event loop is shown in examples/analyzer_example.cxx
Definition at line 40 of file TRootanaEventLoop.hxx.
TRootanaEventLoop::~TRootanaEventLoop | ( | ) | [virtual] |
Definition at line 111 of file TRootanaEventLoop.cxx.
References CloseRootFile(), and fODB.
00111 { 00112 00113 if(fODB) delete fODB; 00114 CloseRootFile(); 00115 00116 }
TRootanaEventLoop::TRootanaEventLoop | ( | ) | [protected] |
Create the TApplication
Definition at line 84 of file TRootanaEventLoop.cxx.
References fApp, fBufferName, fCreateMainWindow, fCurrentRunNumber, fDataContainer, fDisableRootOutput, fIsOffline, fMaxEvents, fODB, fOnlineHistDir, fOnlineName, fOutputFile, fOutputFilename, fSuppressTimestampWarnings, fUseBatchMode, and gUseOnlyRecent.
00084 { 00085 00086 fOutputFile = 0; 00087 fOutputFilename = std::string("output"); 00088 fDisableRootOutput = false; 00089 fODB = 0; 00090 fOnlineHistDir = 0; 00091 fMaxEvents = 0; 00092 fCurrentRunNumber = 0; 00093 fIsOffline = true; 00094 00095 fCreateMainWindow = true; 00096 fUseBatchMode = false; 00097 fSuppressTimestampWarnings = false; 00098 00099 gUseOnlyRecent = false; 00100 00101 fBufferName = std::string("SYSTEM"); 00102 fOnlineName = std::string("rootana"); 00103 00104 fDataContainer = new TDataContainer(); 00105 00106 /// Create the TApplication 00107 char **argv2 = NULL; 00108 fApp = new TApplication("rootana", 0, argv2); 00109 }
void TRootanaEventLoop::BeginRun | ( | int | transition, | |
int | run, | |||
int | time | |||
) | [virtual] |
Called before the first event of a file is read, but you should prefer Initialize() for general initialization. This method will be called once for each input file.
Reimplemented in Analyzer, Analyzer, MyTestLoop, and TRootanaDisplay.
Definition at line 121 of file TRootanaEventLoop.cxx.
Referenced by ProcessMidasFile().
bool TRootanaEventLoop::CheckEventID | ( | int | eventId | ) |
Little helper method to check if EventID matchs requested EventID list.
Definition at line 135 of file TRootanaEventLoop.cxx.
References fProcessEventIDs.
Referenced by ProcessMidasFile().
00135 { 00136 00137 // If we didn't specify list of accepted IDs, then accept all. 00138 if(fProcessEventIDs.size()==0) return true; 00139 00140 // Otherwise check event ID against list 00141 for(unsigned int i = 0; i < fProcessEventIDs.size(); i++){ 00142 if(fProcessEventIDs[i] == (eventId & 0xFFFF)) 00143 return true; 00144 } 00145 00146 return false; 00147 }
bool TRootanaEventLoop::CheckOption | ( | std::string | option | ) | [virtual] |
Check an option and return true if it is valid. The return value is used to flag errors during option handling. If the options are valid, then CheckOption should return true to indicate success. If there is a problem processing the options, then CheckOption should return false. If this returns false, then the event loop will print the Usage message and exit with a non zero value (i.e. indicate failure).
Reimplemented in MyTestLoop.
Definition at line 131 of file TRootanaEventLoop.cxx.
Referenced by ExecuteLoop().
bool TRootanaEventLoop::CheckOptionRAD | ( | std::string | option | ) | [protected, virtual] |
This is a special version of CheckOption that is only used by TRootanaDisplay. This is just so that users still have the ability to set options for executables derived from TRootanaDisplay.
Reimplemented in TRootanaDisplay.
Definition at line 132 of file TRootanaEventLoop.cxx.
Referenced by ExecuteLoop().
void TRootanaEventLoop::CloseRootFile | ( | ) |
Cloe output ROOT file.
Definition at line 456 of file TRootanaEventLoop.cxx.
References fOutputFile.
Referenced by ProcessMidasFile(), TRootanaDisplay::QuitButtonAction(), and ~TRootanaEventLoop().
00456 { 00457 00458 if(fOutputFile) { 00459 std::cout << "Closing ROOT file " << std::endl; 00460 fOutputFile->Write(); 00461 fOutputFile->Close(); 00462 fOutputFile=0; 00463 } 00464 00465 }
bool TRootanaEventLoop::CreateOutputFile | ( | std::string | name, | |
std::string | options = "RECREATE" | |||
) | [inline, protected] |
Definition at line 198 of file TRootanaEventLoop.hxx.
References fOutputFile.
00198 { 00199 00200 fOutputFile = new TFile(name.c_str(),options.c_str()); 00201 00202 return true; 00203 }
static void TRootanaEventLoop::CreateSingleton | ( | ) | [inline, static] |
This static templated function will make it a little easier for users to create the singleton instance.
Definition at line 125 of file TRootanaEventLoop.hxx.
References fTRootanaEventLoop.
00126 { 00127 if(fTRootanaEventLoop) 00128 std::cout << "Singleton has already been created" << std::endl; 00129 else 00130 fTRootanaEventLoop = new T(); 00131 }
void TRootanaEventLoop::DisableAutoMainWindow | ( | ) | [inline] |
Disable automatic creation of MainWindow.
Definition at line 135 of file TRootanaEventLoop.hxx.
References fCreateMainWindow.
00135 { fCreateMainWindow = false;}
void TRootanaEventLoop::DisableRootOutput | ( | bool | disable = true |
) | [inline] |
Definition at line 157 of file TRootanaEventLoop.hxx.
References fDisableRootOutput.
Referenced by MyTestLoop::MyTestLoop().
00157 {fDisableRootOutput = disable;};
void TRootanaEventLoop::EndRun | ( | int | transition, | |
int | run, | |||
int | time | |||
) | [virtual] |
Called after the last event of a file is read, but you should prefer Finalize() for general finalization. This method will be called once for each input file.
Reimplemented in Analyzer, MyTestLoop, and TRootanaDisplay.
Definition at line 123 of file TRootanaEventLoop.cxx.
Referenced by ProcessMidasFile().
int TRootanaEventLoop::ExecuteLoop | ( | int | argc, | |
char * | argv[] | |||
) |
Method to actually process the Midas information, either as file or online.
Definition at line 177 of file TRootanaEventLoop.cxx.
References TDirectory::cd(), CheckOption(), CheckOptionRAD(), fApp, fBufferName, fCreateMainWindow, Finalize(), fIsOffline, fMaxEvents, fOnlineHistDir, fUseBatchMode, Initialize(), PrintHelp(), ProcessMidasFile(), and StartNetDirectoryServer().
Referenced by main().
00177 { 00178 00179 setbuf(stdout,NULL); 00180 setbuf(stderr,NULL); 00181 00182 signal(SIGILL, SIG_DFL); 00183 signal(SIGBUS, SIG_DFL); 00184 signal(SIGSEGV, SIG_DFL); 00185 00186 std::vector<std::string> args; 00187 for (int i=0; i<argc; i++) 00188 { 00189 if (strcmp(argv[i],"-h")==0) 00190 PrintHelp(); // does not return 00191 args.push_back(argv[i]); 00192 } 00193 00194 00195 if(fUseBatchMode){ // Disable creating extra window if batch mode requested. 00196 fCreateMainWindow = false; 00197 } 00198 00199 if(gROOT->IsBatch() && !fUseBatchMode) { 00200 printf("Cannot run in batch mode\n"); 00201 return 1; 00202 } 00203 00204 bool forceEnableGraphics = false; 00205 bool testMode = false; 00206 int tcpPort = 0; 00207 int rhttpdPort = 0; // ROOT THttpServer port 00208 const char* hostname = NULL; 00209 const char* exptname = NULL; 00210 00211 for (unsigned int i=1; i<args.size(); i++) // loop over the commandline options 00212 { 00213 const char* arg = args[i].c_str(); 00214 //printf("argv[%d] is %s\n",i,arg); 00215 00216 if (strncmp(arg,"-e",2)==0) // Event cutoff flag (only applicable in offline mode) 00217 fMaxEvents = atoi(arg+2); 00218 else if (strncmp(arg,"-m",2)==0) // Enable memory debugging 00219 ;// gEnableShowMem = true; 00220 else if (strncmp(arg,"-P",2)==0) // Set the histogram server port 00221 tcpPort = atoi(arg+2); 00222 #ifdef HAVE_THTTP_SERVER 00223 else if (strncmp(arg,"-r",2)==0) // Set the THttpdServer port 00224 rhttpdPort = atoi(arg+2); 00225 #endif 00226 else if (strcmp(arg,"-T")==0) 00227 testMode = true; 00228 else if (strcmp(arg,"-g")==0) 00229 forceEnableGraphics = true; 00230 else if (strncmp(arg,"-H",2)==0) 00231 hostname = strdup(arg+2); 00232 else if (strncmp(arg,"-E",2)==0) 00233 exptname = strdup(arg+2); 00234 else if (strncmp(arg,"-b",2)==0){ 00235 fBufferName = std::string(arg+2); 00236 }else if (strcmp(arg,"-h")==0) 00237 PrintHelp(); // does not return 00238 else if(arg[0] == '-')// Check if a TRootanaDisplay or user-defined options 00239 if(!CheckOptionRAD(args[i])) 00240 if(!CheckOption(args[i])) 00241 PrintHelp(); // does not return 00242 } 00243 00244 // Do quick check if we are processing online or offline. 00245 // Want to know before we initialize. 00246 fIsOffline = false; 00247 for (unsigned int i=1; i<args.size(); i++){ 00248 const char* arg = args[i].c_str(); 00249 if (arg[0] != '-') 00250 { 00251 fIsOffline = true; 00252 } 00253 } 00254 00255 00256 MainWindow *mainWindow=0; 00257 if(fCreateMainWindow){ 00258 std::cout << "Create main window! " << std::endl; 00259 mainWindow = new MainWindow(gClient->GetRoot(), 200, 300); 00260 } 00261 00262 gROOT->cd(); 00263 fOnlineHistDir = new TDirectory("rootana", "rootana online plots"); 00264 00265 #ifdef HAVE_LIBNETDIRECTORY 00266 if (tcpPort) 00267 StartNetDirectoryServer(tcpPort, fOnlineHistDir); 00268 #else 00269 if (tcpPort) 00270 fprintf(stderr,"ERROR: No support for the TNetDirectory server!\n"); 00271 #endif 00272 00273 #ifdef HAVE_THTTP_SERVER 00274 00275 THttpServer *root_http_serv; // = new THttpServer("http:8080"); 00276 if(rhttpdPort){ 00277 char address[100]; 00278 sprintf(address,"http:%i",rhttpdPort); 00279 root_http_serv = new THttpServer(address); 00280 } 00281 #endif 00282 00283 // Initialize the event loop with user initialization. 00284 Initialize(); 00285 00286 for (unsigned int i=1; i<args.size(); i++){ 00287 const char* arg = args[i].c_str(); 00288 if (arg[0] != '-') 00289 { 00290 ProcessMidasFile(fApp,arg); 00291 } 00292 } 00293 00294 if (testMode){ 00295 std::cout << "Entering test mode." << std::endl; 00296 fOnlineHistDir->cd(); 00297 TH1D* hh = new TH1D("test", "test", 100, 0, 100); 00298 hh->Fill(1); 00299 hh->Fill(10); 00300 hh->Fill(50); 00301 00302 fApp->Run(kTRUE); 00303 if(fCreateMainWindow) delete mainWindow; 00304 return 0; 00305 } 00306 00307 // if we processed some data files, 00308 // do not go into online mode. 00309 if (fIsOffline){ 00310 if(fCreateMainWindow) delete mainWindow; 00311 return 0; 00312 } 00313 00314 #ifdef HAVE_MIDAS 00315 ProcessMidasOnline(fApp, hostname, exptname);; 00316 #endif 00317 00318 if(fCreateMainWindow) delete mainWindow; 00319 00320 Finalize(); 00321 00322 return 0; 00323 00324 }
void TRootanaEventLoop::Finalize | ( | ) | [virtual] |
Called after the last event has been processed, but before any open output files are closed.
Definition at line 125 of file TRootanaEventLoop.cxx.
Referenced by ExecuteLoop().
TRootanaEventLoop & TRootanaEventLoop::Get | ( | void | ) | [static] |
Definition at line 72 of file TRootanaEventLoop.cxx.
References fTRootanaEventLoop.
Referenced by main().
00072 { 00073 00074 if(!fTRootanaEventLoop){ 00075 std::cerr << "Singleton Not Instantiated! " 00076 << " Need to call something like SomeClass::CreateSingleton<SomeClass>(); Exiting!" 00077 <<std::endl; exit(0); 00078 } 00079 return *fTRootanaEventLoop; 00080 }
int TRootanaEventLoop::GetCurrentRunNumber | ( | ) | const [inline] |
Current Run Number.
Definition at line 107 of file TRootanaEventLoop.hxx.
References fCurrentRunNumber.
Referenced by MyTestLoop::ProcessMidasEvent(), TRootanaDisplay::QuitButtonAction(), and TRootanaDisplay::UpdatePlotsAction().
00107 {return fCurrentRunNumber;};
TDataContainer* TRootanaEventLoop::GetDataContainer | ( | ) | [inline] |
Method to get the data container that event loop owns.
Definition at line 49 of file TRootanaEventLoop.hxx.
References fDataContainer.
00049 {return fDataContainer;};
VirtualOdb* TRootanaEventLoop::GetODB | ( | ) | [inline] |
Get pointer to ODB variables.
Definition at line 141 of file TRootanaEventLoop.hxx.
References fODB.
00141 {return fODB;}
bool TRootanaEventLoop::GetSuppressTimestampWarnings | ( | ) | [inline] |
Suppress timestamp warnings? true = suppress warnings.
Definition at line 189 of file TRootanaEventLoop.hxx.
References fSuppressTimestampWarnings.
00189 { return fSuppressTimestampWarnings;};
void TRootanaEventLoop::Initialize | ( | void | ) | [virtual] |
Called after the arguments are processes but before reading the first event is read
Reimplemented in Analyzer, Analyzer, and TRootanaDisplay.
Definition at line 119 of file TRootanaEventLoop.cxx.
Referenced by ExecuteLoop().
bool TRootanaEventLoop::IsOffline | ( | ) | const [inline] |
Are we processing offline data?
Definition at line 104 of file TRootanaEventLoop.hxx.
References fIsOffline.
Referenced by TRootanaDisplay::InitializeMainWindow().
00104 {return fIsOffline;};
bool TRootanaEventLoop::IsOnline | ( | ) | const [inline] |
Are we processing online data?
Definition at line 101 of file TRootanaEventLoop.hxx.
References fIsOffline.
Referenced by TRootanaDisplay::InitializeMainWindow(), TRootanaDisplay::ProcessMidasEvent(), TRootanaDisplay::QuitButtonAction(), and TRootanaDisplay::UpdatePlotsAction().
00101 {return !fIsOffline;};
bool TRootanaEventLoop::IsRootFileValid | ( | ) | [inline] |
Check if output ROOT file is valid and open.
Definition at line 151 of file TRootanaEventLoop.hxx.
References fOutputFile.
00151 { 00152 if(fOutputFile) return true; 00153 return false; 00154 }
int TRootanaEventLoop::IsRootOutputEnabled | ( | ) | [inline] |
Definition at line 159 of file TRootanaEventLoop.hxx.
References fDisableRootOutput.
00159 {return !fDisableRootOutput;};
void TRootanaEventLoop::OpenRootFile | ( | int | run, | |
std::string | midasFilename = std::string("") | |||
) |
Open output ROOT file.
Definition at line 422 of file TRootanaEventLoop.cxx.
References fDisableRootOutput, fOutputFile, fOutputFilename, NetDirectoryExport(), and SetFullOutputFileName().
Referenced by ProcessMidasFile().
00422 { 00423 00424 if(fDisableRootOutput) return; 00425 00426 if(fOutputFile) { 00427 fOutputFile->Write(); 00428 fOutputFile->Close(); 00429 fOutputFile=0; 00430 } 00431 00432 char filename[1024]; 00433 // This is the default filename, using fOutputFilename 00434 sprintf(filename, "%s%08d.root",fOutputFilename.c_str(), run); 00435 00436 // See if user has implemented a function where they specify 00437 // the root file name using the midas file name... 00438 // Only works offline, because we need midas file name 00439 if(midasFilename.compare("") != 0){ 00440 std::string fullname = SetFullOutputFileName(run,midasFilename); 00441 if(fullname.compare("") != 0){ 00442 sprintf(filename, "%s",fullname.c_str()); 00443 } 00444 } 00445 00446 fOutputFile = new TFile(filename,"RECREATE"); 00447 std::cout << "Opened output file with name : " << filename << std::endl; 00448 00449 00450 #ifdef HAVE_LIBNETDIRECTORY 00451 NetDirectoryExport(fOutputFile, "outputFile"); 00452 #endif 00453 }
virtual bool TRootanaEventLoop::PreFilter | ( | TDataContainer & | dataContainer | ) | [inline, virtual] |
The PreFilter method allows user to specify whether to ignore a particular event. Specifically, if PreFilter returns
true -> then ProcessMidasEvent will be called or false -> then ProcessMidasEvent will not be called
This is particularly useful for the RootanaDisplay, where you might want to only process and plot certain events.
Definition at line 98 of file TRootanaEventLoop.hxx.
Referenced by ProcessMidasFile().
void TRootanaEventLoop::PrintHelp | ( | ) | [private] |
Help Message.
Definition at line 149 of file TRootanaEventLoop.cxx.
References Usage(), and UsageRAD().
Referenced by ExecuteLoop().
00149 { 00150 00151 printf("\nUsage:\n"); 00152 printf("\n./analyzer.exe [-h] [-Hhostname] [-Eexptname] [-eMaxEvents] [-P9091] [-p9090] [-m] [-g] [file1 file2 ...]\n"); 00153 printf("\n"); 00154 printf("\t-h: print this help message\n"); 00155 printf("\t-T: test mode - start and serve a test histogram\n"); 00156 printf("\t-Hhostname: connect to MIDAS experiment on given host\n"); 00157 printf("\t-Eexptname: connect to this MIDAS experiment\n"); 00158 printf("\t-bbuffer: connect to this MIDAS buffer\n"); 00159 printf("\t-P: Start the TNetDirectory server on specified tcp port (for use with roody -Plocalhost:9091)\n"); 00160 printf("\t-p: Start the old midas histogram server on specified tcp port (for use with roody -Hlocalhost:9090)\n"); 00161 #ifdef HAVE_THTTP_SERVER 00162 printf("\t-r: Start THttpServer on specified tcp port\n"); 00163 #endif 00164 printf("\t-eXXX: Number of events XXX to read from input data files\n"); 00165 //printf("\t-m: Enable memory leak debugging\n"); 00166 printf("\t-g: Enable graphics display when processing data files\n"); 00167 UsageRAD(); // Print description of TRootanaDisplay options. 00168 Usage(); // Print description of user options. 00169 printf("\n"); 00170 printf("Example1: analyze online data: ./analyzer.exe -P9091\n"); 00171 printf("Example2: analyze existing data: ./analyzer.exe /data/alpha/current/run00500.mid\n"); 00172 00173 exit(1); 00174 }
virtual bool TRootanaEventLoop::ProcessMidasEvent | ( | TDataContainer & | dataContainer | ) | [pure virtual] |
The main method, called for each event. Users must implement this function!
Implemented in Analyzer, Analyzer, MyTestLoop, and TRootanaDisplay.
Referenced by ProcessMidasFile().
int TRootanaEventLoop::ProcessMidasFile | ( | TApplication * | app, | |
const char * | fname | |||
) |
Treat the begin run and end run events differently.
Definition at line 328 of file TRootanaEventLoop.cxx.
References BeginRun(), CheckEventID(), TDataContainer::CleanupEvent(), TMidasFile::Close(), CloseRootFile(), EndRun(), fCurrentRunNumber, fDataContainer, fMaxEvents, fODB, TMidasEvent::GetData(), TMidasEvent::GetSerialNumber(), gUseOnlyRecent, TMidasFile::Open(), OpenRootFile(), PreFilter(), PrintCurrentStats(), ProcessMidasEvent(), raTotalEventsProcessed, raTotalEventsSkippedForAge, TMidasFile::Read(), and TDataContainer::SetMidasEventPointer().
Referenced by ExecuteLoop().
00329 { 00330 TMidasFile f; 00331 bool tryOpen = f.Open(fname); 00332 00333 if (!tryOpen){ 00334 printf("Cannot open input file \"%s\"\n",fname); 00335 return -1; 00336 } 00337 00338 // This parameter is irrelevant for offline processing. 00339 gUseOnlyRecent = false; 00340 00341 int i=0; 00342 while (1) 00343 { 00344 TMidasEvent event; 00345 if (!f.Read(&event)) 00346 break; 00347 00348 /// Treat the begin run and end run events differently. 00349 int eventId = event.GetEventId(); 00350 00351 00352 00353 if ((eventId & 0xFFFF) == 0x8000){// begin run event 00354 00355 event.Print(); 00356 00357 // Load ODB contents from the ODB XML file 00358 if (fODB) delete fODB; 00359 fODB = new XmlOdb(event.GetData(),event.GetDataSize()); 00360 00361 fCurrentRunNumber = event.GetSerialNumber(); 00362 OpenRootFile(fCurrentRunNumber,fname); 00363 BeginRun(0,event.GetSerialNumber(),0); 00364 raTotalEventsProcessed = 0; 00365 raTotalEventsSkippedForAge = 0; 00366 00367 } else if ((eventId & 0xFFFF) == 0x8001){// end run event 00368 00369 event.Print(); 00370 //EndRun(0,fCurrentRunNumber,0); 00371 00372 00373 } else if ((eventId & 0xFFFF) == 0x8002){ 00374 00375 event.Print(); 00376 printf("Log message: %s\n", event.GetData()); 00377 00378 }else if(CheckEventID(eventId)){ // all other events; check that this event ID should be processed. 00379 00380 // Set the bank list for midas event. 00381 event.SetBankList(); 00382 00383 // Set the midas event pointer in the physics event. 00384 fDataContainer->SetMidasEventPointer(event); 00385 00386 //ProcessEvent if prefilter is satisfied... 00387 if(PreFilter(*fDataContainer)) 00388 ProcessMidasEvent(*fDataContainer); 00389 00390 // Cleanup the information for this event. 00391 fDataContainer->CleanupEvent(); 00392 00393 } 00394 00395 PrintCurrentStats(); 00396 00397 // Check if we have processed desired number of events. 00398 i++; 00399 if ((fMaxEvents!=0)&&(i>=fMaxEvents)){ 00400 printf("Reached event %d, exiting loop.\n",i); 00401 break; 00402 } 00403 } 00404 00405 f.Close(); 00406 00407 EndRun(0,fCurrentRunNumber,0); 00408 CloseRootFile(); 00409 00410 // start the ROOT GUI event loop 00411 // app->Run(kTRUE); 00412 00413 return 0; 00414 }
void TRootanaEventLoop::ProcessThisEventID | ( | int | eventID | ) | [inline] |
Provide a way to force program to only process certain event IDs. This method can be called repeatedly to specify several different event IDs to accept. If the method is not called then all eventIDs are accepted.
Definition at line 177 of file TRootanaEventLoop.hxx.
References fProcessEventIDs.
00177 { 00178 fProcessEventIDs.push_back(eventID); 00179 };
void TRootanaEventLoop::SetCurrentRunNumber | ( | int | run | ) | [inline] |
Current Run Number.
Definition at line 110 of file TRootanaEventLoop.hxx.
References fCurrentRunNumber.
00110 {fCurrentRunNumber = run;};
virtual std::string TRootanaEventLoop::SetFullOutputFileName | ( | int | run, | |
std::string | midasFilename | |||
) | [inline, virtual] |
This is an alternative, more complicated way of setting the output ROOT filename. In this case the user is given the run number and the midas file name and, from that information, constructs the output ROOT filename themselves.
Reimplemented in Analyzer.
Definition at line 168 of file TRootanaEventLoop.hxx.
Referenced by OpenRootFile().
void TRootanaEventLoop::SetOnlineName | ( | std::string | name | ) | [inline] |
Definition at line 172 of file TRootanaEventLoop.hxx.
References fOnlineName.
00172 {fOnlineName = name;};
void TRootanaEventLoop::SetOutputFilename | ( | std::string | name | ) | [inline] |
Set the output filename. File name will be XXX.root, where XXX is run number
Definition at line 163 of file TRootanaEventLoop.hxx.
References fOutputFilename.
Referenced by MyTestLoop::MyTestLoop().
00163 {fOutputFilename = name;};
void TRootanaEventLoop::SuppressTimestampWarnings | ( | ) | [inline] |
Suppress the warning methods regarding old timestamp events for online ie warnings about analyzer falling behind data taking.
Definition at line 186 of file TRootanaEventLoop.hxx.
References fSuppressTimestampWarnings.
00186 { fSuppressTimestampWarnings = true;};
void TRootanaEventLoop::Usage | ( | void | ) | [virtual] |
Called when there is a usage error. This code should print a usage message and then return.
Reimplemented in MyTestLoop.
Definition at line 127 of file TRootanaEventLoop.cxx.
Referenced by PrintHelp().
void TRootanaEventLoop::UsageRAD | ( | void | ) | [protected, virtual] |
Also a special version of usage for TRootanaDisplay. See CheckOptionRAD.
Reimplemented in TRootanaDisplay.
Definition at line 128 of file TRootanaEventLoop.cxx.
Referenced by PrintHelp().
void TRootanaEventLoop::UseBatchMode | ( | ) | [inline] |
Use a batch mode, where we don't check ROOT status.
Definition at line 138 of file TRootanaEventLoop.hxx.
References fUseBatchMode.
00138 { fUseBatchMode = true;}
void TRootanaEventLoop::UseOnlyRecent | ( | bool | setting = true |
) |
Method to set whether analyzer should operate in GET_RECENT mode, where we only process data that is less than 1 second old (this is not default). Setting true will use this option.
Definition at line 416 of file TRootanaEventLoop.cxx.
References gUseOnlyRecent.
00416 { 00417 00418 gUseOnlyRecent = setting; 00419 };
TApplication* TRootanaEventLoop::fApp [private] |
Definition at line 274 of file TRootanaEventLoop.hxx.
Referenced by ExecuteLoop(), and TRootanaEventLoop().
std::string TRootanaEventLoop::fBufferName [private] |
Buffer to connect to.
Definition at line 261 of file TRootanaEventLoop.hxx.
Referenced by ExecuteLoop(), and TRootanaEventLoop().
bool TRootanaEventLoop::fCreateMainWindow [private] |
Definition at line 277 of file TRootanaEventLoop.hxx.
Referenced by DisableAutoMainWindow(), ExecuteLoop(), and TRootanaEventLoop().
int TRootanaEventLoop::fCurrentRunNumber [private] |
Current run number.
Definition at line 244 of file TRootanaEventLoop.hxx.
Referenced by GetCurrentRunNumber(), ProcessMidasFile(), SetCurrentRunNumber(), and TRootanaEventLoop().
TDataContainer* TRootanaEventLoop::fDataContainer [private] |
Pointer to the physics event; the physics event is what we pass to user. The midas event is accessible through physics event. We make a single instance of the physics event for whole execution, because sometimes the decoded information needs to persist across multiple midas events.
Definition at line 252 of file TRootanaEventLoop.hxx.
Referenced by GetDataContainer(), ProcessMidasFile(), and TRootanaEventLoop().
bool TRootanaEventLoop::fDisableRootOutput [private] |
Variable for disabling/enabling Root output.
Definition at line 235 of file TRootanaEventLoop.hxx.
Referenced by DisableRootOutput(), IsRootOutputEnabled(), OpenRootFile(), and TRootanaEventLoop().
bool TRootanaEventLoop::fIsOffline [private] |
Are we processing offline or online data?
Definition at line 241 of file TRootanaEventLoop.hxx.
Referenced by ExecuteLoop(), IsOffline(), IsOnline(), and TRootanaEventLoop().
int TRootanaEventLoop::fMaxEvents [private] |
Definition at line 271 of file TRootanaEventLoop.hxx.
Referenced by ExecuteLoop(), ProcessMidasFile(), and TRootanaEventLoop().
VirtualOdb* TRootanaEventLoop::fODB [private] |
Pointer to the ODB access instance.
Definition at line 238 of file TRootanaEventLoop.hxx.
Referenced by GetODB(), ProcessMidasFile(), TRootanaEventLoop(), and ~TRootanaEventLoop().
TDirectory* TRootanaEventLoop::fOnlineHistDir [protected] |
TDirectory for online histograms.
Definition at line 212 of file TRootanaEventLoop.hxx.
Referenced by ExecuteLoop(), MyTestLoop::ProcessMidasEvent(), and TRootanaEventLoop().
std::string TRootanaEventLoop::fOnlineName [private] |
Name of program, as seen by MIDAS.
Definition at line 264 of file TRootanaEventLoop.hxx.
Referenced by SetOnlineName(), and TRootanaEventLoop().
TFile* TRootanaEventLoop::fOutputFile [private] |
Output ROOT file.
Definition at line 228 of file TRootanaEventLoop.hxx.
Referenced by CloseRootFile(), CreateOutputFile(), IsRootFileValid(), OpenRootFile(), and TRootanaEventLoop().
std::string TRootanaEventLoop::fOutputFilename [private] |
Base part of the output filename File name will be XXX.root, where XXX is run number
Definition at line 232 of file TRootanaEventLoop.hxx.
Referenced by OpenRootFile(), SetOutputFilename(), and TRootanaEventLoop().
std::vector<int> TRootanaEventLoop::fProcessEventIDs [private] |
This is the set of eventIDs to process.
Definition at line 255 of file TRootanaEventLoop.hxx.
Referenced by CheckEventID(), and ProcessThisEventID().
bool TRootanaEventLoop::fSuppressTimestampWarnings [private] |
Bool for suppressing the warnings about old timestamps.
Definition at line 267 of file TRootanaEventLoop.hxx.
Referenced by GetSuppressTimestampWarnings(), SuppressTimestampWarnings(), and TRootanaEventLoop().
TRootanaEventLoop * TRootanaEventLoop::fTRootanaEventLoop = NULL [static, protected] |
The static pointer to the singleton instance.
Definition at line 209 of file TRootanaEventLoop.hxx.
Referenced by CreateSingleton(), and Get().
bool TRootanaEventLoop::fUseBatchMode [private] |
Definition at line 280 of file TRootanaEventLoop.hxx.
Referenced by ExecuteLoop(), TRootanaEventLoop(), and UseBatchMode().