test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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>
14  if(pset.exists("setRunNumber")) {
15  RunNumber_t run = pset.getUntrackedParameter<unsigned int>("setRunNumber");
16  if(run != 0U) {
17  return std::make_unique<SetRunHelper>(pset);
18  }
19  }
20  if(pset.exists("setRunNumberForEachLumi")) {
21  std::vector<RunNumber_t> runs = pset.getUntrackedParameter<std::vector<unsigned int> >("setRunNumberForEachLumi");
22  if(!runs.empty()) {
23  return std::make_unique<SetRunForEachLumiHelper>(pset);
24  }
25  }
26  return std::make_unique<DefaultRunHelper>();
27  }
28 
30 
31  void
33  assert(lumi == originalLumi);
34  }
35 
36  void
38  assert(run == originalRun);
39  }
40 
42 
44  RunHelperBase(),
45  setRun_(pset.getUntrackedParameter<unsigned int>("setRunNumber")),
46  forcedRunOffset_(0),
47  firstTime_(true) {
48  }
49 
51 
52  void
54  if(firstTime_ && setRun_ != 0) {
56  if(forcedRunOffset_ < 0) {
58  << "The value of the 'setRunNumber' parameter must not be\n"
59  << "less than the first run number in the first input file.\n"
60  << "'setRunNumber' was " << setRun_ <<", while the first run was "
61  << firstRun << ".\n";
62  }
63  }
64  firstTime_ = false;
65  }
66 
67  void
69  id = RunID(id.run() + forcedRunOffset_);
71  }
72 
73  void
75  id = LuminosityBlockID(id.run() + forcedRunOffset_, id.luminosityBlock());
76  if(RunID(id.run()) < RunID::firstValidRun()) id = LuminosityBlockID(RunID::firstValidRun().run(), id.luminosityBlock());
77  }
78 
79  void
80  SetRunHelper::overrideRunNumber(EventID& id, bool isRealData) {
81  if(isRealData) {
82  throw Exception(errors::Configuration, "SetRunHelper::overrideRunNumber()")
83  << "The 'setRunNumber' parameter of PoolSource cannot be used with real data.\n";
84  }
85  id = EventID(id.run() + forcedRunOffset_, id.luminosityBlock(), id.event());
86  if(RunID(id.run()) < RunID::firstValidRun()) {
88  }
89  }
90 
91  void
93  assert(run == originalRun + forcedRunOffset_);
94  }
95 
97  RunHelperBase(),
98  setRunNumberForEachLumi_(pset.getUntrackedParameter<std::vector<unsigned int> >("setRunNumberForEachLumi")),
99  indexOfNextRunNumber_(0),
100  realRunNumber_(0),
101  fakeNewRun_(false),
102  firstTime_(true) {
103  }
104 
106 
109  if(newItemType == InputSource::IsRun || (newItemType == InputSource::IsLumi && previousItemType != InputSource::IsRun)) {
110  if(firstTime_) {
111  firstTime_ = false;
112  } else {
114  }
116  throw Exception(errors::MismatchedInputFiles, "PoolSource::getNextItemType")
117  << " Parameter 'setRunNumberForEachLumi' has " << setRunNumberForEachLumi_.size() << " entries\n"
118  << "but this job is processing more luminosity blocks than this.\n";
119  }
121  if(run == 0) {
122  throw Exception(errors::Configuration, "PoolSource") <<
123  "'setRunNumberForEachLumi' contains an illegal run number of '0'.\n";
124  }
125  bool sameRunNumber = (indexOfNextRunNumber_ != 0U && run == setRunNumberForEachLumi_[indexOfNextRunNumber_ - 1]);
126  if(!sameRunNumber) {
127  fakeNewRun_ = (newItemType != InputSource::IsRun);
128  return InputSource::IsRun;
129  }
130  }
131  return newItemType;
132  }
133 
137  }
138 
139  void
141  if(realRunNumber_ != 0 && run != realRunNumber_) {
142  throw Exception(errors::MismatchedInputFiles, "PoolSource::checkForNewRun")
143  << " Parameter 'setRunNumberForEachLumi' can only process a single run.\n"
144  << "but this job is processing more than one run.\n";
145  }
147  }
148 
149  void
152  }
153 
154  void
156  id = LuminosityBlockID(runNumberToUseForThisLumi(), id.luminosityBlock());
157  }
158 
159  void
161  if(isRealData) {
162  throw Exception(errors::Configuration, "SetRunForEachLumiHelper::overrideRunNumber()")
163  << "The 'setRunNumberForEachLumi' parameter of PoolSource cannot be used with real data.\n";
164  }
165  id = EventID(runNumberToUseForThisLumi(), id.luminosityBlock(), id.event());
166  }
167 
168  void
171  }
172 
173  void
175  desc.addOptionalNode(ParameterDescription<unsigned int>("setRunNumber", 0U, false) xor
176  ParameterDescription<std::vector<unsigned int> >("setRunNumberForEachLumi", std::vector<unsigned int>(), false), true)
177  ->setComment("If 'setRun' is non-zero, change number of first run to this number. Apply same offset to all runs." \
178  "If 'setRunNumberForEachLumi' is non-empty, use these as run numbers for each lumi respectively." \
179  "''setRun' and 'setRunNumberForEachLumi' are mutually exclusive and allowed only for simulation.");
180  }
181 }
void setComment(std::string const &value)
T getUntrackedParameter(std::string const &, T const &) const
virtual void checkForNewRun(RunNumber_t run) override
Definition: RunHelper.cc:140
static LuminosityBlockID firstValidLuminosityBlock()
virtual void checkRunConsistency(RunNumber_t run, RunNumber_t origninalRun) const override
Definition: RunHelper.cc:169
virtual void setForcedRunOffset(RunNumber_t firstRun) override
Definition: RunHelper.cc:53
tuple lumi
Definition: fjr2json.py:35
static void fillDescription(ParameterSetDescription &desc)
Definition: RunHelper.cc:174
virtual void overrideRunNumber(EventID &event, bool isRealData) override
Definition: RunHelper.cc:80
assert(m_qm.get())
bool exists(std::string const &parameterName) const
checks if a parameter exists
string firstRun
Definition: dataset.py:924
static RunID firstValidRun()
Definition: RunID.h:77
unsigned int LuminosityBlockNumber_t
virtual InputSource::ItemType nextItemType(InputSource::ItemType const &previousItemType, InputSource::ItemType const &newIemType) override
Definition: RunHelper.cc:108
virtual void checkRunConsistency(RunNumber_t run, RunNumber_t origninalRun) const override
Definition: RunHelper.cc:92
SetRunHelper(ParameterSet const &pset)
Definition: RunHelper.cc:43
tuple runs
Definition: gather_cfg.py:87
virtual ~DefaultRunHelper()
Definition: RunHelper.cc:41
virtual ~SetRunHelper()
Definition: RunHelper.cc:50
ParameterDescriptionNode * addOptionalNode(ParameterDescriptionNode const &node, bool writeToCfi)
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:13
SetRunForEachLumiHelper(ParameterSet const &pset)
Definition: RunHelper.cc:96
virtual ~RunHelperBase()
Definition: RunHelper.cc:29
virtual void checkLumiConsistency(LuminosityBlockNumber_t lumi, LuminosityBlockNumber_t origninalLumi) const
Definition: RunHelper.cc:32
RunNumber_t setRun_
Definition: RunHelper.h:56
virtual RunNumber_t runNumberToUseForThisLumi() const override
Definition: RunHelper.cc:135
unsigned int RunNumber_t
volatile std::atomic< bool > shutdown_flag false
std::vector< RunNumber_t > setRunNumberForEachLumi_
Definition: RunHelper.h:79
virtual void overrideRunNumber(EventID &event, bool isRealData) override
Definition: RunHelper.cc:160
virtual void checkRunConsistency(RunNumber_t run, RunNumber_t origninalRun) const
Definition: RunHelper.cc:37