CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes
edm::IDGeneratorSourceBase< BASE > Class Template Referenceabstract

#include <IDGeneratorSourceBase.h>

Inheritance diagram for edm::IDGeneratorSourceBase< BASE >:

Public Member Functions

EventNumber_t event () const
 
unsigned int eventCreationDelay () const
 
EventID const & eventID () const
 
 IDGeneratorSourceBase (ParameterSet const &pset, InputSourceDescription const &desc, bool realData)
 
LuminosityBlockNumber_t luminosityBlock () const
 
unsigned int numberEventsInLumi () const
 
unsigned int numberEventsInRun () const
 
unsigned int numberEventsInThisLumi () const
 
unsigned int numberEventsInThisRun () const
 
TimeValue_t presentTime () const
 
RunNumber_t run () const
 
unsigned int timeBetweenEvents () const
 
 ~IDGeneratorSourceBase () noexcept(false) override
 

Static Public Member Functions

static void fillDescription (ParameterSetDescription &desc)
 

Protected Member Functions

template<typename F >
void doReadEvent (EventPrincipal &eventPrincipal, F &&f)
 
void doReadEventWithDelayedReader (EventPrincipal &eventPrincipal, ProcessHistoryID const &historyID, EventSelectionIDVector eventSelectionIDs, BranchListIndexes branchListIndexes, DelayedReader *reader)
 

Private Member Functions

void advanceToNext (EventID &eventID, TimeValue_t &time)
 
void beginJob () override
 
virtual size_t fileIndex () const
 
BASE::ItemTypeInfo getNextItemType () final
 
virtual void initialize (EventID &id, TimeValue_t &time, TimeValue_t &interval)
 
virtual bool noFiles () const
 
std::shared_ptr< LuminosityBlockAuxiliaryreadLuminosityBlockAuxiliary_ () override
 
std::shared_ptr< RunAuxiliaryreadRunAuxiliary_ () override
 
void retreatToPrevious (EventID &eventID, TimeValue_t &time)
 
void rewind_ () override
 
RunNumber_t runForLumi (LuminosityBlockNumber_t) const
 
virtual bool setRunAndEventInfo (EventID &id, TimeValue_t &time, EventAuxiliary::ExperimentType &etype)=0
 
void skip (int offset) override
 

Private Attributes

EventAuxiliary::ExperimentType eType_
 
unsigned int eventCreationDelay_
 
EventID eventID_
 
std::vector< edm::LuminosityBlockIDfirstLumiForRuns_
 
bool isRealData_
 
unsigned int numberEventsInLumi_
 
unsigned int numberEventsInRun_
 
unsigned int numberEventsInThisLumi_
 
unsigned int numberEventsInThisRun_
 
EventID origEventID_
 
TimeValue_t origTime_
 
TimeValue_t presentTime_
 
TimeValue_t timeBetweenEvents_
 
EventNumber_t const zerothEvent_
 

Detailed Description

template<typename BASE>
class edm::IDGeneratorSourceBase< BASE >

Definition at line 24 of file IDGeneratorSourceBase.h.

Constructor & Destructor Documentation

◆ IDGeneratorSourceBase()

template<typename BASE >
edm::IDGeneratorSourceBase< BASE >::IDGeneratorSourceBase ( ParameterSet const &  pset,
InputSourceDescription const &  desc,
bool  realData 
)
explicit

Definition at line 42 of file IDGeneratorSourceBase.cc.

45  : BASE(pset, desc),
47  pset.getUntrackedParameter<std::vector<edm::LuminosityBlockID>>("firstLuminosityBlockForEachRun")),
48  numberEventsInRun_(pset.getUntrackedParameter<unsigned int>("numberEventsInRun", BASE::remainingEvents())),
50  pset.getUntrackedParameter<unsigned int>("numberEventsInLuminosityBlock", BASE::remainingEvents())),
51  presentTime_(pset.getUntrackedParameter<unsigned long long>("firstTime", 1ULL)), //time in ns
54  pset.getUntrackedParameter<unsigned long long>("timeBetweenEvents", kNanoSecPerSec / kAveEventPerSec)),
55  eventCreationDelay_(pset.getUntrackedParameter<unsigned int>("eventCreationDelay", 0)),
58  zerothEvent_(pset.existsAs<unsigned int>("firstEvent", false)
59  ? pset.getUntrackedParameter<unsigned int>("firstEvent", 1) - 1
60  : pset.getUntrackedParameter<unsigned long long>("firstEvent", 1) - 1),
61  eventID_(pset.getUntrackedParameter<unsigned int>("firstRun", 1),
62  pset.getUntrackedParameter<unsigned int>("firstLuminosityBlock", 1),
63  zerothEvent_),
65  isRealData_(realData),
67  BASE::setTimestamp(Timestamp(presentTime_));
68  checkFirstLumiForRuns(firstLumiForRuns_);
69  if (not firstLumiForRuns_.empty()) {
70  numberEventsInRun_ = -1;
72  }
73  }
static unsigned long long constexpr kAveEventPerSec
RunNumber_t runForLumi(LuminosityBlockNumber_t) const
LuminosityBlockNumber_t luminosityBlock() const
Definition: EventID.h:39
EventNumber_t const zerothEvent_
std::vector< edm::LuminosityBlockID > firstLumiForRuns_
static unsigned long long constexpr kNanoSecPerSec
EventAuxiliary::ExperimentType eType_

◆ ~IDGeneratorSourceBase()

template<typename BASE >
edm::IDGeneratorSourceBase< BASE >::~IDGeneratorSourceBase ( )
overridenoexcept

Definition at line 76 of file IDGeneratorSourceBase.cc.

76 {}

Member Function Documentation

◆ advanceToNext()

template<typename BASE >
void edm::IDGeneratorSourceBase< BASE >::advanceToNext ( EventID eventID,
TimeValue_t time 
)
private

Definition at line 178 of file IDGeneratorSourceBase.cc.

178  {
180  // same run
183  // new lumi
186  if (not firstLumiForRuns_.empty()) {
188  if (run != eventID.run()) {
191 
192  eventID = EventID(run, eventID.luminosityBlock(), eventID.event());
193  }
194  }
195  } else {
198  }
199  } else {
200  // new run
204  }
206  }
RunNumber_t runForLumi(LuminosityBlockNumber_t) const
EventID next(LuminosityBlockNumber_t const &lumi) const
Definition: EventID.h:43
EventID const & eventID() const
LuminosityBlockNumber_t luminosityBlock() const
Definition: EventID.h:39
RunNumber_t run() const
Definition: EventID.h:38
EventID nextRunFirstEvent(LuminosityBlockNumber_t const &lumi) const
Definition: EventID.h:50
std::vector< edm::LuminosityBlockID > firstLumiForRuns_
EventNumber_t event() const
Definition: EventID.h:40

◆ beginJob()

template<typename BASE >
void edm::IDGeneratorSourceBase< BASE >::beginJob ( void  )
overrideprivate

Definition at line 116 of file IDGeneratorSourceBase.cc.

116  {
117  BASE::beginJob();
118  // Initialize cannot be called from the constructor, because it is a virtual function
119  // that needs to be invoked from a derived class if the derived class overrides it.
121  }
virtual void initialize(EventID &id, TimeValue_t &time, TimeValue_t &interval)
void beginJob()
Definition: Breakpoints.cc:14

◆ doReadEvent()

template<typename BASE>
template<typename F >
void edm::IDGeneratorSourceBase< BASE >::doReadEvent ( EventPrincipal eventPrincipal,
F &&  f 
)
inlineprotected

Definition at line 45 of file IDGeneratorSourceBase.h.

45  {
46  assert(BASE::eventCached() || BASE::processingMode() != BASE::RunsLumisAndEvents);
48  auto history = BASE::processHistoryRegistry().getMapped(aux.processHistoryID());
49  eventPrincipal.fillEventPrincipal(aux, history);
50  f(eventPrincipal);
51  BASE::resetEventCached();
52  }
Guid const & processGUID()
Definition: processGUID.cc:4
assert(be >=bs)
double f[11][100]
EventAuxiliary::ExperimentType eType_

◆ doReadEventWithDelayedReader()

template<typename BASE>
void edm::IDGeneratorSourceBase< BASE >::doReadEventWithDelayedReader ( EventPrincipal eventPrincipal,
ProcessHistoryID const &  historyID,
EventSelectionIDVector  eventSelectionIDs,
BranchListIndexes  branchListIndexes,
DelayedReader reader 
)
inlineprotected

Definition at line 54 of file IDGeneratorSourceBase.h.

58  {
59  assert(BASE::eventCached() || BASE::processingMode() != BASE::RunsLumisAndEvents);
61  aux.setProcessHistoryID(historyID);
62  auto history = BASE::processHistoryRegistry().getMapped(aux.processHistoryID());
63  eventPrincipal.fillEventPrincipal(
64  aux, history, std::move(eventSelectionIDs), std::move(branchListIndexes), reader);
65  BASE::resetEventCached();
66  }
Guid const & processGUID()
Definition: processGUID.cc:4
assert(be >=bs)
def move(src, dest)
Definition: eostools.py:511
EventAuxiliary::ExperimentType eType_

◆ event()

template<typename BASE>
EventNumber_t edm::IDGeneratorSourceBase< BASE >::event ( ) const
inline

Definition at line 38 of file IDGeneratorSourceBase.h.

38 { return eventID_.event(); }
EventNumber_t event() const
Definition: EventID.h:40

◆ eventCreationDelay()

template<typename BASE>
unsigned int edm::IDGeneratorSourceBase< BASE >::eventCreationDelay ( ) const
inline

Definition at line 33 of file IDGeneratorSourceBase.h.

33 { return eventCreationDelay_; }

◆ eventID()

template<typename BASE>
EventID const& edm::IDGeneratorSourceBase< BASE >::eventID ( ) const
inline

Definition at line 36 of file IDGeneratorSourceBase.h.

◆ fileIndex()

template<typename BASE >
size_t edm::IDGeneratorSourceBase< BASE >::fileIndex ( ) const
privatevirtual

Reimplemented in edm::ProducerSourceFromFiles.

Definition at line 259 of file IDGeneratorSourceBase.cc.

259  {
260  return 0UL;
261  }

◆ fillDescription()

template<typename BASE >
void edm::IDGeneratorSourceBase< BASE >::fillDescription ( ParameterSetDescription desc)
static

Definition at line 264 of file IDGeneratorSourceBase.cc.

Referenced by edm::EmptySource::fillDescriptions(), and edm::DelayedReaderThrowingSource::fillDescriptions().

264  {
265  desc.addOptionalUntracked<unsigned int>("numberEventsInRun")
266  ->setComment("Number of events to generate in each run.");
267  desc.addOptionalUntracked<unsigned int>("numberEventsInLuminosityBlock")
268  ->setComment("Number of events to generate in each lumi.");
269  desc.addUntracked<unsigned long long>("firstTime", 1)->setComment("Time before first event (ns) (for timestamp).");
270  desc.addUntracked<unsigned long long>("timeBetweenEvents", kNanoSecPerSec / kAveEventPerSec)
271  ->setComment("Time between consecutive events (ns) (for timestamp).");
272  desc.addUntracked<unsigned int>("eventCreationDelay", 0)
273  ->setComment("Real time delay between generation of consecutive events (ms).");
274 
275  desc.addNode(edm::ParameterDescription<unsigned int>("firstEvent", 1U, false) xor
276  edm::ParameterDescription<unsigned long long>("firstEvent", 1ULL, false))
277  ->setComment(
278  "'firstEvent' is an XOR group because it can have type uint32 or uint64, default:1\n"
279  "Event number of first event to generate.");
280 
281  desc.addUntracked<unsigned int>("firstLuminosityBlock", 1)
282  ->setComment("Luminosity block number of first lumi to generate.");
283  desc.addUntracked<unsigned int>("firstRun", 1)->setComment("Run number of first run to generate.");
284  desc.addUntracked<std::vector<edm::LuminosityBlockID>>("firstLuminosityBlockForEachRun", {})
285  ->setComment(
286  "When the source makes a new LuminosityBlock, this list is checked to see what Run number should be used. "
287  "The LuminosityBlock numbers are required to be in ascending order.");
288  BASE::fillDescription(desc);
289  }
static unsigned long long constexpr kAveEventPerSec
static unsigned long long constexpr kNanoSecPerSec

◆ getNextItemType()

template<typename BASE >
BASE::ItemTypeInfo edm::IDGeneratorSourceBase< BASE >::getNextItemType ( )
finalprivate

Definition at line 137 of file IDGeneratorSourceBase.cc.

137  {
138  if (BASE::state() == BASE::ItemType::IsInvalid) {
139  return noFiles() ? BASE::ItemType::IsStop : BASE::ItemType::IsFile;
140  }
141  if (BASE::newRun()) {
142  return BASE::ItemType::IsRun;
143  }
144  if (BASE::newLumi()) {
145  return BASE::ItemType::IsLumi;
146  }
147  if (BASE::eventCached()) {
148  return BASE::ItemType::IsEvent;
149  }
150  EventID oldEventID = eventID_;
152  if (eventCreationDelay_ > 0) {
153  std::this_thread::sleep_for(std::chrono::microseconds(eventCreationDelay_));
154  }
155  size_t index = fileIndex();
157  if (!another) {
158  return BASE::ItemType::IsStop;
159  }
160  bool newFile = (fileIndex() > index);
161  BASE::setEventCached();
162  if (BASE::newRun() || eventID_.run() != oldEventID.run()) {
163  // New Run
164  BASE::setNewRun();
165  BASE::setNewLumi();
166  return newFile ? BASE::ItemType::IsFile : BASE::ItemType::IsRun;
167  }
168  // Same Run
169  if (BASE::newLumi() || eventID_.luminosityBlock() != oldEventID.luminosityBlock()) {
170  // New Lumi
171  BASE::setNewLumi();
172  return newFile ? BASE::ItemType::IsFile : BASE::ItemType::IsLumi;
173  }
174  return newFile ? BASE::ItemType::IsFile : BASE::ItemType::IsEvent;
175  }
LuminosityBlockNumber_t luminosityBlock() const
Definition: EventID.h:39
virtual bool setRunAndEventInfo(EventID &id, TimeValue_t &time, EventAuxiliary::ExperimentType &etype)=0
virtual size_t fileIndex() const
RunNumber_t run() const
Definition: EventID.h:38
void advanceToNext(EventID &eventID, TimeValue_t &time)
EventAuxiliary::ExperimentType eType_

◆ initialize()

template<typename BASE >
void edm::IDGeneratorSourceBase< BASE >::initialize ( EventID id,
TimeValue_t time,
TimeValue_t interval 
)
privatevirtual

Reimplemented in cond::FileBasedEmptySource, and cond::EmptyIOVSource.

Definition at line 124 of file IDGeneratorSourceBase.cc.

124 {}

◆ luminosityBlock()

template<typename BASE>
LuminosityBlockNumber_t edm::IDGeneratorSourceBase< BASE >::luminosityBlock ( ) const
inline

Definition at line 39 of file IDGeneratorSourceBase.h.

39 { return eventID_.luminosityBlock(); }
LuminosityBlockNumber_t luminosityBlock() const
Definition: EventID.h:39

◆ noFiles()

template<typename BASE >
bool edm::IDGeneratorSourceBase< BASE >::noFiles ( ) const
privatevirtual

Definition at line 254 of file IDGeneratorSourceBase.cc.

254  {
255  return false;
256  }

◆ numberEventsInLumi()

template<typename BASE>
unsigned int edm::IDGeneratorSourceBase< BASE >::numberEventsInLumi ( ) const
inline

Definition at line 30 of file IDGeneratorSourceBase.h.

30 { return numberEventsInLumi_; }

◆ numberEventsInRun()

template<typename BASE>
unsigned int edm::IDGeneratorSourceBase< BASE >::numberEventsInRun ( ) const
inline

Definition at line 29 of file IDGeneratorSourceBase.h.

29 { return numberEventsInRun_; }

◆ numberEventsInThisLumi()

template<typename BASE>
unsigned int edm::IDGeneratorSourceBase< BASE >::numberEventsInThisLumi ( ) const
inline

Definition at line 35 of file IDGeneratorSourceBase.h.

◆ numberEventsInThisRun()

template<typename BASE>
unsigned int edm::IDGeneratorSourceBase< BASE >::numberEventsInThisRun ( ) const
inline

Definition at line 34 of file IDGeneratorSourceBase.h.

◆ presentTime()

template<typename BASE>
TimeValue_t edm::IDGeneratorSourceBase< BASE >::presentTime ( ) const
inline

Definition at line 31 of file IDGeneratorSourceBase.h.

31 { return presentTime_; }

◆ readLuminosityBlockAuxiliary_()

template<typename BASE >
std::shared_ptr< LuminosityBlockAuxiliary > edm::IDGeneratorSourceBase< BASE >::readLuminosityBlockAuxiliary_ ( )
overrideprivate

Definition at line 86 of file IDGeneratorSourceBase.cc.

86  {
87  if (BASE::processingMode() == BASE::Runs)
88  return std::shared_ptr<LuminosityBlockAuxiliary>();
90  BASE::resetNewLumi();
91  return std::make_shared<LuminosityBlockAuxiliary>(
93  }
static Timestamp invalidTimestamp()
Definition: Timestamp.h:75
LuminosityBlockNumber_t luminosityBlock() const
Definition: EventID.h:39
RunNumber_t run() const
Definition: EventID.h:38

◆ readRunAuxiliary_()

template<typename BASE >
std::shared_ptr< RunAuxiliary > edm::IDGeneratorSourceBase< BASE >::readRunAuxiliary_ ( )
overrideprivate

Definition at line 79 of file IDGeneratorSourceBase.cc.

79  {
81  BASE::resetNewRun();
82  return std::make_shared<RunAuxiliary>(eventID_.run(), ts, Timestamp::invalidTimestamp());
83  }
static Timestamp invalidTimestamp()
Definition: Timestamp.h:75
RunNumber_t run() const
Definition: EventID.h:38

◆ retreatToPrevious()

template<typename BASE >
void edm::IDGeneratorSourceBase< BASE >::retreatToPrevious ( EventID eventID,
TimeValue_t time 
)
private

Definition at line 209 of file IDGeneratorSourceBase.cc.

209  {
210  if (numberEventsInRun_ < 1 || numberEventsInThisRun_ > 0) {
211  // same run
214  if (!(numberEventsInLumi_ < 1 || numberEventsInThisLumi_ > 0)) {
215  // new lumi
218 
219  if (not firstLumiForRuns_.empty()) {
221  if (run != eventID.run()) {
223 
224  eventID = EventID(run, eventID.luminosityBlock(), eventID.event());
225  }
226  }
227  } else {
229  }
230  } else {
231  // new run
237  }
239  }
RunNumber_t runForLumi(LuminosityBlockNumber_t) const
EventID const & eventID() const
assert(be >=bs)
LuminosityBlockNumber_t luminosityBlock() const
Definition: EventID.h:39
EventID previous(LuminosityBlockNumber_t const &lumi) const
Definition: EventID.h:58
RunNumber_t run() const
Definition: EventID.h:38
EventID previousRunLastEvent(LuminosityBlockNumber_t const &lumi) const
Definition: EventID.h:51
std::vector< edm::LuminosityBlockID > firstLumiForRuns_
EventNumber_t event() const
Definition: EventID.h:40

◆ rewind_()

template<typename BASE >
void edm::IDGeneratorSourceBase< BASE >::rewind_ ( )
overrideprivate

Definition at line 127 of file IDGeneratorSourceBase.cc.

127  {
132  BASE::setNewRun();
133  BASE::setNewLumi();
134  }

◆ run()

template<typename BASE>
RunNumber_t edm::IDGeneratorSourceBase< BASE >::run ( ) const
inline

Definition at line 37 of file IDGeneratorSourceBase.h.

37 { return eventID_.run(); }
RunNumber_t run() const
Definition: EventID.h:38

◆ runForLumi()

template<typename BASE >
RunNumber_t edm::IDGeneratorSourceBase< BASE >::runForLumi ( LuminosityBlockNumber_t  iLumi) const
private

Definition at line 242 of file IDGeneratorSourceBase.cc.

242  {
243  auto it = std::find_if(firstLumiForRuns_.rbegin(), firstLumiForRuns_.rend(), [iLumi](auto const& iV) {
244  return iV.luminosityBlock() <= iLumi;
245  });
246  if (it == firstLumiForRuns_.rend()) {
247  //use first since we are off the end
248  return firstLumiForRuns_[0].run();
249  }
250  return it->run();
251  }
std::vector< edm::LuminosityBlockID > firstLumiForRuns_

◆ setRunAndEventInfo()

template<typename BASE>
virtual bool edm::IDGeneratorSourceBase< BASE >::setRunAndEventInfo ( EventID id,
TimeValue_t time,
EventAuxiliary::ExperimentType etype 
)
privatepure virtual

◆ skip()

template<typename BASE >
void edm::IDGeneratorSourceBase< BASE >::skip ( int  offset)
overrideprivate

Definition at line 96 of file IDGeneratorSourceBase.cc.

96  {
97  EventID oldEventID = eventID_;
98  for (; offset < 0; ++offset) {
100  }
101  for (; offset > 0; --offset) {
103  }
104  if (eventID_.run() != oldEventID.run()) {
105  // New Run
106  BASE::setNewRun();
107  BASE::setNewLumi();
108  }
109  if (eventID_.luminosityBlock() != oldEventID.luminosityBlock()) {
110  // New Lumi
111  BASE::setNewLumi();
112  }
113  }
LuminosityBlockNumber_t luminosityBlock() const
Definition: EventID.h:39
void retreatToPrevious(EventID &eventID, TimeValue_t &time)
RunNumber_t run() const
Definition: EventID.h:38
void advanceToNext(EventID &eventID, TimeValue_t &time)

◆ timeBetweenEvents()

template<typename BASE>
unsigned int edm::IDGeneratorSourceBase< BASE >::timeBetweenEvents ( ) const
inline

Definition at line 32 of file IDGeneratorSourceBase.h.

32 { return timeBetweenEvents_; }

Member Data Documentation

◆ eType_

template<typename BASE>
EventAuxiliary::ExperimentType edm::IDGeneratorSourceBase< BASE >::eType_
private

◆ eventCreationDelay_

template<typename BASE>
unsigned int edm::IDGeneratorSourceBase< BASE >::eventCreationDelay_
private

◆ eventID_

template<typename BASE>
EventID edm::IDGeneratorSourceBase< BASE >::eventID_
private

◆ firstLumiForRuns_

template<typename BASE>
std::vector<edm::LuminosityBlockID> edm::IDGeneratorSourceBase< BASE >::firstLumiForRuns_
private

Definition at line 85 of file IDGeneratorSourceBase.h.

◆ isRealData_

template<typename BASE>
bool edm::IDGeneratorSourceBase< BASE >::isRealData_
private

◆ numberEventsInLumi_

template<typename BASE>
unsigned int edm::IDGeneratorSourceBase< BASE >::numberEventsInLumi_
private

◆ numberEventsInRun_

template<typename BASE>
unsigned int edm::IDGeneratorSourceBase< BASE >::numberEventsInRun_
private

◆ numberEventsInThisLumi_

template<typename BASE>
unsigned int edm::IDGeneratorSourceBase< BASE >::numberEventsInThisLumi_
private

◆ numberEventsInThisRun_

template<typename BASE>
unsigned int edm::IDGeneratorSourceBase< BASE >::numberEventsInThisRun_
private

◆ origEventID_

template<typename BASE>
EventID edm::IDGeneratorSourceBase< BASE >::origEventID_
private

Definition at line 97 of file IDGeneratorSourceBase.h.

◆ origTime_

template<typename BASE>
TimeValue_t edm::IDGeneratorSourceBase< BASE >::origTime_
private

Definition at line 89 of file IDGeneratorSourceBase.h.

◆ presentTime_

template<typename BASE>
TimeValue_t edm::IDGeneratorSourceBase< BASE >::presentTime_
private

◆ timeBetweenEvents_

template<typename BASE>
TimeValue_t edm::IDGeneratorSourceBase< BASE >::timeBetweenEvents_
private

◆ zerothEvent_

template<typename BASE>
EventNumber_t const edm::IDGeneratorSourceBase< BASE >::zerothEvent_
private

Definition at line 95 of file IDGeneratorSourceBase.h.