CMS 3D CMS Logo

EventRange.cc
Go to the documentation of this file.
3 #include <cassert>
4 #include <ostream>
5 //#include <limits>
6 
7 namespace edm {
9  : // Special cases since 0 means maximum
10  startEventID_(0U, 0U, EventID::maxEventNumber()),
11  endEventID_(0U, 0U, EventID::maxEventNumber()) {}
12 
14  LuminosityBlockNumber_t startLumi,
15  EventNumber_t startEvent,
18  EventNumber_t endEvent)
19  : // Special cases since 0 means maximum
20  startEventID_(startRun, startLumi, startEvent != 0 ? startEvent : EventID::maxEventNumber()),
21  endEventID_(endRun, endLumi, endEvent != 0 ? endEvent : EventID::maxEventNumber()) {
22  assert((startLumi == 0) == (endLumi == 0));
23  }
24 
25  EventRange::EventRange(EventID const& begin, EventID const& end) : startEventID_(begin), endEventID_(end) {}
26 
27  std::ostream& operator<<(std::ostream& oStream, EventRange const& r) {
28  if (r.startLumi() == 0) {
29  oStream << "'" << r.startRun() << ":" << r.startEvent() << "-" << r.endRun() << ":" << r.endEvent() << "'";
30  } else {
31  oStream << "'" << r.startRun() << ":" << r.startLumi() << ":" << r.startEvent() << "-" << r.endRun() << ":"
32  << r.endLumi() << ":" << r.endEvent() << "'";
33  }
34  return oStream;
35  }
36 
37  bool contains(EventRange const& lh, EventID const& rh) {
38  if (lh.startLumi() == 0) {
39  return (contains_(lh, EventID(rh.run(), 0U, rh.event())));
40  }
41  return (contains_(lh, rh));
42  }
43 
44  bool contains_(EventRange const& lh, EventID const& rh) { return (rh >= lh.startEventID() && rh <= lh.endEventID()); }
45 
46  bool contains(EventRange const& lh, EventRange const& rh) {
47  assert((lh.startLumi() == 0) == (rh.startLumi() == 0));
48  return (contains(lh, rh.startEventID()) && contains(lh, rh.endEventID()));
49  }
50 
51  bool overlaps(EventRange const& lh, EventRange const& rh) {
52  assert((lh.startLumi() == 0) == (rh.startLumi() == 0));
53  return !distinct(lh, rh);
54  }
55 
56  bool lessThanSpecial(EventRange const& lh, EventRange const& rh) {
57  // First, separate the ranges so that those with 0 lumiID go first.
58  if ((lh.startLumi() == 0) != (rh.startLumi() == 0)) {
59  return lh.startLumi() == 0;
60  }
61  return lh.endEventID() < rh.startEventID();
62  }
63 
64  bool lessThan(EventRange const& lh, EventRange const& rh) {
65  assert((lh.startLumi() == 0) == (rh.startLumi() == 0));
66  return lh.endEventID() < rh.startEventID();
67  }
68 
69  bool distinct(EventRange const& lh, EventRange const& rh) {
70  assert((lh.startLumi() == 0) == (rh.startLumi() == 0));
71  return lessThan(lh, rh) || lessThan(rh, lh);
72  }
73 
74  namespace {
75  bool mergeSpecial(EventRange& lh, EventRange& rh) {
76  // Don't combine a range with 0 lumiID with a range with non-zero lumiID.
77  if ((lh.startLumi() == 0) != (rh.startLumi() == 0)) {
78  return false;
79  }
80  if (overlaps(lh, rh)) {
81  EventID begin = min(lh.startEventID(), rh.startEventID());
82  EventID end = max(lh.endEventID(), rh.endEventID());
83  rh = lh = EventRange(begin, end);
84  return true;
85  }
86  return false;
87  }
88 
89  bool sortByStartEventIDSpecial(EventRange const& lh, EventRange const& rh) {
90  // First, separate the ranges so that those with 0 lumiID go first.
91  if ((lh.startLumi() == 0) != (rh.startLumi() == 0)) {
92  return lh.startLumi() == 0;
93  }
94  return lh.startEventID() < rh.startEventID();
95  }
96  } // namespace
97 
98  std::vector<EventRange>& sortAndRemoveOverlaps(std::vector<EventRange>& eventRange) {
99  if (eventRange.size() <= 1U)
100  return eventRange;
101  sort_all(eventRange, sortByStartEventIDSpecial);
102  for (std::vector<EventRange>::iterator i = eventRange.begin() + 1, e = eventRange.end(); i != e; ++i) {
103  std::vector<EventRange>::iterator iprev = i - 1;
104  if (mergeSpecial(*iprev, *i)) {
105  i = eventRange.erase(iprev);
106  e = eventRange.end();
107  }
108  }
109  return eventRange;
110  }
111 } // namespace edm
edm::EventRange::startEventID
EventID startEventID() const
Definition: EventRange.h:46
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::contains_
bool contains_(EventRange const &lh, EventID const &rh)
Definition: EventRange.cc:44
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::max
EventID const & max(EventID const &lh, EventID const &rh)
Definition: EventID.h:118
edm::EventRange::endEventID
EventID endEventID() const
Definition: EventRange.h:47
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
mps_fire.end
end
Definition: mps_fire.py:242
edm::EventNumber_t
unsigned long long EventNumber_t
Definition: RunLumiEventNumber.h:12
edm::lessThanSpecial
bool lessThanSpecial(EventRange const &lh, EventRange const &rh)
Definition: EventRange.cc:56
edm::EventID::run
RunNumber_t run() const
Definition: EventID.h:38
edm::EventRange::EventRange
EventRange()
Definition: EventRange.cc:8
mitigatedMETSequence_cff.U
U
Definition: mitigatedMETSequence_cff.py:36
edm::EventRange::startLumi
LuminosityBlockNumber_t startLumi() const
Definition: EventRange.h:50
Ecal2004TBTDCRanges_v1_cff.startRun
startRun
Definition: Ecal2004TBTDCRanges_v1_cff.py:6
edm::EventID::event
EventNumber_t event() const
Definition: EventID.h:40
edm::contains
bool contains(EventRange const &lh, EventID const &rh)
Definition: EventRange.cc:37
edm::EventRange::endLumi
LuminosityBlockNumber_t endLumi() const
Definition: EventRange.h:51
alignCSCRings.r
r
Definition: alignCSCRings.py:93
edm::lessThan
bool lessThan(EventRange const &lh, EventRange const &rh)
Definition: EventRange.cc:64
unittestinputsource_cfi.eventRange
eventRange
Definition: unittestinputsource_cfi.py:108
edm::EventID
Definition: EventID.h:31
edm::EventRange
Definition: EventRange.h:31
edm::overlaps
bool overlaps(EventRange const &lh, EventRange const &rh)
Definition: EventRange.cc:51
EventRange.h
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37