Diana Software
Classes | Public Types | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
QDriver Class Referenceabstract

Base class for diana drivers. More...

Inheritance diagram for QDriver:
QBaseModule QModuleTimeProfiling

Classes

class  Action
 class to store ActionId and fEventNumber (in case fActionId=ACT_GOTOEV) More...
 

Public Types

enum  ActionId {
  ACT_NONE , ACT_NEXTEV , ACT_SKIP , ACT_PREVEV ,
  ACT_GOTOEV , ACT_RERUN , ACT_QUIT
}
 actions that the driver can perform More...
 
- Public Types inherited from QBaseModule
enum  Type {
  Module , Filter , Reader , Writer ,
  Driver
}
 

Public Member Functions

 QDriver ()
 
virtual ~QDriver ()
 
virtual Action Init (QEventAssembler &eva)
 Init method is called before event loop. More...
 
virtual Action Do (QEventAssembler &eva)
 Do method is called for each event, getting the QEventAssembler as argument. More...
 
virtual Action Do (QEventAssembler &eva, const QEventList &neigh)
 Do method is called for each event, getting the QEventAssembler and list of neighbours as argument. More...
 
virtual Action Done ()=0
 Done method is called after event loop. More...
 
- Public Member Functions inherited from QBaseModule
 QBaseModule (Type type)
 constructor More...
 
virtual ~QBaseModule ()
 constructor More...
 
double GetDouble (const std::string &parname, double defVal, bool warnCfg=true) const
 Get a double parameter from config file. More...
 
std::vector< double > GetVectorDouble (const std::string &parname, std::vector< double > defVal, bool warnCfg=true) const
 Get a std::vector<double> parameter from config file with syntax "{x,y,z}". More...
 
int GetInt (const std::string &parname, int defVal, bool warnCfg=true) const
 Get an int parameter from config file ( see GetDouble() ) More...
 
std::vector< int > GetVectorInt (const std::string &parname, std::vector< int > defVal, bool warnCfg=true) const
 Get an vector<int> parameter from config file ( see GetVectorDouble() ) More...
 
bool GetBool (const std::string &parname, bool defVal, bool warnCfg=true) const
 Get a bool parameter from config file ( see GetDouble() ) More...
 
std::vector< bool > GetVectorBool (const std::string &parname, std::vector< bool > defVal, bool warnCfg=true) const
 Get a vector<bool> parameter from config file ( see GetVectorDouble() ) More...
 
const std::string & GetString (const std::string &parname, const std::string &defVal, bool warnCfg=true) const
 Get a string parameter from config file ( see GetDouble() ) More...
 
std::vector< std::string > GetVectorString (const std::string &parname, std::vector< std::string > defVal, bool warnCfg=true) const
 Get a vector<string> parameter from config file ( see GetVectorDouble() ) More...
 
void Debug (const char *descr,...) const
 Send a debug message (used to debug the module) with printf syntax. More...
 
void Info (const char *descr,...) const
 Send an info message (information) with printf syntax. More...
 
void Warn (const char *descr,...) const
 Send a warning message (an error that the framework can recover) with printf syntax. More...
 
void Error (const char *descr,...) const
 Send an error message (an error that the framework cannot recover) with printf syntax. More...
 
void Panic (const char *descr,...) const
 Send a panic message (stops the framework) with printf syntax. More...
 
const QGlobalDataManagerGlobalData () const
 interface for saving and loading global QObjects More...
 
bool GetRunAgain () const
 Check if the sequence will be reiterated. More...
 
void SetRunAgain (bool b)
 Set that the sequence will be reiterated. More...
 
unsigned int GetIteration () const
 Get Current sequence iteration. More...
 
unsigned int GetOccurrence () const
 get the number of times the same module is loaded inside a QSequence More...
 
bool isEnabled () const
 check if module is enabled More...
 
std::string GetFullPath () const
 Get Full Path of module "GetName() + "." + GetOccurrence". More...
 
const std::string & GetName () const
 Get Module name. More...
 
const std::string & GetLabel () const
 Get Module name + the optional ExtraLabel ("name_extralabel") More...
 
MsgLevel GetVerbosity ()
 get verbosity level set from config file More...
 
const QSequenceGetSequence () const
 get reference to this sequence More...
 
void Update (QSequence *s, unsigned int occurrence)
 set the occurrence in the same sequence. MV FIXME: should not be public More...
 
bool NeedNeighbours ()
 check wheter this module needs neighbours (available after the first event is processed) More...
 
void BeginBase (QEventAssembler &ev)
 Begin Base method is called before event loop. More...
 
bool ProcessBase (QEventAssembler &ev, QEventList &evl, const bool exec, QEventList &ovl)
 ProcessBase method is called for each event, getting the event and as argument. More...
 
void EndBase ()
 EndBase method is called after event loop. More...
 
const std::vector< QEventLabel > & GetRequiredLabels () const
 Get labels of objects required by this module. More...
 

Protected Member Functions

const std::vector< QBaseModule * > & GetModulesList () const
 get const list of QBaseModule (s) in the QSequence More...
 
std::map< std::string, QVdt * > GetModuleParameters (const std::string &name, int occ)
 get list of parameters for a given QBaseModule with name name and occurrence occ More...
 
QSequenceGetSequence () const
 get non-const reference to this sequence More...
 
- Protected Member Functions inherited from QBaseModule
QModuleConfigGetConfig ()
 Get module config. More...
 
void SetNeedNeighbours (bool need)
 set wheter this module needs neighbours More...
 
- Protected Member Functions inherited from QModuleTimeProfiling
 QModuleTimeProfiling ()
 ctor initialized internal variables More...
 
virtual ~QModuleTimeProfiling ()
 dtor does nothing More...
 
void SetTimeProfilingOn (bool val)
 Set the time profiling on/off. More...
 
bool GetTimeProfilingOn () const
 Check if the time profiling is on. More...
 
void ResetTimer ()
 Reset the timer to now. More...
 
double GetTimer () const
 return the time since the last reset More...
 
virtual void StartProcessCall ()
 Start of a process call. More...
 
virtual void EndProcessCall ()
 End a process call and increment time and calls. More...
 
unsigned long long GetProcessCalls () const
 Return the total number of process calls. More...
 
double GetTotalProcessTime () const
 Return the total processing time. More...
 
double GetProcessCallTime () const
 Return the average time of a single process call. More...
 
std::string GetTimeProfileReport (const std::string &prefix="") const
 Report the time profiling. More...
 

Private Member Functions

void Begin (QEventAssembler &eva)
 Begin method is called before event loop, and calls Init() More...
 
bool Process (QEventAssembler &eva, QEventList &neigh, const bool exec, QEventList &oneigh)
 Process method is called for each event, getting the QEventAssembler as argument and calls Do() More...
 
void End ()
 End method is called after event loop and calls Done() More...
 
void HandleAction (Action action)
 internal method to handle action returned by inheriting classes More...
 
bool StopRun ()
 method used by QSequence to check if the run should be stopped More...
 
void SetModulesList (const std::vector< QBaseModule * > &modList)
 method used by QSequence to set the list of modules in the QSequence More...
 
const QErrorJumpToEvent (Long64_t event)
 next iteration diana will jump to event More...
 

Private Attributes

Action fLastAction
 last action performed More...
 
bool fStopRun
 stop run or not More...
 
bool fSkip
 skip event More...
 
int fCurrentEventNumber
 current event number to make ACT_PREV use JumpToEvent(fCurrentEventNumber-1) More...
 
std::vector< QBaseModule * > fModules
 list of current modules More...
 
bool fSkipEvents
 skip filtered events More...
 

Friends

class QSequence
 

Additional Inherited Members

- Protected Attributes inherited from QBaseModule
bool fExecuted
 
- Protected Attributes inherited from QModuleTimeProfiling
bool fTimeProfilingOn
 Report the time profiling. More...
 
unsigned long long int fProcessCalls
 NUmber of calls to the process. More...
 
double fProcessTime
 Total time spent running the process. More...
 

Detailed Description

Base class for diana drivers.

Author
Marco Vignati

QDriver modules can control the flow of diana through events, and the QSequence execution. QDrivers may have full access to the QEvent, when methods with QEventAssembler as argument are implemented. Inheriting modules must implement the Init() Do() and Done() methods, that return the Action to be performed. Actions can be of different types, as documented below. Only one driver is allowed in a QSequence, and can be loaded with the -D inline option without dclaring it in the cfg. By default drivers do not see filters, i.e. the Do is executed on all events, and all neighbours are contained in the QEventList. To disable this behavior, set SkipEvents = true in the cfg.

This class defines the following config file parameters (see QBaseModule for inherited parameters).

Definition at line 32 of file QDriver.hh.

Member Enumeration Documentation

◆ ActionId

actions that the driver can perform

Enumerator
ACT_NONE 

No action is performed, do not interfere with diana

ACT_NEXTEV 

go to next QEvent (default diana behavior)

ACT_SKIP 

skip execution of writer module on this event

ACT_PREVEV 

go to previous QEvent

ACT_GOTOEV 

go to event with number (see Action)

ACT_RERUN 

rerun the sequence right now (and not at the end of the QEvent loop like QBaseModule::SetRunAgain())

ACT_QUIT 

stop the sequence right now

Definition at line 41 of file QDriver.hh.

Constructor & Destructor Documentation

◆ QDriver()

QDriver::QDriver ( )
inline

Definition at line 36 of file QDriver.hh.

◆ ~QDriver()

virtual QDriver::~QDriver ( )
inlinevirtual

Definition at line 38 of file QDriver.hh.

Member Function Documentation

◆ Begin()

void QDriver::Begin ( QEventAssembler eva)
privatevirtual

◆ Do() [1/2]

QDriver::Action QDriver::Do ( QEventAssembler eva)
virtual

Do method is called for each event, getting the QEventAssembler as argument.

Definition at line 16 of file QDriver.cc.

References ACT_NEXTEV, and QBaseModule::Panic().

Referenced by Do(), and Process().

◆ Do() [2/2]

QDriver::Action QDriver::Do ( QEventAssembler eva,
const QEventList neigh 
)
virtual

Do method is called for each event, getting the QEventAssembler and list of neighbours as argument.

Definition at line 22 of file QDriver.cc.

References Do().

◆ Done()

virtual Action QDriver::Done ( )
pure virtual

Done method is called after event loop.

Referenced by End().

◆ End()

void QDriver::End ( )
privatevirtual

End method is called after event loop and calls Done()

Implements QBaseModule.

Definition at line 46 of file QDriver.cc.

References ACT_QUIT, ACT_RERUN, Done(), QDriver::Action::fActionId, fLastAction, and HandleAction().

◆ GetModuleParameters()

std::map<std::string, QVdt*> QDriver::GetModuleParameters ( const std::string &  name,
int  occ 
)
inlineprotected

get list of parameters for a given QBaseModule with name name and occurrence occ

Definition at line 84 of file QDriver.hh.

References QOptions::GetInstance(), QOptions::GetModuleParameters(), QBaseModule::GetName(), and GetSequence().

◆ GetModulesList()

const std::vector<QBaseModule*>& QDriver::GetModulesList ( ) const
inlineprotected

get const list of QBaseModule (s) in the QSequence

Definition at line 81 of file QDriver.hh.

References fModules.

◆ GetSequence()

QSequence& QDriver::GetSequence ( ) const
inlineprotected

get non-const reference to this sequence

Definition at line 87 of file QDriver.hh.

References QBaseModule::my_sequence.

Referenced by GetModuleParameters(), and JumpToEvent().

◆ HandleAction()

void QDriver::HandleAction ( Action  action)
private

internal method to handle action returned by inheriting classes

Definition at line 71 of file QDriver.cc.

References ACT_GOTOEV, ACT_NEXTEV, ACT_PREVEV, ACT_QUIT, ACT_RERUN, ACT_SKIP, err, QBaseModule::Error(), QDriver::Action::fActionId, fCurrentEventNumber, QDriver::Action::fEventNumber, fSkip, fStopRun, JumpToEvent(), QERR_SUCCESS, and QBaseModule::SetRunAgain().

Referenced by Begin(), End(), and Process().

◆ Init()

Q_BEGIN_NAMESPACE QDriver::Action QDriver::Init ( QEventAssembler eva)
virtual

Init method is called before event loop.

Definition at line 9 of file QDriver.cc.

References ACT_NEXTEV, and QBaseModule::Panic().

Referenced by Begin().

◆ JumpToEvent()

const QError& QDriver::JumpToEvent ( Long64_t  event)
inlineprivate

next iteration diana will jump to event

Definition at line 109 of file QDriver.hh.

References GetSequence(), and QSequence::JumpToEvent().

Referenced by HandleAction().

◆ Process()

bool QDriver::Process ( QEventAssembler eva,
QEventList neigh,
const bool  exec,
QEventList oneigh 
)
privatevirtual

Process method is called for each event, getting the QEventAssembler as argument and calls Do()

Implements QBaseModule.

Definition at line 54 of file QDriver.cc.

References ACT_QUIT, ACT_RERUN, Do(), QDriver::Action::fActionId, fCurrentEventNumber, QBaseModule::fExecuted, fLastAction, fSkip, fSkipEvents, QEvent::Get(), QEventAssembler::GetEvent(), QEvent::GetReadNumber(), and HandleAction().

◆ SetModulesList()

void QDriver::SetModulesList ( const std::vector< QBaseModule * > &  modList)
inlineprivate

method used by QSequence to set the list of modules in the QSequence

Definition at line 106 of file QDriver.hh.

References fModules.

Referenced by QSequence::Run().

◆ StopRun()

bool QDriver::StopRun ( )
inlineprivate

method used by QSequence to check if the run should be stopped

Definition at line 103 of file QDriver.hh.

References fStopRun.

Referenced by QSequence::Run().

Friends And Related Function Documentation

◆ QSequence

friend class QSequence
friend

Definition at line 125 of file QDriver.hh.

Member Data Documentation

◆ fCurrentEventNumber

int QDriver::fCurrentEventNumber
private

current event number to make ACT_PREV use JumpToEvent(fCurrentEventNumber-1)

Definition at line 119 of file QDriver.hh.

Referenced by HandleAction(), and Process().

◆ fLastAction

Action QDriver::fLastAction
private

last action performed

Definition at line 113 of file QDriver.hh.

Referenced by Begin(), End(), and Process().

◆ fModules

std::vector<QBaseModule*> QDriver::fModules
private

list of current modules

Definition at line 121 of file QDriver.hh.

Referenced by GetModulesList(), and SetModulesList().

◆ fSkip

bool QDriver::fSkip
private

skip event

Definition at line 117 of file QDriver.hh.

Referenced by HandleAction(), and Process().

◆ fSkipEvents

bool QDriver::fSkipEvents
private

skip filtered events

Definition at line 123 of file QDriver.hh.

Referenced by Begin(), and Process().

◆ fStopRun

bool QDriver::fStopRun
private

stop run or not

Definition at line 115 of file QDriver.hh.

Referenced by HandleAction(), and StopRun().


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