Marlin
01.17.01
|
Base class for Marlin processors. More...
#include <Processor.h>
Public Member Functions | |
Processor (const std::string &typeName) | |
Possible verbosity levels. More... | |
virtual | ~Processor () |
Destructor. More... | |
virtual Processor * | newProcessor ()=0 |
Return a new instance of the processor. More... | |
virtual void | init () |
Called at the begin of the job before anything is read. More... | |
virtual void | processRunHeader (LCRunHeader *) |
Called for every run, e.g. More... | |
virtual void | processEvent (LCEvent *) |
Called for every event - the working horse. More... | |
virtual void | check (LCEvent *) |
Called for every event - right after processEvent() has been called for this processor. More... | |
virtual void | end () |
Called after data processing for clean up in the inverse order of the init() method so that resources allocated in the first processor also will be available for all following processors. More... | |
virtual const std::string & | type () const |
Return type name for the processor (as set in constructor). More... | |
virtual const std::string & | name () const |
Return name of this processor. More... | |
virtual const std::string & | logLevelName () const |
Return name of the local verbosity level of this processor - "" if not set. More... | |
virtual std::shared_ptr < StringParameters > | parameters () |
Return parameters defined for this Processor. More... | |
virtual void | printDescription () |
Print information about this processor in ASCII steering file format. More... | |
virtual void | printDescriptionXML (std::ostream &stream=std::cout) |
Print information about this processor in XML steering file format. More... | |
template<class T > | |
void | printParameters () |
Print the parameters and their values depending on the given verbosity level. More... | |
void | printParameters () |
Print the parameters and their values with verbosity level MESSAGE. More... | |
const std::string & | description () |
Description of processor. More... | |
bool | isFirstEvent () |
True if first event in processEvent(evt) - use this e.g. More... | |
std::string | getLCIOInType (const std::string &colName) |
Return the LCIO input type for the collection colName - empty string if colName is not a registered collection name. More... | |
std::string | getLCIOOutType (const std::string &colName) |
Return the LCIO output type for the collection colName - empty string if colName is not a registered collection name. More... | |
bool | isInputCollectionName (const std::string ¶meterName) |
True if the given parameter defines an LCIO input collection, i.e. More... | |
bool | isOutputCollectionName (const std::string ¶meterName) |
True if the given parameter defines an LCIO output collection. More... | |
virtual void | setParameters (std::shared_ptr< StringParameters > parameters) |
Helper function returns the ProcessorParameter for the given name. More... | |
virtual void | setName (const std::string &processorName) |
Set processor name. More... | |
Protected Member Functions | |
void | setReturnValue (bool val) |
Set the return value for this processor - typically at end of processEvent(). More... | |
void | setReturnValue (const std::string &name, bool val) |
Set a named return value for this processor - typically at end of processEvent() The value can be used in a condition in the steering file referred to by ProcessorName.name of the processor. More... | |
template<class T > | |
void | registerProcessorParameter (const std::string ¶meterName, const std::string ¶meterDescription, T ¶meter, const T &defaultVal, int setSize=0) |
Register a steering variable for this processor - call in constructor of processor. More... | |
void | registerInputCollection (const std::string &collectionType, const std::string ¶meterName, const std::string ¶meterDescription, std::string ¶meter, const std::string &defaultVal, int setSize=0) |
Specialization of registerProcessorParameter() for a parameter that defines an input collection - can be used fo checking the consistency of the steering file. More... | |
void | registerOutputCollection (const std::string &collectionType, const std::string ¶meterName, const std::string ¶meterDescription, std::string ¶meter, const std::string &defaultVal, int setSize=0) |
Specialization of registerProcessorParameter() for a parameter that defines an output collection - can be used fo checking the consistency of the steering file. More... | |
void | registerInputCollections (const std::string &collectionType, const std::string ¶meterName, const std::string ¶meterDescription, StringVec ¶meter, const StringVec &defaultVal, int setSize=0) |
Specialization of registerProcessorParameter() for a parameter that defines one or several input collections - can be used fo checking the consistency of the steering file. More... | |
template<class T > | |
void | registerOptionalParameter (const std::string ¶meterName, const std::string ¶meterDescription, T ¶meter, const T &defaultVal, int setSize=0) |
Same as registerProcessorParameter except that the parameter is optional. More... | |
bool | parameterSet (const std::string &name) |
Tests whether the parameter has been set in the steering file. More... | |
void | checkForExistingParameter (const std::string ¶meterName) |
Tests whether the parameter has been registered before. More... | |
template<class T > | |
void | message (const std::string &m) const |
Print message according to verbosity level of the templated parameter (one of DEBUG, MESSAGE, WARNING, ERROR ) and the global parameter "Verbosity". More... | |
template<class T > | |
void | message (const std::basic_ostream< char, std::char_traits< char > > &m) const |
Same as message(const std::string& message) except that it allows the output of more complex messages in the argument using the log() method, e.g. More... | |
std::stringstream & | log () const |
Returns an empty stringstream that is used by the message method. More... | |
Protected Attributes | |
std::string | _description ="" |
Describes what the processor does. More... | |
std::string | _typeName ="" |
std::string | _processorName ="" |
std::shared_ptr< StringParameters > | _parameters {} |
ProcParamMap | _map {} |
bool | _isFirstEvent = false |
LCIOTypeMap | _inTypeMap {} |
LCIOTypeMap | _outTypeMap {} |
std::string | _logLevelName {} |
Private Member Functions | |
Processor (const Processor &)=delete | |
Processor & | operator= (const Processor &)=delete |
virtual void | setProcessorParameters (std::shared_ptr< StringParameters > processorParameters) |
Allow friend class CCProcessor to change/reset processor parameters. More... | |
virtual void | updateParameters () |
Allow friend class CCProcessor to update processor parameters. More... | |
virtual void | baseInit () |
Sets the registered steering parameters before calling init() More... | |
void | setFirstEvent (bool firstEvent) |
Called by ProcessorMgr. More... | |
void | setLCIOInType (const std::string &colName, const std::string &lcioInType) |
Set the expected LCIO type for a parameter that refers to one or more input collections, e.g. More... | |
void | setLCIOOutType (const std::string &collectionName, const std::string &lcioOutType) |
Set the LCIO type for a parameter that refers to an output collections, i.e. More... | |
const ProcParamMap & | procMap () |
Helper function for fixing old steering files. More... | |
Processor () | |
Private Attributes | |
std::stringstream * | _str =NULL |
Friends | |
class | ProcessorMgr |
class | CMProcessor |
class | XMLFixCollTypes |
Base class for Marlin processors.
Users can optionaly overwrite the following methods:
init, processRun, processEvent and end.
Use registerProcessorParameter to define all parameters that the module uses. Registered parameters are filled automatically before init() is called. With MyAplication -l you can print a list of available processors including the steering parameters they use/need.
With MyAplication -x you can print an example XML steering file for all known processors.
Definition at line 64 of file Processor.h.
|
privatedelete |
marlin::Processor::Processor | ( | const std::string & | typeName | ) |
Possible verbosity levels.
Global variable used to set the verbosity level Default constructor - subclasses need to call this in their default constructor.
Definition at line 14 of file Processor.cc.
References _logLevelName, marlin::ProcessorMgr::instance(), registerOptionalParameter(), and marlin::ProcessorMgr::registerProcessor().
|
virtual |
Destructor.
Definition at line 36 of file Processor.cc.
References _map, _str, std::map< K, T >::begin(), and std::map< K, T >::end().
|
private |
Definition at line 34 of file Processor.cc.
|
privatevirtual |
Sets the registered steering parameters before calling init()
Definition at line 214 of file Processor.cc.
References init().
|
inlinevirtual |
Called for every event - right after processEvent() has been called for this processor.
Use to check processing and/or produce check plots.
Reimplemented in marlin::SimpleFastMCProcessor, marlin::EventSelector, marlin::TestProcessor, MemoryMonitor, and Statusmonitor.
Definition at line 116 of file Processor.h.
|
inlineprotected |
Tests whether the parameter has been registered before.
name | name of the parameter to check |
logic_error | if parameter has been registered before |
Definition at line 335 of file Processor.h.
References std::endl(), and std::stringstream::str().
|
inline |
Description of processor.
Definition at line 193 of file Processor.h.
Referenced by marlin::CMProcessor::CMProcessor(), marlin::CCProcessor::getDescription(), printDescription(), and printDescriptionXML().
|
inlinevirtual |
Called after data processing for clean up in the inverse order of the init() method so that resources allocated in the first processor also will be available for all following processors.
Reimplemented in marlin::SimpleFastMCProcessor, marlin::LCIOOutputProcessor, marlin::EventSelector, marlin::TestProcessor, MemoryMonitor, Statusmonitor, and marlin::StdHepReader.
Definition at line 123 of file Processor.h.
std::string marlin::Processor::getLCIOInType | ( | const std::string & | colName | ) |
Return the LCIO input type for the collection colName - empty string if colName is not a registered collection name.
Definition at line 241 of file Processor.cc.
References _inTypeMap, and isInputCollectionName().
Referenced by marlin::CCProcessor::addColsFromParam(), and marlin::XMLFixCollTypes::parse().
std::string marlin::Processor::getLCIOOutType | ( | const std::string & | colName | ) |
Return the LCIO output type for the collection colName - empty string if colName is not a registered collection name.
Definition at line 250 of file Processor.cc.
References _outTypeMap, and isOutputCollectionName().
Referenced by marlin::CCProcessor::addColsFromParam(), and marlin::XMLFixCollTypes::parse().
|
inlinevirtual |
Called at the begin of the job before anything is read.
Use to initialize the processor, e.g. book histograms.
Reimplemented in marlin::SimpleFastMCProcessor, marlin::LCIOOutputProcessor, marlin::StdHepReader, marlin::EventSelector, marlin::TestProcessor, MemoryMonitor, and Statusmonitor.
Definition at line 101 of file Processor.h.
Referenced by baseInit().
|
inline |
True if first event in processEvent(evt) - use this e.g.
to initialize histograms etc.
Definition at line 198 of file Processor.h.
Referenced by marlin::SimpleFastMCProcessor::check(), marlin::TestProcessor::processEvent(), and marlin::StdHepReader::readDataSource().
bool marlin::Processor::isInputCollectionName | ( | const std::string & | parameterName | ) |
True if the given parameter defines an LCIO input collection, i.e.
the type has been defined with setLCIOInType().
Definition at line 259 of file Processor.cc.
References _inTypeMap, std::map< K, T >::end(), and std::map< K, T >::find().
Referenced by marlin::CCProcessor::addColsFromParam(), getLCIOInType(), marlin::XMLFixCollTypes::parse(), and printDescriptionXML().
bool marlin::Processor::isOutputCollectionName | ( | const std::string & | parameterName | ) |
True if the given parameter defines an LCIO output collection.
Definition at line 267 of file Processor.cc.
References _outTypeMap, std::map< K, T >::end(), and std::map< K, T >::find().
Referenced by marlin::CCProcessor::addColsFromParam(), getLCIOOutType(), marlin::XMLFixCollTypes::parse(), and printDescriptionXML().
|
protected |
Returns an empty stringstream that is used by the message method.
Definition at line 71 of file Processor.cc.
References _str.
|
inlinevirtual |
Return name of the local verbosity level of this processor - "" if not set.
Definition at line 136 of file Processor.h.
Referenced by marlin::TestProcessor::processEvent().
|
inlineprotected |
Print message according to verbosity level of the templated parameter (one of DEBUG, MESSAGE, WARNING, ERROR ) and the global parameter "Verbosity".
If Marlin is compiled w/o debug mode ($MARLINDEBUG not set) then DEBUG messages will be ignored completely at compile time, i.e. no output (and code!) will be generated, regardless of the value of the "Verbosity" parameter. This is useful in order to save CPU time in production mode.
Every line of the output string will be prepended by the verbosity level of the message and the processor name, e.g:
[ MESSAGE "MyTestProcessor" ] processing event 42 in run 4711
Use this method for simple strings. In order to use more complex messages, including numbers, use:
Definition at line 364 of file Processor.h.
References std::endl().
|
inlineprotected |
Same as message(const std::string& message) except that it allows the output of more complex messages in the argument using the log() method, e.g.
:
message<MESSAGE>( log() << " processing event " << evt->getEventNumber() << " in run " << evt->getRunNumber() ) ;
Definition at line 389 of file Processor.h.
References std::stringstream::str().
|
inlinevirtual |
Return name of this processor.
Reimplemented in marlin::EventSelector.
Definition at line 132 of file Processor.h.
Referenced by Statusmonitor::end(), MemoryMonitor::end(), marlin::LCIOOutputProcessor::end(), marlin::SimpleFastMCProcessor::end(), marlin::TestProcessor::init(), printDescriptionXML(), marlin::ProcessorEventSeeder::registerProcessor(), marlin::RewindDataFilesException::RewindDataFilesException(), marlin::ProcessorMgr::setProcessorReturnValue(), marlin::SkipEventException::SkipEventException(), and marlin::StopProcessingException::StopProcessingException().
|
pure virtual |
Return a new instance of the processor.
Has to be implemented by subclasses.
Implemented in marlin::SimpleFastMCProcessor, marlin::LCIOOutputProcessor, marlin::EventSelector, marlin::StdHepReader, MemoryMonitor, marlin::TestProcessor, and Statusmonitor.
Referenced by marlin::ProcessorMgr::addActiveProcessor(), and marlin::CMProcessor::CMProcessor().
|
inlinevirtual |
Return parameters defined for this Processor.
Definition at line 141 of file Processor.h.
Referenced by marlin::TestProcessor::init().
|
protected |
Tests whether the parameter has been set in the steering file.
Definition at line 204 of file Processor.cc.
References _map, std::map< K, T >::end(), and std::map< K, T >::find().
Referenced by marlin::LCIOOutputProcessor::dropCollections(), marlin::LCIOOutputProcessor::init(), and setParameters().
|
virtual |
Print information about this processor in ASCII steering file format.
Definition at line 85 of file Processor.cc.
References _map, std::map< K, T >::begin(), marlin::ProcessorParameter::defaultValue(), marlin::ProcessorParameter::description(), description(), std::map< K, T >::end(), std::endl(), marlin::ProcessorParameter::isOptional(), marlin::ProcessorParameter::name(), marlin::ProcessorParameter::type(), and type().
|
virtual |
Print information about this processor in XML steering file format.
Definition at line 135 of file Processor.cc.
References _inTypeMap, _map, _outTypeMap, std::map< K, T >::begin(), marlin::ProcessorParameter::defaultValue(), marlin::ProcessorParameter::description(), description(), std::map< K, T >::end(), std::endl(), isInputCollectionName(), marlin::ProcessorParameter::isOptional(), isOutputCollectionName(), marlin::ProcessorParameter::name(), name(), marlin::ProcessorParameter::type(), and type().
|
inline |
Print the parameters and their values depending on the given verbosity level.
Definition at line 156 of file Processor.h.
References std::endl().
Referenced by Statusmonitor::init(), MemoryMonitor::init(), marlin::EventSelector::init(), marlin::StdHepReader::init(), marlin::LCIOOutputProcessor::init(), and marlin::SimpleFastMCProcessor::init().
void marlin::Processor::printParameters | ( | ) |
Print the parameters and their values with verbosity level MESSAGE.
|
inlinevirtual |
Called for every event - the working horse.
Reimplemented in marlin::SimpleFastMCProcessor, marlin::LCIOOutputProcessor, marlin::EventSelector, marlin::TestProcessor, MemoryMonitor, and Statusmonitor.
Definition at line 110 of file Processor.h.
|
inlinevirtual |
Called for every run, e.g.
overwrite to initialize run dependent histograms.
Reimplemented in marlin::SimpleFastMCProcessor, marlin::LCIOOutputProcessor, marlin::EventSelector, marlin::TestProcessor, MemoryMonitor, and Statusmonitor.
Definition at line 106 of file Processor.h.
|
inlineprivate |
Helper function for fixing old steering files.
Definition at line 444 of file Processor.h.
Referenced by marlin::XMLFixCollTypes::parse().
|
inlineprotected |
Specialization of registerProcessorParameter() for a parameter that defines an input collection - can be used fo checking the consistency of the steering file.
Definition at line 268 of file Processor.h.
Referenced by marlin::SimpleFastMCProcessor::SimpleFastMCProcessor().
|
inlineprotected |
Specialization of registerProcessorParameter() for a parameter that defines one or several input collections - can be used fo checking the consistency of the steering file.
Definition at line 296 of file Processor.h.
|
inlineprotected |
Same as registerProcessorParameter except that the parameter is optional.
The value of the parameter will still be set to the default value, which is used to print an example steering line. Use parameterSet() to check whether it actually has been set in the steering file.
Definition at line 314 of file Processor.h.
Referenced by marlin::LCIOOutputProcessor::myConstruct(), and Processor().
|
inlineprotected |
Specialization of registerProcessorParameter() for a parameter that defines an output collection - can be used fo checking the consistency of the steering file.
Definition at line 282 of file Processor.h.
Referenced by marlin::SimpleFastMCProcessor::SimpleFastMCProcessor().
|
inlineprotected |
Register a steering variable for this processor - call in constructor of processor.
The default value has to be of the same type as the parameter, e.g.
float _cut ;
...
registerProcessorParameter( "Cut", "cut...", _cut , float( 3.141592 ) ) ;
as implicit conversions don't work for templates.
The optional parameter setSize is used for formating the printout of parameters. This can be used if the parameter values are expected to come in sets of fixed size.
Definition at line 254 of file Processor.h.
Referenced by marlin::EventSelector::EventSelector(), MemoryMonitor::MemoryMonitor(), marlin::LCIOOutputProcessor::myConstruct(), marlin::SimpleFastMCProcessor::SimpleFastMCProcessor(), Statusmonitor::Statusmonitor(), and marlin::StdHepReader::StdHepReader().
|
inlineprivate |
Called by ProcessorMgr.
Definition at line 424 of file Processor.h.
|
private |
Set the expected LCIO type for a parameter that refers to one or more input collections, e.g.
:
setReturnValue( "InputCollecitonName" , LCIO::MCPARTICLE ) ;
Set to LCIO::LCObject if more than one type is allowed, e.g. for a viewer processor.
Definition at line 237 of file Processor.cc.
References _inTypeMap.
|
private |
Set the LCIO type for a parameter that refers to an output collections, i.e.
the type has been defined with setLCIOOutType().
Definition at line 263 of file Processor.cc.
References _outTypeMap.
|
inlinevirtual |
Set processor name.
Definition at line 227 of file Processor.h.
Referenced by marlin::ProcessorMgr::addActiveProcessor().
|
virtual |
Helper function returns the ProcessorParameter for the given name.
Initialize the parameters
Definition at line 54 of file Processor.cc.
References _logLevelName, _parameters, parameterSet(), and updateParameters().
Referenced by marlin::ProcessorMgr::addActiveProcessor().
|
inlineprivatevirtual |
Allow friend class CCProcessor to change/reset processor parameters.
Definition at line 412 of file Processor.h.
|
protected |
Set the return value for this processor - typically at end of processEvent().
The value can be used in a condition in the steering file referred to by the name of the processor.
Definition at line 232 of file Processor.cc.
References marlin::ProcessorMgr::instance(), and marlin::ProcessorMgr::setProcessorReturnValue().
Referenced by marlin::TestProcessor::processEvent(), and marlin::EventSelector::processEvent().
|
protected |
Set a named return value for this processor - typically at end of processEvent() The value can be used in a condition in the steering file referred to by ProcessorName.name of the processor.
Definition at line 271 of file Processor.cc.
References marlin::ProcessorMgr::instance(), and marlin::ProcessorMgr::setProcessorReturnValue().
|
inlinevirtual |
Return type name for the processor (as set in constructor).
Definition at line 128 of file Processor.h.
Referenced by printDescription(), printDescriptionXML(), and marlin::ProcessorMgr::registerProcessor().
|
privatevirtual |
Allow friend class CCProcessor to update processor parameters.
Definition at line 222 of file Processor.cc.
References _map, _parameters, std::map< K, T >::begin(), std::map< K, T >::end(), and std::shared_ptr::get().
Referenced by setParameters().
|
friend |
Definition at line 67 of file Processor.h.
|
friend |
Definition at line 66 of file Processor.h.
|
friend |
Definition at line 68 of file Processor.h.
|
protected |
Describes what the processor does.
Set in constructor.
Definition at line 452 of file Processor.h.
Referenced by marlin::EventSelector::EventSelector(), MemoryMonitor::MemoryMonitor(), marlin::LCIOOutputProcessor::myConstruct(), marlin::SimpleFastMCProcessor::SimpleFastMCProcessor(), Statusmonitor::Statusmonitor(), marlin::StdHepReader::StdHepReader(), and marlin::TestProcessor::TestProcessor().
|
protected |
Definition at line 459 of file Processor.h.
Referenced by getLCIOInType(), isInputCollectionName(), printDescriptionXML(), and setLCIOInType().
|
protected |
Definition at line 458 of file Processor.h.
Referenced by marlin::StdHepReader::readDataSource().
|
protected |
Definition at line 462 of file Processor.h.
Referenced by Processor(), and setParameters().
|
protected |
Definition at line 457 of file Processor.h.
Referenced by parameterSet(), printDescription(), printDescriptionXML(), updateParameters(), and ~Processor().
|
protected |
Definition at line 460 of file Processor.h.
Referenced by getLCIOOutType(), isOutputCollectionName(), printDescriptionXML(), and setLCIOOutType().
|
protected |
Definition at line 455 of file Processor.h.
Referenced by setParameters(), and updateParameters().
|
protected |
Definition at line 454 of file Processor.h.
|
mutableprivate |
Definition at line 465 of file Processor.h.
Referenced by log(), and ~Processor().
|
protected |
Definition at line 453 of file Processor.h.