ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
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 More...
 
 AlgorithmWrapper ()
 standard default constructor for serialization More...
 
 AlgorithmWrapper (std::unique_ptr< Algorithm > &&val_algorithm)
 standard constructor More...
 
virtual std::string_view getName () const override
 
virtual bool hasName (const std::string &name) const override
 whether this algorithm has the given name More...
 
virtual std::unique_ptr< IAlgorithmWrappermakeClone () const override
 make a clone of this algorithm More...
 
virtual AlgorithmgetLegacyAlg () override
 get the legacy algorithm, if we wrap one More...
 
virtual StatusCode initialize (const AlgorithmWorkerData &workerData) override
 call initialize on the algorithm More...
 
virtual StatusCode execute () override
 call execute on the algorithm More...
 
virtual StatusCode postExecute () override
 call postExecute on the algorithm More...
 
virtual StatusCode finalize () override
 call finalize on the algorithm More...
 
virtual ::StatusCode fileExecute () override
 call fileExecute on the algorithm More...
 
virtual ::StatusCode beginInputFile () override
 call beginInputFile on the algorithm More...
 
virtual ::StatusCode endInputFile () override
 call endInputFile on the algorithm More...
 

Private Attributes

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

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  }

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;
181  RCU_CHANGE_INVARIANT (this);
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 &&
190  m_algorithm->m_wk->tree() != nullptr &&
191  m_algorithm->m_wk->tree()->GetEntries() > 0)
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  }

◆ 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;
209  RCU_CHANGE_INVARIANT (this);
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 ( )
overridevirtual

call execute on the algorithm

Implements EL::IAlgorithmWrapper.

Definition at line 105 of file AlgorithmWrapper.cxx.

107  {
108  using namespace msgAlgorithmConfig;
109  RCU_CHANGE_INVARIANT (this);
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;
165  RCU_CHANGE_INVARIANT (this);
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;
141  RCU_CHANGE_INVARIANT (this);
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  }

◆ 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;
91  RCU_CHANGE_INVARIANT (this);
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  }

◆ 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;
125  RCU_CHANGE_INVARIANT (this);
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.

◆ m_isInitialized

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

whether Algorithm::initialize has been called

Definition at line 79 of file AlgorithmWrapper.h.


The documentation for this class was generated from the following files:
EL::AlgorithmWrapper::m_firstFile
bool m_firstFile
whether this is the first file we encounter
Definition: AlgorithmWrapper.h:76
ANA_MSG_ERROR
#define ANA_MSG_ERROR(xmsg)
Macro printing error messages.
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:294
EL::AlgorithmWrapper::m_isInitialized
bool m_isInitialized
whether Algorithm::initialize has been called
Definition: AlgorithmWrapper.h:79
EL::AlgorithmWrapper::m_algorithm
std::unique_ptr< Algorithm > m_algorithm
the actual algorithm
Definition: AlgorithmWrapper.h:73
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
RCU_CHANGE_INVARIANT
#define RCU_CHANGE_INVARIANT(x)
Definition: Assert.h:231
RCU_THROW_MSG
#define RCU_THROW_MSG(message)
Definition: PrintMsg.h:58
RCU_READ_INVARIANT
#define RCU_READ_INVARIANT(x)
Definition: Assert.h:229
RCU_NEW_INVARIANT
#define RCU_NEW_INVARIANT(x)
Definition: Assert.h:233