CMS 3D CMS Logo

EcalTestDevDB.cc
Go to the documentation of this file.
3 
7 
9 
13 
15 
17 
19 
20 #include <vector>
21 
22 using namespace std;
23 
25  : m_timetype(iConfig.getParameter<std::string>("timetype")), m_cacheIDs(), m_records() {
26  std::string container;
29 
30  m_firstRun = static_cast<unsigned long>(atoi(iConfig.getParameter<std::string>("firstRun").c_str()));
31  m_lastRun = static_cast<unsigned long>(atoi(iConfig.getParameter<std::string>("lastRun").c_str()));
32  m_interval = static_cast<unsigned long>(atoi(iConfig.getParameter<std::string>("interval").c_str()));
33 
34  typedef std::vector<edm::ParameterSet> Parameters;
35  Parameters toCopy = iConfig.getParameter<Parameters>("toCopy");
36  for (Parameters::iterator i = toCopy.begin(); i != toCopy.end(); ++i) {
37  container = i->getParameter<std::string>("container");
38  record = i->getParameter<std::string>("record");
39  m_cacheIDs.insert(std::make_pair(container, 0));
40  m_records.insert(std::make_pair(container, record));
41  }
42 }
43 
45 
46 void EcalTestDevDB::analyze(const edm::Event& evt, const edm::EventSetup& evtSetup) {
48  if (!dbOutput.isAvailable()) {
49  throw cms::Exception("PoolDBOutputService is not available");
50  }
51 
52  std::string container;
54  typedef std::map<std::string, std::string>::const_iterator recordIter;
55  for (recordIter i = m_records.begin(); i != m_records.end(); ++i) {
56  container = (*i).first;
57  record = (*i).second;
58 
59  std::string recordName = m_records[container];
60 
61  // Loop through each of the runs
62 
63  unsigned long nrec = (m_lastRun - m_firstRun) / m_interval + 1;
64  unsigned long nstart = 0;
65  if (m_firstRun == 0 && m_lastRun == 0) {
66  // it should do at least once the loop
67  nstart = 0;
68  nrec = 1;
69  }
70 
71  for (unsigned long i = nstart; i < nrec; i++) {
72  unsigned long irun = m_firstRun + i * m_interval;
73 
74  // Arguments 0 0 mean infinite IOV
75  if (m_firstRun == 0 && m_lastRun == 0) {
76  edm::LogInfo("EcalTestDevDB") << "Infinite IOV mode";
78  }
79 
80  edm::LogInfo("EcalTestDevDB") << "Starting Transaction for run " << irun << "...";
81 
82  if (container == "EcalPedestals") {
83  const auto condObject = generateEcalPedestals();
84  if (irun == m_firstRun && dbOutput->isNewTagRequest(recordName)) {
85  // create new
86  edm::LogInfo("EcalTestDevDB") << "First One ";
87  dbOutput->createOneIOV<const EcalPedestals>(*condObject, dbOutput->beginOfTime(), recordName);
88  } else {
89  // append
90  edm::LogInfo("EcalTestDevDB") << "Old One ";
91  dbOutput->appendOneIOV<const EcalPedestals>(*condObject, irun, recordName);
92  }
93 
94  } else if (container == "EcalADCToGeVConstant") {
95  const auto condObject = generateEcalADCToGeVConstant();
96  if (irun == m_firstRun && dbOutput->isNewTagRequest(recordName)) {
97  // create new
98  edm::LogInfo("EcalTestDevDB") << "First One ";
99  dbOutput->createOneIOV<const EcalADCToGeVConstant>(*condObject, dbOutput->beginOfTime(), recordName);
100  } else {
101  // append
102  edm::LogInfo("EcalTestDevDB") << "Old One ";
103  dbOutput->appendOneIOV<const EcalADCToGeVConstant>(*condObject, irun, recordName);
104  }
105 
106  } else if (container == "EcalIntercalibConstants") {
107  const auto condObject = generateEcalIntercalibConstants();
108  if (irun == m_firstRun && dbOutput->isNewTagRequest(recordName)) {
109  // create new
110  edm::LogInfo("EcalTestDevDB") << "First One ";
111  dbOutput->createOneIOV<const EcalIntercalibConstants>(*condObject, dbOutput->beginOfTime(), recordName);
112  } else {
113  // append
114  edm::LogInfo("EcalTestDevDB") << "Old One ";
115  dbOutput->appendOneIOV<const EcalIntercalibConstants>(*condObject, irun, recordName);
116  }
117  } else if (container == "EcalLinearCorrections") {
118  const auto condObject = generateEcalLinearCorrections();
119  if (irun == m_firstRun && dbOutput->isNewTagRequest(recordName)) {
120  // create new
121  edm::LogInfo("EcalTestDevDB") << "First One ";
122  dbOutput->createOneIOV<const EcalLinearCorrections>(*condObject, dbOutput->beginOfTime(), recordName);
123  } else {
124  // append
125  edm::LogInfo("EcalTestDevDB") << "Old One ";
126  dbOutput->appendOneIOV<const EcalLinearCorrections>(*condObject, irun, recordName);
127  }
128 
129  } else if (container == "EcalGainRatios") {
130  const auto condObject = generateEcalGainRatios();
131  if (irun == m_firstRun && dbOutput->isNewTagRequest(recordName)) {
132  // create new
133  edm::LogInfo("EcalTestDevDB") << "First One ";
134  dbOutput->createOneIOV<const EcalGainRatios>(*condObject, dbOutput->beginOfTime(), recordName);
135  } else {
136  // append
137  edm::LogInfo("EcalTestDevDB") << "Old One ";
138  dbOutput->appendOneIOV<const EcalGainRatios>(*condObject, irun, recordName);
139  }
140 
141  } else if (container == "EcalWeightXtalGroups") {
142  const auto condObject = generateEcalWeightXtalGroups();
143  if (irun == m_firstRun && dbOutput->isNewTagRequest(recordName)) {
144  // create new
145  edm::LogInfo("EcalTestDevDB") << "First One ";
146  dbOutput->createOneIOV<const EcalWeightXtalGroups>(*condObject, dbOutput->beginOfTime(), recordName);
147  } else {
148  // append
149  edm::LogInfo("EcalTestDevDB") << "Old One ";
150  dbOutput->appendOneIOV<const EcalWeightXtalGroups>(*condObject, irun, recordName);
151  }
152 
153  } else if (container == "EcalTBWeights") {
154  const auto condObject = generateEcalTBWeights();
155  if (irun == m_firstRun && dbOutput->isNewTagRequest(recordName)) {
156  // create new
157  edm::LogInfo("EcalTestDevDB") << "First One ";
158  dbOutput->createOneIOV<const EcalTBWeights>(*condObject, dbOutput->beginOfTime(), recordName);
159  } else {
160  // append
161  edm::LogInfo("EcalTestDevDB") << "Old One ";
162  dbOutput->appendOneIOV<const EcalTBWeights>(*condObject, irun, recordName);
163  }
164 
165  } else if (container == "EcalLaserAPDPNRatios") {
166  const auto condObject = generateEcalLaserAPDPNRatios(irun);
167  if (irun == m_firstRun && dbOutput->isNewTagRequest(recordName)) {
168  // create new
169  edm::LogInfo("EcalTestDevDB") << "First One ";
170  dbOutput->createOneIOV<const EcalLaserAPDPNRatios>(*condObject, dbOutput->beginOfTime(), recordName);
171  } else {
172  // append
173  edm::LogInfo("EcalTestDevDB") << "Old One ";
174  dbOutput->appendOneIOV<const EcalLaserAPDPNRatios>(*condObject, irun, recordName);
175  }
176  } else if (container == "EcalLaserAPDPNRatiosRef") {
177  const auto condObject = generateEcalLaserAPDPNRatiosRef();
178  if (irun == m_firstRun && dbOutput->isNewTagRequest(recordName)) {
179  // create new
180  edm::LogInfo("EcalTestDevDB") << "First One ";
181  dbOutput->createOneIOV<const EcalLaserAPDPNRatiosRef>(*condObject, dbOutput->beginOfTime(), recordName);
182  } else {
183  // append
184  edm::LogInfo("EcalTestDevDB") << "Old One ";
185  dbOutput->appendOneIOV<const EcalLaserAPDPNRatiosRef>(*condObject, irun, recordName);
186  }
187  } else if (container == "EcalLaserAlphas") {
188  const auto condObject = generateEcalLaserAlphas();
189  if (irun == m_firstRun && dbOutput->isNewTagRequest(recordName)) {
190  // create new
191  edm::LogInfo("EcalTestDevDB") << "First One ";
192  dbOutput->createOneIOV<const EcalLaserAlphas>(*condObject, dbOutput->beginOfTime(), recordName);
193  } else {
194  // append
195  edm::LogInfo("EcalTestDevDB") << "Old One ";
196  dbOutput->appendOneIOV<const EcalLaserAlphas>(*condObject, irun, recordName);
197  }
198  } else {
199  edm::LogWarning("EcalTestDevDB") << "it does not work yet for " << container << "...";
200  }
201  }
202  }
203 }
204 
205 //-------------------------------------------------------------
206 std::shared_ptr<EcalPedestals> EcalTestDevDB::generateEcalPedestals() {
207  //-------------------------------------------------------------
208 
209  auto peds = std::make_shared<EcalPedestals>();
211  for (int iEta = -EBDetId::MAX_IETA; iEta <= EBDetId::MAX_IETA; ++iEta) {
212  if (iEta == 0)
213  continue;
214  for (int iPhi = EBDetId::MIN_IPHI; iPhi <= EBDetId::MAX_IPHI; ++iPhi) {
215  item.mean_x1 = 200. * ((double)std::rand() / (double(RAND_MAX) + double(1)));
216  item.rms_x1 = (double)std::rand() / (double(RAND_MAX) + double(1));
217  item.mean_x6 = 1200. * ((double)std::rand() / (double(RAND_MAX) + double(1)));
218  item.rms_x6 = 6. * ((double)std::rand() / (double(RAND_MAX) + double(1)));
219  item.mean_x12 = 2400. * ((double)std::rand() / (double(RAND_MAX) + double(1)));
220  item.rms_x12 = 12. * ((double)std::rand() / (double(RAND_MAX) + double(1)));
221 
222  EBDetId ebdetid(iEta, iPhi);
223  peds->insert(std::make_pair(ebdetid.rawId(), item));
224  }
225  }
226  return peds;
227 }
228 
229 //-------------------------------------------------------------
230 std::shared_ptr<EcalADCToGeVConstant> EcalTestDevDB::generateEcalADCToGeVConstant() {
231  //-------------------------------------------------------------
232 
233  double r = (double)std::rand() / (double(RAND_MAX) + double(1));
234  auto agc = std::make_shared<EcalADCToGeVConstant>(36. + r * 4., 60. + r * 4);
235  return agc;
236 }
237 
238 //-------------------------------------------------------------
239 std::shared_ptr<EcalIntercalibConstants> EcalTestDevDB::generateEcalIntercalibConstants() {
240  //-------------------------------------------------------------
241 
242  auto ical = std::make_shared<EcalIntercalibConstants>();
243 
244  for (int ieta = -EBDetId::MAX_IETA; ieta <= EBDetId::MAX_IETA; ++ieta) {
245  if (ieta == 0)
246  continue;
247  for (int iphi = EBDetId::MIN_IPHI; iphi <= EBDetId::MAX_IPHI; ++iphi) {
248  EBDetId ebid(ieta, iphi);
249 
250  double r = (double)std::rand() / (double(RAND_MAX) + double(1));
251  ical->setValue(ebid.rawId(), 0.85 + r * 0.3);
252  } // loop over phi
253  } // loop over eta
254  return ical;
255 }
256 
257 //-------------------------------------------------------------
258 std::shared_ptr<EcalLinearCorrections> EcalTestDevDB::generateEcalLinearCorrections() {
259  //-------------------------------------------------------------
260 
261  auto ical = std::make_shared<EcalLinearCorrections>();
262 
263  for (int ieta = -EBDetId::MAX_IETA; ieta <= EBDetId::MAX_IETA; ++ieta) {
264  if (ieta == 0)
265  continue;
266  for (int iphi = EBDetId::MIN_IPHI; iphi <= EBDetId::MAX_IPHI; ++iphi) {
267  if (EBDetId::validDetId(ieta, iphi)) {
268  EBDetId ebid(ieta, iphi);
269 
271  pairAPDPN.p1 = 1.0;
272  pairAPDPN.p2 = 1.0;
273  pairAPDPN.p3 = 1.0;
274  ical->setValue(ebid, pairAPDPN);
275  }
276  }
277  }
278 
279  for (int iX = EEDetId::IX_MIN; iX <= EEDetId::IX_MAX; ++iX) {
280  for (int iY = EEDetId::IY_MIN; iY <= EEDetId::IY_MAX; ++iY) {
281  // make an EEDetId since we need EEDetId::rawId() to be used as the key for the pedestals
282  if (EEDetId::validDetId(iX, iY, 1)) {
283  EEDetId eedetidpos(iX, iY, 1);
284 
286  pairAPDPN.p1 = 1.0;
287  pairAPDPN.p2 = 1.0;
288  pairAPDPN.p3 = 1.0;
289 
290  ical->setValue(eedetidpos, pairAPDPN);
291  }
292 
293  if (EEDetId::validDetId(iX, iY, -1)) {
294  EEDetId eedetidneg(iX, iY, -1);
295 
297  pairAPDPN.p1 = 1.0;
298  pairAPDPN.p2 = 1.0;
299  pairAPDPN.p3 = 1.0;
300 
301  ical->setValue(eedetidneg, pairAPDPN);
302  }
303  }
304  }
305 
307  for (int i = 0; i < 92; i++) {
308  TimeStamp.t1 = edm::Timestamp(0);
311 
312  ical->setTime(i, TimeStamp);
313  }
314 
315  return ical;
316 }
317 
318 //-------------------------------------------------------------
319 std::shared_ptr<EcalGainRatios> EcalTestDevDB::generateEcalGainRatios() {
320  //-------------------------------------------------------------
321 
322  // create gain ratios
323  auto gratio = std::make_shared<EcalGainRatios>();
324 
325  for (int ieta = -EBDetId::MAX_IETA; ieta <= EBDetId::MAX_IETA; ++ieta) {
326  if (ieta == 0)
327  continue;
328  for (int iphi = EBDetId::MIN_IPHI; iphi <= EBDetId::MAX_IPHI; ++iphi) {
329  EBDetId ebid(ieta, iphi);
330 
331  double r = (double)std::rand() / (double(RAND_MAX) + double(1));
332 
334  gr.setGain12Over6(1.9 + r * 0.2);
335  gr.setGain6Over1(5.9 + r * 0.2);
336 
337  gratio->setValue(ebid.rawId(), gr);
338 
339  } // loop over phi
340  } // loop over eta
341  return gratio;
342 }
343 
344 //-------------------------------------------------------------
345 std::shared_ptr<EcalWeightXtalGroups> EcalTestDevDB::generateEcalWeightXtalGroups() {
346  //-------------------------------------------------------------
347 
348  auto xtalGroups = std::make_shared<EcalWeightXtalGroups>();
349  for (int ieta = -EBDetId::MAX_IETA; ieta <= EBDetId::MAX_IETA; ++ieta) {
350  if (ieta == 0)
351  continue;
352  for (int iphi = EBDetId::MIN_IPHI; iphi <= EBDetId::MAX_IPHI; ++iphi) {
353  EBDetId ebid(ieta, iphi);
354  xtalGroups->setValue(ebid.rawId(), EcalXtalGroupId(ieta)); // define rings in eta
355  }
356  }
357  return xtalGroups;
358 }
359 
360 //-------------------------------------------------------------
361 std::shared_ptr<EcalTBWeights> EcalTestDevDB::generateEcalTBWeights() {
362  //-------------------------------------------------------------
363 
364  auto tbwgt = std::make_shared<EcalTBWeights>();
365 
366  // create weights for each distinct group ID
367  int nMaxTDC = 10;
368  for (int igrp = -EBDetId::MAX_IETA; igrp <= EBDetId::MAX_IETA; ++igrp) {
369  if (igrp == 0)
370  continue;
371  for (int itdc = 1; itdc <= nMaxTDC; ++itdc) {
372  // generate random number
373  double r = (double)std::rand() / (double(RAND_MAX) + double(1));
374 
375  // make a new set of weights
376  EcalWeightSet wgt;
379 
380  for (size_t i = 0; i < 3; ++i) {
381  for (size_t j = 0; j < 10; ++j) {
382  double ww = igrp * itdc * r + i * 10. + j;
383  mat1(i, j) = ww;
384  mat2(i, j) = 100 + ww;
385  }
386  }
387 
388  // fill the chi2 matrcies
389  r = (double)std::rand() / (double(RAND_MAX) + double(1));
392  for (size_t i = 0; i < 10; ++i) {
393  for (size_t j = 0; j < 10; ++j) {
394  double ww = igrp * itdc * r + i * 10. + j;
395  mat3(i, j) = 1000 + ww;
396  mat4(i, j) = 1000 + 100 + ww;
397  }
398  }
399 
400  // put the weight in the container
401  tbwgt->setValue(std::make_pair(igrp, itdc), wgt);
402  }
403  }
404  return tbwgt;
405 }
406 
407 //--------------------------------------------------------------
408 std::shared_ptr<EcalLaserAPDPNRatios> EcalTestDevDB::generateEcalLaserAPDPNRatios(uint32_t i_run) {
409  //--------------------------------------------------------------
410 
411  auto laser = std::make_shared<EcalLaserAPDPNRatios>();
412 
415 
416  // if((m_firstRun == 0 && i_run == 0) || (m_firstRun == 1 && i_run == 1)){
417 
418  edm::LogInfo("EcalTestDevDB") << "First & last run: " << i_run << " " << m_firstRun << " " << m_lastRun;
419  if (m_firstRun == i_run && (i_run == 0 || i_run == 1)) {
420  APDPNpair.p1 = (double(1) + 1 / double(log(exp(1) + double((i_run - m_firstRun) * 10)))) / double(2);
421  APDPNpair.p2 = (double(1) + 1 / double(log(exp(1) + double((i_run - m_firstRun) * 10) + double(10)))) / double(2);
422  APDPNpair.p3 = double(0);
423  edm::LogInfo("EcalTestDevDB") << i_run << " " << m_firstRun << " " << APDPNpair.p1 << " " << APDPNpair.p2;
424 
425  for (int iEta = -EBDetId::MAX_IETA; iEta <= EBDetId::MAX_IETA; ++iEta) {
426  if (iEta == 0)
427  continue;
428  for (int iPhi = EBDetId::MIN_IPHI; iPhi <= EBDetId::MAX_IPHI; ++iPhi) {
429  //APDPNpair.p1= double(1);
430  //APDPNpair.p2= double(1);
431 
432  EBDetId ebid(iEta, iPhi);
433  int hi = ebid.hashedIndex();
434 
435  if (hi < static_cast<int>(laser->getLaserMap().size())) {
436  laser->setValue(hi, APDPNpair);
437  } else {
438  edm::LogError("EcalTestDevDB") << "error with laser Map (ratio)!";
439  continue;
440  }
441  }
442  }
443 
444  for (int iX = EEDetId::IX_MIN; iX <= EEDetId::IX_MAX; ++iX) {
445  for (int iY = EEDetId::IY_MIN; iY <= EEDetId::IY_MAX; ++iY) {
446  // make an EEDetId since we need EEDetId::rawId() to be used as the key for the pedestals
447 
448  if (!EEDetId::validDetId(iX, iY, 1))
449  continue;
450 
451  EEDetId eedetidpos(iX, iY, 1);
452  //APDPNpair.p1 = double(1);
453  //APDPNpair.p2 = double(1);
454 
455  int hi = eedetidpos.hashedIndex() + EBDetId::MAX_HASH + 1;
456  if (hi < static_cast<int>(laser->getLaserMap().size())) {
457  laser->setValue(hi, APDPNpair);
458  } else {
459  edm::LogError("EcalTestDevDB") << "error with laser Map (ratio)!";
460  continue;
461  }
462 
463  if (!EEDetId::validDetId(iX, iY, -1))
464  continue;
465 
466  EEDetId eedetidneg(iX, iY, -1);
467  //APDPNpair.p1 = double(1);
468  //APDPNpair.p2 = double(1);
469  hi = eedetidneg.hashedIndex() + EBDetId::MAX_HASH + 1;
470  if (hi < static_cast<int>(laser->getLaserMap().size())) {
471  laser->setValue(hi, APDPNpair);
472  } else {
473  edm::LogError("EcalTestDevDB") << "error with laser Map (ratio)!";
474  continue;
475  }
476  }
477  }
478 
479  for (int i = 0; i < 92; i++) {
480  if (i < static_cast<int>(laser->getTimeMap().size())) {
481  TimeStamp.t1 = edm::Timestamp(1380 * (i_run - m_firstRun) + 15 * i);
482  TimeStamp.t2 = edm::Timestamp(1380 * (i_run - m_firstRun + 1) + 15 * i);
483  laser->setTime(i, TimeStamp);
484  } else {
485  edm::LogError("EcalTestDevDB") << "error with laser Map (time)!";
486  continue;
487  }
488  }
489 
490  } else {
491  APDPNpair.p1 = (double(1) + 1 / double(log(exp(1) + double((i_run - m_firstRun) * 10)))) / double(2);
492  APDPNpair.p2 = (double(1) + 1 / double(log(exp(1) + double((i_run - m_firstRun) * 10) + double(10)))) / double(2);
493  APDPNpair.p3 = double(0);
494  edm::LogInfo("EcalTestDevDB") << i_run << " " << m_firstRun << " " << APDPNpair.p1 << " " << APDPNpair.p2;
495 
496  for (int iEta = -EBDetId::MAX_IETA; iEta <= EBDetId::MAX_IETA; ++iEta) {
497  if (iEta == 0)
498  continue;
499  for (int iPhi = EBDetId::MIN_IPHI; iPhi <= EBDetId::MAX_IPHI; ++iPhi) {
500  EBDetId ebid(iEta, iPhi);
501  int hi = ebid.hashedIndex();
502 
503  if (hi < static_cast<int>(laser->getLaserMap().size())) {
504  laser->setValue(hi, APDPNpair);
505  } else {
506  edm::LogError("EcalTestDevDB") << "error with laser Map (ratio)!";
507  }
508  }
509  }
510  for (int iX = EEDetId::IX_MIN; iX <= EEDetId::IX_MAX; ++iX) {
511  for (int iY = EEDetId::IY_MIN; iY <= EEDetId::IY_MAX; ++iY) {
512  // make an EEDetId since we need EEDetId::rawId() to be used as the key for the pedestals
513 
514  if (!EEDetId::validDetId(iX, iY, 1))
515  continue;
516 
517  EEDetId eedetidpos(iX, iY, 1);
518  int hi = eedetidpos.hashedIndex() + EBDetId::MAX_HASH + 1;
519  if (hi < static_cast<int>(laser->getLaserMap().size())) {
520  laser->setValue(hi, APDPNpair);
521  } else {
522  edm::LogError("EcalTestDevDB") << "error with laser Map (ratio)!";
523  continue;
524  }
525 
526  if (!EEDetId::validDetId(iX, iY, -1))
527  continue;
528 
529  EEDetId eedetidneg(iX, iY, -1);
530  hi = eedetidneg.hashedIndex() + EBDetId::MAX_HASH + 1;
531  if (hi < static_cast<int>(laser->getLaserMap().size())) {
532  laser->setValue(hi, APDPNpair);
533  } else {
534  edm::LogError("EcalTestDevDB") << "error with laser Map (ratio)!";
535  continue;
536  }
537  }
538  }
539 
540  for (int i = 0; i < 92; i++) {
541  if (i < static_cast<int>(laser->getTimeMap().size())) {
542  TimeStamp.t1 = edm::Timestamp(1380 * (i_run - m_firstRun) + 15 * i);
543  TimeStamp.t2 = edm::Timestamp(1380 * (i_run - m_firstRun + 1) + 15 * i);
544  laser->setTime(i, TimeStamp);
545  } else {
546  edm::LogError("EcalTestDevDB") << "error with laser Map (time)!";
547  continue;
548  }
549  }
550  }
551 
552  return laser;
553 }
554 
555 //--------------------------------------------------------------
556 std::shared_ptr<EcalLaserAPDPNRatiosRef> EcalTestDevDB::generateEcalLaserAPDPNRatiosRef() {
557  //--------------------------------------------------------------
558 
559  auto laser = std::make_shared<EcalLaserAPDPNRatiosRef>();
560 
561  EcalLaserAPDPNref APDPNref;
562 
563  for (int iEta = -EBDetId::MAX_IETA; iEta <= EBDetId::MAX_IETA; ++iEta) {
564  if (iEta == 0)
565  continue;
566  for (int iPhi = EBDetId::MIN_IPHI; iPhi <= EBDetId::MAX_IPHI; ++iPhi) {
567  APDPNref = double(1.5);
568  EBDetId ebid(iEta, iPhi);
569 
570  int hi = ebid.hashedIndex();
571  if (hi < static_cast<int>(laser->getMap().size())) {
572  laser->setValue(hi, APDPNref);
573  } else {
574  edm::LogError("EcalTestDevDB") << "error with laser Map (ref)!";
575  }
576  }
577  }
578 
579  for (int iX = EEDetId::IX_MIN; iX <= EEDetId::IX_MAX; ++iX) {
580  for (int iY = EEDetId::IY_MIN; iY <= EEDetId::IY_MAX; ++iY) {
581  if (!EEDetId::validDetId(iX, iY, 1))
582  continue;
583 
584  EEDetId eedetidpos(iX, iY, 1);
585  APDPNref = double(1.5);
586 
587  int hi = eedetidpos.hashedIndex() + EBDetId::MAX_HASH + 1;
588  if (hi < static_cast<int>(laser->getMap().size())) {
589  laser->setValue(hi, APDPNref);
590  } else {
591  edm::LogError("EcalTestDevDB") << "error with laser Map (ref)!";
592  }
593 
594  if (!EEDetId::validDetId(iX, iY, -1))
595  continue;
596 
597  EEDetId eedetidneg(iX, iY, -1);
598  APDPNref = double(1.5);
599 
600  hi = eedetidneg.hashedIndex() + EBDetId::MAX_HASH + 1;
601  if (hi < static_cast<int>(laser->getMap().size())) {
602  laser->setValue(hi, APDPNref);
603  } else {
604  edm::LogError("EcalTestDevDB") << "error with laser Map (ref)!";
605  }
606  }
607  }
608 
609  return laser;
610 }
611 
612 //--------------------------------------------------------------
613 std::shared_ptr<EcalLaserAlphas> EcalTestDevDB::generateEcalLaserAlphas() {
614  //--------------------------------------------------------------
615 
616  auto laser = std::make_shared<EcalLaserAlphas>();
617 
619 
620  for (int iEta = -EBDetId::MAX_IETA; iEta <= EBDetId::MAX_IETA; ++iEta) {
621  if (iEta == 0)
622  continue;
623  for (int iPhi = EBDetId::MIN_IPHI; iPhi <= EBDetId::MAX_IPHI; ++iPhi) {
624  Alpha = double(1.55);
625  EBDetId ebid(iEta, iPhi);
626 
627  int hi = ebid.hashedIndex();
628  if (hi < static_cast<int>(laser->getMap().size())) {
629  laser->setValue(hi, Alpha);
630  } else {
631  edm::LogError("EcalTestDevDB") << "error with laser Map (alpha)!";
632  }
633  }
634  }
635 
636  for (int iX = EEDetId::IX_MIN; iX <= EEDetId::IX_MAX; ++iX) {
637  for (int iY = EEDetId::IY_MIN; iY <= EEDetId::IY_MAX; ++iY) {
638  if (!EEDetId::validDetId(iX, iY, 1))
639  continue;
640 
641  EEDetId eedetidpos(iX, iY, 1);
642  Alpha = double(1.55);
643 
644  int hi = eedetidpos.hashedIndex() + EBDetId::MAX_HASH + 1;
645  if (hi < static_cast<int>(laser->getMap().size())) {
646  laser->setValue(hi, Alpha);
647  } else {
648  edm::LogError("EcalTestDevDB") << "error with laser Map (alpha)!";
649  }
650 
651  if (!EEDetId::validDetId(iX, iY, -1))
652  continue;
653  EEDetId eedetidneg(iX, iY, -1);
654  Alpha = double(1.55);
655 
656  hi = eedetidneg.hashedIndex() + EBDetId::MAX_HASH + 1;
657  if (hi < static_cast<int>(laser->getMap().size())) {
658  laser->setValue(hi, Alpha);
659  } else {
660  edm::LogError("EcalTestDevDB") << "error with laser Map (alpha)!";
661  }
662  }
663  }
664 
665  return laser;
666 }
Definition: mat4.h:9
EcalChi2WeightMatrix & getChi2WeightsBeforeGainSwitch()
Definition: EcalWeightSet.h:28
std::shared_ptr< EcalLaserAPDPNRatiosRef > generateEcalLaserAPDPNRatiosRef()
float EcalLaserAlpha
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
static const int MIN_IPHI
Definition: EBDetId.h:135
static Timestamp endOfTime()
Definition: Timestamp.h:76
std::shared_ptr< EcalLinearCorrections > generateEcalLinearCorrections()
static const int MAX_HASH
Definition: EBDetId.h:150
static const IOVSyncValue & endOfTime()
Definition: IOVSyncValue.cc:82
std::shared_ptr< EcalLaserAlphas > generateEcalLaserAlphas()
std::map< std::string, std::string > m_records
Definition: EcalTestDevDB.h:62
math::Matrix< 10, 10 >::type EcalChi2WeightMatrix
Definition: EcalWeightSet.h:20
math::Matrix< 3, 10 >::type EcalWeightMatrix
Definition: EcalWeightSet.h:19
std::shared_ptr< EcalLaserAPDPNRatios > generateEcalLaserAPDPNRatios(uint32_t i_run)
std::shared_ptr< EcalTBWeights > generateEcalTBWeights()
Log< level::Error, false > LogError
static const int IX_MIN
Definition: EEDetId.h:290
unsigned long m_lastRun
Definition: EcalTestDevDB.h:64
float EcalLaserAPDPNref
static const int IY_MIN
Definition: EEDetId.h:294
void createOneIOV(const T &payload, cond::Time_t firstSinceTime, const std::string &recordName)
static bool validDetId(int i, int j)
check if a valid index combination
Definition: EBDetId.h:118
void setGain12Over6(const float &g)
void appendOneIOV(const T &payload, cond::Time_t sinceTime, const std::string &recordName)
std::shared_ptr< EcalGainRatios > generateEcalGainRatios()
EcalTestDevDB(const edm::ParameterSet &iConfig)
vector< ParameterSet > Parameters
bool isNewTagRequest(const std::string &recordName)
Definition: EPCuts.h:4
std::shared_ptr< EcalPedestals > generateEcalPedestals()
~EcalTestDevDB() override
EcalChi2WeightMatrix & getChi2WeightsAfterGainSwitch()
Definition: EcalWeightSet.h:29
EcalWeightMatrix & getWeightsAfterGainSwitch()
Definition: EcalWeightSet.h:27
unsigned int m_interval
Definition: EcalTestDevDB.h:65
static const int IX_MAX
Definition: EEDetId.h:298
std::shared_ptr< EcalIntercalibConstants > generateEcalIntercalibConstants()
void analyze(const edm::Event &evt, const edm::EventSetup &evtSetup) override
Log< level::Info, false > LogInfo
RunNumber_t run() const
Definition: EventID.h:38
unsigned long m_firstRun
Definition: EcalTestDevDB.h:63
static const int MAX_IPHI
Definition: EBDetId.h:137
EcalWeightMatrix & getWeightsBeforeGainSwitch()
Definition: EcalWeightSet.h:26
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
Definition: EEDetId.h:248
static const int MAX_IETA
Definition: EBDetId.h:136
const EventID & eventID() const
Definition: IOVSyncValue.h:40
int hashedIndex() const
get a compact index for arrays
Definition: EBDetId.h:82
std::shared_ptr< EcalADCToGeVConstant > generateEcalADCToGeVConstant()
static const int IY_MAX
Definition: EEDetId.h:302
bool isAvailable() const
Definition: Service.h:40
std::map< std::string, unsigned long long > m_cacheIDs
Definition: EcalTestDevDB.h:61
std::shared_ptr< EcalWeightXtalGroups > generateEcalWeightXtalGroups()
Log< level::Warning, false > LogWarning
int hashedIndex() const
Definition: EEDetId.h:183
void setGain6Over1(const float &g)