fire v0.19.0
Framework for sImulation and Reconstruction of Events
fire::Processor Class Referenceabstract

Base class for all event processing components. More...

#include <Processor.h>

Inheritance diagram for fire::Processor:
[legend]
Collaboration diagram for fire::Processor:
[legend]

Classes

class  AbortEventException
 Specific exception used to abort an event. More...
 
class  Factory
 The special factory used to create processors. More...
 

Public Member Functions

 Processor (const config::Parameters &ps)
 Configure the processor upon construction. More...
 
virtual ~Processor ()=default
 virtual default destructor so derived classes can be destructed
 
virtual void beforeNewRun (RunHeader &header)
 Handle allowing processors to modify run headers before the run begins. More...
 
virtual void onNewRun (const RunHeader &runHeader)
 Callback for the Processor to take any necessary action when the run being processed changes. More...
 
virtual void onFileOpen (const std::string &file_name)
 Callback for the Processor to take any necessary action when a new input event file is opened. More...
 
virtual void onFileClose (const std::string &file_name)
 Callback for the Processor to take any necessary action when a event input file is closed. More...
 
virtual void onProcessStart ()
 Callback for the Processor to take any necessary action when the processing of events starts.
 
virtual void onProcessEnd ()
 Callback for the Processor to take any necessary action when the processing of events finishes, such as calculating job-summary quantities.
 
const std::stringgetName () const
 Get the processor name.
 
virtual void process (Event &event)=0
 have the derived processors do what they need to do More...
 
virtual void attach (Process *p) final
 Attach the current process to this processor. More...
 
template<class T >
const T & getCondition (const std::string &condition_name)
 Access a conditions object for the current event. More...
 

Protected Member Functions

void setStorageHint (StorageControl::Hint hint, const std::string &purpose="") const
 Mark the current event as having the given storage control hint from this processor and the given purpose string. More...
 
void abortEvent ()
 Abort the event immediately. More...
 
void fatalError (const std::string &msg)
 End processing due to a fatal runtime error. More...
 

Protected Attributes

logging::logger theLog_
 The logger for this Processor. More...
 

Private Member Functions

ConditionsgetConditions () const
 Internal getter for conditions without exposing all of Process.
 

Private Attributes

std::string name_
 The name of the Processor.
 
Processprocess_ {nullptr}
 Handle to current process.
 

Detailed Description

Base class for all event processing components.

This is the main interface that users of fire will interact with. In order to perform a new task, a user would define a new Processor which can take data from the event bus, process it in some way, and then add new data onto the event bus. This format is applicable all along the data processing chain from generation (simulation or raw decoding) to reconstruction to analysis.

Callback Ordering

The ordering of the callback functions is decided by the Process::run and is helpful to document here for users creating new Processors.

  1. Constructor - before any processing begins, all of the processors are constructed and passed their configuration parameters.
  2. onProcessStart - before any processing begins but after the conditions providers are told the process is starting
  3. onFileOpen - only if there are input files, this is called before any events in the input file are processed
  4. beforeNewRun - called before conditions providers are given the run header when a new run is encountered (i.e. before processing begins when there are not input files or when the event header has a new run number when there are run numbers)
  5. onNewRun - called after conditions providers are given the run header
  6. process - called on each event
  7. onFileClose - only if there are input files, this is called after all events in the input file are processed
  8. onProcessEnd - all processing is done and the Processors are about to be destructed.
  9. Destructor - the processors are destructed automatically in the destruction of the core Process object

Constructor & Destructor Documentation

◆ Processor()

fire::Processor::Processor ( const config::Parameters ps)

Configure the processor upon construction.

The parameters a processor has access to are the member variables of the python class in the sequence that has class_name equal to the Processor class name.

This base class assumes the existence of an additional parameter 'name' for which a logger can be constructed and an error message can be labeled.

Parameters
[in]psParameter set to be used to configure this processor

Member Function Documentation

◆ abortEvent()

void fire::Processor::abortEvent ( )
inlineprotected

Abort the event immediately.

Skip the rest of the sequence and don't save anything in the event bus.

◆ attach()

virtual void fire::Processor::attach ( Process p)
inlinefinalvirtual

Attach the current process to this processor.

Marked 'final' to prevent derived classes from redefining this function and potentially abusing the handle to the current process.

Parameters
[in]ppointer to current Process

◆ beforeNewRun()

virtual void fire::Processor::beforeNewRun ( RunHeader header)
inlinevirtual

Handle allowing processors to modify run headers before the run begins.

This is called before any conditions providers are given the run header, so it can be used to provide parameters that conditions providers require.

Parameters
headerRunHeader for Processor to add parameters to

Reimplemented in framework::Analyzer.

◆ fatalError()

void fire::Processor::fatalError ( const std::string msg)
inlineprotected

End processing due to a fatal runtime error.

Parameters
[in]msgError message to printout

◆ getCondition()

template<class T >
const T & fire::Processor::getCondition ( const std::string condition_name)
inline

Access a conditions object for the current event.

See also
Conditions::get and Conditions::getConditionPtr for how conditions objects are retrieved.

Usage

Inside of the process function, this function can be used following the example below.

// inside void process(Event& event) for your Processor
const auto& co = getCondition<MyObjectType>("ConditionName");

The const and & are there because auto is not usually able to deduce that they are necessary and without them, a deep copy of the condition object would be made at this point.

Template Parameters
Ttype of condition object
Parameters
[in]condition_nameName of condition object to retrieve
Returns
const handle to the condition object

◆ onFileClose()

virtual void fire::Processor::onFileClose ( const std::string file_name)
inlinevirtual

Callback for the Processor to take any necessary action when a event input file is closed.

Note
This callback is only used with their are input files.
Parameters
[in]filenameInput event file name

◆ onFileOpen()

virtual void fire::Processor::onFileOpen ( const std::string file_name)
inlinevirtual

Callback for the Processor to take any necessary action when a new input event file is opened.

Note
This callback is only used with their are input files.
Parameters
[in]filenameInput event file name.

◆ onNewRun()

virtual void fire::Processor::onNewRun ( const RunHeader runHeader)
inlinevirtual

Callback for the Processor to take any necessary action when the run being processed changes.

This is called after any conditions providers are configured with the run header, so it can be used for internal book-keeping within the processor and it can be used to acquire conditions that do not change with respect to changing event contexts.

Parameters
runHeaderThe RunHeader containing run information.

◆ process()

virtual void fire::Processor::process ( Event event)
pure virtual

have the derived processors do what they need to do

See also
Event::get for retrieve event data objects
Event::add for adding new data objects
Parameters
[in]eventEvent holding the data to be processed

Implemented in framework::Producer, framework::Analyzer, and framework::EventProcessor.

◆ setStorageHint()

void fire::Processor::setStorageHint ( StorageControl::Hint  hint,
const std::string purpose = "" 
) const
protected

Mark the current event as having the given storage control hint from this processor and the given purpose string.

Parameters
[in]hintThe storage control hint to apply for the given event
[in]purposeA purpose string which can be used in the skim control configuration to select which hints to "listen" to

Member Data Documentation

◆ theLog_

logging::logger fire::Processor::theLog_
mutableprotected

The logger for this Processor.

The channel name for this logging stream is set to the name of the processor as configured in the Processor constructor.


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