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

Base class for modules. More...

Inheritance diagram for QBaseModule:
QModuleTimeProfiling QDriver QFilter QModule QReader QWriter MCoincidenceVeto MCoincidenceMultiplicity MCoincidenceTiming MFlagCoincidence MSorter MTimeEnergy MTimeSort MQinoDataReader QFileReader QFileWriter

Public Types

enum  Type {
  Module , Filter , Reader , Writer ,
  Driver
}
 

Public Member Functions

 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...
 
virtual void Begin (QEventAssembler &ev)=0
 Begin method is called before event loop and must be implemented by inheriting classes. 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...
 
virtual bool Process (QEventAssembler &ev, QEventList &evl, const bool exec, QEventList &ovl)=0
 Process method is called for each event, getting the event and as argument and must be implemented by inheriting classes. More...
 
void EndBase ()
 EndBase method is called after event loop. More...
 
virtual void End ()=0
 End method is called after event loop and must be implemented by inheriting classes. More...
 
const std::vector< QEventLabel > & GetRequiredLabels () const
 Get labels of objects required by this module. More...
 

Protected Member Functions

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...
 

Protected Attributes

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...
 

Private Member Functions

void UpdateEnableFlag ()
 update enable flag More...
 
void Disable ()
 disable More...
 
void UpdateConfigParameters (const std::string &p) const
 update module config More...
 
void SetVerbosity (MsgLevel l=WarnMsg)
 

Private Attributes

MsgLevel verbosity
 
unsigned int fOccurrence
 
bool fEnabled
 
std::string fLabel
 
std::string fName
 
std::string fMessageName
 
bool fFirstCall
 
bool fNeedNeighbours
 
QSequencemy_sequence
 
QModuleConfig fConfig
 
Type fType
 
std::vector< QEventLabelfRequiredLabels
 

Friends

template<class T >
class QModFactory
 
class QModuleFactory
 
class QSequence
 
class QModule
 
class QWriter
 
class QDriver
 
class QFilter
 

Detailed Description

Base class for modules.

Author
M. Pallavicini, M. Vignati

This class implements general methods that are used by all modules, such as config file parameters and interfaces to check and control the sequence execution. This class define the following config file parameters:

Optional Parameters:

Each module type have to inherit from this base class that is managed by the QSequence through the BeginBase(), ProcessBase() and EndBase() methods.

Definition at line 57 of file QBaseModule.hh.

Member Enumeration Documentation

◆ Type

Enumerator
Module 
Filter 
Reader 
Writer 
Driver 

Definition at line 60 of file QBaseModule.hh.

Constructor & Destructor Documentation

◆ QBaseModule()

Q_BEGIN_NAMESPACE QBaseModule::QBaseModule ( Type  type)

constructor

Definition at line 18 of file QBaseModule.cc.

References fEnabled, fMessageName, fName, fNeedNeighbours, fOccurrence, fType, verbosity, and WarnMsg.

◆ ~QBaseModule()

QBaseModule::~QBaseModule ( )
virtual

constructor

Definition at line 30 of file QBaseModule.cc.

Member Function Documentation

◆ Begin()

virtual void QBaseModule::Begin ( QEventAssembler ev)
pure virtual

Begin method is called before event loop and must be implemented by inheriting classes.

Implemented in QReader, QModule, QDriver, QWriter, and QFilter.

Referenced by BeginBase().

◆ BeginBase()

void QBaseModule::BeginBase ( QEventAssembler ev)

◆ Debug()

void QBaseModule::Debug ( const char *  descr,
  ... 
) const
inline

◆ Disable()

void QBaseModule::Disable ( )
inlineprivate

disable

Definition at line 176 of file QBaseModule.hh.

References fEnabled.

◆ End()

virtual void QBaseModule::End ( )
pure virtual

End method is called after event loop and must be implemented by inheriting classes.

Implemented in QWriter, QReader, QModule, QFilter, and QDriver.

Referenced by EndBase().

◆ EndBase()

void QBaseModule::EndBase ( )

◆ Error()

void QBaseModule::Error ( const char *  descr,
  ... 
) const
inline

Send an error message (an error that the framework cannot recover) with printf syntax.

Definition at line 238 of file QBaseModule.hh.

References ErrorMsg, fMessageName, QMessageHandler::Get(), QMessageHandler::Send(), and verbosity.

Referenced by QFilter::Begin(), QDriver::Begin(), MTimeSort::Do(), QFilter::End(), and QDriver::HandleAction().

◆ GetBool()

bool QBaseModule::GetBool ( const std::string &  parname,
bool  defVal,
bool  warnCfg = true 
) const

◆ GetConfig()

QModuleConfig& QBaseModule::GetConfig ( )
inlineprotected

Get module config.

Definition at line 166 of file QBaseModule.hh.

References fConfig.

◆ GetDouble()

double QBaseModule::GetDouble ( const std::string &  parname,
double  defVal,
bool  warnCfg = true 
) const

Get a double parameter from config file.

Parameters
parnamename of the parameter as it appears in the config file.
defvaldefault return value if the parameter is not found in the config file.
warnCfgsend a warn message if the parameter is not found in the config file.

Definition at line 184 of file QBaseModule.cc.

References QOptions::GetDouble(), QOptions::GetInstance(), GetName(), GetOccurrence(), GetSequence(), QOptions::SetParameter(), UpdateConfigParameters(), and Warn().

Referenced by MCoincidenceVeto::GetCuts(), QTriggerBULLDAQ::GetParametersFromCFG(), QTriggerNoise::GetParametersFromCFG(), QTriggerOptimumFilter::GetParametersFromCFG(), QTriggerThreshold::GetParametersFromCFG(), QTriggerTTL::GetParametersFromCFG(), MCoincidenceMultiplicity::Init(), MCoincidenceTiming::Init(), MFlagCoincidence::Init(), and QTimeNeighbour::Init().

◆ GetFullPath()

std::string QBaseModule::GetFullPath ( ) const

Get Full Path of module "GetName() + "." + GetOccurrence".

Definition at line 177 of file QBaseModule.cc.

References GetName(), and GetOccurrence().

◆ GetInt()

int QBaseModule::GetInt ( const std::string &  parname,
int  defVal,
bool  warnCfg = true 
) const

◆ GetIteration()

unsigned int QBaseModule::GetIteration ( ) const
inline

◆ GetLabel()

const std::string& QBaseModule::GetLabel ( ) const
inline

Get Module name + the optional ExtraLabel ("name_extralabel")

Definition at line 133 of file QBaseModule.hh.

References fLabel.

◆ GetName()

const std::string& QBaseModule::GetName ( ) const
inline

◆ GetOccurrence()

unsigned int QBaseModule::GetOccurrence ( ) const
inline

get the number of times the same module is loaded inside a QSequence

Definition at line 125 of file QBaseModule.hh.

References fOccurrence.

Referenced by GetBool(), GetDouble(), GetFullPath(), GetInt(), GetString(), GetVectorBool(), GetVectorDouble(), GetVectorInt(), GetVectorString(), QModuleFactory::Init(), Update(), and UpdateConfigParameters().

◆ GetRequiredLabels()

const std::vector<QEventLabel>& QBaseModule::GetRequiredLabels ( ) const
inline

Get labels of objects required by this module.

Definition at line 159 of file QBaseModule.hh.

References fRequiredLabels.

Referenced by QFilter::FilterAlgorithm(), and QModule::Process().

◆ GetRunAgain()

bool QBaseModule::GetRunAgain ( ) const
inline

Check if the sequence will be reiterated.

Definition at line 118 of file QBaseModule.hh.

References QSequence::GetRunAgain(), and my_sequence.

Referenced by QFileWriter::Done().

◆ GetSequence()

const QSequence& QBaseModule::GetSequence ( ) const
inline

◆ GetString()

const std::string & QBaseModule::GetString ( const std::string &  parname,
const std::string &  defVal,
bool  warnCfg = true 
) const

◆ GetVectorBool()

std::vector< bool > QBaseModule::GetVectorBool ( const std::string &  parname,
std::vector< bool >  defVal,
bool  warnCfg = true 
) const

Get a vector<bool> parameter from config file ( see GetVectorDouble() )

Definition at line 270 of file QBaseModule.cc.

References QOptions::GetInstance(), GetName(), GetOccurrence(), GetSequence(), QOptions::GetVectorBool(), QOptions::SetParameter(), UpdateConfigParameters(), and Warn().

◆ GetVectorDouble()

std::vector< double > QBaseModule::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}".

Parameters
parnamename of the parameter as it appears in the config file.
defvaldefault return value if the parameter is not found in the config file.
warnCfgsend a warn message if the parameter is not found in the config file.

Definition at line 199 of file QBaseModule.cc.

References QOptions::GetInstance(), GetName(), GetOccurrence(), GetSequence(), QOptions::GetVectorDouble(), QOptions::SetParameter(), UpdateConfigParameters(), and Warn().

◆ GetVectorInt()

std::vector< int > QBaseModule::GetVectorInt ( const std::string &  parname,
std::vector< int >  defVal,
bool  warnCfg = true 
) const

Get an vector<int> parameter from config file ( see GetVectorDouble() )

Definition at line 234 of file QBaseModule.cc.

References QOptions::GetInstance(), GetName(), GetOccurrence(), GetSequence(), QOptions::GetVectorInt(), QOptions::SetParameter(), UpdateConfigParameters(), and Warn().

◆ GetVectorString()

std::vector< std::string > QBaseModule::GetVectorString ( const std::string &  parname,
std::vector< std::string >  defVal,
bool  warnCfg = true 
) const

◆ GetVerbosity()

MsgLevel QBaseModule::GetVerbosity ( )
inline

get verbosity level set from config file

Definition at line 135 of file QBaseModule.hh.

References verbosity.

◆ GlobalData()

const QGlobalDataManager& QBaseModule::GlobalData ( ) const
inline

interface for saving and loading global QObjects

Definition at line 116 of file QBaseModule.hh.

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

Referenced by QFileWriter::BuildFileName(), and QFileWriter::Do().

◆ Info()

void QBaseModule::Info ( const char *  descr,
  ... 
) const
inline

◆ isEnabled()

bool QBaseModule::isEnabled ( ) const
inline

check if module is enabled

Definition at line 127 of file QBaseModule.hh.

References fEnabled.

Referenced by QSequence::Dump(), QSequence::Run(), and QSequence::~QSequence().

◆ NeedNeighbours()

bool QBaseModule::NeedNeighbours ( )
inline

check wheter this module needs neighbours (available after the first event is processed)

Definition at line 141 of file QBaseModule.hh.

References fNeedNeighbours.

Referenced by QSequence::CheckModuleWithNeighbours().

◆ Panic()

void QBaseModule::Panic ( const char *  descr,
  ... 
) const
inline

◆ Process()

virtual bool QBaseModule::Process ( QEventAssembler ev,
QEventList evl,
const bool  exec,
QEventList ovl 
)
pure virtual

Process method is called for each event, getting the event and as argument and must be implemented by inheriting classes.

Implemented in QWriter, QReader, QModule, QDriver, and QFilter.

Referenced by ProcessBase().

◆ ProcessBase()

bool QBaseModule::ProcessBase ( QEventAssembler ev,
QEventList evl,
const bool  exec,
QEventList ovl 
)

◆ SetNeedNeighbours()

void QBaseModule::SetNeedNeighbours ( bool  need)
inlineprotected

set wheter this module needs neighbours

Definition at line 169 of file QBaseModule.hh.

References fNeedNeighbours.

Referenced by QFilter::Begin(), QWriter::Begin(), QDriver::Begin(), QModule::Begin(), QModule::Do(), and QFilter::Filter().

◆ SetRunAgain()

void QBaseModule::SetRunAgain ( bool  b)
inline

Set that the sequence will be reiterated.

Definition at line 120 of file QBaseModule.hh.

References b, my_sequence, and QSequence::SetRunAgain().

Referenced by MCoincidenceTiming::Done(), MFlagCoincidence::Done(), QModule::End(), and QDriver::HandleAction().

◆ SetVerbosity()

void QBaseModule::SetVerbosity ( MsgLevel  l = WarnMsg)
inlineprivate

Definition at line 195 of file QBaseModule.hh.

References verbosity.

◆ Update()

void QBaseModule::Update ( QSequence s,
unsigned int  occurrence 
)

◆ UpdateConfigParameters()

void QBaseModule::UpdateConfigParameters ( const std::string &  p) const
private

◆ UpdateEnableFlag()

void QBaseModule::UpdateEnableFlag ( )
inlineprivate

update enable flag

Definition at line 173 of file QBaseModule.hh.

References fEnabled, and GetBool().

Referenced by QSequence::Dump().

◆ Warn()

void QBaseModule::Warn ( const char *  descr,
  ... 
) const
inline

Friends And Related Function Documentation

◆ QDriver

friend class QDriver
friend

Definition at line 203 of file QBaseModule.hh.

◆ QFilter

friend class QFilter
friend

Definition at line 204 of file QBaseModule.hh.

◆ QModFactory

template<class T >
friend class QModFactory
friend

Definition at line 197 of file QBaseModule.hh.

◆ QModule

friend class QModule
friend

Definition at line 201 of file QBaseModule.hh.

◆ QModuleFactory

friend class QModuleFactory
friend

Definition at line 199 of file QBaseModule.hh.

◆ QSequence

friend class QSequence
friend

Definition at line 200 of file QBaseModule.hh.

◆ QWriter

friend class QWriter
friend

Definition at line 202 of file QBaseModule.hh.

Member Data Documentation

◆ fConfig

QModuleConfig QBaseModule::fConfig
mutableprivate

Definition at line 191 of file QBaseModule.hh.

Referenced by BeginBase(), GetConfig(), Update(), and UpdateConfigParameters().

◆ fEnabled

bool QBaseModule::fEnabled
private

Definition at line 184 of file QBaseModule.hh.

Referenced by Disable(), isEnabled(), QBaseModule(), and UpdateEnableFlag().

◆ fExecuted

bool QBaseModule::fExecuted
protected

◆ fFirstCall

bool QBaseModule::fFirstCall
private

Definition at line 188 of file QBaseModule.hh.

◆ fLabel

std::string QBaseModule::fLabel
private

◆ fMessageName

std::string QBaseModule::fMessageName
private

Definition at line 187 of file QBaseModule.hh.

Referenced by Debug(), Error(), Info(), Panic(), QBaseModule(), Update(), and Warn().

◆ fName

std::string QBaseModule::fName
private

Definition at line 186 of file QBaseModule.hh.

Referenced by BeginBase(), GetName(), QBaseModule(), and Update().

◆ fNeedNeighbours

bool QBaseModule::fNeedNeighbours
private

Definition at line 189 of file QBaseModule.hh.

Referenced by BeginBase(), EndBase(), NeedNeighbours(), QBaseModule(), and SetNeedNeighbours().

◆ fOccurrence

unsigned int QBaseModule::fOccurrence
private

Definition at line 183 of file QBaseModule.hh.

Referenced by GetOccurrence(), QBaseModule(), and Update().

◆ fRequiredLabels

std::vector<QEventLabel> QBaseModule::fRequiredLabels
private

Definition at line 193 of file QBaseModule.hh.

Referenced by BeginBase(), and GetRequiredLabels().

◆ fType

Type QBaseModule::fType
private

Definition at line 192 of file QBaseModule.hh.

Referenced by QBaseModule(), and Update().

◆ my_sequence

QSequence* QBaseModule::my_sequence
private

◆ verbosity

MsgLevel QBaseModule::verbosity
private

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