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() == 0) {
31  }
32  return *runPrincipal_.get();
33  }
34 
35  std::shared_ptr<RunPrincipal> const&
37  if (phid != reducedInputProcessHistoryID_ ||
38  run != run_ ||
39  runPrincipal_.get() == 0) {
41  }
42  return runPrincipal_;
43  }
44 
47  if (runPrincipal_.get() == 0) {
49  }
50  return *runPrincipal_.get();
51  }
52 
53  std::shared_ptr<RunPrincipal> const&
55  if (runPrincipal_.get() == 0) {
57  }
58  return runPrincipal_;
59  }
60 
63  if (phid != reducedInputProcessHistoryID_ ||
64  run != run_ ||
65  lumi != lumi_ ||
66  lumiPrincipal_.get() == 0) {
68  }
69  return *lumiPrincipal_.get();
70  }
71 
72  std::shared_ptr<LuminosityBlockPrincipal> const&
74  if (phid != reducedInputProcessHistoryID_ ||
75  run != run_ ||
76  lumi != lumi_ ||
77  lumiPrincipal_.get() == 0) {
79  }
80  return lumiPrincipal_;
81  }
82 
85  if (lumiPrincipal_.get() == 0) {
87  }
88  return *lumiPrincipal_.get();
89  }
90 
91  std::shared_ptr<LuminosityBlockPrincipal> const&
93  if (lumiPrincipal_.get() == 0) {
95  }
96  return lumiPrincipal_;
97  }
98 
99  void PrincipalCache::merge(std::shared_ptr<RunAuxiliary> aux, std::shared_ptr<ProductRegistry const> reg) {
100  if (runPrincipal_.get() == 0) {
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  }
128 
129  void PrincipalCache::merge(std::shared_ptr<LuminosityBlockAuxiliary> aux, std::shared_ptr<ProductRegistry const> reg) {
130  if (lumiPrincipal_.get() == 0) {
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  }
159 
160  void PrincipalCache::insert(std::shared_ptr<RunPrincipal> rp) {
161  if (runPrincipal_.get() != 0) {
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  }
174 
175  void PrincipalCache::insert(std::shared_ptr<LuminosityBlockPrincipal> lbp) {
176  if (lumiPrincipal_.get() != 0) {
178  << "PrincipalCache::insert\n"
179  << "Illegal attempt to insert lumi into cache\n"
180  << "Contact a Framework Developer\n";
181  }
182  if (runPrincipal_.get() == 0) {
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  }
209 
210  void PrincipalCache::insert(std::shared_ptr<EventPrincipal> ep) {
211  unsigned int iStreamIndex = ep->streamID().value();
212  assert(iStreamIndex < eventPrincipals_.size());
213  eventPrincipals_[iStreamIndex] = ep;
214  }
215 
217  if (runPrincipal_.get() == 0) {
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  }
234 
236  if (lumiPrincipal_.get() == 0) {
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  }
254 
255  void PrincipalCache::adjustEventsToNewProductRegistry(std::shared_ptr<ProductRegistry const> reg) {
256  for(auto &eventPrincipal : eventPrincipals_) {
257  if (eventPrincipal) {
259  bool eventOK = eventPrincipal->adjustToNewProductRegistry(*reg);
260  assert(eventOK);
261  }
262  }
263  }
264 
266  if (runPrincipal_) {
267  runPrincipal_->adjustIndexesAfterProductRegistryAddition();
268  }
269  if (lumiPrincipal_) {
270  lumiPrincipal_->adjustIndexesAfterProductRegistryAddition();
271  }
272  }
273 
274  void
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  }
281 
282  void
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  }
289 }
void throwRunMissing() const
void insert(std::shared_ptr< RunPrincipal > rp)
void deleteLumi(ProcessHistoryID const &phid, RunNumber_t run, LuminosityBlockNumber_t lumi)
void setNumberOfConcurrentPrincipals(PreallocationConfiguration const &)
std::shared_ptr< RunPrincipal > const & runPrincipalPtr() const
void throwLumiMissing() const
LuminosityBlockNumber_t lumi_
void adjustIndexesAfterProductRegistryAddition()
unsigned int LuminosityBlockNumber_t
std::shared_ptr< LuminosityBlockPrincipal > lumiPrincipal_
std::shared_ptr< LuminosityBlockPrincipal > const & lumiPrincipalPtr() const
RunPrincipal & runPrincipal() const
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_
LuminosityBlockPrincipal & lumiPrincipal() const
HLT enums.
bool adjustToNewProductRegistry(ProductRegistry const &reg)
Definition: Principal.cc:246
unsigned int RunNumber_t
void adjustIndexesAfterProductRegistryAddition()
Definition: Principal.cc:810
ProcessHistoryRegistry const * processHistoryRegistry_
std::shared_ptr< RunPrincipal > runPrincipal_
void merge(std::shared_ptr< RunAuxiliary > aux, std::shared_ptr< ProductRegistry const > reg)