CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Attributes
edm::EventSkipperByID Class Reference

#include <EventSkipperByID.h>

Public Member Functions

 EventSkipperByID (ParameterSet const &pset)
 
bool skipIt (RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event) const
 
bool skippingEvents () const
 
bool skippingLumis () const
 
bool somethingToSkip () const
 
 ~EventSkipperByID ()
 

Static Public Member Functions

static std::unique_ptr< EventSkipperByIDcreate (ParameterSet const &pset)
 
static void fillDescription (ParameterSetDescription &desc)
 

Private Attributes

EventNumber_t firstEvent_
 
LuminosityBlockNumber_t firstLumi_
 
RunNumber_t firstRun_
 
bool skippingEvents_
 
bool skippingLumis_
 
bool somethingToSkip_
 
std::vector< EventRangewhichEventsToProcess_
 
std::vector< EventRangewhichEventsToSkip_
 
std::vector< LuminosityBlockRangewhichLumisToProcess_
 
std::vector< LuminosityBlockRangewhichLumisToSkip_
 

Detailed Description

Definition at line 17 of file EventSkipperByID.h.

Constructor & Destructor Documentation

◆ EventSkipperByID()

edm::EventSkipperByID::EventSkipperByID ( ParameterSet const &  pset)
explicit

Definition at line 7 of file EventSkipperByID.cc.

References edm::sortAndRemoveOverlaps(), whichEventsToProcess_, whichEventsToSkip_, whichLumisToProcess_, and whichLumisToSkip_.

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>())),
23  pset.getUntrackedParameter<std::vector<EventRange> >("eventsToSkip", std::vector<EventRange>())),
25  pset.getUntrackedParameter<std::vector<EventRange> >("eventsToProcess", std::vector<EventRange>())),
26  skippingLumis_(!(whichLumisToSkip_.empty() && whichLumisToProcess_.empty() && firstLumi_ == 0)),
29  !(firstRun_ <= 1U && firstLumi_ <= 1U && firstEvent_ <= 1U)) {
34  }
LuminosityBlockNumber_t firstLumi_
std::vector< LuminosityBlockRange > whichLumisToSkip_
std::vector< EventRange > whichEventsToProcess_
std::vector< LuminosityBlockRange > whichLumisToProcess_
std::vector< EventRange > whichEventsToSkip_
EventNumber_t firstEvent_
std::vector< EventRange > & sortAndRemoveOverlaps(std::vector< EventRange > &eventRange)
Definition: EventRange.cc:98

◆ ~EventSkipperByID()

edm::EventSkipperByID::~EventSkipperByID ( )

Definition at line 36 of file EventSkipperByID.cc.

36 {}

Member Function Documentation

◆ create()

std::unique_ptr< EventSkipperByID > edm::EventSkipperByID::create ( ParameterSet const &  pset)
static

Definition at line 38 of file EventSkipperByID.cc.

References muonDTDigis_cfi::pset.

Referenced by edm::RepeatingCachedRootSource::RepeatingCachedRootSource().

38  {
39  auto evSkp = std::make_unique<EventSkipperByID>(pset);
40  if (!evSkp->somethingToSkip()) {
41  evSkp.reset();
42  }
43  return evSkp;
44  }

◆ fillDescription()

void edm::EventSkipperByID::fillDescription ( ParameterSetDescription desc)
static

Definition at line 116 of file EventSkipperByID.cc.

References submitPVResolutionJobs::desc, and mitigatedMETSequence_cff::U.

Referenced by edm::RootPrimaryFileSequence::fillDescription(), dqmservices::DQMStreamerReader::fillDescriptions(), and edm::StreamerFileReader::fillDescriptions().

116  {
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  }

◆ skipIt()

bool edm::EventSkipperByID::skipIt ( RunNumber_t  run,
LuminosityBlockNumber_t  lumi,
EventNumber_t  event 
) const

Definition at line 49 of file EventSkipperByID.cc.

References edm::binary_search_all(), nano_mu_local_reco_cff::bool, unittestinputsource_cfi::eventRange, firstEvent_, firstLumi_, firstRun_, edm::lessThan(), edm::lessThanSpecial(), beamSpotPI::lumiRange, writedatasetfile::run, skippingEvents(), skippingLumis(), mitigatedMETSequence_cff::U, whichEventsToProcess_, whichEventsToSkip_, whichLumisToProcess_, and whichLumisToSkip_.

49  {
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.
79  LuminosityBlockID lumiID = LuminosityBlockID(run, lumi);
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  }
bool skippingEvents() const
LuminosityBlockNumber_t firstLumi_
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 skippingLumis() const
std::vector< EventRange > whichEventsToSkip_
EventNumber_t firstEvent_
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
Definition: event.py:1

◆ skippingEvents()

bool edm::EventSkipperByID::skippingEvents ( ) const
inline

Definition at line 23 of file EventSkipperByID.h.

References skippingEvents_.

Referenced by skipIt().

23 { return skippingEvents_; }

◆ skippingLumis()

bool edm::EventSkipperByID::skippingLumis ( ) const
inline

Definition at line 22 of file EventSkipperByID.h.

References skippingLumis_.

Referenced by skipIt().

22 { return skippingLumis_; }

◆ somethingToSkip()

bool edm::EventSkipperByID::somethingToSkip ( ) const
inline

Definition at line 24 of file EventSkipperByID.h.

References somethingToSkip_.

24 { return somethingToSkip_; }

Member Data Documentation

◆ firstEvent_

EventNumber_t edm::EventSkipperByID::firstEvent_
private

Definition at line 31 of file EventSkipperByID.h.

Referenced by skipIt().

◆ firstLumi_

LuminosityBlockNumber_t edm::EventSkipperByID::firstLumi_
private

Definition at line 30 of file EventSkipperByID.h.

Referenced by skipIt().

◆ firstRun_

RunNumber_t edm::EventSkipperByID::firstRun_
private

Definition at line 29 of file EventSkipperByID.h.

Referenced by skipIt().

◆ skippingEvents_

bool edm::EventSkipperByID::skippingEvents_
private

Definition at line 37 of file EventSkipperByID.h.

Referenced by skippingEvents().

◆ skippingLumis_

bool edm::EventSkipperByID::skippingLumis_
private

Definition at line 36 of file EventSkipperByID.h.

Referenced by skippingLumis().

◆ somethingToSkip_

bool edm::EventSkipperByID::somethingToSkip_
private

Definition at line 38 of file EventSkipperByID.h.

Referenced by somethingToSkip().

◆ whichEventsToProcess_

std::vector<EventRange> edm::EventSkipperByID::whichEventsToProcess_
private

Definition at line 35 of file EventSkipperByID.h.

Referenced by EventSkipperByID(), and skipIt().

◆ whichEventsToSkip_

std::vector<EventRange> edm::EventSkipperByID::whichEventsToSkip_
private

Definition at line 34 of file EventSkipperByID.h.

Referenced by EventSkipperByID(), and skipIt().

◆ whichLumisToProcess_

std::vector<LuminosityBlockRange> edm::EventSkipperByID::whichLumisToProcess_
private

Definition at line 33 of file EventSkipperByID.h.

Referenced by EventSkipperByID(), and skipIt().

◆ whichLumisToSkip_

std::vector<LuminosityBlockRange> edm::EventSkipperByID::whichLumisToSkip_
private

Definition at line 32 of file EventSkipperByID.h.

Referenced by EventSkipperByID(), and skipIt().