ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
DataQuality
GoodRunsLists
Root
TGRLCollection.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
6
#include "
GoodRunsLists/TGRLCollection.h
"
7
#include "
GoodRunsLists/TMsgLogger.h
"
8
9
#include <algorithm>
10
11
ClassImp
(
Root::TGRLCollection
)
12
13
14
Root::TGRLCollection::TGRLCollection
( Bool_t checkGRLInfo )
15
:
std
::
vector
<TGoodRunsList>()
16
, TObject()
17
, m_checkGRLInfo( checkGRLInfo )
18
{
19
}
20
21
22
Root::TGRLCollection::~TGRLCollection
()
23
{
24
this->
Reset
();
25
}
26
27
28
void
29
Root::TGRLCollection::Reset
()
30
{
31
this->
clear
();
32
m_checkGRLInfo
=kFALSE;
33
}
34
35
36
void
37
Root::TGRLCollection::SetVersion
(
const
TString& version )
38
{
39
std::vector<TGoodRunsList>::iterator itr = this->begin();
40
std::vector<TGoodRunsList>::iterator end = this->end();
41
for
(; itr!=end; ++itr) itr->SetVersion(version);
42
}
43
44
45
void
46
Root::TGRLCollection::SetMetaData
(
const
std::map<TString,TString>& metadata )
47
{
48
std::vector<TGoodRunsList>::iterator itr = this->begin();
49
std::vector<TGoodRunsList>::iterator end = this->end();
50
for
(; itr!=end; ++itr) itr->SetMetaData(metadata);
51
}
52
53
void
54
Root::TGRLCollection::Summary
(Bool_t
verbose
/*= kFALSE*/
)
const
55
{
56
std::vector<TGoodRunsList>::const_iterator itr = this->begin();
57
std::vector<TGoodRunsList>::const_iterator end = this->end();
58
59
for
(; itr!=end; ++itr)
60
itr->Summary(
verbose
) ;
61
}
62
63
64
Bool_t
65
Root::TGRLCollection::HasRun
(
const
Int_t& runnr )
const
66
{
67
std::vector<TGoodRunsList>::const_iterator itr = this->begin();
68
std::vector<TGoodRunsList>::const_iterator end = this->end();
69
70
Bool_t pass(kFALSE);
71
for
(; itr!=end && !pass; ++itr)
72
pass = itr->HasRun(runnr);
73
74
return
pass;
75
}
76
77
78
Bool_t
79
Root::TGRLCollection::HasRunLumiBlock
(
const
Int_t& runnr,
const
Int_t& lumiblocknr )
const
80
{
81
std::vector<TGoodRunsList>::const_iterator itr = this->begin();
82
std::vector<TGoodRunsList>::const_iterator end = this->end();
83
84
Bool_t pass(kFALSE);
85
for
(; itr!=end && !pass; ++itr)
86
pass = itr->HasRunLumiBlock(runnr,lumiblocknr);
87
88
return
pass;
89
}
90
91
92
Bool_t
93
Root::TGRLCollection::IsEmpty
()
const
94
{
95
if
(this->
empty
())
return
kTRUE;
96
97
Bool_t isEmpty(kTRUE);
98
std::vector< TGoodRunsList >::const_iterator litr = this->begin();
99
for
(; litr!=this->end() && isEmpty; ++litr)
100
isEmpty = isEmpty && litr->IsEmpty();
101
102
return
isEmpty;
103
}
104
105
106
const
Root::TGoodRunsList
107
Root::TGRLCollection::GetMergedGoodRunsList
(
const
Root::BoolOperation
& operation )
const
108
{
109
// nothing interpreted. Return empty grl.
110
if
(this->
empty
())
return
Root::TGoodRunsList
();
111
112
// set first goodrunslist
113
std::vector<Root::TGoodRunsList>::const_iterator itr = this->begin();
114
Root::TGoodRunsList
grl(*itr);
115
if
(this->
size
()==1) {
116
grl.
Compress
();
117
return
grl;
118
}
119
120
TMsgLogger
mylogger(
"TGRLCollection"
);
121
mylogger <<
kINFO
<<
"Now merging GRLs."
<<
GEndl
;
122
123
// check version and metadata when merging goodrunslists?
124
grl.SetCheckGRLInfo(
m_checkGRLInfo
);
125
126
if
(!
m_checkGRLInfo
)
127
mylogger <<
kINFO
<<
"Metadata and other info not required to be identical between GRLs."
<<
GEndl
;
128
129
// start AND-ing or OR-ring with following goodrunslists
130
for
(++itr; itr!=this->end(); ++itr) {
131
switch
(operation) {
132
case
OR
:
133
if
( grl.HasOverlapWith(*itr,
false
/*verbose*/
) ) {
// MB 22-june: LB splitting across files, turn off warning.
134
//mylogger << kWARNING << "Merging GRLs with overlapping lumi-blocks! Overlapping LBs rejected." << GEndl;
135
//mylogger << kWARNING << "IMPORTANT : Check your analysis for possible duplicate events!" << GEndl;
136
}
137
grl.AddGRL( *itr );
138
break
;
139
case
AND
:
140
grl = grl.GetOverlapWith(*itr);
141
break
;
142
}
143
}
144
145
grl.Compress();
// cleanup, safe space
146
return
grl;
147
}
148
149
150
const
Root::TGoodRunsList
151
Root::TGRLCollection::GetGoodRunsList
(
unsigned
int
idx )
const
152
{
153
// invalid idx. Return empty grl.
154
if
(idx>=this->
size
())
return
Root::TGoodRunsList
();
155
156
return
(*
this
)[idx];
157
}
158
159
160
const
Root::TGRLCollection
161
Root::TGRLCollection::GetMergedGRLCollection
(
const
Root::BoolOperation
& operation )
const
162
{
163
if
(this->
empty
()
/*|| this->size()==1*/
)
return
*
this
;
// nothing to merge, return this
164
165
TMsgLogger
mylogger(
"TGRLCollection"
);
166
mylogger <<
kINFO
<<
"Now merging GRLs where possible. Metadata required to be identical."
<<
GEndl
;
167
168
Root::TGRLCollection
mergevec;
169
170
std::vector<TGoodRunsList>::const_iterator itr = this->begin();
171
std::vector<TGoodRunsList>::const_iterator end = this->end();
172
std::vector<TGoodRunsList>::iterator mitr;
173
174
for
(; itr!=end; ++itr) {
175
bool
matchFound(
false
);
176
for
(mitr=mergevec.begin(); mitr!=mergevec.end() && !matchFound ; ++mitr) {
177
if
(mitr->HasSameGRLInfo(*itr)) {
178
matchFound =
true
;
179
switch
(operation) {
180
case
OR
:
181
if
( mitr->HasOverlapWith(*itr,
false
/*verbose*/
) ) {
// // MB 22-june: LB splitting across files, turn off warning.
182
//mylogger << kWARNING << "Merging GRLs with overlapping lumi-blocks! Overlapping LBs rejected." << GEndl;
183
//mylogger << kWARNING << "IMPORTANT : Check your analysis for possible duplicate events!" << GEndl;
184
}
185
mitr->AddGRL( *itr );
186
break
;
187
case
AND
:
188
*mitr = mitr->GetOverlapWith( *itr );
189
break
;
190
}
191
mitr->Compress();
// safe space
192
}
193
}
194
if
(!matchFound) {
195
mergevec.push_back(*itr);
196
mergevec.rbegin()->Compress();
// safe space
197
}
198
}
199
200
return
mergevec;
201
}
202
203
204
std::vector<Root::TGoodRunsList>::iterator
205
Root::TGRLCollection::find
(
const
TString& name )
206
{
207
Bool_t found(
false
);
208
209
std::vector<TGoodRunsList>::iterator itr = this->begin();
210
std::vector<TGoodRunsList>::iterator end = this->end();
211
212
for
(; itr!=end; ++itr) {
213
found = ( name==TString(itr->GetName()) ) ;
214
if
(found)
break
;
215
}
216
217
return
itr;
218
}
219
220
221
std::vector<Root::TGoodRunsList>::const_iterator
222
Root::TGRLCollection::find
(
const
TString& name )
const
223
{
224
Bool_t found(
false
);
225
226
std::vector<TGoodRunsList>::const_iterator itr = this->begin();
227
std::vector<TGoodRunsList>::const_iterator end = this->end();
228
229
for
(; itr!=end; ++itr) {
230
found = ( name==TString(itr->GetName()) ) ;
231
if
(found)
break
;
232
}
233
234
return
itr;
235
}
236
237
238
Bool_t
239
Root::TGRLCollection::HasGoodRunsList
(
const
TString& name )
const
240
{
241
return
(this->
find
(name)!=this->end());
242
}
243
244
245
const
Root::TGRLCollection
246
Root::TGRLCollection::GetOverlapWith
(
const
TGoodRunsList
& other )
const
247
{
248
Root::TGRLCollection
overlapvec;
249
250
std::vector<TGoodRunsList>::const_iterator itr = this->begin();
251
for
(; itr!=this->end(); ++itr) {
252
Root::TGoodRunsList
overlapgrl = itr->GetOverlapWith(other);
253
overlapgrl.SetName(itr->GetName());
254
overlapgrl.
SetVersion
(itr->GetVersion());
255
overlapgrl.
SetMetaData
(itr->GetMetaData());
256
overlapgrl.
Compress
();
257
overlapvec.push_back(std::move(overlapgrl));
// also push_back if empty!
258
}
259
260
return
overlapvec;
261
}
262
263
264
size
size_t size() const
Number of registered mappings.
clear
void clear()
Empty the pool.
ClassImp
ClassImp(Root::TGRLCollection) Root
Definition
TGRLCollection.cxx:11
TGRLCollection.h
TMsgLogger.h
GEndl
#define GEndl
Definition
TMsgLogger.h:147
empty
static const Attributes_t empty
Definition
XmlStreamer.cxx:16
Root::TGRLCollection
Definition
TGRLCollection.h:24
Root::TGRLCollection::GetMergedGoodRunsList
const TGoodRunsList GetMergedGoodRunsList(const Root::BoolOperation &operation=OR) const
Definition
TGRLCollection.cxx:107
Root::TGRLCollection::GetGoodRunsList
const TGoodRunsList GetGoodRunsList(unsigned int idx) const
Definition
TGRLCollection.cxx:151
Root::TGRLCollection::Reset
void Reset()
Definition
TGRLCollection.cxx:29
Root::TGRLCollection::m_checkGRLInfo
Bool_t m_checkGRLInfo
Definition
TGRLCollection.h:57
Root::TGRLCollection::SetVersion
void SetVersion(const TString &version)
Definition
TGRLCollection.cxx:37
Root::TGRLCollection::SetMetaData
void SetMetaData(const std::map< TString, TString > &metadata)
Definition
TGRLCollection.cxx:46
Root::TGRLCollection::HasRun
Bool_t HasRun(const Int_t &runnr) const
Definition
TGRLCollection.cxx:65
Root::TGRLCollection::HasRunLumiBlock
Bool_t HasRunLumiBlock(const Int_t &runnr, const Int_t &lumiblocknr) const
Definition
TGRLCollection.cxx:79
Root::TGRLCollection::GetOverlapWith
const Root::TGRLCollection GetOverlapWith(const TGoodRunsList &other) const
Definition
TGRLCollection.cxx:246
Root::TGRLCollection::Summary
void Summary(Bool_t verbose=kFALSE) const
Definition
TGRLCollection.cxx:54
Root::TGRLCollection::GetMergedGRLCollection
const Root::TGRLCollection GetMergedGRLCollection(const Root::BoolOperation &operation=OR) const
Definition
TGRLCollection.cxx:161
Root::TGRLCollection::TGRLCollection
TGRLCollection(Bool_t checkGRLInfo=kFALSE)
Root::TGRLCollection::HasGoodRunsList
Bool_t HasGoodRunsList(const TString &name) const
Definition
TGRLCollection.cxx:239
Root::TGRLCollection::IsEmpty
Bool_t IsEmpty() const
Definition
TGRLCollection.cxx:93
Root::TGRLCollection::~TGRLCollection
virtual ~TGRLCollection()
Definition
TGRLCollection.cxx:22
Root::TGRLCollection::find
std::vector< TGoodRunsList >::iterator find(const TString &name)
Definition
TGRLCollection.cxx:205
Root::TGoodRunsList
Definition
TGoodRunsList.h:26
Root::TGoodRunsList::SetVersion
void SetVersion(const TString &version)
Definition
TGoodRunsList.h:52
Root::TGoodRunsList::Compress
void Compress()
Definition
TGoodRunsList.cxx:429
Root::TGoodRunsList::SetMetaData
void SetMetaData(const std::map< TString, TString > &metadata)
Definition
TGoodRunsList.h:54
Root::TMsgLogger
Definition
TMsgLogger.h:47
vector
Definition
MultiHisto.h:13
find
std::string find(const std::string &s)
return a remapped string
Definition
hcg.cxx:140
verbose
bool verbose
Definition
hcg.cxx:75
Root::kINFO
@ kINFO
Definition
TMsgLogger.h:40
Root::BoolOperation
BoolOperation
Definition
TGRLCollection.h:22
Root::AND
@ AND
Definition
TGRLCollection.h:22
Root::OR
@ OR
Definition
TGRLCollection.h:22
std
STL namespace.
Generated on
for ATLAS Offline Software by
1.17.0