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 36 of file AlgorithmWrapper.cxx.

38 : m_algorithm (std::move (val_algorithm))
39 {
40 RCU_NEW_INVARIANT (this);
41 }
#define RCU_NEW_INVARIANT(x)
Definition Assert.h:228
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 177 of file AlgorithmWrapper.cxx.

179 {
180 using namespace msgAlgorithmConfig;
182
183 if (m_algorithm->changeInput(m_firstFile).isFailure())
184 {
185 ANA_MSG_ERROR ("failed to call changeInput() on algorithm: " << m_algorithm->name());
186 return StatusCode::FAILURE;
187 }
188 m_firstFile = false;
189 if (m_isInitialized == false && m_algorithm->m_wk->hasInputEvents())
190 {
191 if (m_algorithm->initialize().isFailure())
192 {
193 ANA_MSG_ERROR ("failed to call initialize() on algorithm: " << m_algorithm->name());
194 return StatusCode::FAILURE;
195 }
196 m_isInitialized = true;
197 }
198 return StatusCode::SUCCESS;
199 }
#define RCU_CHANGE_INVARIANT(x)
Definition Assert.h:226
#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 203 of file AlgorithmWrapper.cxx.

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

◆ execute()

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

call execute on the algorithm

Implements EL::IAlgorithmWrapper.

Definition at line 105 of file AlgorithmWrapper.cxx.

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

◆ fileExecute()

StatusCode EL::AlgorithmWrapper::fileExecute ( )
overridevirtual

call fileExecute on the algorithm

Implements EL::IAlgorithmWrapper.

Definition at line 161 of file AlgorithmWrapper.cxx.

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

◆ finalize()

StatusCode EL::AlgorithmWrapper::finalize ( )
overridevirtual

call finalize on the algorithm

Implements EL::IAlgorithmWrapper.

Definition at line 137 of file AlgorithmWrapper.cxx.

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

◆ getLegacyAlg()

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

get the legacy algorithm, if we wrap one

Reimplemented from EL::IAlgorithmWrapper.

Definition at line 78 of file AlgorithmWrapper.cxx.

80 {
81 RCU_READ_INVARIANT (this);
82 return m_algorithm.get();
83 }
#define RCU_READ_INVARIANT(x)
Definition Assert.h:224

◆ getName()

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

Inherited Members

Implements EL::IAlgorithmWrapper.

Definition at line 45 of file AlgorithmWrapper.cxx.

47 {
48 RCU_READ_INVARIANT (this);
49 return m_algorithm->GetName();
50 }

◆ hasName()

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

whether this algorithm has the given name

Implements EL::IAlgorithmWrapper.

Definition at line 54 of file AlgorithmWrapper.cxx.

56 {
57 RCU_READ_INVARIANT (this);
58 return m_algorithm->hasName (name);
59 }

◆ initialize()

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

call initialize on the algorithm

Implements EL::IAlgorithmWrapper.

Definition at line 87 of file AlgorithmWrapper.cxx.

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

◆ makeClone()

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

make a clone of this algorithm

Implements EL::IAlgorithmWrapper.

Definition at line 63 of file AlgorithmWrapper.cxx.

65 {
66 using namespace msgAlgorithmConfig;
67 RCU_READ_INVARIANT (this);
68
69 std::unique_ptr<Algorithm> myalgorithm
70 (dynamic_cast<Algorithm*>(m_algorithm->Clone ()));
71 if (myalgorithm == nullptr)
72 RCU_THROW_MSG ("failed to clone algorithm " + std::string (m_algorithm->GetName()));
73 return std::make_unique<AlgorithmWrapper> (std::move (myalgorithm));
74 }
#define RCU_THROW_MSG(message)
Definition PrintMsg.h:53

◆ postExecute()

StatusCode EL::AlgorithmWrapper::postExecute ( )
overridevirtual

call postExecute on the algorithm

Reimplemented from EL::IAlgorithmWrapper.

Definition at line 121 of file AlgorithmWrapper.cxx.

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

◆ testInvariant()

void EL::AlgorithmWrapper::testInvariant ( ) const

test the invariant of this object

Public Members

Definition at line 29 of file AlgorithmWrapper.cxx.

31 {
32 }

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: