CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PrincipalCache.cc
Go to the documentation of this file.
2 
8 
9 namespace edm {
10 
12  run_(0U),
13  lumi_(0U) {
14  }
15 
17 
20  if (phid != reducedInputProcessHistoryID_ ||
21  run != run_ ||
22  runPrincipal_.get() == 0) {
24  }
25  return *runPrincipal_.get();
26  }
27 
28  boost::shared_ptr<RunPrincipal> const&
30  if (phid != reducedInputProcessHistoryID_ ||
31  run != run_ ||
32  runPrincipal_.get() == 0) {
34  }
35  return runPrincipal_;
36  }
37 
40  if (runPrincipal_.get() == 0) {
42  }
43  return *runPrincipal_.get();
44  }
45 
46  boost::shared_ptr<RunPrincipal> const&
48  if (runPrincipal_.get() == 0) {
50  }
51  return runPrincipal_;
52  }
53 
56  if (phid != reducedInputProcessHistoryID_ ||
57  run != run_ ||
58  lumi != lumi_ ||
59  lumiPrincipal_.get() == 0) {
61  }
62  return *lumiPrincipal_.get();
63  }
64 
65  boost::shared_ptr<LuminosityBlockPrincipal> const&
67  if (phid != reducedInputProcessHistoryID_ ||
68  run != run_ ||
69  lumi != lumi_ ||
70  lumiPrincipal_.get() == 0) {
72  }
73  return lumiPrincipal_;
74  }
75 
78  if (lumiPrincipal_.get() == 0) {
80  }
81  return *lumiPrincipal_.get();
82  }
83 
84  boost::shared_ptr<LuminosityBlockPrincipal> const&
86  if (lumiPrincipal_.get() == 0) {
88  }
89  return lumiPrincipal_;
90  }
91 
92  void PrincipalCache::merge(boost::shared_ptr<RunAuxiliary> aux, boost::shared_ptr<ProductRegistry const> reg) {
93  if (runPrincipal_.get() == 0) {
95  << "PrincipalCache::merge\n"
96  << "Illegal attempt to merge run into cache\n"
97  << "There is no run in cache to merge with\n"
98  << "Contact a Framework Developer\n";
99  }
100  if (inputProcessHistoryID_ != aux->processHistoryID()) {
101  if (reducedInputProcessHistoryID_ != ProcessHistoryRegistry::instance()->extra().reduceProcessHistoryID(aux->processHistoryID())) {
103  << "PrincipalCache::insert\n"
104  << "Illegal attempt to merge run into cache\n"
105  << "Reduced ProcessHistoryID inconsistent with the one already in cache\n"
106  << "Contact a Framework Developer\n";
107  }
108  inputProcessHistoryID_ = aux->processHistoryID();
109  }
110  if (aux->run() != run_) {
112  << "PrincipalCache::insert\n"
113  << "Illegal attempt to merge run into cache\n"
114  << "Run number inconsistent with run number already in cache\n"
115  << "Contact a Framework Developer\n";
116  }
117  bool runOK = runPrincipal_->adjustToNewProductRegistry(*reg);
118  assert(runOK);
119  runPrincipal_->mergeAuxiliary(*aux);
120  }
121 
122  void PrincipalCache::merge(boost::shared_ptr<LuminosityBlockAuxiliary> aux, boost::shared_ptr<ProductRegistry const> reg) {
123  if (lumiPrincipal_.get() == 0) {
125  << "PrincipalCache::merge\n"
126  << "Illegal attempt to merge luminosity block into cache\n"
127  << "There is no luminosity block in the cache to merge with\n"
128  << "Contact a Framework Developer\n";
129  }
130  if (inputProcessHistoryID_ != aux->processHistoryID()) {
131  if (reducedInputProcessHistoryID_ != ProcessHistoryRegistry::instance()->extra().reduceProcessHistoryID(aux->processHistoryID())) {
133  << "PrincipalCache::insert\n"
134  << "Illegal attempt to merge run into cache\n"
135  << "Reduced ProcessHistoryID inconsistent with the one already in cache\n"
136  << "Contact a Framework Developer\n";
137  }
138  inputProcessHistoryID_ = aux->processHistoryID();
139  }
140  if (aux->run() != run_ ||
141  aux->luminosityBlock() != lumi_) {
143  << "PrincipalCache::insert\n"
144  << "Illegal attempt to merge lumi into cache\n"
145  << "Run and lumi numbers are inconsistent with the ones already in the cache\n"
146  << "Contact a Framework Developer\n";
147  }
148  bool lumiOK = lumiPrincipal_->adjustToNewProductRegistry(*reg);
149  assert(lumiOK);
150  lumiPrincipal_->mergeAuxiliary(*aux);
151  }
152 
153  void PrincipalCache::insert(boost::shared_ptr<RunPrincipal> rp) {
154  if (runPrincipal_.get() != 0) {
156  << "PrincipalCache::insert\n"
157  << "Illegal attempt to insert run into cache\n"
158  << "Contact a Framework Developer\n";
159  }
160  if (inputProcessHistoryID_ != rp->aux().processHistoryID()) {
161  reducedInputProcessHistoryID_ = ProcessHistoryRegistry::instance()->extra().reduceProcessHistoryID(rp->aux().processHistoryID());
162  inputProcessHistoryID_ = rp->aux().processHistoryID();
163  }
164  run_ = rp->run();
165  runPrincipal_ = rp;
166  }
167 
168  void PrincipalCache::insert(boost::shared_ptr<LuminosityBlockPrincipal> lbp) {
169  if (lumiPrincipal_.get() != 0) {
171  << "PrincipalCache::insert\n"
172  << "Illegal attempt to insert lumi into cache\n"
173  << "Contact a Framework Developer\n";
174  }
175  if (runPrincipal_.get() == 0) {
177  << "PrincipalCache::insert\n"
178  << "Illegal attempt to insert lumi into cache\n"
179  << "Run is invalid\n"
180  << "Contact a Framework Developer\n";
181  }
182  if (inputProcessHistoryID_ != lbp->aux().processHistoryID()) {
183  if (reducedInputProcessHistoryID_ != ProcessHistoryRegistry::instance()->extra().reduceProcessHistoryID(lbp->aux().processHistoryID())) {
185  << "PrincipalCache::insert\n"
186  << "Illegal attempt to insert lumi into cache\n"
187  << "luminosity block has ProcessHistoryID inconsistent with run\n"
188  << "Contact a Framework Developer\n";
189  }
190  inputProcessHistoryID_ = lbp->aux().processHistoryID();
191  }
192  if (lbp->run() != run_) {
194  << "PrincipalCache::insert\n"
195  << "Illegal attempt to insert lumi into cache\n"
196  << "luminosity block inconsistent with run number of run in cache\n"
197  << "Contact a Framework Developer\n";
198  }
199  lumi_ = lbp->luminosityBlock();
200  lumiPrincipal_ = lbp;
201  }
202 
204  if (runPrincipal_.get() == 0) {
206  << "PrincipalCache::deleteRun\n"
207  << "Illegal attempt to delete run from cache\n"
208  << "There is no run in cache to delete\n"
209  << "Contact a Framework Developer\n";
210  }
211  if (reducedInputProcessHistoryID_ != phid ||
212  run != run_) {
214  << "PrincipalCache::deleteRun\n"
215  << "Illegal attempt to delete run from cache\n"
216  << "Run number or reduced ProcessHistoryID inconsistent with those in cache\n"
217  << "Contact a Framework Developer\n";
218  }
219  runPrincipal_.reset();
220  }
221 
223  if (lumiPrincipal_.get() == 0) {
225  << "PrincipalCache::deleteLumi\n"
226  << "Illegal attempt to delete luminosity block from cache\n"
227  << "There is no luminosity block in the cache to delete\n"
228  << "Contact a Framework Developer\n";
229  }
230  if (reducedInputProcessHistoryID_ != phid ||
231  run != run_ ||
232  lumi != lumi_) {
234  << "PrincipalCache::deleteLumi\n"
235  << "Illegal attempt to delete luminosity block from cache\n"
236  << "Run number, lumi numbers, or reduced ProcessHistoryID inconsistent with those in cache\n"
237  << "Contact a Framework Developer\n";
238  }
239  lumiPrincipal_.reset();
240  }
241 
242  void PrincipalCache::adjustEventToNewProductRegistry(boost::shared_ptr<ProductRegistry const> reg) {
243  if (eventPrincipal_) {
244  eventPrincipal_->adjustIndexesAfterProductRegistryAddition();
245  bool eventOK = eventPrincipal_->adjustToNewProductRegistry(*reg);
246  assert(eventOK);
247  }
248  }
249 
251  if (runPrincipal_) {
252  runPrincipal_->adjustIndexesAfterProductRegistryAddition();
253  }
254  if (lumiPrincipal_) {
255  lumiPrincipal_->adjustIndexesAfterProductRegistryAddition();
256  }
257  }
258 
259  void
262  << "PrincipalCache::runPrincipal\n"
263  << "Requested a run that is not in the cache (should never happen)\n"
264  << "Contact a Framework Developer\n";
265  }
266 
267  void
270  << "PrincipalCache::lumiPrincipal or PrincipalCache::lumiPrincipalPtr\n"
271  << "Requested a luminosity block that is not in the cache (should never happen)\n"
272  << "Contact a Framework Developer\n";
273  }
274 }
void throwRunMissing() const
boost::shared_ptr< RunPrincipal > const & runPrincipalPtr() const
void deleteLumi(ProcessHistoryID const &phid, RunNumber_t run, LuminosityBlockNumber_t lumi)
void merge(boost::shared_ptr< RunAuxiliary > aux, boost::shared_ptr< ProductRegistry const > reg)
static ThreadSafeRegistry * instance()
tuple lumi
Definition: fjr2json.py:35
void throwLumiMissing() const
void insert(boost::shared_ptr< RunPrincipal > rp)
LuminosityBlockNumber_t lumi_
void adjustIndexesAfterProductRegistryAddition()
unsigned int LuminosityBlockNumber_t
Definition: EventID.h:31
void adjustEventToNewProductRegistry(boost::shared_ptr< ProductRegistry const > reg)
RunPrincipal & runPrincipal() const
ProcessHistoryID reducedInputProcessHistoryID_
boost::shared_ptr< LuminosityBlockPrincipal > const & lumiPrincipalPtr() const
boost::shared_ptr< RunPrincipal > runPrincipal_
void deleteRun(ProcessHistoryID const &phid, RunNumber_t run)
ProcessHistoryID inputProcessHistoryID_
LuminosityBlockPrincipal & lumiPrincipal() const
unsigned int RunNumber_t
Definition: EventRange.h:32
boost::shared_ptr< LuminosityBlockPrincipal > lumiPrincipal_
boost::shared_ptr< EventPrincipal > eventPrincipal_