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 ProcessBlockPrincipal;
40  class RunPrincipal;
41  class LuminosityBlockPrincipal;
42  class EventPrincipal;
43  class RunAuxiliary;
44  class LuminosityBlockAuxiliary;
45  class ProductRegistry;
46  class PreallocationConfiguration;
47 
49  public:
52  PrincipalCache(PrincipalCache&&) = default;
53 
56 
57  enum class ProcessBlockType { New, Input };
60  }
61 
63  std::shared_ptr<RunPrincipal> const& runPrincipalPtr(ProcessHistoryID const& phid, RunNumber_t run) const;
64  RunPrincipal& runPrincipal() const;
65  std::shared_ptr<RunPrincipal> const& runPrincipalPtr() const;
66  bool hasRunPrincipal() const { return bool(runPrincipal_); }
67 
68  std::shared_ptr<LuminosityBlockPrincipal> getAvailableLumiPrincipalPtr();
69 
70  EventPrincipal& eventPrincipal(unsigned int iStreamIndex) const { return *(eventPrincipals_[iStreamIndex]); }
71 
72  void merge(std::shared_ptr<RunAuxiliary> aux, std::shared_ptr<ProductRegistry const> reg);
73 
75  void insert(std::unique_ptr<ProcessBlockPrincipal>);
76  void insertForInput(std::unique_ptr<ProcessBlockPrincipal>);
77  void insert(std::shared_ptr<RunPrincipal> rp);
78  void insert(std::unique_ptr<LuminosityBlockPrincipal> lbp);
79  void insert(std::shared_ptr<EventPrincipal> ep);
80 
81  void deleteRun(ProcessHistoryID const& phid, RunNumber_t run);
82 
83  void adjustEventsToNewProductRegistry(std::shared_ptr<ProductRegistry const> reg);
84 
86 
88 
89  void preReadFile();
90 
91  private:
92  void throwRunMissing() const;
93  void throwLumiMissing() const;
94 
95  // These are explicitly cleared when finished with the processblock, run,
96  // lumi, or event
97  std::unique_ptr<ProcessBlockPrincipal> processBlockPrincipal_;
98  std::unique_ptr<ProcessBlockPrincipal> inputProcessBlockPrincipal_;
99  std::shared_ptr<RunPrincipal> runPrincipal_;
101  std::vector<std::shared_ptr<EventPrincipal>> eventPrincipals_;
102 
103  // This is just an accessor to the registry owned by the input source.
104  ProcessHistoryRegistry const* processHistoryRegistry_; // We don't own this
105 
106  // These are intentionally not cleared so that when inserting
107  // the next principal the conversion from full ProcessHistoryID_
108  // to reduced ProcessHistoryID_ is still in memory and does
109  // not need to be recalculated if the ID does not change. I
110  // expect that very often these ID's will not change from one
111  // principal to the next and a good amount of CPU can be saved
112  // by not recalculating.
117  };
118 } // namespace edm
119 
120 #endif
edm::RunNumber_t
unsigned int RunNumber_t
Definition: RunLumiEventNumber.h:14
ProcessHistoryID.h
edm::PrincipalCache::ProcessBlockType::New
electrons_cff.bool
bool
Definition: electrons_cff.py:366
edm::PrincipalCache::processBlockPrincipal_
std::unique_ptr< ProcessBlockPrincipal > processBlockPrincipal_
Definition: PrincipalCache.h:97
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::PrincipalCache::setProcessHistoryRegistry
void setProcessHistoryRegistry(ProcessHistoryRegistry const &phr)
Definition: PrincipalCache.h:87
ProcessHistoryRegistry.h
edm::PrincipalCache::~PrincipalCache
~PrincipalCache()
Definition: PrincipalCache.cc:15
edm::LuminosityBlockNumber_t
unsigned int LuminosityBlockNumber_t
Definition: RunLumiEventNumber.h:13
edm::PrincipalCache::runPrincipalPtr
std::shared_ptr< RunPrincipal > const & runPrincipalPtr() const
Definition: PrincipalCache.cc:43
edm::ProcessBlockPrincipal
Definition: ProcessBlockPrincipal.h:22
LuminosityBlockID.h
edm::PrincipalCache::throwLumiMissing
void throwLumiMissing() const
Definition: PrincipalCache.cc:161
edm::ReusableObjectHolder
Definition: ReusableObjectHolder.h:80
edm::PrincipalCache::lumi_
LuminosityBlockNumber_t lumi_
Definition: PrincipalCache.h:116
ReusableObjectHolder.h
edm::EventPrincipal
Definition: EventPrincipal.h:46
edm::PrincipalCache::eventPrincipals_
std::vector< std::shared_ptr< EventPrincipal > > eventPrincipals_
Definition: PrincipalCache.h:101
edm::PrincipalCache
Definition: PrincipalCache.h:48
edm::PrincipalCache::merge
void merge(std::shared_ptr< RunAuxiliary > aux, std::shared_ptr< ProductRegistry const > reg)
Definition: PrincipalCache.cc:54
edm::PrincipalCache::runPrincipal_
std::shared_ptr< RunPrincipal > runPrincipal_
Definition: PrincipalCache.h:99
edm::Hash< ProcessHistoryType >
edm::PrincipalCache::PrincipalCache
PrincipalCache()
Definition: PrincipalCache.cc:13
edm::PrincipalCache::processBlockPrincipal
ProcessBlockPrincipal & processBlockPrincipal(ProcessBlockType processBlockType) const
Definition: PrincipalCache.h:58
edm::PrincipalCache::preReadFile
void preReadFile()
Definition: PrincipalCache.cc:149
edm::PrincipalCache::deleteRun
void deleteRun(ProcessHistoryID const &phid, RunNumber_t run)
Definition: PrincipalCache.cc:110
edm::PrincipalCache::processHistoryRegistry_
ProcessHistoryRegistry const * processHistoryRegistry_
Definition: PrincipalCache.h:104
printConversionInfo.aux
aux
Definition: printConversionInfo.py:19
edm::PrincipalCache::throwRunMissing
void throwRunMissing() const
Definition: PrincipalCache.cc:155
edm::PrincipalCache::reducedInputProcessHistoryID_
ProcessHistoryID reducedInputProcessHistoryID_
Definition: PrincipalCache.h:114
edm::PrincipalCache::runPrincipal
RunPrincipal & runPrincipal() const
Definition: PrincipalCache.cc:36
edm::PrincipalCache::inputProcessBlockPrincipal_
std::unique_ptr< ProcessBlockPrincipal > inputProcessBlockPrincipal_
Definition: PrincipalCache.h:98
edm::PrincipalCache::insertForInput
void insertForInput(std::unique_ptr< ProcessBlockPrincipal >)
Definition: PrincipalCache.cc:98
edm::PrincipalCache::adjustEventsToNewProductRegistry
void adjustEventsToNewProductRegistry(std::shared_ptr< ProductRegistry const > reg)
Definition: PrincipalCache.cc:127
edm::PrincipalCache::inputProcessHistoryID_
ProcessHistoryID inputProcessHistoryID_
Definition: PrincipalCache.h:113
edm::PrincipalCache::ProcessBlockType
ProcessBlockType
Definition: PrincipalCache.h:57
edm::PrincipalCache::inputProcessBlockPrincipal
ProcessBlockPrincipal & inputProcessBlockPrincipal() const
Definition: PrincipalCache.h:55
edm::PreallocationConfiguration
Definition: PreallocationConfiguration.h:27
edm::PrincipalCache::ProcessBlockType::Input
writedatasetfile.run
run
Definition: writedatasetfile.py:27
edm::PrincipalCache::getAvailableLumiPrincipalPtr
std::shared_ptr< LuminosityBlockPrincipal > getAvailableLumiPrincipalPtr()
Definition: PrincipalCache.cc:50
edm::PrincipalCache::hasRunPrincipal
bool hasRunPrincipal() const
Definition: PrincipalCache.h:66
edm::ProcessHistoryRegistry
Definition: ProcessHistoryRegistry.h:18
edm::PrincipalCache::processBlockPrincipal
ProcessBlockPrincipal & processBlockPrincipal() const
Definition: PrincipalCache.h:54
edm::RunPrincipal
Definition: RunPrincipal.h:34
edm::PrincipalCache::eventPrincipal
EventPrincipal & eventPrincipal(unsigned int iStreamIndex) const
Definition: PrincipalCache.h:70
edm::PrincipalCache::insert
void insert(std::unique_ptr< ProcessBlockPrincipal >)
Definition: PrincipalCache.cc:96
edm::PrincipalCache::lumiHolder_
edm::ReusableObjectHolder< LuminosityBlockPrincipal > lumiHolder_
Definition: PrincipalCache.h:100
edm::PrincipalCache::run_
RunNumber_t run_
Definition: PrincipalCache.h:115
SiStripBadComponentsDQMServiceTemplate_cfg.ep
ep
Definition: SiStripBadComponentsDQMServiceTemplate_cfg.py:86
RunID.h
edm::PrincipalCache::adjustIndexesAfterProductRegistryAddition
void adjustIndexesAfterProductRegistryAddition()
Definition: PrincipalCache.cc:137
edm::PrincipalCache::setNumberOfConcurrentPrincipals
void setNumberOfConcurrentPrincipals(PreallocationConfiguration const &)
Definition: PrincipalCache.cc:17