LDMX Software
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
framework::EventProcessor Class Reference

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

#include <EventProcessor.h>

Public Member Functions

 EventProcessor (const std::string &name, Process &process)
 Class constructor.
 
virtual ~EventProcessor ()
 Class destructor.
 
virtual void configure (framework::config::Parameters &parameters)
 Callback for the EventProcessor to configure itself from the given set of parameters.
 
virtual void onNewRun (const ldmx::RunHeader &runHeader)
 Callback for the EventProcessor to take any necessary action when the run being processed changes.
 
virtual void onFileOpen (EventFile &eventFile)
 Callback for the EventProcessor to take any necessary action when a new event input ROOT file is opened.
 
virtual void onFileClose (EventFile &eventFile)
 Callback for the EventProcessor to take any necessary action when a event input ROOT file is closed.
 
virtual void onProcessStart ()
 Callback for the EventProcessor to take any necessary action when the processing of events starts, such as creating histograms.
 
virtual void onProcessEnd ()
 Callback for the EventProcessor to take any necessary action when the processing of events finishes, such as calculating job-summary quantities.
 
template<class T >
const T & getCondition (const std::string &condition_name)
 Access a conditions object for the current event.
 
TDirectory * getHistoDirectory ()
 Access/create a directory in the histogram file for this event processor to create histograms and analysis tuples.
 
void setStorageHint (framework::StorageControl::Hint hint)
 Mark the current event as having the given storage control hint from this module.
 
void setStorageHint (framework::StorageControl::Hint hint, const std::string &purposeString)
 Mark the current event as having the given storage control hint from this module and the given purpose string.
 
int getLogFrequency () const
 Get the current logging frequency from the process.
 
int getRunNumber () const
 Get the run number from the process.
 
std::string getName () const
 Get the processor name.
 
void createHistograms (const std::vector< framework::config::Parameters > &histos)
 Internal function which is used to create histograms passed from the python configuration @parma histos vector of Parameters that configure histograms to create.
 

Static Public Member Functions

static void declare (const std::string &classname, int classtype, EventProcessorMaker *)
 Internal function which is part of the PluginFactory machinery.
 

Protected Member Functions

void abortEvent ()
 Abort the event immediately.
 

Protected Attributes

HistogramHelper histograms_
 Interface class for making and filling histograms.
 
NtupleManagerntuple_ {NtupleManager::getInstance()}
 Manager for any ntuples.
 
logging::logger theLog_
 The logger for this EventProcessor.
 

Private Member Functions

ConditionsgetConditions () const
 Internal getter for conditions without exposing all of Process.
 
const ldmx::EventHeadergetEventHeader () const
 Internal getter for EventHeader without exposing all of Process.
 

Private Attributes

Processprocess_
 Handle to the Process.
 
std::string name_
 The name of the EventProcessor.
 
TDirectory * histoDir_ {0}
 Histogram directory.
 

Detailed Description

Base class for all event processing components.

Definition at line 65 of file EventProcessor.h.

Constructor & Destructor Documentation

◆ EventProcessor()

framework::EventProcessor::EventProcessor ( const std::string &  name,
Process process 
)

Class constructor.

Parameters
nameName for this instance of the class.
processThe Process class associated with EventProcessor, provided by the framework.
Note
The name provided to this function should not be the class name, but rather a logical label for this instance of the class, as more than one copy of a given class can be loaded into a Process with different parameters. Names should not include whitespace or special characters.

Definition at line 11 of file EventProcessor.cxx.

12 : histograms_{name},
13 theLog_{logging::makeLogger(name)},
14 process_{process},
15 name_{name} {}
Process & process_
Handle to the Process.
std::string name_
The name of the EventProcessor.
logging::logger theLog_
The logger for this EventProcessor.
HistogramHelper histograms_
Interface class for making and filling histograms.

◆ ~EventProcessor()

virtual framework::EventProcessor::~EventProcessor ( )
inlinevirtual

Class destructor.

Definition at line 84 of file EventProcessor.h.

84{ ; }

Member Function Documentation

◆ abortEvent()

void framework::EventProcessor::abortEvent ( )
inlineprotected

Abort the event immediately.

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

Definition at line 213 of file EventProcessor.h.

213{ throw AbortEventException(); }

Referenced by packing::SingleSubsystemPacker::analyze(), hcal::HcalAlignPolarfires::produce(), packing::RawIO::produce(), packing::SingleSubsystemUnpacker::produce(), simcore::ReSimulator::produce(), and simcore::Simulator::produce().

◆ configure()

virtual void framework::EventProcessor::configure ( framework::config::Parameters parameters)
inlinevirtual

Callback for the EventProcessor to configure itself from the given set of parameters.

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

For an example, look at MyProcessor.

Parameters
parametersParameters for configuration.

Reimplemented in ecal::EcalDigiProducer, ecal::EcalRawDecoder, ecal::EcalRawEncoder, ecal::EcalRecProducer, ecal::EcalTrigPrimDigiProducer, trigger::NtupleWriter, trigger::PropagationMapWriter, recon::EcalPreselectionSkimmer, packing::FiberTrackerRawDecoder, packing::WRRawDecoder, hcal::HcalDigiProducer, hcal::HcalRawDecoder, hcal::HcalRecProducer, hcal::HcalTrigPrimDigiProducer, framework::test::TestProducer, hcal::HcalDoubleEndRecProducer, hcal::HcalSingleEndRecProducer, framework::test::TestConfig, dqm::HCalDQM, dqm::HcalGeometryVerifier, dqm::HcalInefficiencyAnalyzer, dqm::HCalRawDigi, dqm::PhotoNuclearDQM, dqm::RecoilTrackerDQM, dqm::ReSimVerifier, ecal::DNNEcalVetoProcessor, ecal::EcalClusterProducer, ecal::EcalVetoProcessor, hcal::HcalClusterProducer, hcal::HcalVetoProcessor, hcal::HcalWABVetoProcessor, recon::BeamElectronLocator, recon::ElectronCounter, recon::MyProcessor, recon::OverlayProducer, recon::SequentialTrigger, recon::TriggerProcessor, simcore::ReSimulator, simcore::Simulator, simcore::SimulatorBase, tracking::dqm::TrackingRecoDQM, tracking::reco::AlignmentTestProcessor, tracking::reco::CKFProcessor, tracking::reco::DigitizationProcessor, tracking::reco::GSFProcessor, tracking::reco::SeedFinderProcessor, tracking::reco::TruthSeedProcessor, tracking::reco::Vertexer, tracking::reco::VertexProcessor, trigscint::EventReadoutProducer, trigscint::QIEAnalyzer, trigscint::QualityFlagAnalyzer, trigscint::TestBeamClusterAnalyzer, trigscint::TestBeamHitAnalyzer, trigscint::TestBeamHitProducer, trigscint::TrigScintDigiProducer, trigscint::TrigScintQIEDigiProducer, trigscint::TrigScintRecHitProducer, trigscint::TruthHitProducer, dqm::EcalDigiVerifier, dqm::EcalMipTrackingFeatures, dqm::EcalShowerFeatures, dqm::EcalVetoResults, dqm::SimObjects, dqm::Trigger, recon::ParticleFlow, recon::PFEcalClusterProducer, recon::PFHcalClusterProducer, recon::PFTrackProducer, recon::PFTruthProducer, trigger::DumpFileWriter, trigger::EcalTPSelector, trigger::TrigEcalClusterProducer, trigger::TrigEcalEnergySum, trigger::TrigElectronProducer, trigger::TrigHcalEnergySum, trigscint::TestBeamClusterProducer, dqm::NtuplizeHgcrocDigiCollection, dqm::NtuplizeTrigScintQIEDigis, dqm::SampleValidation, hcal::HcalAlignPolarfires, hcal::HcalPedestalAnalyzer, packing::RawIO, packing::SingleSubsystemPacker, packing::SingleSubsystemUnpacker, trigscint::QIEDecoder, trigscint::QIEEncoder, trigscint::TrigScintClusterProducer, trigscint::TrigScintFirmwareHitProducer, trigscint::TrigScintFirmwareTracker, trigscint::TrigScintTrackProducer, dqm::TrigScintClusterDQM, dqm::TrigScintDQM, dqm::TrigScintHitDQM, and dqm::TrigScintTrackDQM.

Definition at line 98 of file EventProcessor.h.

98{}

Referenced by framework::Process::Process().

◆ createHistograms()

void framework::EventProcessor::createHistograms ( const std::vector< framework::config::Parameters > &  histos)

Internal function which is used to create histograms passed from the python configuration @parma histos vector of Parameters that configure histograms to create.

Definition at line 50 of file EventProcessor.cxx.

51 {
52 for (auto const &h : histos) {
53 auto name{h.getParameter<std::string>("name")};
54 auto xLabel{h.getParameter<std::string>("xlabel")};
55 auto xbins{h.getParameter<std::vector<double>>("xbins")};
56 auto yLabel{h.getParameter<std::string>("ylabel")};
57 auto ybins{h.getParameter<std::vector<double>>("ybins", {})};
58 if (ybins.empty()) {
59 // assume 1D histogram
60 histograms_.create(name, xLabel, xbins);
61 } else {
62 // assume 2D histogram
63 histograms_.create(name, xLabel, xbins, yLabel, ybins);
64 }
65 }
66}
void create(const std::string &name, const std::string &xLabel, const double &bins, const double &xmin, const double &xmax)
Create a ROOT 1D histogram of type TH1F and pool it for later use.

References framework::HistogramHelper::create(), and histograms_.

Referenced by framework::Process::Process().

◆ declare()

void framework::EventProcessor::declare ( const std::string &  classname,
int  classtype,
EventProcessorMaker maker 
)
static

Internal function which is part of the PluginFactory machinery.

Parameters
classnameThe class name of the processor.
classtypeThe class type of the processor (1 for Producer, 2 for Analyzer).

Definition at line 44 of file EventProcessor.cxx.

45 {
47 maker);
48}
void registerEventProcessor(const std::string &classname, int classtype, EventProcessorMaker *maker)
Register the event processor.
static PluginFactory & getInstance()
Get the factory instance.

References framework::PluginFactory::getInstance(), and framework::PluginFactory::registerEventProcessor().

◆ getCondition()

template<class T >
const T & framework::EventProcessor::getCondition ( const std::string &  condition_name)
inline

Access a conditions object for the current event.

Definition at line 141 of file EventProcessor.h.

141 {
142 return getConditions().getCondition<T>(condition_name);
143 }
const T & getCondition(const std::string &condition_name)
Primary request action for a conditions object If the object is in the cache and still valid (IOV),...
Definition Conditions.h:83
Conditions & getConditions() const
Internal getter for conditions without exposing all of Process.

References framework::Conditions::getCondition(), and getConditions().

Referenced by simcore::ConditionsInterface::getCondition().

◆ getConditions()

Conditions & framework::EventProcessor::getConditions ( ) const
private

Internal getter for conditions without exposing all of Process.

Definition at line 17 of file EventProcessor.cxx.

17 {
18 return process_.getConditions();
19}
Conditions & getConditions()
Get a reference to the conditions system.
Definition Process.h:78

References framework::Process::getConditions(), and process_.

Referenced by getCondition().

◆ getEventHeader()

const ldmx::EventHeader & framework::EventProcessor::getEventHeader ( ) const
private

Internal getter for EventHeader without exposing all of Process.

Definition at line 21 of file EventProcessor.cxx.

21 {
22 return *(process_.getEventHeader());
23}
const ldmx::EventHeader * getEventHeader() const
Get the pointer to the current event header, if defined.
Definition Process.h:68

References framework::Process::getEventHeader(), and process_.

◆ getHistoDirectory()

TDirectory * framework::EventProcessor::getHistoDirectory ( )

Access/create a directory in the histogram file for this event processor to create histograms and analysis tuples.

Note
This method makes the returned directory the current directory so that newly created objects should go into that directory
Returns
TDirectory* reference to directory in histogram file

Definition at line 25 of file EventProcessor.cxx.

25 {
26 if (!histoDir_) {
28 }
29 histoDir_->cd(); // make this the current directory
30 return histoDir_;
31}
TDirectory * histoDir_
Histogram directory.
TDirectory * makeHistoDirectory(const std::string &dirName)
Construct a TDirectory* for the given module.
Definition Process.cxx:424

References histoDir_, framework::Process::makeHistoDirectory(), name_, and process_.

Referenced by dqm::SimObjects::createCalorimeterHists(), dqm::SimObjects::createTrackerHists(), dqm::SimObjects::onProcessStart(), dqm::Trigger::onProcessStart(), dqm::TrigScintClusterDQM::onProcessStart(), dqm::TrigScintDQM::onProcessStart(), dqm::TrigScintHitDQM::onProcessStart(), dqm::TrigScintTrackDQM::onProcessStart(), dqm::NtuplizeHgcrocDigiCollection::onProcessStart(), dqm::NtuplizeTrigScintQIEDigis::onProcessStart(), ecal::test::EcalCheckEnergyReconstruction::onProcessStart(), framework::test::TestAnalyzer::onProcessStart(), hcal::test::HcalCheckReconstruction::onProcessStart(), packing::FiberTrackerRawDecoder::onProcessStart(), packing::WRRawDecoder::onProcessStart(), dqm::HCalRawDigi::onProcessStart(), and framework::Process::Process().

◆ getLogFrequency()

int framework::EventProcessor::getLogFrequency ( ) const

Get the current logging frequency from the process.

Returns
int frequency logging should occurr

Definition at line 38 of file EventProcessor.cxx.

38 {
40}
int getLogFrequency() const
Get the frequency with which the event information is printed.
Definition Process.h:84

References framework::Process::getLogFrequency(), and process_.

◆ getName()

std::string framework::EventProcessor::getName ( ) const
inline

Get the processor name.

Definition at line 188 of file EventProcessor.h.

188{ return name_; }

References name_.

Referenced by tracking::reco::SeedFinderProcessor::configure(), ecal::EcalTrigPrimDigiProducer::produce(), and hcal::HcalTrigPrimDigiProducer::produce().

◆ getRunNumber()

int framework::EventProcessor::getRunNumber ( ) const

Get the run number from the process.

Returns
int run number

Definition at line 42 of file EventProcessor.cxx.

42{ return process_.getRunNumber(); }
int getRunNumber() const
Get the current run number or the run number to be used when initiating new events from the job.
Definition Process.cxx:420

References framework::Process::getRunNumber(), and process_.

◆ onFileClose()

virtual void framework::EventProcessor::onFileClose ( EventFile eventFile)
inlinevirtual

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

Parameters
filenameInput event ROOT file name
Note
This callback is rarely used.

Definition at line 121 of file EventProcessor.h.

121{}

◆ onFileOpen()

virtual void framework::EventProcessor::onFileOpen ( EventFile eventFile)
inlinevirtual

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

Parameters
filenameInput event ROOT file name.
Note
This callback is rarely used.

Definition at line 113 of file EventProcessor.h.

113{}

◆ onNewRun()

virtual void framework::EventProcessor::onNewRun ( const ldmx::RunHeader runHeader)
inlinevirtual

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

Parameters
runHeaderThe RunHeader containing run information.

Reimplemented in recon::OverlayProducer, simcore::Simulator, tracking::reco::DigitizationProcessor, tracking::reco::AlignmentTestProcessor, tracking::reco::CKFProcessor, tracking::reco::GSFProcessor, and tracking::reco::TruthSeedProcessor.

Definition at line 105 of file EventProcessor.h.

105{}

◆ onProcessEnd()

virtual void framework::EventProcessor::onProcessEnd ( )
inlinevirtual

◆ onProcessStart()

virtual void framework::EventProcessor::onProcessStart ( )
inlinevirtual

◆ setStorageHint() [1/2]

void framework::EventProcessor::setStorageHint ( framework::StorageControl::Hint  hint)
inline

Mark the current event as having the given storage control hint from this module.

Parameters
controlhintThe storage control hint to apply for the given event

Definition at line 160 of file EventProcessor.h.

160 {
161 setStorageHint(hint, "");
162 }
void setStorageHint(framework::StorageControl::Hint hint)
Mark the current event as having the given storage control hint from this module.

References setStorageHint().

Referenced by dqm::EcalDigiVerifier::analyze(), recon::RecoilMissesEcalSkimmer::produce(), recon::EcalPreselectionSkimmer::produce(), framework::test::TestProducer::produce(), ecal::EcalVetoProcessor::produce(), hcal::HcalAlignPolarfires::produce(), hcal::HcalVetoProcessor::produce(), hcal::HcalWABVetoProcessor::produce(), recon::SequentialTrigger::produce(), recon::TriggerProcessor::produce(), and setStorageHint().

◆ setStorageHint() [2/2]

void framework::EventProcessor::setStorageHint ( framework::StorageControl::Hint  hint,
const std::string &  purposeString 
)

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

Parameters
controlhintThe storage control hint to apply for the given event
purposeStringA purpose string which can be used in the skim control configuration

Definition at line 33 of file EventProcessor.cxx.

34 {
35 process_.getStorageController().addHint(name_, hint, purposeString);
36}
StorageControl & getStorageController()
Access the storage control unit for this process.
Definition Process.h:109
void addHint(const std::string &processor_name, Hint hint, const std::string &purposeString)
Add a storage hint for a given processor.

References framework::StorageControl::addHint(), framework::Process::getStorageController(), name_, and process_.

Member Data Documentation

◆ histoDir_

TDirectory* framework::EventProcessor::histoDir_ {0}
private

Histogram directory.

Definition at line 242 of file EventProcessor.h.

242{0};

Referenced by getHistoDirectory().

◆ histograms_

HistogramHelper framework::EventProcessor::histograms_
protected

◆ name_

std::string framework::EventProcessor::name_
private

The name of the EventProcessor.

Definition at line 239 of file EventProcessor.h.

Referenced by getHistoDirectory(), getName(), and setStorageHint().

◆ ntuple_

NtupleManager& framework::EventProcessor::ntuple_ {NtupleManager::getInstance()}
protected

◆ process_

Process& framework::EventProcessor::process_
private

◆ theLog_

logging::logger framework::EventProcessor::theLog_
protected

The logger for this EventProcessor.

Definition at line 222 of file EventProcessor.h.


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