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 getProvenance(ProductID const& pid, ModuleCallingContext const* mcc) const;
121 
122  BasicHandle getByProductID(ProductID const& oid) const;
123 
124  void put(BranchDescription const& bd,
125  std::unique_ptr<WrapperBase> edp,
126  ProductProvenance const& productProvenance) const;
127 
128  void put(ProductResolverIndex index, std::unique_ptr<WrapperBase> edp, ParentageID productProvenance) const;
129 
130  void putOnRead(BranchDescription const& bd,
131  std::unique_ptr<WrapperBase> edp,
132  std::optional<ProductProvenance> productProvenance) const;
133 
134  WrapperBase const* getIt(ProductID const& pid) const override;
135  std::optional<std::tuple<WrapperBase const*, unsigned int>> getThinnedProduct(ProductID const& pid,
136  unsigned int key) const override;
137  void getThinnedProducts(ProductID const& pid,
138  std::vector<WrapperBase const*>& foundContainers,
139  std::vector<unsigned int>& keys) const override;
141  unsigned int key,
142  ProductID const& thinned) const override;
143 
144  ProductID branchIDToProductID(BranchID const& bid) const;
145 
147  provRetrieverPtr_->mergeProvenanceRetrievers(other.provRetrieverPtr());
148  }
149 
150  using Base::getProvenance;
151 
152  private:
153  BranchID pidToBid(ProductID const& pid) const;
154 
155  edm::ThinnedAssociation const* getThinnedAssociation(edm::BranchID const& branchID) const;
156 
157  unsigned int transitionIndex_() const override;
158  void changedIndexes_() final;
159 
162  }
163  std::shared_ptr<ProductProvenanceRetriever>& provRetrieverPtr() { return get_underlying_safe(provRetrieverPtr_); }
164 
170 
171  private:
173 
175 
176  // Pointer to the 'retriever' that will get provenance information from the persistent store.
178 
180 
181  std::shared_ptr<BranchIDListHelper const> branchIDListHelper_;
182  std::shared_ptr<ThinnedAssociationsHelper const> thinnedAssociationsHelper_;
183 
185 
186  std::vector<ProcessIndex> branchListIndexToProcessIndex_;
187 
189  };
190 
191  inline bool isSameEvent(EventPrincipal const& a, EventPrincipal const& b) { return isSameEvent(a.aux(), b.aux()); }
192 } // namespace edm
193 #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:181
edm::EventPrincipal::luminosityBlockPrincipal_
edm::propagate_const< LuminosityBlockPrincipal * > luminosityBlockPrincipal_
Definition: EventPrincipal.h:174
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:160
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:172
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:302
deep_tau::DeepTauBase::BasicDiscriminator
BasicDiscriminator
Definition: DeepTauBase.h:115
edm::EventPrincipal::mergeProvenanceRetrievers
void mergeProvenanceRetrievers(EventPrincipal &other)
Definition: EventPrincipal.h:146
edm::EventPrincipal::thinnedAssociationsHelper_
std::shared_ptr< ThinnedAssociationsHelper const > thinnedAssociationsHelper_
Definition: EventPrincipal.h:182
edm::Principal::ConstProductResolverPtr
ProductResolverBase const * ConstProductResolverPtr
Definition: Principal.h:63
edm::EventPrincipal::getThinnedProduct
std::optional< std::tuple< WrapperBase const *, unsigned int > > getThinnedProduct(ProductID const &pid, unsigned int key) const override
Definition: EventPrincipal.cc:304
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:57
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:163
edm::Principal::processHistory
ProcessHistory const & processHistory() const
Definition: Principal.h:141
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::getProvenance
Provenance getProvenance(ProductID const &pid, ModuleCallingContext const *mcc) const
Definition: EventPrincipal.cc:354
edm::EventPrincipal::setRunAndLumiNumber
void setRunAndLumiNumber(RunNumber_t run, LuminosityBlockNumber_t lumi)
Definition: EventPrincipal.cc:170
edm::EventPrincipal::productProvenanceRetrieverPtr
ProductProvenanceRetriever const * productProvenanceRetrieverPtr() const
Definition: EventPrincipal.h:114
edm::EventPrincipal::branchListIndexes
BranchListIndexes const & branchListIndexes() const
Definition: EventPrincipal.cc:361
edm::Principal::getProvenance
Provenance getProvenance(BranchID const &bid, ModuleCallingContext const *mcc) const
Definition: Principal.cc:824
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:177
edm::EventPrincipal::changedIndexes_
void changedIndexes_() final
Definition: EventPrincipal.cc:256
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:363
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:1467
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:179
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:328
Principal.h
a
double a
Definition: hdecay.h:119
edm::EventPrincipal::luminosityBlock
LuminosityBlockNumber_t luminosityBlock() const
Definition: EventPrincipal.h:108
edm::EventPrincipal::branchListIndexToProcessIndex_
std::vector< ProcessIndex > branchListIndexToProcessIndex_
Definition: EventPrincipal.h:186
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:168
edm::EventPrincipal::commonFillEventPrincipal
void commonFillEventPrincipal(EventAuxiliary const &aux, ProcessHistory const *processHistory, DelayedReader *reader)
Definition: EventPrincipal.cc:117
edm::EventPrincipal::putOnRead
void putOnRead(BranchDescription const &bd, std::unique_ptr< WrapperBase > edp, std::optional< ProductProvenance > productProvenance) const
Definition: EventPrincipal.cc:210
edm::EventPrincipal::eventSelectionIDs
EventSelectionIDVector const & eventSelectionIDs() const
Definition: EventPrincipal.cc:359
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:140
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:179
edm::EventPrincipal::getByProductID
BasicHandle getByProductID(ProductID const &oid) const
Definition: EventPrincipal.cc:268
edm::EventPrincipal::fillEventPrincipal
void fillEventPrincipal(EventAuxiliary const &aux, ProcessHistory const *processHistory, DelayedReader *reader=nullptr)
Definition: EventPrincipal.cc:104
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:315
edm::ProductProvenanceRetriever
Definition: ProductProvenanceRetriever.h:56
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:57
edm::EventPrincipal::branchIDToProductID
ProductID branchIDToProductID(BranchID const &bid) const
Definition: EventPrincipal.cc:230
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:188
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:254
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:223
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:177
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:184
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:31
edm::EventPrincipal::wasBranchListIndexesChangedFromInput
bool wasBranchListIndexesChangedFromInput(BranchListIndexes const &) const
Definition: EventPrincipal.cc:130
EventSelectionID.h
edm::ModuleCallingContext
Definition: ModuleCallingContext.h:29
edm::Timestamp
Definition: Timestamp.h:30