ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
D3PDTools
EventLoop
Root
JobConfig.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3
*/
4
6
7
8
9
//
10
// includes
11
//
12
13
#include <
EventLoop/JobConfig.h
>
14
15
#include <
AnaAlgorithm/IAlgorithmWrapper.h
>
16
#include <
EventLoop/AlgorithmData.h
>
17
#include <
EventLoop/MessageCheck.h
>
18
#include <
RootCoreUtils/Assert.h
>
19
20
#include <stdexcept>
21
22
//
23
// method implementations
24
//
25
26
ClassImp
(
EL::JobConfig
)
27
28
namespace
EL
29
{
30
void
JobConfig ::
31
testInvariant ()
const
32
{}
33
34
35
36
JobConfig ::
37
JobConfig ()
noexcept
38
{
39
RCU_NEW_INVARIANT
(
this
);
40
}
41
42
43
44
JobConfig ::
45
JobConfig (
const
JobConfig
& that)
46
: TObject (that),
47
m_algorithmCount (that.m_algorithmCount),
48
m_algSequenceStartIndices (that.m_algSequenceStartIndices)
49
{
50
RCU_READ_INVARIANT
(&that);
51
52
for
(
const
auto
&
algorithm
: that.m_algorithms)
53
{
54
if
(
algorithm
!=
nullptr
)
55
{
56
m_algorithms.push_back (
algorithm
->makeClone ());
57
}
else
58
{
59
m_algorithms.emplace_back (
nullptr
);
60
}
61
}
62
63
RCU_NEW_INVARIANT
(
this
);
64
}
65
66
67
68
JobConfig ::
69
JobConfig (
JobConfig
&& that) noexcept
70
:
JobConfig
()
71
{
72
that.swap (*
this
);
73
74
// no invariant used
75
}
76
77
78
79
JobConfig ::
80
~JobConfig ()
noexcept
81
{
82
RCU_DESTROY_INVARIANT
(
this
);
83
84
// not actually doing anything here, but have to make the
85
// destructor explicit to break include dependencies.
86
}
87
88
89
90
JobConfig
& JobConfig ::
91
operator = (
const
JobConfig
& that)
92
{
93
// no invariant used
94
JobConfig
(that).swap (*
this
);
95
return
*
this
;
96
}
97
98
99
100
JobConfig
& JobConfig ::
101
operator = (
JobConfig
&& that)
noexcept
102
{
103
// no invariant used
104
that.swap (*
this
);
105
return
*
this
;
106
}
107
108
109
110
void
JobConfig ::
111
swap (
JobConfig
& that)
noexcept
112
{
113
RCU_CHANGE_INVARIANT
(
this
);
114
RCU_CHANGE_INVARIANT
(&that);
115
std::swap
(m_algorithmCount, that.m_algorithmCount);
116
m_algorithms.swap (that.m_algorithms);
117
m_algSequenceStartIndices.swap (that.m_algSequenceStartIndices);
118
}
119
120
121
122
::StatusCode
JobConfig ::
123
addAlgorithm (std::unique_ptr<IAlgorithmWrapper>&& val_algorithm)
124
{
125
using namespace
msgEventLoop;
126
127
RCU_CHANGE_INVARIANT
(
this
);
128
RCU_REQUIRE
(val_algorithm !=
nullptr
);
129
130
if
(getAlgorithm (val_algorithm->getName()) !=
nullptr
)
131
{
132
ANA_MSG_ERROR
(
"can't have two algorithms with the same name: "
<< val_algorithm->getName());
133
return ::StatusCode::FAILURE;
134
}
135
136
m_algorithms.push_back (std::move (val_algorithm));
137
++ m_algorithmCount;
138
return ::StatusCode::SUCCESS;
139
}
140
141
142
143
const
IAlgorithmWrapper *JobConfig ::
144
getAlgorithm (std::string_view name)
const
noexcept
145
{
146
RCU_READ_INVARIANT
(
this
);
147
for
(
const
auto
&
algorithm
: m_algorithms)
148
{
149
if
(
algorithm
!=
nullptr
&&
algorithm
->getName() == name)
150
return
algorithm
.get();
151
}
152
return
nullptr
;
153
}
154
155
156
157
std::vector<Detail::AlgorithmData> JobConfig ::
158
extractAlgorithms ()
159
{
160
RCU_CHANGE_INVARIANT
(
this
);
161
if
(m_algorithmCount != m_algorithms.size())
162
throw
std::runtime_error (
"JobConfig::extractAlgorithms: algorithm count missmatch. streaming error?"
);
163
for
(
const
auto
&
algorithm
: m_algorithms)
164
{
165
if
(
algorithm
==
nullptr
)
166
throw
std::runtime_error (
"JobConfig::extractAlgorithms: algorithm null. streaming error?"
);
167
}
168
m_algorithmCount = 0;
169
std::vector<Detail::AlgorithmData> result;
170
result.reserve (m_algorithms.size());
171
for
(
auto
&
algorithm
: m_algorithms)
172
result.emplace_back (std::move (
algorithm
));
173
m_algorithms.clear();
174
for
(
auto
sequenceStartIndex : m_algSequenceStartIndices)
175
{
176
// need to check here, since the user could have added a new
177
// sequence start at the end of the list, without adding an
178
// algorithm for it.
179
if
(sequenceStartIndex < result.size())
180
result[sequenceStartIndex].m_sequenceStart =
true
;
181
}
182
// clear the sequence starts as well, so that reusing this JobConfig
183
// after extraction does not reapply the old starts to newly added
184
// algorithms
185
m_algSequenceStartIndices.clear();
186
return
result;
187
}
188
189
190
191
std::size_t JobConfig ::
192
numberOfAlgorithms ()
const
noexcept
193
{
194
RCU_READ_INVARIANT
(
this
);
195
return
m_algorithms.size();
196
}
197
198
199
200
void
201
JobConfig ::
202
startNewAlgSequence ()
203
{
204
RCU_CHANGE_INVARIANT
(
this
);
205
m_algSequenceStartIndices.push_back (m_algorithms.size());
206
}
207
}
AlgorithmData.h
Assert.h
RCU_DESTROY_INVARIANT
#define RCU_DESTROY_INVARIANT(x)
Definition
Assert.h:223
RCU_CHANGE_INVARIANT
#define RCU_CHANGE_INVARIANT(x)
Definition
Assert.h:219
RCU_NEW_INVARIANT
#define RCU_NEW_INVARIANT(x)
Definition
Assert.h:221
RCU_REQUIRE
#define RCU_REQUIRE(x)
Definition
Assert.h:196
RCU_READ_INVARIANT
#define RCU_READ_INVARIANT(x)
Definition
Assert.h:217
ANA_MSG_ERROR
#define ANA_MSG_ERROR(xmsg,...)
Macro printing error messages.
Definition
Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:295
IAlgorithmWrapper.h
ClassImp
ClassImp(EL::JobConfig) namespace EL
Definition
JobConfig.cxx:26
JobConfig.h
MessageCheck.h
EL::JobConfig
the job configuration that is independent of driver and dataset
Definition
JobConfig.h:45
algorithm
std::string algorithm
Definition
hcg.cxx:87
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::swap
void swap(ElementLinkVector< DOBJ > &lhs, ElementLinkVector< DOBJ > &rhs)
Definition
AthLinks/ElementLinkVector.h:484
JobConfig
Definition
CoolFix.cxx:80
Generated on
for ATLAS Offline Software by
1.17.0