ATLAS Offline Software
Loading...
Searching...
No Matches
EL::AlgorithmWrapper Class Referencefinal

an IAlgorithmWrapper for AnaAlgorithm More...

#include <AlgorithmWrapper.h>

Inheritance diagram for EL::AlgorithmWrapper:
Collaboration diagram for EL::AlgorithmWrapper:

Public Member Functions

void testInvariant () const
 test the invariant of this object
 AlgorithmWrapper ()
 standard default constructor for serialization
 AlgorithmWrapper (std::unique_ptr< Algorithm > &&val_algorithm)
 standard constructor
virtual std::string_view getName () const override
virtual bool hasName (const std::string &name) const override
 whether this algorithm has the given name
virtual std::unique_ptr< IAlgorithmWrappermakeClone () const override
 make a clone of this algorithm
virtual AlgorithmgetLegacyAlg () override
 get the legacy algorithm, if we wrap one
virtual StatusCode initialize (const AlgorithmWorkerData &workerData) override
 call initialize on the algorithm
virtual StatusCode execute (const EventContext &ctx) override
 call execute on the algorithm
virtual StatusCode postExecute () override
 call postExecute on the algorithm
virtual StatusCode finalize () override
 call finalize on the algorithm
virtual::StatusCode fileExecute () override
 call fileExecute on the algorithm
virtual::StatusCode beginInputFile () override
 call beginInputFile on the algorithm
virtual::StatusCode endInputFile () override
 call endInputFile on the algorithm

Private Attributes

std::unique_ptr< Algorithmm_algorithm
 the actual algorithm
bool m_firstFile {true}
 whether this is the first file we encounter
bool m_isInitialized {false}
 whether Algorithm::initialize has been called

Detailed Description

an IAlgorithmWrapper for AnaAlgorithm

Definition at line 22 of file AlgorithmWrapper.h.

Constructor & Destructor Documentation

◆ AlgorithmWrapper() [1/2]

EL::AlgorithmWrapper::AlgorithmWrapper ( )
inline

standard default constructor for serialization

Definition at line 33 of file AlgorithmWrapper.h.

33{};

◆ AlgorithmWrapper() [2/2]

EL::AlgorithmWrapper::AlgorithmWrapper ( std::unique_ptr< Algorithm > && val_algorithm)

standard constructor

Definition at line 38 of file AlgorithmWrapper.cxx.

40 : m_algorithm (std::move (val_algorithm))
41 {
42 RCU_NEW_INVARIANT (this);
43 }
#define RCU_NEW_INVARIANT(x)
Definition Assert.h:221
std::unique_ptr< Algorithm > m_algorithm
the actual algorithm

Member Function Documentation

◆ beginInputFile()

StatusCode EL::AlgorithmWrapper::beginInputFile ( )
overridevirtual

call beginInputFile on the algorithm

Implements EL::IAlgorithmWrapper.

Definition at line 179 of file AlgorithmWrapper.cxx.

181 {
182 using namespace msgAlgorithmConfig;
184
185 if (m_algorithm->changeInput(m_firstFile).isFailure())
186 {
187 ANA_MSG_ERROR ("failed to call changeInput() on algorithm: " << m_algorithm->name());
188 return StatusCode::FAILURE;
189 }
190 m_firstFile = false;
191 if (m_isInitialized == false && m_algorithm->m_wk->hasInputEvents())
192 {
193 if (m_algorithm->initialize().isFailure())
194 {
195 ANA_MSG_ERROR ("failed to call initialize() on algorithm: " << m_algorithm->name());
196 return StatusCode::FAILURE;
197 }
198 m_isInitialized = true;
199 }
200 return StatusCode::SUCCESS;
201 }
#define RCU_CHANGE_INVARIANT(x)
Definition Assert.h:219
#define ANA_MSG_ERROR(xmsg)
Macro printing error messages.
bool m_isInitialized
whether Algorithm::initialize has been called
bool m_firstFile
whether this is the first file we encounter

◆ endInputFile()

StatusCode EL::AlgorithmWrapper::endInputFile ( )
overridevirtual

call endInputFile on the algorithm

Implements EL::IAlgorithmWrapper.

Definition at line 205 of file AlgorithmWrapper.cxx.

207 {
208 using namespace msgAlgorithmConfig;
210
211 if (m_algorithm->endOfFile().isFailure())
212 {
213 ANA_MSG_ERROR ("failed to call endOfFile() on algorithm: " << m_algorithm->name());
214 return StatusCode::FAILURE;
215 }
216 return StatusCode::SUCCESS;
217 }

◆ execute()

StatusCode EL::AlgorithmWrapper::execute ( const EventContext & ctx)
overridevirtual

call execute on the algorithm

Implements EL::IAlgorithmWrapper.

Definition at line 107 of file AlgorithmWrapper.cxx.

109 {
110 using namespace msgAlgorithmConfig;
112
113 if (m_algorithm->execute().isFailure())
114 {
115 ANA_MSG_ERROR ("failed to call execute() on algorithm: " << m_algorithm->name());
116 return StatusCode::FAILURE;
117 }
118 return StatusCode::SUCCESS;
119 }

◆ fileExecute()

StatusCode EL::AlgorithmWrapper::fileExecute ( )
overridevirtual

call fileExecute on the algorithm

Implements EL::IAlgorithmWrapper.

Definition at line 163 of file AlgorithmWrapper.cxx.

165 {
166 using namespace msgAlgorithmConfig;
168
169 if (m_algorithm->fileExecute().isFailure())
170 {
171 ANA_MSG_ERROR ("failed to call fileExecute() on algorithm: " << m_algorithm->name());
172 return StatusCode::FAILURE;
173 }
174 return StatusCode::SUCCESS;
175 }

◆ finalize()

StatusCode EL::AlgorithmWrapper::finalize ( )
overridevirtual

call finalize on the algorithm

Implements EL::IAlgorithmWrapper.

Definition at line 139 of file AlgorithmWrapper.cxx.

141 {
142 using namespace msgAlgorithmConfig;
144
145 if (m_isInitialized == true)
146 {
147 if (m_algorithm->finalize().isFailure())
148 {
149 ANA_MSG_ERROR ("failed to call finalize() on algorithm: " << m_algorithm->name());
150 return StatusCode::FAILURE;
151 }
152 }
153 if (m_algorithm->histFinalize().isFailure())
154 {
155 ANA_MSG_ERROR ("failed to call histFinalize() on algorithm: " << m_algorithm->name());
156 return StatusCode::FAILURE;
157 }
158 return StatusCode::SUCCESS;
159 }

◆ getLegacyAlg()

Algorithm * EL::AlgorithmWrapper::getLegacyAlg ( )
overridevirtual

get the legacy algorithm, if we wrap one

Reimplemented from EL::IAlgorithmWrapper.

Definition at line 80 of file AlgorithmWrapper.cxx.

82 {
83 RCU_READ_INVARIANT (this);
84 return m_algorithm.get();
85 }
#define RCU_READ_INVARIANT(x)
Definition Assert.h:217

◆ getName()

std::string_view EL::AlgorithmWrapper::getName ( ) const
overridevirtual

Inherited Members

Implements EL::IAlgorithmWrapper.

Definition at line 47 of file AlgorithmWrapper.cxx.

49 {
50 RCU_READ_INVARIANT (this);
51 return m_algorithm->GetName();
52 }

◆ hasName()

bool EL::AlgorithmWrapper::hasName ( const std::string & name) const
overridevirtual

whether this algorithm has the given name

Implements EL::IAlgorithmWrapper.

Definition at line 56 of file AlgorithmWrapper.cxx.

58 {
59 RCU_READ_INVARIANT (this);
60 return m_algorithm->hasName (name);
61 }

◆ initialize()

StatusCode EL::AlgorithmWrapper::initialize ( const AlgorithmWorkerData & workerData)
overridevirtual

call initialize on the algorithm

Implements EL::IAlgorithmWrapper.

Definition at line 89 of file AlgorithmWrapper.cxx.

91 {
92 using namespace msgAlgorithmConfig;
94
95 m_algorithm->m_wk = workerData.m_wk;
96 m_algorithm->m_evtStorePtr = workerData.m_evtStore;
97 if (m_algorithm->histInitialize().isFailure())
98 {
99 ANA_MSG_ERROR ("failed to call histInitialize() on algorithm: " << m_algorithm->name());
100 return StatusCode::FAILURE;
101 }
102 return StatusCode::SUCCESS;
103 }

◆ makeClone()

std::unique_ptr< IAlgorithmWrapper > EL::AlgorithmWrapper::makeClone ( ) const
overridevirtual

make a clone of this algorithm

Implements EL::IAlgorithmWrapper.

Definition at line 65 of file AlgorithmWrapper.cxx.

67 {
68 using namespace msgAlgorithmConfig;
69 RCU_READ_INVARIANT (this);
70
71 std::unique_ptr<Algorithm> myalgorithm
72 (dynamic_cast<Algorithm*>(m_algorithm->Clone ()));
73 if (myalgorithm == nullptr)
74 throw std::runtime_error (std::format ("failed to clone algorithm {}", m_algorithm->GetName()));
75 return std::make_unique<AlgorithmWrapper> (std::move (myalgorithm));
76 }

◆ postExecute()

StatusCode EL::AlgorithmWrapper::postExecute ( )
overridevirtual

call postExecute on the algorithm

Reimplemented from EL::IAlgorithmWrapper.

Definition at line 123 of file AlgorithmWrapper.cxx.

125 {
126 using namespace msgAlgorithmConfig;
128
129 if (m_algorithm->postExecute().isFailure())
130 {
131 ANA_MSG_ERROR ("failed to call postExecute() on algorithm: " << m_algorithm->name());
132 return StatusCode::FAILURE;
133 }
134 return StatusCode::SUCCESS;
135 }

◆ testInvariant()

void EL::AlgorithmWrapper::testInvariant ( ) const

test the invariant of this object

Public Members

Definition at line 31 of file AlgorithmWrapper.cxx.

33 {
34 }

Member Data Documentation

◆ m_algorithm

std::unique_ptr<Algorithm> EL::AlgorithmWrapper::m_algorithm
private

the actual algorithm

Private Members

Definition at line 73 of file AlgorithmWrapper.h.

◆ m_firstFile

bool EL::AlgorithmWrapper::m_firstFile {true}
private

whether this is the first file we encounter

Definition at line 76 of file AlgorithmWrapper.h.

76{true};

◆ m_isInitialized

bool EL::AlgorithmWrapper::m_isInitialized {false}
private

whether Algorithm::initialize has been called

Definition at line 79 of file AlgorithmWrapper.h.

79{false};

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