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.
80  LuminosityBlockRange lumiRange = LuminosityBlockRange(lumiID, lumiID);
81  bool (*lt)(LuminosityBlockRange const&, LuminosityBlockRange const&) = &lessThan;
82  if (binary_search_all(whichLumisToSkip_, lumiRange, lt)) {
83  // The entry is in a lumi specified in whichLumisToSkip. Skip it.
84  return true;
85  }
86  if (!whichLumisToProcess_.empty() && !binary_search_all(whichLumisToProcess_, lumiRange, lt)) {
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
edm::RunNumber_t
unsigned int RunNumber_t
Definition: RunLumiEventNumber.h:14
electrons_cff.bool
bool
Definition: electrons_cff.py:393
funct::false
false
Definition: Factorize.h:29
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
Algorithms.h
edm::sortAndRemoveOverlaps
std::vector< EventRange > & sortAndRemoveOverlaps(std::vector< EventRange > &eventRange)
Definition: EventRange.cc:98
edm::EventSkipperByID::firstRun_
RunNumber_t firstRun_
Definition: EventSkipperByID.h:29
edm::LuminosityBlockNumber_t
unsigned int LuminosityBlockNumber_t
Definition: RunLumiEventNumber.h:13
EventSkipperByID.h
edm::EventSkipperByID::create
static std::unique_ptr< EventSkipperByID > create(ParameterSet const &pset)
Definition: EventSkipperByID.cc:38
edm::EventSkipperByID::skipIt
bool skipIt(RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event) const
Definition: EventSkipperByID.cc:49
edm::EventSkipperByID::~EventSkipperByID
~EventSkipperByID()
Definition: EventSkipperByID.cc:36
edm::EventSkipperByID::skippingEvents
bool skippingEvents() const
Definition: EventSkipperByID.h:23
edm::EventSkipperByID::firstLumi_
LuminosityBlockNumber_t firstLumi_
Definition: EventSkipperByID.h:30
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::binary_search_all
bool binary_search_all(ForwardSequence const &s, Datum const &d)
wrappers for std::binary_search
Definition: Algorithms.h:58
ParameterSetDescription.h
edm::LuminosityBlockID
Definition: LuminosityBlockID.h:31
mitigatedMETSequence_cff.U
U
Definition: mitigatedMETSequence_cff.py:36
edm::EventSkipperByID::skippingLumis
bool skippingLumis() const
Definition: EventSkipperByID.h:22
edm::ParameterSet
Definition: ParameterSet.h:47
edm::EventSkipperByID::whichLumisToProcess_
std::vector< LuminosityBlockRange > whichLumisToProcess_
Definition: EventSkipperByID.h:33
edm::EventSkipperByID::whichLumisToSkip_
std::vector< LuminosityBlockRange > whichLumisToSkip_
Definition: EventSkipperByID.h:32
createfilelist.int
int
Definition: createfilelist.py:10
edm::EventSkipperByID::whichEventsToProcess_
std::vector< EventRange > whichEventsToProcess_
Definition: EventSkipperByID.h:35
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
edm::EventSkipperByID::whichEventsToSkip_
std::vector< EventRange > whichEventsToSkip_
Definition: EventSkipperByID.h:34
edm::EventSkipperByID::firstEvent_
EventNumber_t firstEvent_
Definition: EventSkipperByID.h:31
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
std
Definition: JetResolutionObject.h:76
writedatasetfile.run
run
Definition: writedatasetfile.py:27
relativeConstraints.empty
bool empty
Definition: relativeConstraints.py:46
edm::lessThan
bool lessThan(EventRange const &lh, EventRange const &rh)
Definition: EventRange.cc:64
unittestinputsource_cfi.eventRange
eventRange
Definition: unittestinputsource_cfi.py:108
edm::EventSkipperByID::EventSkipperByID
EventSkipperByID(ParameterSet const &pset)
Definition: EventSkipperByID.cc:7
edm::EventSkipperByID::fillDescription
static void fillDescription(ParameterSetDescription &desc)
Definition: EventSkipperByID.cc:116
ParameterSet.h
event
Definition: event.py:1
edm::EventID
Definition: EventID.h:31
edm::EventRange
Definition: EventRange.h:31
lumi
Definition: LumiSectionData.h:20
edm::ParameterDescription
Definition: ParameterDescription.h:110
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
edm::LuminosityBlockRange
Definition: LuminosityBlockRange.h:32