36 void read(
const std::string& f ) {
40 size_t pos =
file.find(
"http");
41 if ( pos!=std::string::npos ) {
42 std::string cmd =
"wget ";
48 std::string mvcmd =
"mv ";
50 std::system( mvcmd.c_str() );
52 std::system( cmd.c_str() );
55 std::cout <<
"lumiParser file: " <<
file << std::endl;
58 std::ifstream input(
file.c_str() );
62 std::vector<int>
lbend;
65 for( std::string line; getline( input, line ); ) {
70 std::string inputline =
tolower(line);
73 if ( inputline.find(
"run:")!=std::string::npos ||
74 inputline.find(
"<run>")!=std::string::npos ) {
80 std::string
label = line;
93 for( std::string fline ; getline( input, fline ) ; ) {
94 if (
tolower(fline).
find(
"from:")!=std::string::npos ) {
95 chop( fline,
"From:" );
97 std::string start = fline;
100 lbstart.push_back( std::atoi(start.c_str()) );
101 lbend.push_back( std::atoi(fline.c_str()) );
103 else if (
tolower(fline).
find(
"lbrange")!=std::string::npos ) {
104 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()) );
123 std::cout <<
"lumiParser: read " << size() <<
" runs" << std::endl;
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() );
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() );
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 );
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 );
161 for (
unsigned i=0 ; i<t.size() ; i++ )
if ( t[i]>=
'a' && t[i]<=
'z' ) t[i] +=
'A'-
'a';
168 for (
unsigned i=0 ; i<t.size() ; i++ )
if ( t[i]>=
'A' && t[i]<=
'Z' ) t[i] -=
'A'-
'a';
void addRange(int run, int start, int stop)
add a lumi block range for a given run
void chomp(std::string &s, const std::string ®ex)
all these string manipulation routines should all be available from elsewhere
void tail(std::string &s, const std::string ®ex)
lumiParser(const std::string &file)
std::string toupper(const std::string &s)
std::string tolower(const std::string &s)
void chop(std::string &s, const std::string ®ex)
void clean(std::string &s, const std::string ®ex)
void read(const std::string &f)
bool exists(const std::string &filename)
does a file exist
std::string find(const std::string &s)
return a remapped string
static std::vector< uint32_t > lbstart
static std::vector< uint32_t > lbend
std::string label(const std::string &format, int i)
standalone implementation of a good lumi block list
std::ostream & operator<<(std::ostream &s, const lumiParser &lp)