ATLAS Offline Software
Loading...
Searching...
No Matches
EL::Detail::EventModule Class Reference

#include <EventModule.h>

Inheritance diagram for EL::Detail::EventModule:
Collaboration diagram for EL::Detail::EventModule:

Public Member Functions

 EventModule (const std::string &name)
 effects: standard constructor.
 ~EventModule ()
 effects: standard destructor.
virtual StatusCode postFinalize (ModuleData &data) override
 actions after algorithms have been finalized
virtual StatusCode onFirstInputFile (ModuleData &data) override
 actions after opening a the first input file
virtual StatusCode onNextInputFile (ModuleData &data) override
 actions after opening an input file after the first one
virtual StatusCode onNewInputFile (ModuleData &data) override
 actions after opening a new input file
virtual StatusCode postCloseInputFile (ModuleData &data) override
 actions after CloseInputFile is called on the algorithms
virtual StatusCode onExecute (ModuleData &data) override
 actions just before execute is called on algorithms
virtual StatusCode firstInitialize (ModuleData &data)
 action at the the very beginning of the worker job
virtual StatusCode preFileInitialize (ModuleData &data)
 action before opening the first file in the worker job
virtual StatusCode onInitialize (ModuleData &data)
 action just before algorithms are initialized
virtual StatusCode processInputs (ModuleData &data, IInputModuleActions &actions)
 process all input files
virtual StatusCode postFirstEvent (ModuleData &data)
 action after processing first event
virtual StatusCode onCloseInputFile (ModuleData &data)
 actions before closing an input file
virtual StatusCode onFileExecute (ModuleData &data)
 actions just before fileExecute is called on algorithms
virtual StatusCode onFinalize (ModuleData &data)
 actions just before algorithms are finalized
virtual StatusCode onWorkerEnd (ModuleData &data)
 action at the end of the worker job
virtual StatusCode postFileClose (ModuleData &data)
 action at end of the worker job
virtual void reportInputFailure (ModuleData &data)
 report that we failed to open our input file

Private Attributes

std::unique_ptr< xAOD::Eventm_event
 description: the event structure used
std::unique_ptr< xAOD::TStorem_store
std::unique_ptr< asg::SgEventm_evtStore
Gaudi::Property< bool > m_useStats {this, "useStats", false}
 description: whether we collect D3PDPerfStats statistics
Gaudi::Property< bool > m_summaryReport {this, "summaryReport", true}

Detailed Description

Definition at line 31 of file EventModule.h.

Constructor & Destructor Documentation

◆ EventModule()

EL::Detail::EventModule::EventModule ( const std::string & name)

effects: standard constructor.

guarantee: no-fail

Definition at line 40 of file EventModule.cxx.

41 : Module (name)
42 {}

◆ ~EventModule()

EL::Detail::EventModule::~EventModule ( )

effects: standard destructor.

guarantee: no-fail

Definition at line 44 of file EventModule.cxx.

45 {}

Member Function Documentation

◆ firstInitialize()

StatusCode EL::Detail::Module::firstInitialize ( ModuleData & data)
virtualinherited

action at the the very beginning of the worker job

This gets called as early as possible in the worker initialization. Essentially all that should happen before this is to load all the modules. The main purpose is to start any benchmarks that are meant to capture the initialization process as well.

Reimplemented in EL::Detail::AlgorithmMemoryModule, EL::Detail::AlgorithmTimerModule, EL::Detail::MemoryMonitorModule, and EL::Detail::StopwatchModule.

Definition at line 25 of file Module.cxx.

27 {
28 return ::StatusCode::SUCCESS;
29 }

◆ onCloseInputFile()

StatusCode EL::Detail::Module::onCloseInputFile ( ModuleData & data)
virtualinherited

actions before closing an input file

Reimplemented in EL::Detail::AlgorithmStateModule, and EL::Detail::TreeCacheModule.

Definition at line 55 of file Module.cxx.

57 {
58 return ::StatusCode::SUCCESS;
59 }

◆ onExecute()

StatusCode EL::Detail::EventModule::onExecute ( ModuleData & data)
overridevirtual

actions just before execute is called on algorithms

For now that is mostly used to point input modules to the right event

Reimplemented from EL::Detail::Module.

Definition at line 131 of file EventModule.cxx.

131 {
132 // move to next event
133 m_store->clear ();
134 if (m_event->getEntry (data.m_inputEntry) < 0)
135 RCU_THROW_MSG ("failed to read from xAOD");
136 return StatusCode::SUCCESS;
137 }
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
#define RCU_THROW_MSG(message)
Definition PrintMsg.h:58
std::unique_ptr< xAOD::Event > m_event
description: the event structure used
Definition EventModule.h:69
std::unique_ptr< xAOD::TStore > m_store
Definition EventModule.h:70

◆ onFileExecute()

StatusCode EL::Detail::Module::onFileExecute ( ModuleData & data)
virtualinherited

actions just before fileExecute is called on algorithms

Reimplemented in EL::Detail::AlgorithmStateModule, EL::Detail::FileExecutedModule, and EL::Detail::StopwatchModule.

Definition at line 77 of file Module.cxx.

79 {
80 return ::StatusCode::SUCCESS;
81 }

◆ onFinalize()

StatusCode EL::Detail::Module::onFinalize ( ModuleData & data)
virtualinherited

actions just before algorithms are finalized

Reimplemented in EL::Detail::AlgorithmStateModule, and EL::Detail::MemoryMonitorModule.

Definition at line 101 of file Module.cxx.

103 {
104 return ::StatusCode::SUCCESS;
105 }

◆ onFirstInputFile()

StatusCode EL::Detail::EventModule::onFirstInputFile ( ModuleData & data)
overridevirtual

actions after opening a the first input file

Reimplemented from EL::Detail::Module.

Definition at line 48 of file EventModule.cxx.

48 {
49
50 if (m_event != nullptr || m_store != nullptr) {
51 ANA_MSG_ERROR ("module initialized twice");
52 return StatusCode::FAILURE;
53 }
54 if (data.m_event != nullptr || data.m_tstore != nullptr) {
55 ANA_MSG_ERROR ("duplicate EventModule??");
56 return StatusCode::FAILURE;
57 }
58
59 // Perform a sanity check.
60 if (!data.m_inputFile) {
61 ANA_MSG_ERROR ("File is not available during initialization?!?");
62 return StatusCode::FAILURE;
63 }
64
65 // Set up the reading from the first input file. This is the generic
66 // interface for both TTree and RNTuple reading. But note that no event is loaded with getEntry(...)
67 // yet, as we don't want to allow users to access the first event
68 // during initialisation. Only the in-file metadata...
69 m_event = xAOD::Event::createAndReadFrom(*data.m_inputFile.get());
70 if (!m_event) {
71 ATH_MSG_ERROR( "cannot read from file: " << *data.m_inputFile->GetName());
72 return StatusCode::FAILURE;
73 }
74 // Set event in module data
75 data.m_event = m_event.get();
76 ATH_MSG_DEBUG( "EventModule::onFirstInputFile: opened " << data.m_inputFile->GetName());
77 if (!m_summaryReport.value())
79
80 m_store.reset (new xAOD::TStore);
81
82 m_evtStore = std::make_unique<asg::SgEvent> (m_event.get(), m_store.get());
83
84 if (m_useStats.value())
86
87 data.m_tstore = m_store.get();
88 data.m_evtStore = m_evtStore.get();
89 return StatusCode::SUCCESS;
90 }
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
#define ANA_MSG_ERROR(xmsg)
Macro printing error messages.
Gaudi::Property< bool > m_summaryReport
Definition EventModule.h:76
std::unique_ptr< asg::SgEvent > m_evtStore
Definition EventModule.h:71
Gaudi::Property< bool > m_useStats
description: whether we collect D3PDPerfStats statistics
Definition EventModule.h:75
static std::unique_ptr< Event > createAndReadFrom(TFile &file)
static method to create an Event object and readFrom a file, given by a TFile.
Definition EventIO.cxx:43
void start(bool clear=true)
Start the statistics collection.
static PerfStats & instance()
Function accessing the singleton instance.
void enableDataSubmission(bool value)
Function for turning data submission on/off.
static TFileAccessTracer & instance()
Access the singleton instance of this class.

◆ onInitialize()

StatusCode EL::Detail::Module::onInitialize ( ModuleData & data)
virtualinherited

action just before algorithms are initialized

This is typically used for any setup that this module needs to do.

Reimplemented in EL::Detail::AlgorithmStateModule, EL::Detail::FactoryPreloadModule, EL::Detail::FileExecutedModule, EL::Detail::MemoryMonitorModule, and EL::Detail::WorkerConfigModule.

Definition at line 89 of file Module.cxx.

91 {
92 return ::StatusCode::SUCCESS;
93 }

◆ onNewInputFile()

StatusCode EL::Detail::EventModule::onNewInputFile ( ModuleData & data)
overridevirtual

actions after opening a new input file

Reimplemented from EL::Detail::Module.

Definition at line 104 of file EventModule.cxx.

105 {
106 if (m_event == nullptr || m_store == nullptr) {
107 ANA_MSG_ERROR ("module not inititalized");
108 return StatusCode::FAILURE;
109 }
110 // readFrom has already been done in onFirstInputFile or onNextInputFile
111 // Here we only need to make sure getEntry(0) is called
112 if ((m_event->getEntries() > 0) && (m_event->getEntry (0) < 0)) {
113 ANA_MSG_ERROR ("Failed to load first entry from file");
114 return StatusCode::FAILURE;
115 }
116 m_store->clear ();
117 return StatusCode::SUCCESS;
118 }

◆ onNextInputFile()

StatusCode EL::Detail::EventModule::onNextInputFile ( ModuleData & data)
overridevirtual

actions after opening an input file after the first one

Reimplemented from EL::Detail::Module.

Definition at line 93 of file EventModule.cxx.

93 {
94
95 if (m_event == nullptr || m_store == nullptr) {
96 ANA_MSG_ERROR ("module not inititalized");
97 return StatusCode::FAILURE;
98 }
99 ANA_CHECK (m_event->readFrom (*data.m_inputFile.get()));
100 m_store->clear ();
101 return StatusCode::SUCCESS;
102 }
#define ANA_CHECK(EXP)
check whether the given expression was successful

◆ onWorkerEnd()

StatusCode EL::Detail::Module::onWorkerEnd ( ModuleData & data)
virtualinherited

action at the end of the worker job

This is mostly meant/used to print job summary statements at the very end of worker job, and actually have them show up at or at least near the end of any log file.

Reimplemented in EL::Detail::LeakCheckModule, EL::Detail::MemoryMonitorModule, and EL::Detail::StopwatchModule.

Definition at line 113 of file Module.cxx.

115 {
116 return ::StatusCode::SUCCESS;
117 }

◆ postCloseInputFile()

StatusCode EL::Detail::EventModule::postCloseInputFile ( ModuleData & data)
overridevirtual

actions after CloseInputFile is called on the algorithms

Right now that is only used to disconnect the Event object from the input file.

Reimplemented from EL::Detail::Module.

Definition at line 120 of file EventModule.cxx.

120 {
121
122 if (m_event == nullptr || m_store == nullptr) {
123 ANA_MSG_ERROR ("module not inititalized");
124 return StatusCode::FAILURE;
125 }
126 // Nothing to do post close input file
127 return StatusCode::SUCCESS;
128 }

◆ postFileClose()

StatusCode EL::Detail::Module::postFileClose ( ModuleData & data)
virtualinherited

action at end of the worker job

Executed just right before worker exit successfully at this stage all outputs have been created

Reimplemented in EL::Detail::GridReportingModule, and EL::Detail::PostClosedOutputsModule.

Definition at line 119 of file Module.cxx.

121 {
122 return ::StatusCode::SUCCESS;
123 }

◆ postFinalize()

StatusCode EL::Detail::EventModule::postFinalize ( ModuleData & data)
overridevirtual

actions after algorithms have been finalized

This is usually used to calculate some job summary information that is to be stored it in the histogram output file.

Reimplemented from EL::Detail::Module.

Definition at line 140 of file EventModule.cxx.

140 {
141
142 if (m_useStats.value()) {
144 std::unique_ptr<xAOD::ReadStats> stats
145 (new xAOD::ReadStats (xAOD::IOStats::instance().stats()));
146 stats->SetName (Job::optXAODReadStats.c_str());
147 stats->Print ();
148 data.addOutput (std::move (stats));
149 }
150 data.m_evtStore = nullptr;
151 data.m_event = nullptr;
152 data.m_tstore = nullptr;
153 m_evtStore.reset ();
154 m_event.reset ();
155 m_store.reset ();
156 return StatusCode::SUCCESS;
157 }
static const std::string optXAODReadStats
description: the name of the XAODPerfStats object produced as I gather it, as well as the name of the...
Definition Job.h:370
static IOStats & instance()
Singleton object accessor.
Definition IOStats.cxx:11
void stop()
Stop the statistics collection.

◆ postFirstEvent()

StatusCode EL::Detail::Module::postFirstEvent ( ModuleData & data)
virtualinherited

action after processing first event

This is mostly meant to set up benchmarks that record per-event performance. While a lot of initialization happens during initialize() there is a fair amount of initialization that happens on the first event, so when recording per-event performance the first event is sort of "special" and may need to be omitted.

Reimplemented in EL::Detail::LeakCheckModule, and EL::Detail::MemoryMonitorModule.

Definition at line 67 of file Module.cxx.

69 {
70 return ::StatusCode::SUCCESS;
71 }

◆ preFileInitialize()

StatusCode EL::Detail::Module::preFileInitialize ( ModuleData & data)
virtualinherited

action before opening the first file in the worker job

This is mostly meant to allow loading the dictionaries before any files and associated information is loaded.

Definition at line 31 of file Module.cxx.

33 {
34 return ::StatusCode::SUCCESS;
35 }

◆ processInputs()

StatusCode EL::Detail::Module::processInputs ( ModuleData & data,
IInputModuleActions & actions )
virtualinherited

process all input files

This deviates slightly from the usual pattern for module functions in that I pass in the possible actions as an argument. See IInputModuleActions for details.

Reimplemented in EL::Detail::BatchInputModule, and EL::Detail::DirectInputModule.

Definition at line 95 of file Module.cxx.

97 {
98 return ::StatusCode::SUCCESS;
99 }

◆ reportInputFailure()

void EL::Detail::Module::reportInputFailure ( ModuleData & data)
virtualinherited

report that we failed to open our input file

Reimplemented in EL::Detail::GridReportingModule.

Definition at line 73 of file Module.cxx.

75 {}

Member Data Documentation

◆ m_event

std::unique_ptr<xAOD::Event> EL::Detail::EventModule::m_event
private

description: the event structure used

Definition at line 69 of file EventModule.h.

◆ m_evtStore

std::unique_ptr<asg::SgEvent> EL::Detail::EventModule::m_evtStore
private

Definition at line 71 of file EventModule.h.

◆ m_store

std::unique_ptr<xAOD::TStore> EL::Detail::EventModule::m_store
private

Definition at line 70 of file EventModule.h.

◆ m_summaryReport

Gaudi::Property<bool> EL::Detail::EventModule::m_summaryReport {this, "summaryReport", true}
private

Definition at line 76 of file EventModule.h.

76{this, "summaryReport", true};

◆ m_useStats

Gaudi::Property<bool> EL::Detail::EventModule::m_useStats {this, "useStats", false}
private

description: whether we collect D3PDPerfStats statistics

Definition at line 75 of file EventModule.h.

75{this, "useStats", false};

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