ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Trigger
TrigAnalysis
TrigInDetAnalysisUser
Analysis
src
lumiParser.h
Go to the documentation of this file.
1
/* emacs: this is -*- c++ -*- */
10
11
12
#ifndef LUMIPARSER_H
13
#define LUMIPARSER_H
14
15
#include <iostream>
16
#include <fstream>
17
#include <sstream>
18
#include <string>
19
#include <vector>
20
#include <set>
21
#include <cstdlib>
22
#include <cmath>
23
24
#include "
lumiList.h
"
25
#include "
computils.h
"
26
27
28
class
lumiParser
:
public
lumiList
{
29
30
public
:
31
32
lumiParser
() { }
33
34
lumiParser
(
const
std::string&
file
) {
read
(
file
); }
35
36
void
read
(
const
std::string& f ) {
37
39
std::string
file
= f;
40
size_t
pos =
file
.find(
"http"
);
41
if
( pos!=std::string::npos ) {
42
std::string cmd =
"wget "
;
43
cmd +=
file
;
44
tail
(
file
,
"/"
);
45
if
(
exists
(
file
) ) {
48
std::string mvcmd =
"mv "
;
49
mvcmd +=
file
+
" "
+
file
+
".bak"
;
50
std::system( mvcmd.c_str() );
51
}
52
std::system( cmd.c_str() );
53
}
54
55
std::cout <<
"lumiParser file: "
<<
file
<< std::endl;
56
58
std::ifstream input(
file
.c_str() );
59
60
int
run
;
61
std::vector<int>
lbstart
;
62
std::vector<int>
lbend
;
63
65
for
( std::string line; getline( input, line ); ) {
66
67
// std::string s;
68
// std::cout << line << std::endl;
69
70
std::string inputline =
tolower
(line);
71
73
if
( inputline.find(
"run:"
)!=std::string::npos ||
74
inputline.find(
"<run>"
)!=std::string::npos ) {
75
77
80
std::string
label
= line;
81
chop
(
label
,
"Run:"
);
82
chop
(
label
,
"<Run>"
);
83
chomp
(
label
,
"</Run>"
);
84
clean
(
label
,
" "
);
85
86
run
= std::atoi(
label
.c_str());
87
lbstart
.clear();
88
lbend
.clear();
89
90
// std::cout << "\n\n" << line << "\trun: " << label << std::endl;
91
93
for
( std::string fline ; getline( input, fline ) ; ) {
94
if
(
tolower
(fline).
find
(
"from:"
)!=std::string::npos ) {
95
chop
( fline,
"From:"
);
96
clean
( fline,
" "
);
97
std::string start = fline;
98
chomp
( start,
"to"
);
99
chop
( fline,
"to"
);
100
lbstart
.push_back( std::atoi(start.c_str()) );
101
lbend
.push_back( std::atoi(fline.c_str()) );
102
}
103
else
if
(
tolower
(fline).
find
(
"lbrange"
)!=std::string::npos ) {
104
clean
( fline,
"\""
);
105
clean
( fline,
" "
);
106
chop
( fline,
"LBRange"
);
107
chomp
( fline,
"/>"
);
108
chop
( fline,
"Start="
);
109
std::string start = fline;
110
chomp
( start,
"End"
);
111
chop
( fline,
"End="
);
112
lbstart
.push_back( std::atoi(start.c_str()) );
113
lbend
.push_back( std::atoi(fline.c_str()) );
114
}
115
else
break
;
116
}
117
118
for
(
unsigned
il=0 ; il<
lbstart
.size() ; il++ ) this->
addRange
( run,
lbstart
[il],
lbend
[il] );
119
120
}
121
}
122
123
std::cout <<
"lumiParser: read "
<<
size
() <<
" runs"
<< std::endl;
124
}
125
126
virtual
~lumiParser
() { }
127
128
private
:
129
132
133
void
chomp
( std::string& s,
const
std::string& regex ) {
134
size_t
pos = s.find( regex );
135
if
( pos!=std::string::npos ) s.erase( pos, s.size() );
136
}
137
138
void
chop
( std::string& s,
const
std::string& regex ) {
139
size_t
pos = s.find( regex );
140
if
( pos!=std::string::npos ) s.erase( 0, pos+regex.size() );
141
}
142
143
void
tail
( std::string& s,
const
std::string& regex ) {
144
size_t
pos = s.find( regex );
145
while
( pos!=std::string::npos ) {
146
s.erase( 0, pos+regex.size() );
147
pos = s.find( regex );
148
}
149
}
150
151
void
clean
( std::string& s,
const
std::string& regex ) {
152
size_t
pos = s.find( regex );
153
while
( pos!=std::string::npos ) {
154
s.erase( pos, regex.size() );
155
pos = s.find( regex );
156
}
157
}
158
159
std::string
toupper
(
const
std::string& s ) {
160
std::string t = s;
161
for
(
unsigned
i=0 ; i<t.size() ; i++ )
if
( t[i]>=
'a'
&& t[i]<=
'z'
) t[i] +=
'A'
-
'a'
;
162
return
t;
163
}
164
165
166
std::string
tolower
(
const
std::string& s ) {
167
std::string t = s;
168
for
(
unsigned
i=0 ; i<t.size() ; i++ )
if
( t[i]>=
'A'
&& t[i]<=
'Z'
) t[i] -=
'A'
-
'a'
;
169
return
t;
170
}
171
172
173
};
174
175
176
177
inline
std::ostream&
operator<<
( std::ostream& s,
const
lumiParser
& lp ) {
178
// return s << *dynamic_cast<const lumiList*>(&_l);
179
return
s << (
const
lumiList
&)lp;
180
}
181
182
183
#endif
// LUMIPARSER_H
184
185
186
187
188
189
190
191
192
193
size
size_t size() const
Number of registered mappings.
lumiList
Definition
lumiList.h:27
lumiList::lumiList
lumiList(bool b=true)
Definition
lumiList.h:41
lumiList::addRange
void addRange(int run, int start, int stop)
add a lumi block range for a given run
Definition
lumiList.h:48
lumiParser
Definition
lumiParser.h:28
lumiParser::chomp
void chomp(std::string &s, const std::string ®ex)
all these string manipulation routines should all be available from elsewhere
Definition
lumiParser.h:133
lumiParser::~lumiParser
virtual ~lumiParser()
Definition
lumiParser.h:126
lumiParser::tail
void tail(std::string &s, const std::string ®ex)
Definition
lumiParser.h:143
lumiParser::lumiParser
lumiParser(const std::string &file)
Definition
lumiParser.h:34
lumiParser::toupper
std::string toupper(const std::string &s)
Definition
lumiParser.h:159
lumiParser::tolower
std::string tolower(const std::string &s)
Definition
lumiParser.h:166
lumiParser::chop
void chop(std::string &s, const std::string ®ex)
Definition
lumiParser.h:138
lumiParser::clean
void clean(std::string &s, const std::string ®ex)
Definition
lumiParser.h:151
lumiParser::lumiParser
lumiParser()
Definition
lumiParser.h:32
lumiParser::read
void read(const std::string &f)
Definition
lumiParser.h:36
exists
bool exists(const std::string &filename)
does a file exist
Definition
computils.cxx:256
computils.h
find
std::string find(const std::string &s)
return a remapped string
Definition
hcg.cxx:140
lbstart
static std::vector< uint32_t > lbstart
Definition
iLumiCalc.h:38
lbend
static std::vector< uint32_t > lbend
Definition
iLumiCalc.h:39
label
std::string label(const std::string &format, int i)
Definition
label.h:19
lumiList.h
standalone implementation of a good lumi block list
operator<<
std::ostream & operator<<(std::ostream &s, const lumiParser &lp)
Definition
lumiParser.h:177
file
TFile * file
Definition
tile_monitor.h:29
run
int run(int argc, char *argv[])
Definition
ttree2hdf5.cxx:28
Generated on
for ATLAS Offline Software by
1.17.0