CMS 3D CMS Logo

EventSkipperByID.cc
Go to the documentation of this file.
5 
6 namespace edm {
8  : // The default value provided as the second argument to the getUntrackedParameter function call
9  // is not used when the ParameterSet has been validated and the parameters are not optional
10  // in the description. As soon as all primary input sources and all modules with a secondary
11  // input sources have defined descriptions, the defaults in the getUntrackedParameterSet function
12  // calls can and should be deleted from the code.
13  firstRun_(pset.getUntrackedParameter<unsigned int>("firstRun", 1U)),
14  firstLumi_(pset.getUntrackedParameter<unsigned int>("firstLuminosityBlock", 0U)),
15  firstEvent_(pset.existsAs<unsigned int>("firstEvent", false)
16  ? pset.getUntrackedParameter<unsigned int>("firstEvent")
17  : pset.getUntrackedParameter<unsigned long long>("firstEvent", 1U)),
18  whichLumisToSkip_(pset.getUntrackedParameter<std::vector<LuminosityBlockRange> >(
19  "lumisToSkip", std::vector<LuminosityBlockRange>())),
20  whichLumisToProcess_(pset.getUntrackedParameter<std::vector<LuminosityBlockRange> >(
21  "lumisToProcess", std::vector<LuminosityBlockRange>())),
22  whichEventsToSkip_(
23  pset.getUntrackedParameter<std::vector<EventRange> >("eventsToSkip", std::vector<EventRange>())),
24  whichEventsToProcess_(
25  pset.getUntrackedParameter<std::vector<EventRange> >("eventsToProcess", std::vector<EventRange>())),
26  skippingLumis_(!(whichLumisToSkip_.empty() && whichLumisToProcess_.empty() && firstLumi_ == 0)),
27  skippingEvents_(!(whichEventsToSkip_.empty() && whichEventsToProcess_.empty())),
28  somethingToSkip_(skippingLumis_ || skippingEvents_ ||
29  !(firstRun_ <= 1U && firstLumi_ <= 1U && firstEvent_ <= 1U)) {
34  }
35 
37 
38  std::unique_ptr<EventSkipperByID> EventSkipperByID::create(ParameterSet const& pset) {
39  auto evSkp = std::make_unique<EventSkipperByID>(pset);
40  if (!evSkp->somethingToSkip()) {
41  evSkp.reset();
42  }
43  return evSkp;
44  }
45 
46  // Determines whether a run, lumi, or event will be skipped based on the run, lumi, and event number.
47  // This function is called by a predicate, so it must not modify the state of the EventSkipperByID_ object.
48  // The mutable lumi_ and event_ data members are just temporary caches, so they may be modified.
50  if (run == 0U)
51  run = 1U; // Correct zero run number
52  if (run < firstRun_) {
53  // Skip all entries before the first run.
54  return true;
55  }
56  if (lumi == 0U) {
57  // This is a run entry that is not before the first run.
58  // Keep it, since there are no other parameters to skip runs.
59  return false;
60  }
61  // If we get here, this is a lumi or event entry.
62  if (run == firstRun_) {
63  // This lumi or event entry is in the first run to be processed.
64  if (lumi < firstLumi_) {
65  // This lumi or event entry is for a lumi prior to the first lumi to be processed. Skip it.
66  return true;
67  }
68  if (firstLumi_ == 0 || lumi == firstLumi_) {
69  // If we get here, this entry is in the first lumi to be processed in the first run.
70  // Note that if firstLumi_ == 0, we are processing all lumis in the run.
71  if (event != 0U && event < firstEvent_) {
72  // This is an event entry prior to the first event to be processed. Skip it.
73  return true;
74  }
75  }
76  }
77  if (skippingLumis()) {
78  // If we get here, the entry was not skipped due to firstRun, firstLuminosityBlock, and/or firstEvent.
81  bool (*lt)(LuminosityBlockRange const&, LuminosityBlockRange const&) = &lessThan;
83  // The entry is in a lumi specified in whichLumisToSkip. Skip it.
84  return true;
85  }
87  // The entry is not in a lumi specified in non-empty whichLumisToProcess. Skip it.
88  return true;
89  }
90  }
91  if (event == 0U) {
92  // The entry is a lumi entry that was not skipped above. Keep it.
93  return false;
94  }
95  if (skippingEvents()) {
96  // If we get here, the entry was not skipped due to firstRun, firstLuminosityBlock, and/or firstEvent.
97  EventID eventID = EventID(run, lumi, event);
98  EventRange eventRange = EventRange(eventID, eventID);
99  EventID eventIDNoLumi = EventID(run, 0U, event);
100  EventRange eventRangeNoLumi = EventRange(eventIDNoLumi, eventIDNoLumi);
101  bool (*lt)(EventRange const&, EventRange const&) = &lessThanSpecial;
103  binary_search_all(whichEventsToSkip_, eventRangeNoLumi, lt)) {
104  // The entry is an event specified in whichEventsToSkip. Skip it.
105  return true;
106  }
108  !binary_search_all(whichEventsToProcess_, eventRangeNoLumi, lt)) {
109  // The entry is not an event specified in non-empty whichEventsToProcess. Skip it.
110  return true;
111  }
112  }
113  return false;
114  }
115 
117  desc.addUntracked<unsigned int>("firstRun", 1U)->setComment("Skip any run with run number < 'firstRun'.");
118  desc.addUntracked<unsigned int>("firstLuminosityBlock", 0U)
119  ->setComment("Skip any lumi in run 'firstRun' with lumi number < 'firstLuminosityBlock'.");
120 
121  desc.addNode(edm::ParameterDescription<unsigned int>("firstEvent", 1U, false) xor
122  edm::ParameterDescription<unsigned long long>("firstEvent", 1ULL, false))
123  ->setComment(
124  "'firstEvent' is an XOR group because it can have type uint32 or uint64, default:1\n"
125  "If 'firstLuminosityBlock' == 0, skip any event in run 'firstRun' with event number < 'firstEvent'.\n"
126  "If 'firstLuminosityBlock' != 0, skip any event in lumi 'firstRun:firstLuminosityBlock' with event number "
127  "< 'firstEvent'.");
128 
129  std::vector<LuminosityBlockRange> defaultLumis;
130  desc.addUntracked<std::vector<LuminosityBlockRange> >("lumisToSkip", defaultLumis)
131  ->setComment(
132  "Skip any lumi inside the specified run:lumi range. In python do 'help(cms.LuminosityBlockRange)' for "
133  "documentation.");
134  desc.addUntracked<std::vector<LuminosityBlockRange> >("lumisToProcess", defaultLumis)
135  ->setComment(
136  "If not empty, skip any lumi outside the specified run:lumi range. In python do "
137  "'help(cms.LuminosityBlockRange)' for documentation.");
138 
139  std::vector<EventRange> defaultEvents;
140  desc.addUntracked<std::vector<EventRange> >("eventsToSkip", defaultEvents)
141  ->setComment(
142  "Skip any event inside the specified run:event or run:lumi:event range. In python do "
143  "'help(cms.EventRange)' for documentation.");
144  desc.addUntracked<std::vector<EventRange> >("eventsToProcess", defaultEvents)
145  ->setComment(
146  "If not empty, skip any event outside the specified run:event or run:lumi:event range. In python do "
147  "'help(cms.EventRange)' for documentation.");
148  }
149 } // namespace edm
static std::unique_ptr< EventSkipperByID > create(ParameterSet const &pset)
unsigned long long EventNumber_t
bool skippingEvents() const
LuminosityBlockNumber_t firstLumi_
unsigned int LuminosityBlockNumber_t
std::vector< LuminosityBlockRange > whichLumisToSkip_
std::vector< EventRange > whichEventsToProcess_
bool lessThanSpecial(EventRange const &lh, EventRange const &rh)
Definition: EventRange.cc:56
std::vector< LuminosityBlockRange > whichLumisToProcess_
bool skipIt(RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event) const
bool skippingLumis() const
std::vector< EventRange > whichEventsToSkip_
EventNumber_t firstEvent_
static void fillDescription(ParameterSetDescription &desc)
HLT enums.
std::vector< EventRange > & sortAndRemoveOverlaps(std::vector< EventRange > &eventRange)
Definition: EventRange.cc:98
bool binary_search_all(ForwardSequence const &s, Datum const &d)
wrappers for std::binary_search
Definition: Algorithms.h:58
bool lessThan(EventRange const &lh, EventRange const &rh)
Definition: EventRange.cc:64
string lumiRange
unsigned int RunNumber_t
EventSkipperByID(ParameterSet const &pset)
Definition: event.py:1