ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
D3PDTools
EventLoop
Root
AlgorithmWrapper.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
6
7
8
9
//
10
// includes
11
//
12
13
#include <
EventLoop/AlgorithmWrapper.h
>
14
15
#include <
AnaAlgorithm/MessageCheck.h
>
16
#include <
AnaAlgorithm/AlgorithmWorkerData.h
>
17
#include <
EventLoop/Algorithm.h
>
18
#include <
EventLoop/IWorker.h
>
19
#include <
RootCoreUtils/Assert.h
>
20
#include <
RootCoreUtils/ThrowMsg.h
>
21
#include <
xAODRootAccess/Event.h
>
22
23
//
24
// method implementations
25
//
26
27
namespace
EL
28
{
29
void
AlgorithmWrapper ::
30
testInvariant ()
const
31
{
32
}
33
34
35
36
AlgorithmWrapper ::
37
AlgorithmWrapper (std::unique_ptr<Algorithm>&& val_algorithm)
38
:
m_algorithm
(
std
::move (val_algorithm))
39
{
40
RCU_NEW_INVARIANT
(
this
);
41
}
42
43
44
45
std::string_view AlgorithmWrapper ::
46
getName ()
const
47
{
48
RCU_READ_INVARIANT
(
this
);
49
return
m_algorithm
->GetName();
50
}
51
52
53
54
bool
AlgorithmWrapper ::
55
hasName (
const
std::string& name)
const
56
{
57
RCU_READ_INVARIANT
(
this
);
58
return
m_algorithm
->hasName (name);
59
}
60
61
62
63
std::unique_ptr<IAlgorithmWrapper> AlgorithmWrapper ::
64
makeClone()
const
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
}
75
76
77
78
Algorithm
*AlgorithmWrapper ::
79
getLegacyAlg ()
80
{
81
RCU_READ_INVARIANT
(
this
);
82
return
m_algorithm
.get();
83
}
84
85
86
87
StatusCode
AlgorithmWrapper ::
88
initialize (
const
AlgorithmWorkerData
& workerData)
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
}
102
103
104
105
StatusCode
AlgorithmWrapper ::
106
execute (
const
EventContext&
/*ctx*/
)
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
}
118
119
120
121
StatusCode
AlgorithmWrapper ::
122
postExecute ()
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
}
134
135
136
137
StatusCode
AlgorithmWrapper ::
138
finalize ()
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
}
158
159
160
161
::StatusCode
AlgorithmWrapper ::
162
fileExecute ()
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
}
174
175
176
177
::StatusCode
AlgorithmWrapper ::
178
beginInputFile ()
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
&&
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
}
200
201
202
203
::StatusCode
AlgorithmWrapper ::
204
endInputFile ()
205
{
206
using namespace
msgAlgorithmConfig;
207
RCU_CHANGE_INVARIANT
(
this
);
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
}
216
}
AlgorithmWorkerData.h
AlgorithmWrapper.h
Algorithm.h
Assert.h
RCU_CHANGE_INVARIANT
#define RCU_CHANGE_INVARIANT(x)
Definition
Assert.h:226
RCU_NEW_INVARIANT
#define RCU_NEW_INVARIANT(x)
Definition
Assert.h:228
RCU_READ_INVARIANT
#define RCU_READ_INVARIANT(x)
Definition
Assert.h:224
ANA_MSG_ERROR
#define ANA_MSG_ERROR(xmsg)
Macro printing error messages.
Definition
Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:294
Event.h
IWorker.h
MessageCheck.h
RCU_THROW_MSG
#define RCU_THROW_MSG(message)
Definition
PrintMsg.h:53
ThrowMsg.h
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
EL::AlgorithmWrapper::m_firstFile
bool m_firstFile
whether this is the first file we encounter
Definition
AlgorithmWrapper.h:76
EL::Algorithm
Definition
Algorithm.h:22
EL
This module defines the arguments passed from the BATCH driver to the BATCH worker.
Definition
AsgComponentFactories.h:16
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition
PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
std
STL namespace.
EL::AlgorithmWorkerData
all the external components an algorithm needs before initialization (in EventLoop)
Definition
AlgorithmWorkerData.h:34
EL::AlgorithmWorkerData::m_evtStore
asg::SgEvent * m_evtStore
Definition
AlgorithmWorkerData.h:35
EL::AlgorithmWorkerData::m_wk
IWorker * m_wk
Definition
AlgorithmWorkerData.h:39
Generated on
for ATLAS Offline Software by
1.17.0