CMS 3D CMS Logo

PrincipalCache.cc
Go to the documentation of this file.
2 
9 
10 namespace edm {
11 
13  run_(0U),
14  lumi_(0U) {
15  }
16 
18 
19 
21  {
22  eventPrincipals_.resize(iConfig.numberOfStreams());
23  }
24 
27  if (phid != reducedInputProcessHistoryID_ ||
28  run != run_ ||
29  runPrincipal_.get() == nullptr) {
31  }
32  return *runPrincipal_.get();
33  }
34 
35  std::shared_ptr<RunPrincipal> const&
37  if (phid != reducedInputProcessHistoryID_ ||
38  run != run_ ||
39  runPrincipal_.get() == nullptr) {
41  }
42  return runPrincipal_;
43  }
44 
47  if (runPrincipal_.get() == nullptr) {
49  }
50  return *runPrincipal_.get();
51  }
52 
53  std::shared_ptr<RunPrincipal> const&
55  if (runPrincipal_.get() == nullptr) {
57  }
58  return runPrincipal_;
59  }
60 
61  std::shared_ptr<LuminosityBlockPrincipal>
63 
64  void PrincipalCache::merge(std::shared_ptr<RunAuxiliary> aux, std::shared_ptr<ProductRegistry const> reg) {
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  }
93 
94  void PrincipalCache::insert(std::shared_ptr<RunPrincipal> rp) {
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  }
108 
109  void PrincipalCache::insert(std::unique_ptr<LuminosityBlockPrincipal> lbp) {
110  lumiHolder_.add(std::move(lbp));
111  }
112 
113  void PrincipalCache::insert(std::shared_ptr<EventPrincipal> ep) {
114  unsigned int iStreamIndex = ep->streamID().value();
115  assert(iStreamIndex < eventPrincipals_.size());
116  eventPrincipals_[iStreamIndex] = ep;
117  }
118 
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  }
137 
138  void PrincipalCache::adjustEventsToNewProductRegistry(std::shared_ptr<ProductRegistry const> reg) {
139  for(auto &eventPrincipal : eventPrincipals_) {
140  if (eventPrincipal) {
142  bool eventOK = eventPrincipal->adjustToNewProductRegistry(*reg);
143  assert(eventOK);
144  }
145  }
146  }
147 
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  }
159 
160  void
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  }
167 
168  void
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  }
175 }
void throwRunMissing() const
void insert(std::shared_ptr< RunPrincipal > rp)
void setNumberOfConcurrentPrincipals(PreallocationConfiguration const &)
std::shared_ptr< RunPrincipal > const & runPrincipalPtr() const
void throwLumiMissing() const
void adjustIndexesAfterProductRegistryAddition()
RunPrincipal & runPrincipal() const
edm::ReusableObjectHolder< LuminosityBlockPrincipal > lumiHolder_
std::vector< std::shared_ptr< EventPrincipal > > eventPrincipals_
ProcessHistoryID reducedInputProcessHistoryID_
ProcessHistoryID const & reducedProcessHistoryID(ProcessHistoryID const &fullID) const
void adjustEventsToNewProductRegistry(std::shared_ptr< ProductRegistry const > reg)
EventPrincipal & eventPrincipal(unsigned int iStreamIndex) const
void deleteRun(ProcessHistoryID const &phid, RunNumber_t run)
ProcessHistoryID inputProcessHistoryID_
HLT enums.
bool adjustToNewProductRegistry(ProductRegistry const &reg)
Definition: Principal.cc:280
std::shared_ptr< LuminosityBlockPrincipal > getAvailableLumiPrincipalPtr()
unsigned int RunNumber_t
void adjustIndexesAfterProductRegistryAddition()
Definition: Principal.cc:888
ProcessHistoryRegistry const * processHistoryRegistry_
std::shared_ptr< RunPrincipal > runPrincipal_
def move(src, dest)
Definition: eostools.py:510
void merge(std::shared_ptr< RunAuxiliary > aux, std::shared_ptr< ProductRegistry const > reg)