ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
LumiBlock
LumiCalc
src
iLumiCalc.h
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
LumiCalc/LumiCalculator.h
"
6
#include "
LumiCalc/CoolQuery.h
"
7
#include "
LumiCalc/LumiBlockRangeContainerConverter.h
"
8
#include "
GoodRunsLists/TGoodRunsListReader.h
"
9
#include "
GoodRunsLists/TGoodRunsList.h
"
10
#include "
GoodRunsLists/TGRLCollection.h
"
11
#include "
GoodRunsLists/TMsgLogger.h
"
12
#include "
CxxUtils/checker_macros.h
"
13
14
#include "
cmdline.h
"
15
16
#include <TROOT.h>
17
#include <TStopwatch.h>
18
#include <TString.h>
19
#include <TFile.h>
20
#include <TTree.h>
21
22
#include <iomanip>
23
#include <stdio.h>
24
#include <sys/stat.h>
25
#include <sys/types.h>
26
27
static
std::vector<std::string>
tagfile
;
28
static
std::vector<std::string>
aodfile
;
29
static
std::vector<std::string>
xmlfile
;
30
static
std::vector<std::string>
rootfile
;
31
static
std::string
treename
=
"tree"
;
32
static
std::string
d3pddirname
=
"Lumi"
;
33
static
std::string
xmloutfile
=
"out.xml"
;
34
static
std::vector<std::string>
triggerchain
;
35
static
std::string
livetrigger
;
36
static
Root::TMsgLogger
logger
(
"iLumiCalc"
);
37
static
std::vector<uint32_t>
runnumber
;
38
static
std::vector<uint32_t>
lbstart
;
39
static
std::vector<uint32_t>
lbend
;
40
static
uint32_t
minlbstart
= cool::ValidityKeyMin & 0xFFFFFFFF;
41
static
uint32_t
maxlbend
= (cool::ValidityKeyMax & 0xFFFFFFFF)/2;
42
static
uint32_t
minrunnum
= (cool::ValidityKeyMin >> 32);
43
static
uint32_t
maxrunnum
= (cool::ValidityKeyMax >> 32);
44
45
//______________________________________________________________
46
// Mini progress bar implementation, reduced version of
47
// the one from TMVA/Timer class implementation
48
class
ProgressBar
:
public
TStopwatch {
49
50
public
:
51
ProgressBar
( Int_t, Int_t,
const
char
* prefix =
""
);
52
~ProgressBar
();
53
54
void
Reset
();
55
void
DrawProgressBar
( Int_t );
56
TString
SecToText
( Double_t );
57
Double_t
ElapsedSeconds
();
58
TString
GetElapsedTime
();
59
TString
GetLeftTime
( Int_t );
60
61
Int_t
pbNbins
;
62
Int_t
Ncounts
;
63
TString
Prefix
;
64
65
};
66
67
//_______________________________________________________________________
68
ProgressBar::ProgressBar
(Int_t ncounts, Int_t nbins,
const
char
* prefix)
69
:
pbNbins
(nbins),
Ncounts
(ncounts),
Prefix
(TString(prefix))
70
{
71
Reset
();
72
}
73
74
//_______________________________________________________________________
75
ProgressBar::~ProgressBar
()
76
{}
77
78
//_______________________________________________________________________
79
void
ProgressBar::Reset
()
80
{
81
TStopwatch::Start( kTRUE );
82
}
83
84
//_______________________________________________________________________
85
Double_t
ProgressBar::ElapsedSeconds
()
86
{
87
// computes elapsed time in seconds
88
Double_t rt = TStopwatch::RealTime(); TStopwatch::Start( kFALSE );
89
return
rt;
90
}
91
//_______________________________________________________________________
92
93
TString
ProgressBar::GetElapsedTime
()
94
{
95
// returns string with elapsed time
96
return
SecToText
(
ElapsedSeconds
());
97
}
98
99
//_______________________________________________________________________
100
TString
ProgressBar::GetLeftTime
( Int_t icounts )
101
{
102
// returns pretty string with time left
103
Double_t leftTime = ( icounts <= 0 ? -1 :
104
icounts >
Ncounts
? -1 :
105
Double_t(
Ncounts
- icounts)/Double_t(icounts)*
ElapsedSeconds
() );
106
107
return
SecToText
( leftTime );
108
}
109
110
//_______________________________________________________________________
111
TString
ProgressBar::SecToText
( Double_t seconds )
112
{
113
114
TString out =
""
;
115
if
(seconds < 0 ) out =
"unknown"
;
116
else
if
(seconds <= 300) out = Form(
"%i sec"
, Int_t(seconds) );
117
else
{
118
if
(seconds > 3600) {
119
Int_t
h
= Int_t(seconds/3600);
120
if
(
h
<= 1) out = Form(
"%i hr : "
,
h
);
121
else
out = Form(
"%i hrs : "
,
h
);
122
123
seconds = Int_t(seconds)%3600;
124
}
125
Int_t m = Int_t(seconds/60);
126
if
(m <= 1) out += Form(
"%i min"
, m );
127
else
out += Form(
"%i mins"
, m );
128
}
129
130
return
out;
131
}
132
133
//_______________________________________________________________________
134
void
ProgressBar::DrawProgressBar
( Int_t i )
135
{
136
137
// check for consistency:
138
if
(i >
Ncounts
-1) i =
Ncounts
-1;
139
if
(i < 0 ) i = 0;
140
Int_t ic = Int_t(Float_t(i)/Float_t(
Ncounts
)*
pbNbins
);
141
142
std::clog <<
Prefix
<<
" "
;
143
144
// re-print the actual bar
145
std::clog <<
"["
;
146
for
(Int_t it = 0; it<ic; it++){
147
std::clog <<
">"
;
148
}
149
150
for
(Int_t it = ic+1; it<
pbNbins
; it++){
151
std::clog <<
" "
;
152
}
153
std::clog <<
"]"
;
154
155
// print timing information
156
std::clog <<
"("
<< Int_t((100*(i+1))/Float_t(
Ncounts
)) <<
"%"
157
<<
", "
<<
"time left: "
<< this->
GetLeftTime
( i ) <<
") "
;
158
std::clog <<
"\r"
<< std::flush;
159
}
160
161
162
//______________________________________________________________
163
bool
FileExists
(
const
std::string& strFilename) {
164
struct
stat stFileInfo;
165
bool
blnReturn;
166
int
intStat;
167
168
// Attempt to get the file attributes
169
intStat = stat(strFilename.c_str(),&stFileInfo);
170
if
(intStat == 0) {
171
// We were able to get the file attributes
172
// so the file obviously exists.
173
174
175
blnReturn =
true
;
176
}
else
{
177
// We were not able to get the file attributes.
178
// This may mean that we don't have permission to
179
// access the folder which contains this file. If you
180
// need to do that level of checking, lookup the
181
// return values of stat which will give you
182
// more details on why stat failed.
183
blnReturn =
false
;
184
}
185
186
return
(blnReturn);
187
}
CoolQuery.h
LumiBlockRangeContainerConverter.h
LumiCalculator.h
TGRLCollection.h
TGoodRunsListReader.h
TGoodRunsList.h
TMsgLogger.h
checker_macros.h
Define macros for attributes used to control the static checker.
h
Header file for AthHistogramAlgorithm.
ProgressBar::DrawProgressBar
void DrawProgressBar(Int_t)
Definition
iLumiCalc.h:134
ProgressBar::ElapsedSeconds
Double_t ElapsedSeconds()
Definition
iLumiCalc.h:85
ProgressBar::Ncounts
Int_t Ncounts
Definition
iLumiCalc.h:62
ProgressBar::GetElapsedTime
TString GetElapsedTime()
Definition
iLumiCalc.h:93
ProgressBar::GetLeftTime
TString GetLeftTime(Int_t)
Definition
iLumiCalc.h:100
ProgressBar::pbNbins
Int_t pbNbins
Definition
iLumiCalc.h:61
ProgressBar::~ProgressBar
~ProgressBar()
Definition
iLumiCalc.h:75
ProgressBar::SecToText
TString SecToText(Double_t)
Definition
iLumiCalc.h:111
ProgressBar::Reset
void Reset()
Definition
iLumiCalc.h:79
ProgressBar::ProgressBar
ProgressBar(Int_t, Int_t, const char *prefix="")
Definition
iLumiCalc.h:68
ProgressBar::Prefix
TString Prefix
Definition
iLumiCalc.h:63
Root::TMsgLogger
Definition
TMsgLogger.h:47
cmdline.h
The header file for the command line option parser generated by GNU Gengetopt version 2....
minlbstart
static uint32_t minlbstart
Definition
iLumiCalc.h:40
FileExists
bool FileExists(const std::string &strFilename)
Definition
iLumiCalc.h:163
triggerchain
static std::vector< std::string > triggerchain
Definition
iLumiCalc.h:34
lbstart
static std::vector< uint32_t > lbstart
Definition
iLumiCalc.h:38
runnumber
static std::vector< uint32_t > runnumber
Definition
iLumiCalc.h:37
tagfile
static std::vector< std::string > tagfile
Definition
iLumiCalc.h:27
xmlfile
static std::vector< std::string > xmlfile
Definition
iLumiCalc.h:29
rootfile
static std::vector< std::string > rootfile
Definition
iLumiCalc.h:30
aodfile
static std::vector< std::string > aodfile
Definition
iLumiCalc.h:28
maxrunnum
static uint32_t maxrunnum
Definition
iLumiCalc.h:43
minrunnum
static uint32_t minrunnum
Definition
iLumiCalc.h:42
logger
static Root::TMsgLogger logger("iLumiCalc")
maxlbend
static uint32_t maxlbend
Definition
iLumiCalc.h:41
livetrigger
static std::string livetrigger
Definition
iLumiCalc.h:35
lbend
static std::vector< uint32_t > lbend
Definition
iLumiCalc.h:39
d3pddirname
static std::string d3pddirname
Definition
iLumiCalc.h:32
treename
static std::string treename
Definition
iLumiCalc.h:31
xmloutfile
static std::string xmloutfile
Definition
iLumiCalc.h:33
Generated on
for ATLAS Offline Software by
1.17.0