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 
24 
25 #include <map>
26 #include <memory>
27 #include <string>
28 #include <vector>
29 #include <optional>
30 
31 namespace edm {
32  class BranchID;
33  class BranchIDListHelper;
34  class ProductProvenanceRetriever;
35  class DelayedReader;
36  class EventID;
37  class HistoryAppender;
38  class LuminosityBlockPrincipal;
39  class ModuleCallingContext;
40  class ProductID;
41  class StreamContext;
42  class ThinnedAssociation;
43  class ThinnedAssociationsHelper;
44  class RunPrincipal;
45 
46  class EventPrincipal : public Principal {
47  public:
49  typedef Principal Base;
50 
54  EventPrincipal(std::shared_ptr<ProductRegistry const> reg,
55  std::shared_ptr<BranchIDListHelper const> branchIDListHelper,
56  std::shared_ptr<ThinnedAssociationsHelper const> thinnedAssociationsHelper,
57  ProcessConfiguration const& pc,
58  HistoryAppender* historyAppender,
59  unsigned int streamIndex = 0,
60  bool isForPrimaryProcess = true);
61  ~EventPrincipal() override {}
62 
65  DelayedReader* reader = nullptr);
70  //provRetriever is changed via a call to ProductProvenanceRetriever::deepSwap
75  ProductProvenanceRetriever const& provRetriever,
76  DelayedReader* reader = nullptr,
77  bool deepCopyRetriever = true);
78 
79  void clearEventPrincipal();
80 
82 
84 
85  bool luminosityBlockPrincipalPtrValid() const { return luminosityBlockPrincipal_ != nullptr; }
86 
87  //does not share ownership
89 
91 
92  EventID const& id() const { return aux().id(); }
93 
94  Timestamp const& time() const { return aux().time(); }
95 
96  bool isReal() const { return aux().isRealData(); }
97 
99 
100  int bunchCrossing() const { return aux().bunchCrossing(); }
101 
102  int storeNumber() const { return aux().storeNumber(); }
103 
104  EventAuxiliary const& aux() const { return aux_; }
105 
106  StreamID streamID() const { return streamID_; }
107 
109 
110  RunNumber_t run() const { return id().run(); }
111 
112  RunPrincipal const& runPrincipal() const;
113 
115 
117 
118  BranchListIndexes const& branchListIndexes() const;
119 
120  Provenance const& getProvenance(ProductID const& pid) const;
121  StableProvenance const& getStableProvenance(ProductID const& pid) const;
122 
123  BasicHandle getByProductID(ProductID const& oid) const;
124 
125  void put(BranchDescription const& bd,
126  std::unique_ptr<WrapperBase> edp,
127  ProductProvenance const& productProvenance) const;
128 
129  void put(ProductResolverIndex index, std::unique_ptr<WrapperBase> edp, ParentageID productProvenance) const;
130 
131  void putOnRead(BranchDescription const& bd,
132  std::unique_ptr<WrapperBase> edp,
133  std::optional<ProductProvenance> productProvenance) const;
134 
135  WrapperBase const* getIt(ProductID const& pid) const override;
136  std::optional<std::tuple<WrapperBase const*, unsigned int>> getThinnedProduct(ProductID const& pid,
137  unsigned int key) const override;
138  void getThinnedProducts(ProductID const& pid,
139  std::vector<WrapperBase const*>& foundContainers,
140  std::vector<unsigned int>& keys) const override;
142  unsigned int key,
143  ProductID const& thinned) const override;
144 
145  ProductID branchIDToProductID(BranchID const& bid) const;
146 
148  provRetrieverPtr_->mergeProvenanceRetrievers(other.provRetrieverPtr());
149  }
150 
151  using Base::getProvenance;
153 
154  private:
155  BranchID pidToBid(ProductID const& pid) const;
156 
157  edm::ThinnedAssociation const* getThinnedAssociation(edm::BranchID const& branchID) const;
158 
159  unsigned int transitionIndex_() const override;
160  void changedIndexes_() final;
161 
164  }
165  std::shared_ptr<ProductProvenanceRetriever>& provRetrieverPtr() { return get_underlying_safe(provRetrieverPtr_); }
166 
172 
173  private:
175 
177 
178  // Pointer to the 'retriever' that will get provenance information from the persistent store.
180 
182 
183  std::shared_ptr<BranchIDListHelper const> branchIDListHelper_;
184  std::shared_ptr<ThinnedAssociationsHelper const> thinnedAssociationsHelper_;
185 
187 
188  std::vector<ProcessIndex> branchListIndexToProcessIndex_;
189 
191  };
192 
193  inline bool isSameEvent(EventPrincipal const& a, EventPrincipal const& b) { return isSameEvent(a.aux(), b.aux()); }
194 } // namespace edm
195 #endif
edm::EventPrincipal::ExperimentType
EventAuxiliary::ExperimentType ExperimentType() const
Definition: EventPrincipal.h:98
edm::StreamID
Definition: StreamID.h:30
edm::RunNumber_t
unsigned int RunNumber_t
Definition: RunLumiEventNumber.h:14
edm::EventPrincipal::branchIDListHelper_
std::shared_ptr< BranchIDListHelper const > branchIDListHelper_
Definition: EventPrincipal.h:183
edm::EventPrincipal::luminosityBlockPrincipal_
edm::propagate_const< LuminosityBlockPrincipal * > luminosityBlockPrincipal_
Definition: EventPrincipal.h:176
edm::EventPrincipal::aux
EventAuxiliary const & aux() const
Definition: EventPrincipal.h:104
edm::EventPrincipal::Auxiliary
EventAuxiliary Auxiliary
Definition: EventPrincipal.h:48
edm::ProductResolverIndex
unsigned int ProductResolverIndex
Definition: ProductResolverIndex.h:8
edm::EventPrincipal::luminosityBlockPrincipal
LuminosityBlockPrincipal const & luminosityBlockPrincipal() const
Definition: EventPrincipal.h:81
edm::EventPrincipal::provRetrieverPtr
std::shared_ptr< ProductProvenanceRetriever const > provRetrieverPtr() const
Definition: EventPrincipal.h:162
edm::EventAuxiliary::invalidStoreNumber
static const int invalidStoreNumber
Definition: EventAuxiliary.h:29
edm::BasicHandle
Definition: BasicHandle.h:43
edm::EventPrincipal::aux_
EventAuxiliary aux_
Definition: EventPrincipal.h:174
edm::EventAuxiliary::storeNumber
int storeNumber() const
Definition: EventAuxiliary.h:78
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::EventPrincipal::getIt
WrapperBase const * getIt(ProductID const &pid) const override
Definition: EventPrincipal.cc:303
deep_tau::DeepTauBase::BasicDiscriminator
BasicDiscriminator
Definition: DeepTauBase.h:115
edm::EventPrincipal::mergeProvenanceRetrievers
void mergeProvenanceRetrievers(EventPrincipal &other)
Definition: EventPrincipal.h:147
edm::EventPrincipal::thinnedAssociationsHelper_
std::shared_ptr< ThinnedAssociationsHelper const > thinnedAssociationsHelper_
Definition: EventPrincipal.h:184
edm::Principal::ConstProductResolverPtr
ProductResolverBase const * ConstProductResolverPtr
Definition: Principal.h:62
edm::EventPrincipal::getThinnedProduct
std::optional< std::tuple< WrapperBase const *, unsigned int > > getThinnedProduct(ProductID const &pid, unsigned int key) const override
Definition: EventPrincipal.cc:305
edm::LuminosityBlockPrincipal
Definition: LuminosityBlockPrincipal.h:31
edm::BranchListIndexes
std::vector< BranchListIndex > BranchListIndexes
Definition: BranchListIndex.h:18
edm::ThinnedAssociation
Definition: ThinnedAssociation.h:15
edm::Principal
Definition: Principal.h:56
edm::EventPrincipal::isReal
bool isReal() const
Definition: EventPrincipal.h:96
relativeConstraints.keys
keys
Definition: relativeConstraints.py:89
edm::get_underlying_safe
constexpr std::shared_ptr< T > & get_underlying_safe(propagate_const< std::shared_ptr< T >> &iP)
Definition: get_underlying_safe.h:41
edm::EventPrincipal::provRetrieverPtr
std::shared_ptr< ProductProvenanceRetriever > & provRetrieverPtr()
Definition: EventPrincipal.h:165
edm::Principal::processHistory
ProcessHistory const & processHistory() const
Definition: Principal.h:140
edm::EventID::luminosityBlock
LuminosityBlockNumber_t luminosityBlock() const
Definition: EventID.h:39
watchdog.const
const
Definition: watchdog.py:83
edm::LuminosityBlockNumber_t
unsigned int LuminosityBlockNumber_t
Definition: RunLumiEventNumber.h:13
edm::EventPrincipal::id
EventID const & id() const
Definition: EventPrincipal.h:92
edm::EventAuxiliary::bunchCrossing
int bunchCrossing() const
Definition: EventAuxiliary.h:76
edm::EventPrincipal::setRunAndLumiNumber
void setRunAndLumiNumber(RunNumber_t run, LuminosityBlockNumber_t lumi)
Definition: EventPrincipal.cc:171
edm::EventPrincipal::productProvenanceRetrieverPtr
ProductProvenanceRetriever const * productProvenanceRetrieverPtr() const
Definition: EventPrincipal.h:114
edm::EventPrincipal::branchListIndexes
BranchListIndexes const & branchListIndexes() const
Definition: EventPrincipal.cc:367
edm::propagate_const
Definition: propagate_const.h:32
edm::EventPrincipal::time
Timestamp const & time() const
Definition: EventPrincipal.h:94
edm::EventPrincipal::provRetrieverPtr_
edm::propagate_const< std::shared_ptr< ProductProvenanceRetriever > > provRetrieverPtr_
Definition: EventPrincipal.h:179
edm::EventPrincipal::changedIndexes_
void changedIndexes_() final
Definition: EventPrincipal.cc:257
edm::EventPrincipal::ConstProductResolverPtr
Base::ConstProductResolverPtr ConstProductResolverPtr
Definition: EventPrincipal.h:51
edm::EventPrincipal
Definition: EventPrincipal.h:46
edm::ProductProvenance
Definition: ProductProvenance.h:24
edm::EventPrincipal::getThinnedAssociation
edm::ThinnedAssociation const * getThinnedAssociation(edm::BranchID const &branchID) const
Definition: EventPrincipal.cc:369
edm::Principal::getProvenance
Provenance const & getProvenance(BranchID const &bid) const
Definition: Principal.cc:833
BranchListIndex.h
edm::BranchID
Definition: BranchID.h:14
edm::Principal::reader
DelayedReader * reader() const
Definition: Principal.h:187
edm::EventAuxiliary::id
EventID const & id() const
Definition: EventAuxiliary.h:63
edm::Hash< ParentageType >
trackingPlots.other
other
Definition: trackingPlots.py:1460
b
double b
Definition: hdecay.h:118
edm::EventPrincipal::put
void put(BranchDescription const &bd, std::unique_ptr< WrapperBase > edp, ProductProvenance const &productProvenance) const
Definition: EventPrincipal.cc:180
edm::EventAuxiliary::experimentType
ExperimentType experimentType() const
Definition: EventAuxiliary.h:75
edm::EventID::run
RunNumber_t run() const
Definition: EventID.h:38
WrapperBase.h
edm::EventAuxiliary
Definition: EventAuxiliary.h:14
edm::EventPrincipal::getThinnedKeyFrom
OptionalThinnedKey getThinnedKeyFrom(ProductID const &parent, unsigned int key, ProductID const &thinned) const override
Definition: EventPrincipal.cc:329
Principal.h
a
double a
Definition: hdecay.h:119
edm::EventPrincipal::luminosityBlock
LuminosityBlockNumber_t luminosityBlock() const
Definition: EventPrincipal.h:108
edm::EventPrincipal::getProvenance
Provenance const & getProvenance(ProductID const &pid) const
Definition: EventPrincipal.cc:355
edm::StableProvenance
Definition: StableProvenance.h:30
edm::EventPrincipal::branchListIndexToProcessIndex_
std::vector< ProcessIndex > branchListIndexToProcessIndex_
Definition: EventPrincipal.h:188
edm::EventPrincipal::storeNumber
int storeNumber() const
Definition: EventPrincipal.h:102
edm::EventPrincipal::invalidBunchXing
static const int invalidBunchXing
Definition: EventPrincipal.h:52
edm::EventPrincipal::setLuminosityBlockPrincipal
void setLuminosityBlockPrincipal(LuminosityBlockPrincipal *lbp)
Definition: EventPrincipal.cc:169
edm::EventPrincipal::commonFillEventPrincipal
void commonFillEventPrincipal(EventAuxiliary const &aux, ProcessHistory const *processHistory, DelayedReader *reader)
Definition: EventPrincipal.cc:118
edm::EventPrincipal::putOnRead
void putOnRead(BranchDescription const &bd, std::unique_ptr< WrapperBase > edp, std::optional< ProductProvenance > productProvenance) const
Definition: EventPrincipal.cc:211
edm::EventPrincipal::eventSelectionIDs
EventSelectionIDVector const & eventSelectionIDs() const
Definition: EventPrincipal.cc:365
edm::Principal::getStableProvenance
StableProvenance const & getStableProvenance(BranchID const &bid) const
Definition: Principal.cc:846
edm::WrapperBase
Definition: WrapperBase.h:23
Signal.h
edm::EventAuxiliary::time
Timestamp const & time() const
Definition: EventAuxiliary.h:66
edm::EventPrincipal::streamID
StreamID streamID() const
Definition: EventPrincipal.h:106
edm::HistoryAppender
Definition: HistoryAppender.h:13
edm::EventPrincipal::updateBranchListIndexes
void updateBranchListIndexes(BranchListIndexes &&)
Definition: EventPrincipal.cc:141
edm::EventPrincipal::bunchCrossing
int bunchCrossing() const
Definition: EventPrincipal.h:100
edm::EventPrincipal::Base
Principal Base
Definition: EventPrincipal.h:49
edm::EventPrincipal::eventSelectionIDs_
EventSelectionIDVector eventSelectionIDs_
Definition: EventPrincipal.h:181
edm::EventPrincipal::getByProductID
BasicHandle getByProductID(ProductID const &oid) const
Definition: EventPrincipal.cc:269
edm::EventPrincipal::fillEventPrincipal
void fillEventPrincipal(EventAuxiliary const &aux, ProcessHistory const *processHistory, DelayedReader *reader=nullptr)
Definition: EventPrincipal.cc:105
ProductProvenanceRetriever.h
edm::OptionalThinnedKey
std::variant< unsigned int, detail::GetThinnedKeyFromExceptionFactory, std::monostate > OptionalThinnedKey
Definition: EDProductGetter.h:39
edm::EventPrincipal::getThinnedProducts
void getThinnedProducts(ProductID const &pid, std::vector< WrapperBase const * > &foundContainers, std::vector< unsigned int > &keys) const override
Definition: EventPrincipal.cc:316
edm::ProductProvenanceRetriever
Definition: ProductProvenanceRetriever.h:56
edm::EventPrincipal::getStableProvenance
StableProvenance const & getStableProvenance(ProductID const &pid) const
Definition: EventPrincipal.cc:360
edm::EventPrincipal::run
RunNumber_t run() const
Definition: EventPrincipal.h:110
std
Definition: JetResolutionObject.h:76
edm::EventPrincipal::luminosityBlockPrincipal
LuminosityBlockPrincipal & luminosityBlockPrincipal()
Definition: EventPrincipal.h:83
edm::EventPrincipal::clearEventPrincipal
void clearEventPrincipal()
Definition: EventPrincipal.cc:58
edm::EventPrincipal::branchIDToProductID
ProductID branchIDToProductID(BranchID const &bid) const
Definition: EventPrincipal.cc:231
edm::EventAuxiliary::ExperimentType
ExperimentType
Definition: EventAuxiliary.h:18
EventAuxiliary.h
edm::isSameEvent
bool isSameEvent(EventAuxiliary const &a, EventAuxiliary const &b)
Definition: EventAuxiliary.cc:15
edm::EventPrincipal::streamID_
StreamID streamID_
Definition: EventPrincipal.h:190
edm::EventAuxiliary::invalidBunchXing
static const int invalidBunchXing
Definition: EventAuxiliary.h:28
edm::DelayedReader
Definition: DelayedReader.h:29
edm::EventPrincipal::invalidStoreNumber
static const int invalidStoreNumber
Definition: EventPrincipal.h:53
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
edm::EventPrincipal::luminosityBlockPrincipalPtrValid
bool luminosityBlockPrincipalPtrValid() const
Definition: EventPrincipal.h:85
edm::EventPrincipal::transitionIndex_
unsigned int transitionIndex_() const override
Definition: EventPrincipal.cc:255
edm::EventPrincipal::~EventPrincipal
~EventPrincipal() override
Definition: EventPrincipal.h:61
edm::BranchDescription
Definition: BranchDescription.h:32
edm::EventPrincipal::pidToBid
BranchID pidToBid(ProductID const &pid) const
Definition: EventPrincipal.cc:224
edm::ProcessHistory
Definition: ProcessHistory.h:13
edm::EventAuxiliary::isRealData
bool isRealData() const
Definition: EventAuxiliary.h:74
edm::RunPrincipal
Definition: RunPrincipal.h:34
edm::Provenance
Definition: Provenance.h:34
edm::EventID
Definition: EventID.h:31
edm::EventSelectionIDVector
std::vector< EventSelectionID > EventSelectionIDVector
Definition: EventSelectionID.h:16
get_underlying_safe.h
crabWrapper.key
key
Definition: crabWrapper.py:19
lumi
Definition: LumiSectionData.h:20
StreamID.h
edm::EventPrincipal::runPrincipal
RunPrincipal const & runPrincipal() const
Definition: EventPrincipal.cc:178
class-composition.parent
parent
Definition: class-composition.py:88
edm::ProductID
Definition: ProductID.h:27
edm::ProcessConfiguration
Definition: ProcessConfiguration.h:14
edm::EventPrincipal::branchListIndexes_
BranchListIndexes branchListIndexes_
Definition: EventPrincipal.h:186
edm::EventPrincipal::EventPrincipal
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)
Definition: EventPrincipal.cc:32
edm::EventPrincipal::wasBranchListIndexesChangedFromInput
bool wasBranchListIndexesChangedFromInput(BranchListIndexes const &) const
Definition: EventPrincipal.cc:131
EventSelectionID.h
edm::Timestamp
Definition: Timestamp.h:30