Mēnsūra
Public Types | Public Member Functions | Protected Member Functions | List of all members
Plugin Class Referenceabstract

An abstract class to define a plugin to be used in class Processor. More...

#include <Plugin.hpp>

Inheritance diagram for Plugin:
AnalysisPlugin ReaderPlugin BasicKinematicsPlugin BTagEffHistograms EventIDFilter EventIDReminderFilter EventWeightPlugin JetFilter JetFunctorFilter LeptonFilter LumiMaskFilter MetFilter PECTriggerFilter WeightCollector EventIDReader GeneratorReader GenJetMETReader GenParticleReader JetMETReader LeptonReader PileUpReader

Public Types

enum  EventOutcome { EventOutcome::Ok, EventOutcome::FilterFailed, EventOutcome::NoEvents }
 Outcome of processing of an event. More...
 

Public Member Functions

 Plugin (std::string const &name)
 Constructor.
 
 Plugin (Plugin const &)=default
 Default copy constructor.
 
 Plugin (Plugin &&)=default
 Default move constructor.
 
Pluginoperator= (Plugin const &)=default
 Default assignment operator.
 
virtual ~Plugin ()
 Trivial destructor.
 
virtual void BeginRun (Dataset const &dataset)
 Performs initialization needed when processing of a new dataset starts. More...
 
virtual PluginClone () const =0
 Clones the object. More...
 
virtual void EndRun ()
 Performs necessary actions needed after processing of a dataset is finished. More...
 
Processor const & GetMaster () const
 Returns a reference to the master. More...
 
std::string const & GetName () const
 Returns name of the plugin.
 
EventOutcome ProcessEventToOutcome ()
 Processes a new event from the current dataset. More...
 
void SetMaster (Processor const *processor)
 Provides a pointer to an instance of Processor class that owns the plugin. More...
 

Protected Member Functions

Plugin const * GetDependencyPlugin (std::string const &name) const
 Returns a pointer to a precedent plugin in the path with the given name. More...
 

Detailed Description

An abstract class to define a plugin to be used in class Processor.

The class specifies a simple interface that allows to perform a certain processing for each event in a dataset and, additionally, notify the plugin when processing of the dataset starts and finishes. It contains a pointer to the parent Processor instance that can be used to access other plugins attached to the same Processor.

A single plugin might be used to process several datasets, which requires certain initialization and termination actions to be performed in BeginRun/EndRun methods in case of non-trivial plugins. The pointer to the parent Processor instance is initialized before processing of the first dataset starts and is expected to be valid during the lifetime of the plugin.

A derived class might or might not be copyable, but it must implement a method to clone an instance. The clonning must address only configuration of the processing algorithm but not data members specific for a dataset or an event (e.g. handlers of output files). Such a functionality is required to multiplicate the plugin structure for each thread represented by class Processor.

A derived class must be capable of working in a multi-thread mode. The user should pay attention to the fact that ROOT is not thread-safe. For this reason all critical blocks (which include, for example, creation of any ROOT objects) must be guarded with the help of class ROOTLock.

A derived class must define a valid move constructor.

The user is not advised to inherit directly from this class but use classes ReaderPlugin and AnalysisPlugin instead.

Member Enumeration Documentation

enum Plugin::EventOutcome
strong

Outcome of processing of an event.

Enumerator
Ok 

Everything is fine.

FilterFailed 

Event fails filtering implemented by the plugin.

NoEvents 

There are no events left in the input dataset.

Member Function Documentation

void Plugin::BeginRun ( Dataset const &  dataset)
virtual
virtual Plugin* Plugin::Clone ( ) const
pure virtual

Clones the object.

The method must create a new instance of the (derived) class with the same constructor parameters. The method must not address any parameters specific to a run or an event. Technically it means the method must create a new instance of the class exactly in the same way this has been created and initialized.

The method is used when unique copies of plugins are created for each instance of class Processor. Clonning is performed before call to SetMaster and before the first call to BeginRun.

Implemented in PECTriggerFilterMC, LeptonFilter, PECTriggerFilterData, JetFilter, LeptonSFWeight, BTagEffHistograms, PileUpWeight, BTagWeight, LumiMaskFilter, PECJetMETReader, GenWeightSyst, PECInputData, MetFilter, EventIDFilter, BasicKinematicsPlugin, JetMETUpdate, EventIDReminderFilter, BTagWeightCSVShape, PECLeptonReader, JetFunctorFilter, PECGenParticleReader, PECGeneratorReader, PECGenJetMETReader, WeightCollector, PECPileUpReader, and PECTriggerFilter.

void Plugin::EndRun ( )
virtual

Performs necessary actions needed after processing of a dataset is finished.

The method is trivial in the default implementation.

Reimplemented in BTagEffHistograms, and PECInputData.

Plugin const * Plugin::GetDependencyPlugin ( std::string const &  name) const
protected

Returns a pointer to a precedent plugin in the path with the given name.

The plugin is requested from the master. If it is not found, an exception is thrown.

Processor const & Plugin::GetMaster ( ) const

Returns a reference to the master.

Will throw an exception if the pointer to master is null.

Plugin::EventOutcome Plugin::ProcessEventToOutcome ( )

Processes a new event from the current dataset.

The actual processing is delegated to pure virtual method ProcessEvent, which is to be implemented in a derived class. The boolean decision of this method is reinterpreted with the help of pure virtual method ReinterpretDecision.

The returned value can used by the parent Processor to alter execution of the event loop.

void Plugin::SetMaster ( Processor const *  processor)

Provides a pointer to an instance of Processor class that owns the plugin.

The pointer is guaranteed to be initialized before the first call to BeginRun. It stays valid for the lifetime of the object.


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