ATLAS Offline Software
lumiList.h
Go to the documentation of this file.
1 /* emacs: this is -*- c++ -*- */
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 
27 class lumiList : public std::map< int, grl_run > {
28 
29 public:
30 
32  typedef std::map< int, grl_run > full_type;
33 
36 
37  typedef std::map< int, grl_run >::const_iterator const_iterator;
38 
39 public:
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 
97  std::sort(vec.begin(), vec.end(), grl_run::comparison );
98 
100 
101  double total = 0;
102  for ( unsigned i=vec.size() ; i-- ; ) total += vec[i]->lbsize();
103 
104 
105  double integral = 0;
106  for ( unsigned i=0 ; i<vec.size() ; i++ ) {
107 
108  integral += vec[i]->lbsize();
109 
110  std::cout << i
111  << "\t" << int(100*(i+1.0)/vec.size())
112  << "\t" << int(integral/total*1000)*0.1
113  << "\t" << *vec[i] << "\tfraction: " << vec[i]->lbsize()/total << std::endl;
114 
115  }
116  }
117 
118 private:
119 
120  bool m_terse;
121 
122 };
123 
124 
125 
126 
127 
128 
129 
130 
131 
132 
133 
134 
135 inline std::ostream& operator<<( std::ostream& s, const lumiList& ll ) {
136 
137  lumiList::const_iterator itr = ll.begin();
138 
139  s << "lumilist: " << ll.size() << " runs" << "\n";
140 
141  while ( itr!=ll.end() ) {
142 
143  s << "lumiList: run " << itr->first << " range: " << itr->second.first() << "\t- " << itr->second.last() << "\t : size " << itr->second.lbsize() << "\n";
144 
145  ++itr;
146  }
147 
148  return s;
149 }
150 
151 
152 #endif // ANALYSIS_LUMILIST_H
153 
154 
155 
156 
157 
158 
159 
160 
161 
162 
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
python.SystemOfUnits.second
int second
Definition: SystemOfUnits.py:120
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
detail::ll
long long ll
Definition: PrimitiveHelpers.h:46
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
integral
double integral(TH1 *h)
Definition: computils.cxx:57
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
lumiList::full_type
std::map< int, grl_run > full_type
full map type
Definition: lumiList.h:32
lumiList::const_iterator
std::map< int, grl_run >::const_iterator const_iterator
Definition: lumiList.h:37
lumiList::~lumiList
~lumiList()
Definition: lumiList.h:43
mergePhysValFiles.start
start
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:14
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
skel.it
it
Definition: skel.GENtoEVGEN.py:396
vec
std::vector< size_t > vec
Definition: CombinationsGeneratorTest.cxx:12
PixelModuleFeMask_create_db.stop
int stop
Definition: PixelModuleFeMask_create_db.py:76
lumiList::addRange
void addRange(int run, int start, int stop)
add a lumi block range for a given run
Definition: lumiList.h:48
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
lumiList::lumiList
lumiList(bool b=true)
Definition: lumiList.h:41
CxxUtils::vec
typename vecDetail::vec_typedef< T, N >::type vec
Define a nice alias for the vectorized type.
Definition: vec.h:207
lumiList::setterse
void setterse(bool b)
Definition: lumiList.h:45
python.BunchSpacingUtils.lb
lb
Definition: BunchSpacingUtils.py:88
lumiFormat.i
int i
Definition: lumiFormat.py:85
grl_run::comparison
static bool comparison(const grl_run *r1, const grl_run *r2)
Definition: grl_run.h:55
run
Definition: run.py:1
lumiList::iterator
std::map< int, grl_run >::iterator iterator
iterators over the full map
Definition: lumiList.h:35
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
lumiList::inRange
bool inRange(int run, int lb)
is this run, lumiblock in any of the ranges? if the run is not in the list, it is assumed that all ev...
Definition: lumiList.h:67
lumiList::m_terse
bool m_terse
Definition: lumiList.h:120
python.PyAthena.v
v
Definition: PyAthena.py:154
grl_run.h
DeMoScan.first
bool first
Definition: DeMoScan.py:536
lumiList::sort
void sort()
sort the runs by the number of good lumi blocks
Definition: lumiList.h:83
operator<<
std::ostream & operator<<(std::ostream &s, const lumiList &ll)
Definition: lumiList.h:135
grl_run
Definition: grl_run.h:26
lumiList
Definition: lumiList.h:27