File indexing completed on 2024-09-07 04:35:45
0001 #include "FWCore/ServiceRegistry/interface/Service.h"
0002 #include "CondCore/DBOutputService/interface/PoolDBOutputService.h"
0003
0004 #include "FWCore/Framework/interface/Event.h"
0005 #include "FWCore/Framework/interface/MakerMacros.h"
0006 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0007
0008 #include "DataFormats/Common/interface/Handle.h"
0009
0010 #include "FWCore/Framework/interface/ESHandle.h"
0011 #include "FWCore/Framework/interface/EventSetup.h"
0012 #include "FWCore/Framework/interface/EventSetupRecordKey.h"
0013
0014 #include "DataFormats/Provenance/interface/Timestamp.h"
0015
0016 #include "CondTools/Ecal/interface/EcalTestDevDB.h"
0017
0018 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0019
0020 #include <vector>
0021
0022 using namespace std;
0023
0024 EcalTestDevDB::EcalTestDevDB(const edm::ParameterSet& iConfig)
0025 : m_timetype(iConfig.getParameter<std::string>("timetype")), m_cacheIDs(), m_records() {
0026 std::string container;
0027 std::string tag;
0028 std::string record;
0029
0030 m_firstRun = static_cast<unsigned long>(atoi(iConfig.getParameter<std::string>("firstRun").c_str()));
0031 m_lastRun = static_cast<unsigned long>(atoi(iConfig.getParameter<std::string>("lastRun").c_str()));
0032 m_interval = static_cast<unsigned long>(atoi(iConfig.getParameter<std::string>("interval").c_str()));
0033
0034 typedef std::vector<edm::ParameterSet> Parameters;
0035 Parameters toCopy = iConfig.getParameter<Parameters>("toCopy");
0036 for (Parameters::iterator i = toCopy.begin(); i != toCopy.end(); ++i) {
0037 container = i->getParameter<std::string>("container");
0038 record = i->getParameter<std::string>("record");
0039 m_cacheIDs.insert(std::make_pair(container, 0));
0040 m_records.insert(std::make_pair(container, record));
0041 }
0042 }
0043
0044 EcalTestDevDB::~EcalTestDevDB() {}
0045
0046 void EcalTestDevDB::analyze(const edm::Event& evt, const edm::EventSetup& evtSetup) {
0047 edm::Service<cond::service::PoolDBOutputService> dbOutput;
0048 if (!dbOutput.isAvailable()) {
0049 throw cms::Exception("PoolDBOutputService is not available");
0050 }
0051
0052 std::string container;
0053 std::string record;
0054 typedef std::map<std::string, std::string>::const_iterator recordIter;
0055 for (recordIter i = m_records.begin(); i != m_records.end(); ++i) {
0056 container = (*i).first;
0057 record = (*i).second;
0058
0059 std::string recordName = m_records[container];
0060
0061
0062
0063 unsigned long nrec = (m_lastRun - m_firstRun) / m_interval + 1;
0064 unsigned long nstart = 0;
0065 if (m_firstRun == 0 && m_lastRun == 0) {
0066
0067 nstart = 0;
0068 nrec = 1;
0069 }
0070
0071 for (unsigned long i = nstart; i < nrec; i++) {
0072 unsigned long irun = m_firstRun + i * m_interval;
0073
0074
0075 if (m_firstRun == 0 && m_lastRun == 0) {
0076 edm::LogInfo("EcalTestDevDB") << "Infinite IOV mode";
0077 irun = edm::IOVSyncValue::endOfTime().eventID().run();
0078 }
0079
0080 edm::LogInfo("EcalTestDevDB") << "Starting Transaction for run " << irun << "...";
0081
0082 if (container == "EcalPedestals") {
0083 const auto condObject = generateEcalPedestals();
0084 if (irun == m_firstRun && dbOutput->isNewTagRequest(recordName)) {
0085
0086 edm::LogInfo("EcalTestDevDB") << "First One ";
0087 dbOutput->createOneIOV<const EcalPedestals>(*condObject, dbOutput->beginOfTime(), recordName);
0088 } else {
0089
0090 edm::LogInfo("EcalTestDevDB") << "Old One ";
0091 dbOutput->appendOneIOV<const EcalPedestals>(*condObject, irun, recordName);
0092 }
0093
0094 } else if (container == "EcalADCToGeVConstant") {
0095 const auto condObject = generateEcalADCToGeVConstant();
0096 if (irun == m_firstRun && dbOutput->isNewTagRequest(recordName)) {
0097
0098 edm::LogInfo("EcalTestDevDB") << "First One ";
0099 dbOutput->createOneIOV<const EcalADCToGeVConstant>(*condObject, dbOutput->beginOfTime(), recordName);
0100 } else {
0101
0102 edm::LogInfo("EcalTestDevDB") << "Old One ";
0103 dbOutput->appendOneIOV<const EcalADCToGeVConstant>(*condObject, irun, recordName);
0104 }
0105
0106 } else if (container == "EcalIntercalibConstants") {
0107 const auto condObject = generateEcalIntercalibConstants();
0108 if (irun == m_firstRun && dbOutput->isNewTagRequest(recordName)) {
0109
0110 edm::LogInfo("EcalTestDevDB") << "First One ";
0111 dbOutput->createOneIOV<const EcalIntercalibConstants>(*condObject, dbOutput->beginOfTime(), recordName);
0112 } else {
0113
0114 edm::LogInfo("EcalTestDevDB") << "Old One ";
0115 dbOutput->appendOneIOV<const EcalIntercalibConstants>(*condObject, irun, recordName);
0116 }
0117 } else if (container == "EcalLinearCorrections") {
0118 const auto condObject = generateEcalLinearCorrections();
0119 if (irun == m_firstRun && dbOutput->isNewTagRequest(recordName)) {
0120
0121 edm::LogInfo("EcalTestDevDB") << "First One ";
0122 dbOutput->createOneIOV<const EcalLinearCorrections>(*condObject, dbOutput->beginOfTime(), recordName);
0123 } else {
0124
0125 edm::LogInfo("EcalTestDevDB") << "Old One ";
0126 dbOutput->appendOneIOV<const EcalLinearCorrections>(*condObject, irun, recordName);
0127 }
0128
0129 } else if (container == "EcalGainRatios") {
0130 const auto condObject = generateEcalGainRatios();
0131 if (irun == m_firstRun && dbOutput->isNewTagRequest(recordName)) {
0132
0133 edm::LogInfo("EcalTestDevDB") << "First One ";
0134 dbOutput->createOneIOV<const EcalGainRatios>(*condObject, dbOutput->beginOfTime(), recordName);
0135 } else {
0136
0137 edm::LogInfo("EcalTestDevDB") << "Old One ";
0138 dbOutput->appendOneIOV<const EcalGainRatios>(*condObject, irun, recordName);
0139 }
0140
0141 } else if (container == "EcalWeightXtalGroups") {
0142 const auto condObject = generateEcalWeightXtalGroups();
0143 if (irun == m_firstRun && dbOutput->isNewTagRequest(recordName)) {
0144
0145 edm::LogInfo("EcalTestDevDB") << "First One ";
0146 dbOutput->createOneIOV<const EcalWeightXtalGroups>(*condObject, dbOutput->beginOfTime(), recordName);
0147 } else {
0148
0149 edm::LogInfo("EcalTestDevDB") << "Old One ";
0150 dbOutput->appendOneIOV<const EcalWeightXtalGroups>(*condObject, irun, recordName);
0151 }
0152
0153 } else if (container == "EcalTBWeights") {
0154 const auto condObject = generateEcalTBWeights();
0155 if (irun == m_firstRun && dbOutput->isNewTagRequest(recordName)) {
0156
0157 edm::LogInfo("EcalTestDevDB") << "First One ";
0158 dbOutput->createOneIOV<const EcalTBWeights>(*condObject, dbOutput->beginOfTime(), recordName);
0159 } else {
0160
0161 edm::LogInfo("EcalTestDevDB") << "Old One ";
0162 dbOutput->appendOneIOV<const EcalTBWeights>(*condObject, irun, recordName);
0163 }
0164
0165 } else if (container == "EcalLaserAPDPNRatios") {
0166 const auto condObject = generateEcalLaserAPDPNRatios(irun);
0167 if (irun == m_firstRun && dbOutput->isNewTagRequest(recordName)) {
0168
0169 edm::LogInfo("EcalTestDevDB") << "First One ";
0170 dbOutput->createOneIOV<const EcalLaserAPDPNRatios>(*condObject, dbOutput->beginOfTime(), recordName);
0171 } else {
0172
0173 edm::LogInfo("EcalTestDevDB") << "Old One ";
0174 dbOutput->appendOneIOV<const EcalLaserAPDPNRatios>(*condObject, irun, recordName);
0175 }
0176 } else if (container == "EcalLaserAPDPNRatiosRef") {
0177 const auto condObject = generateEcalLaserAPDPNRatiosRef();
0178 if (irun == m_firstRun && dbOutput->isNewTagRequest(recordName)) {
0179
0180 edm::LogInfo("EcalTestDevDB") << "First One ";
0181 dbOutput->createOneIOV<const EcalLaserAPDPNRatiosRef>(*condObject, dbOutput->beginOfTime(), recordName);
0182 } else {
0183
0184 edm::LogInfo("EcalTestDevDB") << "Old One ";
0185 dbOutput->appendOneIOV<const EcalLaserAPDPNRatiosRef>(*condObject, irun, recordName);
0186 }
0187 } else if (container == "EcalLaserAlphas") {
0188 const auto condObject = generateEcalLaserAlphas();
0189 if (irun == m_firstRun && dbOutput->isNewTagRequest(recordName)) {
0190
0191 edm::LogInfo("EcalTestDevDB") << "First One ";
0192 dbOutput->createOneIOV<const EcalLaserAlphas>(*condObject, dbOutput->beginOfTime(), recordName);
0193 } else {
0194
0195 edm::LogInfo("EcalTestDevDB") << "Old One ";
0196 dbOutput->appendOneIOV<const EcalLaserAlphas>(*condObject, irun, recordName);
0197 }
0198 } else {
0199 edm::LogWarning("EcalTestDevDB") << "it does not work yet for " << container << "...";
0200 }
0201 }
0202 }
0203 }
0204
0205
0206 std::shared_ptr<EcalPedestals> EcalTestDevDB::generateEcalPedestals() {
0207
0208
0209 auto peds = std::make_shared<EcalPedestals>();
0210 EcalPedestals::Item item;
0211 for (int iEta = -EBDetId::MAX_IETA; iEta <= EBDetId::MAX_IETA; ++iEta) {
0212 if (iEta == 0)
0213 continue;
0214 for (int iPhi = EBDetId::MIN_IPHI; iPhi <= EBDetId::MAX_IPHI; ++iPhi) {
0215 item.mean_x1 = 200. * ((double)std::rand() / (double(RAND_MAX) + double(1)));
0216 item.rms_x1 = (double)std::rand() / (double(RAND_MAX) + double(1));
0217 item.mean_x6 = 1200. * ((double)std::rand() / (double(RAND_MAX) + double(1)));
0218 item.rms_x6 = 6. * ((double)std::rand() / (double(RAND_MAX) + double(1)));
0219 item.mean_x12 = 2400. * ((double)std::rand() / (double(RAND_MAX) + double(1)));
0220 item.rms_x12 = 12. * ((double)std::rand() / (double(RAND_MAX) + double(1)));
0221
0222 EBDetId ebdetid(iEta, iPhi);
0223 peds->insert(std::make_pair(ebdetid.rawId(), item));
0224 }
0225 }
0226 return peds;
0227 }
0228
0229
0230 std::shared_ptr<EcalADCToGeVConstant> EcalTestDevDB::generateEcalADCToGeVConstant() {
0231
0232
0233 double r = (double)std::rand() / (double(RAND_MAX) + double(1));
0234 auto agc = std::make_shared<EcalADCToGeVConstant>(36. + r * 4., 60. + r * 4);
0235 return agc;
0236 }
0237
0238
0239 std::shared_ptr<EcalIntercalibConstants> EcalTestDevDB::generateEcalIntercalibConstants() {
0240
0241
0242 auto ical = std::make_shared<EcalIntercalibConstants>();
0243
0244 for (int ieta = -EBDetId::MAX_IETA; ieta <= EBDetId::MAX_IETA; ++ieta) {
0245 if (ieta == 0)
0246 continue;
0247 for (int iphi = EBDetId::MIN_IPHI; iphi <= EBDetId::MAX_IPHI; ++iphi) {
0248 EBDetId ebid(ieta, iphi);
0249
0250 double r = (double)std::rand() / (double(RAND_MAX) + double(1));
0251 ical->setValue(ebid.rawId(), 0.85 + r * 0.3);
0252 }
0253 }
0254 return ical;
0255 }
0256
0257
0258 std::shared_ptr<EcalLinearCorrections> EcalTestDevDB::generateEcalLinearCorrections() {
0259
0260
0261 auto ical = std::make_shared<EcalLinearCorrections>();
0262
0263 for (int ieta = -EBDetId::MAX_IETA; ieta <= EBDetId::MAX_IETA; ++ieta) {
0264 if (ieta == 0)
0265 continue;
0266 for (int iphi = EBDetId::MIN_IPHI; iphi <= EBDetId::MAX_IPHI; ++iphi) {
0267 if (EBDetId::validDetId(ieta, iphi)) {
0268 EBDetId ebid(ieta, iphi);
0269
0270 EcalLinearCorrections::Values pairAPDPN;
0271 pairAPDPN.p1 = 1.0;
0272 pairAPDPN.p2 = 1.0;
0273 pairAPDPN.p3 = 1.0;
0274 ical->setValue(ebid, pairAPDPN);
0275 }
0276 }
0277 }
0278
0279 for (int iX = EEDetId::IX_MIN; iX <= EEDetId::IX_MAX; ++iX) {
0280 for (int iY = EEDetId::IY_MIN; iY <= EEDetId::IY_MAX; ++iY) {
0281
0282 if (EEDetId::validDetId(iX, iY, 1)) {
0283 EEDetId eedetidpos(iX, iY, 1);
0284
0285 EcalLinearCorrections::Values pairAPDPN;
0286 pairAPDPN.p1 = 1.0;
0287 pairAPDPN.p2 = 1.0;
0288 pairAPDPN.p3 = 1.0;
0289
0290 ical->setValue(eedetidpos, pairAPDPN);
0291 }
0292
0293 if (EEDetId::validDetId(iX, iY, -1)) {
0294 EEDetId eedetidneg(iX, iY, -1);
0295
0296 EcalLinearCorrections::Values pairAPDPN;
0297 pairAPDPN.p1 = 1.0;
0298 pairAPDPN.p2 = 1.0;
0299 pairAPDPN.p3 = 1.0;
0300
0301 ical->setValue(eedetidneg, pairAPDPN);
0302 }
0303 }
0304 }
0305
0306 EcalLinearCorrections::Times TimeStamp;
0307 for (int i = 0; i < 92; i++) {
0308 TimeStamp.t1 = edm::Timestamp(0);
0309 TimeStamp.t2 = edm::Timestamp(edm::Timestamp::endOfTime().value());
0310 TimeStamp.t3 = edm::Timestamp(edm::Timestamp::endOfTime().value());
0311
0312 ical->setTime(i, TimeStamp);
0313 }
0314
0315 return ical;
0316 }
0317
0318
0319 std::shared_ptr<EcalGainRatios> EcalTestDevDB::generateEcalGainRatios() {
0320
0321
0322
0323 auto gratio = std::make_shared<EcalGainRatios>();
0324
0325 for (int ieta = -EBDetId::MAX_IETA; ieta <= EBDetId::MAX_IETA; ++ieta) {
0326 if (ieta == 0)
0327 continue;
0328 for (int iphi = EBDetId::MIN_IPHI; iphi <= EBDetId::MAX_IPHI; ++iphi) {
0329 EBDetId ebid(ieta, iphi);
0330
0331 double r = (double)std::rand() / (double(RAND_MAX) + double(1));
0332
0333 EcalMGPAGainRatio gr;
0334 gr.setGain12Over6(1.9 + r * 0.2);
0335 gr.setGain6Over1(5.9 + r * 0.2);
0336
0337 gratio->setValue(ebid.rawId(), gr);
0338
0339 }
0340 }
0341 return gratio;
0342 }
0343
0344
0345 std::shared_ptr<EcalWeightXtalGroups> EcalTestDevDB::generateEcalWeightXtalGroups() {
0346
0347
0348 auto xtalGroups = std::make_shared<EcalWeightXtalGroups>();
0349 for (int ieta = -EBDetId::MAX_IETA; ieta <= EBDetId::MAX_IETA; ++ieta) {
0350 if (ieta == 0)
0351 continue;
0352 for (int iphi = EBDetId::MIN_IPHI; iphi <= EBDetId::MAX_IPHI; ++iphi) {
0353 EBDetId ebid(ieta, iphi);
0354 xtalGroups->setValue(ebid.rawId(), EcalXtalGroupId(ieta));
0355 }
0356 }
0357 return xtalGroups;
0358 }
0359
0360
0361 std::shared_ptr<EcalTBWeights> EcalTestDevDB::generateEcalTBWeights() {
0362
0363
0364 auto tbwgt = std::make_shared<EcalTBWeights>();
0365
0366
0367 int nMaxTDC = 10;
0368 for (int igrp = -EBDetId::MAX_IETA; igrp <= EBDetId::MAX_IETA; ++igrp) {
0369 if (igrp == 0)
0370 continue;
0371 for (int itdc = 1; itdc <= nMaxTDC; ++itdc) {
0372
0373 double r = (double)std::rand() / (double(RAND_MAX) + double(1));
0374
0375
0376 EcalWeightSet wgt;
0377 EcalWeightSet::EcalWeightMatrix& mat1 = wgt.getWeightsBeforeGainSwitch();
0378 EcalWeightSet::EcalWeightMatrix& mat2 = wgt.getWeightsAfterGainSwitch();
0379
0380 for (size_t i = 0; i < 3; ++i) {
0381 for (size_t j = 0; j < 10; ++j) {
0382 double ww = igrp * itdc * r + i * 10. + j;
0383 mat1(i, j) = ww;
0384 mat2(i, j) = 100 + ww;
0385 }
0386 }
0387
0388
0389 r = (double)std::rand() / (double(RAND_MAX) + double(1));
0390 EcalWeightSet::EcalChi2WeightMatrix& mat3 = wgt.getChi2WeightsBeforeGainSwitch();
0391 EcalWeightSet::EcalChi2WeightMatrix& mat4 = wgt.getChi2WeightsAfterGainSwitch();
0392 for (size_t i = 0; i < 10; ++i) {
0393 for (size_t j = 0; j < 10; ++j) {
0394 double ww = igrp * itdc * r + i * 10. + j;
0395 mat3(i, j) = 1000 + ww;
0396 mat4(i, j) = 1000 + 100 + ww;
0397 }
0398 }
0399
0400
0401 tbwgt->setValue(std::make_pair(igrp, itdc), wgt);
0402 }
0403 }
0404 return tbwgt;
0405 }
0406
0407
0408 std::shared_ptr<EcalLaserAPDPNRatios> EcalTestDevDB::generateEcalLaserAPDPNRatios(uint32_t i_run) {
0409
0410
0411 auto laser = std::make_shared<EcalLaserAPDPNRatios>();
0412
0413 EcalLaserAPDPNRatios::EcalLaserAPDPNpair APDPNpair;
0414 EcalLaserAPDPNRatios::EcalLaserTimeStamp TimeStamp;
0415
0416
0417
0418 edm::LogInfo("EcalTestDevDB") << "First & last run: " << i_run << " " << m_firstRun << " " << m_lastRun;
0419 if (m_firstRun == i_run && (i_run == 0 || i_run == 1)) {
0420 APDPNpair.p1 = (double(1) + 1 / double(log(exp(1) + double((i_run - m_firstRun) * 10)))) / double(2);
0421 APDPNpair.p2 = (double(1) + 1 / double(log(exp(1) + double((i_run - m_firstRun) * 10) + double(10)))) / double(2);
0422 APDPNpair.p3 = double(0);
0423 edm::LogInfo("EcalTestDevDB") << i_run << " " << m_firstRun << " " << APDPNpair.p1 << " " << APDPNpair.p2;
0424
0425 for (int iEta = -EBDetId::MAX_IETA; iEta <= EBDetId::MAX_IETA; ++iEta) {
0426 if (iEta == 0)
0427 continue;
0428 for (int iPhi = EBDetId::MIN_IPHI; iPhi <= EBDetId::MAX_IPHI; ++iPhi) {
0429
0430
0431
0432 EBDetId ebid(iEta, iPhi);
0433 int hi = ebid.hashedIndex();
0434
0435 if (hi < static_cast<int>(laser->getLaserMap().size())) {
0436 laser->setValue(hi, APDPNpair);
0437 } else {
0438 edm::LogError("EcalTestDevDB") << "error with laser Map (ratio)!";
0439 continue;
0440 }
0441 }
0442 }
0443
0444 for (int iX = EEDetId::IX_MIN; iX <= EEDetId::IX_MAX; ++iX) {
0445 for (int iY = EEDetId::IY_MIN; iY <= EEDetId::IY_MAX; ++iY) {
0446
0447
0448 if (!EEDetId::validDetId(iX, iY, 1))
0449 continue;
0450
0451 EEDetId eedetidpos(iX, iY, 1);
0452
0453
0454
0455 int hi = eedetidpos.hashedIndex() + EBDetId::MAX_HASH + 1;
0456 if (hi < static_cast<int>(laser->getLaserMap().size())) {
0457 laser->setValue(hi, APDPNpair);
0458 } else {
0459 edm::LogError("EcalTestDevDB") << "error with laser Map (ratio)!";
0460 continue;
0461 }
0462
0463 if (!EEDetId::validDetId(iX, iY, -1))
0464 continue;
0465
0466 EEDetId eedetidneg(iX, iY, -1);
0467
0468
0469 hi = eedetidneg.hashedIndex() + EBDetId::MAX_HASH + 1;
0470 if (hi < static_cast<int>(laser->getLaserMap().size())) {
0471 laser->setValue(hi, APDPNpair);
0472 } else {
0473 edm::LogError("EcalTestDevDB") << "error with laser Map (ratio)!";
0474 continue;
0475 }
0476 }
0477 }
0478
0479 for (int i = 0; i < 92; i++) {
0480 if (i < static_cast<int>(laser->getTimeMap().size())) {
0481 TimeStamp.t1 = edm::Timestamp(1380 * (i_run - m_firstRun) + 15 * i);
0482 TimeStamp.t2 = edm::Timestamp(1380 * (i_run - m_firstRun + 1) + 15 * i);
0483 laser->setTime(i, TimeStamp);
0484 } else {
0485 edm::LogError("EcalTestDevDB") << "error with laser Map (time)!";
0486 continue;
0487 }
0488 }
0489
0490 } else {
0491 APDPNpair.p1 = (double(1) + 1 / double(log(exp(1) + double((i_run - m_firstRun) * 10)))) / double(2);
0492 APDPNpair.p2 = (double(1) + 1 / double(log(exp(1) + double((i_run - m_firstRun) * 10) + double(10)))) / double(2);
0493 APDPNpair.p3 = double(0);
0494 edm::LogInfo("EcalTestDevDB") << i_run << " " << m_firstRun << " " << APDPNpair.p1 << " " << APDPNpair.p2;
0495
0496 for (int iEta = -EBDetId::MAX_IETA; iEta <= EBDetId::MAX_IETA; ++iEta) {
0497 if (iEta == 0)
0498 continue;
0499 for (int iPhi = EBDetId::MIN_IPHI; iPhi <= EBDetId::MAX_IPHI; ++iPhi) {
0500 EBDetId ebid(iEta, iPhi);
0501 int hi = ebid.hashedIndex();
0502
0503 if (hi < static_cast<int>(laser->getLaserMap().size())) {
0504 laser->setValue(hi, APDPNpair);
0505 } else {
0506 edm::LogError("EcalTestDevDB") << "error with laser Map (ratio)!";
0507 }
0508 }
0509 }
0510 for (int iX = EEDetId::IX_MIN; iX <= EEDetId::IX_MAX; ++iX) {
0511 for (int iY = EEDetId::IY_MIN; iY <= EEDetId::IY_MAX; ++iY) {
0512
0513
0514 if (!EEDetId::validDetId(iX, iY, 1))
0515 continue;
0516
0517 EEDetId eedetidpos(iX, iY, 1);
0518 int hi = eedetidpos.hashedIndex() + EBDetId::MAX_HASH + 1;
0519 if (hi < static_cast<int>(laser->getLaserMap().size())) {
0520 laser->setValue(hi, APDPNpair);
0521 } else {
0522 edm::LogError("EcalTestDevDB") << "error with laser Map (ratio)!";
0523 continue;
0524 }
0525
0526 if (!EEDetId::validDetId(iX, iY, -1))
0527 continue;
0528
0529 EEDetId eedetidneg(iX, iY, -1);
0530 hi = eedetidneg.hashedIndex() + EBDetId::MAX_HASH + 1;
0531 if (hi < static_cast<int>(laser->getLaserMap().size())) {
0532 laser->setValue(hi, APDPNpair);
0533 } else {
0534 edm::LogError("EcalTestDevDB") << "error with laser Map (ratio)!";
0535 continue;
0536 }
0537 }
0538 }
0539
0540 for (int i = 0; i < 92; i++) {
0541 if (i < static_cast<int>(laser->getTimeMap().size())) {
0542 TimeStamp.t1 = edm::Timestamp(1380 * (i_run - m_firstRun) + 15 * i);
0543 TimeStamp.t2 = edm::Timestamp(1380 * (i_run - m_firstRun + 1) + 15 * i);
0544 laser->setTime(i, TimeStamp);
0545 } else {
0546 edm::LogError("EcalTestDevDB") << "error with laser Map (time)!";
0547 continue;
0548 }
0549 }
0550 }
0551
0552 return laser;
0553 }
0554
0555
0556 std::shared_ptr<EcalLaserAPDPNRatiosRef> EcalTestDevDB::generateEcalLaserAPDPNRatiosRef() {
0557
0558
0559 auto laser = std::make_shared<EcalLaserAPDPNRatiosRef>();
0560
0561 EcalLaserAPDPNref APDPNref;
0562
0563 for (int iEta = -EBDetId::MAX_IETA; iEta <= EBDetId::MAX_IETA; ++iEta) {
0564 if (iEta == 0)
0565 continue;
0566 for (int iPhi = EBDetId::MIN_IPHI; iPhi <= EBDetId::MAX_IPHI; ++iPhi) {
0567 APDPNref = double(1.5);
0568 EBDetId ebid(iEta, iPhi);
0569
0570 int hi = ebid.hashedIndex();
0571 if (hi < static_cast<int>(laser->getMap().size())) {
0572 laser->setValue(hi, APDPNref);
0573 } else {
0574 edm::LogError("EcalTestDevDB") << "error with laser Map (ref)!";
0575 }
0576 }
0577 }
0578
0579 for (int iX = EEDetId::IX_MIN; iX <= EEDetId::IX_MAX; ++iX) {
0580 for (int iY = EEDetId::IY_MIN; iY <= EEDetId::IY_MAX; ++iY) {
0581 if (!EEDetId::validDetId(iX, iY, 1))
0582 continue;
0583
0584 EEDetId eedetidpos(iX, iY, 1);
0585 APDPNref = double(1.5);
0586
0587 int hi = eedetidpos.hashedIndex() + EBDetId::MAX_HASH + 1;
0588 if (hi < static_cast<int>(laser->getMap().size())) {
0589 laser->setValue(hi, APDPNref);
0590 } else {
0591 edm::LogError("EcalTestDevDB") << "error with laser Map (ref)!";
0592 }
0593
0594 if (!EEDetId::validDetId(iX, iY, -1))
0595 continue;
0596
0597 EEDetId eedetidneg(iX, iY, -1);
0598 APDPNref = double(1.5);
0599
0600 hi = eedetidneg.hashedIndex() + EBDetId::MAX_HASH + 1;
0601 if (hi < static_cast<int>(laser->getMap().size())) {
0602 laser->setValue(hi, APDPNref);
0603 } else {
0604 edm::LogError("EcalTestDevDB") << "error with laser Map (ref)!";
0605 }
0606 }
0607 }
0608
0609 return laser;
0610 }
0611
0612
0613 std::shared_ptr<EcalLaserAlphas> EcalTestDevDB::generateEcalLaserAlphas() {
0614
0615
0616 auto laser = std::make_shared<EcalLaserAlphas>();
0617
0618 EcalLaserAlpha Alpha;
0619
0620 for (int iEta = -EBDetId::MAX_IETA; iEta <= EBDetId::MAX_IETA; ++iEta) {
0621 if (iEta == 0)
0622 continue;
0623 for (int iPhi = EBDetId::MIN_IPHI; iPhi <= EBDetId::MAX_IPHI; ++iPhi) {
0624 Alpha = double(1.55);
0625 EBDetId ebid(iEta, iPhi);
0626
0627 int hi = ebid.hashedIndex();
0628 if (hi < static_cast<int>(laser->getMap().size())) {
0629 laser->setValue(hi, Alpha);
0630 } else {
0631 edm::LogError("EcalTestDevDB") << "error with laser Map (alpha)!";
0632 }
0633 }
0634 }
0635
0636 for (int iX = EEDetId::IX_MIN; iX <= EEDetId::IX_MAX; ++iX) {
0637 for (int iY = EEDetId::IY_MIN; iY <= EEDetId::IY_MAX; ++iY) {
0638 if (!EEDetId::validDetId(iX, iY, 1))
0639 continue;
0640
0641 EEDetId eedetidpos(iX, iY, 1);
0642 Alpha = double(1.55);
0643
0644 int hi = eedetidpos.hashedIndex() + EBDetId::MAX_HASH + 1;
0645 if (hi < static_cast<int>(laser->getMap().size())) {
0646 laser->setValue(hi, Alpha);
0647 } else {
0648 edm::LogError("EcalTestDevDB") << "error with laser Map (alpha)!";
0649 }
0650
0651 if (!EEDetId::validDetId(iX, iY, -1))
0652 continue;
0653 EEDetId eedetidneg(iX, iY, -1);
0654 Alpha = double(1.55);
0655
0656 hi = eedetidneg.hashedIndex() + EBDetId::MAX_HASH + 1;
0657 if (hi < static_cast<int>(laser->getMap().size())) {
0658 laser->setValue(hi, Alpha);
0659 } else {
0660 edm::LogError("EcalTestDevDB") << "error with laser Map (alpha)!";
0661 }
0662 }
0663 }
0664
0665 return laser;
0666 }