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  if (pset.exists("firstLuminosityBlockForEachRun")) {
26  if (not pset.getUntrackedParameter<std::vector<LuminosityBlockID>>("firstLuminosityBlockForEachRun").empty()) {
27  return std::make_unique<FirstLuminosityBlockForEachRunHelper>(pset);
28  }
29  }
30  return std::make_unique<DefaultRunHelper>();
31  }
32 
34 
36  assert(lumi == originalLumi);
37  }
38 
40  assert(run == originalRun);
41  }
42 
44 
46  : RunHelperBase(),
47  setRun_(pset.getUntrackedParameter<unsigned int>("setRunNumber")),
48  forcedRunOffset_(0),
49  firstTime_(true) {}
50 
52 
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 " << firstRun << ".\n";
61  }
62  }
63  firstTime_ = false;
64  }
65 
67  id = RunID(id.run() + forcedRunOffset_);
68  if (id < RunID::firstValidRun())
69  id = RunID::firstValidRun();
70  }
71 
73  id = LuminosityBlockID(id.run() + forcedRunOffset_, id.luminosityBlock());
74  if (RunID(id.run()) < RunID::firstValidRun())
75  id = LuminosityBlockID(RunID::firstValidRun().run(), id.luminosityBlock());
76  }
77 
78  void SetRunHelper::overrideRunNumber(EventID& id, bool isRealData) {
79  if (isRealData) {
80  throw Exception(errors::Configuration, "SetRunHelper::overrideRunNumber()")
81  << "The 'setRunNumber' parameter of PoolSource cannot be used with real data.\n";
82  }
83  id = EventID(id.run() + forcedRunOffset_, id.luminosityBlock(), id.event());
84  if (RunID(id.run()) < RunID::firstValidRun()) {
85  id = EventID(
87  }
88  }
89 
91  assert(run == originalRun + forcedRunOffset_);
92  }
93 
95  : RunHelperBase(),
96  setRunNumberForEachLumi_(pset.getUntrackedParameter<std::vector<unsigned int>>("setRunNumberForEachLumi")),
97  indexOfNextRunNumber_(0),
98  realRunNumber_(0),
99  fakeNewRun_(false),
100  firstTime_(true) {}
101 
103 
105  InputSource::ItemType const& newItemType,
106  RunNumber_t,
108  EventNumber_t) {
109  if (newItemType == InputSource::IsRun ||
110  (newItemType == InputSource::IsLumi && previousItemType != InputSource::IsRun)) {
111  if (firstTime_) {
112  firstTime_ = false;
113  } else {
115  }
117  throw Exception(errors::MismatchedInputFiles, "PoolSource::getNextItemType")
118  << " Parameter 'setRunNumberForEachLumi' has " << setRunNumberForEachLumi_.size() << " entries\n"
119  << "but this job is processing more luminosity blocks than this.\n";
120  }
122  if (run == 0) {
123  throw Exception(errors::Configuration, "PoolSource")
124  << "'setRunNumberForEachLumi' contains an illegal run number of '0'.\n";
125  }
126  bool sameRunNumber = (indexOfNextRunNumber_ != 0U && run == setRunNumberForEachLumi_[indexOfNextRunNumber_ - 1]);
127  if (!sameRunNumber) {
128  fakeNewRun_ = (newItemType != InputSource::IsRun);
129  return InputSource::IsRun;
130  }
131  }
132  return newItemType;
133  }
134 
137  }
138 
140  if (realRunNumber_ != 0 && run != realRunNumber_) {
141  throw Exception(errors::MismatchedInputFiles, "PoolSource::checkForNewRun")
142  << " Parameter 'setRunNumberForEachLumi' can only process a single run.\n"
143  << "but this job is processing more than one run.\n";
144  }
146  }
147 
149 
151  id = LuminosityBlockID(runNumberToUseForThisLumi(), id.luminosityBlock());
152  }
153 
155  if (isRealData) {
156  throw Exception(errors::Configuration, "SetRunForEachLumiHelper::overrideRunNumber()")
157  << "The 'setRunNumberForEachLumi' parameter of PoolSource cannot be used with real data.\n";
158  }
159  id = EventID(runNumberToUseForThisLumi(), id.luminosityBlock(), id.event());
160  }
161 
164  }
165 
167  : lumiToRun_(pset.getUntrackedParameter<std::vector<edm::LuminosityBlockID>>("firstLuminosityBlockForEachRun")),
168  realRunNumber_{0},
169  lastUsedRunNumber_{0},
170  fakeNewRun_{false} {}
171 
173  InputSource::ItemType const& newItemType,
174  RunNumber_t,
176  EventNumber_t) {
177  if (newItemType == InputSource::IsLumi && previousItemType != InputSource::IsRun) {
178  auto run = findRunFromLumi(iLumi);
179  if (run == 0) {
180  throw Exception(errors::Configuration, "PoolSource")
181  << "'firstLuminosityBlockForEachRun' contains an illegal run number of '0'.\n";
182  }
183  if (lastUsedRunNumber_ != run) {
184  fakeNewRun_ = true;
186  return InputSource::IsRun;
187  }
188  }
189  return newItemType;
190  }
191 
193 
195  if (realRunNumber_ != 0 && run != realRunNumber_) {
196  throw Exception(errors::MismatchedInputFiles, "PoolSource::checkForNewRun")
197  << " Parameter 'firstLuminosityBlockForEachRun' can only process a single run.\n"
198  << "but this job is processing more than one run.\n";
199  }
202  fakeNewRun_ = false;
203  }
204 
206 
208  id = LuminosityBlockID(runNumberToUseForThisLumi(), id.luminosityBlock());
209  }
210 
212  if (isRealData) {
213  throw Exception(errors::Configuration, "FirstLuminosityBlockForEachRunHelper::overrideRunNumber()")
214  << "The 'firstLuminosityBlockForEachRun' parameter of PoolSource cannot be used with real data.\n";
215  }
216  id = EventID(runNumberToUseForThisLumi(), id.luminosityBlock(), id.event());
217  }
218 
221  }
222 
224  RunNumber_t run = 0;
225  for (auto const& lumiID : lumiToRun_) {
226  if (lumiID.luminosityBlock() > iLumi) {
227  break;
228  }
229  run = lumiID.run();
230  }
231  if (0 == run) {
232  throw Exception(errors::Configuration, "FirstLuminosityBlockForEachRunHelper::findRunFromLumi()")
233  << "The 'firstLuminosityBlockForEachRun' parameter does not have a matching Run number for LuminosityBlock "
234  "number: "
235  << iLumi << ".\n";
236  }
237  return run;
238  }
239 
241  desc.addOptionalNode(ParameterDescription<unsigned int>("setRunNumber", 0U, false) xor
242  ParameterDescription<std::vector<unsigned int>>(
243  "setRunNumberForEachLumi", std::vector<unsigned int>(), false) xor
244  ParameterDescription<std::vector<LuminosityBlockID>>(
245  "firstLuminosityBlockForEachRun", std::vector<LuminosityBlockID>(), false),
246  true)
247  ->setComment(
248  "If 'setRun' is non-zero, change number of first run to this number. Apply same offset to all runs."
249  "If 'setRunNumberForEachLumi' is non-empty, use these as run numbers for each lumi respectively."
250  "If 'firstLuminosityBlockForEachRun' is non-empty, the LuminosityBlock ID is used to determine which Run "
251  "ID to use. The entries must be ascending values of LuminosityBlock ID."
252  "''setRun', 'setRunNumberForEachLumi' and 'firstLuminosityBlockForEachRun' are mutually exclusive and "
253  "allowed only for simulation.");
254  }
255 } // namespace edm
dataset.firstRun
firstRun
Definition: dataset.py:940
edm::RunNumber_t
unsigned int RunNumber_t
Definition: RunLumiEventNumber.h:14
edm::FirstLuminosityBlockForEachRunHelper::lastUsedRunNumber_
RunNumber_t lastUsedRunNumber_
Definition: RunHelper.h:114
edm::errors::MismatchedInputFiles
Definition: EDMException.h:52
RunHelper.h
edm::RunHelperBase::~RunHelperBase
virtual ~RunHelperBase()
Definition: RunHelper.cc:33
edm::FirstLuminosityBlockForEachRunHelper::nextItemType
InputSource::ItemType nextItemType(InputSource::ItemType const &previousItemType, InputSource::ItemType const &newIemType, RunNumber_t, LuminosityBlockNumber_t, EventNumber_t) override
Definition: RunHelper.cc:172
edm::SetRunHelper::firstTime_
bool firstTime_
Definition: RunHelper.h:62
funct::false
false
Definition: Factorize.h:34
edm::RunID
Definition: RunID.h:28
edm::SetRunForEachLumiHelper::nextItemType
InputSource::ItemType nextItemType(InputSource::ItemType const &previousItemType, InputSource::ItemType const &newIemType, RunNumber_t, LuminosityBlockNumber_t, EventNumber_t) override
Definition: RunHelper.cc:104
edm::SetRunHelper::SetRunHelper
SetRunHelper(ParameterSet const &pset)
Definition: RunHelper.cc:45
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::FirstLuminosityBlockForEachRunHelper::lumiToRun_
const std::vector< edm::LuminosityBlockID > lumiToRun_
Definition: RunHelper.h:112
edm::SetRunForEachLumiHelper::SetRunForEachLumiHelper
SetRunForEachLumiHelper(ParameterSet const &pset)
Definition: RunHelper.cc:94
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
writedatasetfile.runs
runs
Definition: writedatasetfile.py:27
cms::cuda::assert
assert(be >=bs)
edm::FirstLuminosityBlockForEachRunHelper::fakeNewRun_
bool fakeNewRun_
Definition: RunHelper.h:115
edm::SetRunForEachLumiHelper::fakeNewRun_
bool fakeNewRun_
Definition: RunHelper.h:88
edm::FirstLuminosityBlockForEachRunHelper::FirstLuminosityBlockForEachRunHelper
FirstLuminosityBlockForEachRunHelper(ParameterSet const &pset)
Definition: RunHelper.cc:166
edm::FirstLuminosityBlockForEachRunHelper::findRunFromLumi
RunNumber_t findRunFromLumi(LuminosityBlockNumber_t) const
Definition: RunHelper.cc:223
edm::LuminosityBlockNumber_t
unsigned int LuminosityBlockNumber_t
Definition: RunLumiEventNumber.h:13
edm::FirstLuminosityBlockForEachRunHelper::runNumberToUseForThisLumi
RunNumber_t runNumberToUseForThisLumi() const override
Definition: RunHelper.cc:192
edm::SetRunHelper::forcedRunOffset_
int forcedRunOffset_
Definition: RunHelper.h:61
edm::RunHelperBase::fillDescription
static void fillDescription(ParameterSetDescription &desc)
Definition: RunHelper.cc:240
edm::InputSource::IsRun
Definition: InputSource.h:78
edm::FirstLuminosityBlockForEachRunHelper::overrideRunNumber
void overrideRunNumber(EventID &event, bool isRealData) override
Definition: RunHelper.cc:211
edm::ParameterSetDescription::addOptionalNode
ParameterDescriptionNode * addOptionalNode(ParameterDescriptionNode const &node, bool writeToCfi)
Definition: ParameterSetDescription.cc:50
EDMException.h
edm::SetRunForEachLumiHelper::setRunNumberForEachLumi_
std::vector< RunNumber_t > setRunNumberForEachLumi_
Definition: RunHelper.h:85
edm::SetRunHelper::setForcedRunOffset
void setForcedRunOffset(RunNumber_t firstRun) override
Definition: RunHelper.cc:53
edm::FirstLuminosityBlockForEachRunHelper::realRunNumber_
RunNumber_t realRunNumber_
Definition: RunHelper.h:113
edm::makeRunHelper
std::unique_ptr< RunHelperBase > makeRunHelper(ParameterSet const &pset)
Definition: RunHelper.cc:12
edm::EventNumber_t
unsigned long long EventNumber_t
Definition: RunLumiEventNumber.h:12
ParameterSetDescription.h
edm::LuminosityBlockID
Definition: LuminosityBlockID.h:31
edm::RunID::firstValidRun
static RunID firstValidRun()
Definition: RunID.h:58
mitigatedMETSequence_cff.U
U
Definition: mitigatedMETSequence_cff.py:36
edm::RunHelperBase::checkRunConsistency
virtual void checkRunConsistency(RunNumber_t run, RunNumber_t origninalRun) const
Definition: RunHelper.cc:39
edm::RunHelperBase
Definition: RunHelper.h:15
edm::SetRunForEachLumiHelper::~SetRunForEachLumiHelper
~SetRunForEachLumiHelper() override
Definition: RunHelper.cc:102
funct::true
true
Definition: Factorize.h:173
edm::ParameterSet
Definition: ParameterSet.h:36
edm::SetRunForEachLumiHelper::overrideRunNumber
void overrideRunNumber(EventID &event, bool isRealData) override
Definition: RunHelper.cc:154
edm::InputSource::IsLumi
Definition: InputSource.h:78
edm::SetRunHelper::setRun_
RunNumber_t setRun_
Definition: RunHelper.h:60
createfilelist.int
int
Definition: createfilelist.py:10
edm::SetRunForEachLumiHelper::checkRunConsistency
void checkRunConsistency(RunNumber_t run, RunNumber_t origninalRun) const override
Definition: RunHelper.cc:162
edm::SetRunForEachLumiHelper::indexOfNextRunNumber_
size_t indexOfNextRunNumber_
Definition: RunHelper.h:86
edm::SetRunForEachLumiHelper::runNumberToUseForThisLumi
RunNumber_t runNumberToUseForThisLumi() const override
Definition: RunHelper.cc:135
edm::SetRunForEachLumiHelper::checkForNewRun
void checkForNewRun(RunNumber_t run, LuminosityBlockNumber_t nextLumi) override
Definition: RunHelper.cc:139
edm::SetRunHelper::checkRunConsistency
void checkRunConsistency(RunNumber_t run, RunNumber_t origninalRun) const override
Definition: RunHelper.cc:90
edm::FirstLuminosityBlockForEachRunHelper::checkForNewRun
void checkForNewRun(RunNumber_t run, LuminosityBlockNumber_t nextLumi) override
Definition: RunHelper.cc:194
edm::DefaultRunHelper::~DefaultRunHelper
~DefaultRunHelper() override
Definition: RunHelper.cc:43
edm::InputSource::ItemType
ItemType
Definition: InputSource.h:78
std
Definition: JetResolutionObject.h:76
writedatasetfile.run
run
Definition: writedatasetfile.py:27
Exception
Definition: hltDiff.cc:246
edm::SetRunForEachLumiHelper::realRunNumber_
RunNumber_t realRunNumber_
Definition: RunHelper.h:87
edm::SetRunHelper::overrideRunNumber
void overrideRunNumber(EventID &event, bool isRealData) override
Definition: RunHelper.cc:78
edm::FirstLuminosityBlockForEachRunHelper::checkRunConsistency
void checkRunConsistency(RunNumber_t run, RunNumber_t originalRun) const override
Definition: RunHelper.cc:219
edm::RunHelperBase::checkLumiConsistency
virtual void checkLumiConsistency(LuminosityBlockNumber_t lumi, LuminosityBlockNumber_t origninalLumi) const
Definition: RunHelper.cc:35
edm::ParameterDescriptionNode::setComment
void setComment(std::string const &value)
Definition: ParameterDescriptionNode.cc:106
edm::SetRunForEachLumiHelper::firstTime_
bool firstTime_
Definition: RunHelper.h:89
edm::LuminosityBlockID::firstValidLuminosityBlock
static LuminosityBlockID firstValidLuminosityBlock()
Definition: LuminosityBlockID.h:86
edm::EventID
Definition: EventID.h:31
lumi
Definition: LumiSectionData.h:20
edm::SetRunHelper::~SetRunHelper
~SetRunHelper() override
Definition: RunHelper.cc:51
event
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
edm::ParameterDescription
Definition: ParameterDescription.h:110
edm::errors::Configuration
Definition: EDMException.h:36
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27