ATLAS Offline Software
Loading...
Searching...
No Matches
Root::TGoodRunsList Class Reference

#include <TGoodRunsList.h>

Inheritance diagram for Root::TGoodRunsList:
Collaboration diagram for Root::TGoodRunsList:

Public Member Functions

 TGoodRunsList ()
 TGoodRunsList (const char *name)
virtual ~TGoodRunsList ()
 TGoodRunsList (const TGoodRunsList &)=default
 TGoodRunsList (TGoodRunsList &&)=default
TGoodRunsListoperator= (const TGoodRunsList &)=default
TGoodRunsListoperator= (TGoodRunsList &&)=default
void AddGRL (const TGoodRunsList &other)
const Root::TGoodRunsList GetOverlapWith (const TGoodRunsList &other) const
const Root::TGoodRunsList GetSumWith (const TGoodRunsList &other) const
const Root::TGoodRunsList GetPartOnlyIn (const TGoodRunsList &other) const
const Root::TGoodRunsList GetPartNotIn (const TGoodRunsList &other) const
Bool_t HasTriggerInfo () const
Bool_t HasRun (Int_t runnr) const
Bool_t HasRunLumiBlock (Int_t runnr, Int_t lumiblocknr) const
Bool_t HasSameGRLInfo (const TGoodRunsList &other) const
Bool_t HasOverlapWith (const TGoodRunsList &other, bool verb=false) const
void AddRunLumiBlock (Int_t runnr, Int_t lumiblocknr)
void SetVersion (const TString &version)
void AddMetaData (const TString &key, const TString &value)
void SetMetaData (const std::map< TString, TString > &metadata)
void SetCheckGRLInfo (Bool_t check=kTRUE)
const Bool_t & GetCheckGRLInfo () const
const TString & GetVersion () const
const std::map< TString, TString > & GetMetaData () const
unsigned int GetMetaDataSize () const
void Summary (Bool_t verbose=kFALSE) const
Bool_t IsEmpty () const
std::vector< int > GetRunlist () const
std::vector< Root::TGoodRunGetGoodRuns () const
std::vector< std::string > GetTriggerList () const
std::vector< std::string > GetStreamList () const
TString GetSuggestedName () const
void Compress ()

Public Attributes

keys
 STL member.
elements
 STL member.

Private Attributes

TString m_version
std::map< TString, TString > m_metadata
bool m_checkGRLInfo {false}

Detailed Description

Definition at line 26 of file TGoodRunsList.h.

Constructor & Destructor Documentation

◆ TGoodRunsList() [1/4]

Root::TGoodRunsList::TGoodRunsList ( )

◆ TGoodRunsList() [2/4]

Root::TGoodRunsList::TGoodRunsList ( const char * name)

Definition at line 20 of file TGoodRunsList.cxx.

21 : std::map<Int_t,TGoodRun>()
22 , TNamed(name,"notitle")
23{
24}

◆ ~TGoodRunsList()

Root::TGoodRunsList::~TGoodRunsList ( )
virtual

Definition at line 27 of file TGoodRunsList.cxx.

28{
29}

◆ TGoodRunsList() [3/4]

Root::TGoodRunsList::TGoodRunsList ( const TGoodRunsList & )
default

◆ TGoodRunsList() [4/4]

Root::TGoodRunsList::TGoodRunsList ( TGoodRunsList && )
default

Member Function Documentation

◆ AddGRL()

void Root::TGoodRunsList::AddGRL ( const TGoodRunsList & other)

Definition at line 32 of file TGoodRunsList.cxx.

33{
34 // ensure version and name are identical
35 Bool_t same = this->HasSameGRLInfo(other);
36 if (m_checkGRLInfo || other.GetCheckGRLInfo()) {
37 if (!same) {
38 TMsgLogger m_logger("TGoodRunsList");
39 m_logger << kWARNING << "Incompatible NamedLumiRanges: " << GEndl;
40 this->Summary(kFALSE);
41 other.Summary(kFALSE);
42 m_logger << kWARNING << "Not adding GoodRunsList." << GEndl;
43 return;
44 }
45 }
46
47 // merge metadata
48 for (const auto& othermditem : other.GetMetaData()) {
49 auto thismditem = m_metadata.find(othermditem.first);
50 if (thismditem == m_metadata.end()) {
51 m_metadata.insert(othermditem);
52 } else {
53 auto& nameStr = othermditem.first;
54 auto& thisvaluestr = thismditem->second;
55 if (thisvaluestr != othermditem.second) {
56 if (nameStr == "RunList") {
57 thisvaluestr += ",";
58 } else {
59 thisvaluestr += " | ";
60 }
61 thisvaluestr += othermditem.second;
62 }
63 }
64 }
65
66 const TGoodRunsList& diffgrl = this->GetPartOnlyIn(other);
67
68 std::map<Int_t,Root::TGoodRun>::const_iterator itr;
69 // Store diffgrl goodrunslist
70 for (itr = diffgrl.begin(); itr!=diffgrl.end(); ++itr) {
71 if (this->find(itr->first)!=this->end()) { // overlapping runnumbers
72 Root::TGoodRun grun = itr->second.GetSumWith( this->find(itr->first)->second ) ;
73 if (!grun.IsEmpty()) (*this)[itr->first] = grun;
74 } else if (!itr->second.IsEmpty()) { // store rest directly
75 (*this)[itr->first] = itr->second;
76 }
77 }
78
79 return;
80}
#define GEndl
Definition TMsgLogger.h:147
Bool_t IsEmpty() const
Definition TGoodRun.cxx:249
void Summary(Bool_t verbose=kFALSE) const
Bool_t HasSameGRLInfo(const TGoodRunsList &other) const
const Root::TGoodRunsList GetPartOnlyIn(const TGoodRunsList &other) const
std::map< TString, TString > m_metadata
std::string find(const std::string &s)
return a remapped string
Definition hcg.cxx:138
@ kWARNING
Definition TMsgLogger.h:41

◆ AddMetaData()

void Root::TGoodRunsList::AddMetaData ( const TString & key,
const TString & value )
inline

Definition at line 53 of file TGoodRunsList.h.

◆ AddRunLumiBlock()

void Root::TGoodRunsList::AddRunLumiBlock ( Int_t runnr,
Int_t lumiblocknr )

Definition at line 413 of file TGoodRunsList.cxx.

414{
415 if (runnr<0 || lumiblocknr<0) return;
416 if (this->HasRunLumiBlock(runnr,lumiblocknr)) return;
417
418 std::map< Int_t, TGoodRun >::iterator itr = this->find(runnr);
419 if (itr==this->end()) {
420 this->insert( std::pair< Int_t, TGoodRun >(runnr,Root::TGoodRun(runnr)) );
421 itr = this->find(runnr);
422 }
423
424 itr->second.AddLB(lumiblocknr);
425}
Bool_t HasRunLumiBlock(Int_t runnr, Int_t lumiblocknr) const

◆ Compress()

void Root::TGoodRunsList::Compress ( )

Definition at line 429 of file TGoodRunsList.cxx.

430{
431 for (auto& [runno, run] : *this) run.Compress();
432}

◆ GetCheckGRLInfo()

const Bool_t & Root::TGoodRunsList::GetCheckGRLInfo ( ) const
inline

Definition at line 57 of file TGoodRunsList.h.

57{ return m_checkGRLInfo; }

◆ GetGoodRuns()

std::vector< Root::TGoodRun > Root::TGoodRunsList::GetGoodRuns ( ) const

Definition at line 287 of file TGoodRunsList.cxx.

288{
289 std::vector<Root::TGoodRun> runlist;
290 for (const auto& [runno, run] : *this) runlist.push_back(run);
291
292 return runlist;
293}

◆ GetMetaData()

const std::map< TString, TString > & Root::TGoodRunsList::GetMetaData ( ) const
inline

Definition at line 59 of file TGoodRunsList.h.

59{ return m_metadata; }

◆ GetMetaDataSize()

unsigned int Root::TGoodRunsList::GetMetaDataSize ( ) const
inline

Definition at line 60 of file TGoodRunsList.h.

60{ return m_metadata.size(); }

◆ GetOverlapWith()

const Root::TGoodRunsList Root::TGoodRunsList::GetOverlapWith ( const TGoodRunsList & other) const

Definition at line 83 of file TGoodRunsList.cxx.

84{
85 Root::TGoodRunsList overlapgrl;
86 overlapgrl.SetName("Overlap of GRLs");
87
88 // ensure version and metadata are identical
89 Bool_t same = this->HasSameGRLInfo(other);
90 if (m_checkGRLInfo || other.GetCheckGRLInfo()) {
91 if (!same) {
92 TMsgLogger m_logger("TGoodRunsList");
93 m_logger << kWARNING << "Incompatible NamedLumiRanges: " << GEndl;
94 this->Summary(kFALSE);
95 other.Summary(kFALSE);
96 m_logger << kWARNING << "Returning empty GoodRunsList." << GEndl;
97 return overlapgrl;
98 }
99 }
100 if (same) {
101 overlapgrl.SetName(this->GetName());
102 overlapgrl.SetVersion(this->GetVersion());
103 overlapgrl.SetMetaData(this->GetMetaData());
104 }
105
106 // Store goodruns
107 std::map<Int_t,Root::TGoodRun>::const_iterator itr = this->begin();
108 for (; itr!=this->end(); ++itr) {
109 if (other.find(itr->first)!=other.end()) { // check runnumbers
110 Root::TGoodRun grun = itr->second.GetOverlapWith( other.find(itr->first)->second ) ;
111 if (!grun.IsEmpty()) {
112 grun.Sort(); // sort lumiblock ranges before storage
113 overlapgrl[itr->first] = grun;
114 }
115 }
116 }
117
118 return overlapgrl;
119}
void SetVersion(const TString &version)
const TString & GetVersion() const
void SetMetaData(const std::map< TString, TString > &metadata)
const std::map< TString, TString > & GetMetaData() const

◆ GetPartNotIn()

const Root::TGoodRunsList Root::TGoodRunsList::GetPartNotIn ( const TGoodRunsList & other) const

Definition at line 175 of file TGoodRunsList.cxx.

176{
177 Root::TGoodRunsList notinother;
178 notinother.SetName("Difference of GRLs");
179
180 // ensure version and metadata are identical
181 Bool_t same = this->HasSameGRLInfo(other);
182 if (m_checkGRLInfo || other.GetCheckGRLInfo()) {
183 if (!same) {
184 TMsgLogger m_logger("TGoodRunsList");
185 m_logger << kWARNING << "Incompatible NamedLumiRanges: " << GEndl;
186 this->Summary(kFALSE);
187 other.Summary(kFALSE);
188 m_logger << kWARNING << "Returning empty GoodRunsList." << GEndl;
189 return notinother;
190 }
191 }
192 if (same) {
193 notinother.SetName(this->GetName());
194 notinother.SetVersion(this->GetVersion());
195 notinother.SetMetaData(this->GetMetaData());
196 }
197
198 std::map<Int_t,Root::TGoodRun>::const_iterator itr;
199 // How to store this goodrun ?
200 for (itr = this->begin(); itr!=this->end(); ++itr) {
201 if (other.find(itr->first)!=other.end()) { // check runnumbers
202 Root::TGoodRun notinrun = itr->second.GetPartNotIn( other.find(itr->first)->second ) ;
203 if (!notinrun.IsEmpty()) notinother[itr->first] = notinrun;
204 } else if (!itr->second.IsEmpty()) { // store difference
205 notinother[itr->first] = itr->second;
206 }
207 }
208
209 return notinother;
210}

◆ GetPartOnlyIn()

const Root::TGoodRunsList Root::TGoodRunsList::GetPartOnlyIn ( const TGoodRunsList & other) const

Definition at line 168 of file TGoodRunsList.cxx.

169{
170 return other.GetPartNotIn(*this);
171}

◆ GetRunlist()

std::vector< int > Root::TGoodRunsList::GetRunlist ( ) const

Definition at line 277 of file TGoodRunsList.cxx.

278{
279 std::vector<int> runlist;
280 for (const auto& [runno, run] : *this) runlist.push_back(runno);
281
282 return runlist;
283}

◆ GetStreamList()

std::vector< std::string > Root::TGoodRunsList::GetStreamList ( ) const

Definition at line 311 of file TGoodRunsList.cxx.

312{
313 std::vector<std::string> streamlist;
314
315 for (const auto& [key, value] : m_metadata) {
316 TString streamname = key;
317 streamname.ToLower();
318 if (streamname.BeginsWith("stream") && value.Length()>0) streamlist.push_back(value.Data());
319 }
320 return streamlist;
321}

◆ GetSuggestedName()

TString Root::TGoodRunsList::GetSuggestedName ( ) const

Definition at line 390 of file TGoodRunsList.cxx.

391{
392 if (this->IsEmpty()) return "grl_empty";
393
394 Int_t beginrun(-1), endrun(-1), beginlb(-1), endlb(-1);
395
396 Root::TGoodRun begingr = this->begin()->second;
397 Root::TGoodRun endgr = this->rbegin()->second;
398
399 if (!begingr.IsEmpty()) {
400 beginrun = begingr.GetRunNumber();
401 beginlb = begingr.begin()->Begin();
402 }
403 if (!endgr.IsEmpty()) {
404 endrun = endgr.GetRunNumber();
405 endlb = endgr.rbegin()->End();
406 }
407
408 return Form("grl_%d.%d-%d.%d",beginrun,beginlb,endrun,endlb);
409}
Int_t GetRunNumber() const
Definition TGoodRun.h:42
Bool_t IsEmpty() const

◆ GetSumWith()

const Root::TGoodRunsList Root::TGoodRunsList::GetSumWith ( const TGoodRunsList & other) const

Definition at line 123 of file TGoodRunsList.cxx.

124{
125 Root::TGoodRunsList sumgrl;
126 sumgrl.SetName("Sum of GRLs"/*this->GetName()*/);
127
128 // ensure version and metadata are identical
129 Bool_t same = this->HasSameGRLInfo(other);
130 if (m_checkGRLInfo || other.GetCheckGRLInfo()) {
131 if (!same) {
132 TMsgLogger m_logger("TGoodRunsList");
133 m_logger << kWARNING << "Incompatible NamedLumiRanges: " << GEndl;
134 this->Summary(kFALSE);
135 other.Summary(kFALSE);
136 m_logger << kWARNING << "Returning empty GoodRunsList." << GEndl;
137 return sumgrl;
138 }
139 }
140 if (same) {
141 sumgrl.SetName(this->GetName());
142 sumgrl.SetVersion(this->GetVersion());
143 sumgrl.SetMetaData(this->GetMetaData());
144 }
145
146 std::map<Int_t,Root::TGoodRun>::const_iterator itr;
147 // Store this goodruns
148 for (itr = this->begin(); itr!=this->end(); ++itr) {
149 if (other.find(itr->first)!=other.end()) { // check runnumbers
150 Root::TGoodRun grun = itr->second.GetSumWith( other.find(itr->first)->second ) ;
151 if (!grun.IsEmpty()) sumgrl[itr->first] = grun;
152 } else if (!itr->second.IsEmpty()) { // store difference
153 sumgrl[itr->first] = itr->second;
154 }
155 }
156 // Store remaining other goodruns
157 for (itr = other.begin(); itr!=other.end(); ++itr) {
158 if (sumgrl.find(itr->first)==sumgrl.end() && !itr->second.IsEmpty()) { // check for remaining runnumbers
159 sumgrl[itr->first] = itr->second;
160 }
161 }
162
163 return sumgrl;
164}

◆ GetTriggerList()

std::vector< std::string > Root::TGoodRunsList::GetTriggerList ( ) const

Definition at line 297 of file TGoodRunsList.cxx.

298{
299 std::vector<std::string> triggerchains;
300
301 for (const auto& [key, value] : m_metadata) {
302 TString triggername = key;
303 triggername.ToLower();
304 if (triggername.BeginsWith("trigger") && value.Length()>0) triggerchains.push_back(value.Data());
305 }
306 return triggerchains;
307}

◆ GetVersion()

const TString & Root::TGoodRunsList::GetVersion ( ) const
inline

Definition at line 58 of file TGoodRunsList.h.

58{ return m_version; }

◆ HasOverlapWith()

Bool_t Root::TGoodRunsList::HasOverlapWith ( const TGoodRunsList & other,
bool verb = false ) const

Definition at line 242 of file TGoodRunsList.cxx.

243{
244 const Root::TGoodRunsList overlapgrl = this->GetOverlapWith(other);
245 bool isEmpty = overlapgrl.IsEmpty();
246 if (!isEmpty && verb) overlapgrl.Summary(true);
247
248 return !isEmpty;
249}
#define verb
const Root::TGoodRunsList GetOverlapWith(const TGoodRunsList &other) const

◆ HasRun()

Bool_t Root::TGoodRunsList::HasRun ( Int_t runnr) const

Definition at line 214 of file TGoodRunsList.cxx.

215{
216 return ( this->find(runnr)!=this->end() );
217}

◆ HasRunLumiBlock()

Bool_t Root::TGoodRunsList::HasRunLumiBlock ( Int_t runnr,
Int_t lumiblocknr ) const

Definition at line 221 of file TGoodRunsList.cxx.

222{
223 const auto run = this->find(runnr);
224 return ( run!=this->end() && run->second.HasLB( lumiblocknr ) );
225}

◆ HasSameGRLInfo()

Bool_t Root::TGoodRunsList::HasSameGRLInfo ( const TGoodRunsList & other) const

check names

check versions

check RQ version <Metadata Name="RQTSVNVersion">CoolRunQuery-unknown</Metadata>

Definition at line 325 of file TGoodRunsList.cxx.

326{
327 TMsgLogger m_logger("TGoodRunsList");
328 Bool_t same(kTRUE);
329
331 same = same && (TString(this->GetName())==TString(other.GetName())) ;
332 if (!same) {
333 m_logger << kDEBUG << "Incompatible names: <" << this->GetName() << "> <" << other.GetName() << ">" << GEndl;
334 return kFALSE;
335 }
337 same = same && (this->GetVersion()==other.GetVersion()) ;
338 if (!same) {
339 m_logger << kDEBUG << "Incompatible versions: <" << this->GetVersion() << "> <" << other.GetVersion() << ">" << GEndl;
340 return kFALSE;
341 }
344 std::map<TString,TString>::const_iterator mitr = this->GetMetaData().find("RQTSVNVersion");
345 std::map<TString,TString>::const_iterator oitr = other.GetMetaData().find("RQTSVNVersion");
346 if ( mitr==this->GetMetaData().end() && oitr==other.GetMetaData().end() ) {
347 ; // ok, RQ version missing from both grls
348 } else if ( mitr!=this->GetMetaData().end() && oitr!=other.GetMetaData().end() ) {
349 same = same && ( mitr->second==oitr->second );
350 if (!same) { m_logger << kDEBUG << "Incompatible run query versions: " << mitr->first
351 << " : <" << mitr->second << "> <" << oitr->second << ">" << GEndl; }
352 } else { same=kFALSE; } // version is missing from one grl
353
354/*
356 same = same && (this->GetMetaData().size()==other.GetMetaData().size()) ;
357 if (!same) {
358 m_logger << kDEBUG << "Incompatible metadata sizes: <" << this->GetMetaData().size() << "> <" << other.GetMetaData().size() << ">" << GEndl;
359 return kFALSE;
360 }
362 std::map<TString,TString>::const_iterator mitr = this->GetMetaData().begin();
363 for(; mitr!=this->GetMetaData().end() && same; ++mitr) {
364 if (other.GetMetaData().find(mitr->first)!=other.GetMetaData().end()) {
365 same = same && ( mitr->second==(other.GetMetaData().find(mitr->first))->second );
366 if (!same) { m_logger << kDEBUG << "Incompatible metadata: " << mitr->first
367 << " : <" << mitr->second << "> <" << (other.GetMetaData().find(mitr->first))->second << ">" << GEndl; }
368 } else same=kFALSE;
369 }
370*/
371 return same;
372}
@ kDEBUG
Definition TMsgLogger.h:39

◆ HasTriggerInfo()

Bool_t Root::TGoodRunsList::HasTriggerInfo ( ) const

Definition at line 229 of file TGoodRunsList.cxx.

230{
231 std::map<TString,TString>::const_iterator itr = m_metadata.begin();
232 for (; itr!=m_metadata.end(); ++itr) {
233 TString triggername = itr->first;
234 triggername.ToLower();
235 if (triggername.BeginsWith("trigger") && itr->second.Length()>0) return kTRUE;
236 }
237 return kFALSE;
238}

◆ IsEmpty()

Bool_t Root::TGoodRunsList::IsEmpty ( ) const

Definition at line 376 of file TGoodRunsList.cxx.

377{
378 if (this->empty()) return kTRUE;
379
380 Bool_t isEmpty(kTRUE);
381 std::map< Int_t, TGoodRun >::const_iterator litr = this->begin();
382 for (; litr!=this->end() && isEmpty; ++litr)
383 isEmpty = isEmpty && litr->second.IsEmpty();
384
385 return isEmpty;
386}
static const Attributes_t empty

◆ operator=() [1/2]

TGoodRunsList & Root::TGoodRunsList::operator= ( const TGoodRunsList & )
default

◆ operator=() [2/2]

TGoodRunsList & Root::TGoodRunsList::operator= ( TGoodRunsList && )
default

◆ SetCheckGRLInfo()

void Root::TGoodRunsList::SetCheckGRLInfo ( Bool_t check = kTRUE)
inline

Definition at line 55 of file TGoodRunsList.h.

◆ SetMetaData()

void Root::TGoodRunsList::SetMetaData ( const std::map< TString, TString > & metadata)
inline

Definition at line 54 of file TGoodRunsList.h.

◆ SetVersion()

void Root::TGoodRunsList::SetVersion ( const TString & version)
inline

Definition at line 52 of file TGoodRunsList.h.

◆ Summary()

void Root::TGoodRunsList::Summary ( Bool_t verbose = kFALSE) const

Definition at line 253 of file TGoodRunsList.cxx.

254{
255 // TNamed print
256 Print();
257
258 TMsgLogger m_logger("TGoodRunsList");
259 // Versioning and metadata info
260 m_logger << kINFO << "Version: " << m_version << GEndl;
261 std::map<TString,TString>::const_iterator titr = m_metadata.begin();
262 for (titr = m_metadata.begin(); titr!=m_metadata.end(); ++titr)
263 m_logger << kINFO << "Metadata: " << (titr->first) << " : " << (titr->second) << GEndl;
264
265 m_logger << kINFO << "Number of runs: " << this->size() << GEndl;
266
267 // Info about runs
268 if (verbose) {
269 std::map<Int_t,Root::TGoodRun>::const_iterator itr = this->begin();
270 std::map<Int_t,Root::TGoodRun>::const_iterator end = this->end();
271 for (; itr!=end; ++itr) itr->second.Summary();
272 }
273}
bool verbose
Definition hcg.cxx:73
@ kINFO
Definition TMsgLogger.h:40
void Print(const PParameter *param, TDirectory *topdir, Option_t *opt="")

Member Data Documentation

◆ elements

T std::map< K, T >::elements
inherited

STL member.

◆ keys

K std::map< K, T >::keys
inherited

STL member.

◆ m_checkGRLInfo

bool Root::TGoodRunsList::m_checkGRLInfo {false}
private

Definition at line 77 of file TGoodRunsList.h.

77{false};

◆ m_metadata

std::map<TString,TString> Root::TGoodRunsList::m_metadata
private

Definition at line 76 of file TGoodRunsList.h.

◆ m_version

TString Root::TGoodRunsList::m_version
private

Definition at line 75 of file TGoodRunsList.h.


The documentation for this class was generated from the following files: