CMS 3D CMS Logo

LuminosityBlockRange.cc
Go to the documentation of this file.
3 #include <cassert>
4 #include <ostream>
5 //#include <limits>
6 
7 namespace edm {
8 
9  // static unsigned int const shift = 8 * sizeof(unsigned int);
10  //
11  // LuminosityBlockID::LuminosityBlockID(uint64_t id) :
12  // run_(static_cast<RunNumber_t>(id >> shift)),
13  // luminosityBlock_(static_cast<LuminosityBlockNumber_t>(std::numeric_limits<unsigned int>::max() & id))
14  // {
15  // }
16  //
17  // uint64_t
18  // LuminosityBlockID::value() const {
19  // uint64_t id = run_;
20  // id = id << shift;
21  // id += luminosityBlock_;
22  // return id;
23  // }
24 
26  : // Special cases since 0 means maximum
27  startLumiID_(0, LuminosityBlockID::maxLuminosityBlockNumber()),
28  endLumiID_(0, LuminosityBlockID::maxLuminosityBlockNumber()) {}
29 
31  LuminosityBlockNumber_t startLuminosityBlock,
33  LuminosityBlockNumber_t endLuminosityBlock)
34  : // Special cases since 0 means maximum
35  startLumiID_(startRun,
36  startLuminosityBlock != 0 ? startLuminosityBlock : LuminosityBlockID::maxLuminosityBlockNumber()),
37  endLumiID_(endRun,
38  endLuminosityBlock != 0 ? endLuminosityBlock : LuminosityBlockID::maxLuminosityBlockNumber()) {}
39 
41  : startLumiID_(begin), endLumiID_(end) {}
42 
43  std::ostream& operator<<(std::ostream& oStream, LuminosityBlockRange const& r) {
44  oStream << "'" << r.startRun() << ":" << r.startLumi() << "-" << r.endRun() << ":" << r.endLumi() << "'";
45  return oStream;
46  }
47 
49  if (rh >= lh.startLumiID() && rh <= lh.endLumiID()) {
50  return true;
51  }
52  return false;
53  }
54 
56  if (contains(lh, rh.startLumiID()) && contains(lh, rh.endLumiID())) {
57  return true;
58  }
59  return false;
60  }
61 
62  bool overlaps(LuminosityBlockRange const& lh, LuminosityBlockRange const& rh) { return !distinct(lh, rh); }
63 
65  return lh.endLumiID() < rh.startLumiID();
66  }
67 
69  return lessThan(lh, rh) || lessThan(rh, lh);
70  }
71 
73  if (overlaps(lh, rh)) {
74  LuminosityBlockID begin = min(lh.startLumiID(), rh.startLumiID());
75  LuminosityBlockID end = max(lh.endLumiID(), rh.endLumiID());
76  rh = lh = LuminosityBlockRange(begin, end);
77  return true;
78  }
79  return false;
80  }
81 
82  namespace {
83  bool sortByStartLuminosityBlockID(LuminosityBlockRange const& lh, LuminosityBlockRange const& rh) {
84  assert((lh.startLumi() == 0) == (rh.startLumi() == 0));
85  return lh.startLumiID() < rh.startLumiID();
86  }
87  } // namespace
88 
89  std::vector<LuminosityBlockRange>& sortAndRemoveOverlaps(std::vector<LuminosityBlockRange>& lumiRange) {
90  if (lumiRange.size() <= 1U)
91  return lumiRange;
92  sort_all(lumiRange, sortByStartLuminosityBlockID);
93  for (std::vector<LuminosityBlockRange>::iterator i = lumiRange.begin() + 1, e = lumiRange.end(); i != e; ++i) {
94  std::vector<LuminosityBlockRange>::iterator iprev = i - 1;
95  if (merge(*iprev, *i)) {
96  i = lumiRange.erase(iprev);
97  e = lumiRange.end();
98  }
99  }
100  return lumiRange;
101  }
102 } // namespace edm
bool contains(EventRange const &lh, EventID const &rh)
Definition: EventRange.cc:37
bool int lh
Definition: SIMDVec.h:20
assert(be >=bs)
unsigned int LuminosityBlockNumber_t
bool distinct(EventRange const &lh, EventRange const &rh)
Definition: EventRange.cc:69
LuminosityBlockID endLumiID() const
EventID const & min(EventID const &lh, EventID const &rh)
Definition: EventID.h:116
void sort_all(RandomAccessSequence &s)
wrappers for std::sort
Definition: Algorithms.h:92
bool merge(LuminosityBlockRange &lh, LuminosityBlockRange &rh)
bool overlaps(EventRange const &lh, EventRange const &rh)
Definition: EventRange.cc:51
HLT enums.
std::vector< EventRange > & sortAndRemoveOverlaps(std::vector< EventRange > &eventRange)
Definition: EventRange.cc:98
bool lessThan(EventRange const &lh, EventRange const &rh)
Definition: EventRange.cc:64
string lumiRange
unsigned int RunNumber_t
LuminosityBlockID startLumiID() 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:118