CMS 3D CMS Logo

PrincipalCache.h
Go to the documentation of this file.
1 #ifndef FWCore_Framework_PrincipalCache_h
2 #define FWCore_Framework_PrincipalCache_h
3 
4 /*
5 Contains a shared pointer to the RunPrincipal,
6 LuminosityBlockPrincipal, and EventPrincipal.
7 Manages merging of run and luminosity block
8 principals when there is more than one principal
9 from the same run or luminosity block and having
10 the same reduced ProcessHistoryID.
11 
12 The EventPrincipal is reused each event and is created
13 by the EventProcessor or SubProcess which contains
14 an object of this type as a data member.
15 
16 The RunPrincipal and LuminosityBlockPrincipal is
17 created by the InputSource each time a different
18 run or luminosity block is encountered.
19 
20 Performs checks that process history IDs or runs and
21 lumis, run numbers, and luminosity numbers are consistent.
22 
23 Original Author: W. David Dagenhart
24 */
25 
30 
32 
33 #include <memory>
34 #include <vector>
35 #include <cassert>
36 
37 namespace edm {
38 
39  class RunPrincipal;
40  class LuminosityBlockPrincipal;
41  class EventPrincipal;
42  class RunAuxiliary;
43  class LuminosityBlockAuxiliary;
44  class ProductRegistry;
45  class PreallocationConfiguration;
46 
48  public:
49 
52  PrincipalCache(PrincipalCache&&) = default;
53 
55  std::shared_ptr<RunPrincipal> const& runPrincipalPtr(ProcessHistoryID const& phid, RunNumber_t run) const;
56  RunPrincipal& runPrincipal() const;
57  std::shared_ptr<RunPrincipal> const& runPrincipalPtr() const;
58  bool hasRunPrincipal() const {return bool(runPrincipal_);}
59 
60  std::shared_ptr<LuminosityBlockPrincipal> getAvailableLumiPrincipalPtr();
61 
62  EventPrincipal& eventPrincipal(unsigned int iStreamIndex) const { return *(eventPrincipals_[iStreamIndex]); }
63 
64  void merge(std::shared_ptr<RunAuxiliary> aux, std::shared_ptr<ProductRegistry const> reg);
65 
67  void insert(std::shared_ptr<RunPrincipal> rp);
68  void insert(std::unique_ptr<LuminosityBlockPrincipal> lbp);
69  void insert(std::shared_ptr<EventPrincipal> ep);
70 
71  void deleteRun(ProcessHistoryID const& phid, RunNumber_t run);
72 
73  void adjustEventsToNewProductRegistry(std::shared_ptr<ProductRegistry const> reg);
74 
76 
78 
79  private:
80 
81  void throwRunMissing() const;
82  void throwLumiMissing() const;
83 
84  // These are explicitly cleared when finished with the run,
85  // lumi, or event
86  std::shared_ptr<RunPrincipal> runPrincipal_;
88  std::vector<std::shared_ptr<EventPrincipal>> eventPrincipals_;
89 
90  // This is just an accessor to the registry owned by the input source.
91  ProcessHistoryRegistry const* processHistoryRegistry_; // We don't own this
92 
93  // These are intentionally not cleared so that when inserting
94  // the next principal the conversion from full ProcessHistoryID_
95  // to reduced ProcessHistoryID_ is still in memory and does
96  // not need to be recalculated if the ID does not change. I
97  // expect that very often these ID's will not change from one
98  // principal to the next and a good amount of CPU can be saved
99  // by not recalculating.
104  };
105 }
106 
107 #endif
void throwRunMissing() const
void insert(std::shared_ptr< RunPrincipal > rp)
void setNumberOfConcurrentPrincipals(PreallocationConfiguration const &)
std::shared_ptr< RunPrincipal > const & runPrincipalPtr() const
void throwLumiMissing() const
bool hasRunPrincipal() const
LuminosityBlockNumber_t lumi_
void adjustIndexesAfterProductRegistryAddition()
unsigned int LuminosityBlockNumber_t
RunPrincipal & runPrincipal() const
edm::ReusableObjectHolder< LuminosityBlockPrincipal > lumiHolder_
std::vector< std::shared_ptr< EventPrincipal > > eventPrincipals_
ProcessHistoryID reducedInputProcessHistoryID_
void adjustEventsToNewProductRegistry(std::shared_ptr< ProductRegistry const > reg)
EventPrincipal & eventPrincipal(unsigned int iStreamIndex) const
void setProcessHistoryRegistry(ProcessHistoryRegistry const &phr)
void deleteRun(ProcessHistoryID const &phid, RunNumber_t run)
ProcessHistoryID inputProcessHistoryID_
HLT enums.
std::shared_ptr< LuminosityBlockPrincipal > getAvailableLumiPrincipalPtr()
unsigned int RunNumber_t
ProcessHistoryRegistry const * processHistoryRegistry_
std::shared_ptr< RunPrincipal > runPrincipal_
void merge(std::shared_ptr< RunAuxiliary > aux, std::shared_ptr< ProductRegistry const > reg)