Public Member Functions | |
Analyzer () | |
virtual | ~Analyzer () |
void | Initialize () |
void | Init () |
void | BeginRun (int transition, int run, int time) |
bool | ProcessMidasEvent (TDataContainer &dataContainer) |
Analyzer () | |
virtual | ~Analyzer () |
void | Initialize () |
void | BeginRun (int transition, int run, int time) |
void | EndRun (int transition, int run, int time) |
bool | ProcessMidasEvent (TDataContainer &dataContainer) |
std::string | SetFullOutputFileName (int run, std::string midasFilename) |
TDataContainer * | GetDataContainer () |
Method to get the data container that event loop owns. | |
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) |
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 () |
Public Attributes | |
TAnaManager * | anaManager |
TTree * | fTree |
Protected Member Functions | |
bool | CreateOutputFile (std::string name, std::string options="RECREATE") |
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. |
Definition at line 14 of file ana.cxx.
Analyzer::Analyzer | ( | ) | [inline] |
Definition at line 25 of file ana.cxx.
References anaManager.
00025 { 00026 //DisableAutoMainWindow(); 00027 00028 anaManager = 0; 00029 00030 };
Analyzer::Analyzer | ( | ) | [inline] |
Definition at line 40 of file midas2root.cxx.
virtual Analyzer::~Analyzer | ( | ) | [inline, virtual] |
Definition at line 44 of file midas2root.cxx.
void Analyzer::BeginRun | ( | int | transition, | |
int | run, | |||
int | time | |||
) | [inline, 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 from TRootanaEventLoop.
Definition at line 52 of file midas2root.cxx.
References fTree.
void Analyzer::BeginRun | ( | int | transition, | |
int | run, | |||
int | time | |||
) | [inline, 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 from TRootanaEventLoop.
Definition at line 47 of file ana.cxx.
References Init().
00047 { 00048 00049 Init(); 00050 00051 }
bool TRootanaEventLoop::CheckEventID | ( | int | eventId | ) | [inherited] |
Little helper method to check if EventID matchs requested EventID list.
Definition at line 135 of file TRootanaEventLoop.cxx.
References TRootanaEventLoop::fProcessEventIDs.
Referenced by TRootanaEventLoop::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, inherited] |
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 TRootanaEventLoop::ExecuteLoop().
bool TRootanaEventLoop::CheckOptionRAD | ( | std::string | option | ) | [protected, virtual, inherited] |
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 TRootanaEventLoop::ExecuteLoop().
void TRootanaEventLoop::CloseRootFile | ( | ) | [inherited] |
Cloe output ROOT file.
Definition at line 456 of file TRootanaEventLoop.cxx.
References TRootanaEventLoop::fOutputFile.
Referenced by TRootanaEventLoop::ProcessMidasFile(), TRootanaDisplay::QuitButtonAction(), and TRootanaEventLoop::~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, inherited] |
Definition at line 198 of file TRootanaEventLoop.hxx.
References TRootanaEventLoop::fOutputFile.
00198 { 00199 00200 fOutputFile = new TFile(name.c_str(),options.c_str()); 00201 00202 return true; 00203 }
static void TRootanaEventLoop::CreateSingleton | ( | ) | [inline, static, inherited] |
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 TRootanaEventLoop::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, inherited] |
Disable automatic creation of MainWindow.
Definition at line 135 of file TRootanaEventLoop.hxx.
References TRootanaEventLoop::fCreateMainWindow.
00135 { fCreateMainWindow = false;}
void TRootanaEventLoop::DisableRootOutput | ( | bool | disable = true |
) | [inline, inherited] |
Definition at line 157 of file TRootanaEventLoop.hxx.
References TRootanaEventLoop::fDisableRootOutput.
Referenced by MyTestLoop::MyTestLoop().
00157 {fDisableRootOutput = disable;};
void Analyzer::EndRun | ( | int | transition, | |
int | run, | |||
int | time | |||
) | [inline, 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 from TRootanaEventLoop.
Definition at line 65 of file midas2root.cxx.
int TRootanaEventLoop::ExecuteLoop | ( | int | argc, | |
char * | argv[] | |||
) | [inherited] |
Method to actually process the Midas information, either as file or online.
Definition at line 177 of file TRootanaEventLoop.cxx.
References TDirectory::cd(), TRootanaEventLoop::CheckOption(), TRootanaEventLoop::CheckOptionRAD(), TRootanaEventLoop::fApp, TRootanaEventLoop::fBufferName, TRootanaEventLoop::fCreateMainWindow, TRootanaEventLoop::Finalize(), TRootanaEventLoop::fIsOffline, TRootanaEventLoop::fMaxEvents, TRootanaEventLoop::fOnlineHistDir, TRootanaEventLoop::fUseBatchMode, TRootanaEventLoop::Initialize(), TRootanaEventLoop::PrintHelp(), TRootanaEventLoop::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, inherited] |
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 TRootanaEventLoop::ExecuteLoop().
TRootanaEventLoop & TRootanaEventLoop::Get | ( | void | ) | [static, inherited] |
Definition at line 72 of file TRootanaEventLoop.cxx.
References TRootanaEventLoop::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, inherited] |
Current Run Number.
Definition at line 107 of file TRootanaEventLoop.hxx.
References TRootanaEventLoop::fCurrentRunNumber.
Referenced by MyTestLoop::ProcessMidasEvent(), TRootanaDisplay::QuitButtonAction(), and TRootanaDisplay::UpdatePlotsAction().
00107 {return fCurrentRunNumber;};
TDataContainer* TRootanaEventLoop::GetDataContainer | ( | ) | [inline, inherited] |
Method to get the data container that event loop owns.
Definition at line 49 of file TRootanaEventLoop.hxx.
References TRootanaEventLoop::fDataContainer.
00049 {return fDataContainer;};
VirtualOdb* TRootanaEventLoop::GetODB | ( | ) | [inline, inherited] |
Get pointer to ODB variables.
Definition at line 141 of file TRootanaEventLoop.hxx.
References TRootanaEventLoop::fODB.
00141 {return fODB;}
bool TRootanaEventLoop::GetSuppressTimestampWarnings | ( | ) | [inline, inherited] |
Suppress timestamp warnings? true = suppress warnings.
Definition at line 189 of file TRootanaEventLoop.hxx.
References TRootanaEventLoop::fSuppressTimestampWarnings.
00189 { return fSuppressTimestampWarnings;};
void Analyzer::Init | ( | ) | [inline] |
Definition at line 39 of file ana.cxx.
References anaManager.
Referenced by BeginRun(), and ProcessMidasEvent().
00039 { 00040 00041 if(anaManager) 00042 delete anaManager; 00043 anaManager = new TAnaManager(); 00044 }
void Analyzer::Initialize | ( | void | ) | [inline, virtual] |
Called after the arguments are processes but before reading the first event is read
Reimplemented from TRootanaEventLoop.
Definition at line 46 of file midas2root.cxx.
void Analyzer::Initialize | ( | void | ) | [inline, virtual] |
Called after the arguments are processes but before reading the first event is read
Reimplemented from TRootanaEventLoop.
bool TRootanaEventLoop::IsOffline | ( | ) | const [inline, inherited] |
Are we processing offline data?
Definition at line 104 of file TRootanaEventLoop.hxx.
References TRootanaEventLoop::fIsOffline.
Referenced by TRootanaDisplay::InitializeMainWindow().
00104 {return fIsOffline;};
bool TRootanaEventLoop::IsOnline | ( | ) | const [inline, inherited] |
Are we processing online data?
Definition at line 101 of file TRootanaEventLoop.hxx.
References TRootanaEventLoop::fIsOffline.
Referenced by TRootanaDisplay::InitializeMainWindow(), TRootanaDisplay::ProcessMidasEvent(), TRootanaDisplay::QuitButtonAction(), and TRootanaDisplay::UpdatePlotsAction().
00101 {return !fIsOffline;};
bool TRootanaEventLoop::IsRootFileValid | ( | ) | [inline, inherited] |
Check if output ROOT file is valid and open.
Definition at line 151 of file TRootanaEventLoop.hxx.
References TRootanaEventLoop::fOutputFile.
00151 { 00152 if(fOutputFile) return true; 00153 return false; 00154 }
int TRootanaEventLoop::IsRootOutputEnabled | ( | ) | [inline, inherited] |
Definition at line 159 of file TRootanaEventLoop.hxx.
References TRootanaEventLoop::fDisableRootOutput.
00159 {return !fDisableRootOutput;};
void TRootanaEventLoop::OpenRootFile | ( | int | run, | |
std::string | midasFilename = std::string("") | |||
) | [inherited] |
Open output ROOT file.
Definition at line 422 of file TRootanaEventLoop.cxx.
References TRootanaEventLoop::fDisableRootOutput, TRootanaEventLoop::fOutputFile, TRootanaEventLoop::fOutputFilename, NetDirectoryExport(), and TRootanaEventLoop::SetFullOutputFileName().
Referenced by TRootanaEventLoop::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, inherited] |
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 TRootanaEventLoop::ProcessMidasFile().
bool Analyzer::ProcessMidasEvent | ( | TDataContainer & | dataContainer | ) | [inline, virtual] |
The main method, called for each event. Users must implement this function!
Implements TRootanaEventLoop.
Definition at line 73 of file midas2root.cxx.
References fTree, TDataContainer::GetEventData(), TV792Data::GetMeasurements(), TDataContainer::GetMidasEvent(), and TMidasEvent::GetSerialNumber().
00073 { 00074 00075 int id = dataContainer.GetMidasEvent().GetSerialNumber(); 00076 if(id%10 == 0) printf("."); 00077 00078 00079 #ifdef USE_V792 00080 TV792Data *data = dataContainer.GetEventData<TV792Data>("ADC0"); 00081 if(data){ 00082 nchannels = 32; 00083 for(int i = 0; i < nchannels;i++) adc_value[i] = 0; 00084 00085 /// Get the Vector of ADC Measurements. 00086 std::vector<VADCMeasurement> measurements = data->GetMeasurements(); 00087 for(unsigned int i = 0; i < measurements.size(); i++){ // loop over measurements 00088 00089 int chan = measurements[i].GetChannel(); 00090 uint32_t adc = measurements[i].GetMeasurement(); 00091 00092 if(chan >= 0 && chan < nchannels) 00093 adc_value[chan] = adc; 00094 } 00095 } 00096 #endif 00097 00098 fTree->Fill(); 00099 00100 return true; 00101 00102 };
bool Analyzer::ProcessMidasEvent | ( | TDataContainer & | dataContainer | ) | [inline, virtual] |
The main method, called for each event. Users must implement this function!
Implements TRootanaEventLoop.
Definition at line 54 of file ana.cxx.
References anaManager, Init(), and TAnaManager::ProcessMidasEvent().
00054 { 00055 00056 if(!anaManager) Init(); 00057 00058 anaManager->ProcessMidasEvent(dataContainer); 00059 00060 return true; 00061 }
int TRootanaEventLoop::ProcessMidasFile | ( | TApplication * | app, | |
const char * | fname | |||
) | [inherited] |
Treat the begin run and end run events differently.
Definition at line 328 of file TRootanaEventLoop.cxx.
References TRootanaEventLoop::BeginRun(), TRootanaEventLoop::CheckEventID(), TDataContainer::CleanupEvent(), TMidasFile::Close(), TRootanaEventLoop::CloseRootFile(), TRootanaEventLoop::EndRun(), TRootanaEventLoop::fCurrentRunNumber, TRootanaEventLoop::fDataContainer, TRootanaEventLoop::fMaxEvents, TRootanaEventLoop::fODB, TMidasEvent::GetData(), TMidasEvent::GetSerialNumber(), gUseOnlyRecent, TMidasFile::Open(), TRootanaEventLoop::OpenRootFile(), TRootanaEventLoop::PreFilter(), PrintCurrentStats(), TRootanaEventLoop::ProcessMidasEvent(), raTotalEventsProcessed, raTotalEventsSkippedForAge, TMidasFile::Read(), and TDataContainer::SetMidasEventPointer().
Referenced by TRootanaEventLoop::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, inherited] |
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 TRootanaEventLoop::fProcessEventIDs.
00177 { 00178 fProcessEventIDs.push_back(eventID); 00179 };
void TRootanaEventLoop::SetCurrentRunNumber | ( | int | run | ) | [inline, inherited] |
Current Run Number.
Definition at line 110 of file TRootanaEventLoop.hxx.
References TRootanaEventLoop::fCurrentRunNumber.
00110 {fCurrentRunNumber = run;};
std::string Analyzer::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 from TRootanaEventLoop.
Definition at line 105 of file midas2root.cxx.
00106 { 00107 char buff[128]; 00108 Int_t in_num = 0, part = 0; 00109 Int_t num[2] = { 0, 0 }; // run and subrun values 00110 // get run/subrun numbers from file name 00111 for (int i=0; ; ++i) { 00112 char ch = midasFilename[i]; 00113 if (!ch) break; 00114 if (ch == '/') { 00115 // skip numbers in the directory name 00116 num[0] = num[1] = in_num = part = 0; 00117 } else if (ch >= '0' && ch <= '9' && part < 2) { 00118 num[part] = num[part] * 10 + (ch - '0'); 00119 in_num = 1; 00120 } else if (in_num) { 00121 in_num = 0; 00122 ++part; 00123 } 00124 } 00125 if (part == 2) { 00126 if (run != num[0]) { 00127 std::cerr << "File name run number (" << num[0] 00128 << ") disagrees with MIDAS run (" << run << ")" << std::endl; 00129 exit(1); 00130 } 00131 sprintf(buff,"output_%.6d_%.4d.root", run, num[1]); 00132 printf("Using filename %s\n",buff); 00133 } else { 00134 sprintf(buff,"output_%.6d.root", run); 00135 } 00136 return std::string(buff); 00137 };
void TRootanaEventLoop::SetOnlineName | ( | std::string | name | ) | [inline, inherited] |
Definition at line 172 of file TRootanaEventLoop.hxx.
References TRootanaEventLoop::fOnlineName.
00172 {fOnlineName = name;};
void TRootanaEventLoop::SetOutputFilename | ( | std::string | name | ) | [inline, inherited] |
Set the output filename. File name will be XXX.root, where XXX is run number
Definition at line 163 of file TRootanaEventLoop.hxx.
References TRootanaEventLoop::fOutputFilename.
Referenced by MyTestLoop::MyTestLoop().
00163 {fOutputFilename = name;};
void TRootanaEventLoop::SuppressTimestampWarnings | ( | ) | [inline, inherited] |
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 TRootanaEventLoop::fSuppressTimestampWarnings.
00186 { fSuppressTimestampWarnings = true;};
void TRootanaEventLoop::Usage | ( | void | ) | [virtual, inherited] |
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 TRootanaEventLoop::PrintHelp().
void TRootanaEventLoop::UsageRAD | ( | void | ) | [protected, virtual, inherited] |
Also a special version of usage for TRootanaDisplay. See CheckOptionRAD.
Reimplemented in TRootanaDisplay.
Definition at line 128 of file TRootanaEventLoop.cxx.
Referenced by TRootanaEventLoop::PrintHelp().
void TRootanaEventLoop::UseBatchMode | ( | ) | [inline, inherited] |
Use a batch mode, where we don't check ROOT status.
Definition at line 138 of file TRootanaEventLoop.hxx.
References TRootanaEventLoop::fUseBatchMode.
00138 { fUseBatchMode = true;}
void TRootanaEventLoop::UseOnlyRecent | ( | bool | setting = true |
) | [inherited] |
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 };
Definition at line 23 of file ana.cxx.
Referenced by Analyzer(), Init(), and ProcessMidasEvent().
TDirectory* TRootanaEventLoop::fOnlineHistDir [protected, inherited] |
TDirectory for online histograms.
Definition at line 212 of file TRootanaEventLoop.hxx.
Referenced by TRootanaEventLoop::ExecuteLoop(), MyTestLoop::ProcessMidasEvent(), and TRootanaEventLoop::TRootanaEventLoop().
TTree* Analyzer::fTree |
Definition at line 31 of file midas2root.cxx.
Referenced by BeginRun(), and ProcessMidasEvent().
TRootanaEventLoop * TRootanaEventLoop::fTRootanaEventLoop = NULL [static, protected, inherited] |
The static pointer to the singleton instance.
Definition at line 209 of file TRootanaEventLoop.hxx.
Referenced by TRootanaEventLoop::CreateSingleton(), and TRootanaEventLoop::Get().