ATLAS Offline Software
Loading...
Searching...
No Matches
lumiList.h
Go to the documentation of this file.
1/* emacs: this is -*- c++ -*- */
13
14
15#ifndef ANALYSIS_LUMILIST_H
16#define ANALYSIS_LUMILIST_H
17
18#include <iostream>
19#include <map>
20#include <algorithm>
21
22#include "grl_run.h"
23
24
25
26
27class lumiList : public std::map< int, grl_run > {
28
29public:
30
32 typedef std::map< int, grl_run > full_type;
33
35 typedef std::map< int, grl_run >::iterator iterator;
36
37 typedef std::map< int, grl_run >::const_iterator const_iterator;
38
39public:
40
41 lumiList(bool b=true) : m_terse(b) { }
42
43 ~lumiList() { }
44
45 void setterse(bool b) { m_terse=b; }
46
48 void addRange(int run, int start, int stop) {
49
50 iterator it = find(run);
51
52 if ( it == end() ) {
53 std::pair< iterator, bool > in = insert( std::pair<int, grl_run >( run, grl_run( run ) ) );
54 it = in.first;
55 }
56
57 it->second.add_range( start, stop );
58
59 if ( !m_terse ) std::cout << "lumiList::addRange() run " << run << ";\t" << start << " - " << stop << std::endl;
60 }
61
62
63
67 bool inRange( int run, int lb ) {
68
69 iterator itr = find(run);
70
71 if ( itr == end() ) return true;
72 else {
73 grl_run& v = itr->second;
74 for ( unsigned i=0 ; i<v.size() ; i++ ) {
75 if ( lb>=v[i].first && lb<=v[i].second ) return true;
76 }
77 }
78 return false;
79 }
80
81
83 void sort() {
84
85 std::cout << "lumiList::sort() sorting ..." << std::endl;
86
87 std::vector< const grl_run* > vec;
88
89 const_iterator itr = begin();
90
91 while ( itr!=end() ) {
92 vec.push_back( &(itr->second) );
93 ++itr;
94 }
95 if (vec.empty()){
96 return;
97 }
99 std::sort(vec.begin(), vec.end(), grl_run::comparison );
100
102
103 double total = 0;
104 for ( unsigned i=vec.size() ; i-- ; ) total += vec[i]->lbsize();
105
106 if (total == 0){
107 return;
108 }
109 double integral = 0;
110 for ( unsigned i=0 ; i<vec.size() ; i++ ) {
111
112 integral += vec[i]->lbsize();
113
114 std::cout << i
115 << "\t" << int(100*(i+1.0)/vec.size())
116 << "\t" << int(integral/total*1000)*0.1
117 << "\t" << *vec[i] << "\tfraction: " << vec[i]->lbsize()/total << std::endl;
118
119 }
120 }
121
122private:
123
125
126};
127
128
129
130
131
132
133
134
135
136
137
138
139inline std::ostream& operator<<( std::ostream& s, const lumiList& ll ) {
140
141 lumiList::const_iterator itr = ll.begin();
142
143 s << "lumilist: " << ll.size() << " runs" << "\n";
144
145 while ( itr!=ll.end() ) {
146
147 s << "lumiList: run " << itr->first << " range: " << itr->second.first() << "\t- " << itr->second.last() << "\t : size " << itr->second.lbsize() << "\n";
148
149 ++itr;
150 }
151
152 return s;
153}
154
155
156#endif // ANALYSIS_LUMILIST_H
157
158
159
160
161
162
163
164
165
166
std::vector< size_t > vec
static bool comparison(const grl_run *r1, const grl_run *r2)
Definition grl_run.h:55
void setterse(bool b)
Definition lumiList.h:45
std::map< int, grl_run > full_type
full map type
Definition lumiList.h:32
void sort()
sort the runs by the number of good lumi blocks
Definition lumiList.h:83
std::map< int, grl_run >::iterator iterator
iterators over the full map
Definition lumiList.h:35
bool inRange(int run, int lb)
is this run, lumiblock in any of the ranges?
Definition lumiList.h:67
lumiList(bool b=true)
Definition lumiList.h:41
bool m_terse
Definition lumiList.h:124
~lumiList()
Definition lumiList.h:43
void addRange(int run, int start, int stop)
add a lumi block range for a given run
Definition lumiList.h:48
std::map< int, grl_run >::const_iterator const_iterator
Definition lumiList.h:37
double integral(TH1 *h)
Definition computils.cxx:59
int lb
Definition globals.cxx:23
@basic basic run class for the good runs list
std::string find(const std::string &s)
return a remapped string
Definition hcg.cxx:138
std::ostream & operator<<(std::ostream &s, const lumiList &ll)
Definition lumiList.h:139
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
int run(int argc, char *argv[])