MarlinMT
0.1.0
|
#include <Processor.h>
Inherits marlinmt::Component.
Inherited by marlinmt::CPUCrunchingProcessor, marlinmt::DumpEventProcessor, marlinmt::EventSelectorProcessor, marlinmt::LCIOEventUnpackingProcessor, marlinmt::LCIOOutputProcessor, marlinmt::MemoryMonitorProcessor, marlinmt::Statusmonitor, and marlinmt::TestProcessor.
Public Types | |
enum | ERuntimeOption { ERuntimeOption::eCritical, ERuntimeOption::eClone } |
ERuntimeOption enumerator. More... | |
using | RuntimeOptions = std::map< ERuntimeOption, bool > |
Public Types inherited from marlinmt::Component | |
using | LoggerPtr = Logging::Logger |
Public Types inherited from marlinmt::Configurable | |
using | ParameterMap = std::map< std::string, std::shared_ptr< ParameterImpl > > |
using | iterator = ParameterMap::iterator |
using | const_iterator = ParameterMap::const_iterator |
Public Member Functions | |
virtual | ~Processor ()=default |
Processor (const std::string &t) | |
Constructor. More... | |
virtual void | init () |
Initialize the processor. More... | |
virtual void | processRunHeader (RunHeader *) |
Call at start of run. More... | |
virtual void | processEvent (EventStore *) |
Process an input event. More... | |
virtual void | end () |
Terminate the processor. More... | |
std::optional< bool > | runtimeOption (ERuntimeOption option) const |
Get the forced runtime option settings. More... | |
Public Member Functions inherited from marlinmt::Component | |
Component ()=delete | |
No default constructor. More... | |
Component (const Component &)=delete | |
No copy or assignement. More... | |
Component & | operator= (const Component &)=delete |
virtual | ~Component ()=default |
Default destructor. More... | |
Component (const std::string &type) | |
Constructor with component type. More... | |
const std::string & | type () const |
Get the component name. More... | |
const std::string & | name () const |
Get the component name. More... | |
void | setName (const std::string &n) |
Set the component name. More... | |
const std::string & | description () const |
Get the component description. More... | |
void | setDescription (const std::string &desc) |
Set the component description. More... | |
const Application & | application () const |
Get the application in which the component is registered. More... | |
Application & | application () |
Get the application in which the component is registered. More... | |
template<class T > | |
Logging::StreamType | log () const |
Log a message with specific log level. More... | |
Logging::StreamType | debug () const |
Shortcut for log<DEBUG>() More... | |
Logging::StreamType | message () const |
Shortcut for log<MESSAGE>() More... | |
Logging::StreamType | warning () const |
Shortcut for log<WARNING>() More... | |
Logging::StreamType | error () const |
Shortcut for log<ERROR>() More... | |
void | setVerbosity (const std::string &level) |
Set the verbosity level. More... | |
const std::string & | verbosity () const |
Get the verbosity level. More... | |
bool | isInitialized () const |
Whether the component has been initialized. More... | |
void | setup (Application *app) |
Setup the component. More... | |
void | printParameters () const |
Print the component parameters. More... | |
template<class T > | |
void | printParameters () const |
Print the component parameters at specific verbosity. More... | |
void | setParameters (const ConfigSection §ion, bool throwIfNotFound=false) |
Set the parameters from the configuration section. More... | |
void | getParameters (ConfigSection §ion, const std::set< std::string > &exclude={}) const |
Get the parameters from configurable object and populate the config section with. More... | |
Public Member Functions inherited from marlinmt::Configurable | |
Configurable ()=default | |
virtual | ~Configurable ()=default |
template<typename T > | |
std::shared_ptr< ParameterImpl > | addParameter (EParameterType paramType, const std::string &name, const std::string &desc, std::shared_ptr< T > value) |
Add a parameter. More... | |
template<typename T > | |
std::shared_ptr< ParameterImpl > | addParameter (EParameterType paramType, const std::string &name, const std::string &desc, std::shared_ptr< T > value, T defVal) |
Add a parameter. More... | |
template<typename T > | |
T | parameter (const std::string &name) const |
Get a parameter value. More... | |
template<typename T > | |
T | parameter (const std::string &name, const T &fallback) const |
Get a parameter value. More... | |
void | checkParameter (const std::string &name) const |
Check if the parameter has been registered. More... | |
bool | exists (const std::string &name) const |
Return true if the parameter has been registered. More... | |
bool | isSet (const std::string &name) const |
Returns true if the parameter exists and is set, false otherwise. More... | |
void | clear () |
Remove all parameters. More... | |
void | unset () |
Unset all registered parameters. More... | |
iterator | begin () |
const_iterator | begin () const |
iterator | end () |
const_iterator | end () const |
Protected Member Functions | |
void | setRuntimeOption (ERuntimeOption option, bool value) |
Force the runtime option to a given boolean value. More... | |
Private Member Functions | |
Processor ()=delete | |
Processor (const Processor &)=delete | |
Processor & | operator= (const Processor &)=delete |
void | initialize () override |
From Component class. More... | |
Private Attributes | |
RuntimeOptions | _forcedRuntimeOptions {} |
The user forced runtime options for parallel processing. More... | |
Friends | |
class | ProcessorApi |
Additional Inherited Members | |
Protected Attributes inherited from marlinmt::Component | |
std::string | _type {} |
The component type. More... | |
std::string | _name {} |
The component name. More... | |
std::string | _description {"No description"} |
The component description. More... | |
Application * | _application {nullptr} |
The application in which the component has been registered. More... | |
LoggerPtr | _logger {nullptr} |
The logger instance. More... | |
StringParameter | _verbosity { *this, "Verbosity", "The component verbosity level", "MESSAGE" } |
The verbosity level of the logger (parameter) More... | |
Protected Attributes inherited from marlinmt::Configurable | |
ParameterMap | _parameters {} |
The parameter map. More... | |
Processor class.
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 43 of file Processor.h.
using marlinmt::Processor::RuntimeOptions = std::map<ERuntimeOption, bool> |
Definition at line 63 of file Processor.h.
|
strong |
ERuntimeOption enumerator.
Enumerator | |
---|---|
eCritical | |
eClone | Whether the processor has to be executed in a critical section. Whether the processor must be cloned in each thread worker |
Definition at line 58 of file Processor.h.
|
privatedelete |
|
privatedelete |
|
virtualdefault |
marlinmt::Processor::Processor | ( | const std::string & | t | ) |
Constructor.
Subclasses need to call this in their default constructor.
t | the processor type |
Definition at line 8 of file Processor.cc.
|
inlinevirtual |
Terminate the processor.
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 marlinmt::LCIOOutputProcessor, marlinmt::TestProcessor, and marlinmt::Statusmonitor.
Definition at line 97 of file Processor.h.
References initialize(), runtimeOption(), setRuntimeOption(), and marlinmt::book::Flags::value().
|
inlinevirtual |
Initialize the processor.
Called at the begin of the job before anything is read. Use to initialize the processor, e.g. book histograms.
Reimplemented in marlinmt::LCIOOutputProcessor, marlinmt::MemoryMonitorProcessor, marlinmt::EventSelectorProcessor, marlinmt::TestProcessor, marlinmt::Statusmonitor, marlinmt::DumpEventProcessor, marlinmt::CPUCrunchingProcessor, and marlinmt::LCIOEventUnpackingProcessor.
Definition at line 78 of file Processor.h.
Referenced by initialize().
|
overrideprivatevirtual |
From Component class.
Reimplemented from marlinmt::Component.
Definition at line 15 of file Processor.cc.
References marlinmt::Component::application(), marlinmt::Application::configuration(), init(), marlinmt::Component::name(), marlinmt::Configuration::section(), and marlinmt::Component::setParameters().
Referenced by end().
|
inlinevirtual |
Process an input event.
Called for every event - the working horse.
Reimplemented in marlinmt::LCIOOutputProcessor, marlinmt::TestProcessor, marlinmt::MemoryMonitorProcessor, marlinmt::Statusmonitor, marlinmt::EventSelectorProcessor, marlinmt::DumpEventProcessor, marlinmt::CPUCrunchingProcessor, and marlinmt::LCIOEventUnpackingProcessor.
Definition at line 89 of file Processor.h.
|
inlinevirtual |
Call at start of run.
Reimplemented in marlinmt::LCIOOutputProcessor, marlinmt::TestProcessor, and marlinmt::Statusmonitor.
Definition at line 83 of file Processor.h.
std::optional< bool > marlinmt::Processor::runtimeOption | ( | ERuntimeOption | option | ) | const |
Get the forced runtime option settings.
The return value is set if the forced option was specified by the user.
option | the runtime option to get |
Definition at line 26 of file Processor.cc.
References _forcedRuntimeOptions.
Referenced by end().
|
protected |
Force the runtime option to a given boolean value.
Depending on the implementation of your processor, setting one of the runtime option might be a necessity. For example, you handle a lot of data in your processor members that you don't want to duplicate. In this case you should call in the constructor
The code contained in processEvent() might also not be thread safe. In this case you can ask the Marlin framework to call the processEvent() method in a critical section (using std::mutex). Do to so, call:
If a runtime option is forced in the code and the steering file tries to overwrite it, an exception will be raised.
Note that this method must be called in user processor constructor to ensure it is correctly handled by the framework at configuration time.
option | the runtime option to force |
value | the boolean value to set |
Definition at line 37 of file Processor.cc.
References _forcedRuntimeOptions, and marlinmt::book::Flags::value().
Referenced by marlinmt::DumpEventProcessor::DumpEventProcessor(), end(), marlinmt::LCIOOutputProcessor::LCIOOutputProcessor(), marlinmt::MemoryMonitorProcessor::MemoryMonitorProcessor(), and marlinmt::Statusmonitor::Statusmonitor().
|
friend |
Definition at line 44 of file Processor.h.
|
private |
The user forced runtime options for parallel processing.
Definition at line 142 of file Processor.h.
Referenced by runtimeOption(), and setRuntimeOption().