CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
LuminosityBlockRange.cc
Go to the documentation of this file.
3 #include <cassert>
4 #include <ostream>
5 //#include <limits>
6 
7 
8 
9 namespace edm {
10 
11 // static unsigned int const shift = 8 * sizeof(unsigned int);
12 //
13 // LuminosityBlockID::LuminosityBlockID(boost::uint64_t id) :
14 // run_(static_cast<RunNumber_t>(id >> shift)),
15 // luminosityBlock_(static_cast<LuminosityBlockNumber_t>(std::numeric_limits<unsigned int>::max() & id))
16 // {
17 // }
18 //
19 // boost::uint64_t
20 // LuminosityBlockID::value() const {
21 // boost::uint64_t id = run_;
22 // id = id << shift;
23 // id += luminosityBlock_;
24 // return id;
25 // }
26 
27 
29  // Special cases since 0 means maximum
30  startLumiID_(0, LuminosityBlockID::maxLuminosityBlockNumber()),
31  endLumiID_(0, LuminosityBlockID::maxLuminosityBlockNumber()){
32  }
33 
35  RunNumber_t endRun, LuminosityBlockNumber_t endLuminosityBlock) :
36  // Special cases since 0 means maximum
37  startLumiID_(startRun, startLuminosityBlock != 0 ? startLuminosityBlock : LuminosityBlockID::maxLuminosityBlockNumber()),
38  endLumiID_(endRun, endLuminosityBlock !=0 ? endLuminosityBlock : LuminosityBlockID::maxLuminosityBlockNumber()) {
39  }
40 
42  startLumiID_(begin),
43  endLumiID_(end) {
44  }
45 
46  std::ostream& operator<<(std::ostream& oStream, LuminosityBlockRange const& r) {
47  oStream << "'" << r.startRun() << ":" << r.startLumi() << "-"
48  << r.endRun() << ":" << r.endLumi() << "'" ;
49  return oStream;
50  }
51 
53  if (rh >= lh.startLumiID() && rh <= lh.endLumiID()) {
54  return true;
55  }
56  return false;
57  }
58 
60  if (contains(lh,rh.startLumiID()) && contains(lh,rh.endLumiID())) {
61  return true;
62  }
63  return false;
64  }
65 
67  return !distinct(lh, rh);
68  }
69 
71  return lh.endLumiID() < rh.startLumiID();
72  }
73 
75  return lessThan(lh, rh) || lessThan(rh, lh);
76  }
77 
79  if (overlaps(lh, rh)) {
82  rh = lh = LuminosityBlockRange(begin, end);
83  return true;
84  }
85  return false;
86  }
87 
88  namespace {
89  bool sortByStartLuminosityBlockID(LuminosityBlockRange const& lh, LuminosityBlockRange const& rh) {
90  assert((lh.startLumi() == 0) == (rh.startLumi() == 0));
91  return lh.startLumiID() < rh.startLumiID();
92  }
93  }
94 
95  std::vector<LuminosityBlockRange>&
96  sortAndRemoveOverlaps(std::vector<LuminosityBlockRange>& lumiRange) {
97  if (lumiRange.size() <= 1U) return lumiRange;
98  sort_all(lumiRange, sortByStartLuminosityBlockID);
99  for (std::vector<LuminosityBlockRange>::iterator i = lumiRange.begin() + 1, e = lumiRange.end();
100  i != e; ++i) {
101  std::vector<LuminosityBlockRange>::iterator iprev = i - 1;
102  if (merge(*iprev, *i)) {
103  i = lumiRange.erase(iprev);
104  e = lumiRange.end();
105  }
106  }
107  return lumiRange;
108  }
109 }
int i
Definition: DBlmapReader.cc:9
bool contains(EventRange const &lh, EventID const &rh)
Definition: EventRange.cc:38
bool int lh
Definition: SSEVec.h:37
unsigned int LuminosityBlockNumber_t
Definition: EventID.h:31
LuminosityBlockNumber_t startLumi() const
bool distinct(EventRange const &lh, EventRange const &rh)
Definition: EventRange.cc:72
EventID const & min(EventID const &lh, EventID const &rh)
Definition: EventID.h:132
#define end
Definition: vmac.h:38
RunNumber_t startRun() const
void sort_all(RandomAccessSequence &s)
wrappers for std::sort
Definition: Algorithms.h:120
bool merge(LuminosityBlockRange &lh, LuminosityBlockRange &rh)
bool overlaps(EventRange const &lh, EventRange const &rh)
Definition: EventRange.cc:54
LuminosityBlockID startLumiID() const
#define begin
Definition: vmac.h:31
LuminosityBlockID endLumiID() const
std::vector< EventRange > & sortAndRemoveOverlaps(std::vector< EventRange > &eventRange)
Definition: EventRange.cc:102
RunNumber_t endRun() const
bool lessThan(EventRange const &lh, EventRange const &rh)
Definition: EventRange.cc:67
unsigned int RunNumber_t
Definition: EventRange.h:32
LuminosityBlockNumber_t endLumi() const
std::ostream & operator<<(std::ostream &ost, const HLTGlobalStatus &hlt)
Formatted printout of trigger tbale.
EventID const & max(EventID const &lh, EventID const &rh)
Definition: EventID.h:137