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
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
118private:
119
121
122};
123
124
125
126
127
128
129
130
131
132
133
134
135inline 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
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:120
~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:135
Definition run.py:1
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.