LDMX Software
framework::EventProcessor Class Referenceabstract

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

#include <EventProcessor.h>

Public Member Functions

 DECLARE_FACTORY (EventProcessor, EventProcessor *, const std::string &, Process &)
 declare that we have a factory for this class
 
 EventProcessor (const std::string &name, Process &process)
 Class constructor.
 
virtual ~EventProcessor ()=default
 Class destructor.
 
virtual void configure (framework::config::Parameters &parameters)
 Callback for the EventProcessor to configure itself from the given set of parameters.
 
virtual void beforeNewRun (ldmx::RunHeader &runHeader)
 Callback for Producers to add parameters to the run header before conditions are initialized.
 
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.
 
virtual void process (Event &event)=0
 How an EventProcessor processes an event.
 
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.
 

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 62 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 10 of file EventProcessor.cxx.

11 : histograms_{name},
12 theLog_{logging::makeLogger(name)},
14 name_{name} {}
Process & process_
Handle to the Process.
std::string name_
The name of the EventProcessor.
virtual void process(Event &event)=0
How an EventProcessor processes an event.
logging::logger theLog_
The logger for this EventProcessor.
HistogramHelper histograms_
Interface class for making and filling histograms.

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 218 of file EventProcessor.h.

218{ throw AbortEventException(); }

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

◆ beforeNewRun()

virtual void framework::EventProcessor::beforeNewRun ( ldmx::RunHeader & runHeader)
inlinevirtual

Callback for Producers to add parameters to the run header before conditions are initialized.

Reimplemented in ecal::test::EcalFakeSimHits, framework::Analyzer, framework::test::TestProducer, hcal::HcalRawDecoder, hcal::test::HcalFakeSimHits, packing::RawIO, packing::SingleSubsystemUnpacker, and simcore::Simulator.

Definition at line 105 of file EventProcessor.h.

105{}

◆ 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 dqm::DarkBremInteraction, dqm::EcalClusterAnalyzer, dqm::EcalDigiVerifier, dqm::EcalMipTrackingFeatures, dqm::EcalPnetVetoResults, dqm::EcalShowerFeatures, dqm::EcalVetoResults, dqm::EcalWABRecResults, dqm::GenieTruthDQM, dqm::HCalDQM, dqm::HcalGeometryVerifier, dqm::HcalInefficiencyAnalyzer, dqm::HCalRawDigi, dqm::HcalVetoResults, dqm::HgcrocPulseTruthAnalyzer, dqm::NtuplizeHgcrocDigiCollection, dqm::NtuplizeTrigScintQIEDigis, dqm::PhotoNuclearDQM, dqm::ReSimVerifier, dqm::SampleValidation, dqm::SimObjects, dqm::Trigger, dqm::TrigScintClusterDQM, dqm::TrigScintDQM, dqm::TrigScintHitDQM, dqm::TrigScintTrackDQM, dqm::TrkDeDxMassEstFeatures, ecal::EcalClusterProducer, ecal::EcalDigiProducer, ecal::EcalMipTrackingProcessor, ecal::EcalPnetVetoProcessor, ecal::EcalRawDecoder, ecal::EcalRawEncoder, ecal::EcalRecProducer, ecal::EcalTrigPrimDigiProducer, ecal::EcalVetoProcessor, ecal::EcalWABRecProcessor, ecal::test::EcalCheckEnergyReconstruction, framework::test::TestAnalyzer, framework::test::TestConfig, framework::test::TestProducer, hcal::HcalAlignPolarfires, hcal::HcalClusterProducer, hcal::HcalDigiProducer, hcal::HcalDoubleEndRecProducer, hcal::HcalPedestalAnalyzer, hcal::HcalRawDecoder, hcal::HcalRecProducer, hcal::HcalSimpleDigiAndRecProducer, hcal::HcalSingleEndRecProducer, hcal::HcalTrigPrimDigiProducer, hcal::HcalVetoProcessor, hcal::HcalWABVetoProcessor, hcal::test::HcalCheckPositionMap, hcal::test::HcalCheckReconstruction, ldmx::ecal::TrigPrimResolutionAnalyzer, packing::FiberTrackerRawDecoder, packing::RawIO, packing::SingleSubsystemPacker, packing::SingleSubsystemUnpacker, packing::WRRawDecoder, recon::BeamElectronLocator, recon::EcalPreselectionSkimmer, recon::ElectronCounter, recon::MyProcessor, recon::OverlayProducer, recon::ParticleFlow, recon::PFEcalClusterProducer, recon::PFHcalClusterProducer, recon::PFTrackProducer, recon::PFTruthProducer, recon::RecoilFiducialityProcessor, recon::RecoilMissesEcalSkimmer, recon::SequentialTrigger, recon::TrackDeDxMassEstimator, recon::TriggerProcessor, simcore::GenieReweightProducer, simcore::ReSimulator, simcore::Simulator, simcore::SimulatorBase, tracking::dqm::StraightTracksDQM, tracking::dqm::TrackerDigiDQM, tracking::dqm::TrackingRecoDQM, tracking::reco::AlignmentTestProcessor, tracking::reco::CKFProcessor, tracking::reco::DigitizationProcessor, tracking::reco::GreedyAmbiguitySolver, tracking::reco::GSFProcessor, tracking::reco::LinearSeedFinder, tracking::reco::LinearTrackFinder, tracking::reco::LinearTruthTracking, tracking::reco::SeedFinderProcessor, tracking::reco::TruthSeedProcessor, tracking::reco::Vertexer, tracking::reco::VertexProcessor, tracking::TrackerVetoProcessor, trigger::DumpFileWriter, trigger::EcalTPSelector, trigger::HcalTPSelector, trigger::NtupleWriter, trigger::PropagationMapWriter, trigger::TrigEcalClusterProducer, trigger::TrigEcalEnergySum, trigger::TrigElectronProducer, trigger::TrigHcalEnergySum, trigger::TrigMipReco, trigscint::EventReadoutProducer, trigscint::QIEAnalyzer, trigscint::QIEDecoder, trigscint::QIEEncoder, trigscint::QualityFlagAnalyzer, trigscint::TestBeamClusterAnalyzer, trigscint::TestBeamClusterProducer, trigscint::TestBeamHitAnalyzer, trigscint::TestBeamHitProducer, trigscint::TrigScintClusterProducer, trigscint::TrigScintDigiProducer, trigscint::TrigScintFirmwareHitProducer, trigscint::TrigScintFirmwareTracker, trigscint::TrigScintQIEDigiProducer, trigscint::TrigScintRecHitProducer, trigscint::TrigScintTrackProducer, and trigscint::TruthHitProducer.

Definition at line 99 of file EventProcessor.h.

99{}

◆ 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 43 of file EventProcessor.cxx.

44 {
45 for (auto const &h : histos) {
46 auto name{h.getParameter<std::string>("name")};
47 auto xLabel{h.getParameter<std::string>("xlabel")};
48 auto xbins{h.getParameter<std::vector<double>>("xbins")};
49 auto yLabel{h.getParameter<std::string>("ylabel")};
50 auto ybins{h.getParameter<std::vector<double>>("ybins", {})};
51 if (ybins.empty()) {
52 // assume 1D histogram
53 histograms_.create(name, xLabel, xbins);
54 } else {
55 // assume 2D histogram
56 histograms_.create(name, xLabel, xbins, yLabel, ybins);
57 }
58 }
59}
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_.

◆ 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 155 of file EventProcessor.h.

155 {
156 return getConditions().getCondition<T>(condition_name);
157 }
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 dqm::NtuplizeHgcrocDigiCollection::analyze(), ldmx::ecal::TrigPrimResolutionAnalyzer::analyze(), simcore::ConditionsInterface::getCondition(), tracking::reco::TrackingGeometryUser::getNamedCondition(), ecal::EcalDigiProducer::onNewRun(), hcal::HcalDigiProducer::onNewRun(), hcal::HcalSimpleDigiAndRecProducer::onNewRun(), recon::OverlayProducer::onNewRun(), simcore::Simulator::onNewRun(), ecal::EcalDigiProducer::produce(), ecal::EcalMipTrackingProcessor::produce(), ecal::EcalRawDecoder::produce(), ecal::EcalRawEncoder::produce(), ecal::EcalRecProducer::produce(), ecal::EcalTrigPrimDigiProducer::produce(), ecal::EcalVetoProcessor::produce(), ecal::EcalWABRecProcessor::produce(), hcal::HcalDigiProducer::produce(), hcal::HcalDoubleEndRecProducer::produce(), hcal::HcalRawDecoder::produce(), hcal::HcalRecProducer::produce(), hcal::HcalSimpleDigiAndRecProducer::produce(), hcal::HcalSingleEndRecProducer::produce(), hcal::HcalTrigPrimDigiProducer::produce(), recon::OverlayProducer::produce(), and trigger::TrigEcalClusterProducer::produce().

◆ getConditions()

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

Internal getter for conditions without exposing all of Process.

Definition at line 16 of file EventProcessor.cxx.

16 {
17 return process_.getConditions();
18}
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 20 of file EventProcessor.cxx.

20 {
21 return *(process_.getEventHeader());
22}
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 24 of file EventProcessor.cxx.

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

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

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

◆ getLogFrequency()

int framework::EventProcessor::getLogFrequency ( ) const

Get the current logging frequency from the process.

Returns
int frequency logging should occurr

Definition at line 37 of file EventProcessor.cxx.

37 {
39}
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

◆ getRunNumber()

int framework::EventProcessor::getRunNumber ( ) const

Get the run number from the process.

Returns
int run number

Definition at line 41 of file EventProcessor.cxx.

41{ 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:443

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 128 of file EventProcessor.h.

128{}

◆ 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 120 of file EventProcessor.h.

120{}

◆ onNewRun()

◆ onProcessEnd()

◆ onProcessStart()

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

Callback for the EventProcessor to take any necessary action when the processing of events starts, such as creating histograms.

Reimplemented in dqm::DarkBremInteraction, dqm::GenieTruthDQM, dqm::HCalRawDigi, dqm::HcalVetoResults, dqm::NtuplizeHgcrocDigiCollection, dqm::NtuplizeTrigScintQIEDigis, dqm::PhotoNuclearDQM, dqm::SampleValidation, dqm::SimObjects, dqm::Trigger, dqm::TrigScintClusterDQM, dqm::TrigScintDQM, dqm::TrigScintHitDQM, dqm::TrigScintTrackDQM, dqm::TrkDeDxMassEstFeatures, ecal::test::EcalCheckEnergyReconstruction, framework::test::TestAnalyzer, hcal::test::HcalCheckPositionMap, hcal::test::HcalCheckReconstruction, ldmx::ecal::TrigPrimResolutionAnalyzer, packing::FiberTrackerRawDecoder, packing::WRRawDecoder, recon::BeamElectronLocator, recon::OverlayProducer, simcore::SimulatorBase, tracking::reco::AlignmentTestProcessor, tracking::reco::CKFProcessor, tracking::reco::DigitizationProcessor, tracking::reco::GSFProcessor, tracking::reco::LinearSeedFinder, tracking::reco::SeedFinderProcessor, tracking::reco::TruthSeedProcessor, tracking::reco::Vertexer, tracking::reco::VertexProcessor, trigger::DumpFileWriter, trigger::NtupleWriter, trigger::PropagationMapWriter, trigger::TrigElectronProducer, trigscint::QIEAnalyzer, trigscint::QIEDecoder, trigscint::QIEEncoder, trigscint::QualityFlagAnalyzer, trigscint::TestBeamClusterAnalyzer, trigscint::TestBeamClusterProducer, trigscint::TestBeamHitAnalyzer, trigscint::TrigScintClusterProducer, and trigscint::TrigScintTrackProducer.

Definition at line 135 of file EventProcessor.h.

135{}

◆ process()

virtual void framework::EventProcessor::process ( Event & event)
pure virtual

How an EventProcessor processes an event.

This becomes Producer::produce or Analyzer::analyze depending on which one the user inherits from.

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

◆ 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 174 of file EventProcessor.h.

174 {
175 setStorageHint(hint, "");
176 }
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(), ecal::EcalVetoProcessor::produce(), framework::test::TestProducer::produce(), hcal::HcalAlignPolarfires::produce(), hcal::HcalVetoProcessor::produce(), hcal::HcalWABVetoProcessor::produce(), recon::EcalPreselectionSkimmer::produce(), recon::RecoilFiducialityProcessor::produce(), recon::RecoilMissesEcalSkimmer::produce(), recon::SequentialTrigger::produce(), recon::TriggerProcessor::produce(), tracking::TrackerVetoProcessor::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 32 of file EventProcessor.cxx.

33 {
34 process_.getStorageController().addHint(name_, hint, purposeString);
35}
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 247 of file EventProcessor.h.

247{0};

Referenced by getHistoDirectory().

◆ histograms_

HistogramHelper framework::EventProcessor::histograms_
protected

Interface class for making and filling histograms.

Definition at line 221 of file EventProcessor.h.

Referenced by dqm::EcalClusterAnalyzer::analyze(), dqm::EcalDigiVerifier::analyze(), dqm::EcalMipTrackingFeatures::analyze(), dqm::EcalPnetVetoResults::analyze(), dqm::EcalShowerFeatures::analyze(), dqm::EcalVetoResults::analyze(), dqm::EcalWABRecResults::analyze(), dqm::HcalGeometryVerifier::analyze(), dqm::HcalInefficiencyAnalyzer::analyze(), dqm::HCalRawDigi::analyze(), dqm::HcalVetoResults::analyze(), dqm::HgcrocPulseTruthAnalyzer::analyze(), dqm::PhotoNuclearDQM::analyze(), dqm::SampleValidation::analyze(), dqm::SimObjects::analyze(), dqm::Trigger::analyze(), dqm::TrigScintClusterDQM::analyze(), dqm::TrigScintDQM::analyze(), dqm::TrigScintHitDQM::analyze(), dqm::TrigScintTrackDQM::analyze(), dqm::TrkDeDxMassEstFeatures::analyze(), ldmx::ecal::TrigPrimResolutionAnalyzer::analyze(), tracking::dqm::StraightTracksDQM::analyze(), tracking::dqm::TrackerDigiDQM::analyze(), tracking::dqm::TrackingRecoDQM::analyze(), dqm::SimObjects::createCalorimeterHists(), createHistograms(), dqm::SimObjects::createTrackerHists(), dqm::PhotoNuclearDQM::findParticleKinematics(), dqm::PhotoNuclearDQM::findRecoilProperties(), dqm::PhotoNuclearDQM::findSubleadingKinematics(), dqm::HCalRawDigi::onProcessStart(), dqm::HcalVetoResults::onProcessStart(), dqm::SampleValidation::onProcessStart(), dqm::SimObjects::onProcessStart(), dqm::Trigger::onProcessStart(), dqm::TrigScintClusterDQM::onProcessStart(), dqm::TrigScintDQM::onProcessStart(), dqm::TrigScintHitDQM::onProcessStart(), dqm::TrigScintTrackDQM::onProcessStart(), dqm::TrkDeDxMassEstFeatures::onProcessStart(), ldmx::ecal::TrigPrimResolutionAnalyzer::onProcessStart(), dqm::DarkBremInteraction::produce(), dqm::DarkBremInteraction::setHistLabels(), dqm::PhotoNuclearDQM::setHistLabels(), and tracking::dqm::TrackingRecoDQM::trackStateMonitoring().

◆ name_

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

The name of the EventProcessor.

Definition at line 244 of file EventProcessor.h.

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

◆ ntuple_

◆ process_

Process& framework::EventProcessor::process_
private

◆ theLog_

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

The logger for this EventProcessor.

Definition at line 227 of file EventProcessor.h.


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