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 deleteLumi (ProcessHistoryID const &phid, RunNumber_t run, LuminosityBlockNumber_t lumi)
 
void deleteRun (ProcessHistoryID const &phid, RunNumber_t run)
 
EventPrincipaleventPrincipal (unsigned int iStreamIndex) const
 
bool hasLumiPrincipal () const
 
bool hasRunPrincipal () const
 
void insert (std::shared_ptr< RunPrincipal > rp)
 
void insert (std::shared_ptr< LuminosityBlockPrincipal > lbp)
 
void insert (std::shared_ptr< EventPrincipal > ep)
 
LuminosityBlockPrincipallumiPrincipal (ProcessHistoryID const &phid, RunNumber_t run, LuminosityBlockNumber_t lumi) const
 
LuminosityBlockPrincipallumiPrincipal () const
 
std::shared_ptr< LuminosityBlockPrincipal > const & lumiPrincipalPtr (ProcessHistoryID const &phid, RunNumber_t run, LuminosityBlockNumber_t lumi) const
 
std::shared_ptr< LuminosityBlockPrincipal > const & lumiPrincipalPtr () const
 
void merge (std::shared_ptr< RunAuxiliary > aux, std::shared_ptr< ProductRegistry const > reg)
 
void merge (std::shared_ptr< LuminosityBlockAuxiliary > aux, std::shared_ptr< ProductRegistry const > reg)
 
 PrincipalCache ()
 
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_
 
std::shared_ptr< LuminosityBlockPrincipallumiPrincipal_
 
ProcessHistoryRegistry const * processHistoryRegistry_
 
ProcessHistoryID reducedInputProcessHistoryID_
 
RunNumber_t run_
 
std::shared_ptr< RunPrincipalrunPrincipal_
 

Detailed Description

Definition at line 45 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 { }

Member Function Documentation

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

Definition at line 255 of file PrincipalCache.cc.

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

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

255  {
256  for(auto &eventPrincipal : eventPrincipals_) {
257  if (eventPrincipal) {
259  bool eventOK = eventPrincipal->adjustToNewProductRegistry(*reg);
260  assert(eventOK);
261  }
262  }
263  }
std::vector< std::shared_ptr< EventPrincipal > > eventPrincipals_
EventPrincipal & eventPrincipal(unsigned int iStreamIndex) const
bool adjustToNewProductRegistry(ProductRegistry const &reg)
Definition: Principal.cc:261
void adjustIndexesAfterProductRegistryAddition()
Definition: Principal.cc:872
void edm::PrincipalCache::adjustIndexesAfterProductRegistryAddition ( )

Definition at line 265 of file PrincipalCache.cc.

References lumiPrincipal_, and runPrincipal_.

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

265  {
266  if (runPrincipal_) {
267  runPrincipal_->adjustIndexesAfterProductRegistryAddition();
268  }
269  if (lumiPrincipal_) {
270  lumiPrincipal_->adjustIndexesAfterProductRegistryAddition();
271  }
272  }
std::shared_ptr< LuminosityBlockPrincipal > lumiPrincipal_
std::shared_ptr< RunPrincipal > runPrincipal_
void edm::PrincipalCache::deleteLumi ( ProcessHistoryID const &  phid,
RunNumber_t  run,
LuminosityBlockNumber_t  lumi 
)

Definition at line 235 of file PrincipalCache.cc.

References Exception, edm::errors::LogicError, lumi_, lumiPrincipal_, reducedInputProcessHistoryID_, and run_.

Referenced by edm::SubProcess::deleteLumiFromCache(), edm::EventProcessor::deleteLumiFromCache(), and eventPrincipal().

235  {
236  if (lumiPrincipal_.get() == nullptr) {
238  << "PrincipalCache::deleteLumi\n"
239  << "Illegal attempt to delete luminosity block from cache\n"
240  << "There is no luminosity block in the cache to delete\n"
241  << "Contact a Framework Developer\n";
242  }
243  if (reducedInputProcessHistoryID_ != phid ||
244  run != run_ ||
245  lumi != lumi_) {
247  << "PrincipalCache::deleteLumi\n"
248  << "Illegal attempt to delete luminosity block from cache\n"
249  << "Run number, lumi numbers, or reduced ProcessHistoryID inconsistent with those in cache\n"
250  << "Contact a Framework Developer\n";
251  }
252  lumiPrincipal_.reset();
253  }
LuminosityBlockNumber_t lumi_
std::shared_ptr< LuminosityBlockPrincipal > lumiPrincipal_
ProcessHistoryID reducedInputProcessHistoryID_
void edm::PrincipalCache::deleteRun ( ProcessHistoryID const &  phid,
RunNumber_t  run 
)

Definition at line 216 of file PrincipalCache.cc.

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

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

216  {
217  if (runPrincipal_.get() == nullptr) {
219  << "PrincipalCache::deleteRun\n"
220  << "Illegal attempt to delete run from cache\n"
221  << "There is no run in cache to delete\n"
222  << "Contact a Framework Developer\n";
223  }
224  if (reducedInputProcessHistoryID_ != phid ||
225  run != run_) {
227  << "PrincipalCache::deleteRun\n"
228  << "Illegal attempt to delete run from cache\n"
229  << "Run number or reduced ProcessHistoryID inconsistent with those in cache\n"
230  << "Contact a Framework Developer\n";
231  }
232  runPrincipal_.reset();
233  }
ProcessHistoryID reducedInputProcessHistoryID_
std::shared_ptr< RunPrincipal > runPrincipal_
EventPrincipal& edm::PrincipalCache::eventPrincipal ( unsigned int  iStreamIndex) const
inline
bool edm::PrincipalCache::hasLumiPrincipal ( ) const
inline

Definition at line 61 of file PrincipalCache.h.

References electrons_cff::bool, and lumiPrincipal_.

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

61 {return bool(lumiPrincipal_);}
std::shared_ptr< LuminosityBlockPrincipal > lumiPrincipal_
bool edm::PrincipalCache::hasRunPrincipal ( ) const
inline
void edm::PrincipalCache::insert ( std::shared_ptr< RunPrincipal rp)

Definition at line 160 of file PrincipalCache.cc.

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

Referenced by edm::SubProcess::doBeginLuminosityBlockAsync(), edm::SubProcess::doBeginRunAsync(), eventPrincipal(), edm::EventProcessor::init(), edm::EventProcessor::readLuminosityBlock(), edm::EventProcessor::readRun(), and edm::SubProcess::SubProcess().

160  {
161  if (runPrincipal_.get() != nullptr) {
163  << "PrincipalCache::insert\n"
164  << "Illegal attempt to insert run into cache\n"
165  << "Contact a Framework Developer\n";
166  }
167  if (inputProcessHistoryID_ != rp->aux().processHistoryID()) {
169  inputProcessHistoryID_ = rp->aux().processHistoryID();
170  }
171  run_ = rp->run();
172  runPrincipal_ = rp;
173  }
ProcessHistoryID reducedInputProcessHistoryID_
ProcessHistoryID const & reducedProcessHistoryID(ProcessHistoryID const &fullID) const
ProcessHistoryID inputProcessHistoryID_
ProcessHistoryRegistry const * processHistoryRegistry_
std::shared_ptr< RunPrincipal > runPrincipal_
void edm::PrincipalCache::insert ( std::shared_ptr< LuminosityBlockPrincipal lbp)

Definition at line 175 of file PrincipalCache.cc.

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

175  {
176  if (lumiPrincipal_.get() != nullptr) {
178  << "PrincipalCache::insert\n"
179  << "Illegal attempt to insert lumi into cache\n"
180  << "Contact a Framework Developer\n";
181  }
182  if (runPrincipal_.get() == nullptr) {
184  << "PrincipalCache::insert\n"
185  << "Illegal attempt to insert lumi into cache\n"
186  << "Run is invalid\n"
187  << "Contact a Framework Developer\n";
188  }
189  if (inputProcessHistoryID_ != lbp->aux().processHistoryID()) {
190  if (reducedInputProcessHistoryID_ != processHistoryRegistry_->reducedProcessHistoryID(lbp->aux().processHistoryID())) {
192  << "PrincipalCache::insert\n"
193  << "Illegal attempt to insert lumi into cache\n"
194  << "luminosity block has ProcessHistoryID inconsistent with run\n"
195  << "Contact a Framework Developer\n";
196  }
197  inputProcessHistoryID_ = lbp->aux().processHistoryID();
198  }
199  if (lbp->run() != run_) {
201  << "PrincipalCache::insert\n"
202  << "Illegal attempt to insert lumi into cache\n"
203  << "luminosity block inconsistent with run number of run in cache\n"
204  << "Contact a Framework Developer\n";
205  }
206  lumi_ = lbp->luminosityBlock();
207  lumiPrincipal_ = lbp;
208  }
LuminosityBlockNumber_t lumi_
std::shared_ptr< LuminosityBlockPrincipal > lumiPrincipal_
ProcessHistoryID reducedInputProcessHistoryID_
ProcessHistoryID const & reducedProcessHistoryID(ProcessHistoryID const &fullID) const
ProcessHistoryID inputProcessHistoryID_
ProcessHistoryRegistry const * processHistoryRegistry_
std::shared_ptr< RunPrincipal > runPrincipal_
void edm::PrincipalCache::insert ( std::shared_ptr< EventPrincipal ep)

Definition at line 210 of file PrincipalCache.cc.

References eventPrincipals_.

210  {
211  unsigned int iStreamIndex = ep->streamID().value();
212  assert(iStreamIndex < eventPrincipals_.size());
213  eventPrincipals_[iStreamIndex] = ep;
214  }
std::vector< std::shared_ptr< EventPrincipal > > eventPrincipals_
LuminosityBlockPrincipal & edm::PrincipalCache::lumiPrincipal ( ProcessHistoryID const &  phid,
RunNumber_t  run,
LuminosityBlockNumber_t  lumi 
) const

Definition at line 62 of file PrincipalCache.cc.

References lumi_, lumiPrincipal_, reducedInputProcessHistoryID_, run_, and throwLumiMissing().

Referenced by edm::EventProcessor::beginLumi(), edm::EventProcessor::endLumi(), edm::SubProcess::writeLumi(), and edm::EventProcessor::writeLumi().

62  {
63  if (phid != reducedInputProcessHistoryID_ ||
64  run != run_ ||
65  lumi != lumi_ ||
66  lumiPrincipal_.get() == nullptr) {
68  }
69  return *lumiPrincipal_.get();
70  }
void throwLumiMissing() const
LuminosityBlockNumber_t lumi_
std::shared_ptr< LuminosityBlockPrincipal > lumiPrincipal_
ProcessHistoryID reducedInputProcessHistoryID_
LuminosityBlockPrincipal & edm::PrincipalCache::lumiPrincipal ( ) const

Definition at line 84 of file PrincipalCache.cc.

References lumiPrincipal_, and throwLumiMissing().

Referenced by hasRunPrincipal().

84  {
85  if (lumiPrincipal_.get() == nullptr) {
87  }
88  return *lumiPrincipal_.get();
89  }
void throwLumiMissing() const
std::shared_ptr< LuminosityBlockPrincipal > lumiPrincipal_
std::shared_ptr< LuminosityBlockPrincipal > const & edm::PrincipalCache::lumiPrincipalPtr ( ProcessHistoryID const &  phid,
RunNumber_t  run,
LuminosityBlockNumber_t  lumi 
) const
std::shared_ptr< LuminosityBlockPrincipal > const & edm::PrincipalCache::lumiPrincipalPtr ( ) const

Definition at line 92 of file PrincipalCache.cc.

References lumiPrincipal_, and throwLumiMissing().

Referenced by hasRunPrincipal().

92  {
93  if (lumiPrincipal_.get() == nullptr) {
95  }
96  return lumiPrincipal_;
97  }
void throwLumiMissing() const
std::shared_ptr< LuminosityBlockPrincipal > lumiPrincipal_
void edm::PrincipalCache::merge ( std::shared_ptr< RunAuxiliary aux,
std::shared_ptr< ProductRegistry const >  reg 
)

Definition at line 99 of file PrincipalCache.cc.

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

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

99  {
100  if (runPrincipal_.get() == nullptr) {
102  << "PrincipalCache::merge\n"
103  << "Illegal attempt to merge run into cache\n"
104  << "There is no run in cache to merge with\n"
105  << "Contact a Framework Developer\n";
106  }
107  if (inputProcessHistoryID_ != aux->processHistoryID()) {
110  << "PrincipalCache::merge\n"
111  << "Illegal attempt to merge run into cache\n"
112  << "Reduced ProcessHistoryID inconsistent with the one already in cache\n"
113  << "Contact a Framework Developer\n";
114  }
115  inputProcessHistoryID_ = aux->processHistoryID();
116  }
117  if (aux->run() != run_) {
119  << "PrincipalCache::merge\n"
120  << "Illegal attempt to merge run into cache\n"
121  << "Run number inconsistent with run number already in cache\n"
122  << "Contact a Framework Developer\n";
123  }
124  bool runOK = runPrincipal_->adjustToNewProductRegistry(*reg);
125  assert(runOK);
126  runPrincipal_->mergeAuxiliary(*aux);
127  }
ProcessHistoryID reducedInputProcessHistoryID_
ProcessHistoryID const & reducedProcessHistoryID(ProcessHistoryID const &fullID) const
ProcessHistoryID inputProcessHistoryID_
ProcessHistoryRegistry const * processHistoryRegistry_
std::shared_ptr< RunPrincipal > runPrincipal_
void edm::PrincipalCache::merge ( std::shared_ptr< LuminosityBlockAuxiliary aux,
std::shared_ptr< ProductRegistry const >  reg 
)

Definition at line 129 of file PrincipalCache.cc.

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

129  {
130  if (lumiPrincipal_.get() == nullptr) {
132  << "PrincipalCache::merge\n"
133  << "Illegal attempt to merge luminosity block into cache\n"
134  << "There is no luminosity block in the cache to merge with\n"
135  << "Contact a Framework Developer\n";
136  }
137  if (inputProcessHistoryID_ != aux->processHistoryID()) {
140  << "PrincipalCache::merge\n"
141  << "Illegal attempt to merge run into cache\n"
142  << "Reduced ProcessHistoryID inconsistent with the one already in cache\n"
143  << "Contact a Framework Developer\n";
144  }
145  inputProcessHistoryID_ = aux->processHistoryID();
146  }
147  if (aux->run() != run_ ||
148  aux->luminosityBlock() != lumi_) {
150  << "PrincipalCache::merge\n"
151  << "Illegal attempt to merge lumi into cache\n"
152  << "Run and lumi numbers are inconsistent with the ones already in the cache\n"
153  << "Contact a Framework Developer\n";
154  }
155  bool lumiOK = lumiPrincipal_->adjustToNewProductRegistry(*reg);
156  assert(lumiOK);
157  lumiPrincipal_->mergeAuxiliary(*aux);
158  }
LuminosityBlockNumber_t lumi_
std::shared_ptr< LuminosityBlockPrincipal > lumiPrincipal_
ProcessHistoryID reducedInputProcessHistoryID_
ProcessHistoryID const & reducedProcessHistoryID(ProcessHistoryID const &fullID) const
ProcessHistoryID inputProcessHistoryID_
ProcessHistoryRegistry const * processHistoryRegistry_
RunPrincipal & edm::PrincipalCache::runPrincipal ( ProcessHistoryID const &  phid,
RunNumber_t  run 
) const

Definition at line 26 of file PrincipalCache.cc.

References reducedInputProcessHistoryID_, run_, runPrincipal_, and throwRunMissing().

Referenced by edm::EventProcessor::beginRun(), edm::EventProcessor::endRun(), edm::SubProcess::writeRun(), and edm::EventProcessor::writeRun().

26  {
27  if (phid != reducedInputProcessHistoryID_ ||
28  run != run_ ||
29  runPrincipal_.get() == nullptr) {
31  }
32  return *runPrincipal_.get();
33  }
void throwRunMissing() const
ProcessHistoryID reducedInputProcessHistoryID_
std::shared_ptr< RunPrincipal > runPrincipal_
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(), and edm::SubProcess::SubProcess().

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

Definition at line 80 of file PrincipalCache.h.

References processHistoryRegistry_, throwLumiMissing(), and throwRunMissing().

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

ProcessHistoryRegistry const * processHistoryRegistry_
void edm::PrincipalCache::throwLumiMissing ( ) const
private

Definition at line 283 of file PrincipalCache.cc.

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

Referenced by lumiPrincipal(), lumiPrincipalPtr(), and setProcessHistoryRegistry().

283  {
285  << "PrincipalCache::lumiPrincipal or PrincipalCache::lumiPrincipalPtr\n"
286  << "Requested a luminosity block that is not in the cache (should never happen)\n"
287  << "Contact a Framework Developer\n";
288  }
void edm::PrincipalCache::throwRunMissing ( ) const
private

Definition at line 275 of file PrincipalCache.cc.

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

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

275  {
277  << "PrincipalCache::runPrincipal\n"
278  << "Requested a run that is not in the cache (should never happen)\n"
279  << "Contact a Framework Developer\n";
280  }

Member Data Documentation

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

Definition at line 103 of file PrincipalCache.h.

Referenced by insert(), and merge().

LuminosityBlockNumber_t edm::PrincipalCache::lumi_
private

Definition at line 106 of file PrincipalCache.h.

Referenced by deleteLumi(), insert(), lumiPrincipal(), lumiPrincipalPtr(), and merge().

std::shared_ptr<LuminosityBlockPrincipal> edm::PrincipalCache::lumiPrincipal_
private
ProcessHistoryRegistry const* edm::PrincipalCache::processHistoryRegistry_
private

Definition at line 94 of file PrincipalCache.h.

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

ProcessHistoryID edm::PrincipalCache::reducedInputProcessHistoryID_
private
RunNumber_t edm::PrincipalCache::run_
private
std::shared_ptr<RunPrincipal> edm::PrincipalCache::runPrincipal_
private