CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
31 #include <memory>
32 #include <vector>
33 #include <cassert>
34 
35 namespace edm {
36 
37  class RunPrincipal;
38  class LuminosityBlockPrincipal;
39  class EventPrincipal;
40  class RunAuxiliary;
41  class LuminosityBlockAuxiliary;
42  class ProductRegistry;
43  class PreallocationConfiguration;
44 
46  public:
47 
50 
52  std::shared_ptr<RunPrincipal> const& runPrincipalPtr(ProcessHistoryID const& phid, RunNumber_t run) const;
53  RunPrincipal& runPrincipal() const;
54  std::shared_ptr<RunPrincipal> const& runPrincipalPtr() const;
55  bool hasRunPrincipal() const {return bool(runPrincipal_);}
56 
58  std::shared_ptr<LuminosityBlockPrincipal> const& lumiPrincipalPtr(ProcessHistoryID const& phid, RunNumber_t run, LuminosityBlockNumber_t lumi) const;
60  std::shared_ptr<LuminosityBlockPrincipal> const& lumiPrincipalPtr() const;
61  bool hasLumiPrincipal() const {return bool(lumiPrincipal_);}
62 
63  EventPrincipal& eventPrincipal(unsigned int iStreamIndex) const { return *(eventPrincipals_[iStreamIndex]); }
64 
65  void merge(std::shared_ptr<RunAuxiliary> aux, std::shared_ptr<ProductRegistry const> reg);
66  void merge(std::shared_ptr<LuminosityBlockAuxiliary> aux, std::shared_ptr<ProductRegistry const> reg);
67 
69  void insert(std::shared_ptr<RunPrincipal> rp);
70  void insert(std::shared_ptr<LuminosityBlockPrincipal> lbp);
71  void insert(std::shared_ptr<EventPrincipal> ep);
72 
73  void deleteRun(ProcessHistoryID const& phid, RunNumber_t run);
75 
76  void adjustEventsToNewProductRegistry(std::shared_ptr<ProductRegistry const> reg);
77 
79 
81 
82  private:
83 
84  void throwRunMissing() const;
85  void throwLumiMissing() const;
86 
87  // These are explicitly cleared when finished with the run,
88  // lumi, or event
89  std::shared_ptr<RunPrincipal> runPrincipal_;
90  std::shared_ptr<LuminosityBlockPrincipal> lumiPrincipal_;
91  std::vector<std::shared_ptr<EventPrincipal>> eventPrincipals_;
92 
93  // This is just an accessor to the registry owned by the input source.
94  ProcessHistoryRegistry const* processHistoryRegistry_; // We don't own this
95 
96  // These are intentionally not cleared so that when inserting
97  // the next principal the conversion from full ProcessHistoryID_
98  // to reduced ProcessHistoryID_ is still in memory and does
99  // not need to be recalculated if the ID does not change. I
100  // expect that very often these ID's will not change from one
101  // principal to the next and a good amount of CPU can be saved
102  // by not recalculating.
107  };
108 }
109 
110 #endif
void throwRunMissing() const
void insert(std::shared_ptr< RunPrincipal > rp)
void deleteLumi(ProcessHistoryID const &phid, RunNumber_t run, LuminosityBlockNumber_t lumi)
void setNumberOfConcurrentPrincipals(PreallocationConfiguration const &)
std::shared_ptr< RunPrincipal > const & runPrincipalPtr() const
tuple lumi
Definition: fjr2json.py:35
void throwLumiMissing() const
bool hasRunPrincipal() const
LuminosityBlockNumber_t lumi_
void adjustIndexesAfterProductRegistryAddition()
unsigned int LuminosityBlockNumber_t
std::shared_ptr< LuminosityBlockPrincipal > lumiPrincipal_
std::shared_ptr< LuminosityBlockPrincipal > const & lumiPrincipalPtr() const
RunPrincipal & runPrincipal() const
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)
bool hasLumiPrincipal() const
void deleteRun(ProcessHistoryID const &phid, RunNumber_t run)
ProcessHistoryID inputProcessHistoryID_
LuminosityBlockPrincipal & lumiPrincipal() const
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)