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
RCU_INVARIANT
(
this
!=
nullptr
);
34
}
35
36
37
38
JobConfig ::
39
JobConfig ()
noexcept
40
{
41
RCU_NEW_INVARIANT
(
this
);
42
}
43
44
45
46
JobConfig ::
47
JobConfig (
const
JobConfig
& that)
48
: TObject (that),
49
m_algorithmCount (that.m_algorithmCount),
50
m_algSequenceStartIndices (that.m_algSequenceStartIndices)
51
{
52
RCU_READ_INVARIANT
(&that);
53
54
for
(
const
auto
&
algorithm
: that.m_algorithms)
55
{
56
if
(
algorithm
!=
nullptr
)
57
{
58
m_algorithms.push_back (
algorithm
->makeClone ());
59
}
else
60
{
61
m_algorithms.emplace_back (
nullptr
);
62
}
63
}
64
65
RCU_NEW_INVARIANT
(
this
);
66
}
67
68
69
70
JobConfig ::
71
JobConfig (
JobConfig
&& that) noexcept
72
:
JobConfig
()
73
{
74
that.swap (*
this
);
75
76
// no invariant used
77
}
78
79
80
81
JobConfig ::
82
~JobConfig ()
noexcept
83
{
84
RCU_DESTROY_INVARIANT
(
this
);
85
86
// not actually doing anything here, but have to make the
87
// destructor explicit to break include dependencies.
88
}
89
90
91
92
JobConfig
& JobConfig ::
93
operator = (
const
JobConfig
& that)
94
{
95
// no invariant used
96
JobConfig
(that).swap (*
this
);
97
return
*
this
;
98
}
99
100
101
102
JobConfig
& JobConfig ::
103
operator = (
JobConfig
&& that)
noexcept
104
{
105
// no invariant used
106
that.swap (*
this
);
107
return
*
this
;
108
}
109
110
111
112
void
JobConfig ::
113
swap (
JobConfig
& that)
noexcept
114
{
115
RCU_CHANGE_INVARIANT
(
this
);
116
RCU_CHANGE_INVARIANT
(&that);
117
std::swap
(m_algorithmCount, that.m_algorithmCount);
118
m_algorithms.swap (that.m_algorithms);
119
m_algSequenceStartIndices.swap (that.m_algSequenceStartIndices);
120
}
121
122
123
124
::StatusCode
JobConfig ::
125
addAlgorithm (std::unique_ptr<IAlgorithmWrapper>&& val_algorithm)
126
{
127
using namespace
msgEventLoop;
128
129
RCU_CHANGE_INVARIANT
(
this
);
130
RCU_REQUIRE
(val_algorithm !=
nullptr
);
131
132
if
(getAlgorithm (val_algorithm->getName()) !=
nullptr
)
133
{
134
ANA_MSG_ERROR
(
"can't have two algorithms with the same name: "
<< val_algorithm->getName());
135
return ::StatusCode::FAILURE;
136
}
137
138
m_algorithms.push_back (std::move (val_algorithm));
139
++ m_algorithmCount;
140
return ::StatusCode::SUCCESS;
141
}
142
143
144
145
const
IAlgorithmWrapper *JobConfig ::
146
getAlgorithm (std::string_view name)
const
noexcept
147
{
148
RCU_READ_INVARIANT
(
this
);
149
for
(
const
auto
&
algorithm
: m_algorithms)
150
{
151
if
(
algorithm
!=
nullptr
&&
algorithm
->getName() == name)
152
return
algorithm
.get();
153
}
154
return
nullptr
;
155
}
156
157
158
159
std::vector<Detail::AlgorithmData> JobConfig ::
160
extractAlgorithms ()
161
{
162
RCU_CHANGE_INVARIANT
(
this
);
163
if
(m_algorithmCount != m_algorithms.size())
164
throw
std::runtime_error (
"JobConfig::extractAlgorithms: algorithm count missmatch. streaming error?"
);
165
for
(
const
auto
&
algorithm
: m_algorithms)
166
{
167
if
(
algorithm
==
nullptr
)
168
throw
std::runtime_error (
"JobConfig::extractAlgorithms: algorithm null. streaming error?"
);
169
}
170
m_algorithmCount = 0;
171
std::vector<Detail::AlgorithmData> result;
172
result.reserve (m_algorithms.size());
173
for
(
auto
&
algorithm
: m_algorithms)
174
result.emplace_back (std::move (
algorithm
));
175
m_algorithms.clear();
176
for
(
auto
sequenceStartIndex : m_algSequenceStartIndices)
177
{
178
// need to check here, since the user could have added a new
179
// sequence start at the end of the list, without adding an
180
// algorithm for it.
181
if
(sequenceStartIndex < result.size())
182
result[sequenceStartIndex].m_sequenceStart =
true
;
183
}
184
return
result;
185
}
186
187
188
189
std::size_t JobConfig ::
190
numberOfAlgorithms ()
const
noexcept
191
{
192
RCU_READ_INVARIANT
(
this
);
193
return
m_algorithms.size();
194
}
195
196
197
198
void
199
JobConfig ::
200
startNewAlgSequence ()
201
{
202
RCU_CHANGE_INVARIANT
(
this
);
203
m_algSequenceStartIndices.push_back (m_algorithms.size());
204
}
205
}
AlgorithmData.h
Assert.h
RCU_INVARIANT
#define RCU_INVARIANT(x)
Definition
Assert.h:189
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:294
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