CMS 3D CMS Logo

EventPrincipal.h
Go to the documentation of this file.
1 #ifndef FWCore_Framework_EventPrincipal_h
2 #define FWCore_Framework_EventPrincipal_h
3 
4 /*----------------------------------------------------------------------
5 
6 EventPrincipal: This is the class responsible for management of
7 per event EDProducts. It is not seen by reconstruction code;
8 such code sees the Event class, which is a proxy for EventPrincipal.
9 
10 The major internal component of the EventPrincipal
11 is the DataBlock.
12 
13 ----------------------------------------------------------------------*/
14 
26 
27 #include <map>
28 #include <memory>
29 #include <string>
30 #include <vector>
31 #include <optional>
32 
33 namespace edm {
34  class BranchID;
35  class BranchIDListHelper;
36  class ProductProvenanceRetriever;
37  class DelayedReader;
38  class EventID;
39  class HistoryAppender;
40  class LuminosityBlockPrincipal;
41  class ModuleCallingContext;
42  class ProductID;
43  class StreamContext;
44  class ThinnedAssociation;
45  class ThinnedAssociationsHelper;
46  class RunPrincipal;
47 
48  class EventPrincipal : public Principal {
49  public:
51  typedef Principal Base;
52 
56  EventPrincipal(std::shared_ptr<ProductRegistry const> reg,
57  std::shared_ptr<BranchIDListHelper const> branchIDListHelper,
58  std::shared_ptr<ThinnedAssociationsHelper const> thinnedAssociationsHelper,
59  ProcessConfiguration const& pc,
60  HistoryAppender* historyAppender,
61  unsigned int streamIndex = 0,
62  bool isForPrimaryProcess = true,
63  ProcessBlockHelperBase const* processBlockHelper = nullptr);
64  ~EventPrincipal() override {}
65 
68  DelayedReader* reader = nullptr);
73  DelayedReader* reader = nullptr);
74  //provRetriever is changed via a call to ProductProvenanceRetriever::deepSwap
80  ProductProvenanceRetriever const& provRetriever,
81  DelayedReader* reader = nullptr,
82  bool deepCopyRetriever = true);
83 
84  void clearEventPrincipal();
85 
87 
89 
90  bool luminosityBlockPrincipalPtrValid() const { return luminosityBlockPrincipal_ != nullptr; }
91 
92  //does not share ownership
94 
96 
97  EventID const& id() const { return aux().id(); }
98 
99  Timestamp const& time() const { return aux().time(); }
100 
101  bool isReal() const { return aux().isRealData(); }
102 
104 
105  int bunchCrossing() const { return aux().bunchCrossing(); }
106 
107  int storeNumber() const { return aux().storeNumber(); }
108 
109  EventAuxiliary const& aux() const { return aux_; }
110 
111  StreamID streamID() const { return streamID_; }
112 
114 
115  RunNumber_t run() const { return id().run(); }
116 
117  RunPrincipal const& runPrincipal() const;
118 
120 
122 
123  BranchListIndexes const& branchListIndexes() const;
124 
126 
127  Provenance const& getProvenance(ProductID const& pid) const;
128  StableProvenance const& getStableProvenance(ProductID const& pid) const;
129 
130  BasicHandle getByProductID(ProductID const& oid) const;
131 
132  void put(BranchDescription const& bd,
133  std::unique_ptr<WrapperBase> edp,
134  ProductProvenance const& productProvenance) const;
135 
136  void put(ProductResolverIndex index, std::unique_ptr<WrapperBase> edp, ParentageID productProvenance) const;
137 
138  void putOnRead(BranchDescription const& bd,
139  std::unique_ptr<WrapperBase> edp,
140  std::optional<ProductProvenance> productProvenance) const;
141 
142  WrapperBase const* getIt(ProductID const& pid) const override;
143  std::optional<std::tuple<WrapperBase const*, unsigned int>> getThinnedProduct(ProductID const& pid,
144  unsigned int key) const override;
145  void getThinnedProducts(ProductID const& pid,
146  std::vector<WrapperBase const*>& foundContainers,
147  std::vector<unsigned int>& keys) const override;
149  unsigned int key,
150  ProductID const& thinned) const override;
151 
152  ProductID branchIDToProductID(BranchID const& bid) const;
153 
155  provRetrieverPtr_->mergeProvenanceRetrievers(other.provRetrieverPtr());
156  }
157 
158  using Base::getProvenance;
160 
161  unsigned int processBlockIndex(std::string const& processName) const override;
162 
163  private:
164  BranchID pidToBid(ProductID const& pid) const;
165 
166  edm::ThinnedAssociation const* getThinnedAssociation(edm::BranchID const& branchID) const;
167 
168  unsigned int transitionIndex_() const override;
169  void changedIndexes_() final;
170 
173  }
174  std::shared_ptr<ProductProvenanceRetriever>& provRetrieverPtr() { return get_underlying_safe(provRetrieverPtr_); }
175 
181 
182  private:
184 
186 
187  // Pointer to the 'retriever' that will get provenance information from the persistent store.
189 
191 
192  std::shared_ptr<BranchIDListHelper const> branchIDListHelper_;
194  std::shared_ptr<ThinnedAssociationsHelper const> thinnedAssociationsHelper_;
195 
197 
199 
200  std::vector<ProcessIndex> branchListIndexToProcessIndex_;
201 
203  };
204 
205  inline bool isSameEvent(EventPrincipal const& a, EventPrincipal const& b) { return isSameEvent(a.aux(), b.aux()); }
206 } // namespace edm
207 #endif
std::shared_ptr< ThinnedAssociationsHelper const > thinnedAssociationsHelper_
std::optional< std::tuple< WrapperBase const *, unsigned int > > getThinnedProduct(ProductID const &pid, unsigned int key) const override
void setLuminosityBlockPrincipal(LuminosityBlockPrincipal *lbp)
void commonFillEventPrincipal(EventAuxiliary const &aux, ProcessHistory const *processHistory, DelayedReader *reader)
bool isSameEvent(EventAuxiliary const &a, EventAuxiliary const &b)
unsigned int ProductResolverIndex
EventAuxiliary const & aux() const
RunNumber_t run() const
std::variant< unsigned int, detail::GetThinnedKeyFromExceptionFactory, std::monostate > OptionalThinnedKey
std::shared_ptr< ProductProvenanceRetriever > & provRetrieverPtr()
EventToProcessBlockIndexes eventToProcessBlockIndexes_
Timestamp const & time() const
Definition: Hash.h:43
EventSelectionIDVector eventSelectionIDs_
unsigned int processBlockIndex(std::string const &processName) const override
edm::ThinnedAssociation const * getThinnedAssociation(edm::BranchID const &branchID) const
static int const invalidBunchXing
StableProvenance const & getStableProvenance(BranchID const &bid) const
Definition: Principal.cc:788
BranchListIndexes branchListIndexes_
Timestamp const & time() const
LuminosityBlockPrincipal const & luminosityBlockPrincipal() const
edm::propagate_const< LuminosityBlockPrincipal * > luminosityBlockPrincipal_
void changedIndexes_() final
std::shared_ptr< BranchIDListHelper const > branchIDListHelper_
LuminosityBlockPrincipal & luminosityBlockPrincipal()
constexpr std::shared_ptr< T > & get_underlying_safe(propagate_const< std::shared_ptr< T >> &iP)
EventAuxiliary aux_
Provenance const & getProvenance(ProductID const &pid) const
edm::propagate_const< std::shared_ptr< ProductProvenanceRetriever > > provRetrieverPtr_
StreamID streamID() const
OptionalThinnedKey getThinnedKeyFrom(ProductID const &parent, unsigned int key, ProductID const &thinned) const override
unsigned int LuminosityBlockNumber_t
BasicHandle getByProductID(ProductID const &oid) const
EventPrincipal(std::shared_ptr< ProductRegistry const > reg, std::shared_ptr< BranchIDListHelper const > branchIDListHelper, std::shared_ptr< ThinnedAssociationsHelper const > thinnedAssociationsHelper, ProcessConfiguration const &pc, HistoryAppender *historyAppender, unsigned int streamIndex=0, bool isForPrimaryProcess=true, ProcessBlockHelperBase const *processBlockHelper=nullptr)
BranchID pidToBid(ProductID const &pid) const
std::vector< EventSelectionID > EventSelectionIDVector
LuminosityBlockNumber_t luminosityBlock() const
LuminosityBlockNumber_t luminosityBlock() const
Definition: EventID.h:39
EventToProcessBlockIndexes const & eventToProcessBlockIndexes() const
EventID const & id() const
void mergeProvenanceRetrievers(EventPrincipal &other)
ProductID branchIDToProductID(BranchID const &bid) const
std::vector< BranchListIndex > BranchListIndexes
void put(BranchDescription const &bd, std::unique_ptr< WrapperBase > edp, ProductProvenance const &productProvenance) const
static int const invalidBunchXing
int storeNumber() const
Base::ConstProductResolverPtr ConstProductResolverPtr
EventAuxiliary Auxiliary
bool isRealData() const
void getThinnedProducts(ProductID const &pid, std::vector< WrapperBase const *> &foundContainers, std::vector< unsigned int > &keys) const override
key
prepare the HTCondor submission files and eventually submit them
int bunchCrossing() const
std::shared_ptr< ProductProvenanceRetriever const > provRetrieverPtr() const
void updateBranchListIndexes(BranchListIndexes &&)
~EventPrincipal() override
EventAuxiliary::ExperimentType ExperimentType() const
RunPrincipal const & runPrincipal() const
std::vector< ProcessIndex > branchListIndexToProcessIndex_
RunNumber_t run() const
Definition: EventID.h:38
int bunchCrossing() const
WrapperBase const * getIt(ProductID const &pid) const override
static int const invalidStoreNumber
unsigned int transitionIndex_() const override
void putOnRead(BranchDescription const &bd, std::unique_ptr< WrapperBase > edp, std::optional< ProductProvenance > productProvenance) const
ProcessHistory const & processHistory() const
Definition: Principal.h:134
ProductProvenanceRetriever const * productProvenanceRetrieverPtr() const
double b
Definition: hdecay.h:120
ProductResolverBase const * ConstProductResolverPtr
Definition: Principal.h:62
bool wasBranchListIndexesChangedFromInput(BranchListIndexes const &) const
void fillEventPrincipal(EventAuxiliary const &aux, ProcessHistory const *processHistory, DelayedReader *reader=nullptr)
int storeNumber() const
ProcessBlockHelperBase const * processBlockHelper_
static int const invalidStoreNumber
HLT enums.
StableProvenance const & getStableProvenance(ProductID const &pid) const
double a
Definition: hdecay.h:121
EventSelectionIDVector const & eventSelectionIDs() const
Provenance const & getProvenance(BranchID const &bid) const
Definition: Principal.cc:775
unsigned int RunNumber_t
ExperimentType experimentType() const
void setRunAndLumiNumber(RunNumber_t run, LuminosityBlockNumber_t lumi)
BranchListIndexes const & branchListIndexes() const
EventID const & id() const
DelayedReader * reader() const
Definition: Principal.h:181
bool luminosityBlockPrincipalPtrValid() const