Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-09-28 23:48:08

0001 // -*- C++ -*-
0002 // Original Author:  Fedor Ratnikov
0003 //
0004 //
0005 
0006 #include <memory>
0007 #include <iostream>
0008 #include <string>
0009 #include <vector>
0010 
0011 #include "FWCore/Framework/interface/ValidityInterval.h"
0012 #include "DataFormats/HcalDetId/interface/HcalZDCDetId.h"
0013 #include "DataFormats/HcalDetId/interface/HcalDetId.h"
0014 #include "DataFormats/HcalDetId/interface/HcalGenericDetId.h"
0015 #include "DataFormats/HcalDetId/interface/HcalSubdetector.h"
0016 #include "DataFormats/HcalDetId/interface/HcalTrigTowerDetId.h"
0017 #include "FWCore/ParameterSet/interface/FileInPath.h"
0018 
0019 #include "CondFormats/DataRecord/interface/HcalAllRcds.h"
0020 #include "Geometry/Records/interface/HcalRecNumberingRecord.h"
0021 
0022 #include "Geometry/ForwardGeometry/interface/ZdcTopology.h"
0023 #include "Geometry/CaloTopology/interface/HcalTopology.h"
0024 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0025 
0026 #include "HcalHardcodeCalibrations.h"
0027 
0028 //#define DebugLog
0029 
0030 // class decleration
0031 //
0032 
0033 using namespace cms;
0034 
0035 namespace {
0036 
0037   const std::vector<HcalGenericDetId>& allCells(const HcalTopology& hcaltopology, bool killHE = false) {
0038     static std::vector<HcalGenericDetId> result;
0039     int maxDepth = hcaltopology.maxDepth();
0040 
0041 #ifdef DebugLog
0042     std::cout << std::endl << "HcalHardcodeCalibrations:   maxDepth = " << maxDepth << std::endl;
0043 #endif
0044 
0045     if (result.empty()) {
0046       for (int eta = -HcalDetId::kHcalEtaMask2; eta <= (int)(HcalDetId::kHcalEtaMask2); eta++) {
0047         for (unsigned int phi = 0; phi <= HcalDetId::kHcalPhiMask2; phi++) {
0048           for (int depth = 1; depth <= maxDepth; depth++) {
0049             for (int det = 1; det <= HcalForward; det++) {
0050               HcalDetId cell((HcalSubdetector)det, eta, phi, depth);
0051               if (killHE && HcalEndcap == cell.subdetId())
0052                 continue;
0053               if (hcaltopology.valid(cell)) {
0054                 result.push_back(cell);
0055 #ifdef DebugLog
0056                 std::cout << " HcalHardcodedCalibrations: det|eta|phi|depth = " << det << "|" << eta << "|" << phi
0057                           << "|" << depth << std::endl;
0058 #endif
0059               }
0060             }
0061           }
0062         }
0063       }
0064       ZdcTopology zdctopology;
0065       HcalZDCDetId zcell;
0066       HcalZDCDetId::Section section = HcalZDCDetId::EM;
0067       for (int depth = 1; depth < 6; depth++) {
0068         zcell = HcalZDCDetId(section, true, depth);
0069         if (zdctopology.valid(zcell))
0070           result.push_back(zcell);
0071         zcell = HcalZDCDetId(section, false, depth);
0072         if (zdctopology.valid(zcell))
0073           result.push_back(zcell);
0074       }
0075       section = HcalZDCDetId::HAD;
0076       for (int depth = 1; depth < 5; depth++) {
0077         zcell = HcalZDCDetId(section, true, depth);
0078         if (zdctopology.valid(zcell))
0079           result.push_back(zcell);
0080         zcell = HcalZDCDetId(section, false, depth);
0081         if (zdctopology.valid(zcell))
0082           result.push_back(zcell);
0083       }
0084       section = HcalZDCDetId::LUM;
0085       for (int depth = 1; depth < 3; depth++) {
0086         zcell = HcalZDCDetId(section, true, depth);
0087         if (zdctopology.valid(zcell))
0088           result.push_back(zcell);
0089         zcell = HcalZDCDetId(section, false, depth);
0090         if (zdctopology.valid(zcell))
0091           result.push_back(zcell);
0092       }
0093       section = HcalZDCDetId::RPD;
0094       for (int depth = 1; depth < 17; depth++) {
0095         zcell = HcalZDCDetId(section, true, depth);
0096         if (zdctopology.valid(zcell))
0097           result.push_back(zcell);
0098         zcell = HcalZDCDetId(section, false, depth);
0099         if (zdctopology.valid(zcell))
0100           result.push_back(zcell);
0101       }
0102 
0103       // HcalGenTriggerTower (HcalGenericSubdetector = 5)
0104       // NASTY HACK !!!
0105       // - As no valid(cell) check found for HcalTrigTowerDetId
0106       // to create HT cells (ieta=1-28, iphi=1-72)&(ieta=29-32, iphi=1,5,... 69)
0107 
0108       for (int vers = 0; vers <= HcalTrigTowerDetId::kHcalVersMask; ++vers) {
0109         for (int depth = 0; depth <= HcalTrigTowerDetId::kHcalDepthMask; ++depth) {
0110           for (int eta = -HcalTrigTowerDetId::kHcalEtaMask; eta <= HcalTrigTowerDetId::kHcalEtaMask; eta++) {
0111             for (int phi = 1; phi <= HcalTrigTowerDetId::kHcalPhiMask; phi++) {
0112               HcalTrigTowerDetId cell(eta, phi, depth, vers);
0113               if (hcaltopology.validHT(cell)) {
0114                 result.push_back(cell);
0115 #ifdef DebugLog
0116                 std::cout << " HcalHardcodedCalibrations: eta|phi|depth|vers = " << eta << "|" << phi << "|" << depth
0117                           << "|" << vers << std::endl;
0118 #endif
0119               }
0120             }
0121           }
0122         }
0123       }
0124     }
0125     return result;
0126   }
0127 
0128 }  // namespace
0129 
0130 HcalHardcodeCalibrations::HcalHardcodeCalibrations(const edm::ParameterSet& iConfig)
0131     : hb_recalibration(nullptr),
0132       he_recalibration(nullptr),
0133       hf_recalibration(nullptr),
0134       setHEdsegm(false),
0135       setHBdsegm(false) {
0136   edm::LogInfo("HCAL") << "HcalHardcodeCalibrations::HcalHardcodeCalibrations->...";
0137 
0138   if (iConfig.exists("GainWidthsForTrigPrims"))
0139     switchGainWidthsForTrigPrims = iConfig.getParameter<bool>("GainWidthsForTrigPrims");
0140   else
0141     switchGainWidthsForTrigPrims = false;
0142 
0143   //DB helper preparation
0144   dbHardcode.setHB(HcalHardcodeParameters(iConfig.getParameter<edm::ParameterSet>("hb")));
0145   dbHardcode.setHE(HcalHardcodeParameters(iConfig.getParameter<edm::ParameterSet>("he")));
0146   dbHardcode.setHF(HcalHardcodeParameters(iConfig.getParameter<edm::ParameterSet>("hf")));
0147   dbHardcode.setHO(HcalHardcodeParameters(iConfig.getParameter<edm::ParameterSet>("ho")));
0148   dbHardcode.setHBUpgrade(HcalHardcodeParameters(iConfig.getParameter<edm::ParameterSet>("hbUpgrade")));
0149   dbHardcode.setHEUpgrade(HcalHardcodeParameters(iConfig.getParameter<edm::ParameterSet>("heUpgrade")));
0150   dbHardcode.setHFUpgrade(HcalHardcodeParameters(iConfig.getParameter<edm::ParameterSet>("hfUpgrade")));
0151   dbHardcode.useHBUpgrade(iConfig.getParameter<bool>("useHBUpgrade"));
0152   dbHardcode.useHEUpgrade(iConfig.getParameter<bool>("useHEUpgrade"));
0153   dbHardcode.useHFUpgrade(iConfig.getParameter<bool>("useHFUpgrade"));
0154   dbHardcode.useHOUpgrade(iConfig.getParameter<bool>("useHOUpgrade"));
0155   dbHardcode.testHFQIE10(iConfig.getParameter<bool>("testHFQIE10"));
0156   dbHardcode.testHEPlan1(iConfig.getParameter<bool>("testHEPlan1"));
0157   dbHardcode.setKillHE(iConfig.getParameter<bool>("killHE"));
0158   dbHardcode.setSiPMCharacteristics(iConfig.getParameter<std::vector<edm::ParameterSet>>("SiPMCharacteristics"));
0159 
0160   useLayer0Weight = iConfig.getParameter<bool>("useLayer0Weight");
0161   useIeta18depth1 = iConfig.getParameter<bool>("useIeta18depth1");
0162   testHEPlan1 = iConfig.getParameter<bool>("testHEPlan1");
0163   // HB, HE, HF recalibration preparation
0164   iLumi = iConfig.getParameter<double>("iLumi");
0165 
0166   if (iLumi > 0.0) {
0167     bool hb_recalib = iConfig.getParameter<bool>("HBRecalibration");
0168     bool he_recalib = iConfig.getParameter<bool>("HERecalibration");
0169     bool hf_recalib = iConfig.getParameter<bool>("HFRecalibration");
0170     if (hb_recalib) {
0171       hb_recalibration =
0172           std::make_unique<HBHERecalibration>(iLumi,
0173                                               iConfig.getParameter<double>("HBreCalibCutoff"),
0174                                               iConfig.getParameter<edm::FileInPath>("HBmeanenergies").fullPath());
0175     }
0176     if (he_recalib) {
0177       he_recalibration =
0178           std::make_unique<HBHERecalibration>(iLumi,
0179                                               iConfig.getParameter<double>("HEreCalibCutoff"),
0180                                               iConfig.getParameter<edm::FileInPath>("HEmeanenergies").fullPath());
0181     }
0182     if (hf_recalib && !iConfig.getParameter<edm::ParameterSet>("HFRecalParameterBlock").empty())
0183       hf_recalibration =
0184           std::make_unique<HFRecalibration>(iConfig.getParameter<edm::ParameterSet>("HFRecalParameterBlock"));
0185 
0186 #ifdef DebugLog
0187     std::cout << " HcalHardcodeCalibrations:  iLumi = " << iLumi << std::endl;
0188 #endif
0189   }
0190 
0191   std::vector<std::string> toGet = iConfig.getUntrackedParameter<std::vector<std::string>>("toGet");
0192   for (auto& objectName : toGet) {
0193     bool all = objectName == "all";
0194 #ifdef DebugLog
0195     std::cout << "Load parameters for " << objectName << std::endl;
0196 #endif
0197     if ((objectName == "Pedestals") || all) {
0198       topoTokens_[kPedestals] = setWhatProduced(this, &HcalHardcodeCalibrations::producePedestals).consumes();
0199       findingRecord<HcalPedestalsRcd>();
0200     }
0201     if ((objectName == "PedestalWidths") || all) {
0202       topoTokens_[kPedestalWidths] = setWhatProduced(this, &HcalHardcodeCalibrations::producePedestalWidths).consumes();
0203       findingRecord<HcalPedestalWidthsRcd>();
0204     }
0205     if ((objectName == "EffectivePedestals") || all) {
0206       topoTokens_[kEffectivePedestals] =
0207           setWhatProduced(this, &HcalHardcodeCalibrations::produceEffectivePedestals, edm::es::Label("effective"))
0208               .consumes();
0209       findingRecord<HcalPedestalsRcd>();
0210     }
0211     if ((objectName == "EffectivePedestalWidths") || all) {
0212       topoTokens_[kEffectivePedestalWidths] =
0213           setWhatProduced(this, &HcalHardcodeCalibrations::produceEffectivePedestalWidths, edm::es::Label("effective"))
0214               .consumes();
0215       findingRecord<HcalPedestalWidthsRcd>();
0216     }
0217     if ((objectName == "Gains") || all) {
0218       topoTokens_[kGains] = setWhatProduced(this, &HcalHardcodeCalibrations::produceGains).consumes();
0219       findingRecord<HcalGainsRcd>();
0220     }
0221     if ((objectName == "GainWidths") || all) {
0222       topoTokens_[kGainWidths] = setWhatProduced(this, &HcalHardcodeCalibrations::produceGainWidths).consumes();
0223       findingRecord<HcalGainWidthsRcd>();
0224     }
0225     if ((objectName == "QIEData") || all) {
0226       topoTokens_[kQIEData] = setWhatProduced(this, &HcalHardcodeCalibrations::produceQIEData).consumes();
0227       findingRecord<HcalQIEDataRcd>();
0228     }
0229     if ((objectName == "QIETypes") || all) {
0230       topoTokens_[kQIETypes] = setWhatProduced(this, &HcalHardcodeCalibrations::produceQIETypes).consumes();
0231       findingRecord<HcalQIETypesRcd>();
0232     }
0233     if ((objectName == "ChannelQuality") || (objectName == "channelQuality") || all) {
0234       topoTokens_[kChannelQuality] = setWhatProduced(this, &HcalHardcodeCalibrations::produceChannelQuality).consumes();
0235       findingRecord<HcalChannelQualityRcd>();
0236     }
0237     if ((objectName == "ElectronicsMap") || (objectName == "electronicsMap") || all) {
0238       topoTokens_[kElectronicsMap] = setWhatProduced(this, &HcalHardcodeCalibrations::produceElectronicsMap).consumes();
0239       findingRecord<HcalElectronicsMapRcd>();
0240     }
0241     if ((objectName == "ZSThresholds") || (objectName == "zsThresholds") || all) {
0242       topoTokens_[kZSThresholds] = setWhatProduced(this, &HcalHardcodeCalibrations::produceZSThresholds).consumes();
0243       findingRecord<HcalZSThresholdsRcd>();
0244     }
0245     if ((objectName == "RespCorrs") || (objectName == "ResponseCorrection") || all) {
0246       auto c = setWhatProduced(this, &HcalHardcodeCalibrations::produceRespCorrs);
0247       topoTokens_[kRespCorrs] = c.consumes();
0248       if (he_recalibration) {
0249         heDarkeningToken_ = c.consumes(edm::ESInputTag("", "HE"));
0250       }
0251       if (hb_recalibration) {
0252         hbDarkeningToken_ = c.consumes(edm::ESInputTag("", "HB"));
0253       }
0254       findingRecord<HcalRespCorrsRcd>();
0255     }
0256     if ((objectName == "LUTCorrs") || (objectName == "LUTCorrection") || all) {
0257       topoTokens_[kLUTCorrs] = setWhatProduced(this, &HcalHardcodeCalibrations::produceLUTCorrs).consumes();
0258       findingRecord<HcalLUTCorrsRcd>();
0259     }
0260     if ((objectName == "PFCorrs") || (objectName == "PFCorrection") || all) {
0261       topoTokens_[kPFCorrs] = setWhatProduced(this, &HcalHardcodeCalibrations::producePFCorrs).consumes();
0262       findingRecord<HcalPFCorrsRcd>();
0263     }
0264     if ((objectName == "TimeCorrs") || (objectName == "TimeCorrection") || all) {
0265       topoTokens_[kTimeCorrs] = setWhatProduced(this, &HcalHardcodeCalibrations::produceTimeCorrs).consumes();
0266       findingRecord<HcalTimeCorrsRcd>();
0267     }
0268     if ((objectName == "L1TriggerObjects") || (objectName == "L1Trigger") || all) {
0269       topoTokens_[kL1TriggerObjects] =
0270           setWhatProduced(this, &HcalHardcodeCalibrations::produceL1TriggerObjects).consumes();
0271       findingRecord<HcalL1TriggerObjectsRcd>();
0272     }
0273     if ((objectName == "ValidationCorrs") || (objectName == "ValidationCorrection") || all) {
0274       topoTokens_[kValidationCorrs] =
0275           setWhatProduced(this, &HcalHardcodeCalibrations::produceValidationCorrs).consumes();
0276       findingRecord<HcalValidationCorrsRcd>();
0277     }
0278     if ((objectName == "LutMetadata") || (objectName == "lutMetadata") || all) {
0279       topoTokens_[kLutMetadata] = setWhatProduced(this, &HcalHardcodeCalibrations::produceLutMetadata).consumes();
0280       findingRecord<HcalLutMetadataRcd>();
0281     }
0282     if ((objectName == "DcsValues") || all) {
0283       setWhatProduced(this, &HcalHardcodeCalibrations::produceDcsValues);
0284       findingRecord<HcalDcsRcd>();
0285     }
0286     if ((objectName == "DcsMap") || (objectName == "dcsMap") || all) {
0287       setWhatProduced(this, &HcalHardcodeCalibrations::produceDcsMap);
0288       findingRecord<HcalDcsMapRcd>();
0289     }
0290     if ((objectName == "RecoParams") || all) {
0291       topoTokens_[kRecoParams] = setWhatProduced(this, &HcalHardcodeCalibrations::produceRecoParams).consumes();
0292       findingRecord<HcalRecoParamsRcd>();
0293     }
0294     if ((objectName == "LongRecoParams") || all) {
0295       topoTokens_[kLongRecoParams] = setWhatProduced(this, &HcalHardcodeCalibrations::produceLongRecoParams).consumes();
0296       findingRecord<HcalLongRecoParamsRcd>();
0297     }
0298     if ((objectName == "ZDCLowGainFractions") || all) {
0299       topoTokens_[kZDCLowGainFractions] =
0300           setWhatProduced(this, &HcalHardcodeCalibrations::produceZDCLowGainFractions).consumes();
0301       findingRecord<HcalZDCLowGainFractionsRcd>();
0302     }
0303     if ((objectName == "MCParams") || all) {
0304       topoTokens_[kMCParams] = setWhatProduced(this, &HcalHardcodeCalibrations::produceMCParams).consumes();
0305       findingRecord<HcalMCParamsRcd>();
0306     }
0307     if ((objectName == "FlagHFDigiTimeParams") || all) {
0308       topoTokens_[kFlagHFDigiTimeParams] =
0309           setWhatProduced(this, &HcalHardcodeCalibrations::produceFlagHFDigiTimeParams).consumes();
0310       findingRecord<HcalFlagHFDigiTimeParamsRcd>();
0311     }
0312     if ((objectName == "FrontEndMap") || (objectName == "frontEndMap") || all) {
0313       topoTokens_[kFrontEndMap] = setWhatProduced(this, &HcalHardcodeCalibrations::produceFrontEndMap).consumes();
0314       findingRecord<HcalFrontEndMapRcd>();
0315     }
0316     if ((objectName == "SiPMParameters") || all) {
0317       topoTokens_[kSiPMParameters] = setWhatProduced(this, &HcalHardcodeCalibrations::produceSiPMParameters).consumes();
0318       findingRecord<HcalSiPMParametersRcd>();
0319     }
0320     if ((objectName == "SiPMCharacteristics") || all) {
0321       setWhatProduced(this, &HcalHardcodeCalibrations::produceSiPMCharacteristics);
0322       findingRecord<HcalSiPMCharacteristicsRcd>();
0323     }
0324     if ((objectName == "TPChannelParameters") || all) {
0325       topoTokens_[kTPChannelParameters] =
0326           setWhatProduced(this, &HcalHardcodeCalibrations::produceTPChannelParameters).consumes();
0327       findingRecord<HcalTPChannelParametersRcd>();
0328     }
0329     if ((objectName == "TPParameters") || all) {
0330       setWhatProduced(this, &HcalHardcodeCalibrations::produceTPParameters);
0331       findingRecord<HcalTPParametersRcd>();
0332     }
0333   }
0334 }
0335 
0336 HcalHardcodeCalibrations::~HcalHardcodeCalibrations() {}
0337 
0338 //
0339 // member functions
0340 //
0341 void HcalHardcodeCalibrations::setIntervalFor(const edm::eventsetup::EventSetupRecordKey& iKey,
0342                                               const edm::IOVSyncValue& iTime,
0343                                               edm::ValidityInterval& oInterval) {
0344   std::string record = iKey.name();
0345   edm::LogInfo("HCAL") << "HcalHardcodeCalibrations::setIntervalFor-> key: " << record << " time: " << iTime.eventID()
0346                        << '/' << iTime.time().value();
0347   oInterval = edm::ValidityInterval(edm::IOVSyncValue::beginOfTime(), edm::IOVSyncValue::endOfTime());  //infinite
0348 }
0349 
0350 std::unique_ptr<HcalPedestals> HcalHardcodeCalibrations::producePedestals_(
0351     const HcalPedestalsRcd& rec, const edm::ESGetToken<HcalTopology, HcalRecNumberingRecord>& token, bool eff) {
0352   std::string seff = eff ? "Effective" : "";
0353   edm::LogInfo("HCAL") << "HcalHardcodeCalibrations::produce" << seff << "Pedestals-> ...";
0354 
0355   auto const& topo = rec.get(token);
0356   auto result = std::make_unique<HcalPedestals>(&topo, false);
0357   const std::vector<HcalGenericDetId>& cells = allCells(topo, dbHardcode.killHE());
0358   for (auto cell : cells) {
0359     HcalPedestal item = dbHardcode.makePedestal(cell, false, eff, &topo, iLumi);
0360     result->addValues(item);
0361   }
0362   return result;
0363 }
0364 
0365 std::unique_ptr<HcalPedestalWidths> HcalHardcodeCalibrations::producePedestalWidths_(
0366     const HcalPedestalWidthsRcd& rec, const edm::ESGetToken<HcalTopology, HcalRecNumberingRecord>& token, bool eff) {
0367   std::string seff = eff ? "Effective" : "";
0368   edm::LogInfo("HCAL") << "HcalHardcodeCalibrations::produce" << seff << "PedestalWidths-> ...";
0369   auto const& topo = rec.get(token);
0370   auto result = std::make_unique<HcalPedestalWidths>(&topo, false);
0371   const std::vector<HcalGenericDetId>& cells = allCells(topo, dbHardcode.killHE());
0372   for (auto cell : cells) {
0373     HcalPedestalWidth item = dbHardcode.makePedestalWidth(cell, eff, &topo, iLumi);
0374     result->addValues(item);
0375   }
0376   return result;
0377 }
0378 
0379 std::unique_ptr<HcalPedestals> HcalHardcodeCalibrations::producePedestals(const HcalPedestalsRcd& rec) {
0380   return producePedestals_(rec, topoTokens_[kPedestals], false);
0381 }
0382 
0383 std::unique_ptr<HcalPedestals> HcalHardcodeCalibrations::produceEffectivePedestals(const HcalPedestalsRcd& rec) {
0384   return producePedestals_(rec, topoTokens_[kEffectivePedestals], true);
0385 }
0386 
0387 std::unique_ptr<HcalPedestalWidths> HcalHardcodeCalibrations::producePedestalWidths(const HcalPedestalWidthsRcd& rec) {
0388   return producePedestalWidths_(rec, topoTokens_[kPedestalWidths], false);
0389 }
0390 
0391 std::unique_ptr<HcalPedestalWidths> HcalHardcodeCalibrations::produceEffectivePedestalWidths(
0392     const HcalPedestalWidthsRcd& rec) {
0393   return producePedestalWidths_(rec, topoTokens_[kEffectivePedestalWidths], true);
0394 }
0395 
0396 std::unique_ptr<HcalGains> HcalHardcodeCalibrations::produceGains(const HcalGainsRcd& rec) {
0397   edm::LogInfo("HCAL") << "HcalHardcodeCalibrations::produceGains-> ...";
0398 
0399   auto const& topo = rec.get(topoTokens_[kGains]);
0400   auto result = std::make_unique<HcalGains>(&topo);
0401   const std::vector<HcalGenericDetId>& cells = allCells(topo, dbHardcode.killHE());
0402   for (auto cell : cells) {
0403     HcalGain item = dbHardcode.makeGain(cell);
0404     result->addValues(item);
0405   }
0406   return result;
0407 }
0408 
0409 std::unique_ptr<HcalGainWidths> HcalHardcodeCalibrations::produceGainWidths(const HcalGainWidthsRcd& rec) {
0410   edm::LogInfo("HCAL") << "HcalHardcodeCalibrations::produceGainWidths-> ...";
0411 
0412   auto const& topo = rec.get(topoTokens_[kGainWidths]);
0413   auto result = std::make_unique<HcalGainWidths>(&topo);
0414   const std::vector<HcalGenericDetId>& cells = allCells(topo, dbHardcode.killHE());
0415   for (auto cell : cells) {
0416     // for Upgrade - include TrigPrims, for regular case - only HcalDetId
0417     if (switchGainWidthsForTrigPrims) {
0418       HcalGainWidth item = dbHardcode.makeGainWidth(cell);
0419       result->addValues(item);
0420     } else if (!cell.isHcalTrigTowerDetId()) {
0421       HcalGainWidth item = dbHardcode.makeGainWidth(cell);
0422       result->addValues(item);
0423     }
0424   }
0425   return result;
0426 }
0427 
0428 std::unique_ptr<HcalQIEData> HcalHardcodeCalibrations::produceQIEData(const HcalQIEDataRcd& rcd) {
0429   edm::LogInfo("HCAL") << "HcalHardcodeCalibrations::produceQIEData-> ...";
0430 
0431   /*
0432   std::cout << std::endl << ">>>  HcalHardcodeCalibrations::produceQIEData"
0433         << std::endl;  
0434   */
0435 
0436   auto const& topo = rcd.get(topoTokens_[kQIEData]);
0437   auto result = std::make_unique<HcalQIEData>(&topo);
0438   const std::vector<HcalGenericDetId>& cells = allCells(topo, dbHardcode.killHE());
0439   for (auto cell : cells) {
0440     HcalQIECoder coder = dbHardcode.makeQIECoder(cell);
0441     result->addCoder(coder);
0442   }
0443   return result;
0444 }
0445 
0446 std::unique_ptr<HcalQIETypes> HcalHardcodeCalibrations::produceQIETypes(const HcalQIETypesRcd& rcd) {
0447   edm::LogInfo("HCAL") << "HcalHardcodeCalibrations::produceQIETypes-> ...";
0448   auto const& topo = rcd.get(topoTokens_[kQIETypes]);
0449 
0450   auto result = std::make_unique<HcalQIETypes>(&topo);
0451   const std::vector<HcalGenericDetId>& cells = allCells(topo, dbHardcode.killHE());
0452   for (auto cell : cells) {
0453     HcalQIEType item = dbHardcode.makeQIEType(cell);
0454     result->addValues(item);
0455   }
0456   return result;
0457 }
0458 
0459 std::unique_ptr<HcalChannelQuality> HcalHardcodeCalibrations::produceChannelQuality(const HcalChannelQualityRcd& rcd) {
0460   edm::LogInfo("HCAL") << "HcalHardcodeCalibrations::produceChannelQuality-> ...";
0461   auto const& topo = rcd.get(topoTokens_[kChannelQuality]);
0462 
0463   auto result = std::make_unique<HcalChannelQuality>(&topo);
0464   const std::vector<HcalGenericDetId>& cells = allCells(topo, dbHardcode.killHE());
0465   for (auto cell : cells) {
0466     // Special: removal of (non-instrumented) layer "-1"("nose") = depth 1
0467     // from Upgrade HE, either from
0468     // (i)  HEP17 sector in 2017 or
0469     // (ii) the entire HE rin=18 from 2018 through Run 3.
0470     // May require a revision  by 2021.
0471 
0472     uint32_t status = 0;
0473 
0474     if (!(cell.isHcalZDCDetId())) {
0475       HcalDetId hid = HcalDetId(cell);
0476       int iphi = hid.iphi();
0477       int ieta = hid.ieta();
0478       int absieta = hid.ietaAbs();
0479       int depth = hid.depth();
0480 
0481       // specific HEP17 sector (2017 only)
0482       bool isHEP17 = (iphi >= 63) && (iphi <= 66) && (ieta > 0);
0483       // |ieta|=18, depth=1
0484       bool is18d1 = (absieta == 18) && (depth == 1);
0485 
0486       if ((!useIeta18depth1 && is18d1) && ((testHEPlan1 && isHEP17) || (!testHEPlan1))) {
0487         status = 0x8002;  // dead cell
0488       }
0489     }
0490 
0491     HcalChannelStatus item(cell.rawId(), status);
0492     result->addValues(item);
0493   }
0494 
0495   return result;
0496 }
0497 
0498 std::unique_ptr<HcalRespCorrs> HcalHardcodeCalibrations::produceRespCorrs(const HcalRespCorrsRcd& rcd) {
0499   edm::LogInfo("HCAL") << "HcalHardcodeCalibrations::produceRespCorrs-> ...";
0500   auto const& topo = rcd.get(topoTokens_[kRespCorrs]);
0501 
0502   //set depth segmentation for HB/HE recalib - only happens once
0503   if ((he_recalibration && !setHEdsegm) || (hb_recalibration && !setHBdsegm)) {
0504     std::vector<std::vector<int>> m_segmentation;
0505     int maxEta = topo.lastHBHERing();
0506     m_segmentation.resize(maxEta);
0507     for (int i = 0; i < maxEta; i++) {
0508       topo.getDepthSegmentation(i + 1, m_segmentation[i]);
0509     }
0510     if (he_recalibration && !setHEdsegm) {
0511       he_recalibration->setup(m_segmentation, &rcd.get(heDarkeningToken_));
0512       setHEdsegm = true;
0513     }
0514     if (hb_recalibration && !setHBdsegm) {
0515       hb_recalibration->setup(m_segmentation, &rcd.get(hbDarkeningToken_));
0516       setHBdsegm = true;
0517     }
0518   }
0519 
0520   auto result = std::make_unique<HcalRespCorrs>(&topo);
0521   const std::vector<HcalGenericDetId>& cells = allCells(topo, dbHardcode.killHE());
0522   for (const auto& cell : cells) {
0523     double corr = 1.0;
0524 
0525     //check for layer 0 reweighting: when depth 1 has only one layer, it is layer 0
0526     if (useLayer0Weight &&
0527         ((cell.genericSubdet() == HcalGenericDetId::HcalGenEndcap) ||
0528          (cell.genericSubdet() == HcalGenericDetId::HcalGenBarrel)) &&
0529         (HcalDetId(cell).depth() == 1 &&
0530          dbHardcode.getLayersInDepth(HcalDetId(cell).ietaAbs(), HcalDetId(cell).depth(), &topo) == 1)) {
0531       //layer 0 is thicker than other layers (9mm vs 3.7mm) and brighter (Bicron vs SCSN81)
0532       //in Run1/Run2 (pre-2017 for HE), ODU for layer 0 had neutral density filter attached
0533       //NDF was simulated as weight of 0.5 applied to Geant energy deposits
0534       //for Phase1, NDF is removed - simulated as weight of 1.2 applied to Geant energy deposits
0535       //to maintain RECO calibrations, move the layer 0 energy scale back to its previous state using respcorrs
0536       corr = 0.5 / 1.2;
0537     }
0538 
0539     if ((hb_recalibration != nullptr) && (cell.genericSubdet() == HcalGenericDetId::HcalGenBarrel)) {
0540       int depth_ = HcalDetId(cell).depth();
0541       int ieta_ = HcalDetId(cell).ieta();
0542       corr *= hb_recalibration->getCorr(ieta_, depth_);
0543 #ifdef DebugLog
0544       std::cout << "HB ieta, depth = " << ieta_ << ",  " << depth_ << "   corr = " << corr << std::endl;
0545 #endif
0546     } else if ((he_recalibration != nullptr) && (cell.genericSubdet() == HcalGenericDetId::HcalGenEndcap)) {
0547       int depth_ = HcalDetId(cell).depth();
0548       int ieta_ = HcalDetId(cell).ieta();
0549       corr *= he_recalibration->getCorr(ieta_, depth_);
0550 #ifdef DebugLog
0551       std::cout << "HE ieta, depth = " << ieta_ << ",  " << depth_ << "   corr = " << corr << std::endl;
0552 #endif
0553     } else if ((hf_recalibration != nullptr) && (cell.genericSubdet() == HcalGenericDetId::HcalGenForward)) {
0554       int depth_ = HcalDetId(cell).depth();
0555       int ieta_ = HcalDetId(cell).ieta();
0556       corr = hf_recalibration->getCorr(ieta_, depth_, iLumi);
0557 #ifdef DebugLog
0558       std::cout << "HF ieta, depth = " << ieta_ << ",  " << depth_ << "   corr = " << corr << std::endl;
0559 #endif
0560     }
0561 
0562     HcalRespCorr item(cell.rawId(), corr);
0563     result->addValues(item);
0564   }
0565   return result;
0566 }
0567 
0568 std::unique_ptr<HcalLUTCorrs> HcalHardcodeCalibrations::produceLUTCorrs(const HcalLUTCorrsRcd& rcd) {
0569   edm::LogInfo("HCAL") << "HcalHardcodeCalibrations::produceLUTCorrs-> ...";
0570   auto const& topo = rcd.get(topoTokens_[kLUTCorrs]);
0571 
0572   auto result = std::make_unique<HcalLUTCorrs>(&topo);
0573   const std::vector<HcalGenericDetId>& cells = allCells(topo, dbHardcode.killHE());
0574   for (auto cell : cells) {
0575     HcalLUTCorr item(cell.rawId(), 1.0);
0576     result->addValues(item);
0577   }
0578   return result;
0579 }
0580 
0581 std::unique_ptr<HcalPFCorrs> HcalHardcodeCalibrations::producePFCorrs(const HcalPFCorrsRcd& rcd) {
0582   edm::LogInfo("HCAL") << "HcalHardcodeCalibrations::producePFCorrs-> ...";
0583   auto const& topo = rcd.get(topoTokens_[kPFCorrs]);
0584 
0585   auto result = std::make_unique<HcalPFCorrs>(&topo);
0586   const std::vector<HcalGenericDetId>& cells = allCells(topo, dbHardcode.killHE());
0587   for (auto cell : cells) {
0588     HcalPFCorr item(cell.rawId(), 1.0);
0589     result->addValues(item);
0590   }
0591   return result;
0592 }
0593 
0594 std::unique_ptr<HcalTimeCorrs> HcalHardcodeCalibrations::produceTimeCorrs(const HcalTimeCorrsRcd& rcd) {
0595   edm::LogInfo("HCAL") << "HcalHardcodeCalibrations::produceTimeCorrs-> ...";
0596   auto const& topo = rcd.get(topoTokens_[kTimeCorrs]);
0597 
0598   auto result = std::make_unique<HcalTimeCorrs>(&topo);
0599   const std::vector<HcalGenericDetId>& cells = allCells(topo, dbHardcode.killHE());
0600   for (auto cell : cells) {
0601     HcalTimeCorr item(cell.rawId(), 0.0);
0602     result->addValues(item);
0603   }
0604   return result;
0605 }
0606 
0607 std::unique_ptr<HcalZSThresholds> HcalHardcodeCalibrations::produceZSThresholds(const HcalZSThresholdsRcd& rcd) {
0608   edm::LogInfo("HCAL") << "HcalHardcodeCalibrations::produceZSThresholds-> ...";
0609   auto const& topo = rcd.get(topoTokens_[kZSThresholds]);
0610 
0611   auto result = std::make_unique<HcalZSThresholds>(&topo);
0612   const std::vector<HcalGenericDetId>& cells = allCells(topo, dbHardcode.killHE());
0613   for (auto cell : cells) {
0614     HcalZSThreshold item = dbHardcode.makeZSThreshold(cell);
0615     result->addValues(item);
0616   }
0617   return result;
0618 }
0619 
0620 std::unique_ptr<HcalL1TriggerObjects> HcalHardcodeCalibrations::produceL1TriggerObjects(
0621     const HcalL1TriggerObjectsRcd& rcd) {
0622   edm::LogInfo("HCAL") << "HcalHardcodeCalibrations::produceL1TriggerObjects-> ...";
0623   auto const& topo = rcd.get(topoTokens_[kL1TriggerObjects]);
0624 
0625   auto result = std::make_unique<HcalL1TriggerObjects>(&topo);
0626   const std::vector<HcalGenericDetId>& cells = allCells(topo, dbHardcode.killHE());
0627   for (auto cell : cells) {
0628     HcalL1TriggerObject item(cell.rawId(), 0., 1., 0);
0629     result->addValues(item);
0630   }
0631   // add tag and algo values
0632   result->setTagString("hardcoded");
0633   result->setAlgoString("hardcoded");
0634   return result;
0635 }
0636 
0637 std::unique_ptr<HcalElectronicsMap> HcalHardcodeCalibrations::produceElectronicsMap(const HcalElectronicsMapRcd& rcd) {
0638   edm::LogInfo("HCAL") << "HcalHardcodeCalibrations::produceElectronicsMap-> ...";
0639   auto const& topo = rcd.get(topoTokens_[kElectronicsMap]);
0640 
0641   const std::vector<HcalGenericDetId>& cells = allCells(topo, dbHardcode.killHE());
0642   return dbHardcode.makeHardcodeMap(cells);
0643 }
0644 
0645 std::unique_ptr<HcalValidationCorrs> HcalHardcodeCalibrations::produceValidationCorrs(
0646     const HcalValidationCorrsRcd& rcd) {
0647   edm::LogInfo("HCAL") << "HcalHardcodeCalibrations::produceValidationCorrs-> ...";
0648   auto const& topo = rcd.get(topoTokens_[kValidationCorrs]);
0649 
0650   auto result = std::make_unique<HcalValidationCorrs>(&topo);
0651   const std::vector<HcalGenericDetId>& cells = allCells(topo, dbHardcode.killHE());
0652   for (auto cell : cells) {
0653     HcalValidationCorr item(cell.rawId(), 1.0);
0654     result->addValues(item);
0655   }
0656   return result;
0657 }
0658 
0659 std::unique_ptr<HcalLutMetadata> HcalHardcodeCalibrations::produceLutMetadata(const HcalLutMetadataRcd& rcd) {
0660   edm::LogInfo("HCAL") << "HcalHardcodeCalibrations::produceLutMetadata-> ...";
0661   auto const& topo = rcd.get(topoTokens_[kLutMetadata]);
0662 
0663   auto result = std::make_unique<HcalLutMetadata>(&topo);
0664 
0665   result->setRctLsb(0.5);
0666   result->setNominalGain(0.177);  // for HBHE SiPMs
0667 
0668   const std::vector<HcalGenericDetId>& cells = allCells(topo, dbHardcode.killHE());
0669   for (const auto& cell : cells) {
0670     float rcalib = 1.;
0671     int granularity = 1;
0672     int threshold = 0;
0673 
0674     if (cell.isHcalTrigTowerDetId()) {
0675       rcalib = 0.;
0676     }
0677 
0678     HcalLutMetadatum item(cell.rawId(), rcalib, granularity, threshold);
0679     result->addValues(item);
0680   }
0681 
0682   return result;
0683 }
0684 
0685 std::unique_ptr<HcalDcsValues> HcalHardcodeCalibrations::produceDcsValues(const HcalDcsRcd& rcd) {
0686   edm::LogInfo("HCAL") << "HcalHardcodeCalibrations::produceDcsValues-> ...";
0687   auto result = std::make_unique<HcalDcsValues>();
0688   return result;
0689 }
0690 
0691 std::unique_ptr<HcalDcsMap> HcalHardcodeCalibrations::produceDcsMap(const HcalDcsMapRcd& rcd) {
0692   edm::LogInfo("HCAL") << "HcalHardcodeCalibrations::produceDcsMap-> ...";
0693 
0694   return dbHardcode.makeHardcodeDcsMap();
0695 }
0696 
0697 std::unique_ptr<HcalRecoParams> HcalHardcodeCalibrations::produceRecoParams(const HcalRecoParamsRcd& rec) {
0698   edm::LogInfo("HCAL") << "HcalHardcodeCalibrations::produceRecoParams-> ...";
0699   auto const& topo = rec.get(topoTokens_[kRecoParams]);
0700 
0701   auto result = std::make_unique<HcalRecoParams>(&topo);
0702   const std::vector<HcalGenericDetId>& cells = allCells(topo, dbHardcode.killHE());
0703   for (auto cell : cells) {
0704     HcalRecoParam item = dbHardcode.makeRecoParam(cell);
0705     result->addValues(item);
0706   }
0707   return result;
0708 }
0709 
0710 std::unique_ptr<HcalTimingParams> HcalHardcodeCalibrations::produceTimingParams(const HcalTimingParamsRcd& rec) {
0711   edm::LogInfo("HCAL") << "HcalHardcodeCalibrations::produceTimingParams-> ...";
0712   auto const& topo = rec.get(topoTokens_[kTimingParams]);
0713 
0714   auto result = std::make_unique<HcalTimingParams>(&topo);
0715   const std::vector<HcalGenericDetId>& cells = allCells(topo, dbHardcode.killHE());
0716   for (auto cell : cells) {
0717     HcalTimingParam item = dbHardcode.makeTimingParam(cell);
0718     result->addValues(item);
0719   }
0720   return result;
0721 }
0722 
0723 std::unique_ptr<HcalLongRecoParams> HcalHardcodeCalibrations::produceLongRecoParams(const HcalLongRecoParamsRcd& rec) {
0724   edm::LogInfo("HCAL") << "HcalHardcodeCalibrations::produceLongRecoParams-> ...";
0725   auto const& topo = rec.get(topoTokens_[kLongRecoParams]);
0726 
0727   auto result = std::make_unique<HcalLongRecoParams>(&topo);
0728   const std::vector<HcalGenericDetId>& cells = allCells(topo, dbHardcode.killHE());
0729   std::vector<unsigned int> mSignal;
0730   mSignal.push_back(4);
0731   mSignal.push_back(5);
0732   mSignal.push_back(6);
0733   std::vector<unsigned int> mNoise;
0734   mNoise.push_back(1);
0735   mNoise.push_back(2);
0736   mNoise.push_back(3);
0737   for (auto cell : cells) {
0738     if (cell.isHcalZDCDetId()) {
0739       HcalLongRecoParam item(cell.rawId(), mSignal, mNoise);
0740       result->addValues(item);
0741     }
0742   }
0743   return result;
0744 }
0745 
0746 std::unique_ptr<HcalZDCLowGainFractions> HcalHardcodeCalibrations::produceZDCLowGainFractions(
0747     const HcalZDCLowGainFractionsRcd& rec) {
0748   edm::LogInfo("HCAL") << "HcalHardcodeCalibrations::produceZDCLowGainFractions-> ...";
0749   auto const& topo = rec.get(topoTokens_[kZDCLowGainFractions]);
0750 
0751   auto result = std::make_unique<HcalZDCLowGainFractions>(&topo);
0752   const std::vector<HcalGenericDetId>& cells = allCells(topo, dbHardcode.killHE());
0753   for (auto cell : cells) {
0754     HcalZDCLowGainFraction item(cell.rawId(), 0.0);
0755     result->addValues(item);
0756   }
0757   return result;
0758 }
0759 
0760 std::unique_ptr<HcalMCParams> HcalHardcodeCalibrations::produceMCParams(const HcalMCParamsRcd& rec) {
0761   //  std::cout << std::endl << " .... HcalHardcodeCalibrations::produceMCParams ->"<< std::endl;
0762 
0763   edm::LogInfo("HCAL") << "HcalHardcodeCalibrations::produceMCParams-> ...";
0764   auto const& topo = rec.get(topoTokens_[kMCParams]);
0765   auto result = std::make_unique<HcalMCParams>(&topo);
0766   const std::vector<HcalGenericDetId>& cells = allCells(topo, dbHardcode.killHE());
0767   for (auto cell : cells) {
0768     HcalMCParam item = dbHardcode.makeMCParam(cell);
0769     result->addValues(item);
0770   }
0771   return result;
0772 }
0773 
0774 std::unique_ptr<HcalFlagHFDigiTimeParams> HcalHardcodeCalibrations::produceFlagHFDigiTimeParams(
0775     const HcalFlagHFDigiTimeParamsRcd& rec) {
0776   edm::LogInfo("HCAL") << "HcalHardcodeCalibrations::produceFlagHFDigiTimeParams-> ...";
0777   auto const& topo = rec.get(topoTokens_[kFlagHFDigiTimeParams]);
0778 
0779   auto result = std::make_unique<HcalFlagHFDigiTimeParams>(&topo);
0780   const std::vector<HcalGenericDetId>& cells = allCells(topo, dbHardcode.killHE());
0781 
0782   std::vector<double> coef;
0783   coef.push_back(0.93);
0784   coef.push_back(-0.38275);
0785   coef.push_back(-0.012667);
0786 
0787   for (auto cell : cells) {
0788     HcalFlagHFDigiTimeParam item(cell.rawId(),
0789                                  1,    //firstsample
0790                                  3,    // samplestoadd
0791                                  2,    //expectedpeak
0792                                  40.,  // min energy threshold
0793                                  coef  // coefficients
0794     );
0795     result->addValues(item);
0796   }
0797   return result;
0798 }
0799 
0800 std::unique_ptr<HcalFrontEndMap> HcalHardcodeCalibrations::produceFrontEndMap(const HcalFrontEndMapRcd& rec) {
0801   edm::LogInfo("HCAL") << "HcalHardcodeCalibrations::produceFrontEndMap-> ...";
0802   auto const& topo = rec.get(topoTokens_[kFrontEndMap]);
0803 
0804   const std::vector<HcalGenericDetId>& cells = allCells(topo, dbHardcode.killHE());
0805 
0806   return dbHardcode.makeHardcodeFrontEndMap(cells);
0807 }
0808 
0809 std::unique_ptr<HcalSiPMParameters> HcalHardcodeCalibrations::produceSiPMParameters(const HcalSiPMParametersRcd& rec) {
0810   edm::LogInfo("HCAL") << "HcalHardcodeCalibrations::produceSiPMParameters-> ...";
0811   auto const& topo = rec.get(topoTokens_[kSiPMParameters]);
0812 
0813   auto result = std::make_unique<HcalSiPMParameters>(&topo);
0814   const std::vector<HcalGenericDetId>& cells = allCells(topo, dbHardcode.killHE());
0815   for (auto cell : cells) {
0816     HcalSiPMParameter item = dbHardcode.makeHardcodeSiPMParameter(cell, &topo, iLumi);
0817     result->addValues(item);
0818   }
0819   return result;
0820 }
0821 
0822 std::unique_ptr<HcalSiPMCharacteristics> HcalHardcodeCalibrations::produceSiPMCharacteristics(
0823     const HcalSiPMCharacteristicsRcd& rcd) {
0824   edm::LogInfo("HCAL") << "HcalHardcodeCalibrations::produceSiPMCharacteristics-> ...";
0825 
0826   return dbHardcode.makeHardcodeSiPMCharacteristics();
0827 }
0828 
0829 std::unique_ptr<HcalTPChannelParameters> HcalHardcodeCalibrations::produceTPChannelParameters(
0830     const HcalTPChannelParametersRcd& rec) {
0831   edm::LogInfo("HCAL") << "HcalHardcodeCalibrations::produceTPChannelParameters-> ...";
0832   auto const& topo = rec.get(topoTokens_[kTPChannelParameters]);
0833 
0834   auto result = std::make_unique<HcalTPChannelParameters>(&topo);
0835   const std::vector<HcalGenericDetId>& cells = allCells(topo, dbHardcode.killHE());
0836   for (auto cell : cells) {
0837     // Thinking about Phase2 and the new FIR filter,
0838     // for now, don't put TT in TPChannelParams
0839     if (cell.subdetId() == HcalTriggerTower)
0840       continue;
0841     HcalTPChannelParameter item = dbHardcode.makeHardcodeTPChannelParameter(cell);
0842     result->addValues(item);
0843   }
0844   return result;
0845 }
0846 
0847 std::unique_ptr<HcalTPParameters> HcalHardcodeCalibrations::produceTPParameters(const HcalTPParametersRcd& rcd) {
0848   edm::LogInfo("HCAL") << "HcalHardcodeCalibrations::produceTPParameters-> ...";
0849 
0850   auto result = std::make_unique<HcalTPParameters>();
0851   dbHardcode.makeHardcodeTPParameters(*result);
0852   return result;
0853 }
0854 
0855 void HcalHardcodeCalibrations::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0856   edm::ParameterSetDescription desc;
0857   desc.add<double>("iLumi", -1.);
0858   desc.add<bool>("HBRecalibration", false);
0859   desc.add<double>("HBreCalibCutoff", 20.);
0860   desc.add<edm::FileInPath>("HBmeanenergies", edm::FileInPath("CalibCalorimetry/HcalPlugins/data/meanenergiesHB.txt"));
0861   desc.add<bool>("HERecalibration", false);
0862   desc.add<double>("HEreCalibCutoff", 20.);
0863   desc.add<edm::FileInPath>("HEmeanenergies", edm::FileInPath("CalibCalorimetry/HcalPlugins/data/meanenergiesHE.txt"));
0864   desc.add<bool>("HFRecalibration", false);
0865   desc.add<bool>("GainWidthsForTrigPrims", false);
0866   desc.add<bool>("useHBUpgrade", false);
0867   desc.add<bool>("useHEUpgrade", false);
0868   desc.add<bool>("useHFUpgrade", false);
0869   desc.add<bool>("useHOUpgrade", true);
0870   desc.add<bool>("testHFQIE10", false);
0871   desc.add<bool>("testHEPlan1", false);
0872   desc.add<bool>("killHE", false);
0873   desc.add<bool>("useLayer0Weight", false);
0874   desc.add<bool>("useIeta18depth1", true);
0875   desc.addUntracked<std::vector<std::string>>("toGet", std::vector<std::string>());
0876   desc.addUntracked<bool>("fromDDD", false);
0877 
0878   edm::ParameterSetDescription desc_hb;
0879   desc_hb.add<std::vector<double>>("gain", std::vector<double>({0.19}));
0880   desc_hb.add<std::vector<double>>("gainWidth", std::vector<double>({0.0}));
0881   desc_hb.add<double>("pedestal", 3.0);
0882   desc_hb.add<double>("pedestalWidth", 0.55);
0883   desc_hb.add<int>("zsThreshold", 8);
0884   desc_hb.add<std::vector<double>>("qieOffset", std::vector<double>({-0.49, 1.8, 7.2, 37.9}));
0885   desc_hb.add<std::vector<double>>("qieSlope", std::vector<double>({0.912, 0.917, 0.922, 0.923}));
0886   desc_hb.add<int>("qieType", 0);
0887   desc_hb.add<int>("mcShape", 125);
0888   desc_hb.add<int>("recoShape", 105);
0889   desc_hb.add<double>("photoelectronsToAnalog", 0.0);
0890   desc_hb.add<std::vector<double>>("darkCurrent", std::vector<double>({0.0}));
0891   desc_hb.add<std::vector<double>>("noiseCorrelation", std::vector<double>({0.0}));
0892   desc_hb.add<bool>("doRadiationDamage", false);
0893   desc.add<edm::ParameterSetDescription>("hb", desc_hb);
0894 
0895   edm::ParameterSetDescription desc_hbRaddam;
0896   desc_hbRaddam.add<double>("temperatureBase", 20.0);
0897   desc_hbRaddam.add<double>("temperatureNew", -5.0);
0898   desc_hbRaddam.add<double>("intlumiOffset", 150);
0899   desc_hbRaddam.add<double>("depVsTemp", 0.0631);
0900   desc_hbRaddam.add<double>("intlumiToNeutrons", 3.67e8);
0901   desc_hbRaddam.add<std::vector<double>>("depVsNeutrons", {5.69e-11, 7.90e-11});
0902 
0903   edm::ParameterSetDescription desc_hbUpgrade;
0904   desc_hbUpgrade.add<std::vector<double>>("gain", std::vector<double>({0.00111111111111}));
0905   desc_hbUpgrade.add<std::vector<double>>("gainWidth", std::vector<double>({0}));
0906   desc_hbUpgrade.add<double>("pedestal", 18.0);
0907   desc_hbUpgrade.add<double>("pedestalWidth", 5.0);
0908   desc_hbUpgrade.add<int>("zsThreshold", 3);
0909   desc_hbUpgrade.add<std::vector<double>>("qieOffset", std::vector<double>({0.0, 0.0, 0.0, 0.0}));
0910   desc_hbUpgrade.add<std::vector<double>>("qieSlope", std::vector<double>({0.333, 0.333, 0.333, 0.333}));
0911   desc_hbUpgrade.add<int>("qieType", 2);
0912   desc_hbUpgrade.add<int>("mcShape", 206);
0913   desc_hbUpgrade.add<int>("recoShape", 206);
0914   desc_hbUpgrade.add<double>("photoelectronsToAnalog", 57.5);
0915   desc_hbUpgrade.add<std::vector<double>>("darkCurrent", std::vector<double>({0.055}));
0916   desc_hbUpgrade.add<std::vector<double>>("noiseCorrelation", std::vector<double>({0.26}));
0917   desc_hbUpgrade.add<bool>("doRadiationDamage", true);
0918   desc_hbUpgrade.add<edm::ParameterSetDescription>("radiationDamage", desc_hbRaddam);
0919   desc.add<edm::ParameterSetDescription>("hbUpgrade", desc_hbUpgrade);
0920 
0921   edm::ParameterSetDescription desc_he;
0922   desc_he.add<std::vector<double>>("gain", std::vector<double>({0.23}));
0923   desc_he.add<std::vector<double>>("gainWidth", std::vector<double>({0}));
0924   desc_he.add<double>("pedestal", 3.0);
0925   desc_he.add<double>("pedestalWidth", 0.79);
0926   desc_he.add<int>("zsThreshold", 9);
0927   desc_he.add<std::vector<double>>("qieOffset", std::vector<double>({-0.38, 2.0, 7.6, 39.6}));
0928   desc_he.add<std::vector<double>>("qieSlope", std::vector<double>({0.912, 0.916, 0.92, 0.922}));
0929   desc_he.add<int>("qieType", 0);
0930   desc_he.add<int>("mcShape", 125);
0931   desc_he.add<int>("recoShape", 105);
0932   desc_he.add<double>("photoelectronsToAnalog", 0.0);
0933   desc_he.add<std::vector<double>>("darkCurrent", std::vector<double>({0.0}));
0934   desc_he.add<std::vector<double>>("noiseCorrelation", std::vector<double>({0.0}));
0935   desc_he.add<bool>("doRadiationDamage", false);
0936   desc.add<edm::ParameterSetDescription>("he", desc_he);
0937 
0938   edm::ParameterSetDescription desc_heRaddam;
0939   desc_heRaddam.add<double>("temperatureBase", 20.0);
0940   desc_heRaddam.add<double>("temperatureNew", 5.0);
0941   desc_heRaddam.add<double>("intlumiOffset", 75);
0942   desc_heRaddam.add<double>("depVsTemp", 0.0631);
0943   desc_heRaddam.add<double>("intlumiToNeutrons", 2.92e8);
0944   desc_heRaddam.add<std::vector<double>>("depVsNeutrons", {5.69e-11, 7.90e-11});
0945 
0946   edm::ParameterSetDescription desc_heUpgrade;
0947   desc_heUpgrade.add<std::vector<double>>("gain", std::vector<double>({0.00111111111111}));
0948   desc_heUpgrade.add<std::vector<double>>("gainWidth", std::vector<double>({0}));
0949   desc_heUpgrade.add<double>("pedestal", 18.0);
0950   desc_heUpgrade.add<double>("pedestalWidth", 5.0);
0951   desc_heUpgrade.add<int>("zsThreshold", 3);
0952   desc_heUpgrade.add<std::vector<double>>("qieOffset", std::vector<double>({0.0, 0.0, 0.0, 0.0}));
0953   desc_heUpgrade.add<std::vector<double>>("qieSlope", std::vector<double>({0.333, 0.333, 0.333, 0.333}));
0954   desc_heUpgrade.add<int>("qieType", 2);
0955   desc_heUpgrade.add<int>("mcShape", 206);
0956   desc_heUpgrade.add<int>("recoShape", 206);
0957   desc_heUpgrade.add<double>("photoelectronsToAnalog", 57.5);
0958   desc_heUpgrade.add<std::vector<double>>("darkCurrent", std::vector<double>({0.055}));
0959   desc_heUpgrade.add<std::vector<double>>("noiseCorrelation", std::vector<double>({0.26}));
0960   desc_heUpgrade.add<bool>("doRadiationDamage", true);
0961   desc_heUpgrade.add<edm::ParameterSetDescription>("radiationDamage", desc_heRaddam);
0962   desc.add<edm::ParameterSetDescription>("heUpgrade", desc_heUpgrade);
0963 
0964   edm::ParameterSetDescription desc_hf;
0965   desc_hf.add<std::vector<double>>("gain", std::vector<double>({0.14, 0.135}));
0966   desc_hf.add<std::vector<double>>("gainWidth", std::vector<double>({0.0, 0.0}));
0967   desc_hf.add<double>("pedestal", 3.0);
0968   desc_hf.add<double>("pedestalWidth", 0.84);
0969   desc_hf.add<int>("zsThreshold", -9999);
0970   desc_hf.add<std::vector<double>>("qieOffset", std::vector<double>({-0.87, 1.4, 7.8, -29.6}));
0971   desc_hf.add<std::vector<double>>("qieSlope", std::vector<double>({0.359, 0.358, 0.36, 0.367}));
0972   desc_hf.add<int>("qieType", 0);
0973   desc_hf.add<int>("mcShape", 301);
0974   desc_hf.add<int>("recoShape", 301);
0975   desc_hf.add<double>("photoelectronsToAnalog", 0.0);
0976   desc_hf.add<std::vector<double>>("darkCurrent", std::vector<double>({0.0}));
0977   desc_hf.add<std::vector<double>>("noiseCorrelation", std::vector<double>({0.0}));
0978   desc_hf.add<bool>("doRadiationDamage", false);
0979   desc.add<edm::ParameterSetDescription>("hf", desc_hf);
0980 
0981   edm::ParameterSetDescription desc_hfUpgrade;
0982   desc_hfUpgrade.add<std::vector<double>>("gain", std::vector<double>({0.14, 0.135}));
0983   desc_hfUpgrade.add<std::vector<double>>("gainWidth", std::vector<double>({0.0, 0.0}));
0984   desc_hfUpgrade.add<double>("pedestal", 13.33);
0985   desc_hfUpgrade.add<double>("pedestalWidth", 3.33);
0986   desc_hfUpgrade.add<int>("zsThreshold", -9999);
0987   desc_hfUpgrade.add<std::vector<double>>("qieOffset", std::vector<double>({0.0697, -0.7405, 12.38, -671.9}));
0988   desc_hfUpgrade.add<std::vector<double>>("qieSlope", std::vector<double>({0.297, 0.298, 0.298, 0.313}));
0989   desc_hfUpgrade.add<int>("qieType", 1);
0990   desc_hfUpgrade.add<int>("mcShape", 301);
0991   desc_hfUpgrade.add<int>("recoShape", 301);
0992   desc_hfUpgrade.add<double>("photoelectronsToAnalog", 0.0);
0993   desc_hfUpgrade.add<std::vector<double>>("darkCurrent", std::vector<double>({0.0}));
0994   desc_hfUpgrade.add<std::vector<double>>("noiseCorrelation", std::vector<double>({0.0}));
0995   desc_hfUpgrade.add<bool>("doRadiationDamage", false);
0996   desc.add<edm::ParameterSetDescription>("hfUpgrade", desc_hfUpgrade);
0997 
0998   edm::ParameterSetDescription desc_hfrecal;
0999   desc_hfrecal.add<std::vector<double>>("HFdepthOneParameterA", std::vector<double>());
1000   desc_hfrecal.add<std::vector<double>>("HFdepthOneParameterB", std::vector<double>());
1001   desc_hfrecal.add<std::vector<double>>("HFdepthTwoParameterA", std::vector<double>());
1002   desc_hfrecal.add<std::vector<double>>("HFdepthTwoParameterB", std::vector<double>());
1003   desc.add<edm::ParameterSetDescription>("HFRecalParameterBlock", desc_hfrecal);
1004 
1005   edm::ParameterSetDescription desc_ho;
1006   desc_ho.add<std::vector<double>>("gain", std::vector<double>({0.006, 0.0087}));
1007   desc_ho.add<std::vector<double>>("gainWidth", std::vector<double>({0.0, 0.0}));
1008   desc_ho.add<double>("pedestal", 11.0);
1009   desc_ho.add<double>("pedestalWidth", 0.57);
1010   desc_ho.add<int>("zsThreshold", 24);
1011   desc_ho.add<std::vector<double>>("qieOffset", std::vector<double>({-0.44, 1.4, 7.1, 38.5}));
1012   desc_ho.add<std::vector<double>>("qieSlope", std::vector<double>({0.907, 0.915, 0.92, 0.921}));
1013   desc_ho.add<int>("qieType", 0);
1014   desc_ho.add<int>("mcShape", 201);
1015   desc_ho.add<int>("recoShape", 201);
1016   desc_ho.add<double>("photoelectronsToAnalog", 4.0);
1017   desc_ho.add<std::vector<double>>("darkCurrent", std::vector<double>({0.0}));
1018   desc_ho.add<std::vector<double>>("noiseCorrelation", std::vector<double>({0.0}));
1019   desc_ho.add<bool>("doRadiationDamage", false);
1020   desc.add<edm::ParameterSetDescription>("ho", desc_ho);
1021 
1022   edm::ParameterSetDescription validator_sipm;
1023   validator_sipm.add<int>("pixels", 1);
1024   validator_sipm.add<double>("crosstalk", 0);
1025   validator_sipm.add<double>("nonlin1", 1);
1026   validator_sipm.add<double>("nonlin2", 0);
1027   validator_sipm.add<double>("nonlin3", 0);
1028   std::vector<edm::ParameterSet> default_sipm(1);
1029   desc.addVPSet("SiPMCharacteristics", validator_sipm, default_sipm);
1030 
1031   descriptions.addDefault(desc);
1032 }