ROOTANA
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | Private Member Functions | Private Attributes
TRootanaEventLoop Class Referenceabstract

#include <TRootanaEventLoop.hxx>

Inheritance diagram for TRootanaEventLoop:
Inheritance graph
[legend]
Collaboration diagram for TRootanaEventLoop:
Collaboration graph
[legend]

Public Member Functions

virtual ~TRootanaEventLoop ()
 
TDataContainerGetDataContainer ()
 Method to get the data container that event loop owns. More...
 
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 InitializeRAD (void)
 Special version of Init method, to be used only by TRootanaDisplay. More...
 
virtual void BeginRunRAD (int transition, int run, int time)
 
virtual void EndRunRAD (int transition, int run, int time)
 Also special version of EOR method, to be used only by TRootanaDisplay. More...
 
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? More...
 
bool IsOffline () const
 Are we processing offline data? More...
 
int GetCurrentRunNumber () const
 Current Run Number. More...
 
void SetCurrentRunNumber (int run)
 Current Run Number. More...
 
int ExecuteLoop (int argc, char *argv[])
 Method to actually process the Midas information, either as file or online. More...
 
int ProcessMidasFile (TApplication *app, const char *fname)
 
int ProcessMidasOnline (TApplication *app, const char *hostname, const char *exptname)
 
void DisableAutoMainWindow ()
 Disable automatic creation of MainWindow. More...
 
void UseBatchMode ()
 Use a batch mode, where we don't check ROOT status. More...
 
MVOdbGetODB ()
 Get pointer to ODB variables. More...
 
void OpenRootFile (int run, std::string midasFilename=std::string(""))
 Open output ROOT file. More...
 
void CloseRootFile ()
 Cloe output ROOT file. More...
 
bool IsRootFileValid ()
 Check if output ROOT file is valid and open. More...
 
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. More...
 
void SuppressTimestampWarnings ()
 
bool GetSuppressTimestampWarnings ()
 Suppress timestamp warnings? true = suppress warnings. More...
 
void UseOnlyRecent (bool setting=true)
 
void SetTHttpServerReadWrite (bool readwrite=true)
 

Static Public Member Functions

static TRootanaEventLoopGet (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. More...
 

Protected Attributes

TDirectoryfOnlineHistDir
 TDirectory for online histograms. More...
 

Static Protected Attributes

static TRootanaEventLoopfTRootanaEventLoop = NULL
 The static pointer to the singleton instance. More...
 

Private Member Functions

void PrintHelp ()
 Help Message. More...
 

Private Attributes

TFile * fOutputFile
 Output ROOT file. More...
 
std::string fOutputFilename
 
bool fDisableRootOutput
 Variable for disabling/enabling Root output. More...
 
MVOdbfODB
 Pointer to the ODB access instance. More...
 
bool fIsOffline
 Are we processing offline or online data? More...
 
int fCurrentRunNumber
 Current run number. More...
 
TDataContainerfDataContainer
 
std::vector< int > fProcessEventIDs
 This is the set of eventIDs to process. More...
 
std::string fBufferName
 Buffer to connect to. More...
 
std::string fOnlineName
 Name of program, as seen by MIDAS. More...
 
bool fSuppressTimestampWarnings
 Bool for suppressing the warnings about old timestamps. More...
 
int fMaxEvents
 
TApplication * fApp
 
bool fCreateMainWindow
 
bool fUseBatchMode
 

Detailed Description

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 43 of file TRootanaEventLoop.hxx.

Constructor & Destructor Documentation

◆ ~TRootanaEventLoop()

TRootanaEventLoop::~TRootanaEventLoop ( )
virtual

Definition at line 121 of file TRootanaEventLoop.cxx.

Here is the call graph for this function:

◆ TRootanaEventLoop()

TRootanaEventLoop::TRootanaEventLoop ( )
protected

Create the TApplication

Definition at line 94 of file TRootanaEventLoop.cxx.

Member Function Documentation

◆ BeginRun()

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 MyTestLoop, Analyzer, Analyzer, Analyzer, MyTestLoop, and Analyzer.

Definition at line 131 of file TRootanaEventLoop.cxx.

Here is the caller graph for this function:

◆ BeginRunRAD()

virtual void TRootanaEventLoop::BeginRunRAD ( int  transition,
int  run,
int  time 
)
inlinevirtual

Special version of BOR method, to be used only by TRootanaDisplay This is just so that users still have ability to set their own BOR methods, in addition to what TRootanaDisplay needs to do at BOR

Reimplemented in TRootanaDisplay.

Definition at line 80 of file TRootanaEventLoop.hxx.

Here is the caller graph for this function:

◆ CheckEventID()

bool TRootanaEventLoop::CheckEventID ( int  eventId)

Little helper method to check if EventID matchs requested EventID list.

Definition at line 145 of file TRootanaEventLoop.cxx.

Here is the caller graph for this function:

◆ CheckOption()

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 141 of file TRootanaEventLoop.cxx.

Here is the caller graph for this function:

◆ CheckOptionRAD()

bool TRootanaEventLoop::CheckOptionRAD ( std::string  option)
protectedvirtual

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 142 of file TRootanaEventLoop.cxx.

Here is the caller graph for this function:

◆ CloseRootFile()

void TRootanaEventLoop::CloseRootFile ( )

Cloe output ROOT file.

Definition at line 538 of file TRootanaEventLoop.cxx.

Here is the caller graph for this function:

◆ CreateOutputFile()

bool TRootanaEventLoop::CreateOutputFile ( std::string  name,
std::string  options = "RECREATE" 
)
inlineprotected

Definition at line 213 of file TRootanaEventLoop.hxx.

◆ CreateSingleton()

template<typename T >
static void TRootanaEventLoop::CreateSingleton ( )
inlinestatic

This static templated function will make it a little easier for users to create the singleton instance.

Definition at line 137 of file TRootanaEventLoop.hxx.

◆ DisableAutoMainWindow()

void TRootanaEventLoop::DisableAutoMainWindow ( )
inline

Disable automatic creation of MainWindow.

Definition at line 147 of file TRootanaEventLoop.hxx.

Here is the caller graph for this function:

◆ DisableRootOutput()

void TRootanaEventLoop::DisableRootOutput ( bool  disable = true)
inline

Definition at line 169 of file TRootanaEventLoop.hxx.

Here is the caller graph for this function:

◆ EndRun()

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 MyTestLoop, Analyzer, Analyzer, and MyTestLoop.

Definition at line 133 of file TRootanaEventLoop.cxx.

Here is the caller graph for this function:

◆ EndRunRAD()

virtual void TRootanaEventLoop::EndRunRAD ( int  transition,
int  run,
int  time 
)
inlinevirtual

Also special version of EOR method, to be used only by TRootanaDisplay.

Reimplemented in TRootanaDisplay.

Definition at line 82 of file TRootanaEventLoop.hxx.

Here is the caller graph for this function:

◆ ExecuteLoop()

int TRootanaEventLoop::ExecuteLoop ( int  argc,
char *  argv[] 
)

Method to actually process the Midas information, either as file or online.

Definition at line 244 of file TRootanaEventLoop.cxx.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Finalize()

void TRootanaEventLoop::Finalize ( )
virtual

Called after the last event has been processed, but before any open output files are closed.

Definition at line 135 of file TRootanaEventLoop.cxx.

Here is the caller graph for this function:

◆ Get()

TRootanaEventLoop & TRootanaEventLoop::Get ( void  )
static

Definition at line 78 of file TRootanaEventLoop.cxx.

Here is the caller graph for this function:

◆ GetCurrentRunNumber()

int TRootanaEventLoop::GetCurrentRunNumber ( ) const
inline

Current Run Number.

Definition at line 119 of file TRootanaEventLoop.hxx.

Here is the caller graph for this function:

◆ GetDataContainer()

TDataContainer* TRootanaEventLoop::GetDataContainer ( )
inline

Method to get the data container that event loop owns.

Definition at line 52 of file TRootanaEventLoop.hxx.

Here is the caller graph for this function:

◆ GetODB()

MVOdb* TRootanaEventLoop::GetODB ( )
inline

Get pointer to ODB variables.

Definition at line 153 of file TRootanaEventLoop.hxx.

◆ GetSuppressTimestampWarnings()

bool TRootanaEventLoop::GetSuppressTimestampWarnings ( )
inline

Suppress timestamp warnings? true = suppress warnings.

Definition at line 201 of file TRootanaEventLoop.hxx.

◆ Initialize()

void TRootanaEventLoop::Initialize ( void  )
virtual

Called after the arguments are processes but before reading the first event is read

Reimplemented in Analyzer, Analyzer, Analyzer, and Analyzer.

Definition at line 129 of file TRootanaEventLoop.cxx.

Here is the caller graph for this function:

◆ InitializeRAD()

virtual void TRootanaEventLoop::InitializeRAD ( void  )
inlinevirtual

Special version of Init method, to be used only by TRootanaDisplay.

Reimplemented in TRootanaDisplay.

Definition at line 76 of file TRootanaEventLoop.hxx.

Here is the caller graph for this function:

◆ IsOffline()

bool TRootanaEventLoop::IsOffline ( ) const
inline

Are we processing offline data?

Definition at line 116 of file TRootanaEventLoop.hxx.

Here is the caller graph for this function:

◆ IsOnline()

bool TRootanaEventLoop::IsOnline ( ) const
inline

Are we processing online data?

Definition at line 113 of file TRootanaEventLoop.hxx.

Here is the caller graph for this function:

◆ IsRootFileValid()

bool TRootanaEventLoop::IsRootFileValid ( )
inline

Check if output ROOT file is valid and open.

Definition at line 163 of file TRootanaEventLoop.hxx.

◆ IsRootOutputEnabled()

int TRootanaEventLoop::IsRootOutputEnabled ( )
inline

Definition at line 171 of file TRootanaEventLoop.hxx.

◆ OpenRootFile()

void TRootanaEventLoop::OpenRootFile ( int  run,
std::string  midasFilename = std::string("") 
)

Open output ROOT file.

Definition at line 504 of file TRootanaEventLoop.cxx.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ PreFilter()

virtual bool TRootanaEventLoop::PreFilter ( TDataContainer dataContainer)
inlinevirtual

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 110 of file TRootanaEventLoop.hxx.

Here is the caller graph for this function:

◆ PrintHelp()

void TRootanaEventLoop::PrintHelp ( )
private

Help Message.

Get pointer to THttpServer, in order to further configure it. Warning: pointer will be zero if THttpServer not initialized

Definition at line 173 of file TRootanaEventLoop.cxx.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ProcessMidasEvent()

virtual bool TRootanaEventLoop::ProcessMidasEvent ( TDataContainer dataContainer)
pure virtual

The main method, called for each event. Users must implement this function!

Implemented in MyTestLoop, TRootanaDisplay, Analyzer, Analyzer, Analyzer, and Analyzer.

Here is the caller graph for this function:

◆ ProcessMidasFile()

int TRootanaEventLoop::ProcessMidasFile ( TApplication *  app,
const char *  fname 
)

Treat the begin run and end run events differently.

Definition at line 407 of file TRootanaEventLoop.cxx.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ProcessMidasOnline()

int TRootanaEventLoop::ProcessMidasOnline ( TApplication *  app,
const char *  hostname,
const char *  exptname 
)

Definition at line 720 of file TRootanaEventLoop.cxx.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ProcessThisEventID()

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 189 of file TRootanaEventLoop.hxx.

◆ SetCurrentRunNumber()

void TRootanaEventLoop::SetCurrentRunNumber ( int  run)
inline

Current Run Number.

Definition at line 122 of file TRootanaEventLoop.hxx.

Here is the caller graph for this function:

◆ SetFullOutputFileName()

virtual std::string TRootanaEventLoop::SetFullOutputFileName ( int  run,
std::string  midasFilename 
)
inlinevirtual

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 180 of file TRootanaEventLoop.hxx.

Here is the caller graph for this function:

◆ SetOnlineName()

void TRootanaEventLoop::SetOnlineName ( std::string  name)
inline

Definition at line 184 of file TRootanaEventLoop.hxx.

Here is the caller graph for this function:

◆ SetOutputFilename()

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 175 of file TRootanaEventLoop.hxx.

Here is the caller graph for this function:

◆ SetTHttpServerReadWrite()

void TRootanaEventLoop::SetTHttpServerReadWrite ( bool  readwrite = true)

Definition at line 159 of file TRootanaEventLoop.cxx.

Here is the caller graph for this function:

◆ SuppressTimestampWarnings()

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 198 of file TRootanaEventLoop.hxx.

◆ Usage()

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 137 of file TRootanaEventLoop.cxx.

Here is the caller graph for this function:

◆ UsageRAD()

void TRootanaEventLoop::UsageRAD ( void  )
protectedvirtual

Also a special version of usage for TRootanaDisplay. See CheckOptionRAD.

Reimplemented in TRootanaDisplay.

Definition at line 138 of file TRootanaEventLoop.cxx.

Here is the caller graph for this function:

◆ UseBatchMode()

void TRootanaEventLoop::UseBatchMode ( )
inline

Use a batch mode, where we don't check ROOT status.

Definition at line 150 of file TRootanaEventLoop.hxx.

Here is the caller graph for this function:

◆ UseOnlyRecent()

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 498 of file TRootanaEventLoop.cxx.

Field Documentation

◆ fApp

TApplication* TRootanaEventLoop::fApp
private

Definition at line 295 of file TRootanaEventLoop.hxx.

◆ fBufferName

std::string TRootanaEventLoop::fBufferName
private

Buffer to connect to.

Definition at line 282 of file TRootanaEventLoop.hxx.

◆ fCreateMainWindow

bool TRootanaEventLoop::fCreateMainWindow
private

Definition at line 298 of file TRootanaEventLoop.hxx.

◆ fCurrentRunNumber

int TRootanaEventLoop::fCurrentRunNumber
private

Current run number.

Definition at line 265 of file TRootanaEventLoop.hxx.

◆ fDataContainer

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 273 of file TRootanaEventLoop.hxx.

◆ fDisableRootOutput

bool TRootanaEventLoop::fDisableRootOutput
private

Variable for disabling/enabling Root output.

Definition at line 256 of file TRootanaEventLoop.hxx.

◆ fIsOffline

bool TRootanaEventLoop::fIsOffline
private

Are we processing offline or online data?

Definition at line 262 of file TRootanaEventLoop.hxx.

◆ fMaxEvents

int TRootanaEventLoop::fMaxEvents
private

Definition at line 292 of file TRootanaEventLoop.hxx.

◆ fODB

MVOdb* TRootanaEventLoop::fODB
private

Pointer to the ODB access instance.

Definition at line 259 of file TRootanaEventLoop.hxx.

◆ fOnlineHistDir

TDirectory* TRootanaEventLoop::fOnlineHistDir
protected

TDirectory for online histograms.

Definition at line 227 of file TRootanaEventLoop.hxx.

◆ fOnlineName

std::string TRootanaEventLoop::fOnlineName
private

Name of program, as seen by MIDAS.

Definition at line 285 of file TRootanaEventLoop.hxx.

◆ fOutputFile

TFile* TRootanaEventLoop::fOutputFile
private

Output ROOT file.

Definition at line 249 of file TRootanaEventLoop.hxx.

◆ fOutputFilename

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 253 of file TRootanaEventLoop.hxx.

◆ fProcessEventIDs

std::vector<int> TRootanaEventLoop::fProcessEventIDs
private

This is the set of eventIDs to process.

Definition at line 276 of file TRootanaEventLoop.hxx.

◆ fSuppressTimestampWarnings

bool TRootanaEventLoop::fSuppressTimestampWarnings
private

Bool for suppressing the warnings about old timestamps.

Definition at line 288 of file TRootanaEventLoop.hxx.

◆ fTRootanaEventLoop

TRootanaEventLoop * TRootanaEventLoop::fTRootanaEventLoop = NULL
staticprotected

The static pointer to the singleton instance.

Definition at line 224 of file TRootanaEventLoop.hxx.

◆ fUseBatchMode

bool TRootanaEventLoop::fUseBatchMode
private

Definition at line 301 of file TRootanaEventLoop.hxx.


The documentation for this class was generated from the following files: