CMS 3D CMS Logo

RunHelper.cc
Go to the documentation of this file.
1 /*----------------------------------------------------------------------
2 ----------------------------------------------------------------------*/
3 #include "RunHelper.h"
4 
7 
8 #include <cassert>
9 
10 namespace edm {
11 
12  std::unique_ptr<RunHelperBase> makeRunHelper(ParameterSet const& pset) {
13  if (pset.exists("setRunNumber")) {
14  RunNumber_t run = pset.getUntrackedParameter<unsigned int>("setRunNumber");
15  if (run != 0U) {
16  return std::make_unique<SetRunHelper>(pset);
17  }
18  }
19  if (pset.exists("setRunNumberForEachLumi")) {
20  std::vector<RunNumber_t> runs = pset.getUntrackedParameter<std::vector<unsigned int> >("setRunNumberForEachLumi");
21  if (!runs.empty()) {
22  return std::make_unique<SetRunForEachLumiHelper>(pset);
23  }
24  }
25  return std::make_unique<DefaultRunHelper>();
26  }
27 
29 
31  assert(lumi == originalLumi);
32  }
33 
35  assert(run == originalRun);
36  }
37 
39 
41  : RunHelperBase(),
42  setRun_(pset.getUntrackedParameter<unsigned int>("setRunNumber")),
43  forcedRunOffset_(0),
44  firstTime_(true) {}
45 
47 
49  if (firstTime_ && setRun_ != 0) {
51  if (forcedRunOffset_ < 0) {
53  << "The value of the 'setRunNumber' parameter must not be\n"
54  << "less than the first run number in the first input file.\n"
55  << "'setRunNumber' was " << setRun_ << ", while the first run was " << firstRun << ".\n";
56  }
57  }
58  firstTime_ = false;
59  }
60 
62  id = RunID(id.run() + forcedRunOffset_);
63  if (id < RunID::firstValidRun())
64  id = RunID::firstValidRun();
65  }
66 
68  id = LuminosityBlockID(id.run() + forcedRunOffset_, id.luminosityBlock());
69  if (RunID(id.run()) < RunID::firstValidRun())
70  id = LuminosityBlockID(RunID::firstValidRun().run(), id.luminosityBlock());
71  }
72 
73  void SetRunHelper::overrideRunNumber(EventID& id, bool isRealData) {
74  if (isRealData) {
75  throw Exception(errors::Configuration, "SetRunHelper::overrideRunNumber()")
76  << "The 'setRunNumber' parameter of PoolSource cannot be used with real data.\n";
77  }
78  id = EventID(id.run() + forcedRunOffset_, id.luminosityBlock(), id.event());
79  if (RunID(id.run()) < RunID::firstValidRun()) {
80  id = EventID(
82  }
83  }
84 
86  assert(run == originalRun + forcedRunOffset_);
87  }
88 
90  : RunHelperBase(),
91  setRunNumberForEachLumi_(pset.getUntrackedParameter<std::vector<unsigned int> >("setRunNumberForEachLumi")),
92  indexOfNextRunNumber_(0),
93  realRunNumber_(0),
94  fakeNewRun_(false),
95  firstTime_(true) {}
96 
98 
100  InputSource::ItemType const& newItemType) {
101  if (newItemType == InputSource::IsRun ||
102  (newItemType == InputSource::IsLumi && previousItemType != InputSource::IsRun)) {
103  if (firstTime_) {
104  firstTime_ = false;
105  } else {
107  }
109  throw Exception(errors::MismatchedInputFiles, "PoolSource::getNextItemType")
110  << " Parameter 'setRunNumberForEachLumi' has " << setRunNumberForEachLumi_.size() << " entries\n"
111  << "but this job is processing more luminosity blocks than this.\n";
112  }
114  if (run == 0) {
115  throw Exception(errors::Configuration, "PoolSource")
116  << "'setRunNumberForEachLumi' contains an illegal run number of '0'.\n";
117  }
118  bool sameRunNumber = (indexOfNextRunNumber_ != 0U && run == setRunNumberForEachLumi_[indexOfNextRunNumber_ - 1]);
119  if (!sameRunNumber) {
120  fakeNewRun_ = (newItemType != InputSource::IsRun);
121  return InputSource::IsRun;
122  }
123  }
124  return newItemType;
125  }
126 
129  }
130 
132  if (realRunNumber_ != 0 && run != realRunNumber_) {
133  throw Exception(errors::MismatchedInputFiles, "PoolSource::checkForNewRun")
134  << " Parameter 'setRunNumberForEachLumi' can only process a single run.\n"
135  << "but this job is processing more than one run.\n";
136  }
138  }
139 
141 
143  id = LuminosityBlockID(runNumberToUseForThisLumi(), id.luminosityBlock());
144  }
145 
147  if (isRealData) {
148  throw Exception(errors::Configuration, "SetRunForEachLumiHelper::overrideRunNumber()")
149  << "The 'setRunNumberForEachLumi' parameter of PoolSource cannot be used with real data.\n";
150  }
151  id = EventID(runNumberToUseForThisLumi(), id.luminosityBlock(), id.event());
152  }
153 
155  assert(run == runNumberToUseForThisLumi());
156  }
157 
159  desc.addOptionalNode(ParameterDescription<unsigned int>("setRunNumber", 0U, false) xor
160  ParameterDescription<std::vector<unsigned int> >(
161  "setRunNumberForEachLumi", std::vector<unsigned int>(), false),
162  true)
163  ->setComment(
164  "If 'setRun' is non-zero, change number of first run to this number. Apply same offset to all runs."
165  "If 'setRunNumberForEachLumi' is non-empty, use these as run numbers for each lumi respectively."
166  "''setRun' and 'setRunNumberForEachLumi' are mutually exclusive and allowed only for simulation.");
167  }
168 } // namespace edm
void setComment(std::string const &value)
T getUntrackedParameter(std::string const &, T const &) const
void checkForNewRun(RunNumber_t run) override
Definition: RunHelper.cc:131
static LuminosityBlockID firstValidLuminosityBlock()
void setForcedRunOffset(RunNumber_t firstRun) override
Definition: RunHelper.cc:48
void checkRunConsistency(RunNumber_t run, RunNumber_t origninalRun) const override
Definition: RunHelper.cc:154
static void fillDescription(ParameterSetDescription &desc)
Definition: RunHelper.cc:158
void overrideRunNumber(EventID &event, bool isRealData) override
Definition: RunHelper.cc:73
bool exists(std::string const &parameterName) const
checks if a parameter exists
static RunID firstValidRun()
Definition: RunID.h:77
unsigned int LuminosityBlockNumber_t
InputSource::ItemType nextItemType(InputSource::ItemType const &previousItemType, InputSource::ItemType const &newIemType) override
Definition: RunHelper.cc:99
~SetRunHelper() override
Definition: RunHelper.cc:46
SetRunHelper(ParameterSet const &pset)
Definition: RunHelper.cc:40
void checkRunConsistency(RunNumber_t run, RunNumber_t origninalRun) const override
Definition: RunHelper.cc:85
ParameterDescriptionNode * addOptionalNode(ParameterDescriptionNode const &node, bool writeToCfi)
~DefaultRunHelper() override
Definition: RunHelper.cc:38
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
std::unique_ptr< RunHelperBase > makeRunHelper(ParameterSet const &pset)
Definition: RunHelper.cc:12
SetRunForEachLumiHelper(ParameterSet const &pset)
Definition: RunHelper.cc:89
virtual ~RunHelperBase()
Definition: RunHelper.cc:28
~SetRunForEachLumiHelper() override
Definition: RunHelper.cc:97
virtual void checkLumiConsistency(LuminosityBlockNumber_t lumi, LuminosityBlockNumber_t origninalLumi) const
Definition: RunHelper.cc:30
HLT enums.
RunNumber_t setRun_
Definition: RunHelper.h:57
firstRun
Definition: dataset.py:940
unsigned int RunNumber_t
RunNumber_t runNumberToUseForThisLumi() const override
Definition: RunHelper.cc:127
std::vector< RunNumber_t > setRunNumberForEachLumi_
Definition: RunHelper.h:79
void overrideRunNumber(EventID &event, bool isRealData) override
Definition: RunHelper.cc:146
virtual void checkRunConsistency(RunNumber_t run, RunNumber_t origninalRun) const
Definition: RunHelper.cc:34