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