#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. | |
| VirtualOdb * | GetODB () |
| Get pointer to ODB variables. | |
| void | OpenRootFile (int run) |
| 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. | |
| 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. | |
| VirtualOdb * | GetODB () |
| Get pointer to ODB variables. | |
| void | OpenRootFile (int run) |
| 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. | |
Static Public Member Functions | |
| static TRootanaEventLoop & | Get (void) |
| template<typename T > | |
| static void | CreateSingleton () |
| 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. | |
| 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. | |
| 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 |
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 96 of file TRootanaEventLoop.cxx.
References CloseRootFile(), and fODB.
00096 { 00097 00098 if(fODB) delete fODB; 00099 CloseRootFile(); 00100 00101 }

| TRootanaEventLoop::TRootanaEventLoop | ( | ) | [protected] |
Create the TApplication
Definition at line 71 of file TRootanaEventLoop.cxx.
References fApp, fBufferName, fCreateMainWindow, fCurrentRunNumber, fDataContainer, fDisableRootOutput, fIsOffline, fMaxEvents, fODB, fOnlineHistDir, fOnlineName, fOutputFile, fOutputFilename, and fSuppressTimestampWarnings.
00071 { 00072 00073 fOutputFile = 0; 00074 fOutputFilename = std::string("output"); 00075 fDisableRootOutput = false; 00076 fODB = 0; 00077 fOnlineHistDir = 0; 00078 fMaxEvents = 0; 00079 fCurrentRunNumber = 0; 00080 fIsOffline = true; 00081 00082 fCreateMainWindow = true; 00083 fSuppressTimestampWarnings = false; 00084 00085 fBufferName = std::string("SYSTEM"); 00086 fOnlineName = std::string("rootana"); 00087 00088 fDataContainer = new TDataContainer(); 00089 00090 /// Create the TApplication 00091 char **argv2 = NULL; 00092 fApp = new TApplication("rootana", 0, argv2); 00093 00094 }
| virtual TRootanaEventLoop::~TRootanaEventLoop | ( | ) | [virtual] |
| TRootanaEventLoop::TRootanaEventLoop | ( | ) | [protected] |
| virtual 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, TRootanaDisplay, MyTestLoop, and TRootanaDisplay.
| 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, TRootanaDisplay, MyTestLoop, and TRootanaDisplay.
Definition at line 106 of file TRootanaEventLoop.cxx.
Referenced by ProcessMidasFile().

| bool TRootanaEventLoop::CheckEventID | ( | int | eventId | ) |
Little helper method to check if EventID matchs requested EventID list.
| bool TRootanaEventLoop::CheckEventID | ( | int | eventId | ) |
Little helper method to check if EventID matchs requested EventID list.
Definition at line 120 of file TRootanaEventLoop.cxx.
References fProcessEventIDs.
Referenced by ProcessMidasFile().
00120 { 00121 00122 // If we didn't specify list of accepted IDs, then accept all. 00123 if(fProcessEventIDs.size()==0) return true; 00124 00125 // Otherwise check event ID against list 00126 for(unsigned int i = 0; i < fProcessEventIDs.size(); i++){ 00127 if(fProcessEventIDs[i] == (eventId & 0xFFFF)) 00128 return true; 00129 } 00130 00131 return false; 00132 }

| virtual 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.
| 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 116 of file TRootanaEventLoop.cxx.
Referenced by ExecuteLoop().

| virtual 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, and TRootanaDisplay.
| 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, and TRootanaDisplay.
Definition at line 117 of file TRootanaEventLoop.cxx.
Referenced by ExecuteLoop().

| void TRootanaEventLoop::CloseRootFile | ( | ) |
Cloe output ROOT file.
| void TRootanaEventLoop::CloseRootFile | ( | ) |
Cloe output ROOT file.
Definition at line 397 of file TRootanaEventLoop.cxx.
References fOutputFile.
Referenced by ProcessMidasFile(), TRootanaDisplay::QuitButtonAction(), and ~TRootanaEventLoop().
00397 { 00398 00399 if(fOutputFile) { 00400 std::cout << "Closing ROOT file " << std::endl; 00401 fOutputFile->Write(); 00402 fOutputFile->Close(); 00403 fOutputFile=0; 00404 } 00405 00406 }

| bool TRootanaEventLoop::CreateOutputFile | ( | std::string | name, | |
| std::string | options = "RECREATE" | |||
| ) | [inline, protected] |
Definition at line 184 of file TRootanaEventLoop.hxx.
References fOutputFile.
00184 { 00185 00186 fOutputFile = new TFile(name.c_str(),options.c_str()); 00187 00188 return true; 00189 }
| bool TRootanaEventLoop::CreateOutputFile | ( | std::string | name, | |
| std::string | options = "RECREATE" | |||
| ) | [inline, protected] |
Definition at line 184 of file TRootanaEventLoop.hxx.
References fOutputFile.
00184 { 00185 00186 fOutputFile = new TFile(name.c_str(),options.c_str()); 00187 00188 return true; 00189 }
| 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 }
| 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::DisableAutoMainWindow | ( | ) | [inline] |
Disable automatic creation of MainWindow.
Definition at line 135 of file TRootanaEventLoop.hxx.
References fCreateMainWindow.
Referenced by Analyzer::Analyzer().
00135 { fCreateMainWindow = false;}

| void TRootanaEventLoop::DisableRootOutput | ( | bool | disable = true |
) | [inline] |
Definition at line 154 of file TRootanaEventLoop.hxx.
References fDisableRootOutput.
00154 {fDisableRootOutput = disable;};
| void TRootanaEventLoop::DisableRootOutput | ( | bool | disable = true |
) | [inline] |
Definition at line 154 of file TRootanaEventLoop.hxx.
References fDisableRootOutput.
Referenced by MyTestLoop::MyTestLoop().
00154 {fDisableRootOutput = disable;};

| virtual 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 TRootanaDisplay, MyTestLoop, and TRootanaDisplay.
| 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 TRootanaDisplay, MyTestLoop, and TRootanaDisplay.
Definition at line 108 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.
| int TRootanaEventLoop::ExecuteLoop | ( | int | argc, | |
| char * | argv[] | |||
| ) |
Method to actually process the Midas information, either as file or online.
Definition at line 159 of file TRootanaEventLoop.cxx.
References TDirectory::cd(), CheckOption(), CheckOptionRAD(), fApp, fBufferName, fCreateMainWindow, Finalize(), fIsOffline, fMaxEvents, fOnlineHistDir, Initialize(), PrintHelp(), ProcessMidasFile(), and StartNetDirectoryServer().
Referenced by main().
00159 { 00160 00161 setbuf(stdout,NULL); 00162 setbuf(stderr,NULL); 00163 00164 signal(SIGILL, SIG_DFL); 00165 signal(SIGBUS, SIG_DFL); 00166 signal(SIGSEGV, SIG_DFL); 00167 00168 std::vector<std::string> args; 00169 for (int i=0; i<argc; i++) 00170 { 00171 if (strcmp(argv[i],"-h")==0) 00172 PrintHelp(); // does not return 00173 args.push_back(argv[i]); 00174 } 00175 00176 00177 if(gROOT->IsBatch()) { 00178 printf("Cannot run in batch mode\n"); 00179 return 1; 00180 } 00181 00182 bool forceEnableGraphics = false; 00183 bool testMode = false; 00184 int tcpPort = 0; 00185 const char* hostname = NULL; 00186 const char* exptname = NULL; 00187 00188 for (unsigned int i=1; i<args.size(); i++) // loop over the commandline options 00189 { 00190 const char* arg = args[i].c_str(); 00191 //printf("argv[%d] is %s\n",i,arg); 00192 00193 if (strncmp(arg,"-e",2)==0) // Event cutoff flag (only applicable in offline mode) 00194 fMaxEvents = atoi(arg+2); 00195 else if (strncmp(arg,"-m",2)==0) // Enable memory debugging 00196 ;// gEnableShowMem = true; 00197 else if (strncmp(arg,"-P",2)==0) // Set the histogram server port 00198 tcpPort = atoi(arg+2); 00199 else if (strcmp(arg,"-T")==0) 00200 testMode = true; 00201 else if (strcmp(arg,"-g")==0) 00202 forceEnableGraphics = true; 00203 else if (strncmp(arg,"-H",2)==0) 00204 hostname = strdup(arg+2); 00205 else if (strncmp(arg,"-E",2)==0) 00206 exptname = strdup(arg+2); 00207 else if (strncmp(arg,"-b",2)==0){ 00208 fBufferName = std::string(arg+2); 00209 }else if (strcmp(arg,"-h")==0) 00210 PrintHelp(); // does not return 00211 else if(arg[0] == '-')// Check if a TRootanaDisplay or user-defined options 00212 if(!CheckOptionRAD(args[i])) 00213 if(!CheckOption(args[i])) 00214 PrintHelp(); // does not return 00215 } 00216 00217 // Do quick check if we are processing online or offline. 00218 // Want to know before we initialize. 00219 fIsOffline = false; 00220 for (unsigned int i=1; i<args.size(); i++){ 00221 const char* arg = args[i].c_str(); 00222 if (arg[0] != '-') 00223 { 00224 fIsOffline = true; 00225 } 00226 } 00227 00228 00229 MainWindow *mainWindow=0; 00230 if(fCreateMainWindow){ 00231 mainWindow = new MainWindow(gClient->GetRoot(), 200, 300); 00232 } 00233 00234 gROOT->cd(); 00235 fOnlineHistDir = new TDirectory("rootana", "rootana online plots"); 00236 00237 #ifdef HAVE_LIBNETDIRECTORY 00238 if (tcpPort) 00239 StartNetDirectoryServer(tcpPort, fOnlineHistDir); 00240 #else 00241 if (tcpPort) 00242 fprintf(stderr,"ERROR: No support for the TNetDirectory server!\n"); 00243 #endif 00244 00245 // Initialize the event loop with user initialization. 00246 Initialize(); 00247 00248 for (unsigned int i=1; i<args.size(); i++){ 00249 const char* arg = args[i].c_str(); 00250 if (arg[0] != '-') 00251 { 00252 ProcessMidasFile(fApp,arg); 00253 } 00254 } 00255 00256 if (testMode){ 00257 std::cout << "Entering test mode." << std::endl; 00258 fOnlineHistDir->cd(); 00259 TH1D* hh = new TH1D("test", "test", 100, 0, 100); 00260 hh->Fill(1); 00261 hh->Fill(10); 00262 hh->Fill(50); 00263 00264 fApp->Run(kTRUE); 00265 if(fCreateMainWindow) delete mainWindow; 00266 return 0; 00267 } 00268 00269 // if we processed some data files, 00270 // do not go into online mode. 00271 if (fIsOffline){ 00272 if(fCreateMainWindow) delete mainWindow; 00273 return 0; 00274 } 00275 00276 #ifdef HAVE_MIDAS 00277 ProcessMidasOnline(fApp, hostname, exptname);; 00278 #endif 00279 00280 if(fCreateMainWindow) delete mainWindow; 00281 00282 Finalize(); 00283 00284 return 0; 00285 00286 }


| virtual void TRootanaEventLoop::Finalize | ( | ) | [virtual] |
Called after the last event has been processed, but before any open output files are closed.
| void TRootanaEventLoop::Finalize | ( | ) | [virtual] |
Called after the last event has been processed, but before any open output files are closed.
Definition at line 110 of file TRootanaEventLoop.cxx.
Referenced by ExecuteLoop().

| static TRootanaEventLoop& TRootanaEventLoop::Get | ( | void | ) | [static] |
| TRootanaEventLoop & TRootanaEventLoop::Get | ( | void | ) | [static] |
Definition at line 59 of file TRootanaEventLoop.cxx.
References fTRootanaEventLoop.
Referenced by main().
00059 { 00060 00061 if(!fTRootanaEventLoop){ 00062 std::cerr << "Singleton Not Instantiated! " 00063 << " Need to call something like SomeClass::CreateSingleton<SomeClass>(); Exiting!" 00064 <<std::endl; exit(0); 00065 } 00066 return *fTRootanaEventLoop; 00067 }

| int TRootanaEventLoop::GetCurrentRunNumber | ( | ) | const [inline] |
Current Run Number.
Definition at line 107 of file TRootanaEventLoop.hxx.
References fCurrentRunNumber.
00107 {return fCurrentRunNumber;};
| 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;};
| 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 138 of file TRootanaEventLoop.hxx.
References fODB.
00138 {return fODB;}
| VirtualOdb* TRootanaEventLoop::GetODB | ( | ) | [inline] |
Get pointer to ODB variables.
Definition at line 138 of file TRootanaEventLoop.hxx.
References fODB.
00138 {return fODB;}
| bool TRootanaEventLoop::GetSuppressTimestampWarnings | ( | ) | [inline] |
Suppress timestamp warnings? true = suppress warnings.
Definition at line 179 of file TRootanaEventLoop.hxx.
References fSuppressTimestampWarnings.
00179 { return fSuppressTimestampWarnings;};
| bool TRootanaEventLoop::GetSuppressTimestampWarnings | ( | ) | [inline] |
Suppress timestamp warnings? true = suppress warnings.
Definition at line 179 of file TRootanaEventLoop.hxx.
References fSuppressTimestampWarnings.
00179 { return fSuppressTimestampWarnings;};
| virtual void TRootanaEventLoop::Initialize | ( | void | ) | [virtual] |
Called after the arguments are processes but before reading the first event is read
Reimplemented in Analyzer, TRootanaDisplay, and TRootanaDisplay.
| void TRootanaEventLoop::Initialize | ( | void | ) | [virtual] |
Called after the arguments are processes but before reading the first event is read
Reimplemented in Analyzer, TRootanaDisplay, and TRootanaDisplay.
Definition at line 104 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.
00104 {return fIsOffline;};
| 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.
00101 {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 148 of file TRootanaEventLoop.hxx.
References fOutputFile.
00148 { 00149 if(fOutputFile) return true; 00150 return false; 00151 }
| bool TRootanaEventLoop::IsRootFileValid | ( | ) | [inline] |
Check if output ROOT file is valid and open.
Definition at line 148 of file TRootanaEventLoop.hxx.
References fOutputFile.
00148 { 00149 if(fOutputFile) return true; 00150 return false; 00151 }
| int TRootanaEventLoop::IsRootOutputEnabled | ( | ) | [inline] |
Definition at line 156 of file TRootanaEventLoop.hxx.
References fDisableRootOutput.
00156 {return !fDisableRootOutput;};
| int TRootanaEventLoop::IsRootOutputEnabled | ( | ) | [inline] |
Definition at line 156 of file TRootanaEventLoop.hxx.
References fDisableRootOutput.
00156 {return !fDisableRootOutput;};
| void TRootanaEventLoop::OpenRootFile | ( | int | run | ) |
Open output ROOT file.
| void TRootanaEventLoop::OpenRootFile | ( | int | run | ) |
Open output ROOT file.
Definition at line 375 of file TRootanaEventLoop.cxx.
References fDisableRootOutput, fOutputFile, fOutputFilename, and NetDirectoryExport().
Referenced by ProcessMidasFile().
00375 { 00376 00377 if(fDisableRootOutput) return; 00378 00379 if(fOutputFile) { 00380 fOutputFile->Write(); 00381 fOutputFile->Close(); 00382 fOutputFile=0; 00383 } 00384 00385 char filename[1024]; 00386 sprintf(filename, "%s%05d.root",fOutputFilename.c_str(), run); 00387 fOutputFile = new TFile(filename,"RECREATE"); 00388 std::cout << "Opened output file with name : " << filename << std::endl; 00389 00390 00391 #ifdef HAVE_LIBNETDIRECTORY 00392 NetDirectoryExport(fOutputFile, "outputFile"); 00393 #endif 00394 }


| 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.
| 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.
| void TRootanaEventLoop::PrintHelp | ( | ) | [private] |
Help Message.
Definition at line 134 of file TRootanaEventLoop.cxx.
References Usage(), and UsageRAD().
Referenced by ExecuteLoop().
00134 { 00135 00136 printf("\nUsage:\n"); 00137 printf("\n./analyzer.exe [-h] [-Hhostname] [-Eexptname] [-eMaxEvents] [-P9091] [-p9090] [-m] [-g] [file1 file2 ...]\n"); 00138 printf("\n"); 00139 printf("\t-h: print this help message\n"); 00140 printf("\t-T: test mode - start and serve a test histogram\n"); 00141 printf("\t-Hhostname: connect to MIDAS experiment on given host\n"); 00142 printf("\t-Eexptname: connect to this MIDAS experiment\n"); 00143 printf("\t-bbuffer: connect to this MIDAS buffer\n"); 00144 printf("\t-P: Start the TNetDirectory server on specified tcp port (for use with roody -Plocalhost:9091)\n"); 00145 printf("\t-p: Start the old midas histogram server on specified tcp port (for use with roody -Hlocalhost:9090)\n"); 00146 printf("\t-eXXX: Number of events XXX to read from input data files\n"); 00147 //printf("\t-m: Enable memory leak debugging\n"); 00148 printf("\t-g: Enable graphics display when processing data files\n"); 00149 UsageRAD(); // Print description of TRootanaDisplay options. 00150 Usage(); // Print description of user options. 00151 printf("\n"); 00152 printf("Example1: analyze online data: ./analyzer.exe -P9091\n"); 00153 printf("Example2: analyze existing data: ./analyzer.exe /data/alpha/current/run00500.mid\n"); 00154 00155 exit(1); 00156 }


| virtual bool TRootanaEventLoop::ProcessMidasEvent | ( | TDataContainer & | dataContainer | ) | [pure virtual] |
The main method, called for each event. Users must implement this function!
Implemented in Analyzer, TRootanaDisplay, MyTestLoop, and TRootanaDisplay.
| virtual bool TRootanaEventLoop::ProcessMidasEvent | ( | TDataContainer & | dataContainer | ) | [pure virtual] |
The main method, called for each event. Users must implement this function!
Implemented in Analyzer, TRootanaDisplay, MyTestLoop, and TRootanaDisplay.
Referenced by ProcessMidasFile().

| int TRootanaEventLoop::ProcessMidasFile | ( | TApplication * | app, | |
| const char * | fname | |||
| ) |
| int TRootanaEventLoop::ProcessMidasFile | ( | TApplication * | app, | |
| const char * | fname | |||
| ) |
Treat the begin run and end run events differently.
Definition at line 290 of file TRootanaEventLoop.cxx.
References BeginRun(), CheckEventID(), TDataContainer::CleanupEvent(), TMidasFile::Close(), CloseRootFile(), EndRun(), fCurrentRunNumber, fDataContainer, fMaxEvents, fODB, TMidasEvent::GetData(), TMidasEvent::GetSerialNumber(), TMidasFile::Open(), OpenRootFile(), PreFilter(), PrintCurrentStats(), ProcessMidasEvent(), TMidasFile::Read(), and TDataContainer::SetMidasEventPointer().
Referenced by ExecuteLoop().
00291 { 00292 TMidasFile f; 00293 bool tryOpen = f.Open(fname); 00294 00295 if (!tryOpen){ 00296 printf("Cannot open input file \"%s\"\n",fname); 00297 return -1; 00298 } 00299 00300 00301 int i=0; 00302 while (1) 00303 { 00304 TMidasEvent event; 00305 if (!f.Read(&event)) 00306 break; 00307 00308 /// Treat the begin run and end run events differently. 00309 int eventId = event.GetEventId(); 00310 00311 00312 00313 if ((eventId & 0xFFFF) == 0x8000){// begin run event 00314 00315 event.Print(); 00316 00317 // Load ODB contents from the ODB XML file 00318 if (fODB) delete fODB; 00319 fODB = new XmlOdb(event.GetData(),event.GetDataSize()); 00320 00321 fCurrentRunNumber = event.GetSerialNumber(); 00322 OpenRootFile(fCurrentRunNumber); 00323 BeginRun(0,event.GetSerialNumber(),0); 00324 00325 } else if ((eventId & 0xFFFF) == 0x8001){// end run event 00326 00327 event.Print(); 00328 //EndRun(0,fCurrentRunNumber,0); 00329 00330 00331 } else if ((eventId & 0xFFFF) == 0x8002){ 00332 00333 event.Print(); 00334 printf("Log message: %s\n", event.GetData()); 00335 00336 }else if(CheckEventID(eventId)){ // all other events; check that this event ID should be processed. 00337 00338 // Set the bank list for midas event. 00339 event.SetBankList(); 00340 00341 // Set the midas event pointer in the physics event. 00342 fDataContainer->SetMidasEventPointer(event); 00343 00344 //ProcessEvent if prefilter is satisfied... 00345 if(PreFilter(*fDataContainer)) 00346 ProcessMidasEvent(*fDataContainer); 00347 00348 // Cleanup the information for this event. 00349 fDataContainer->CleanupEvent(); 00350 00351 } 00352 00353 PrintCurrentStats(); 00354 00355 // Check if we have processed desired number of events. 00356 i++; 00357 if ((fMaxEvents!=0)&&(i>=fMaxEvents)){ 00358 printf("Reached event %d, exiting loop.\n",i); 00359 break; 00360 } 00361 } 00362 00363 f.Close(); 00364 00365 EndRun(0,fCurrentRunNumber,0); 00366 CloseRootFile(); 00367 00368 // start the ROOT GUI event loop 00369 // app->Run(kTRUE); 00370 00371 return 0; 00372 }


| 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 167 of file TRootanaEventLoop.hxx.
References fProcessEventIDs.
00167 { 00168 fProcessEventIDs.push_back(eventID); 00169 };
| 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 167 of file TRootanaEventLoop.hxx.
References fProcessEventIDs.
00167 { 00168 fProcessEventIDs.push_back(eventID); 00169 };
| void TRootanaEventLoop::SetCurrentRunNumber | ( | int | run | ) | [inline] |
Current Run Number.
Definition at line 110 of file TRootanaEventLoop.hxx.
References fCurrentRunNumber.
00110 {fCurrentRunNumber = run;};
| void TRootanaEventLoop::SetCurrentRunNumber | ( | int | run | ) | [inline] |
Current Run Number.
Definition at line 110 of file TRootanaEventLoop.hxx.
References fCurrentRunNumber.
00110 {fCurrentRunNumber = run;};
| void TRootanaEventLoop::SetOnlineName | ( | std::string | name | ) | [inline] |
Definition at line 162 of file TRootanaEventLoop.hxx.
References fOnlineName.
00162 {fOnlineName = name;};
| void TRootanaEventLoop::SetOnlineName | ( | std::string | name | ) | [inline] |
Definition at line 162 of file TRootanaEventLoop.hxx.
References fOnlineName.
00162 {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 160 of file TRootanaEventLoop.hxx.
References fOutputFilename.
00160 {fOutputFilename = 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 160 of file TRootanaEventLoop.hxx.
References fOutputFilename.
Referenced by MyTestLoop::MyTestLoop().
00160 {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 176 of file TRootanaEventLoop.hxx.
References fSuppressTimestampWarnings.
00176 { fSuppressTimestampWarnings = true;};
| 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 176 of file TRootanaEventLoop.hxx.
References fSuppressTimestampWarnings.
00176 { fSuppressTimestampWarnings = true;};
| virtual 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.
| 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 112 of file TRootanaEventLoop.cxx.
Referenced by PrintHelp().

| virtual void TRootanaEventLoop::UsageRAD | ( | void | ) | [protected, virtual] |
Also a special version of usage for TRootanaDisplay. See CheckOptionRAD.
Reimplemented in TRootanaDisplay, and TRootanaDisplay.
| void TRootanaEventLoop::UsageRAD | ( | void | ) | [protected, virtual] |
Also a special version of usage for TRootanaDisplay. See CheckOptionRAD.
Reimplemented in TRootanaDisplay, and TRootanaDisplay.
Definition at line 113 of file TRootanaEventLoop.cxx.
Referenced by PrintHelp().

TApplication * TRootanaEventLoop::fApp [private] |
Definition at line 260 of file TRootanaEventLoop.hxx.
Referenced by ExecuteLoop(), and TRootanaEventLoop().
std::string TRootanaEventLoop::fBufferName [private] |
Buffer to connect to.
Definition at line 247 of file TRootanaEventLoop.hxx.
Referenced by ExecuteLoop(), and TRootanaEventLoop().
bool TRootanaEventLoop::fCreateMainWindow [private] |
Definition at line 263 of file TRootanaEventLoop.hxx.
Referenced by DisableAutoMainWindow(), ExecuteLoop(), and TRootanaEventLoop().
int TRootanaEventLoop::fCurrentRunNumber [private] |
Current run number.
Definition at line 230 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 238 of file TRootanaEventLoop.hxx.
Referenced by GetDataContainer(), ProcessMidasFile(), and TRootanaEventLoop().
bool TRootanaEventLoop::fDisableRootOutput [private] |
Variable for disabling/enabling Root output.
Definition at line 221 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 227 of file TRootanaEventLoop.hxx.
Referenced by ExecuteLoop(), IsOffline(), IsOnline(), and TRootanaEventLoop().
int TRootanaEventLoop::fMaxEvents [private] |
Definition at line 257 of file TRootanaEventLoop.hxx.
Referenced by ExecuteLoop(), ProcessMidasFile(), and TRootanaEventLoop().
VirtualOdb * TRootanaEventLoop::fODB [private] |
Pointer to the ODB access instance.
Definition at line 224 of file TRootanaEventLoop.hxx.
Referenced by GetODB(), ProcessMidasFile(), TRootanaEventLoop(), and ~TRootanaEventLoop().
TDirectory * TRootanaEventLoop::fOnlineHistDir [protected] |
TDirectory for online histograms.
Definition at line 198 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 250 of file TRootanaEventLoop.hxx.
Referenced by SetOnlineName(), and TRootanaEventLoop().
TFile * TRootanaEventLoop::fOutputFile [private] |
Output ROOT file.
Definition at line 214 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 218 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 241 of file TRootanaEventLoop.hxx.
Referenced by CheckEventID(), and ProcessThisEventID().
bool TRootanaEventLoop::fSuppressTimestampWarnings [private] |
Bool for suppressing the warnings about old timestamps.
Definition at line 253 of file TRootanaEventLoop.hxx.
Referenced by GetSuppressTimestampWarnings(), SuppressTimestampWarnings(), and TRootanaEventLoop().
static TRootanaEventLoop * TRootanaEventLoop::fTRootanaEventLoop = NULL [static, protected] |
The static pointer to the singleton instance.
Definition at line 195 of file TRootanaEventLoop.hxx.
Referenced by CreateSingleton(), and Get().
1.6.1