ATLAS Offline Software
AnaAlgorithmWrapper.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 
8 //
9 // includes
10 //
13 
14 #include "RootCoreUtils/Assert.h"
15 
16 //
17 // method implementations
18 //
19 
20 namespace EL
21 {
23  testInvariant () const
24  {
25  RCU_INVARIANT (!m_config.name().empty());
26  }
27 
28 
29 
32  : m_config (std::move (val_config))
33  {
34  RCU_NEW_INVARIANT (this);
35  }
36 
37 
38 
39  std::string_view AnaAlgorithmWrapper ::
40  getName () const
41  {
42  RCU_READ_INVARIANT (this);
43  return m_config.name();
44  }
45 
46 
47 
49  hasName (const std::string& name) const
50  {
51  RCU_READ_INVARIANT (this);
52  return m_config.name() == name;
53  }
54 
55 
56 
57  std::unique_ptr<IAlgorithmWrapper> AnaAlgorithmWrapper ::
58  makeClone() const
59  {
60  RCU_READ_INVARIANT (this);
61  return std::make_unique<AnaAlgorithmWrapper> (m_config);
62  }
63 
64 
65 
67  initialize (const AlgorithmWorkerData& workerData)
68  {
69  using namespace msgAlgorithmConfig;
70  RCU_CHANGE_INVARIANT (this);
71  if (m_config.makeAlgorithm (m_algorithm, workerData).isFailure())
72  {
73  ANA_MSG_ERROR ("failed to create AnaAlgorithm: " << m_config.name());
74  return StatusCode::FAILURE;
75  }
76  return StatusCode::SUCCESS;
77  }
78 
79 
80 
82  execute ()
83  {
84  using namespace msgAlgorithmConfig;
85  RCU_READ_INVARIANT (this);
86  if (m_algorithm->sysExecute().isFailure())
87  {
88  ANA_MSG_ERROR ("failed to call execute() on algorithm: " << m_config.name());
89  return StatusCode::FAILURE;
90  }
91  return StatusCode::SUCCESS;
92  }
93 
94 
95 
97  finalize ()
98  {
99  using namespace msgAlgorithmConfig;
100  RCU_READ_INVARIANT (this);
101  if (m_algorithm->sysFinalize().isFailure())
102  {
103  ANA_MSG_ERROR ("failed to call finalize() on algorithm: " << m_config.name());
104  return StatusCode::FAILURE;
105  }
106  return StatusCode::SUCCESS;
107  }
108 
109 
110 
112  fileExecute ()
113  {
114  using namespace msgAlgorithmConfig;
115  RCU_READ_INVARIANT (this);
116  if (m_algorithm->hasFileExecute())
117  {
118  if (m_algorithm->sysFileExecute().isFailure())
119  {
120  ANA_MSG_ERROR ("failed to call fileExecute() on algorithm: " << m_config.name());
121  return StatusCode::FAILURE;
122  }
123  }
124  return StatusCode::SUCCESS;
125  }
126 
127 
128 
131  {
132  using namespace msgAlgorithmConfig;
133  RCU_READ_INVARIANT (this);
134  if (m_algorithm->hasBeginInputFile())
135  {
136  if (m_algorithm->sysBeginInputFile().isFailure())
137  {
138  ANA_MSG_ERROR ("failed to call beginInputFile() on algorithm: " << m_config.name());
139  return StatusCode::FAILURE;
140  }
141  }
142  return StatusCode::SUCCESS;
143  }
144 
145 
146 
148  endInputFile ()
149  {
150  using namespace msgAlgorithmConfig;
151  RCU_READ_INVARIANT (this);
152  if (m_algorithm->hasEndInputFile())
153  {
154  if (m_algorithm->sysEndInputFile().isFailure())
155  {
156  ANA_MSG_ERROR ("failed to call endInputFile() on algorithm: " << m_config.name());
157  return StatusCode::FAILURE;
158  }
159  }
160  return StatusCode::SUCCESS;
161  }
162 }
EL::AnaAlgorithmWrapper::execute
virtual StatusCode execute() override
call execute on the algorithm
Definition: AnaAlgorithmWrapper.cxx:82
EL::AnaAlgorithmWrapper::beginInputFile
virtual ::StatusCode beginInputFile() override
call beginInputFile on the algorithm
Definition: AnaAlgorithmWrapper.cxx:130
ANA_MSG_ERROR
#define ANA_MSG_ERROR(xmsg)
Macro printing error messages.
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:294
EL::AnaAlgorithmWrapper::AnaAlgorithmWrapper
AnaAlgorithmWrapper()
standard default constructor for serialization
Definition: AnaAlgorithmWrapper.h:33
EL::AnaAlgorithmConfig
an object that can create a AnaAlgorithm
Definition: AnaAlgorithmConfig.h:29
Assert.h
EL::AnaAlgorithmWrapper::endInputFile
virtual ::StatusCode endInputFile() override
call endInputFile on the algorithm
Definition: AnaAlgorithmWrapper.cxx:148
EL::AnaAlgorithmWrapper::testInvariant
void testInvariant() const
test the invariant of this object
Definition: AnaAlgorithmWrapper.cxx:23
AnaAlgorithmWrapper.h
EL::AnaAlgorithmWrapper::hasName
virtual bool hasName(const std::string &name) const override
whether this algorithm has the given name
Definition: AnaAlgorithmWrapper.cxx:49
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
EL
This module defines the arguments passed from the BATCH driver to the BATCH worker.
Definition: AlgorithmWorkerData.h:24
EL::AnaAlgorithmConfig::makeAlgorithm
::StatusCode makeAlgorithm(std::unique_ptr< AnaAlgorithm > &algorithm, const AlgorithmWorkerData &workerData) const
make an algorithm from this configuration
Definition: AnaAlgorithmConfig.cxx:82
RCU_INVARIANT
#define RCU_INVARIANT(x)
Definition: Assert.h:201
MessageCheck.h
EL::AnaAlgorithmWrapper::initialize
virtual StatusCode initialize(const AlgorithmWorkerData &workerData) override
call initialize on the algorithm
Definition: AnaAlgorithmWrapper.cxx:67
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
EL::AnaAlgorithmWrapper::getName
virtual std::string_view getName() const override
Definition: AnaAlgorithmWrapper.cxx:40
EL::AlgorithmWorkerData
all the external components an algorithm needs before initialization (in EventLoop)
Definition: AlgorithmWorkerData.h:34
EL::AnaAlgorithmWrapper::makeClone
virtual std::unique_ptr< IAlgorithmWrapper > makeClone() const override
make a clone of this algorithm
Definition: AnaAlgorithmWrapper.cxx:58
EL::AnaAlgorithmWrapper::m_algorithm
std::unique_ptr< AnaAlgorithm > m_algorithm
the actual algorithm (once instantiated)
Definition: AnaAlgorithmWrapper.h:76
EL::AnaAlgorithmWrapper::finalize
virtual StatusCode finalize() override
call finalize on the algorithm
Definition: AnaAlgorithmWrapper.cxx:97
EL::AnaAlgorithmWrapper::fileExecute
virtual ::StatusCode fileExecute() override
call fileExecute on the algorithm
Definition: AnaAlgorithmWrapper.cxx:112
RCU_CHANGE_INVARIANT
#define RCU_CHANGE_INVARIANT(x)
Definition: Assert.h:231
asg::AsgComponentConfig::name
const std::string & name() const noexcept
the name of the component
Definition: AsgComponentConfig.cxx:90
RCU_READ_INVARIANT
#define RCU_READ_INVARIANT(x)
Definition: Assert.h:229
EL::AnaAlgorithmWrapper::m_config
AnaAlgorithmConfig m_config
the algorithm configuration
Definition: AnaAlgorithmWrapper.h:69
RCU_NEW_INVARIANT
#define RCU_NEW_INVARIANT(x)
Definition: Assert.h:233