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
Ecal2004TBTDCRanges_v1_cff.endRun
endRun
Definition: Ecal2004TBTDCRanges_v1_cff.py:4
edm::RunNumber_t
unsigned int RunNumber_t
Definition: RunLumiEventNumber.h:14
mps_fire.i
i
Definition: mps_fire.py:428
edm::sort_all
void sort_all(RandomAccessSequence &s)
wrappers for std::sort
Definition: Algorithms.h:92
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::max
EventID const & max(EventID const &lh, EventID const &rh)
Definition: EventID.h:118
edm::min
EventID const & min(EventID const &lh, EventID const &rh)
Definition: EventID.h:116
Algorithms.h
cms::cuda::assert
assert(be >=bs)
edm::sortAndRemoveOverlaps
std::vector< EventRange > & sortAndRemoveOverlaps(std::vector< EventRange > &eventRange)
Definition: EventRange.cc:98
mathSSE::lh
bool int lh
Definition: SIMDVec.h:20
edm::LuminosityBlockNumber_t
unsigned int LuminosityBlockNumber_t
Definition: RunLumiEventNumber.h:13
edm::operator<<
std::ostream & operator<<(std::ostream &ost, const HLTGlobalStatus &hlt)
Formatted printout of trigger tbale.
Definition: HLTGlobalStatus.h:106
edm::distinct
bool distinct(EventRange const &lh, EventRange const &rh)
Definition: EventRange.cc:69
edm::LuminosityBlockRange::startLumiID
LuminosityBlockID startLumiID() const
Definition: LuminosityBlockRange.h:46
mps_fire.end
end
Definition: mps_fire.py:242
edm::LuminosityBlockID
Definition: LuminosityBlockID.h:31
mitigatedMETSequence_cff.U
U
Definition: mitigatedMETSequence_cff.py:36
Ecal2004TBTDCRanges_v1_cff.startRun
startRun
Definition: Ecal2004TBTDCRanges_v1_cff.py:6
edm::contains
bool contains(EventRange const &lh, EventID const &rh)
Definition: EventRange.cc:37
LuminosityBlockRange
alignCSCRings.r
r
Definition: alignCSCRings.py:93
edm::merge
bool merge(LuminosityBlockRange &lh, LuminosityBlockRange &rh)
Definition: LuminosityBlockRange.cc:72
edm::lessThan
bool lessThan(EventRange const &lh, EventRange const &rh)
Definition: EventRange.cc:64
LuminosityBlockRange.h
edm::LuminosityBlockRange::endLumiID
LuminosityBlockID endLumiID() const
Definition: LuminosityBlockRange.h:47
edm::LuminosityBlockRange::LuminosityBlockRange
LuminosityBlockRange()
Definition: LuminosityBlockRange.cc:25
edm::overlaps
bool overlaps(EventRange const &lh, EventRange const &rh)
Definition: EventRange.cc:51
edm::LuminosityBlockRange
Definition: LuminosityBlockRange.h:32
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37