CMS 3D CMS Logo

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

#include <PrincipalCache.h>

Public Types

enum  ProcessBlockType { ProcessBlockType::New, ProcessBlockType::Input }
 

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
 
ProcessBlockPrincipalinputProcessBlockPrincipal () const
 
void insert (std::unique_ptr< ProcessBlockPrincipal >)
 
void insert (std::shared_ptr< RunPrincipal > rp)
 
void insert (std::unique_ptr< LuminosityBlockPrincipal > lbp)
 
void insert (std::shared_ptr< EventPrincipal > ep)
 
void insertForInput (std::unique_ptr< ProcessBlockPrincipal >)
 
void merge (std::shared_ptr< RunAuxiliary > aux, std::shared_ptr< ProductRegistry const > reg)
 
void preReadFile ()
 
 PrincipalCache ()
 
 PrincipalCache (PrincipalCache &&)=default
 
ProcessBlockPrincipalprocessBlockPrincipal () const
 
ProcessBlockPrincipalprocessBlockPrincipal (ProcessBlockType processBlockType) const
 
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_
 
std::unique_ptr< ProcessBlockPrincipalinputProcessBlockPrincipal_
 
ProcessHistoryID inputProcessHistoryID_
 
LuminosityBlockNumber_t lumi_
 
edm::ReusableObjectHolder< LuminosityBlockPrincipallumiHolder_
 
std::unique_ptr< ProcessBlockPrincipalprocessBlockPrincipal_
 
ProcessHistoryRegistry const * processHistoryRegistry_
 
ProcessHistoryID reducedInputProcessHistoryID_
 
RunNumber_t run_
 
std::shared_ptr< RunPrincipalrunPrincipal_
 

Detailed Description

Definition at line 48 of file PrincipalCache.h.

Member Enumeration Documentation

◆ ProcessBlockType

Enumerator
New 
Input 

Definition at line 57 of file PrincipalCache.h.

Constructor & Destructor Documentation

◆ PrincipalCache() [1/2]

edm::PrincipalCache::PrincipalCache ( )

Definition at line 13 of file PrincipalCache.cc.

◆ ~PrincipalCache()

edm::PrincipalCache::~PrincipalCache ( )

Definition at line 15 of file PrincipalCache.cc.

15 {}

◆ PrincipalCache() [2/2]

edm::PrincipalCache::PrincipalCache ( PrincipalCache &&  )
default

Member Function Documentation

◆ adjustEventsToNewProductRegistry()

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

Definition at line 127 of file PrincipalCache.cc.

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

Referenced by edm::EventProcessor::readFile().

127  {
128  for (auto& eventPrincipal : eventPrincipals_) {
129  if (eventPrincipal) {
131  bool eventOK = eventPrincipal->adjustToNewProductRegistry(*reg);
132  assert(eventOK);
133  }
134  }
135  }
assert(be >=bs)
std::vector< std::shared_ptr< EventPrincipal > > eventPrincipals_
EventPrincipal & eventPrincipal(unsigned int iStreamIndex) const
bool adjustToNewProductRegistry(ProductRegistry const &reg)
Definition: Principal.cc:315
void adjustIndexesAfterProductRegistryAddition()
Definition: Principal.cc:939

◆ adjustIndexesAfterProductRegistryAddition()

void edm::PrincipalCache::adjustIndexesAfterProductRegistryAddition ( )

Definition at line 137 of file PrincipalCache.cc.

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

Referenced by edm::EventProcessor::readFile().

137  {
138  if (runPrincipal_) {
139  runPrincipal_->adjustIndexesAfterProductRegistryAddition();
140  }
141  //Need to temporarily hold all the lumis to clear out the lumiHolder_
142  std::vector<std::shared_ptr<LuminosityBlockPrincipal>> temp;
143  while (auto p = lumiHolder_.tryToGet()) {
144  p->adjustIndexesAfterProductRegistryAddition();
145  temp.emplace_back(std::move(p));
146  }
147  }
edm::ReusableObjectHolder< LuminosityBlockPrincipal > lumiHolder_
std::shared_ptr< RunPrincipal > runPrincipal_
def move(src, dest)
Definition: eostools.py:511

◆ deleteRun()

void edm::PrincipalCache::deleteRun ( ProcessHistoryID const &  phid,
RunNumber_t  run 
)

Definition at line 110 of file PrincipalCache.cc.

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

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

110  {
111  if (runPrincipal_.get() == nullptr) {
112  throw edm::Exception(edm::errors::LogicError) << "PrincipalCache::deleteRun\n"
113  << "Illegal attempt to delete run from cache\n"
114  << "There is no run in cache to delete\n"
115  << "Contact a Framework Developer\n";
116  }
117  if (reducedInputProcessHistoryID_ != phid || run != run_) {
119  << "PrincipalCache::deleteRun\n"
120  << "Illegal attempt to delete run from cache\n"
121  << "Run number or reduced ProcessHistoryID inconsistent with those in cache\n"
122  << "Contact a Framework Developer\n";
123  }
124  runPrincipal_.reset();
125  }
ProcessHistoryID reducedInputProcessHistoryID_
std::shared_ptr< RunPrincipal > runPrincipal_

◆ eventPrincipal()

EventPrincipal& edm::PrincipalCache::eventPrincipal ( unsigned int  iStreamIndex) const
inline

◆ getAvailableLumiPrincipalPtr()

std::shared_ptr< LuminosityBlockPrincipal > edm::PrincipalCache::getAvailableLumiPrincipalPtr ( )

Definition at line 50 of file PrincipalCache.cc.

References lumiHolder_.

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

50  {
51  return lumiHolder_.tryToGet();
52  }
edm::ReusableObjectHolder< LuminosityBlockPrincipal > lumiHolder_

◆ hasRunPrincipal()

bool edm::PrincipalCache::hasRunPrincipal ( ) const
inline

Definition at line 66 of file PrincipalCache.h.

References electrons_cff::bool, and runPrincipal_.

Referenced by edm::EventProcessor::readLuminosityBlock(), and edm::EventProcessor::readRun().

66 { return bool(runPrincipal_); }
std::shared_ptr< RunPrincipal > runPrincipal_

◆ inputProcessBlockPrincipal()

ProcessBlockPrincipal& edm::PrincipalCache::inputProcessBlockPrincipal ( ) const
inline

◆ insert() [1/4]

void edm::PrincipalCache::insert ( std::unique_ptr< ProcessBlockPrincipal pb)

◆ insert() [2/4]

void edm::PrincipalCache::insert ( std::shared_ptr< RunPrincipal rp)

Definition at line 82 of file PrincipalCache.cc.

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

Referenced by SequenceTypes.Schedule::_replaceIfHeldDirectly().

82  {
83  if (runPrincipal_.get() != nullptr) {
84  throw edm::Exception(edm::errors::LogicError) << "PrincipalCache::insert\n"
85  << "Illegal attempt to insert run into cache\n"
86  << "Contact a Framework Developer\n";
87  }
88  if (inputProcessHistoryID_ != rp->aux().processHistoryID()) {
90  inputProcessHistoryID_ = rp->aux().processHistoryID();
91  }
92  run_ = rp->run();
93  runPrincipal_ = rp;
94  }
ProcessHistoryID reducedInputProcessHistoryID_
ProcessHistoryID const & reducedProcessHistoryID(ProcessHistoryID const &fullID) const
ProcessHistoryID inputProcessHistoryID_
ProcessHistoryRegistry const * processHistoryRegistry_
std::shared_ptr< RunPrincipal > runPrincipal_

◆ insert() [3/4]

void edm::PrincipalCache::insert ( std::unique_ptr< LuminosityBlockPrincipal lbp)

Definition at line 102 of file PrincipalCache.cc.

References lumiHolder_, and eostools::move().

Referenced by SequenceTypes.Schedule::_replaceIfHeldDirectly().

102 { lumiHolder_.add(std::move(lbp)); }
edm::ReusableObjectHolder< LuminosityBlockPrincipal > lumiHolder_
def move(src, dest)
Definition: eostools.py:511

◆ insert() [4/4]

void edm::PrincipalCache::insert ( std::shared_ptr< EventPrincipal ep)

Definition at line 104 of file PrincipalCache.cc.

References cms::cuda::assert(), SiStripBadComponentsDQMServiceTemplate_cfg::ep, and eventPrincipals_.

Referenced by SequenceTypes.Schedule::_replaceIfHeldDirectly().

104  {
105  unsigned int iStreamIndex = ep->streamID().value();
106  assert(iStreamIndex < eventPrincipals_.size());
107  eventPrincipals_[iStreamIndex] = ep;
108  }
assert(be >=bs)
std::vector< std::shared_ptr< EventPrincipal > > eventPrincipals_

◆ insertForInput()

void edm::PrincipalCache::insertForInput ( std::unique_ptr< ProcessBlockPrincipal pb)

Definition at line 98 of file PrincipalCache.cc.

References inputProcessBlockPrincipal_, and eostools::move().

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

98  {
100  }
std::unique_ptr< ProcessBlockPrincipal > inputProcessBlockPrincipal_
def move(src, dest)
Definition: eostools.py:511

◆ merge()

void edm::PrincipalCache::merge ( std::shared_ptr< RunAuxiliary aux,
std::shared_ptr< ProductRegistry const >  reg 
)

Definition at line 54 of file PrincipalCache.cc.

References cms::cuda::assert(), printConversionInfo::aux, Exception, inputProcessHistoryID_, edm::errors::LogicError, processHistoryRegistry_, reducedInputProcessHistoryID_, edm::ProcessHistoryRegistry::reducedProcessHistoryID(), run_, and runPrincipal_.

Referenced by edm::EventProcessor::readAndMergeRun().

54  {
55  if (runPrincipal_.get() == nullptr) {
56  throw edm::Exception(edm::errors::LogicError) << "PrincipalCache::merge\n"
57  << "Illegal attempt to merge run into cache\n"
58  << "There is no run in cache to merge with\n"
59  << "Contact a Framework Developer\n";
60  }
61  if (inputProcessHistoryID_ != aux->processHistoryID()) {
64  << "PrincipalCache::merge\n"
65  << "Illegal attempt to merge run into cache\n"
66  << "Reduced ProcessHistoryID inconsistent with the one already in cache\n"
67  << "Contact a Framework Developer\n";
68  }
69  inputProcessHistoryID_ = aux->processHistoryID();
70  }
71  if (aux->run() != run_) {
72  throw edm::Exception(edm::errors::LogicError) << "PrincipalCache::merge\n"
73  << "Illegal attempt to merge run into cache\n"
74  << "Run number inconsistent with run number already in cache\n"
75  << "Contact a Framework Developer\n";
76  }
77  bool runOK = runPrincipal_->adjustToNewProductRegistry(*reg);
78  assert(runOK);
79  runPrincipal_->mergeAuxiliary(*aux);
80  }
assert(be >=bs)
ProcessHistoryID reducedInputProcessHistoryID_
ProcessHistoryID const & reducedProcessHistoryID(ProcessHistoryID const &fullID) const
ProcessHistoryID inputProcessHistoryID_
ProcessHistoryRegistry const * processHistoryRegistry_
std::shared_ptr< RunPrincipal > runPrincipal_

◆ preReadFile()

void edm::PrincipalCache::preReadFile ( )

Definition at line 149 of file PrincipalCache.cc.

References runPrincipal_.

Referenced by edm::EventProcessor::readFile().

149  {
150  if (runPrincipal_) {
151  runPrincipal_->preReadFile();
152  }
153  }
std::shared_ptr< RunPrincipal > runPrincipal_

◆ processBlockPrincipal() [1/2]

ProcessBlockPrincipal& edm::PrincipalCache::processBlockPrincipal ( ) const
inline

◆ processBlockPrincipal() [2/2]

ProcessBlockPrincipal& edm::PrincipalCache::processBlockPrincipal ( ProcessBlockType  processBlockType) const
inline

Definition at line 58 of file PrincipalCache.h.

References Input, inputProcessBlockPrincipal_, and processBlockPrincipal_.

58  {
60  }
std::unique_ptr< ProcessBlockPrincipal > processBlockPrincipal_
std::unique_ptr< ProcessBlockPrincipal > inputProcessBlockPrincipal_

◆ runPrincipal() [1/2]

RunPrincipal & edm::PrincipalCache::runPrincipal ( ProcessHistoryID const &  phid,
RunNumber_t  run 
) const

◆ runPrincipal() [2/2]

RunPrincipal & edm::PrincipalCache::runPrincipal ( ) const

Definition at line 36 of file PrincipalCache.cc.

References runPrincipal_, and throwRunMissing().

36  {
37  if (runPrincipal_.get() == nullptr) {
39  }
40  return *runPrincipal_.get();
41  }
void throwRunMissing() const
std::shared_ptr< RunPrincipal > runPrincipal_

◆ runPrincipalPtr() [1/2]

std::shared_ptr< RunPrincipal > const & edm::PrincipalCache::runPrincipalPtr ( ProcessHistoryID const &  phid,
RunNumber_t  run 
) const

◆ runPrincipalPtr() [2/2]

std::shared_ptr< RunPrincipal > const & edm::PrincipalCache::runPrincipalPtr ( ) const

Definition at line 43 of file PrincipalCache.cc.

References runPrincipal_, and throwRunMissing().

43  {
44  if (runPrincipal_.get() == nullptr) {
46  }
47  return runPrincipal_;
48  }
void throwRunMissing() const
std::shared_ptr< RunPrincipal > runPrincipal_

◆ setNumberOfConcurrentPrincipals()

void edm::PrincipalCache::setNumberOfConcurrentPrincipals ( PreallocationConfiguration const &  iConfig)

Definition at line 17 of file PrincipalCache.cc.

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

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

17  {
18  eventPrincipals_.resize(iConfig.numberOfStreams());
19  }
std::vector< std::shared_ptr< EventPrincipal > > eventPrincipals_

◆ setProcessHistoryRegistry()

void edm::PrincipalCache::setProcessHistoryRegistry ( ProcessHistoryRegistry const &  phr)
inline

Definition at line 87 of file PrincipalCache.h.

References processHistoryRegistry_.

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

87 { processHistoryRegistry_ = &phr; }
ProcessHistoryRegistry const * processHistoryRegistry_

◆ throwLumiMissing()

void edm::PrincipalCache::throwLumiMissing ( ) const
private

Definition at line 161 of file PrincipalCache.cc.

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

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

◆ throwRunMissing()

void edm::PrincipalCache::throwRunMissing ( ) const
private

Definition at line 155 of file PrincipalCache.cc.

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

Referenced by runPrincipal(), and runPrincipalPtr().

155  {
156  throw edm::Exception(edm::errors::LogicError) << "PrincipalCache::runPrincipal\n"
157  << "Requested a run that is not in the cache (should never happen)\n"
158  << "Contact a Framework Developer\n";
159  }

Member Data Documentation

◆ eventPrincipals_

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

◆ inputProcessBlockPrincipal_

std::unique_ptr<ProcessBlockPrincipal> edm::PrincipalCache::inputProcessBlockPrincipal_
private

◆ inputProcessHistoryID_

ProcessHistoryID edm::PrincipalCache::inputProcessHistoryID_
private

Definition at line 113 of file PrincipalCache.h.

Referenced by insert(), and merge().

◆ lumi_

LuminosityBlockNumber_t edm::PrincipalCache::lumi_
private

Definition at line 116 of file PrincipalCache.h.

◆ lumiHolder_

edm::ReusableObjectHolder<LuminosityBlockPrincipal> edm::PrincipalCache::lumiHolder_
private

◆ processBlockPrincipal_

std::unique_ptr<ProcessBlockPrincipal> edm::PrincipalCache::processBlockPrincipal_
private

Definition at line 97 of file PrincipalCache.h.

Referenced by insert(), and processBlockPrincipal().

◆ processHistoryRegistry_

ProcessHistoryRegistry const* edm::PrincipalCache::processHistoryRegistry_
private

Definition at line 104 of file PrincipalCache.h.

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

◆ reducedInputProcessHistoryID_

ProcessHistoryID edm::PrincipalCache::reducedInputProcessHistoryID_
private

Definition at line 114 of file PrincipalCache.h.

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

◆ run_

RunNumber_t edm::PrincipalCache::run_
private

Definition at line 115 of file PrincipalCache.h.

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

◆ runPrincipal_

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