CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
edm::PrincipalCache Class Reference

#include <PrincipalCache.h>

Public Member Functions

void adjustEventsToNewProductRegistry (std::shared_ptr< ProductRegistry const > reg)
 
void adjustIndexesAfterProductRegistryAddition ()
 
void deleteRun (ProcessHistoryID const &phid, RunNumber_t run)
 
EventPrincipaleventPrincipal (unsigned int iStreamIndex) const
 
std::shared_ptr< LuminosityBlockPrincipalgetAvailableLumiPrincipalPtr ()
 
bool hasRunPrincipal () const
 
void insert (std::shared_ptr< RunPrincipal > rp)
 
void insert (std::unique_ptr< LuminosityBlockPrincipal > lbp)
 
void insert (std::shared_ptr< EventPrincipal > ep)
 
void merge (std::shared_ptr< RunAuxiliary > aux, std::shared_ptr< ProductRegistry const > reg)
 
 PrincipalCache ()
 
 PrincipalCache (PrincipalCache &&)=default
 
RunPrincipalrunPrincipal (ProcessHistoryID const &phid, RunNumber_t run) const
 
RunPrincipalrunPrincipal () const
 
std::shared_ptr< RunPrincipal > const & runPrincipalPtr (ProcessHistoryID const &phid, RunNumber_t run) const
 
std::shared_ptr< RunPrincipal > const & runPrincipalPtr () const
 
void setNumberOfConcurrentPrincipals (PreallocationConfiguration const &)
 
void setProcessHistoryRegistry (ProcessHistoryRegistry const &phr)
 
 ~PrincipalCache ()
 

Private Member Functions

void throwLumiMissing () const
 
void throwRunMissing () const
 

Private Attributes

std::vector< std::shared_ptr< EventPrincipal > > eventPrincipals_
 
ProcessHistoryID inputProcessHistoryID_
 
LuminosityBlockNumber_t lumi_
 
edm::ReusableObjectHolder< LuminosityBlockPrincipallumiHolder_
 
ProcessHistoryRegistry const * processHistoryRegistry_
 
ProcessHistoryID reducedInputProcessHistoryID_
 
RunNumber_t run_
 
std::shared_ptr< RunPrincipalrunPrincipal_
 

Detailed Description

Definition at line 47 of file PrincipalCache.h.

Constructor & Destructor Documentation

edm::PrincipalCache::PrincipalCache ( )

Definition at line 12 of file PrincipalCache.cc.

12  :
13  run_(0U),
14  lumi_(0U) {
15  }
LuminosityBlockNumber_t lumi_
edm::PrincipalCache::~PrincipalCache ( )

Definition at line 17 of file PrincipalCache.cc.

17 { }
edm::PrincipalCache::PrincipalCache ( PrincipalCache &&  )
default

Member Function Documentation

void edm::PrincipalCache::adjustEventsToNewProductRegistry ( std::shared_ptr< ProductRegistry const >  reg)

Definition at line 138 of file PrincipalCache.cc.

References edm::Principal::adjustIndexesAfterProductRegistryAddition(), edm::Principal::adjustToNewProductRegistry(), eventPrincipal(), and eventPrincipals_.

Referenced by eventPrincipal(), and edm::EventProcessor::readFile().

138  {
139  for(auto &eventPrincipal : eventPrincipals_) {
140  if (eventPrincipal) {
142  bool eventOK = eventPrincipal->adjustToNewProductRegistry(*reg);
143  assert(eventOK);
144  }
145  }
146  }
std::vector< std::shared_ptr< EventPrincipal > > eventPrincipals_
EventPrincipal & eventPrincipal(unsigned int iStreamIndex) const
bool adjustToNewProductRegistry(ProductRegistry const &reg)
Definition: Principal.cc:287
void adjustIndexesAfterProductRegistryAddition()
Definition: Principal.cc:895
void edm::PrincipalCache::adjustIndexesAfterProductRegistryAddition ( )

Definition at line 148 of file PrincipalCache.cc.

References lumiHolder_, eostools::move(), AlCaHLTBitMon_ParallelJobs::p, runPrincipal_, and groupFilesInBlocks::temp.

Referenced by eventPrincipal(), and edm::EventProcessor::readFile().

148  {
149  if (runPrincipal_) {
150  runPrincipal_->adjustIndexesAfterProductRegistryAddition();
151  }
152  //Need to temporarily hold all the lumis to clear out the lumiHolder_
153  std::vector<std::shared_ptr<LuminosityBlockPrincipal>> temp;
154  while(auto p = lumiHolder_.tryToGet()) {
155  p->adjustIndexesAfterProductRegistryAddition();
156  temp.emplace_back(std::move(p));
157  }
158  }
edm::ReusableObjectHolder< LuminosityBlockPrincipal > lumiHolder_
std::shared_ptr< RunPrincipal > runPrincipal_
def move(src, dest)
Definition: eostools.py:510
void edm::PrincipalCache::deleteRun ( ProcessHistoryID const &  phid,
RunNumber_t  run 
)

Definition at line 119 of file PrincipalCache.cc.

References Exception, edm::errors::LogicError, reducedInputProcessHistoryID_, run_, and runPrincipal_.

Referenced by edm::SubProcess::deleteRunFromCache(), edm::EventProcessor::deleteRunFromCache(), edm::test::TestProcessor::endRun(), and eventPrincipal().

119  {
120  if (runPrincipal_.get() == nullptr) {
122  << "PrincipalCache::deleteRun\n"
123  << "Illegal attempt to delete run from cache\n"
124  << "There is no run in cache to delete\n"
125  << "Contact a Framework Developer\n";
126  }
127  if (reducedInputProcessHistoryID_ != phid ||
128  run != run_) {
130  << "PrincipalCache::deleteRun\n"
131  << "Illegal attempt to delete run from cache\n"
132  << "Run number or reduced ProcessHistoryID inconsistent with those in cache\n"
133  << "Contact a Framework Developer\n";
134  }
135  runPrincipal_.reset();
136  }
ProcessHistoryID reducedInputProcessHistoryID_
std::shared_ptr< RunPrincipal > runPrincipal_
EventPrincipal& edm::PrincipalCache::eventPrincipal ( unsigned int  iStreamIndex) const
inline
std::shared_ptr< LuminosityBlockPrincipal > edm::PrincipalCache::getAvailableLumiPrincipalPtr ( )

Definition at line 62 of file PrincipalCache.cc.

References lumiHolder_.

Referenced by edm::test::TestProcessor::beginLuminosityBlock(), edm::SubProcess::doBeginLuminosityBlockAsync(), hasRunPrincipal(), and edm::EventProcessor::readLuminosityBlock().

62 { return lumiHolder_.tryToGet();}
edm::ReusableObjectHolder< LuminosityBlockPrincipal > lumiHolder_
bool edm::PrincipalCache::hasRunPrincipal ( ) const
inline
void edm::PrincipalCache::insert ( std::shared_ptr< RunPrincipal rp)

Definition at line 94 of file PrincipalCache.cc.

References Exception, inputProcessHistoryID_, edm::errors::LogicError, processHistoryRegistry_, reducedInputProcessHistoryID_, edm::ProcessHistoryRegistry::reducedProcessHistoryID(), run_, and runPrincipal_.

Referenced by edm::test::TestProcessor::beginRun(), edm::SubProcess::doBeginRunAsync(), eventPrincipal(), edm::EventProcessor::init(), edm::EventProcessor::readRun(), edm::SubProcess::SubProcess(), and edm::test::TestProcessor::TestProcessor().

94  {
95  if (runPrincipal_.get() != nullptr) {
97  << "PrincipalCache::insert\n"
98  << "Illegal attempt to insert run into cache\n"
99  << "Contact a Framework Developer\n";
100  }
101  if (inputProcessHistoryID_ != rp->aux().processHistoryID()) {
103  inputProcessHistoryID_ = rp->aux().processHistoryID();
104  }
105  run_ = rp->run();
106  runPrincipal_ = rp;
107  }
ProcessHistoryID reducedInputProcessHistoryID_
ProcessHistoryID const & reducedProcessHistoryID(ProcessHistoryID const &fullID) const
ProcessHistoryID inputProcessHistoryID_
ProcessHistoryRegistry const * processHistoryRegistry_
std::shared_ptr< RunPrincipal > runPrincipal_
void edm::PrincipalCache::insert ( std::unique_ptr< LuminosityBlockPrincipal lbp)

Definition at line 109 of file PrincipalCache.cc.

References lumiHolder_, and eostools::move().

109  {
110  lumiHolder_.add(std::move(lbp));
111  }
edm::ReusableObjectHolder< LuminosityBlockPrincipal > lumiHolder_
def move(src, dest)
Definition: eostools.py:510
void edm::PrincipalCache::insert ( std::shared_ptr< EventPrincipal ep)

Definition at line 113 of file PrincipalCache.cc.

References eventPrincipals_.

113  {
114  unsigned int iStreamIndex = ep->streamID().value();
115  assert(iStreamIndex < eventPrincipals_.size());
116  eventPrincipals_[iStreamIndex] = ep;
117  }
std::vector< std::shared_ptr< EventPrincipal > > eventPrincipals_
void edm::PrincipalCache::merge ( std::shared_ptr< RunAuxiliary aux,
std::shared_ptr< ProductRegistry const >  reg 
)

Definition at line 64 of file PrincipalCache.cc.

References Exception, inputProcessHistoryID_, edm::errors::LogicError, processHistoryRegistry_, reducedInputProcessHistoryID_, edm::ProcessHistoryRegistry::reducedProcessHistoryID(), run_, and runPrincipal_.

Referenced by eventPrincipal(), and edm::EventProcessor::readAndMergeRun().

64  {
65  if (runPrincipal_.get() == nullptr) {
67  << "PrincipalCache::merge\n"
68  << "Illegal attempt to merge run into cache\n"
69  << "There is no run in cache to merge with\n"
70  << "Contact a Framework Developer\n";
71  }
72  if (inputProcessHistoryID_ != aux->processHistoryID()) {
75  << "PrincipalCache::merge\n"
76  << "Illegal attempt to merge run into cache\n"
77  << "Reduced ProcessHistoryID inconsistent with the one already in cache\n"
78  << "Contact a Framework Developer\n";
79  }
80  inputProcessHistoryID_ = aux->processHistoryID();
81  }
82  if (aux->run() != run_) {
84  << "PrincipalCache::merge\n"
85  << "Illegal attempt to merge run into cache\n"
86  << "Run number inconsistent with run number already in cache\n"
87  << "Contact a Framework Developer\n";
88  }
89  bool runOK = runPrincipal_->adjustToNewProductRegistry(*reg);
90  assert(runOK);
91  runPrincipal_->mergeAuxiliary(*aux);
92  }
ProcessHistoryID reducedInputProcessHistoryID_
ProcessHistoryID const & reducedProcessHistoryID(ProcessHistoryID const &fullID) const
ProcessHistoryID inputProcessHistoryID_
ProcessHistoryRegistry const * processHistoryRegistry_
std::shared_ptr< RunPrincipal > runPrincipal_
RunPrincipal & edm::PrincipalCache::runPrincipal ( ProcessHistoryID const &  phid,
RunNumber_t  run 
) const
RunPrincipal & edm::PrincipalCache::runPrincipal ( ) const

Definition at line 46 of file PrincipalCache.cc.

References runPrincipal_, and throwRunMissing().

46  {
47  if (runPrincipal_.get() == nullptr) {
49  }
50  return *runPrincipal_.get();
51  }
void throwRunMissing() const
std::shared_ptr< RunPrincipal > runPrincipal_
std::shared_ptr< RunPrincipal > const & edm::PrincipalCache::runPrincipalPtr ( ProcessHistoryID const &  phid,
RunNumber_t  run 
) const
std::shared_ptr< RunPrincipal > const & edm::PrincipalCache::runPrincipalPtr ( ) const

Definition at line 54 of file PrincipalCache.cc.

References runPrincipal_, and throwRunMissing().

54  {
55  if (runPrincipal_.get() == nullptr) {
57  }
58  return runPrincipal_;
59  }
void throwRunMissing() const
std::shared_ptr< RunPrincipal > runPrincipal_
void edm::PrincipalCache::setNumberOfConcurrentPrincipals ( PreallocationConfiguration const &  iConfig)

Definition at line 20 of file PrincipalCache.cc.

References eventPrincipals_, and edm::PreallocationConfiguration::numberOfStreams().

Referenced by eventPrincipal(), edm::EventProcessor::init(), edm::SubProcess::SubProcess(), and edm::test::TestProcessor::TestProcessor().

21  {
22  eventPrincipals_.resize(iConfig.numberOfStreams());
23  }
std::vector< std::shared_ptr< EventPrincipal > > eventPrincipals_
void edm::PrincipalCache::setProcessHistoryRegistry ( ProcessHistoryRegistry const &  phr)
inline
void edm::PrincipalCache::throwLumiMissing ( ) const
private

Definition at line 169 of file PrincipalCache.cc.

References Exception, and edm::errors::LogicError.

Referenced by setProcessHistoryRegistry().

169  {
171  << "PrincipalCache::lumiPrincipal or PrincipalCache::lumiPrincipalPtr\n"
172  << "Requested a luminosity block that is not in the cache (should never happen)\n"
173  << "Contact a Framework Developer\n";
174  }
void edm::PrincipalCache::throwRunMissing ( ) const
private

Definition at line 161 of file PrincipalCache.cc.

References Exception, and edm::errors::LogicError.

Referenced by runPrincipal(), runPrincipalPtr(), and setProcessHistoryRegistry().

161  {
163  << "PrincipalCache::runPrincipal\n"
164  << "Requested a run that is not in the cache (should never happen)\n"
165  << "Contact a Framework Developer\n";
166  }

Member Data Documentation

std::vector<std::shared_ptr<EventPrincipal> > edm::PrincipalCache::eventPrincipals_
private
ProcessHistoryID edm::PrincipalCache::inputProcessHistoryID_
private

Definition at line 100 of file PrincipalCache.h.

Referenced by insert(), and merge().

LuminosityBlockNumber_t edm::PrincipalCache::lumi_
private

Definition at line 103 of file PrincipalCache.h.

edm::ReusableObjectHolder<LuminosityBlockPrincipal> edm::PrincipalCache::lumiHolder_
private
ProcessHistoryRegistry const* edm::PrincipalCache::processHistoryRegistry_
private

Definition at line 91 of file PrincipalCache.h.

Referenced by insert(), merge(), and setProcessHistoryRegistry().

ProcessHistoryID edm::PrincipalCache::reducedInputProcessHistoryID_
private

Definition at line 101 of file PrincipalCache.h.

Referenced by deleteRun(), insert(), merge(), runPrincipal(), and runPrincipalPtr().

RunNumber_t edm::PrincipalCache::run_
private

Definition at line 102 of file PrincipalCache.h.

Referenced by deleteRun(), insert(), merge(), runPrincipal(), and runPrincipalPtr().

std::shared_ptr<RunPrincipal> edm::PrincipalCache::runPrincipal_
private