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:
51  PrincipalCache(PrincipalCache&&) = default;
52 
54  std::shared_ptr<RunPrincipal> const& runPrincipalPtr(ProcessHistoryID const& phid, RunNumber_t run) const;
55  RunPrincipal& runPrincipal() const;
56  std::shared_ptr<RunPrincipal> const& runPrincipalPtr() const;
57  bool hasRunPrincipal() const { return bool(runPrincipal_); }
58 
59  std::shared_ptr<LuminosityBlockPrincipal> getAvailableLumiPrincipalPtr();
60 
61  EventPrincipal& eventPrincipal(unsigned int iStreamIndex) const { return *(eventPrincipals_[iStreamIndex]); }
62 
63  void merge(std::shared_ptr<RunAuxiliary> aux, std::shared_ptr<ProductRegistry const> reg);
64 
66  void insert(std::shared_ptr<RunPrincipal> rp);
67  void insert(std::unique_ptr<LuminosityBlockPrincipal> lbp);
68  void insert(std::shared_ptr<EventPrincipal> ep);
69 
70  void deleteRun(ProcessHistoryID const& phid, RunNumber_t run);
71 
72  void adjustEventsToNewProductRegistry(std::shared_ptr<ProductRegistry const> reg);
73 
75 
77 
78  void preReadFile();
79 
80  private:
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 } // namespace edm
106 
107 #endif
edm::RunNumber_t
unsigned int RunNumber_t
Definition: RunLumiEventNumber.h:14
ProcessHistoryID.h
electrons_cff.bool
bool
Definition: electrons_cff.py:372
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::PrincipalCache::setProcessHistoryRegistry
void setProcessHistoryRegistry(ProcessHistoryRegistry const &phr)
Definition: PrincipalCache.h:76
ProcessHistoryRegistry.h
edm::PrincipalCache::~PrincipalCache
~PrincipalCache()
Definition: PrincipalCache.cc:14
edm::LuminosityBlockNumber_t
unsigned int LuminosityBlockNumber_t
Definition: RunLumiEventNumber.h:13
edm::PrincipalCache::runPrincipalPtr
std::shared_ptr< RunPrincipal > const & runPrincipalPtr() const
Definition: PrincipalCache.cc:42
LuminosityBlockID.h
edm::PrincipalCache::throwLumiMissing
void throwLumiMissing() const
Definition: PrincipalCache.cc:154
edm::ReusableObjectHolder
Definition: ReusableObjectHolder.h:80
edm::PrincipalCache::lumi_
LuminosityBlockNumber_t lumi_
Definition: PrincipalCache.h:103
ReusableObjectHolder.h
edm::EventPrincipal
Definition: EventPrincipal.h:46
edm::PrincipalCache::eventPrincipals_
std::vector< std::shared_ptr< EventPrincipal > > eventPrincipals_
Definition: PrincipalCache.h:88
edm::PrincipalCache
Definition: PrincipalCache.h:47
edm::PrincipalCache::merge
void merge(std::shared_ptr< RunAuxiliary > aux, std::shared_ptr< ProductRegistry const > reg)
Definition: PrincipalCache.cc:53
edm::PrincipalCache::runPrincipal_
std::shared_ptr< RunPrincipal > runPrincipal_
Definition: PrincipalCache.h:86
edm::Hash< ProcessHistoryType >
edm::PrincipalCache::PrincipalCache
PrincipalCache()
Definition: PrincipalCache.cc:12
edm::PrincipalCache::preReadFile
void preReadFile()
Definition: PrincipalCache.cc:142
edm::PrincipalCache::deleteRun
void deleteRun(ProcessHistoryID const &phid, RunNumber_t run)
Definition: PrincipalCache.cc:103
edm::PrincipalCache::processHistoryRegistry_
ProcessHistoryRegistry const * processHistoryRegistry_
Definition: PrincipalCache.h:91
printConversionInfo.aux
aux
Definition: printConversionInfo.py:19
edm::PrincipalCache::throwRunMissing
void throwRunMissing() const
Definition: PrincipalCache.cc:148
edm::PrincipalCache::reducedInputProcessHistoryID_
ProcessHistoryID reducedInputProcessHistoryID_
Definition: PrincipalCache.h:101
edm::PrincipalCache::runPrincipal
RunPrincipal & runPrincipal() const
Definition: PrincipalCache.cc:35
edm::PrincipalCache::adjustEventsToNewProductRegistry
void adjustEventsToNewProductRegistry(std::shared_ptr< ProductRegistry const > reg)
Definition: PrincipalCache.cc:120
edm::PrincipalCache::inputProcessHistoryID_
ProcessHistoryID inputProcessHistoryID_
Definition: PrincipalCache.h:100
edm::PreallocationConfiguration
Definition: PreallocationConfiguration.h:27
writedatasetfile.run
run
Definition: writedatasetfile.py:27
edm::PrincipalCache::getAvailableLumiPrincipalPtr
std::shared_ptr< LuminosityBlockPrincipal > getAvailableLumiPrincipalPtr()
Definition: PrincipalCache.cc:49
edm::PrincipalCache::hasRunPrincipal
bool hasRunPrincipal() const
Definition: PrincipalCache.h:57
edm::ProcessHistoryRegistry
Definition: ProcessHistoryRegistry.h:18
edm::RunPrincipal
Definition: RunPrincipal.h:34
edm::PrincipalCache::eventPrincipal
EventPrincipal & eventPrincipal(unsigned int iStreamIndex) const
Definition: PrincipalCache.h:61
edm::PrincipalCache::lumiHolder_
edm::ReusableObjectHolder< LuminosityBlockPrincipal > lumiHolder_
Definition: PrincipalCache.h:87
edm::PrincipalCache::run_
RunNumber_t run_
Definition: PrincipalCache.h:102
edm::PrincipalCache::insert
void insert(std::shared_ptr< RunPrincipal > rp)
Definition: PrincipalCache.cc:81
SiStripBadComponentsDQMServiceTemplate_cfg.ep
ep
Definition: SiStripBadComponentsDQMServiceTemplate_cfg.py:86
RunID.h
edm::PrincipalCache::adjustIndexesAfterProductRegistryAddition
void adjustIndexesAfterProductRegistryAddition()
Definition: PrincipalCache.cc:130
edm::PrincipalCache::setNumberOfConcurrentPrincipals
void setNumberOfConcurrentPrincipals(PreallocationConfiguration const &)
Definition: PrincipalCache.cc:16