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::ItemType 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 41 of file IDGeneratorSourceBase.cc.

44  : BASE(pset, desc),
46  pset.getUntrackedParameter<std::vector<edm::LuminosityBlockID>>("firstLuminosityBlockForEachRun")),
47  numberEventsInRun_(pset.getUntrackedParameter<unsigned int>("numberEventsInRun", BASE::remainingEvents())),
49  pset.getUntrackedParameter<unsigned int>("numberEventsInLuminosityBlock", BASE::remainingEvents())),
50  presentTime_(pset.getUntrackedParameter<unsigned long long>("firstTime", 1ULL)), //time in ns
53  pset.getUntrackedParameter<unsigned long long>("timeBetweenEvents", kNanoSecPerSec / kAveEventPerSec)),
54  eventCreationDelay_(pset.getUntrackedParameter<unsigned int>("eventCreationDelay", 0)),
57  zerothEvent_(pset.existsAs<unsigned int>("firstEvent", false)
58  ? pset.getUntrackedParameter<unsigned int>("firstEvent", 1) - 1
59  : pset.getUntrackedParameter<unsigned long long>("firstEvent", 1) - 1),
60  eventID_(pset.getUntrackedParameter<unsigned int>("firstRun", 1),
61  pset.getUntrackedParameter<unsigned int>("firstLuminosityBlock", 1),
62  zerothEvent_),
64  isRealData_(realData),
66  BASE::setTimestamp(Timestamp(presentTime_));
67  checkFirstLumiForRuns(firstLumiForRuns_);
68  if (not firstLumiForRuns_.empty()) {
69  numberEventsInRun_ = -1;
71  }
72  }
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 75 of file IDGeneratorSourceBase.cc.

75 {}

Member Function Documentation

◆ advanceToNext()

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

Definition at line 177 of file IDGeneratorSourceBase.cc.

177  {
179  // same run
182  // new lumi
185  if (not firstLumiForRuns_.empty()) {
187  if (run != eventID.run()) {
190 
191  eventID = EventID(run, eventID.luminosityBlock(), eventID.event());
192  }
193  }
194  } else {
197  }
198  } else {
199  // new run
203  }
205  }
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 115 of file IDGeneratorSourceBase.cc.

115  {
116  BASE::beginJob();
117  // Initialize cannot be called from the constructor, because it is a virtual function
118  // that needs to be invoked from a derived class if the derived class overrides it.
120  }
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  }
reader
Definition: DQM.py:105
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 258 of file IDGeneratorSourceBase.cc.

258  {
259  return 0UL;
260  }

◆ fillDescription()

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

Definition at line 263 of file IDGeneratorSourceBase.cc.

Referenced by edm::EmptySource::fillDescriptions().

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

◆ getNextItemType()

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

Definition at line 136 of file IDGeneratorSourceBase.cc.

136  {
137  if (BASE::state() == BASE::IsInvalid) {
138  return noFiles() ? BASE::IsStop : BASE::IsFile;
139  }
140  if (BASE::newRun()) {
141  return BASE::IsRun;
142  }
143  if (BASE::newLumi()) {
144  return BASE::IsLumi;
145  }
146  if (BASE::eventCached()) {
147  return BASE::IsEvent;
148  }
149  EventID oldEventID = eventID_;
151  if (eventCreationDelay_ > 0) {
152  usleep(eventCreationDelay_);
153  }
154  size_t index = fileIndex();
156  if (!another) {
157  return BASE::IsStop;
158  }
159  bool newFile = (fileIndex() > index);
160  BASE::setEventCached();
161  if (BASE::newRun() || eventID_.run() != oldEventID.run()) {
162  // New Run
163  BASE::setNewRun();
164  BASE::setNewLumi();
165  return newFile ? BASE::IsFile : BASE::IsRun;
166  }
167  // Same Run
168  if (BASE::newLumi() || eventID_.luminosityBlock() != oldEventID.luminosityBlock()) {
169  // New Lumi
170  BASE::setNewLumi();
171  return newFile ? BASE::IsFile : BASE::IsLumi;
172  }
173  return newFile ? BASE::IsFile : BASE::IsEvent;
174  }
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 123 of file IDGeneratorSourceBase.cc.

123 {}

◆ 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 253 of file IDGeneratorSourceBase.cc.

253  {
254  return false;
255  }

◆ 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 85 of file IDGeneratorSourceBase.cc.

85  {
86  if (BASE::processingMode() == BASE::Runs)
87  return std::shared_ptr<LuminosityBlockAuxiliary>();
89  BASE::resetNewLumi();
90  return std::make_shared<LuminosityBlockAuxiliary>(
92  }
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 78 of file IDGeneratorSourceBase.cc.

78  {
80  BASE::resetNewRun();
81  return std::make_shared<RunAuxiliary>(eventID_.run(), ts, Timestamp::invalidTimestamp());
82  }
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 208 of file IDGeneratorSourceBase.cc.

208  {
209  if (numberEventsInRun_ < 1 || numberEventsInThisRun_ > 0) {
210  // same run
213  if (!(numberEventsInLumi_ < 1 || numberEventsInThisLumi_ > 0)) {
214  // new lumi
217 
218  if (not firstLumiForRuns_.empty()) {
220  if (run != eventID.run()) {
222 
223  eventID = EventID(run, eventID.luminosityBlock(), eventID.event());
224  }
225  }
226  } else {
228  }
229  } else {
230  // new run
236  }
238  }
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 126 of file IDGeneratorSourceBase.cc.

126  {
131  BASE::setNewRun();
132  BASE::setNewLumi();
133  }

◆ run()

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

Definition at line 37 of file IDGeneratorSourceBase.h.

Referenced by edm::IDGeneratorSourceBase< PuttableSourceBase >::runForLumi().

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 241 of file IDGeneratorSourceBase.cc.

241  {
242  auto it = std::find_if(firstLumiForRuns_.rbegin(), firstLumiForRuns_.rend(), [iLumi](auto const& iV) {
243  return iV.luminosityBlock() <= iLumi;
244  });
245  if (it == firstLumiForRuns_.rend()) {
246  //use first since we are off the end
247  return firstLumiForRuns_[0].run();
248  }
249  return it->run();
250  }
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 95 of file IDGeneratorSourceBase.cc.

95  {
96  EventID oldEventID = eventID_;
97  for (; offset < 0; ++offset) {
99  }
100  for (; offset > 0; --offset) {
102  }
103  if (eventID_.run() != oldEventID.run()) {
104  // New Run
105  BASE::setNewRun();
106  BASE::setNewLumi();
107  }
108  if (eventID_.luminosityBlock() != oldEventID.luminosityBlock()) {
109  // New Lumi
110  BASE::setNewLumi();
111  }
112  }
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.