1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
#ifndef Framework_Sources_IDGeneratorSourceBase_h
#define Framework_Sources_IDGeneratorSourceBase_h
/*----------------------------------------------------------------------
----------------------------------------------------------------------*/
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/EventPrincipal.h"
#include "DataFormats/Provenance/interface/EventAuxiliary.h"
#include "DataFormats/Provenance/interface/EventID.h"
#include "DataFormats/Provenance/interface/Timestamp.h"
#include "DataFormats/Provenance/interface/RunID.h"
#include "DataFormats/Provenance/interface/LuminosityBlockID.h"
#include "DataFormats/Provenance/interface/RunLumiEventNumber.h"
#include "DataFormats/Provenance/interface/ProcessHistoryRegistry.h"
#include <memory>
#include <vector>
namespace edm {
class ParameterSet;
class ParameterSetDescription;
template <typename BASE>
class IDGeneratorSourceBase : public BASE {
public:
explicit IDGeneratorSourceBase(ParameterSet const& pset, InputSourceDescription const& desc, bool realData);
~IDGeneratorSourceBase() noexcept(false) override;
unsigned int numberEventsInRun() const { return numberEventsInRun_; }
unsigned int numberEventsInLumi() const { return numberEventsInLumi_; }
TimeValue_t presentTime() const { return presentTime_; }
unsigned int timeBetweenEvents() const { return timeBetweenEvents_; }
unsigned int eventCreationDelay() const { return eventCreationDelay_; }
unsigned int numberEventsInThisRun() const { return numberEventsInThisRun_; }
unsigned int numberEventsInThisLumi() const { return numberEventsInThisLumi_; }
EventID const& eventID() const { return eventID_; }
RunNumber_t run() const { return eventID_.run(); }
EventNumber_t event() const { return eventID_.event(); }
LuminosityBlockNumber_t luminosityBlock() const { return eventID_.luminosityBlock(); }
static void fillDescription(ParameterSetDescription& desc);
protected:
template <typename F>
void doReadEvent(EventPrincipal& eventPrincipal, F&& f) {
assert(BASE::eventCached() || BASE::processingMode() != BASE::RunsLumisAndEvents);
EventAuxiliary aux(eventID_, BASE::processGUID(), Timestamp(presentTime_), isRealData_, eType_);
auto history = BASE::processHistoryRegistry().getMapped(aux.processHistoryID());
eventPrincipal.fillEventPrincipal(aux, history);
f(eventPrincipal);
BASE::resetEventCached();
}
void doReadEventWithDelayedReader(EventPrincipal& eventPrincipal,
ProcessHistoryID const& historyID,
EventSelectionIDVector eventSelectionIDs,
BranchListIndexes branchListIndexes,
DelayedReader* reader) {
assert(BASE::eventCached() || BASE::processingMode() != BASE::RunsLumisAndEvents);
EventAuxiliary aux(eventID_, BASE::processGUID(), Timestamp(presentTime_), isRealData_, eType_);
aux.setProcessHistoryID(historyID);
auto history = BASE::processHistoryRegistry().getMapped(aux.processHistoryID());
eventPrincipal.fillEventPrincipal(
aux, history, std::move(eventSelectionIDs), std::move(branchListIndexes), reader);
BASE::resetEventCached();
}
private:
typename BASE::ItemTypeInfo getNextItemType() final;
virtual void initialize(EventID& id, TimeValue_t& time, TimeValue_t& interval);
virtual bool setRunAndEventInfo(EventID& id, TimeValue_t& time, EventAuxiliary::ExperimentType& etype) = 0;
virtual bool noFiles() const;
virtual size_t fileIndex() const;
void beginJob(ProductRegistry const&) override;
std::shared_ptr<LuminosityBlockAuxiliary> readLuminosityBlockAuxiliary_() override;
std::shared_ptr<RunAuxiliary> readRunAuxiliary_() override;
void skip(int offset) override;
void rewind_() override;
void advanceToNext(EventID& eventID, TimeValue_t& time);
void retreatToPrevious(EventID& eventID, TimeValue_t& time);
RunNumber_t runForLumi(LuminosityBlockNumber_t) const;
std::vector<edm::LuminosityBlockID> firstLumiForRuns_;
unsigned int numberEventsInRun_;
unsigned int numberEventsInLumi_;
TimeValue_t presentTime_;
TimeValue_t origTime_;
TimeValue_t timeBetweenEvents_;
unsigned int eventCreationDelay_; /* microseconds */
unsigned int numberEventsInThisRun_;
unsigned int numberEventsInThisLumi_;
EventNumber_t const zerothEvent_;
EventID eventID_;
EventID origEventID_;
bool isRealData_;
EventAuxiliary::ExperimentType eType_;
};
} // namespace edm
#endif
|