CMS 3D CMS Logo

CompactEventAuxiliaryVector.h
Go to the documentation of this file.
1 #ifndef DataFormats_Provenance_CompactEventAuxiliaryVector_h
2 #define DataFormats_Provenance_CompactEventAuxiliaryVector_h
3 
4 #include <vector>
5 #include <unordered_set>
6 
9 
10 namespace edm {
12  public:
16 
17  // These components of EventAuxiliary change infrequently, so
18  // they are stored in a std::unordered_set with a reference in
19  // CompactEventAuxiliary
21  public:
22  CompactEventAuxiliaryExtra(bool isReal, ExperimentType eType, int storeNum)
23  : processHistoryID_(), isRealData_(isReal), experimentType_(eType), storeNumber_(storeNum) {}
25  : processHistoryID_(ea.processHistoryID()),
26  isRealData_(ea.isRealData()),
27  experimentType_(ea.experimentType()),
28  storeNumber_(ea.storeNumber()) {}
29 
30  bool operator==(const CompactEventAuxiliaryExtra& extra) const {
31  return processHistoryID_ == extra.processHistoryID_ && isRealData_ == extra.isRealData_ &&
33  }
34  void write(std::ostream& os) const;
35 
36  // Process history ID of the full process history (not the reduced process history)
38  // Is this real data (i.e. not simulated)
40  // Something descriptive of the source of the data
42  // The LHC store number
44  };
45 
46  struct ExtraHash {
47  std::size_t operator()(CompactEventAuxiliaryExtra const& extra) const noexcept {
48  return hash_value(
49  extra.processHistoryID_.compactForm(), extra.isRealData_, extra.experimentType_, extra.storeNumber_);
50  }
51  };
52 
53  using GUIDmemo = std::unordered_set<std::string>;
54  using extraMemo = std::unordered_set<CompactEventAuxiliaryExtra, ExtraHash>;
55 
57  public:
59  std::string const& processGUID,
60  Timestamp const& theTime,
61  int bunchXing,
62  int orbitNum,
63  CompactEventAuxiliaryExtra const& extra,
64  GUIDmemo& guidmemo,
65  extraMemo& extramemo)
66  : id_(theId),
67  processGUID_(memoize(processGUID, guidmemo)),
68  time_(theTime),
69  bunchCrossing_(bunchXing),
70  orbitNumber_(orbitNum),
71  extra_(memoize(extra, extramemo)) {}
72  CompactEventAuxiliary(const EventAuxiliary& ea, GUIDmemo& guidmemo, extraMemo& extramemo)
73  : id_(ea.id()),
74  processGUID_(memoize(ea.processGUID(), guidmemo)),
75  time_(ea.time()),
78  extra_(memoize(CompactEventAuxiliaryExtra(ea), extramemo)) {}
79 
80  void write(std::ostream& os) const;
81 
83  EventID const& id() const { return id_; }
84  std::string const& processGUID() const { return processGUID_; }
85  Timestamp const& time() const { return time_; }
87  EventNumber_t event() const { return id_.event(); }
88  RunNumber_t run() const { return id_.run(); }
89  bool isRealData() const { return extra_.isRealData_; }
91  int bunchCrossing() const { return bunchCrossing_; }
92  int orbitNumber() const { return orbitNumber_; }
93  int storeNumber() const { return extra_.storeNumber_; }
94 
96  auto ea{EventAuxiliary(id_,
98  time_,
103  orbitNumber_)};
105  return ea;
106  }
107 
108  private:
109  template <typename T, typename C>
110  const T& memoize(const T& item, C& memopad) const {
111  auto it = memopad.insert(item);
112  return *it.first;
113  }
114 
115  // Event ID
117  // Globally unique process ID of process that created event.
119  // Time from DAQ
121  // The bunch crossing number
123  // The orbit number
125  // the stuff that changes slowly
127  };
128 
130  using iterator = std::vector<value_type>::iterator;
132  using const_iterator = std::vector<value_type>::const_iterator;
133 
134  size_type size() const { return compactAuxiliaries_.size(); }
135  void reserve(std::size_t size) { compactAuxiliaries_.reserve(size); }
136  const_iterator begin() const { return compactAuxiliaries_.begin(); }
137  const_iterator end() const { return compactAuxiliaries_.end(); }
138  const_iterator cbegin() const { return compactAuxiliaries_.cbegin(); }
139  const_iterator cend() const { return compactAuxiliaries_.cend(); }
140 
141  size_type extrasSize() const { return extras_.size(); }
142  size_type guidsSize() const { return processGUIDs_.size(); }
143 
144  void push_back(const EventAuxiliary& ea) { compactAuxiliaries_.emplace_back(ea, processGUIDs_, extras_); }
145 
146  private:
147  // Items that change every event
148  std::vector<CompactEventAuxiliary> compactAuxiliaries_;
149  // Items that change relatively infrequently
151  // Globally unique process IDs of processes that created events.
153  };
154 
155  inline std::ostream& operator<<(std::ostream& os, const CompactEventAuxiliaryVector::CompactEventAuxiliary& p) {
156  p.write(os);
157  return os;
158  }
159 
160  inline std::ostream& operator<<(std::ostream& os, const CompactEventAuxiliaryVector::CompactEventAuxiliaryExtra& p) {
161  p.write(os);
162  return os;
163  }
164 } // namespace edm
165 
166 #endif
std::vector< CompactEventAuxiliary > compactAuxiliaries_
std::unordered_set< std::string > GUIDmemo
std::vector< value_type >::iterator iterator
void push_back(const EventAuxiliary &ea)
std::vector< value_type >::size_type size_type
unsigned long long EventNumber_t
std::unordered_set< CompactEventAuxiliaryExtra, ExtraHash > extraMemo
bool operator==(const CompactEventAuxiliaryExtra &extra) const
uint16_t size_type
unsigned int LuminosityBlockNumber_t
CompactEventAuxiliary(const EventAuxiliary &ea, GUIDmemo &guidmemo, extraMemo &extramemo)
LuminosityBlockNumber_t luminosityBlock() const
Definition: EventID.h:39
std::vector< value_type >::const_iterator const_iterator
CompactEventAuxiliary(EventID const &theId, std::string const &processGUID, Timestamp const &theTime, int bunchXing, int orbitNum, CompactEventAuxiliaryExtra const &extra, GUIDmemo &guidmemo, extraMemo &extramemo)
CompactEventAuxiliaryExtra(bool isReal, ExperimentType eType, int storeNum)
static int const invalidBunchXing
std::size_t hash_value(const Types &... args)
Definition: hash_combine.h:36
std::size_t operator()(CompactEventAuxiliaryExtra const &extra) const noexcept
RunNumber_t run() const
Definition: EventID.h:38
void setProcessHistoryID(ProcessHistoryID const &phid)
static int const invalidStoreNumber
HLT enums.
unsigned int RunNumber_t
std::ostream & operator<<(std::ostream &ost, const HLTGlobalStatus &hlt)
Formatted printout of trigger tbale.
long double T
EventNumber_t event() const
Definition: EventID.h:40