File indexing completed on 2025-05-11 22:51:51
0001
0002
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
0029
0030
0031
0032
0033 using namespace cms;
0034
0035 namespace {
0036
0037 const std::vector<HcalGenericDetId>& allCells(const HcalTopology& hcaltopology,
0038 const ZdcTopology& zdctopology,
0039 bool killHE = false) {
0040 static std::vector<HcalGenericDetId> result;
0041 int maxDepth = hcaltopology.maxDepth();
0042
0043 #ifdef EDM_ML_DEBUG
0044 edm::LogVerbatim("HcalCalib") << std::endl << "HcalHardcodeCalibrations: maxDepth = " << maxDepth;
0045 #endif
0046
0047 if (result.empty()) {
0048 for (int eta = -HcalDetId::kHcalEtaMask2; eta <= (int)(HcalDetId::kHcalEtaMask2); eta++) {
0049 for (unsigned int phi = 0; phi <= HcalDetId::kHcalPhiMask2; phi++) {
0050 for (int depth = 1; depth <= maxDepth; depth++) {
0051 for (int det = 1; det <= HcalForward; det++) {
0052 HcalDetId cell((HcalSubdetector)det, eta, phi, depth);
0053 if (killHE && HcalEndcap == cell.subdetId())
0054 continue;
0055 if (hcaltopology.valid(cell)) {
0056 result.push_back(cell);
0057 #ifdef EDM_ML_DEBUG
0058 edm::LogVerbatim("HcalCalib") << " HcalHardcodedCalibrations: det|eta|phi|depth = " << det << "|" << eta
0059 << "|" << phi << "|" << depth;
0060 #endif
0061 }
0062 }
0063 }
0064 }
0065 }
0066 HcalZDCDetId zcell;
0067 HcalZDCDetId::Section section = HcalZDCDetId::EM;
0068 for (int depth = 1; depth < 6; depth++) {
0069 zcell = HcalZDCDetId(section, true, depth);
0070 if (zdctopology.valid(zcell)) {
0071 result.push_back(zcell);
0072 #ifdef EDM_ML_DEBUG
0073 edm::LogVerbatim("HcalCalib") << " ZDC cell : " << zcell;
0074 #endif
0075 }
0076 zcell = HcalZDCDetId(section, false, depth);
0077 if (zdctopology.valid(zcell)) {
0078 result.push_back(zcell);
0079 #ifdef EDM_ML_DEBUG
0080 edm::LogVerbatim("HcalCalib") << " ZDC cell : " << zcell;
0081 #endif
0082 }
0083 }
0084 section = HcalZDCDetId::HAD;
0085 for (int depth = 1; depth < 5; depth++) {
0086 zcell = HcalZDCDetId(section, true, depth);
0087 if (zdctopology.valid(zcell)) {
0088 result.push_back(zcell);
0089 #ifdef EDM_ML_DEBUG
0090 edm::LogVerbatim("HcalCalib") << " ZDC cell : " << zcell;
0091 #endif
0092 }
0093 zcell = HcalZDCDetId(section, false, depth);
0094 if (zdctopology.valid(zcell)) {
0095 result.push_back(zcell);
0096 #ifdef EDM_ML_DEBUG
0097 edm::LogVerbatim("HcalCalib") << " ZDC cell : " << zcell;
0098 #endif
0099 }
0100 }
0101 section = HcalZDCDetId::LUM;
0102 for (int depth = 1; depth < 3; depth++) {
0103 zcell = HcalZDCDetId(section, true, depth);
0104 if (zdctopology.valid(zcell)) {
0105 result.push_back(zcell);
0106 #ifdef EDM_ML_DEBUG
0107 edm::LogVerbatim("HcalCalib") << " ZDC cell : " << zcell;
0108 #endif
0109 }
0110 zcell = HcalZDCDetId(section, false, depth);
0111 if (zdctopology.valid(zcell)) {
0112 result.push_back(zcell);
0113 #ifdef EDM_ML_DEBUG
0114 edm::LogVerbatim("HcalCalib") << " ZDC cell : " << zcell;
0115 #endif
0116 }
0117 }
0118 section = HcalZDCDetId::RPD;
0119 for (int depth = 1; depth < 17; depth++) {
0120 zcell = HcalZDCDetId(section, true, depth);
0121 if (zdctopology.valid(zcell)) {
0122 result.push_back(zcell);
0123 #ifdef EDM_ML_DEBUG
0124 edm::LogVerbatim("HcalCalib") << " ZDC cell : " << zcell;
0125 #endif
0126 }
0127 zcell = HcalZDCDetId(section, false, depth);
0128 if (zdctopology.valid(zcell)) {
0129 result.push_back(zcell);
0130 #ifdef EDM_ML_DEBUG
0131 edm::LogVerbatim("HcalCalib") << " ZDC cell : " << zcell;
0132 #endif
0133 }
0134 }
0135
0136
0137
0138
0139
0140
0141 for (int vers = 0; vers <= HcalTrigTowerDetId::kHcalVersMask; ++vers) {
0142 for (int depth = 0; depth <= HcalTrigTowerDetId::kHcalDepthMask; ++depth) {
0143 for (int eta = -HcalTrigTowerDetId::kHcalEtaMask; eta <= HcalTrigTowerDetId::kHcalEtaMask; eta++) {
0144 for (int phi = 1; phi <= HcalTrigTowerDetId::kHcalPhiMask; phi++) {
0145 HcalTrigTowerDetId cell(eta, phi, depth, vers);
0146 if (hcaltopology.validHT(cell)) {
0147 result.push_back(cell);
0148 #ifdef EDM_ML_DEBUG
0149 edm::LogVerbatim("HcalCalib") << " HcalHardcodedCalibrations: eta|phi|depth|vers = " << eta << "|"
0150 << phi << "|" << depth << "|" << vers;
0151 #endif
0152 }
0153 }
0154 }
0155 }
0156 }
0157 }
0158 return result;
0159 }
0160
0161 }
0162
0163 HcalHardcodeCalibrations::HcalHardcodeCalibrations(const edm::ParameterSet& iConfig)
0164 : hb_recalibration(nullptr),
0165 he_recalibration(nullptr),
0166 hf_recalibration(nullptr),
0167 setHEdsegm(false),
0168 setHBdsegm(false) {
0169 #ifdef EDM_ML_DEBUG
0170 edm::LogVerbatim("HCAL") << "HcalHardcodeCalibrations::HcalHardcodeCalibrations->...";
0171 #endif
0172
0173 if (iConfig.exists("GainWidthsForTrigPrims"))
0174 switchGainWidthsForTrigPrims = iConfig.getParameter<bool>("GainWidthsForTrigPrims");
0175 else
0176 switchGainWidthsForTrigPrims = false;
0177
0178
0179 dbHardcode.setHB(HcalHardcodeParameters(iConfig.getParameter<edm::ParameterSet>("hb")));
0180 dbHardcode.setHE(HcalHardcodeParameters(iConfig.getParameter<edm::ParameterSet>("he")));
0181 dbHardcode.setHF(HcalHardcodeParameters(iConfig.getParameter<edm::ParameterSet>("hf")));
0182 dbHardcode.setHO(HcalHardcodeParameters(iConfig.getParameter<edm::ParameterSet>("ho")));
0183 dbHardcode.setHBUpgrade(HcalHardcodeParameters(iConfig.getParameter<edm::ParameterSet>("hbUpgrade")));
0184 dbHardcode.setHEUpgrade(HcalHardcodeParameters(iConfig.getParameter<edm::ParameterSet>("heUpgrade")));
0185 dbHardcode.setHFUpgrade(HcalHardcodeParameters(iConfig.getParameter<edm::ParameterSet>("hfUpgrade")));
0186 dbHardcode.useHBUpgrade(iConfig.getParameter<bool>("useHBUpgrade"));
0187 dbHardcode.useHEUpgrade(iConfig.getParameter<bool>("useHEUpgrade"));
0188 dbHardcode.useHFUpgrade(iConfig.getParameter<bool>("useHFUpgrade"));
0189 dbHardcode.useHOUpgrade(iConfig.getParameter<bool>("useHOUpgrade"));
0190 dbHardcode.testHFQIE10(iConfig.getParameter<bool>("testHFQIE10"));
0191 dbHardcode.testHEPlan1(iConfig.getParameter<bool>("testHEPlan1"));
0192 dbHardcode.setKillHE(iConfig.getParameter<bool>("killHE"));
0193 dbHardcode.setSiPMCharacteristics(iConfig.getParameter<std::vector<edm::ParameterSet>>("SiPMCharacteristics"));
0194
0195 useLayer0Weight = iConfig.getParameter<bool>("useLayer0Weight");
0196 useIeta18depth1 = iConfig.getParameter<bool>("useIeta18depth1");
0197 testHEPlan1 = iConfig.getParameter<bool>("testHEPlan1");
0198
0199 iLumi = iConfig.getParameter<double>("iLumi");
0200
0201 if (iLumi > 0.0) {
0202 bool hb_recalib = iConfig.getParameter<bool>("HBRecalibration");
0203 bool he_recalib = iConfig.getParameter<bool>("HERecalibration");
0204 bool hf_recalib = iConfig.getParameter<bool>("HFRecalibration");
0205 if (hb_recalib) {
0206 hb_recalibration =
0207 std::make_unique<HBHERecalibration>(iLumi,
0208 iConfig.getParameter<double>("HBreCalibCutoff"),
0209 iConfig.getParameter<edm::FileInPath>("HBmeanenergies").fullPath());
0210 }
0211 if (he_recalib) {
0212 he_recalibration =
0213 std::make_unique<HBHERecalibration>(iLumi,
0214 iConfig.getParameter<double>("HEreCalibCutoff"),
0215 iConfig.getParameter<edm::FileInPath>("HEmeanenergies").fullPath());
0216 }
0217 if (hf_recalib && !iConfig.getParameter<edm::ParameterSet>("HFRecalParameterBlock").empty())
0218 hf_recalibration =
0219 std::make_unique<HFRecalibration>(iConfig.getParameter<edm::ParameterSet>("HFRecalParameterBlock"));
0220
0221 #ifdef EDM_ML_DEBUG
0222 edm::LogVerbatim("HcalCalib") << " HcalHardcodeCalibrations: iLumi = " << iLumi;
0223 #endif
0224 }
0225
0226 std::vector<std::string> toGet = iConfig.getUntrackedParameter<std::vector<std::string>>("toGet");
0227 for (auto& objectName : toGet) {
0228 bool all = objectName == "all";
0229 #ifdef EDM_ML_DEBUG
0230 edm::LogVerbatim("HcalCalib") << "Load parameters for " << objectName;
0231 #endif
0232 if ((objectName == "Pedestals") || all) {
0233 auto c = setWhatProduced(this, &HcalHardcodeCalibrations::producePedestals);
0234 topoTokens_[kPedestals] = c.consumes();
0235 zdcTopoTokens_[kPedestals] = c.consumes();
0236 findingRecord<HcalPedestalsRcd>();
0237 }
0238 if ((objectName == "PedestalWidths") || all) {
0239 auto c = setWhatProduced(this, &HcalHardcodeCalibrations::producePedestalWidths);
0240 topoTokens_[kPedestalWidths] = c.consumes();
0241 zdcTopoTokens_[kPedestalWidths] = c.consumes();
0242 findingRecord<HcalPedestalWidthsRcd>();
0243 }
0244 if ((objectName == "EffectivePedestals") || all) {
0245 auto c = setWhatProduced(this, &HcalHardcodeCalibrations::produceEffectivePedestals, edm::es::Label("effective"));
0246 topoTokens_[kEffectivePedestals] = c.consumes();
0247 zdcTopoTokens_[kEffectivePedestals] = c.consumes();
0248 findingRecord<HcalPedestalsRcd>();
0249 }
0250 if ((objectName == "EffectivePedestalWidths") || all) {
0251 auto c =
0252 setWhatProduced(this, &HcalHardcodeCalibrations::produceEffectivePedestalWidths, edm::es::Label("effective"));
0253 topoTokens_[kEffectivePedestalWidths] = c.consumes();
0254 zdcTopoTokens_[kEffectivePedestalWidths] = c.consumes();
0255 findingRecord<HcalPedestalWidthsRcd>();
0256 }
0257 if ((objectName == "Gains") || all) {
0258 auto c = setWhatProduced(this, &HcalHardcodeCalibrations::produceGains);
0259 topoTokens_[kGains] = c.consumes();
0260 zdcTopoTokens_[kGains] = c.consumes();
0261 findingRecord<HcalGainsRcd>();
0262 }
0263 if ((objectName == "GainWidths") || all) {
0264 auto c = setWhatProduced(this, &HcalHardcodeCalibrations::produceGainWidths);
0265 topoTokens_[kGainWidths] = c.consumes();
0266 zdcTopoTokens_[kGainWidths] = c.consumes();
0267 findingRecord<HcalGainWidthsRcd>();
0268 }
0269 if ((objectName == "PFCuts") || all) {
0270 auto c = setWhatProduced(this, &HcalHardcodeCalibrations::producePFCuts);
0271 topoTokens_[kPFCuts] = c.consumes();
0272 zdcTopoTokens_[kPFCuts] = c.consumes();
0273 findingRecord<HcalPFCutsRcd>();
0274 }
0275 if ((objectName == "QIEData") || all) {
0276 auto c = setWhatProduced(this, &HcalHardcodeCalibrations::produceQIEData);
0277 topoTokens_[kQIEData] = c.consumes();
0278 zdcTopoTokens_[kQIEData] = c.consumes();
0279 findingRecord<HcalQIEDataRcd>();
0280 }
0281 if ((objectName == "QIETypes") || all) {
0282 auto c = setWhatProduced(this, &HcalHardcodeCalibrations::produceQIETypes);
0283 topoTokens_[kQIETypes] = c.consumes();
0284 zdcTopoTokens_[kQIETypes] = c.consumes();
0285 findingRecord<HcalQIETypesRcd>();
0286 }
0287 if ((objectName == "ChannelQuality") || (objectName == "channelQuality") || all) {
0288 auto c = setWhatProduced(this, &HcalHardcodeCalibrations::produceChannelQuality);
0289 topoTokens_[kChannelQuality] = c.consumes();
0290 zdcTopoTokens_[kChannelQuality] = c.consumes();
0291 findingRecord<HcalChannelQualityRcd>();
0292 }
0293 if ((objectName == "ElectronicsMap") || (objectName == "electronicsMap") || all) {
0294 auto c = setWhatProduced(this, &HcalHardcodeCalibrations::produceElectronicsMap);
0295 topoTokens_[kElectronicsMap] = c.consumes();
0296 zdcTopoTokens_[kElectronicsMap] = c.consumes();
0297 findingRecord<HcalElectronicsMapRcd>();
0298 }
0299 if ((objectName == "ZSThresholds") || (objectName == "zsThresholds") || all) {
0300 auto c = setWhatProduced(this, &HcalHardcodeCalibrations::produceZSThresholds);
0301 topoTokens_[kZSThresholds] = c.consumes();
0302 zdcTopoTokens_[kZSThresholds] = c.consumes();
0303 findingRecord<HcalZSThresholdsRcd>();
0304 }
0305 if ((objectName == "RespCorrs") || (objectName == "ResponseCorrection") || all) {
0306 auto c = setWhatProduced(this, &HcalHardcodeCalibrations::produceRespCorrs);
0307 topoTokens_[kRespCorrs] = c.consumes();
0308 zdcTopoTokens_[kRespCorrs] = c.consumes();
0309 if (he_recalibration) {
0310 heDarkeningToken_ = c.consumes(edm::ESInputTag("", "HE"));
0311 }
0312 if (hb_recalibration) {
0313 hbDarkeningToken_ = c.consumes(edm::ESInputTag("", "HB"));
0314 }
0315 findingRecord<HcalRespCorrsRcd>();
0316 }
0317 if ((objectName == "LUTCorrs") || (objectName == "LUTCorrection") || all) {
0318 auto c = setWhatProduced(this, &HcalHardcodeCalibrations::produceLUTCorrs);
0319 topoTokens_[kLUTCorrs] = c.consumes();
0320 zdcTopoTokens_[kLUTCorrs] = c.consumes();
0321 findingRecord<HcalLUTCorrsRcd>();
0322 }
0323 if ((objectName == "PFCorrs") || (objectName == "PFCorrection") || all) {
0324 auto c = setWhatProduced(this, &HcalHardcodeCalibrations::producePFCorrs);
0325 topoTokens_[kPFCorrs] = c.consumes();
0326 zdcTopoTokens_[kPFCorrs] = c.consumes();
0327 findingRecord<HcalPFCorrsRcd>();
0328 }
0329 if ((objectName == "TimeCorrs") || (objectName == "TimeCorrection") || all) {
0330 auto c = setWhatProduced(this, &HcalHardcodeCalibrations::produceTimeCorrs);
0331 topoTokens_[kTimeCorrs] = c.consumes();
0332 zdcTopoTokens_[kTimeCorrs] = c.consumes();
0333 findingRecord<HcalTimeCorrsRcd>();
0334 }
0335 if ((objectName == "L1TriggerObjects") || (objectName == "L1Trigger") || all) {
0336 auto c = setWhatProduced(this, &HcalHardcodeCalibrations::produceL1TriggerObjects);
0337 topoTokens_[kL1TriggerObjects] = c.consumes();
0338 zdcTopoTokens_[kL1TriggerObjects] = c.consumes();
0339 findingRecord<HcalL1TriggerObjectsRcd>();
0340 }
0341 if ((objectName == "ValidationCorrs") || (objectName == "ValidationCorrection") || all) {
0342 auto c = setWhatProduced(this, &HcalHardcodeCalibrations::produceValidationCorrs);
0343 topoTokens_[kValidationCorrs] = c.consumes();
0344 zdcTopoTokens_[kValidationCorrs] = c.consumes();
0345 findingRecord<HcalValidationCorrsRcd>();
0346 }
0347 if ((objectName == "LutMetadata") || (objectName == "lutMetadata") || all) {
0348 auto c = setWhatProduced(this, &HcalHardcodeCalibrations::produceLutMetadata);
0349 topoTokens_[kLutMetadata] = c.consumes();
0350 zdcTopoTokens_[kLutMetadata] = c.consumes();
0351 findingRecord<HcalLutMetadataRcd>();
0352 }
0353 if ((objectName == "DcsValues") || all) {
0354 setWhatProduced(this, &HcalHardcodeCalibrations::produceDcsValues);
0355 findingRecord<HcalDcsRcd>();
0356 }
0357 if ((objectName == "DcsMap") || (objectName == "dcsMap") || all) {
0358 setWhatProduced(this, &HcalHardcodeCalibrations::produceDcsMap);
0359 findingRecord<HcalDcsMapRcd>();
0360 }
0361 if ((objectName == "RecoParams") || all) {
0362 auto c = setWhatProduced(this, &HcalHardcodeCalibrations::produceRecoParams);
0363 topoTokens_[kRecoParams] = c.consumes();
0364 zdcTopoTokens_[kRecoParams] = c.consumes();
0365 findingRecord<HcalRecoParamsRcd>();
0366 }
0367 if ((objectName == "LongRecoParams") || all) {
0368 auto c = setWhatProduced(this, &HcalHardcodeCalibrations::produceLongRecoParams);
0369 topoTokens_[kLongRecoParams] = c.consumes();
0370 zdcTopoTokens_[kLongRecoParams] = c.consumes();
0371 findingRecord<HcalLongRecoParamsRcd>();
0372 }
0373 if ((objectName == "ZDCLowGainFractions") || all) {
0374 auto c = setWhatProduced(this, &HcalHardcodeCalibrations::produceZDCLowGainFractions);
0375 topoTokens_[kZDCLowGainFractions] = c.consumes();
0376 zdcTopoTokens_[kZDCLowGainFractions] = c.consumes();
0377 findingRecord<HcalZDCLowGainFractionsRcd>();
0378 }
0379 if ((objectName == "MCParams") || all) {
0380 auto c = setWhatProduced(this, &HcalHardcodeCalibrations::produceMCParams);
0381 topoTokens_[kMCParams] = c.consumes();
0382 zdcTopoTokens_[kMCParams] = c.consumes();
0383 findingRecord<HcalMCParamsRcd>();
0384 }
0385 if ((objectName == "FlagHFDigiTimeParams") || all) {
0386 auto c = setWhatProduced(this, &HcalHardcodeCalibrations::produceFlagHFDigiTimeParams);
0387 topoTokens_[kFlagHFDigiTimeParams] = c.consumes();
0388 zdcTopoTokens_[kFlagHFDigiTimeParams] = c.consumes();
0389 findingRecord<HcalFlagHFDigiTimeParamsRcd>();
0390 }
0391 if ((objectName == "FrontEndMap") || (objectName == "frontEndMap") || all) {
0392 auto c = setWhatProduced(this, &HcalHardcodeCalibrations::produceFrontEndMap);
0393 topoTokens_[kFrontEndMap] = c.consumes();
0394 zdcTopoTokens_[kFrontEndMap] = c.consumes();
0395 findingRecord<HcalFrontEndMapRcd>();
0396 }
0397 if ((objectName == "SiPMParameters") || all) {
0398 auto c = setWhatProduced(this, &HcalHardcodeCalibrations::produceSiPMParameters);
0399 topoTokens_[kSiPMParameters] = c.consumes();
0400 zdcTopoTokens_[kSiPMParameters] = c.consumes();
0401 findingRecord<HcalSiPMParametersRcd>();
0402 }
0403 if ((objectName == "SiPMCharacteristics") || all) {
0404 setWhatProduced(this, &HcalHardcodeCalibrations::produceSiPMCharacteristics);
0405 findingRecord<HcalSiPMCharacteristicsRcd>();
0406 }
0407 if ((objectName == "TPChannelParameters") || all) {
0408 auto c = setWhatProduced(this, &HcalHardcodeCalibrations::produceTPChannelParameters);
0409 topoTokens_[kTPChannelParameters] = c.consumes();
0410 zdcTopoTokens_[kTPChannelParameters] = c.consumes();
0411 findingRecord<HcalTPChannelParametersRcd>();
0412 }
0413 if ((objectName == "TPParameters") || all) {
0414 setWhatProduced(this, &HcalHardcodeCalibrations::produceTPParameters);
0415 findingRecord<HcalTPParametersRcd>();
0416 }
0417 }
0418 }
0419
0420 HcalHardcodeCalibrations::~HcalHardcodeCalibrations() {}
0421
0422
0423
0424
0425 void HcalHardcodeCalibrations::setIntervalFor(const edm::eventsetup::EventSetupRecordKey& iKey,
0426 const edm::IOVSyncValue& iTime,
0427 edm::ValidityInterval& oInterval) {
0428 std::string record = iKey.name();
0429 #ifdef EDM_ML_DEBUG
0430 edm::LogVerbatim("HCAL") << "HcalHardcodeCalibrations::setIntervalFor-> key: " << record
0431 << " time: " << iTime.eventID() << '/' << iTime.time().value();
0432 #endif
0433 oInterval = edm::ValidityInterval(edm::IOVSyncValue::beginOfTime(), edm::IOVSyncValue::endOfTime());
0434 }
0435
0436 std::unique_ptr<HcalPedestals> HcalHardcodeCalibrations::producePedestals_(
0437 const HcalPedestalsRcd& rec,
0438 const edm::ESGetToken<HcalTopology, HcalRecNumberingRecord>& token,
0439 const edm::ESGetToken<ZdcTopology, HcalRecNumberingRecord>& zdctoken,
0440 bool eff) {
0441 std::string seff = eff ? "Effective" : "";
0442 #ifdef EDM_ML_DEBUG
0443 edm::LogVerbatim("HCAL") << "HcalHardcodeCalibrations::produce" << seff << "Pedestals-> ...";
0444 #endif
0445 auto const& topo = rec.get(token);
0446 auto const& zdcTopo = rec.get(zdctoken);
0447 auto result = std::make_unique<HcalPedestals>(&topo, false);
0448 const std::vector<HcalGenericDetId>& cells = allCells(topo, zdcTopo, dbHardcode.killHE());
0449 for (auto cell : cells) {
0450 HcalPedestal item = dbHardcode.makePedestal(cell, false, eff, &topo, iLumi);
0451 result->addValues(item);
0452 }
0453 return result;
0454 }
0455
0456 std::unique_ptr<HcalPedestalWidths> HcalHardcodeCalibrations::producePedestalWidths_(
0457 const HcalPedestalWidthsRcd& rec,
0458 const edm::ESGetToken<HcalTopology, HcalRecNumberingRecord>& token,
0459 const edm::ESGetToken<ZdcTopology, HcalRecNumberingRecord>& zdctoken,
0460 bool eff) {
0461 std::string seff = eff ? "Effective" : "";
0462 #ifdef EDM_ML_DEBUG
0463 edm::LogVerbatim("HCAL") << "HcalHardcodeCalibrations::produce" << seff << "PedestalWidths-> ...";
0464 #endif
0465 auto const& topo = rec.get(token);
0466 auto const& zdcTopo = rec.get(zdctoken);
0467 auto result = std::make_unique<HcalPedestalWidths>(&topo, false);
0468 const std::vector<HcalGenericDetId>& cells = allCells(topo, zdcTopo, dbHardcode.killHE());
0469 for (auto cell : cells) {
0470 HcalPedestalWidth item = dbHardcode.makePedestalWidth(cell, eff, &topo, iLumi);
0471 result->addValues(item);
0472 }
0473 return result;
0474 }
0475
0476 std::unique_ptr<HcalPedestals> HcalHardcodeCalibrations::producePedestals(const HcalPedestalsRcd& rec) {
0477 return producePedestals_(rec, topoTokens_[kPedestals], zdcTopoTokens_[kPedestals], false);
0478 }
0479
0480 std::unique_ptr<HcalPedestals> HcalHardcodeCalibrations::produceEffectivePedestals(const HcalPedestalsRcd& rec) {
0481 return producePedestals_(rec, topoTokens_[kEffectivePedestals], zdcTopoTokens_[kEffectivePedestals], true);
0482 }
0483
0484 std::unique_ptr<HcalPedestalWidths> HcalHardcodeCalibrations::producePedestalWidths(const HcalPedestalWidthsRcd& rec) {
0485 return producePedestalWidths_(rec, topoTokens_[kPedestalWidths], zdcTopoTokens_[kPedestalWidths], false);
0486 }
0487
0488 std::unique_ptr<HcalPedestalWidths> HcalHardcodeCalibrations::produceEffectivePedestalWidths(
0489 const HcalPedestalWidthsRcd& rec) {
0490 return producePedestalWidths_(
0491 rec, topoTokens_[kEffectivePedestalWidths], zdcTopoTokens_[kEffectivePedestalWidths], true);
0492 }
0493
0494 std::unique_ptr<HcalGains> HcalHardcodeCalibrations::produceGains(const HcalGainsRcd& rec) {
0495 #ifdef EDM_ML_DEBUG
0496 edm::LogVerbatim("HCAL") << "HcalHardcodeCalibrations::produceGains-> ...";
0497 #endif
0498 auto const& topo = rec.get(topoTokens_[kGains]);
0499 auto const& zdcTopo = rec.get(zdcTopoTokens_[kGains]);
0500 auto result = std::make_unique<HcalGains>(&topo);
0501 const std::vector<HcalGenericDetId>& cells = allCells(topo, zdcTopo, dbHardcode.killHE());
0502 for (auto cell : cells) {
0503 HcalGain item = dbHardcode.makeGain(cell);
0504 result->addValues(item);
0505 }
0506 return result;
0507 }
0508
0509 std::unique_ptr<HcalGainWidths> HcalHardcodeCalibrations::produceGainWidths(const HcalGainWidthsRcd& rec) {
0510 #ifdef EDM_ML_DEBUG
0511 edm::LogVerbatim("HCAL") << "HcalHardcodeCalibrations::produceGainWidths-> ...";
0512 #endif
0513 auto const& topo = rec.get(topoTokens_[kGainWidths]);
0514 auto const& zdcTopo = rec.get(zdcTopoTokens_[kGainWidths]);
0515 auto result = std::make_unique<HcalGainWidths>(&topo);
0516 const std::vector<HcalGenericDetId>& cells = allCells(topo, zdcTopo, dbHardcode.killHE());
0517 for (auto cell : cells) {
0518
0519 if (switchGainWidthsForTrigPrims) {
0520 #ifdef EDM_ML_DEBUG
0521 edm::LogVerbatim("HcalCalib") << " HcalGainWidths cell (with TPs) : " << std::hex << cell.rawId() << std::dec
0522 << " " << cell;
0523 #endif
0524 HcalGainWidth item = dbHardcode.makeGainWidth(cell);
0525 result->addValues(item);
0526 } else if (!cell.isHcalTrigTowerDetId()) {
0527 #ifdef EDM_ML_DEBUG
0528 edm::LogVerbatim("HcalCalib") << " HcalGainWidths cell (without TPs) : " << std::hex << cell.rawId() << std::dec
0529 << " " << cell;
0530 #endif
0531 HcalGainWidth item = dbHardcode.makeGainWidth(cell);
0532 result->addValues(item);
0533 }
0534 }
0535 return result;
0536 }
0537
0538 std::unique_ptr<HcalPFCuts> HcalHardcodeCalibrations::producePFCuts(const HcalPFCutsRcd& rec) {
0539 #ifdef EDM_ML_DEBUG
0540 edm::LogVerbatim("HCAL") << "HcalHardcodeCalibrations::producePFCuts-> ...";
0541 #endif
0542 auto const& topo = rec.get(topoTokens_[kPFCuts]);
0543 auto const& zdcTopo = rec.get(zdcTopoTokens_[kPFCuts]);
0544 auto result = std::make_unique<HcalPFCuts>(&topo);
0545 const std::vector<HcalGenericDetId>& cells = allCells(topo, zdcTopo, dbHardcode.killHE());
0546 for (auto cell : cells) {
0547
0548 if (!cell.isHcalTrigTowerDetId()) {
0549 HcalPFCut item = dbHardcode.makePFCut(cell, iLumi, dbHardcode.killHE());
0550 result->addValues(item);
0551 }
0552 }
0553 return result;
0554 }
0555
0556 std::unique_ptr<HcalQIEData> HcalHardcodeCalibrations::produceQIEData(const HcalQIEDataRcd& rcd) {
0557 #ifdef EDM_ML_DEBUG
0558 edm::LogVerbatim("HCAL") << "HcalHardcodeCalibrations::produceQIEData-> ...";
0559 #endif
0560
0561 auto const& topo = rcd.get(topoTokens_[kQIEData]);
0562 auto const& zdcTopo = rcd.get(zdcTopoTokens_[kQIEData]);
0563 auto result = std::make_unique<HcalQIEData>(&topo);
0564 const std::vector<HcalGenericDetId>& cells = allCells(topo, zdcTopo, dbHardcode.killHE());
0565 for (auto cell : cells) {
0566 HcalQIECoder coder = dbHardcode.makeQIECoder(cell);
0567 result->addCoder(coder);
0568 }
0569 return result;
0570 }
0571
0572 std::unique_ptr<HcalQIETypes> HcalHardcodeCalibrations::produceQIETypes(const HcalQIETypesRcd& rcd) {
0573 #ifdef EDM_ML_DEBUG
0574 edm::LogVerbatim("HCAL") << "HcalHardcodeCalibrations::produceQIETypes-> ...";
0575 #endif
0576 auto const& topo = rcd.get(topoTokens_[kQIETypes]);
0577 auto const& zdcTopo = rcd.get(zdcTopoTokens_[kQIETypes]);
0578
0579 auto result = std::make_unique<HcalQIETypes>(&topo);
0580 const std::vector<HcalGenericDetId>& cells = allCells(topo, zdcTopo, dbHardcode.killHE());
0581 for (auto cell : cells) {
0582 HcalQIEType item = dbHardcode.makeQIEType(cell);
0583 result->addValues(item);
0584 }
0585 return result;
0586 }
0587
0588 std::unique_ptr<HcalChannelQuality> HcalHardcodeCalibrations::produceChannelQuality(const HcalChannelQualityRcd& rcd) {
0589 #ifdef EDM_ML_DEBUG
0590 edm::LogVerbatim("HCAL") << "HcalHardcodeCalibrations::produceChannelQuality-> ...";
0591 #endif
0592 auto const& topo = rcd.get(topoTokens_[kChannelQuality]);
0593 auto const& zdcTopo = rcd.get(zdcTopoTokens_[kChannelQuality]);
0594
0595 auto result = std::make_unique<HcalChannelQuality>(&topo);
0596 const std::vector<HcalGenericDetId>& cells = allCells(topo, zdcTopo, dbHardcode.killHE());
0597 for (auto cell : cells) {
0598
0599
0600
0601
0602
0603
0604 uint32_t status = 0;
0605
0606 if (!(cell.isHcalZDCDetId())) {
0607 HcalDetId hid = HcalDetId(cell);
0608 int iphi = hid.iphi();
0609 int ieta = hid.ieta();
0610 int absieta = hid.ietaAbs();
0611 int depth = hid.depth();
0612
0613
0614 bool isHEP17 = (iphi >= 63) && (iphi <= 66) && (ieta > 0);
0615
0616 bool is18d1 = (absieta == 18) && (depth == 1);
0617
0618 if ((!useIeta18depth1 && is18d1) && ((testHEPlan1 && isHEP17) || (!testHEPlan1))) {
0619 status = 0x8002;
0620 }
0621 }
0622
0623 HcalChannelStatus item(cell.rawId(), status);
0624 result->addValues(item);
0625 }
0626
0627 return result;
0628 }
0629
0630 std::unique_ptr<HcalRespCorrs> HcalHardcodeCalibrations::produceRespCorrs(const HcalRespCorrsRcd& rcd) {
0631 #ifdef EDM_ML_DEBUG
0632 edm::LogVerbatim("HCAL") << "HcalHardcodeCalibrations::produceRespCorrs-> ...";
0633 #endif
0634 auto const& topo = rcd.get(topoTokens_[kRespCorrs]);
0635 auto const& zdcTopo = rcd.get(zdcTopoTokens_[kRespCorrs]);
0636
0637
0638 if ((he_recalibration && !setHEdsegm) || (hb_recalibration && !setHBdsegm)) {
0639 std::vector<std::vector<int>> m_segmentation;
0640 int maxEta = topo.lastHBHERing();
0641 m_segmentation.resize(maxEta);
0642 for (int i = 0; i < maxEta; i++) {
0643 topo.getDepthSegmentation(i + 1, m_segmentation[i]);
0644 }
0645 if (he_recalibration && !setHEdsegm) {
0646 he_recalibration->setup(m_segmentation, &rcd.get(heDarkeningToken_));
0647 setHEdsegm = true;
0648 }
0649 if (hb_recalibration && !setHBdsegm) {
0650 hb_recalibration->setup(m_segmentation, &rcd.get(hbDarkeningToken_));
0651 setHBdsegm = true;
0652 }
0653 }
0654
0655 auto result = std::make_unique<HcalRespCorrs>(&topo);
0656 const std::vector<HcalGenericDetId>& cells = allCells(topo, zdcTopo, dbHardcode.killHE());
0657 for (const auto& cell : cells) {
0658 double corr = 1.0;
0659
0660
0661 if (useLayer0Weight &&
0662 ((cell.genericSubdet() == HcalGenericDetId::HcalGenEndcap) ||
0663 (cell.genericSubdet() == HcalGenericDetId::HcalGenBarrel)) &&
0664 (HcalDetId(cell).depth() == 1 &&
0665 dbHardcode.getLayersInDepth(HcalDetId(cell).ietaAbs(), HcalDetId(cell).depth(), &topo) == 1)) {
0666
0667
0668
0669
0670
0671 corr = 0.5 / 1.2;
0672 }
0673
0674 if ((hb_recalibration != nullptr) && (cell.genericSubdet() == HcalGenericDetId::HcalGenBarrel)) {
0675 int depth_ = HcalDetId(cell).depth();
0676 int ieta_ = HcalDetId(cell).ieta();
0677 corr *= hb_recalibration->getCorr(ieta_, depth_);
0678 #ifdef EDM_ML_DEBUG
0679 edm::LogVerbatim("HcalCalib") << "HB ieta, depth = " << ieta_ << ", " << depth_ << " corr = " << corr;
0680 #endif
0681 } else if ((he_recalibration != nullptr) && (cell.genericSubdet() == HcalGenericDetId::HcalGenEndcap)) {
0682 int depth_ = HcalDetId(cell).depth();
0683 int ieta_ = HcalDetId(cell).ieta();
0684 corr *= he_recalibration->getCorr(ieta_, depth_);
0685 #ifdef EDM_ML_DEBUG
0686 edm::LogVerbatim("HcalCalib") << "HE ieta, depth = " << ieta_ << ", " << depth_ << " corr = " << corr;
0687 #endif
0688 } else if ((hf_recalibration != nullptr) && (cell.genericSubdet() == HcalGenericDetId::HcalGenForward)) {
0689 int depth_ = HcalDetId(cell).depth();
0690 int ieta_ = HcalDetId(cell).ieta();
0691 corr = hf_recalibration->getCorr(ieta_, depth_, iLumi);
0692 #ifdef EDM_ML_DEBUG
0693 edm::LogVerbatim("HcalCalib") << "HF ieta, depth = " << ieta_ << ", " << depth_ << " corr = " << corr;
0694 #endif
0695 }
0696
0697 HcalRespCorr item(cell.rawId(), corr);
0698 result->addValues(item);
0699 }
0700 return result;
0701 }
0702
0703 std::unique_ptr<HcalLUTCorrs> HcalHardcodeCalibrations::produceLUTCorrs(const HcalLUTCorrsRcd& rcd) {
0704 #ifdef EDM_ML_DEBUG
0705 edm::LogVerbatim("HCAL") << "HcalHardcodeCalibrations::produceLUTCorrs-> ...";
0706 #endif
0707 auto const& topo = rcd.get(topoTokens_[kLUTCorrs]);
0708 auto const& zdcTopo = rcd.get(zdcTopoTokens_[kLUTCorrs]);
0709
0710 auto result = std::make_unique<HcalLUTCorrs>(&topo);
0711 const std::vector<HcalGenericDetId>& cells = allCells(topo, zdcTopo, dbHardcode.killHE());
0712 for (auto cell : cells) {
0713 HcalLUTCorr item(cell.rawId(), 1.0);
0714 result->addValues(item);
0715 }
0716 return result;
0717 }
0718
0719 std::unique_ptr<HcalPFCorrs> HcalHardcodeCalibrations::producePFCorrs(const HcalPFCorrsRcd& rcd) {
0720 #ifdef EDM_ML_DEBUG
0721 edm::LogVerbatim("HCAL") << "HcalHardcodeCalibrations::producePFCorrs-> ...";
0722 #endif
0723 auto const& topo = rcd.get(topoTokens_[kPFCorrs]);
0724 auto const& zdcTopo = rcd.get(zdcTopoTokens_[kPFCorrs]);
0725
0726 auto result = std::make_unique<HcalPFCorrs>(&topo);
0727 const std::vector<HcalGenericDetId>& cells = allCells(topo, zdcTopo, dbHardcode.killHE());
0728 for (auto cell : cells) {
0729 HcalPFCorr item(cell.rawId(), 1.0);
0730 result->addValues(item);
0731 }
0732 return result;
0733 }
0734
0735 std::unique_ptr<HcalTimeCorrs> HcalHardcodeCalibrations::produceTimeCorrs(const HcalTimeCorrsRcd& rcd) {
0736 #ifdef EDM_ML_DEBUG
0737 edm::LogVerbatim("HCAL") << "HcalHardcodeCalibrations::produceTimeCorrs-> ...";
0738 #endif
0739 auto const& topo = rcd.get(topoTokens_[kTimeCorrs]);
0740 auto const& zdcTopo = rcd.get(zdcTopoTokens_[kTimeCorrs]);
0741
0742 auto result = std::make_unique<HcalTimeCorrs>(&topo);
0743 const std::vector<HcalGenericDetId>& cells = allCells(topo, zdcTopo, dbHardcode.killHE());
0744 for (auto cell : cells) {
0745 HcalTimeCorr item(cell.rawId(), 0.0);
0746 result->addValues(item);
0747 }
0748 return result;
0749 }
0750
0751 std::unique_ptr<HcalZSThresholds> HcalHardcodeCalibrations::produceZSThresholds(const HcalZSThresholdsRcd& rcd) {
0752 #ifdef EDM_ML_DEBUG
0753 edm::LogVerbatim("HCAL") << "HcalHardcodeCalibrations::produceZSThresholds-> ...";
0754 #endif
0755 auto const& topo = rcd.get(topoTokens_[kZSThresholds]);
0756 auto const& zdcTopo = rcd.get(zdcTopoTokens_[kZSThresholds]);
0757
0758 auto result = std::make_unique<HcalZSThresholds>(&topo);
0759 const std::vector<HcalGenericDetId>& cells = allCells(topo, zdcTopo, dbHardcode.killHE());
0760 for (auto cell : cells) {
0761 HcalZSThreshold item = dbHardcode.makeZSThreshold(cell);
0762 result->addValues(item);
0763 }
0764 return result;
0765 }
0766
0767 std::unique_ptr<HcalL1TriggerObjects> HcalHardcodeCalibrations::produceL1TriggerObjects(
0768 const HcalL1TriggerObjectsRcd& rcd) {
0769 #ifdef EDM_ML_DEBUG
0770 edm::LogVerbatim("HCAL") << "HcalHardcodeCalibrations::produceL1TriggerObjects-> ...";
0771 #endif
0772 auto const& topo = rcd.get(topoTokens_[kL1TriggerObjects]);
0773 auto const& zdcTopo = rcd.get(zdcTopoTokens_[kL1TriggerObjects]);
0774
0775 auto result = std::make_unique<HcalL1TriggerObjects>(&topo);
0776 const std::vector<HcalGenericDetId>& cells = allCells(topo, zdcTopo, dbHardcode.killHE());
0777 for (auto cell : cells) {
0778 HcalL1TriggerObject item(cell.rawId(), 0., 1., 0);
0779 result->addValues(item);
0780 }
0781
0782 result->setTagString("hardcoded");
0783 result->setAlgoString("hardcoded");
0784 return result;
0785 }
0786
0787 std::unique_ptr<HcalElectronicsMap> HcalHardcodeCalibrations::produceElectronicsMap(const HcalElectronicsMapRcd& rcd) {
0788 #ifdef EDM_ML_DEBUG
0789 edm::LogVerbatim("HCAL") << "HcalHardcodeCalibrations::produceElectronicsMap-> ...";
0790 #endif
0791 auto const& topo = rcd.get(topoTokens_[kElectronicsMap]);
0792 auto const& zdcTopo = rcd.get(zdcTopoTokens_[kElectronicsMap]);
0793
0794 const std::vector<HcalGenericDetId>& cells = allCells(topo, zdcTopo, dbHardcode.killHE());
0795 return dbHardcode.makeHardcodeMap(cells);
0796 }
0797
0798 std::unique_ptr<HcalValidationCorrs> HcalHardcodeCalibrations::produceValidationCorrs(
0799 const HcalValidationCorrsRcd& rcd) {
0800 #ifdef EDM_ML_DEBUG
0801 edm::LogVerbatim("HCAL") << "HcalHardcodeCalibrations::produceValidationCorrs-> ...";
0802 #endif
0803 auto const& topo = rcd.get(topoTokens_[kValidationCorrs]);
0804 auto const& zdcTopo = rcd.get(zdcTopoTokens_[kValidationCorrs]);
0805
0806 auto result = std::make_unique<HcalValidationCorrs>(&topo);
0807 const std::vector<HcalGenericDetId>& cells = allCells(topo, zdcTopo, dbHardcode.killHE());
0808 for (auto cell : cells) {
0809 HcalValidationCorr item(cell.rawId(), 1.0);
0810 result->addValues(item);
0811 }
0812 return result;
0813 }
0814
0815 std::unique_ptr<HcalLutMetadata> HcalHardcodeCalibrations::produceLutMetadata(const HcalLutMetadataRcd& rcd) {
0816 #ifdef EDM_ML_DEBUG
0817 edm::LogVerbatim("HCAL") << "HcalHardcodeCalibrations::produceLutMetadata-> ...";
0818 #endif
0819 auto const& topo = rcd.get(topoTokens_[kLutMetadata]);
0820 auto const& zdcTopo = rcd.get(zdcTopoTokens_[kLutMetadata]);
0821
0822 auto result = std::make_unique<HcalLutMetadata>(&topo);
0823
0824 result->setRctLsb(0.5);
0825 result->setNominalGain(0.177);
0826
0827 const std::vector<HcalGenericDetId>& cells = allCells(topo, zdcTopo, dbHardcode.killHE());
0828 for (const auto& cell : cells) {
0829 float rcalib = 1.;
0830 int granularity = 1;
0831 int threshold = 0;
0832
0833 if (cell.isHcalTrigTowerDetId()) {
0834 rcalib = 0.;
0835 }
0836
0837 HcalLutMetadatum item(cell.rawId(), rcalib, granularity, threshold);
0838 result->addValues(item);
0839 }
0840
0841 return result;
0842 }
0843
0844 std::unique_ptr<HcalDcsValues> HcalHardcodeCalibrations::produceDcsValues(const HcalDcsRcd& rcd) {
0845 #ifdef EDM_ML_DEBUG
0846 edm::LogVerbatim("HCAL") << "HcalHardcodeCalibrations::produceDcsValues-> ...";
0847 #endif
0848 auto result = std::make_unique<HcalDcsValues>();
0849 return result;
0850 }
0851
0852 std::unique_ptr<HcalDcsMap> HcalHardcodeCalibrations::produceDcsMap(const HcalDcsMapRcd& rcd) {
0853 #ifdef EDM_ML_DEBUG
0854 edm::LogVerbatim("HCAL") << "HcalHardcodeCalibrations::produceDcsMap-> ...";
0855 #endif
0856 return dbHardcode.makeHardcodeDcsMap();
0857 }
0858
0859 std::unique_ptr<HcalRecoParams> HcalHardcodeCalibrations::produceRecoParams(const HcalRecoParamsRcd& rec) {
0860 #ifdef EDM_ML_DEBUG
0861 edm::LogVerbatim("HCAL") << "HcalHardcodeCalibrations::produceRecoParams-> ...";
0862 #endif
0863 auto const& topo = rec.get(topoTokens_[kRecoParams]);
0864 auto const& zdcTopo = rec.get(zdcTopoTokens_[kRecoParams]);
0865
0866 auto result = std::make_unique<HcalRecoParams>(&topo);
0867 const std::vector<HcalGenericDetId>& cells = allCells(topo, zdcTopo, dbHardcode.killHE());
0868 for (auto cell : cells) {
0869 HcalRecoParam item = dbHardcode.makeRecoParam(cell);
0870 result->addValues(item);
0871 }
0872 return result;
0873 }
0874
0875 std::unique_ptr<HcalTimingParams> HcalHardcodeCalibrations::produceTimingParams(const HcalTimingParamsRcd& rec) {
0876 #ifdef EDM_ML_DEBUG
0877 edm::LogVerbatim("HCAL") << "HcalHardcodeCalibrations::produceTimingParams-> ...";
0878 #endif
0879 auto const& topo = rec.get(topoTokens_[kTimingParams]);
0880 auto const& zdcTopo = rec.get(zdcTopoTokens_[kTimingParams]);
0881
0882 auto result = std::make_unique<HcalTimingParams>(&topo);
0883 const std::vector<HcalGenericDetId>& cells = allCells(topo, zdcTopo, dbHardcode.killHE());
0884 for (auto cell : cells) {
0885 HcalTimingParam item = dbHardcode.makeTimingParam(cell);
0886 result->addValues(item);
0887 }
0888 return result;
0889 }
0890
0891 std::unique_ptr<HcalLongRecoParams> HcalHardcodeCalibrations::produceLongRecoParams(const HcalLongRecoParamsRcd& rec) {
0892 #ifdef EDM_ML_DEBUG
0893 edm::LogVerbatim("HCAL") << "HcalHardcodeCalibrations::produceLongRecoParams-> ...";
0894 #endif
0895 auto const& topo = rec.get(topoTokens_[kLongRecoParams]);
0896 auto const& zdcTopo = rec.get(zdcTopoTokens_[kLongRecoParams]);
0897
0898 auto result = std::make_unique<HcalLongRecoParams>(&topo);
0899 const std::vector<HcalGenericDetId>& cells = allCells(topo, zdcTopo, dbHardcode.killHE());
0900 std::vector<unsigned int> mSignal;
0901 mSignal.push_back(4);
0902 mSignal.push_back(5);
0903 mSignal.push_back(6);
0904 std::vector<unsigned int> mNoise;
0905 mNoise.push_back(1);
0906 mNoise.push_back(2);
0907 mNoise.push_back(3);
0908 for (auto cell : cells) {
0909 if (cell.isHcalZDCDetId()) {
0910 HcalLongRecoParam item(cell.rawId(), mSignal, mNoise);
0911 result->addValues(item);
0912 }
0913 }
0914 return result;
0915 }
0916
0917 std::unique_ptr<HcalZDCLowGainFractions> HcalHardcodeCalibrations::produceZDCLowGainFractions(
0918 const HcalZDCLowGainFractionsRcd& rec) {
0919 #ifdef EDM_ML_DEBUG
0920 edm::LogVerbatim("HCAL") << "HcalHardcodeCalibrations::produceZDCLowGainFractions-> ...";
0921 #endif
0922 auto const& topo = rec.get(topoTokens_[kZDCLowGainFractions]);
0923 auto const& zdcTopo = rec.get(zdcTopoTokens_[kZDCLowGainFractions]);
0924
0925 auto result = std::make_unique<HcalZDCLowGainFractions>(&topo);
0926 const std::vector<HcalGenericDetId>& cells = allCells(topo, zdcTopo, dbHardcode.killHE());
0927 for (auto cell : cells) {
0928 HcalZDCLowGainFraction item(cell.rawId(), 0.0);
0929 result->addValues(item);
0930 }
0931 return result;
0932 }
0933
0934 std::unique_ptr<HcalMCParams> HcalHardcodeCalibrations::produceMCParams(const HcalMCParamsRcd& rec) {
0935 #ifdef EDM_ML_DEBUG
0936 edm::LogVerbatim("HCAL") << "HcalHardcodeCalibrations::produceMCParams-> ...";
0937 #endif
0938 auto const& topo = rec.get(topoTokens_[kMCParams]);
0939 auto const& zdcTopo = rec.get(zdcTopoTokens_[kMCParams]);
0940 auto result = std::make_unique<HcalMCParams>(&topo);
0941 const std::vector<HcalGenericDetId>& cells = allCells(topo, zdcTopo, dbHardcode.killHE());
0942 for (auto cell : cells) {
0943 HcalMCParam item = dbHardcode.makeMCParam(cell);
0944 result->addValues(item);
0945 }
0946 return result;
0947 }
0948
0949 std::unique_ptr<HcalFlagHFDigiTimeParams> HcalHardcodeCalibrations::produceFlagHFDigiTimeParams(
0950 const HcalFlagHFDigiTimeParamsRcd& rec) {
0951 #ifdef EDM_ML_DEBUG
0952 edm::LogVerbatim("HCAL") << "HcalHardcodeCalibrations::produceFlagHFDigiTimeParams-> ...";
0953 #endif
0954 auto const& topo = rec.get(topoTokens_[kFlagHFDigiTimeParams]);
0955 auto const& zdcTopo = rec.get(zdcTopoTokens_[kFlagHFDigiTimeParams]);
0956
0957 auto result = std::make_unique<HcalFlagHFDigiTimeParams>(&topo);
0958 const std::vector<HcalGenericDetId>& cells = allCells(topo, zdcTopo, dbHardcode.killHE());
0959
0960 std::vector<double> coef;
0961 coef.push_back(0.93);
0962 coef.push_back(-0.38275);
0963 coef.push_back(-0.012667);
0964
0965 for (auto cell : cells) {
0966 HcalFlagHFDigiTimeParam item(cell.rawId(),
0967 1,
0968 3,
0969 2,
0970 40.,
0971 coef
0972 );
0973 result->addValues(item);
0974 }
0975 return result;
0976 }
0977
0978 std::unique_ptr<HcalFrontEndMap> HcalHardcodeCalibrations::produceFrontEndMap(const HcalFrontEndMapRcd& rec) {
0979 #ifdef EDM_ML_DEBUG
0980 edm::LogVerbatim("HCAL") << "HcalHardcodeCalibrations::produceFrontEndMap-> ...";
0981 #endif
0982 auto const& topo = rec.get(topoTokens_[kFrontEndMap]);
0983 auto const& zdcTopo = rec.get(zdcTopoTokens_[kFrontEndMap]);
0984
0985 const std::vector<HcalGenericDetId>& cells = allCells(topo, zdcTopo, dbHardcode.killHE());
0986
0987 return dbHardcode.makeHardcodeFrontEndMap(cells);
0988 }
0989
0990 std::unique_ptr<HcalSiPMParameters> HcalHardcodeCalibrations::produceSiPMParameters(const HcalSiPMParametersRcd& rec) {
0991 #ifdef EDM_ML_DEBUG
0992 edm::LogVerbatim("HCAL") << "HcalHardcodeCalibrations::produceSiPMParameters-> ...";
0993 #endif
0994 auto const& topo = rec.get(topoTokens_[kSiPMParameters]);
0995 auto const& zdcTopo = rec.get(zdcTopoTokens_[kSiPMParameters]);
0996
0997 auto result = std::make_unique<HcalSiPMParameters>(&topo);
0998 const std::vector<HcalGenericDetId>& cells = allCells(topo, zdcTopo, dbHardcode.killHE());
0999 for (auto cell : cells) {
1000 HcalSiPMParameter item = dbHardcode.makeHardcodeSiPMParameter(cell, &topo, iLumi);
1001 result->addValues(item);
1002 }
1003 return result;
1004 }
1005
1006 std::unique_ptr<HcalSiPMCharacteristics> HcalHardcodeCalibrations::produceSiPMCharacteristics(
1007 const HcalSiPMCharacteristicsRcd& rcd) {
1008 #ifdef EDM_ML_DEBUG
1009 edm::LogVerbatim("HCAL") << "HcalHardcodeCalibrations::produceSiPMCharacteristics-> ...";
1010 #endif
1011 return dbHardcode.makeHardcodeSiPMCharacteristics();
1012 }
1013
1014 std::unique_ptr<HcalTPChannelParameters> HcalHardcodeCalibrations::produceTPChannelParameters(
1015 const HcalTPChannelParametersRcd& rec) {
1016 #ifdef EDM_ML_DEBUG
1017 edm::LogVerbatim("HCAL") << "HcalHardcodeCalibrations::produceTPChannelParameters-> ...";
1018 #endif
1019 auto const& topo = rec.get(topoTokens_[kTPChannelParameters]);
1020 auto const& zdcTopo = rec.get(zdcTopoTokens_[kTPChannelParameters]);
1021
1022 auto result = std::make_unique<HcalTPChannelParameters>(&topo);
1023 const std::vector<HcalGenericDetId>& cells = allCells(topo, zdcTopo, dbHardcode.killHE());
1024 for (auto cell : cells) {
1025 HcalTPChannelParameter item = dbHardcode.makeHardcodeTPChannelParameter(cell);
1026 result->addValues(item);
1027 }
1028 return result;
1029 }
1030
1031 std::unique_ptr<HcalTPParameters> HcalHardcodeCalibrations::produceTPParameters(const HcalTPParametersRcd& rcd) {
1032 #ifdef EDM_ML_DEBUG
1033 edm::LogVerbatim("HCAL") << "HcalHardcodeCalibrations::produceTPParameters-> ...";
1034 #endif
1035 auto result = std::make_unique<HcalTPParameters>();
1036 dbHardcode.makeHardcodeTPParameters(*result);
1037 return result;
1038 }
1039
1040 void HcalHardcodeCalibrations::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
1041 edm::ParameterSetDescription desc;
1042 desc.add<double>("iLumi", -1.);
1043 desc.add<bool>("HBRecalibration", false);
1044 desc.add<double>("HBreCalibCutoff", 20.);
1045 desc.add<edm::FileInPath>("HBmeanenergies", edm::FileInPath("CalibCalorimetry/HcalPlugins/data/meanenergiesHB.txt"));
1046 desc.add<bool>("HERecalibration", false);
1047 desc.add<double>("HEreCalibCutoff", 20.);
1048 desc.add<edm::FileInPath>("HEmeanenergies", edm::FileInPath("CalibCalorimetry/HcalPlugins/data/meanenergiesHE.txt"));
1049 desc.add<bool>("HFRecalibration", false);
1050 desc.add<bool>("GainWidthsForTrigPrims", false);
1051 desc.add<bool>("useHBUpgrade", false);
1052 desc.add<bool>("useHEUpgrade", false);
1053 desc.add<bool>("useHFUpgrade", false);
1054 desc.add<bool>("useHOUpgrade", true);
1055 desc.add<bool>("testHFQIE10", false);
1056 desc.add<bool>("testHEPlan1", false);
1057 desc.add<bool>("killHE", false);
1058 desc.add<bool>("useLayer0Weight", false);
1059 desc.add<bool>("useIeta18depth1", true);
1060 desc.addUntracked<std::vector<std::string>>("toGet", std::vector<std::string>());
1061 desc.addUntracked<bool>("fromDDD", false);
1062
1063 edm::ParameterSetDescription desc_hb;
1064 desc_hb.add<std::vector<double>>("gain", std::vector<double>({0.19}));
1065 desc_hb.add<std::vector<double>>("gainWidth", std::vector<double>({0.0}));
1066 desc_hb.add<double>("pedestal", 3.0);
1067 desc_hb.add<double>("pedestalWidth", 0.55);
1068 desc_hb.add<int>("zsThreshold", 8);
1069 desc_hb.add<std::vector<double>>("qieOffset", std::vector<double>({-0.49, 1.8, 7.2, 37.9}));
1070 desc_hb.add<std::vector<double>>("qieSlope", std::vector<double>({0.912, 0.917, 0.922, 0.923}));
1071 desc_hb.add<int>("qieType", 0);
1072 desc_hb.add<int>("mcShape", 125);
1073 desc_hb.add<int>("recoShape", 105);
1074 desc_hb.add<double>("photoelectronsToAnalog", 0.0);
1075 desc_hb.add<std::vector<double>>("darkCurrent", std::vector<double>({0.0}));
1076 desc_hb.add<std::vector<double>>("noiseCorrelation", std::vector<double>({0.0}));
1077 desc_hb.add<bool>("doRadiationDamage", false);
1078 desc_hb.add<double>("noiseThreshold", 0.0);
1079 desc_hb.add<double>("seedThreshold", 0.1);
1080 desc.add<edm::ParameterSetDescription>("hb", desc_hb);
1081
1082 edm::ParameterSetDescription desc_hbRaddam;
1083 desc_hbRaddam.add<double>("temperatureBase", 20.0);
1084 desc_hbRaddam.add<double>("temperatureNew", -5.0);
1085 desc_hbRaddam.add<double>("intlumiOffset", 150);
1086 desc_hbRaddam.add<double>("depVsTemp", 0.0631);
1087 desc_hbRaddam.add<double>("intlumiToNeutrons", 3.67e8);
1088 desc_hbRaddam.add<std::vector<double>>("depVsNeutrons", {5.69e-11, 7.90e-11});
1089
1090 edm::ParameterSetDescription desc_hbUpgrade;
1091 desc_hbUpgrade.add<std::vector<double>>("gain", std::vector<double>({0.00111111111111}));
1092 desc_hbUpgrade.add<std::vector<double>>("gainWidth", std::vector<double>({0}));
1093 desc_hbUpgrade.add<double>("pedestal", 18.0);
1094 desc_hbUpgrade.add<double>("pedestalWidth", 5.0);
1095 desc_hbUpgrade.add<int>("zsThreshold", 3);
1096 desc_hbUpgrade.add<std::vector<double>>("qieOffset", std::vector<double>({0.0, 0.0, 0.0, 0.0}));
1097 desc_hbUpgrade.add<std::vector<double>>("qieSlope", std::vector<double>({0.333, 0.333, 0.333, 0.333}));
1098 desc_hbUpgrade.add<int>("qieType", 2);
1099 desc_hbUpgrade.add<int>("mcShape", 206);
1100 desc_hbUpgrade.add<int>("recoShape", 206);
1101 desc_hbUpgrade.add<double>("photoelectronsToAnalog", 57.5);
1102 desc_hbUpgrade.add<std::vector<double>>("darkCurrent", std::vector<double>({0.055}));
1103 desc_hbUpgrade.add<std::vector<double>>("noiseCorrelation", std::vector<double>({0.26}));
1104 desc_hbUpgrade.add<bool>("doRadiationDamage", true);
1105 desc_hbUpgrade.add<edm::ParameterSetDescription>("radiationDamage", desc_hbRaddam);
1106 desc_hbUpgrade.add<double>("noiseThreshold", 0.0);
1107 desc_hbUpgrade.add<double>("seedThreshold", 0.1);
1108 desc.add<edm::ParameterSetDescription>("hbUpgrade", desc_hbUpgrade);
1109
1110 edm::ParameterSetDescription desc_he;
1111 desc_he.add<std::vector<double>>("gain", std::vector<double>({0.23}));
1112 desc_he.add<std::vector<double>>("gainWidth", std::vector<double>({0}));
1113 desc_he.add<double>("pedestal", 3.0);
1114 desc_he.add<double>("pedestalWidth", 0.79);
1115 desc_he.add<int>("zsThreshold", 9);
1116 desc_he.add<std::vector<double>>("qieOffset", std::vector<double>({-0.38, 2.0, 7.6, 39.6}));
1117 desc_he.add<std::vector<double>>("qieSlope", std::vector<double>({0.912, 0.916, 0.92, 0.922}));
1118 desc_he.add<int>("qieType", 0);
1119 desc_he.add<int>("mcShape", 125);
1120 desc_he.add<int>("recoShape", 105);
1121 desc_he.add<double>("photoelectronsToAnalog", 0.0);
1122 desc_he.add<std::vector<double>>("darkCurrent", std::vector<double>({0.0}));
1123 desc_he.add<std::vector<double>>("noiseCorrelation", std::vector<double>({0.0}));
1124 desc_he.add<bool>("doRadiationDamage", false);
1125 desc_he.add<double>("noiseThreshold", 0.0);
1126 desc_he.add<double>("seedThreshold", 0.1);
1127 desc.add<edm::ParameterSetDescription>("he", desc_he);
1128
1129 edm::ParameterSetDescription desc_heRaddam;
1130 desc_heRaddam.add<double>("temperatureBase", 20.0);
1131 desc_heRaddam.add<double>("temperatureNew", 5.0);
1132 desc_heRaddam.add<double>("intlumiOffset", 75);
1133 desc_heRaddam.add<double>("depVsTemp", 0.0631);
1134 desc_heRaddam.add<double>("intlumiToNeutrons", 2.92e8);
1135 desc_heRaddam.add<std::vector<double>>("depVsNeutrons", {5.69e-11, 7.90e-11});
1136
1137 edm::ParameterSetDescription desc_heUpgrade;
1138 desc_heUpgrade.add<std::vector<double>>("gain", std::vector<double>({0.00111111111111}));
1139 desc_heUpgrade.add<std::vector<double>>("gainWidth", std::vector<double>({0}));
1140 desc_heUpgrade.add<double>("pedestal", 18.0);
1141 desc_heUpgrade.add<double>("pedestalWidth", 5.0);
1142 desc_heUpgrade.add<int>("zsThreshold", 3);
1143 desc_heUpgrade.add<std::vector<double>>("qieOffset", std::vector<double>({0.0, 0.0, 0.0, 0.0}));
1144 desc_heUpgrade.add<std::vector<double>>("qieSlope", std::vector<double>({0.333, 0.333, 0.333, 0.333}));
1145 desc_heUpgrade.add<int>("qieType", 2);
1146 desc_heUpgrade.add<int>("mcShape", 206);
1147 desc_heUpgrade.add<int>("recoShape", 206);
1148 desc_heUpgrade.add<double>("photoelectronsToAnalog", 57.5);
1149 desc_heUpgrade.add<std::vector<double>>("darkCurrent", std::vector<double>({0.055}));
1150 desc_heUpgrade.add<std::vector<double>>("noiseCorrelation", std::vector<double>({0.26}));
1151 desc_heUpgrade.add<bool>("doRadiationDamage", true);
1152 desc_heUpgrade.add<edm::ParameterSetDescription>("radiationDamage", desc_heRaddam);
1153 desc_heUpgrade.add<double>("noiseThreshold", 0.0);
1154 desc_heUpgrade.add<double>("seedThreshold", 0.1);
1155 desc.add<edm::ParameterSetDescription>("heUpgrade", desc_heUpgrade);
1156
1157 edm::ParameterSetDescription desc_hf;
1158 desc_hf.add<std::vector<double>>("gain", std::vector<double>({0.14, 0.135}));
1159 desc_hf.add<std::vector<double>>("gainWidth", std::vector<double>({0.0, 0.0}));
1160 desc_hf.add<double>("pedestal", 3.0);
1161 desc_hf.add<double>("pedestalWidth", 0.84);
1162 desc_hf.add<int>("zsThreshold", -9999);
1163 desc_hf.add<std::vector<double>>("qieOffset", std::vector<double>({-0.87, 1.4, 7.8, -29.6}));
1164 desc_hf.add<std::vector<double>>("qieSlope", std::vector<double>({0.359, 0.358, 0.36, 0.367}));
1165 desc_hf.add<int>("qieType", 0);
1166 desc_hf.add<int>("mcShape", 301);
1167 desc_hf.add<int>("recoShape", 301);
1168 desc_hf.add<double>("photoelectronsToAnalog", 0.0);
1169 desc_hf.add<std::vector<double>>("darkCurrent", std::vector<double>({0.0}));
1170 desc_hf.add<std::vector<double>>("noiseCorrelation", std::vector<double>({0.0}));
1171 desc_hf.add<bool>("doRadiationDamage", false);
1172 desc_hf.add<double>("noiseThreshold", 0.0);
1173 desc_hf.add<double>("seedThreshold", 0.1);
1174 desc.add<edm::ParameterSetDescription>("hf", desc_hf);
1175
1176 edm::ParameterSetDescription desc_hfUpgrade;
1177 desc_hfUpgrade.add<std::vector<double>>("gain", std::vector<double>({0.14, 0.135}));
1178 desc_hfUpgrade.add<std::vector<double>>("gainWidth", std::vector<double>({0.0, 0.0}));
1179 desc_hfUpgrade.add<double>("pedestal", 13.33);
1180 desc_hfUpgrade.add<double>("pedestalWidth", 3.33);
1181 desc_hfUpgrade.add<int>("zsThreshold", -9999);
1182 desc_hfUpgrade.add<std::vector<double>>("qieOffset", std::vector<double>({0.0697, -0.7405, 12.38, -671.9}));
1183 desc_hfUpgrade.add<std::vector<double>>("qieSlope", std::vector<double>({0.297, 0.298, 0.298, 0.313}));
1184 desc_hfUpgrade.add<int>("qieType", 1);
1185 desc_hfUpgrade.add<int>("mcShape", 301);
1186 desc_hfUpgrade.add<int>("recoShape", 301);
1187 desc_hfUpgrade.add<double>("photoelectronsToAnalog", 0.0);
1188 desc_hfUpgrade.add<std::vector<double>>("darkCurrent", std::vector<double>({0.0}));
1189 desc_hfUpgrade.add<std::vector<double>>("noiseCorrelation", std::vector<double>({0.0}));
1190 desc_hfUpgrade.add<bool>("doRadiationDamage", false);
1191 desc_hfUpgrade.add<double>("noiseThreshold", 0.0);
1192 desc_hfUpgrade.add<double>("seedThreshold", 0.1);
1193 desc.add<edm::ParameterSetDescription>("hfUpgrade", desc_hfUpgrade);
1194
1195 edm::ParameterSetDescription desc_hfrecal;
1196 desc_hfrecal.add<std::vector<double>>("HFdepthOneParameterA", std::vector<double>());
1197 desc_hfrecal.add<std::vector<double>>("HFdepthOneParameterB", std::vector<double>());
1198 desc_hfrecal.add<std::vector<double>>("HFdepthTwoParameterA", std::vector<double>());
1199 desc_hfrecal.add<std::vector<double>>("HFdepthTwoParameterB", std::vector<double>());
1200 desc.add<edm::ParameterSetDescription>("HFRecalParameterBlock", desc_hfrecal);
1201
1202 edm::ParameterSetDescription desc_ho;
1203 desc_ho.add<std::vector<double>>("gain", std::vector<double>({0.006, 0.0087}));
1204 desc_ho.add<std::vector<double>>("gainWidth", std::vector<double>({0.0, 0.0}));
1205 desc_ho.add<double>("pedestal", 11.0);
1206 desc_ho.add<double>("pedestalWidth", 0.57);
1207 desc_ho.add<int>("zsThreshold", 24);
1208 desc_ho.add<std::vector<double>>("qieOffset", std::vector<double>({-0.44, 1.4, 7.1, 38.5}));
1209 desc_ho.add<std::vector<double>>("qieSlope", std::vector<double>({0.907, 0.915, 0.92, 0.921}));
1210 desc_ho.add<int>("qieType", 0);
1211 desc_ho.add<int>("mcShape", 201);
1212 desc_ho.add<int>("recoShape", 201);
1213 desc_ho.add<double>("photoelectronsToAnalog", 4.0);
1214 desc_ho.add<std::vector<double>>("darkCurrent", std::vector<double>({0.0}));
1215 desc_ho.add<std::vector<double>>("noiseCorrelation", std::vector<double>({0.0}));
1216 desc_ho.add<bool>("doRadiationDamage", false);
1217 desc_ho.add<double>("noiseThreshold", 0.0);
1218 desc_ho.add<double>("seedThreshold", 0.1);
1219 desc.add<edm::ParameterSetDescription>("ho", desc_ho);
1220
1221 edm::ParameterSetDescription validator_sipm;
1222 validator_sipm.add<int>("pixels", 1);
1223 validator_sipm.add<double>("crosstalk", 0);
1224 validator_sipm.add<double>("nonlin1", 1);
1225 validator_sipm.add<double>("nonlin2", 0);
1226 validator_sipm.add<double>("nonlin3", 0);
1227 std::vector<edm::ParameterSet> default_sipm(1);
1228 desc.addVPSet("SiPMCharacteristics", validator_sipm, default_sipm);
1229
1230 descriptions.addDefault(desc);
1231 }