File indexing completed on 2024-09-07 04:34:52
0001
0002
0003
0004
0005 #include <fstream>
0006 #include <iostream>
0007 #include <memory>
0008
0009 #include "TRandom3.h"
0010
0011 #include "CalibCalorimetry/EcalTrivialCondModules/interface/EcalTrivialConditionRetriever.h"
0012 #include "SimG4CMS/Calo/interface/EnergyResolutionVsLumi.h"
0013 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0014 #include "FWCore/Utilities/interface/Exception.h"
0015
0016 #include "DataFormats/EcalDetId/interface/EBDetId.h"
0017 #include "DataFormats/EcalDetId/interface/EEDetId.h"
0018 #include "DataFormats/EcalDetId/interface/ESDetId.h"
0019 #include "DataFormats/EcalDetId/interface/EcalElectronicsId.h"
0020 #include "DataFormats/EcalDetId/interface/EcalTriggerElectronicsId.h"
0021 #include "DataFormats/EcalDetId/interface/EcalSubdetector.h"
0022
0023
0024
0025 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0026 #include "CondTools/Ecal/interface/EcalIntercalibConstantsXMLTranslator.h"
0027 #include "CondTools/Ecal/interface/EcalIntercalibConstantsMCXMLTranslator.h"
0028
0029 using namespace edm;
0030
0031 EcalTrivialConditionRetriever::EcalTrivialConditionRetriever(const edm::ParameterSet& ps) {
0032 std::string dataPath_ =
0033 ps.getUntrackedParameter<std::string>("dataPath", "CalibCalorimetry/EcalTrivialCondModules/data/");
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052 totLumi_ = ps.getUntrackedParameter<double>("TotLumi", 0.0);
0053 instLumi_ = ps.getUntrackedParameter<double>("InstLumi", 0.0);
0054
0055
0056 adcToGeVEBConstant_ = ps.getUntrackedParameter<double>("adcToGeVEBConstant", 0.035);
0057 adcToGeVEEConstant_ = ps.getUntrackedParameter<double>("adcToGeVEEConstant", 0.060);
0058
0059 intercalibConstantMeanMC_ = ps.getUntrackedParameter<double>("intercalibConstantMeanMC", 1.0);
0060 intercalibConstantSigmaMC_ = ps.getUntrackedParameter<double>("intercalibConstantSigmaMC", 0.0);
0061
0062 linCorrMean_ = ps.getUntrackedParameter<double>("linCorrMean", 1.0);
0063 linCorrSigma_ = ps.getUntrackedParameter<double>("linCorrSigma", 0.0);
0064
0065 linearTime1_ = (unsigned long)atoi(ps.getUntrackedParameter<std::string>("linearTime1", "1").c_str());
0066 linearTime2_ = (unsigned long)atoi(ps.getUntrackedParameter<std::string>("linearTime2", "0").c_str());
0067 linearTime3_ = (unsigned long)atoi(ps.getUntrackedParameter<std::string>("linearTime3", "0").c_str());
0068
0069 intercalibConstantMean_ = ps.getUntrackedParameter<double>("intercalibConstantMean", 1.0);
0070 intercalibConstantSigma_ = ps.getUntrackedParameter<double>("intercalibConstantSigma", 0.0);
0071 intercalibErrorMean_ = ps.getUntrackedParameter<double>("IntercalibErrorMean", 0.0);
0072
0073 timeCalibConstantMean_ = ps.getUntrackedParameter<double>("timeCalibConstantMean", 0.0);
0074 timeCalibConstantSigma_ = ps.getUntrackedParameter<double>("timeCalibConstantSigma", 0.0);
0075 timeCalibErrorMean_ = ps.getUntrackedParameter<double>("timeCalibErrorMean", 0.0);
0076
0077 timeOffsetEBConstant_ = ps.getUntrackedParameter<double>("timeOffsetEBConstant", 0.0);
0078 timeOffsetEEConstant_ = ps.getUntrackedParameter<double>("timeOffsetEEConstant", 0.0);
0079
0080 laserAlphaMean_ = ps.getUntrackedParameter<double>("laserAlphaMean", 1.55);
0081 laserAlphaSigma_ = ps.getUntrackedParameter<double>("laserAlphaSigma", 0);
0082
0083 laserAPDPNTime1_ = (unsigned long)atoi(ps.getUntrackedParameter<std::string>("laserAPDPNTime1", "1").c_str());
0084 laserAPDPNTime2_ = (unsigned long)atoi(ps.getUntrackedParameter<std::string>("laserAPDPNTime2", "0").c_str());
0085 laserAPDPNTime3_ = (unsigned long)atoi(ps.getUntrackedParameter<std::string>("laserAPDPNTime3", "0").c_str());
0086
0087 laserAPDPNRefMean_ = ps.getUntrackedParameter<double>("laserAPDPNRefMean", 1.0);
0088 laserAPDPNRefSigma_ = ps.getUntrackedParameter<double>("laserAPDPNRefSigma", 0.0);
0089
0090 laserAPDPNMean_ = ps.getUntrackedParameter<double>("laserAPDPNMean", 1.0);
0091 laserAPDPNSigma_ = ps.getUntrackedParameter<double>("laserAPDPNSigma", 0.0);
0092
0093 pfRecHitThresholdsNSigmas_ = ps.getUntrackedParameter<double>("EcalPFRecHitThresholdNSigmas", 1.0);
0094 pfRecHitThresholdsNSigmasHEta_ = ps.getUntrackedParameter<double>("EcalPFRecHitThresholdNSigmasHEta", 1.0);
0095 pfRecHitThresholdsEB_ = ps.getUntrackedParameter<double>("EcalPFRecHitThresholdEB", 0.0);
0096 pfRecHitThresholdsEE_ = ps.getUntrackedParameter<double>("EcalPFRecHitThresholdEE", 0.0);
0097
0098 localContCorrParameters_ =
0099 ps.getUntrackedParameter<std::vector<double> >("localContCorrParameters", std::vector<double>(0));
0100 crackCorrParameters_ = ps.getUntrackedParameter<std::vector<double> >("crackCorrParameters", std::vector<double>(0));
0101 energyCorrectionParameters_ =
0102 ps.getUntrackedParameter<std::vector<double> >("energyCorrectionParameters", std::vector<double>(0));
0103 energyUncertaintyParameters_ =
0104 ps.getUntrackedParameter<std::vector<double> >("energyUncertaintyParameters", std::vector<double>(0));
0105 energyCorrectionObjectSpecificParameters_ = ps.getUntrackedParameter<std::vector<double> >(
0106 "energyCorrectionObjectSpecificParameters", std::vector<double>(0));
0107
0108 EBpedMeanX12_ = ps.getUntrackedParameter<double>("EBpedMeanX12", 200.);
0109 EBpedRMSX12_ = ps.getUntrackedParameter<double>("EBpedRMSX12", 1.10);
0110 EBpedMeanX6_ = ps.getUntrackedParameter<double>("EBpedMeanX6", 200.);
0111 EBpedRMSX6_ = ps.getUntrackedParameter<double>("EBpedRMSX6", 0.90);
0112 EBpedMeanX1_ = ps.getUntrackedParameter<double>("EBpedMeanX1", 200.);
0113 EBpedRMSX1_ = ps.getUntrackedParameter<double>("EBpedRMSX1", 0.62);
0114
0115 EEpedMeanX12_ = ps.getUntrackedParameter<double>("EEpedMeanX12", 200.);
0116 EEpedRMSX12_ = ps.getUntrackedParameter<double>("EEpedRMSX12", 2.50);
0117 EEpedMeanX6_ = ps.getUntrackedParameter<double>("EEpedMeanX6", 200.);
0118 EEpedRMSX6_ = ps.getUntrackedParameter<double>("EEpedRMSX6", 2.00);
0119 EEpedMeanX1_ = ps.getUntrackedParameter<double>("EEpedMeanX1", 200.);
0120 EEpedRMSX1_ = ps.getUntrackedParameter<double>("EEpedRMSX1", 1.40);
0121
0122 gainRatio12over6_ = ps.getUntrackedParameter<double>("gainRatio12over6", 2.0);
0123 gainRatio6over1_ = ps.getUntrackedParameter<double>("gainRatio6over1", 6.0);
0124
0125 getWeightsFromFile_ = ps.getUntrackedParameter<bool>("getWeightsFromFile", false);
0126
0127 sampleMaskEB_ = ps.getUntrackedParameter<unsigned int>("sampleMaskEB", 1023);
0128 sampleMaskEE_ = ps.getUntrackedParameter<unsigned int>("sampleMaskEB", 1023);
0129
0130 EBtimeCorrAmplitudeBins_ =
0131 ps.getUntrackedParameter<std::vector<double> >("EBtimeCorrAmplitudeBins", std::vector<double>());
0132 EBtimeCorrShiftBins_ = ps.getUntrackedParameter<std::vector<double> >("EBtimeCorrShiftBins", std::vector<double>());
0133 EEtimeCorrAmplitudeBins_ =
0134 ps.getUntrackedParameter<std::vector<double> >("EEtimeCorrAmplitudeBins", std::vector<double>());
0135 EEtimeCorrShiftBins_ = ps.getUntrackedParameter<std::vector<double> >("EEtimeCorrShiftBins", std::vector<double>());
0136
0137 EBG12samplesCorrelation_ =
0138 ps.getUntrackedParameter<std::vector<double> >("EBG12samplesCorrelation", std::vector<double>());
0139 EBG6samplesCorrelation_ =
0140 ps.getUntrackedParameter<std::vector<double> >("EBG6samplesCorrelation", std::vector<double>());
0141 EBG1samplesCorrelation_ =
0142 ps.getUntrackedParameter<std::vector<double> >("EBG1samplesCorrelation", std::vector<double>());
0143 EEG12samplesCorrelation_ =
0144 ps.getUntrackedParameter<std::vector<double> >("EEG12samplesCorrelation", std::vector<double>());
0145 EEG6samplesCorrelation_ =
0146 ps.getUntrackedParameter<std::vector<double> >("EEG6samplesCorrelation", std::vector<double>());
0147 EEG1samplesCorrelation_ =
0148 ps.getUntrackedParameter<std::vector<double> >("EEG1samplesCorrelation", std::vector<double>());
0149
0150 sim_pulse_shape_EB_thresh_ = ps.getParameter<double>("sim_pulse_shape_EB_thresh");
0151 sim_pulse_shape_EE_thresh_ = ps.getParameter<double>("sim_pulse_shape_EE_thresh");
0152 sim_pulse_shape_APD_thresh_ = ps.getParameter<double>("sim_pulse_shape_APD_thresh");
0153
0154 sim_pulse_shape_TI_ = ps.getUntrackedParameter<double>("sim_pulse_shape_TI", 1.0);
0155
0156 nTDCbins_ = 1;
0157
0158 weightsForAsynchronousRunning_ = ps.getUntrackedParameter<bool>("weightsForTB", false);
0159
0160 edm::LogInfo(" EcalTrivialConditionRetriever ");
0161
0162 if (totLumi_ > 0) {
0163 edm::LogInfo(" EcalTrivialConditionRetriever going to create conditions based on the damage due to ")
0164 << totLumi_ << " fb-1 integrated luminosity";
0165 }
0166
0167 if (weightsForAsynchronousRunning_) {
0168 getWeightsFromFile_ = true;
0169
0170 nTDCbins_ = 50;
0171 }
0172
0173 std::string weightType;
0174 std::ostringstream str;
0175
0176 if (!weightsForAsynchronousRunning_)
0177 str << "_CMS.txt";
0178 else
0179 str << "_TB.txt";
0180
0181 weightType = str.str();
0182
0183 amplWeightsFile_ = ps.getUntrackedParameter<std::string>("amplWeightsFile", dataPath_ + "ampWeights" + weightType);
0184 amplWeightsAftFile_ =
0185 ps.getUntrackedParameter<std::string>("amplWeightsAftFile", dataPath_ + "ampWeightsAfterGainSwitch" + weightType);
0186 pedWeightsFile_ = ps.getUntrackedParameter<std::string>("pedWeightsFile", dataPath_ + "pedWeights" + weightType);
0187 pedWeightsAftFile_ =
0188 ps.getUntrackedParameter<std::string>("pedWeightsAftFile", dataPath_ + "pedWeightsAfterGainSwitch" + weightType);
0189 jittWeightsFile_ = ps.getUntrackedParameter<std::string>("jittWeightsFile", dataPath_ + "timeWeights" + weightType);
0190 jittWeightsAftFile_ = ps.getUntrackedParameter<std::string>("jittWeightsAftFile",
0191 dataPath_ + "timeWeightsAfterGainSwitch" + weightType);
0192 chi2MatrixFile_ = ps.getUntrackedParameter<std::string>("chi2MatrixFile", dataPath_ + "chi2Matrix" + weightType);
0193 chi2MatrixAftFile_ =
0194 ps.getUntrackedParameter<std::string>("chi2MatrixAftFile", dataPath_ + "chi2MatrixAfterGainSwitch" + weightType);
0195
0196 amplWeights_.resize(nTDCbins_);
0197 amplWeightsAft_.resize(nTDCbins_);
0198 pedWeights_.resize(nTDCbins_);
0199 pedWeightsAft_.resize(nTDCbins_);
0200 jittWeights_.resize(nTDCbins_);
0201 jittWeightsAft_.resize(nTDCbins_);
0202 chi2Matrix_.resize(nTDCbins_);
0203 chi2MatrixAft_.resize(nTDCbins_);
0204
0205
0206 getWeightsFromConfiguration(ps);
0207
0208 producedEcalPedestals_ = ps.getUntrackedParameter<bool>("producedEcalPedestals", true);
0209 producedEcalWeights_ = ps.getUntrackedParameter<bool>("producedEcalWeights", true);
0210
0211 producedEcalGainRatios_ = ps.getUntrackedParameter<bool>("producedEcalGainRatios", true);
0212 producedEcalADCToGeVConstant_ = ps.getUntrackedParameter<bool>("producedEcalADCToGeVConstant", true);
0213
0214 producedEcalMappingElectronics_ = ps.getUntrackedParameter<bool>("producedEcalMappingElectronics", true);
0215 mappingFile_ = ps.getUntrackedParameter<std::string>("mappingFile", "");
0216
0217 if (producedEcalMappingElectronics_) {
0218 if (!mappingFile_.empty()) {
0219 setWhatProduced(this, &EcalTrivialConditionRetriever::getMappingFromConfiguration);
0220 } else {
0221 setWhatProduced(this, &EcalTrivialConditionRetriever::produceEcalMappingElectronics);
0222 }
0223 findingRecord<EcalMappingElectronicsRcd>();
0224 }
0225
0226 getEBAlignmentFromFile_ = ps.getUntrackedParameter<bool>("getEBAlignmentFromFile", false);
0227 if (getEBAlignmentFromFile_) {
0228 EBAlignmentFile_ = ps.getUntrackedParameter<std::string>("EBAlignmentFile", dataPath_ + "EBAlignment.txt");
0229 }
0230
0231 getEEAlignmentFromFile_ = ps.getUntrackedParameter<bool>("getEEAlignmentFromFile", false);
0232 if (getEEAlignmentFromFile_) {
0233 EEAlignmentFile_ = ps.getUntrackedParameter<std::string>("EEAlignmentFile", dataPath_ + "EEAlignment.txt");
0234 }
0235
0236 getESAlignmentFromFile_ = ps.getUntrackedParameter<bool>("getESAlignmentFromFile", false);
0237 if (getESAlignmentFromFile_)
0238 ESAlignmentFile_ = ps.getUntrackedParameter<std::string>("ESAlignmentFile", dataPath_ + "ESAlignment.txt");
0239
0240 verbose_ = ps.getUntrackedParameter<int>("verbose", 0);
0241
0242
0243
0244 if (producedEcalPedestals_)
0245 setWhatProduced(this, &EcalTrivialConditionRetriever::produceEcalPedestals);
0246
0247 if (producedEcalWeights_) {
0248 setWhatProduced(this, &EcalTrivialConditionRetriever::produceEcalWeightXtalGroups);
0249 setWhatProduced(this, &EcalTrivialConditionRetriever::produceEcalTBWeights);
0250 }
0251
0252 if (producedEcalGainRatios_)
0253 setWhatProduced(this, &EcalTrivialConditionRetriever::produceEcalGainRatios);
0254
0255 if (producedEcalADCToGeVConstant_)
0256 setWhatProduced(this, &EcalTrivialConditionRetriever::produceEcalADCToGeVConstant);
0257
0258
0259 producedEcalTimeOffsetConstant_ = ps.getUntrackedParameter<bool>("producedEcalTimeOffsetConstant", true);
0260
0261 if (producedEcalTimeOffsetConstant_) {
0262 setWhatProduced(this, &EcalTrivialConditionRetriever::produceEcalTimeOffsetConstant);
0263 findingRecord<EcalTimeOffsetConstantRcd>();
0264 }
0265
0266
0267 producedEcalLinearCorrections_ = ps.getUntrackedParameter<bool>("producedEcalLinearCorrections", true);
0268 linearCorrectionsFile_ = ps.getUntrackedParameter<std::string>("linearCorrectionsFile", "");
0269
0270 if (producedEcalLinearCorrections_) {
0271 if (!linearCorrectionsFile_.empty()) {
0272 setWhatProduced(this, &EcalTrivialConditionRetriever::produceEcalLinearCorrections);
0273 } else {
0274 setWhatProduced(this, &EcalTrivialConditionRetriever::produceEcalLinearCorrections);
0275 }
0276 findingRecord<EcalLinearCorrectionsRcd>();
0277 }
0278
0279
0280 producedEcalIntercalibConstants_ = ps.getUntrackedParameter<bool>("producedEcalIntercalibConstants", true);
0281 intercalibConstantsFile_ = ps.getUntrackedParameter<std::string>("intercalibConstantsFile", "");
0282
0283 intercalibConstantsMCFile_ = ps.getUntrackedParameter<std::string>("intercalibConstantsMCFile", "");
0284
0285 if (producedEcalIntercalibConstants_) {
0286 if (!intercalibConstantsFile_.empty()) {
0287 setWhatProduced(this, &EcalTrivialConditionRetriever::getIntercalibConstantsFromConfiguration);
0288 } else {
0289 setWhatProduced(this, &EcalTrivialConditionRetriever::produceEcalIntercalibConstants);
0290 }
0291 findingRecord<EcalIntercalibConstantsRcd>();
0292 }
0293
0294 producedEcalIntercalibConstantsMC_ = ps.getUntrackedParameter<bool>("producedEcalIntercalibConstantsMC", true);
0295
0296 if (producedEcalIntercalibConstantsMC_) {
0297 if (!intercalibConstantsMCFile_.empty()) {
0298 setWhatProduced(this, &EcalTrivialConditionRetriever::getIntercalibConstantsMCFromConfiguration);
0299 } else {
0300 setWhatProduced(this, &EcalTrivialConditionRetriever::produceEcalIntercalibConstantsMC);
0301 }
0302 findingRecord<EcalIntercalibConstantsMCRcd>();
0303 }
0304
0305
0306 producedEcalIntercalibErrors_ = ps.getUntrackedParameter<bool>("producedEcalIntercalibErrors", true);
0307 intercalibErrorsFile_ = ps.getUntrackedParameter<std::string>("intercalibErrorsFile", "");
0308
0309 if (producedEcalIntercalibErrors_) {
0310 if (!intercalibErrorsFile_.empty()) {
0311 setWhatProduced(this, &EcalTrivialConditionRetriever::getIntercalibErrorsFromConfiguration);
0312 } else {
0313 setWhatProduced(this, &EcalTrivialConditionRetriever::produceEcalIntercalibErrors);
0314 }
0315 findingRecord<EcalIntercalibErrorsRcd>();
0316 }
0317
0318
0319 producedEcalTimeCalibConstants_ = ps.getUntrackedParameter<bool>("producedEcalTimeCalibConstants", true);
0320 timeCalibConstantsFile_ = ps.getUntrackedParameter<std::string>("timeCalibConstantsFile", "");
0321
0322 if (producedEcalTimeCalibConstants_) {
0323 if (!timeCalibConstantsFile_.empty()) {
0324 setWhatProduced(this, &EcalTrivialConditionRetriever::getTimeCalibConstantsFromConfiguration);
0325 } else {
0326 setWhatProduced(this, &EcalTrivialConditionRetriever::produceEcalTimeCalibConstants);
0327 }
0328 findingRecord<EcalTimeCalibConstantsRcd>();
0329 }
0330
0331
0332 producedEcalTimeCalibErrors_ = ps.getUntrackedParameter<bool>("producedEcalTimeCalibErrors", true);
0333 timeCalibErrorsFile_ = ps.getUntrackedParameter<std::string>("timeCalibErrorsFile", "");
0334
0335 if (producedEcalTimeCalibErrors_) {
0336 if (!timeCalibErrorsFile_.empty()) {
0337 setWhatProduced(this, &EcalTrivialConditionRetriever::getTimeCalibErrorsFromConfiguration);
0338 } else {
0339 setWhatProduced(this, &EcalTrivialConditionRetriever::produceEcalTimeCalibErrors);
0340 }
0341 findingRecord<EcalTimeCalibErrorsRcd>();
0342 }
0343
0344
0345 getSimComponentShapeFromFile_ = ps.getUntrackedParameter<bool>("getSimComponentShapeFromFile", false);
0346 producedEcalSimComponentShape_ = ps.getUntrackedParameter<bool>("producedEcalSimComponentShape", true);
0347 std::vector<std::string> vComponentShapes;
0348 EBSimComponentShapeFiles_ =
0349 ps.getUntrackedParameter<std::vector<std::string> >("EBSimComponentShapeFiles", vComponentShapes);
0350
0351 if (producedEcalSimComponentShape_) {
0352 setWhatProduced(this, &EcalTrivialConditionRetriever::getEcalSimComponentShapeFromConfiguration);
0353 findingRecord<EcalSimComponentShapeRcd>();
0354 }
0355
0356
0357 getSimPulseShapeFromFile_ = ps.getUntrackedParameter<bool>("getSimPulseShapeFromFile", false);
0358 producedEcalSimPulseShape_ = ps.getUntrackedParameter<bool>("producedEcalSimPulseShape", true);
0359 EBSimPulseShapeFile_ = ps.getUntrackedParameter<std::string>("EBSimPulseShapeFile", "");
0360 EESimPulseShapeFile_ = ps.getUntrackedParameter<std::string>("EESimPulseShapeFile", "");
0361 APDSimPulseShapeFile_ = ps.getUntrackedParameter<std::string>("APDSimPulseShapeFile", "");
0362
0363 if (producedEcalSimPulseShape_) {
0364 setWhatProduced(this, &EcalTrivialConditionRetriever::getEcalSimPulseShapeFromConfiguration);
0365 findingRecord<EcalSimPulseShapeRcd>();
0366 }
0367
0368 producedEcalPFRecHitThresholds_ = ps.getUntrackedParameter<bool>("producedEcalPFRecHitThresholds", false);
0369
0370
0371 pfRecHitFile_ = ps.getUntrackedParameter<std::string>("pFRecHitFile", dataPath_ + "EB_product_TL235.txt");
0372 pfRecHitFileEE_ = ps.getUntrackedParameter<std::string>("pFRecHitFileEE", dataPath_ + "EE_product_TL235.txt");
0373
0374 if (producedEcalPFRecHitThresholds_) {
0375 if (!pfRecHitFile_.empty()) {
0376 setWhatProduced(this, &EcalTrivialConditionRetriever::getPFRecHitThresholdsFromConfiguration);
0377 } else {
0378 setWhatProduced(this, &EcalTrivialConditionRetriever::produceEcalPFRecHitThresholds);
0379 }
0380 findingRecord<EcalPFRecHitThresholdsRcd>();
0381 }
0382
0383
0384 producedEcalClusterLocalContCorrParameters_ =
0385 ps.getUntrackedParameter<bool>("producedEcalClusterLocalContCorrParameters", false);
0386 producedEcalClusterCrackCorrParameters_ =
0387 ps.getUntrackedParameter<bool>("producedEcalClusterCrackCorrParameters", false);
0388 producedEcalClusterEnergyCorrectionParameters_ =
0389 ps.getUntrackedParameter<bool>("producedEcalClusterEnergyCorrectionParameters", false);
0390 producedEcalClusterEnergyUncertaintyParameters_ =
0391 ps.getUntrackedParameter<bool>("producedEcalClusterEnergyUncertaintyParameters", false);
0392 producedEcalClusterEnergyCorrectionObjectSpecificParameters_ =
0393 ps.getUntrackedParameter<bool>("producedEcalClusterEnergyCorrectionObjectSpecificParameters", false);
0394 if (producedEcalClusterLocalContCorrParameters_) {
0395 setWhatProduced(this, &EcalTrivialConditionRetriever::produceEcalClusterLocalContCorrParameters);
0396 findingRecord<EcalClusterLocalContCorrParametersRcd>();
0397 }
0398 if (producedEcalClusterCrackCorrParameters_) {
0399 setWhatProduced(this, &EcalTrivialConditionRetriever::produceEcalClusterCrackCorrParameters);
0400 findingRecord<EcalClusterCrackCorrParametersRcd>();
0401 }
0402 if (producedEcalClusterEnergyCorrectionParameters_) {
0403 setWhatProduced(this, &EcalTrivialConditionRetriever::produceEcalClusterEnergyCorrectionParameters);
0404 findingRecord<EcalClusterEnergyCorrectionParametersRcd>();
0405 }
0406 if (producedEcalClusterEnergyUncertaintyParameters_) {
0407 setWhatProduced(this, &EcalTrivialConditionRetriever::produceEcalClusterEnergyUncertaintyParameters);
0408 findingRecord<EcalClusterEnergyUncertaintyParametersRcd>();
0409 }
0410 if (producedEcalClusterEnergyCorrectionObjectSpecificParameters_) {
0411 setWhatProduced(this, &EcalTrivialConditionRetriever::produceEcalClusterEnergyCorrectionObjectSpecificParameters);
0412 findingRecord<EcalClusterEnergyCorrectionObjectSpecificParametersRcd>();
0413 }
0414
0415
0416 producedEcalLaserCorrection_ = ps.getUntrackedParameter<bool>("producedEcalLaserCorrection", false);
0417 if (producedEcalLaserCorrection_) {
0418
0419 setWhatProduced(this, &EcalTrivialConditionRetriever::produceEcalLaserAlphas);
0420 findingRecord<EcalLaserAlphasRcd>();
0421 getLaserAlphaFromFileEB_ = ps.getUntrackedParameter<bool>("getLaserAlphaFromFileEB", false);
0422 getLaserAlphaFromFileEE_ = ps.getUntrackedParameter<bool>("getLaserAlphaFromFileEE", false);
0423 getLaserAlphaFromTypeEB_ = ps.getUntrackedParameter<bool>("getLaserAlphaFromTypeEB", false);
0424 getLaserAlphaFromTypeEE_ = ps.getUntrackedParameter<bool>("getLaserAlphaFromTypeEE", false);
0425 edm::LogInfo(" getLaserAlphaFromFileEB_ ") << getLaserAlphaFromFileEB_;
0426 edm::LogInfo(" getLaserAlphaFromFileEE_ ") << getLaserAlphaFromFileEE_;
0427 edm::LogInfo(" getLaserAlphaFromTypeEB_ ") << getLaserAlphaFromTypeEB_;
0428 edm::LogInfo(" getLaserAlphaFromTypeEE_ ") << getLaserAlphaFromTypeEE_;
0429 if (getLaserAlphaFromFileEB_) {
0430 EBLaserAlphaFile_ = ps.getUntrackedParameter<std::string>(
0431 "EBLaserAlphaFile", dataPath_ + "EBLaserAlpha.txt");
0432 }
0433 if (getLaserAlphaFromFileEE_) {
0434 EELaserAlphaFile_ = ps.getUntrackedParameter<std::string>(
0435 "EELaserAlphaFile", dataPath_ + "EELaserAlpha.txt");
0436 }
0437 if (getLaserAlphaFromTypeEB_) {
0438 laserAlphaMeanEBR_ = ps.getUntrackedParameter<double>("laserAlphaMeanEBR", 1.55);
0439 laserAlphaMeanEBC_ = ps.getUntrackedParameter<double>("laserAlphaMeanEBC", 1.00);
0440 EBLaserAlphaFile_ = ps.getUntrackedParameter<std::string>(
0441 "EBLaserAlphaFile", dataPath_ + "EBLaserAlpha.txt");
0442 }
0443 if (getLaserAlphaFromTypeEE_) {
0444 laserAlphaMeanEEC_higheta_ = ps.getUntrackedParameter<double>("laserAlphaMeanEEC_higheta",
0445 1.00);
0446 laserAlphaMeanEER_higheta_ = ps.getUntrackedParameter<double>("laserAlphaMeanEER_higheta",
0447 1.16);
0448 laserAlphaMeanEER_ = ps.getUntrackedParameter<double>("laserAlphaMeanEER", 1.16);
0449 laserAlphaMeanEEC_ = ps.getUntrackedParameter<double>("laserAlphaMeanEEC", 1.00);
0450 EELaserAlphaFile_ = ps.getUntrackedParameter<std::string>(
0451 "EELaserAlphaFile",
0452 dataPath_ + "EELaserAlpha.txt");
0453 EELaserAlphaFile2_ = ps.getUntrackedParameter<std::string>(
0454 "EELaserAlphaFile2", dataPath_ + "EELaserAlpha2.txt");
0455 }
0456 setWhatProduced(this, &EcalTrivialConditionRetriever::produceEcalLaserAPDPNRatiosRef);
0457 findingRecord<EcalLaserAPDPNRatiosRefRcd>();
0458 setWhatProduced(this, &EcalTrivialConditionRetriever::produceEcalLaserAPDPNRatios);
0459 findingRecord<EcalLaserAPDPNRatiosRcd>();
0460 }
0461
0462
0463 producedEcalChannelStatus_ = ps.getUntrackedParameter<bool>("producedEcalChannelStatus", true);
0464 channelStatusFile_ = ps.getUntrackedParameter<std::string>("channelStatusFile", "");
0465
0466 if (producedEcalChannelStatus_) {
0467 if (!channelStatusFile_.empty()) {
0468 setWhatProduced(this, &EcalTrivialConditionRetriever::getChannelStatusFromConfiguration);
0469 } else {
0470 setWhatProduced(this, &EcalTrivialConditionRetriever::produceEcalChannelStatus);
0471 }
0472 findingRecord<EcalChannelStatusRcd>();
0473 }
0474
0475 producedEcalDQMChannelStatus_ = ps.getUntrackedParameter<bool>("producedEcalDQMChannelStatus", true);
0476 if (producedEcalDQMChannelStatus_) {
0477 setWhatProduced(this, &EcalTrivialConditionRetriever::produceEcalDQMChannelStatus);
0478 findingRecord<EcalDQMChannelStatusRcd>();
0479 }
0480
0481 producedEcalDCSTowerStatus_ = ps.getUntrackedParameter<bool>("producedEcalDCSTowerStatus", true);
0482 if (producedEcalDCSTowerStatus_) {
0483 setWhatProduced(this, &EcalTrivialConditionRetriever::produceEcalDCSTowerStatus);
0484 findingRecord<EcalDCSTowerStatusRcd>();
0485 }
0486
0487 producedEcalDAQTowerStatus_ = ps.getUntrackedParameter<bool>("producedEcalDAQTowerStatus", true);
0488 if (producedEcalDAQTowerStatus_) {
0489 setWhatProduced(this, &EcalTrivialConditionRetriever::produceEcalDAQTowerStatus);
0490 findingRecord<EcalDAQTowerStatusRcd>();
0491 }
0492
0493 producedEcalDQMTowerStatus_ = ps.getUntrackedParameter<bool>("producedEcalDQMTowerStatus", true);
0494 if (producedEcalDQMTowerStatus_) {
0495 setWhatProduced(this, &EcalTrivialConditionRetriever::produceEcalDQMTowerStatus);
0496 findingRecord<EcalDQMTowerStatusRcd>();
0497 }
0498
0499
0500 producedEcalTrgChannelStatus_ = ps.getUntrackedParameter<bool>("producedEcalTrgChannelStatus", true);
0501 trgChannelStatusFile_ = ps.getUntrackedParameter<std::string>("trgChannelStatusFile", "");
0502
0503 if (producedEcalTrgChannelStatus_) {
0504 if (!trgChannelStatusFile_.empty()) {
0505 setWhatProduced(this, &EcalTrivialConditionRetriever::getTrgChannelStatusFromConfiguration);
0506 } else {
0507 setWhatProduced(this, &EcalTrivialConditionRetriever::produceEcalTrgChannelStatus);
0508 }
0509 findingRecord<EcalTPGCrystalStatusRcd>();
0510 }
0511
0512
0513 producedEcalAlignmentEB_ = ps.getUntrackedParameter<bool>("producedEcalAlignmentEB", true);
0514 if (producedEcalAlignmentEB_) {
0515 setWhatProduced(this, &EcalTrivialConditionRetriever::produceEcalAlignmentEB);
0516 findingRecord<EBAlignmentRcd>();
0517 }
0518 producedEcalAlignmentEE_ = ps.getUntrackedParameter<bool>("producedEcalAlignmentEE", true);
0519 if (producedEcalAlignmentEE_) {
0520 setWhatProduced(this, &EcalTrivialConditionRetriever::produceEcalAlignmentEE);
0521 findingRecord<EEAlignmentRcd>();
0522 }
0523 producedEcalAlignmentES_ = ps.getUntrackedParameter<bool>("producedEcalAlignmentES", true);
0524 if (producedEcalAlignmentES_) {
0525 setWhatProduced(this, &EcalTrivialConditionRetriever::produceEcalAlignmentES);
0526 findingRecord<ESAlignmentRcd>();
0527 }
0528
0529 if (producedEcalPedestals_)
0530 findingRecord<EcalPedestalsRcd>();
0531
0532 if (producedEcalWeights_) {
0533 findingRecord<EcalWeightXtalGroupsRcd>();
0534 findingRecord<EcalTBWeightsRcd>();
0535 }
0536
0537 if (producedEcalGainRatios_)
0538 findingRecord<EcalGainRatiosRcd>();
0539
0540 if (producedEcalADCToGeVConstant_)
0541 findingRecord<EcalADCToGeVConstantRcd>();
0542
0543 producedEcalSampleMask_ = ps.getUntrackedParameter<bool>("producedEcalSampleMask", true);
0544 if (producedEcalSampleMask_) {
0545 setWhatProduced(this, &EcalTrivialConditionRetriever::produceEcalSampleMask);
0546 findingRecord<EcalSampleMaskRcd>();
0547 }
0548 producedEcalTimeBiasCorrections_ = ps.getUntrackedParameter<bool>("producedEcalTimeBiasCorrections", false);
0549 if (producedEcalTimeBiasCorrections_) {
0550 setWhatProduced(this, &EcalTrivialConditionRetriever::produceEcalTimeBiasCorrections);
0551 findingRecord<EcalTimeBiasCorrectionsRcd>();
0552 }
0553 producedEcalSamplesCorrelation_ = ps.getUntrackedParameter<bool>("producedEcalSamplesCorrelation", false);
0554 if (producedEcalSamplesCorrelation_) {
0555 setWhatProduced(this, &EcalTrivialConditionRetriever::produceEcalSamplesCorrelation);
0556 findingRecord<EcalSamplesCorrelationRcd>();
0557 getSamplesCorrelationFromFile_ = ps.getUntrackedParameter<bool>("getSamplesCorrelationFromFile", false);
0558 if (getSamplesCorrelationFromFile_) {
0559 SamplesCorrelationFile_ =
0560 ps.getUntrackedParameter<std::string>("SamplesCorrelationFile", "EcalSamplesCorrelation.txt");
0561 }
0562 }
0563 }
0564
0565 EcalTrivialConditionRetriever::~EcalTrivialConditionRetriever() {}
0566
0567
0568
0569
0570 void EcalTrivialConditionRetriever::setIntervalFor(const edm::eventsetup::EventSetupRecordKey& rk,
0571 const edm::IOVSyncValue& iTime,
0572 edm::ValidityInterval& oValidity) {
0573 if (verbose_ >= 1)
0574 edm::LogInfo("EcalTrivialConditionRetriever::setIntervalFor(): record key = ")
0575 << rk.name() << "\ttime: " << iTime.time().value();
0576
0577 oValidity = edm::ValidityInterval(edm::IOVSyncValue::beginOfTime(), edm::IOVSyncValue::endOfTime());
0578 }
0579
0580
0581 std::unique_ptr<EcalPedestals> EcalTrivialConditionRetriever::produceEcalPedestals(const EcalPedestalsRcd&) {
0582 auto peds = std::make_unique<EcalPedestals>();
0583 EcalPedestals::Item EBitem;
0584 EcalPedestals::Item EEitem;
0585
0586 EBitem.mean_x1 = EBpedMeanX1_;
0587 EBitem.rms_x1 = EBpedRMSX1_;
0588 EBitem.mean_x6 = EBpedMeanX6_;
0589 EBitem.rms_x6 = EBpedRMSX6_;
0590 EBitem.mean_x12 = EBpedMeanX12_;
0591 EBitem.rms_x12 = EBpedRMSX12_;
0592
0593 EEitem.mean_x1 = EEpedMeanX1_;
0594 EEitem.rms_x1 = EEpedRMSX1_;
0595 EEitem.mean_x6 = EEpedMeanX6_;
0596 EEitem.rms_x6 = EEpedRMSX6_;
0597 EEitem.mean_x12 = EEpedMeanX12_;
0598 EEitem.rms_x12 = EEpedRMSX12_;
0599
0600 for (int iEta = -EBDetId::MAX_IETA; iEta <= EBDetId::MAX_IETA; ++iEta) {
0601 if (iEta == 0)
0602 continue;
0603
0604 if (totLumi_ > 0) {
0605 double eta = EBDetId::approxEta(EBDetId(iEta, 1));
0606
0607 EnergyResolutionVsLumi ageing;
0608 ageing.setLumi(totLumi_);
0609 ageing.setInstLumi(instLumi_);
0610 eta = fabs(eta);
0611 double noisefactor = ageing.calcnoiseIncreaseADC(eta);
0612
0613 EBitem.rms_x1 = EBpedRMSX1_ * noisefactor;
0614 EBitem.rms_x6 = EBpedRMSX6_ * noisefactor;
0615 EBitem.rms_x12 = EBpedRMSX12_ * noisefactor;
0616 edm::LogInfo("rms ped at eta:") << eta << " =" << EBitem.rms_x12;
0617 }
0618
0619 for (int iPhi = EBDetId::MIN_IPHI; iPhi <= EBDetId::MAX_IPHI; ++iPhi) {
0620
0621 if (EBDetId::validDetId(iEta, iPhi)) {
0622 EBDetId ebdetid(iEta, iPhi);
0623 peds->insert(std::make_pair(ebdetid.rawId(), EBitem));
0624 }
0625 }
0626 }
0627
0628 for (int iX = EEDetId::IX_MIN; iX <= EEDetId::IX_MAX; ++iX) {
0629 for (int iY = EEDetId::IY_MIN; iY <= EEDetId::IY_MAX; ++iY) {
0630
0631 if (EEDetId::validDetId(iX, iY, 1)) {
0632 EEDetId eedetidpos(iX, iY, 1);
0633 peds->insert(std::make_pair(eedetidpos.rawId(), EEitem));
0634 }
0635 if (EEDetId::validDetId(iX, iY, -1)) {
0636 EEDetId eedetidneg(iX, iY, -1);
0637 peds->insert(std::make_pair(eedetidneg.rawId(), EEitem));
0638 }
0639 }
0640 }
0641
0642
0643 return peds;
0644 }
0645
0646 std::unique_ptr<EcalWeightXtalGroups> EcalTrivialConditionRetriever::produceEcalWeightXtalGroups(
0647 const EcalWeightXtalGroupsRcd&) {
0648 auto xtalGroups = std::make_unique<EcalWeightXtalGroups>();
0649 EcalXtalGroupId defaultGroupId(1);
0650 for (int ieta = -EBDetId::MAX_IETA; ieta <= EBDetId::MAX_IETA; ++ieta) {
0651 if (ieta == 0)
0652 continue;
0653 for (int iphi = EBDetId::MIN_IPHI; iphi <= EBDetId::MAX_IPHI; ++iphi) {
0654
0655 if (EBDetId::validDetId(ieta, iphi)) {
0656 EBDetId ebid(ieta, iphi);
0657
0658 xtalGroups->setValue(ebid.rawId(), defaultGroupId);
0659 }
0660 }
0661 }
0662
0663 for (int iX = EEDetId::IX_MIN; iX <= EEDetId::IX_MAX; ++iX) {
0664 for (int iY = EEDetId::IY_MIN; iY <= EEDetId::IY_MAX; ++iY) {
0665
0666 if (EEDetId::validDetId(iX, iY, 1)) {
0667 EEDetId eedetidpos(iX, iY, 1);
0668 xtalGroups->setValue(eedetidpos.rawId(), defaultGroupId);
0669 }
0670 if (EEDetId::validDetId(iX, iY, -1)) {
0671 EEDetId eedetidneg(iX, iY, -1);
0672 xtalGroups->setValue(eedetidneg.rawId(), defaultGroupId);
0673 }
0674 }
0675 }
0676 return xtalGroups;
0677 }
0678
0679 std::unique_ptr<EcalLinearCorrections> EcalTrivialConditionRetriever::produceEcalLinearCorrections(
0680 const EcalLinearCorrectionsRcd&) {
0681 auto ical = std::make_unique<EcalLinearCorrections>();
0682
0683 for (int ieta = -EBDetId::MAX_IETA; ieta <= EBDetId::MAX_IETA; ++ieta) {
0684 if (ieta == 0)
0685 continue;
0686 for (int iphi = EBDetId::MIN_IPHI; iphi <= EBDetId::MAX_IPHI; ++iphi) {
0687 if (EBDetId::validDetId(ieta, iphi)) {
0688 EBDetId ebid(ieta, iphi);
0689 double r = (double)std::rand() / (double(RAND_MAX) + double(1));
0690
0691 EcalLinearCorrections::Values pairAPDPN;
0692 pairAPDPN.p1 = linCorrMean_ + r * linCorrSigma_;
0693 pairAPDPN.p2 = linCorrMean_ + r * linCorrSigma_;
0694 pairAPDPN.p3 = linCorrMean_ + r * linCorrSigma_;
0695 ical->setValue(ebid, pairAPDPN);
0696 }
0697 }
0698 }
0699
0700 for (int iX = EEDetId::IX_MIN; iX <= EEDetId::IX_MAX; ++iX) {
0701 for (int iY = EEDetId::IY_MIN; iY <= EEDetId::IY_MAX; ++iY) {
0702
0703 if (EEDetId::validDetId(iX, iY, 1)) {
0704 double r = (double)std::rand() / (double(RAND_MAX) + double(1));
0705 EEDetId eedetidpos(iX, iY, 1);
0706
0707 EcalLinearCorrections::Values pairAPDPN;
0708 pairAPDPN.p1 = linCorrMean_ + r * linCorrSigma_;
0709 pairAPDPN.p2 = linCorrMean_ + r * linCorrSigma_;
0710 pairAPDPN.p3 = linCorrMean_ + r * linCorrSigma_;
0711
0712 ical->setValue(eedetidpos, pairAPDPN);
0713 }
0714
0715 if (EEDetId::validDetId(iX, iY, -1)) {
0716 double r1 = (double)std::rand() / (double(RAND_MAX) + double(1));
0717 EEDetId eedetidneg(iX, iY, -1);
0718
0719 EcalLinearCorrections::Values pairAPDPN;
0720 pairAPDPN.p1 = linCorrMean_ + r1 * linCorrSigma_;
0721 pairAPDPN.p2 = linCorrMean_ + r1 * linCorrSigma_;
0722 pairAPDPN.p3 = linCorrMean_ + r1 * linCorrSigma_;
0723
0724 ical->setValue(eedetidneg, pairAPDPN);
0725 }
0726 }
0727 }
0728
0729 EcalLinearCorrections::Times TimeStamp;
0730
0731 for (int i = 0; i < 92; i++) {
0732 TimeStamp.t1 = Timestamp(linearTime1_);
0733 if (linearTime2_ == 0) {
0734 TimeStamp.t2 = Timestamp(edm::Timestamp::endOfTime().value());
0735 } else {
0736 TimeStamp.t2 = Timestamp(linearTime2_);
0737 }
0738 if (linearTime3_ == 0) {
0739 TimeStamp.t3 = Timestamp(edm::Timestamp::endOfTime().value());
0740 } else {
0741 TimeStamp.t3 = Timestamp(linearTime3_);
0742 }
0743
0744 ical->setTime(i, TimeStamp);
0745 }
0746
0747 return ical;
0748 }
0749
0750
0751
0752 std::unique_ptr<EcalPFRecHitThresholds> EcalTrivialConditionRetriever::produceEcalPFRecHitThresholds(
0753 const EcalPFRecHitThresholdsRcd&) {
0754 auto ical = std::make_unique<EcalPFRecHitThresholds>();
0755
0756 for (int ieta = -EBDetId::MAX_IETA; ieta <= EBDetId::MAX_IETA; ++ieta) {
0757 if (ieta == 0)
0758 continue;
0759 for (int iphi = EBDetId::MIN_IPHI; iphi <= EBDetId::MAX_IPHI; ++iphi) {
0760
0761 if (EBDetId::validDetId(ieta, iphi)) {
0762 EBDetId ebid(ieta, iphi);
0763 ical->setValue(ebid.rawId(), pfRecHitThresholdsEB_);
0764 }
0765 }
0766 }
0767
0768 for (int iX = EEDetId::IX_MIN; iX <= EEDetId::IX_MAX; ++iX) {
0769 for (int iY = EEDetId::IY_MIN; iY <= EEDetId::IY_MAX; ++iY) {
0770
0771 if (EEDetId::validDetId(iX, iY, 1)) {
0772 EEDetId eedetidpos(iX, iY, 1);
0773 ical->setValue(eedetidpos.rawId(), pfRecHitThresholdsEE_);
0774 }
0775 if (EEDetId::validDetId(iX, iY, -1)) {
0776 EEDetId eedetidneg(iX, iY, -1);
0777 ical->setValue(eedetidneg.rawId(), pfRecHitThresholdsEE_);
0778 }
0779 }
0780 }
0781
0782 return ical;
0783 }
0784
0785
0786
0787 std::unique_ptr<EcalIntercalibConstants> EcalTrivialConditionRetriever::produceEcalIntercalibConstants(
0788 const EcalIntercalibConstantsRcd&) {
0789 auto ical = std::make_unique<EcalIntercalibConstants>();
0790
0791 for (int ieta = -EBDetId::MAX_IETA; ieta <= EBDetId::MAX_IETA; ++ieta) {
0792 if (ieta == 0)
0793 continue;
0794 for (int iphi = EBDetId::MIN_IPHI; iphi <= EBDetId::MAX_IPHI; ++iphi) {
0795
0796 if (EBDetId::validDetId(ieta, iphi)) {
0797 EBDetId ebid(ieta, iphi);
0798 double r = (double)std::rand() / (double(RAND_MAX) + double(1));
0799 ical->setValue(ebid.rawId(), intercalibConstantMean_ + r * intercalibConstantSigma_);
0800 }
0801 }
0802 }
0803
0804 for (int iX = EEDetId::IX_MIN; iX <= EEDetId::IX_MAX; ++iX) {
0805 for (int iY = EEDetId::IY_MIN; iY <= EEDetId::IY_MAX; ++iY) {
0806
0807 if (EEDetId::validDetId(iX, iY, 1)) {
0808 double r = (double)std::rand() / (double(RAND_MAX) + double(1));
0809 EEDetId eedetidpos(iX, iY, 1);
0810 ical->setValue(eedetidpos.rawId(), intercalibConstantMean_ + r * intercalibConstantSigma_);
0811 }
0812 if (EEDetId::validDetId(iX, iY, -1)) {
0813 double r1 = (double)std::rand() / (double(RAND_MAX) + double(1));
0814 EEDetId eedetidneg(iX, iY, -1);
0815 ical->setValue(eedetidneg.rawId(), intercalibConstantMean_ + r1 * intercalibConstantSigma_);
0816 }
0817 }
0818 }
0819
0820 return ical;
0821 }
0822
0823 std::unique_ptr<EcalIntercalibConstantsMC> EcalTrivialConditionRetriever::produceEcalIntercalibConstantsMC(
0824 const EcalIntercalibConstantsMCRcd&) {
0825 auto ical = std::make_unique<EcalIntercalibConstantsMC>();
0826
0827 for (int ieta = -EBDetId::MAX_IETA; ieta <= EBDetId::MAX_IETA; ++ieta) {
0828 if (ieta == 0)
0829 continue;
0830 for (int iphi = EBDetId::MIN_IPHI; iphi <= EBDetId::MAX_IPHI; ++iphi) {
0831
0832 if (EBDetId::validDetId(ieta, iphi)) {
0833 EBDetId ebid(ieta, iphi);
0834 double r = (double)std::rand() / (double(RAND_MAX) + double(1));
0835 ical->setValue(ebid.rawId(), intercalibConstantMeanMC_ + r * intercalibConstantSigmaMC_);
0836 }
0837 }
0838 }
0839
0840 for (int iX = EEDetId::IX_MIN; iX <= EEDetId::IX_MAX; ++iX) {
0841 for (int iY = EEDetId::IY_MIN; iY <= EEDetId::IY_MAX; ++iY) {
0842
0843 if (EEDetId::validDetId(iX, iY, 1)) {
0844 double r = (double)std::rand() / (double(RAND_MAX) + double(1));
0845 EEDetId eedetidpos(iX, iY, 1);
0846 ical->setValue(eedetidpos.rawId(), intercalibConstantMeanMC_ + r * intercalibConstantSigmaMC_);
0847 }
0848 if (EEDetId::validDetId(iX, iY, -1)) {
0849 double r1 = (double)std::rand() / (double(RAND_MAX) + double(1));
0850 EEDetId eedetidneg(iX, iY, -1);
0851 ical->setValue(eedetidneg.rawId(), intercalibConstantMeanMC_ + r1 * intercalibConstantSigmaMC_);
0852 }
0853 }
0854 }
0855
0856 return ical;
0857 }
0858
0859 std::unique_ptr<EcalIntercalibErrors> EcalTrivialConditionRetriever::produceEcalIntercalibErrors(
0860 const EcalIntercalibErrorsRcd&) {
0861 auto ical = std::make_unique<EcalIntercalibErrors>();
0862
0863 for (int ieta = -EBDetId::MAX_IETA; ieta <= EBDetId::MAX_IETA; ++ieta) {
0864 if (ieta == 0)
0865 continue;
0866 for (int iphi = EBDetId::MIN_IPHI; iphi <= EBDetId::MAX_IPHI; ++iphi) {
0867
0868 if (EBDetId::validDetId(ieta, iphi)) {
0869 EBDetId ebid(ieta, iphi);
0870 ical->setValue(ebid.rawId(), intercalibErrorMean_);
0871 }
0872 }
0873 }
0874
0875 for (int iX = EEDetId::IX_MIN; iX <= EEDetId::IX_MAX; ++iX) {
0876 for (int iY = EEDetId::IY_MIN; iY <= EEDetId::IY_MAX; ++iY) {
0877
0878 if (EEDetId::validDetId(iX, iY, 1)) {
0879 EEDetId eedetidpos(iX, iY, 1);
0880 ical->setValue(eedetidpos.rawId(), intercalibErrorMean_);
0881 }
0882 if (EEDetId::validDetId(iX, iY, -1)) {
0883 EEDetId eedetidneg(iX, iY, -1);
0884 ical->setValue(eedetidneg.rawId(), intercalibErrorMean_);
0885 }
0886 }
0887 }
0888
0889 return ical;
0890 }
0891
0892 std::unique_ptr<EcalTimeCalibConstants> EcalTrivialConditionRetriever::produceEcalTimeCalibConstants(
0893 const EcalTimeCalibConstantsRcd&) {
0894 auto ical = std::make_unique<EcalTimeCalibConstants>();
0895
0896 for (int ieta = -EBDetId::MAX_IETA; ieta <= EBDetId::MAX_IETA; ++ieta) {
0897 if (ieta == 0)
0898 continue;
0899 for (int iphi = EBDetId::MIN_IPHI; iphi <= EBDetId::MAX_IPHI; ++iphi) {
0900
0901 if (EBDetId::validDetId(ieta, iphi)) {
0902 EBDetId ebid(ieta, iphi);
0903 double r = (double)std::rand() / (double(RAND_MAX) + double(1));
0904 ical->setValue(ebid.rawId(), timeCalibConstantMean_ + r * timeCalibConstantSigma_);
0905 }
0906 }
0907 }
0908
0909 for (int iX = EEDetId::IX_MIN; iX <= EEDetId::IX_MAX; ++iX) {
0910 for (int iY = EEDetId::IY_MIN; iY <= EEDetId::IY_MAX; ++iY) {
0911
0912 if (EEDetId::validDetId(iX, iY, 1)) {
0913 double r = (double)std::rand() / (double(RAND_MAX) + double(1));
0914 EEDetId eedetidpos(iX, iY, 1);
0915 ical->setValue(eedetidpos.rawId(), timeCalibConstantMean_ + r * timeCalibConstantSigma_);
0916 }
0917 if (EEDetId::validDetId(iX, iY, -1)) {
0918 double r1 = (double)std::rand() / (double(RAND_MAX) + double(1));
0919 EEDetId eedetidneg(iX, iY, -1);
0920 ical->setValue(eedetidneg.rawId(), timeCalibConstantMean_ + r1 * timeCalibConstantSigma_);
0921 }
0922 }
0923 }
0924
0925 return ical;
0926 }
0927
0928 std::unique_ptr<EcalTimeCalibErrors> EcalTrivialConditionRetriever::produceEcalTimeCalibErrors(
0929 const EcalTimeCalibErrorsRcd&) {
0930 auto ical = std::make_unique<EcalTimeCalibErrors>();
0931
0932 for (int ieta = -EBDetId::MAX_IETA; ieta <= EBDetId::MAX_IETA; ++ieta) {
0933 if (ieta == 0)
0934 continue;
0935 for (int iphi = EBDetId::MIN_IPHI; iphi <= EBDetId::MAX_IPHI; ++iphi) {
0936
0937 if (EBDetId::validDetId(ieta, iphi)) {
0938 EBDetId ebid(ieta, iphi);
0939 ical->setValue(ebid.rawId(), timeCalibErrorMean_);
0940 }
0941 }
0942 }
0943
0944 for (int iX = EEDetId::IX_MIN; iX <= EEDetId::IX_MAX; ++iX) {
0945 for (int iY = EEDetId::IY_MIN; iY <= EEDetId::IY_MAX; ++iY) {
0946
0947 if (EEDetId::validDetId(iX, iY, 1)) {
0948 EEDetId eedetidpos(iX, iY, 1);
0949 ical->setValue(eedetidpos.rawId(), timeCalibErrorMean_);
0950 }
0951 if (EEDetId::validDetId(iX, iY, -1)) {
0952 EEDetId eedetidneg(iX, iY, -1);
0953 ical->setValue(eedetidneg.rawId(), timeCalibErrorMean_);
0954 }
0955 }
0956 }
0957
0958 return ical;
0959 }
0960
0961 std::unique_ptr<EcalTimeOffsetConstant> EcalTrivialConditionRetriever::produceEcalTimeOffsetConstant(
0962 const EcalTimeOffsetConstantRcd&) {
0963 edm::LogInfo(" produceEcalTimeOffsetConstant: ");
0964 edm::LogInfo(" EB ") << timeOffsetEBConstant_ << " EE " << timeOffsetEEConstant_;
0965 return std::make_unique<EcalTimeOffsetConstant>(timeOffsetEBConstant_, timeOffsetEEConstant_);
0966 }
0967
0968 std::unique_ptr<EcalGainRatios> EcalTrivialConditionRetriever::produceEcalGainRatios(const EcalGainRatiosRcd&) {
0969 auto gratio = std::make_unique<EcalGainRatios>();
0970 EcalMGPAGainRatio gr;
0971 gr.setGain12Over6(gainRatio12over6_);
0972 gr.setGain6Over1(gainRatio6over1_);
0973
0974 for (int ieta = -EBDetId::MAX_IETA; ieta <= EBDetId::MAX_IETA; ++ieta) {
0975 if (ieta == 0)
0976 continue;
0977 for (int iphi = EBDetId::MIN_IPHI; iphi <= EBDetId::MAX_IPHI; ++iphi) {
0978 if (EBDetId::validDetId(ieta, iphi)) {
0979 EBDetId ebid(ieta, iphi);
0980 gratio->setValue(ebid.rawId(), gr);
0981 }
0982 }
0983 }
0984
0985 for (int iX = EEDetId::IX_MIN; iX <= EEDetId::IX_MAX; ++iX) {
0986 for (int iY = EEDetId::IY_MIN; iY <= EEDetId::IY_MAX; ++iY) {
0987
0988 if (EEDetId::validDetId(iX, iY, 1)) {
0989 EEDetId eedetidpos(iX, iY, 1);
0990 gratio->setValue(eedetidpos.rawId(), gr);
0991 }
0992 if (EEDetId::validDetId(iX, iY, -1)) {
0993 EEDetId eedetidneg(iX, iY, -1);
0994 gratio->setValue(eedetidneg.rawId(), gr);
0995 }
0996 }
0997 }
0998
0999 return gratio;
1000 }
1001
1002 std::unique_ptr<EcalADCToGeVConstant> EcalTrivialConditionRetriever::produceEcalADCToGeVConstant(
1003 const EcalADCToGeVConstantRcd&) {
1004 return std::make_unique<EcalADCToGeVConstant>(adcToGeVEBConstant_, adcToGeVEEConstant_);
1005 }
1006
1007 std::unique_ptr<EcalTBWeights> EcalTrivialConditionRetriever::produceEcalTBWeights(const EcalTBWeightsRcd&) {
1008
1009 auto tbwgt = std::make_unique<EcalTBWeights>();
1010
1011
1012
1013
1014
1015 int igrp = 1;
1016 for (int itdc = 1; itdc <= nTDCbins_; ++itdc) {
1017
1018
1019
1020
1021 EcalWeightSet wgt;
1022
1023 EcalWeightSet::EcalWeightMatrix& mat1 = wgt.getWeightsBeforeGainSwitch();
1024 EcalWeightSet::EcalWeightMatrix& mat2 = wgt.getWeightsAfterGainSwitch();
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047 mat1.Place_in_row(amplWeights_[itdc - 1], 0, 0);
1048 mat1.Place_in_row(pedWeights_[itdc - 1], 1, 0);
1049 mat1.Place_in_row(jittWeights_[itdc - 1], 2, 0);
1050
1051
1052 mat2.Place_in_row(amplWeightsAft_[itdc - 1], 0, 0);
1053 mat2.Place_in_row(pedWeightsAft_[itdc - 1], 1, 0);
1054 mat2.Place_in_row(jittWeightsAft_[itdc - 1], 2, 0);
1055
1056
1057
1058 EcalWeightSet::EcalChi2WeightMatrix& mat3 = wgt.getChi2WeightsBeforeGainSwitch();
1059 EcalWeightSet::EcalChi2WeightMatrix& mat4 = wgt.getChi2WeightsAfterGainSwitch();
1060 mat3 = chi2Matrix_[itdc - 1];
1061 mat4 = chi2MatrixAft_[itdc - 1];
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083 tbwgt->setValue(std::make_pair(igrp, itdc), wgt);
1084 }
1085
1086 return tbwgt;
1087 }
1088
1089
1090 std::unique_ptr<EcalClusterLocalContCorrParameters>
1091 EcalTrivialConditionRetriever::produceEcalClusterLocalContCorrParameters(const EcalClusterLocalContCorrParametersRcd&) {
1092 auto ipar = std::make_unique<EcalClusterLocalContCorrParameters>();
1093 for (size_t i = 0; i < localContCorrParameters_.size(); ++i) {
1094 ipar->params().push_back(localContCorrParameters_[i]);
1095 }
1096 return ipar;
1097 }
1098 std::unique_ptr<EcalClusterCrackCorrParameters> EcalTrivialConditionRetriever::produceEcalClusterCrackCorrParameters(
1099 const EcalClusterCrackCorrParametersRcd&) {
1100 auto ipar = std::make_unique<EcalClusterCrackCorrParameters>();
1101 for (size_t i = 0; i < crackCorrParameters_.size(); ++i) {
1102 ipar->params().push_back(crackCorrParameters_[i]);
1103 }
1104 return ipar;
1105 }
1106 std::unique_ptr<EcalClusterEnergyCorrectionParameters>
1107 EcalTrivialConditionRetriever::produceEcalClusterEnergyCorrectionParameters(
1108 const EcalClusterEnergyCorrectionParametersRcd&) {
1109 auto ipar = std::make_unique<EcalClusterEnergyCorrectionParameters>();
1110 for (size_t i = 0; i < energyCorrectionParameters_.size(); ++i) {
1111 ipar->params().push_back(energyCorrectionParameters_[i]);
1112 }
1113 return ipar;
1114 }
1115 std::unique_ptr<EcalClusterEnergyUncertaintyParameters>
1116 EcalTrivialConditionRetriever::produceEcalClusterEnergyUncertaintyParameters(
1117 const EcalClusterEnergyUncertaintyParametersRcd&) {
1118 auto ipar = std::make_unique<EcalClusterEnergyUncertaintyParameters>();
1119 for (size_t i = 0; i < energyUncertaintyParameters_.size(); ++i) {
1120 ipar->params().push_back(energyUncertaintyParameters_[i]);
1121 }
1122 return ipar;
1123 }
1124 std::unique_ptr<EcalClusterEnergyCorrectionObjectSpecificParameters>
1125 EcalTrivialConditionRetriever::produceEcalClusterEnergyCorrectionObjectSpecificParameters(
1126 const EcalClusterEnergyCorrectionObjectSpecificParametersRcd&) {
1127 auto ipar = std::make_unique<EcalClusterEnergyCorrectionObjectSpecificParameters>();
1128 for (size_t i = 0; i < energyCorrectionObjectSpecificParameters_.size(); ++i) {
1129 ipar->params().push_back(energyCorrectionObjectSpecificParameters_[i]);
1130 }
1131 return ipar;
1132 }
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312 std::unique_ptr<EcalLaserAlphas> EcalTrivialConditionRetriever::produceEcalLaserAlphas(const EcalLaserAlphasRcd&) {
1313 edm::LogInfo(" produceEcalLaserAlphas ");
1314 auto ical = std::make_unique<EcalLaserAlphas>();
1315
1316
1317 if (getLaserAlphaFromTypeEB_) {
1318 std::ifstream fEB(edm::FileInPath(EBLaserAlphaFile_).fullPath().c_str());
1319 int SMpos[36] = {-10, 4, -7, -16, 6, -9, 11, -17, 5, 18, 3, -8, 1, -3, -13, 14, -6, 2,
1320 15, -18, 8, 17, -2, 9, -1, 10, -5, 7, -12, -11, 16, -4, -15, -14, 12, 13};
1321
1322 int SMCal[36] = {12, 17, 10, 1, 8, 4, 27, 20, 23, 25, 6, 34, 35, 15, 18, 30, 21, 9,
1323 24, 22, 13, 31, 26, 16, 2, 11, 5, 0, 29, 28, 14, 33, 32, 3, 7, 19};
1324
1325 for (int SMcons = 0; SMcons < 36; SMcons++) {
1326 int SM = SMpos[SMcons];
1327 if (SM < 0)
1328 SM = 17 + abs(SM);
1329 else
1330 SM--;
1331 if (SMCal[SM] != SMcons)
1332 edm::LogInfo(" SM pb : read SM ") << SMcons << " SMpos " << SM << " SMCal " << SMCal[SM];
1333 }
1334
1335 std::string type, batch;
1336 int readSM, pos, bar, bar2;
1337 float alpha = 0;
1338 for (int SMcons = 0; SMcons < 36; SMcons++) {
1339 int SM = SMpos[SMcons];
1340 for (int ic = 0; ic < 1700; ic++) {
1341 fEB >> readSM >> pos >> bar >> bar2 >> type >> batch;
1342
1343 if (readSM != SMcons || pos != ic + 1)
1344 edm::LogInfo(" barrel read pb read SM ")
1345 << readSM << " const SM " << SMcons << " read pos " << pos << " ic " << ic;
1346 if (SM < 0)
1347 SM = 18 + abs(SM);
1348 EBDetId ebdetid(SM, pos, EBDetId::SMCRYSTALMODE);
1349 if (bar == 33101 || bar == 30301)
1350 alpha = laserAlphaMeanEBR_;
1351 else if (bar == 33106) {
1352 if (bar2 <= 2000)
1353 alpha = laserAlphaMeanEBC_;
1354 else {
1355 edm::LogInfo(" problem with barcode first ")
1356 << bar << " last " << bar2 << " read SM " << readSM << " read pos " << pos;
1357 alpha = laserAlphaMeanEBR_;
1358 }
1359 }
1360 ical->setValue(ebdetid, alpha);
1361
1362 if (ic == 1650) {
1363 edm::LogInfo(" ic/alpha ") << ic << "/" << alpha;
1364 }
1365 }
1366 }
1367 fEB.close();
1368
1369 } else if (getLaserAlphaFromFileEB_) {
1370
1371 edm::LogInfo("Laser alpha for EB will be taken from File");
1372 int ieta, iphi;
1373 float alpha;
1374 std::ifstream fEB(edm::FileInPath(EBLaserAlphaFile_).fullPath().c_str());
1375
1376 for (int ic = 0; ic < 61200; ic++) {
1377 fEB >> ieta >> iphi >> alpha;
1378
1379 if (EBDetId::validDetId(ieta, iphi)) {
1380 EBDetId ebid(ieta, iphi);
1381 ical->setValue(ebid, alpha);
1382
1383 }
1384 if (ieta == 10) {
1385 edm::LogInfo("I will print some alphas from the file... ieta/iphi/alpha ")
1386 << ieta << "/" << iphi << "/" << alpha;
1387 }
1388 }
1389 fEB.close();
1390
1391 } else {
1392 edm::LogInfo("laser alphas from default values");
1393
1394
1395 for (int ieta = -EBDetId::MAX_IETA; ieta <= EBDetId::MAX_IETA; ++ieta) {
1396 if (ieta == 0)
1397 continue;
1398 for (int iphi = EBDetId::MIN_IPHI; iphi <= EBDetId::MAX_IPHI; ++iphi) {
1399 if (EBDetId::validDetId(ieta, iphi)) {
1400 EBDetId ebid(ieta, iphi);
1401 double r = (double)std::rand() / (double(RAND_MAX) + double(1));
1402 ical->setValue(ebid, laserAlphaMean_ + r * laserAlphaSigma_);
1403 }
1404 }
1405 }
1406 }
1407
1408 edm::LogInfo(" produceEcalLaserAlphas EE");
1409
1410
1411 int itype, iring, iyear;
1412 float laser = 0;
1413 float las[2][140][6];
1414
1415 if (getLaserAlphaFromTypeEE_) {
1416 edm::LogInfo(" EE laser alphas from type");
1417
1418 std::ifstream fRing(edm::FileInPath(EELaserAlphaFile2_).fullPath().c_str());
1419 for (int i = 0; i < 1681; i++) {
1420 fRing >> itype >> iring >> iyear >> laser;
1421 edm::LogInfo(" ") << itype << " " << iring << " " << iyear << " " << laser << std::endl;
1422 las[itype][iring][iyear] = laser;
1423 }
1424 fRing.close();
1425
1426 std::ifstream fEE(edm::FileInPath(EELaserAlphaFile_).fullPath().c_str());
1427 int nxt = 0;
1428 for (int crystal = 0; crystal < 14648; crystal++) {
1429 int x, y, z, bid, bar, bar2;
1430 float LY, alpha = 0;
1431 fEE >> z >> x >> y >> LY >> bid >> bar >> bar2;
1432 if (x < 1 || x > 100 || y < 1 || y > 100)
1433 edm::LogInfo(" wrong coordinates for barcode ") << bar << " x " << x << " y " << y << " z " << z;
1434 else {
1435 int iyear = 4;
1436 int iring = (int)(sqrt(((float)x - 50.5) * ((float)x - 50.5) + ((float)y - 50.5) * ((float)y - 50.5)) + 85);
1437
1438 double eta = -log(tan(0.5 * atan(sqrt((x - 50.5) * (x - 50.5) + (y - 50.5) * (y - 50.5)) * 2.98 / 328.)));
1439
1440 if (bar == 33201 || (bar == 30399 && bar2 < 568)) {
1441
1442 alpha = laserAlphaMeanEER_;
1443
1444 double raggio = 50.5 - sqrt(((float)x - 50.5) * ((float)x - 50.5) + ((float)y - 50.5) * ((float)y - 50.5));
1445
1446 if (raggio >= 25) {
1447 alpha = 1.07;
1448 }
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462 if (x == 50)
1463 edm::LogInfo("R=") << raggio << " x " << x << " y " << y << " z " << z << "eta=" << eta
1464 << " alpha=" << alpha << " R";
1465
1466 } else if ((bar == 33106 && bar2 > 2000 && bar2 < 4669) || (bar == 30399 && bar2 > 567)) {
1467
1468 itype = 1;
1469 alpha = laserAlphaMeanEEC_;
1470
1471 double raggio = 50.5 - sqrt(((float)x - 50.5) * ((float)x - 50.5) + ((float)y - 50.5) * ((float)y - 50.5));
1472
1473 if (raggio >= 25) {
1474 alpha = 0.80;
1475 }
1476 if (raggio >= 34) {
1477 float r = sqrt((x - 50.5) * (x - 50.5) + (y - 50.5) * (y - 50.5));
1478 if (r < 21) {
1479 nxt = nxt + 1;
1480
1481
1482 if (las[itype][iring][iyear] != 999) {
1483 alpha = 0.7312 + 0.2688 * las[itype][iring][iyear];
1484 }
1485 }
1486 }
1487 if (x == 50)
1488 edm::LogInfo("R=") << raggio << " x " << x << " y " << y << " z " << z << "eta=" << eta
1489 << " alpha=" << alpha << " C";
1490
1491 } else {
1492 edm::LogInfo(" problem with barcode ") << bar << " " << bar2 << " x " << x << " y " << y << " z " << z;
1493 alpha = laserAlphaMeanEER_;
1494 }
1495 }
1496
1497 if (EEDetId::validDetId(x, y, z)) {
1498 EEDetId eedetidpos(x, y, z);
1499 ical->setValue(eedetidpos, alpha);
1500 if (x == 50)
1501 edm::LogInfo(" x ") << x << " y " << y << " alpha " << alpha;
1502 } else
1503 edm::LogInfo(" problem with EEDetId ") << " x " << x << " y " << y << " z " << z;
1504 }
1505 fEE.close();
1506 edm::LogInfo("Number of inner SIC crystals with different alpha= ") << nxt;
1507
1508
1509 } else if (getLaserAlphaFromFileEE_) {
1510 edm::LogInfo(" EE laser alphas from file");
1511
1512 std::ifstream fEE(edm::FileInPath(EELaserAlphaFile_).fullPath().c_str());
1513
1514 for (int crystal = 0; crystal < 14648; crystal++) {
1515 int x, y, z;
1516 float alpha = 1;
1517 fEE >> z >> x >> y >> alpha;
1518 if (x < 1 || x > 100 || y < 1 || y > 100 || z == 0 || z > 1 || z < -1) {
1519 edm::LogInfo("ERROR: wrong coordinates for crystal ") << " x " << x << " y " << y << " z " << z;
1520 edm::LogInfo(" the format of the file should be z x y alpha ");
1521 } else {
1522 if (EEDetId::validDetId(x, y, z)) {
1523 EEDetId eedetidpos(x, y, z);
1524 ical->setValue(eedetidpos, alpha);
1525 } else
1526 edm::LogInfo(" problem with EEDetId ") << " x " << x << " y " << y << " z " << z;
1527 }
1528 }
1529 fEE.close();
1530
1531
1532 } else {
1533
1534 edm::LogInfo(" EE laser alphas from default values");
1535 for (int iX = EEDetId::IX_MIN; iX <= EEDetId::IX_MAX; ++iX) {
1536 for (int iY = EEDetId::IY_MIN; iY <= EEDetId::IY_MAX; ++iY) {
1537
1538 if (EEDetId::validDetId(iX, iY, 1)) {
1539 double r = (double)std::rand() / (double(RAND_MAX) + double(1));
1540 EEDetId eedetidpos(iX, iY, 1);
1541 ical->setValue(eedetidpos, laserAlphaMean_ + r * laserAlphaSigma_);
1542 }
1543 if (EEDetId::validDetId(iX, iY, -1)) {
1544 double r1 = (double)std::rand() / (double(RAND_MAX) + double(1));
1545 EEDetId eedetidneg(iX, iY, -1);
1546 ical->setValue(eedetidneg, laserAlphaMean_ + r1 * laserAlphaSigma_);
1547 }
1548 }
1549 }
1550 }
1551
1552 return ical;
1553 }
1554
1555 std::unique_ptr<EcalLaserAPDPNRatiosRef> EcalTrivialConditionRetriever::produceEcalLaserAPDPNRatiosRef(
1556 const EcalLaserAPDPNRatiosRefRcd&) {
1557 auto ical = std::make_unique<EcalLaserAPDPNRatiosRef>();
1558 for (int ieta = -EBDetId::MAX_IETA; ieta <= EBDetId::MAX_IETA; ++ieta) {
1559 if (ieta == 0)
1560 continue;
1561 for (int iphi = EBDetId::MIN_IPHI; iphi <= EBDetId::MAX_IPHI; ++iphi) {
1562 if (EBDetId::validDetId(ieta, iphi)) {
1563 EBDetId ebid(ieta, iphi);
1564 double r = (double)std::rand() / (double(RAND_MAX) + double(1));
1565 ical->setValue(ebid, laserAPDPNRefMean_ + r * laserAPDPNRefSigma_);
1566 }
1567 }
1568 }
1569
1570 for (int iX = EEDetId::IX_MIN; iX <= EEDetId::IX_MAX; ++iX) {
1571 for (int iY = EEDetId::IY_MIN; iY <= EEDetId::IY_MAX; ++iY) {
1572
1573 if (EEDetId::validDetId(iX, iY, 1)) {
1574 double r = (double)std::rand() / (double(RAND_MAX) + double(1));
1575 EEDetId eedetidpos(iX, iY, 1);
1576 ical->setValue(eedetidpos, laserAPDPNRefMean_ + r * laserAPDPNRefSigma_);
1577 }
1578
1579 if (EEDetId::validDetId(iX, iY, -1)) {
1580 double r1 = (double)std::rand() / (double(RAND_MAX) + double(1));
1581 EEDetId eedetidneg(iX, iY, -1);
1582 ical->setValue(eedetidneg, laserAPDPNRefMean_ + r1 * laserAPDPNRefSigma_);
1583 }
1584 }
1585 }
1586
1587 return ical;
1588 }
1589
1590 std::unique_ptr<EcalLaserAPDPNRatios> EcalTrivialConditionRetriever::produceEcalLaserAPDPNRatios(
1591 const EcalLaserAPDPNRatiosRcd&) {
1592 EnergyResolutionVsLumi ageing;
1593 ageing.setLumi(totLumi_);
1594 ageing.setInstLumi(instLumi_);
1595
1596 auto ical = std::make_unique<EcalLaserAPDPNRatios>();
1597 for (int ieta = -EBDetId::MAX_IETA; ieta <= EBDetId::MAX_IETA; ++ieta) {
1598 if (ieta == 0)
1599 continue;
1600
1601 double eta = EBDetId::approxEta(EBDetId(ieta, 1));
1602
1603 eta = fabs(eta);
1604 double drop = ageing.calcampDropTotal(eta);
1605
1606
1607 for (int iphi = EBDetId::MIN_IPHI; iphi <= EBDetId::MAX_IPHI; ++iphi) {
1608 if (EBDetId::validDetId(ieta, iphi)) {
1609 EBDetId ebid(ieta, iphi);
1610 double r = (double)std::rand() / (double(RAND_MAX) + double(1));
1611
1612 EcalLaserAPDPNRatios::EcalLaserAPDPNpair pairAPDPN;
1613 pairAPDPN.p1 = laserAPDPNMean_ * drop + r * laserAPDPNSigma_;
1614 pairAPDPN.p2 = laserAPDPNMean_ * drop + r * laserAPDPNSigma_;
1615 pairAPDPN.p3 = laserAPDPNMean_ * drop + r * laserAPDPNSigma_;
1616 ical->setValue(ebid, pairAPDPN);
1617 }
1618 }
1619 }
1620
1621 edm::LogInfo("----- EE -----");
1622
1623 for (int iX = EEDetId::IX_MIN; iX <= EEDetId::IX_MAX; ++iX) {
1624 for (int iY = EEDetId::IY_MIN; iY <= EEDetId::IY_MAX; ++iY) {
1625
1626
1627 if (EEDetId::validDetId(iX, iY, 1)) {
1628 double r = (double)std::rand() / (double(RAND_MAX) + double(1));
1629 EEDetId eedetidpos(iX, iY, 1);
1630
1631 double eta = -log(tan(0.5 * atan(sqrt((iX - 50.0) * (iX - 50.0) + (iY - 50.0) * (iY - 50.0)) * 2.98 / 328.)));
1632 eta = fabs(eta);
1633 double drop = ageing.calcampDropTotal(eta);
1634
1635
1636 EcalLaserAPDPNRatios::EcalLaserAPDPNpair pairAPDPN;
1637 pairAPDPN.p1 = laserAPDPNMean_ * drop + r * laserAPDPNSigma_;
1638 pairAPDPN.p2 = laserAPDPNMean_ * drop + r * laserAPDPNSigma_;
1639 pairAPDPN.p3 = laserAPDPNMean_ * drop + r * laserAPDPNSigma_;
1640 ical->setValue(eedetidpos, pairAPDPN);
1641 }
1642
1643 if (EEDetId::validDetId(iX, iY, -1)) {
1644 double r1 = (double)std::rand() / (double(RAND_MAX) + double(1));
1645 EEDetId eedetidneg(iX, iY, -1);
1646
1647 double eta = -log(tan(0.5 * atan(sqrt((iX - 50.0) * (iX - 50.0) + (iY - 50.0) * (iY - 50.0)) * 2.98 / 328.)));
1648 eta = fabs(eta);
1649 double drop = ageing.calcampDropTotal(eta);
1650
1651
1652 EcalLaserAPDPNRatios::EcalLaserAPDPNpair pairAPDPN;
1653 pairAPDPN.p1 = laserAPDPNMean_ * drop + r1 * laserAPDPNSigma_;
1654 pairAPDPN.p2 = laserAPDPNMean_ * drop + r1 * laserAPDPNSigma_;
1655 pairAPDPN.p3 = laserAPDPNMean_ * drop + r1 * laserAPDPNSigma_;
1656 ical->setValue(eedetidneg, pairAPDPN);
1657 }
1658 }
1659 }
1660
1661 EcalLaserAPDPNRatios::EcalLaserTimeStamp TimeStamp;
1662
1663 for (int i = 0; i < 92; i++) {
1664 TimeStamp.t1 = Timestamp(laserAPDPNTime1_);
1665 if (laserAPDPNTime2_ == 0) {
1666 TimeStamp.t2 = Timestamp(edm::Timestamp::endOfTime().value());
1667 } else {
1668 TimeStamp.t2 = Timestamp(laserAPDPNTime2_);
1669 }
1670 if (laserAPDPNTime3_ == 0) {
1671 TimeStamp.t3 = Timestamp(edm::Timestamp::endOfTime().value());
1672 } else {
1673 TimeStamp.t3 = Timestamp(laserAPDPNTime3_);
1674 }
1675
1676 ical->setTime(i, TimeStamp);
1677 }
1678
1679 return ical;
1680 }
1681
1682 void EcalTrivialConditionRetriever::getWeightsFromConfiguration(const edm::ParameterSet& ps) {
1683 std::vector<std::vector<double> > amplwgtv(nTDCbins_);
1684
1685 if (!getWeightsFromFile_ && nTDCbins_ == 1) {
1686 std::vector<double> vampl;
1687
1688 vampl.push_back(-0.33333);
1689 vampl.push_back(-0.33333);
1690 vampl.push_back(-0.33333);
1691 vampl.push_back(0.);
1692 vampl.push_back(0.);
1693 vampl.push_back(1.);
1694 vampl.push_back(0.);
1695 vampl.push_back(0.);
1696 vampl.push_back(0.);
1697 vampl.push_back(0.);
1698 amplwgtv[0] = ps.getUntrackedParameter<std::vector<double> >("amplWeights", vampl);
1699 } else if (getWeightsFromFile_) {
1700 edm::LogInfo("EcalTrivialConditionRetriever")
1701 << "Reading amplitude weights from file " << edm::FileInPath(amplWeightsFile_).fullPath().c_str();
1702 std::ifstream amplFile(edm::FileInPath(amplWeightsFile_).fullPath().c_str());
1703 int tdcBin = 0;
1704 while (!amplFile.eof() && tdcBin < nTDCbins_) {
1705 for (int j = 0; j < 10; ++j) {
1706 float ww;
1707 amplFile >> ww;
1708 amplwgtv[tdcBin].push_back(ww);
1709 }
1710 ++tdcBin;
1711 }
1712 assert(tdcBin == nTDCbins_);
1713
1714 } else {
1715
1716 edm::LogError("EcalTrivialConditionRetriever") << "Configuration not supported. Exception is raised ";
1717 throw cms::Exception("WrongConfig");
1718 }
1719
1720 for (int i = 0; i < nTDCbins_; i++) {
1721 assert(amplwgtv[i].size() == 10);
1722 int j = 0;
1723 for (std::vector<double>::const_iterator it = amplwgtv[i].begin(); it != amplwgtv[i].end(); ++it) {
1724 (amplWeights_[i])[j] = *it;
1725 j++;
1726 }
1727 }
1728
1729 std::vector<std::vector<double> > amplwgtvAftGain(nTDCbins_);
1730
1731 if (!getWeightsFromFile_ && nTDCbins_ == 1) {
1732 std::vector<double> vamplAftGain;
1733 vamplAftGain.push_back(0.);
1734 vamplAftGain.push_back(0.);
1735 vamplAftGain.push_back(0.);
1736 vamplAftGain.push_back(0.);
1737 vamplAftGain.push_back(0.);
1738 vamplAftGain.push_back(1.);
1739 vamplAftGain.push_back(0.);
1740 vamplAftGain.push_back(0.);
1741 vamplAftGain.push_back(0.);
1742 vamplAftGain.push_back(0.);
1743 amplwgtvAftGain[0] = ps.getUntrackedParameter<std::vector<double> >("amplWeightsAftGain", vamplAftGain);
1744 } else if (getWeightsFromFile_) {
1745
1746 edm::LogInfo("EcalTrivialConditionRetriever") << "Reading amplitude weights aftre gain switch from file "
1747 << edm::FileInPath(amplWeightsAftFile_).fullPath().c_str();
1748 std::ifstream amplFile(edm::FileInPath(amplWeightsAftFile_).fullPath().c_str());
1749 int tdcBin = 0;
1750 while (!amplFile.eof() && tdcBin < nTDCbins_) {
1751 for (int j = 0; j < 10; ++j) {
1752 float ww;
1753 amplFile >> ww;
1754 amplwgtvAftGain[tdcBin].push_back(ww);
1755 }
1756 ++tdcBin;
1757 }
1758 assert(tdcBin == nTDCbins_);
1759 } else {
1760
1761 edm::LogError("EcalTrivialConditionRetriever") << "Configuration not supported. Exception is raised ";
1762 throw cms::Exception("WrongConfig");
1763 }
1764
1765 for (int i = 0; i < nTDCbins_; i++) {
1766 assert(amplwgtvAftGain[i].size() == 10);
1767 int j = 0;
1768 for (std::vector<double>::const_iterator it = amplwgtvAftGain[i].begin(); it != amplwgtvAftGain[i].end(); ++it) {
1769 (amplWeightsAft_[i])[j] = *it;
1770 j++;
1771 }
1772 }
1773
1774
1775
1776 std::vector<std::vector<double> > pedwgtv(nTDCbins_);
1777
1778 if (!getWeightsFromFile_ && nTDCbins_ == 1) {
1779 std::vector<double> vped;
1780 vped.push_back(0.33333);
1781 vped.push_back(0.33333);
1782 vped.push_back(0.33333);
1783 vped.push_back(0.);
1784 vped.push_back(0.);
1785 vped.push_back(0.);
1786 vped.push_back(0.);
1787 vped.push_back(0.);
1788 vped.push_back(0.);
1789 vped.push_back(0.);
1790 pedwgtv[0] = ps.getUntrackedParameter<std::vector<double> >("pedWeights", vped);
1791 } else if (getWeightsFromFile_) {
1792
1793 edm::LogInfo("EcalTrivialConditionRetriever")
1794 << "Reading pedestal weights from file " << edm::FileInPath(pedWeightsFile_).fullPath().c_str();
1795 std::ifstream pedFile(edm::FileInPath(pedWeightsFile_).fullPath().c_str());
1796 int tdcBin = 0;
1797 while (!pedFile.eof() && tdcBin < nTDCbins_) {
1798 for (int j = 0; j < 10; ++j) {
1799 float ww;
1800 pedFile >> ww;
1801 pedwgtv[tdcBin].push_back(ww);
1802 }
1803 ++tdcBin;
1804 }
1805 assert(tdcBin == nTDCbins_);
1806 } else {
1807
1808 edm::LogError("EcalTrivialConditionRetriever") << "Configuration not supported. Exception is raised ";
1809 throw cms::Exception("WrongConfig");
1810 }
1811
1812 for (int i = 0; i < nTDCbins_; i++) {
1813 assert(pedwgtv[i].size() == 10);
1814 int j = 0;
1815 for (std::vector<double>::const_iterator it = pedwgtv[i].begin(); it != pedwgtv[i].end(); ++it) {
1816 (pedWeights_[i])[j] = *it;
1817 j++;
1818 }
1819 }
1820
1821 std::vector<std::vector<double> > pedwgtvaft(nTDCbins_);
1822
1823 if (!getWeightsFromFile_ && nTDCbins_ == 1) {
1824 std::vector<double> vped;
1825 vped.push_back(0.);
1826 vped.push_back(0.);
1827 vped.push_back(0.);
1828 vped.push_back(0.);
1829 vped.push_back(0.);
1830 vped.push_back(0.);
1831 vped.push_back(0.);
1832 vped.push_back(0.);
1833 vped.push_back(0.);
1834 vped.push_back(0.);
1835 pedwgtvaft[0] = ps.getUntrackedParameter<std::vector<double> >("pedWeightsAft", vped);
1836 } else if (getWeightsFromFile_) {
1837
1838 edm::LogInfo("EcalTrivialConditionRetriever") << "Reading pedestal after gain switch weights from file "
1839 << edm::FileInPath(pedWeightsAftFile_).fullPath().c_str();
1840 std::ifstream pedFile(edm::FileInPath(pedWeightsAftFile_).fullPath().c_str());
1841 int tdcBin = 0;
1842 while (!pedFile.eof() && tdcBin < nTDCbins_) {
1843 for (int j = 0; j < 10; ++j) {
1844 float ww;
1845 pedFile >> ww;
1846 pedwgtvaft[tdcBin].push_back(ww);
1847 }
1848 ++tdcBin;
1849 }
1850 assert(tdcBin == nTDCbins_);
1851 } else {
1852
1853 edm::LogError("EcalTrivialConditionRetriever") << "Configuration not supported. Exception is raised ";
1854 throw cms::Exception("WrongConfig");
1855 }
1856
1857 for (int i = 0; i < nTDCbins_; i++) {
1858 assert(pedwgtvaft[i].size() == 10);
1859 int j = 0;
1860 for (std::vector<double>::const_iterator it = pedwgtvaft[i].begin(); it != pedwgtvaft[i].end(); ++it) {
1861 (pedWeightsAft_[i])[j] = *it;
1862 j++;
1863 }
1864 }
1865
1866
1867
1868 std::vector<std::vector<double> > jittwgtv(nTDCbins_);
1869
1870 if (!getWeightsFromFile_ && nTDCbins_ == 1) {
1871 std::vector<double> vjitt;
1872 vjitt.push_back(0.04066309);
1873 vjitt.push_back(0.04066309);
1874 vjitt.push_back(0.04066309);
1875 vjitt.push_back(0.000);
1876 vjitt.push_back(1.325176);
1877 vjitt.push_back(-0.04997078);
1878 vjitt.push_back(-0.504338);
1879 vjitt.push_back(-0.5024844);
1880 vjitt.push_back(-0.3903718);
1881 vjitt.push_back(0.000);
1882 jittwgtv[0] = ps.getUntrackedParameter<std::vector<double> >("jittWeights", vjitt);
1883 } else if (getWeightsFromFile_) {
1884
1885 edm::LogInfo("EcalTrivialConditionRetriever")
1886 << "Reading jitter weights from file " << edm::FileInPath(jittWeightsFile_).fullPath().c_str();
1887 std::ifstream jittFile(edm::FileInPath(jittWeightsFile_).fullPath().c_str());
1888 int tdcBin = 0;
1889 while (!jittFile.eof() && tdcBin < nTDCbins_) {
1890 for (int j = 0; j < 10; ++j) {
1891 float ww;
1892 jittFile >> ww;
1893 jittwgtv[tdcBin].push_back(ww);
1894 }
1895 ++tdcBin;
1896 }
1897 assert(tdcBin == nTDCbins_);
1898 } else {
1899
1900 edm::LogError("EcalTrivialConditionRetriever") << "Configuration not supported. Exception is raised ";
1901 throw cms::Exception("WrongConfig");
1902 }
1903
1904 for (int i = 0; i < nTDCbins_; i++) {
1905 assert(jittwgtv[i].size() == 10);
1906 int j = 0;
1907 for (std::vector<double>::const_iterator it = jittwgtv[i].begin(); it != jittwgtv[i].end(); ++it) {
1908 (jittWeights_[i])[j] = *it;
1909 j++;
1910 }
1911 }
1912
1913 std::vector<std::vector<double> > jittwgtvaft(nTDCbins_);
1914
1915 if (!getWeightsFromFile_ && nTDCbins_ == 1) {
1916 std::vector<double> vjitt;
1917 vjitt.push_back(0.);
1918 vjitt.push_back(0.);
1919 vjitt.push_back(0.);
1920 vjitt.push_back(0.);
1921 vjitt.push_back(1.097871);
1922 vjitt.push_back(-0.04551035);
1923 vjitt.push_back(-0.4159156);
1924 vjitt.push_back(-0.4185352);
1925 vjitt.push_back(-0.3367127);
1926 vjitt.push_back(0.);
1927 jittwgtvaft[0] = ps.getUntrackedParameter<std::vector<double> >("jittWeightsAft", vjitt);
1928 } else if (getWeightsFromFile_) {
1929
1930 edm::LogInfo("EcalTrivialConditionRetriever") << "Reading jitter after gain switch weights from file "
1931 << edm::FileInPath(jittWeightsAftFile_).fullPath().c_str();
1932 std::ifstream jittFile(edm::FileInPath(jittWeightsAftFile_).fullPath().c_str());
1933 int tdcBin = 0;
1934 while (!jittFile.eof() && tdcBin < nTDCbins_) {
1935 for (int j = 0; j < 10; ++j) {
1936 float ww;
1937 jittFile >> ww;
1938 jittwgtvaft[tdcBin].push_back(ww);
1939 }
1940 ++tdcBin;
1941 }
1942 assert(tdcBin == nTDCbins_);
1943 } else {
1944
1945 edm::LogError("EcalTrivialConditionRetriever") << "Configuration not supported. Exception is raised ";
1946 throw cms::Exception("WrongConfig");
1947 }
1948
1949 for (int i = 0; i < nTDCbins_; i++) {
1950 assert(jittwgtvaft[i].size() == 10);
1951 int j = 0;
1952 for (std::vector<double>::const_iterator it = jittwgtvaft[i].begin(); it != jittwgtvaft[i].end(); ++it) {
1953 (jittWeightsAft_[i])[j] = *it;
1954 j++;
1955 }
1956 }
1957
1958 std::vector<EcalWeightSet::EcalChi2WeightMatrix> chi2Matrix(nTDCbins_);
1959 if (!getWeightsFromFile_ && nTDCbins_ == 1) {
1960
1961
1962
1963
1964 chi2Matrix[0](0, 0) = 0.694371;
1965 chi2Matrix[0](0, 1) = -0.305629;
1966 chi2Matrix[0](0, 2) = -0.305629;
1967 chi2Matrix[0](0, 3) = 0.;
1968 chi2Matrix[0](0, 4) = 0.;
1969 chi2Matrix[0](0, 5) = 0.;
1970 chi2Matrix[0](0, 6) = 0.;
1971 chi2Matrix[0](0, 7) = 0.;
1972 chi2Matrix[0](0, 8) = 0.;
1973 chi2Matrix[0](0, 9) = 0.;
1974 chi2Matrix[0](1, 0) = -0.305629;
1975 chi2Matrix[0](1, 1) = 0.694371;
1976 chi2Matrix[0](1, 2) = -0.305629;
1977 chi2Matrix[0](1, 3) = 0.;
1978 chi2Matrix[0](1, 4) = 0.;
1979 chi2Matrix[0](1, 5) = 0.;
1980 chi2Matrix[0](1, 6) = 0.;
1981 chi2Matrix[0](1, 7) = 0.;
1982 chi2Matrix[0](1, 8) = 0.;
1983 chi2Matrix[0](1, 9) = 0.;
1984 chi2Matrix[0](2, 0) = -0.305629;
1985 chi2Matrix[0](2, 1) = -0.305629;
1986 chi2Matrix[0](2, 2) = 0.694371;
1987 chi2Matrix[0](2, 3) = 0.;
1988 chi2Matrix[0](2, 4) = 0.;
1989 chi2Matrix[0](2, 5) = 0.;
1990 chi2Matrix[0](2, 6) = 0.;
1991 chi2Matrix[0](2, 7) = 0.;
1992 chi2Matrix[0](2, 8) = 0.;
1993 chi2Matrix[0](2, 9) = 0.;
1994 chi2Matrix[0](3, 0) = 0.;
1995 chi2Matrix[0](3, 1) = 0.;
1996 chi2Matrix[0](3, 2) = 0.;
1997 chi2Matrix[0](3, 3) = 0.;
1998 chi2Matrix[0](3, 4) = 0.;
1999 chi2Matrix[0](3, 5) = 0.;
2000 chi2Matrix[0](3, 6) = 0.;
2001 chi2Matrix[0](3, 7) = 0.;
2002 chi2Matrix[0](3, 8) = 0.;
2003 chi2Matrix[0](3, 9) = 0.;
2004 chi2Matrix[0](4, 0) = 0.;
2005 chi2Matrix[0](4, 1) = 0.;
2006 chi2Matrix[0](4, 2) = 0.;
2007 chi2Matrix[0](4, 3) = 0.;
2008 chi2Matrix[0](4, 4) = 0.8027116;
2009 chi2Matrix[0](4, 5) = -0.2517103;
2010 chi2Matrix[0](4, 6) = -0.2232882;
2011 chi2Matrix[0](4, 7) = -0.1716192;
2012 chi2Matrix[0](4, 8) = -0.1239006;
2013 chi2Matrix[0](4, 9) = 0.;
2014 chi2Matrix[0](5, 0) = 0.;
2015 chi2Matrix[0](5, 1) = 0.;
2016 chi2Matrix[0](5, 2) = 0.;
2017 chi2Matrix[0](5, 3) = 0.;
2018 chi2Matrix[0](5, 4) = -0.2517103;
2019 chi2Matrix[0](5, 5) = 0.6528964;
2020 chi2Matrix[0](5, 6) = -0.2972839;
2021 chi2Matrix[0](5, 7) = -0.2067162;
2022 chi2Matrix[0](5, 8) = -0.1230729;
2023 chi2Matrix[0](5, 9) = 0.;
2024 chi2Matrix[0](6, 0) = 0.;
2025 chi2Matrix[0](6, 1) = 0.;
2026 chi2Matrix[0](6, 2) = 0.;
2027 chi2Matrix[0](6, 3) = 0.;
2028 chi2Matrix[0](6, 4) = -0.2232882;
2029 chi2Matrix[0](6, 5) = -0.2972839;
2030 chi2Matrix[0](6, 6) = 0.7413607;
2031 chi2Matrix[0](6, 7) = -0.1883866;
2032 chi2Matrix[0](6, 8) = -0.1235052;
2033 chi2Matrix[0](6, 9) = 0.;
2034 chi2Matrix[0](7, 0) = 0.;
2035 chi2Matrix[0](7, 1) = 0.;
2036 chi2Matrix[0](7, 2) = 0.;
2037 chi2Matrix[0](7, 3) = 0.;
2038 chi2Matrix[0](7, 4) = -0.1716192;
2039 chi2Matrix[0](7, 5) = -0.2067162;
2040 chi2Matrix[0](7, 6) = -0.1883866;
2041 chi2Matrix[0](7, 7) = 0.844935;
2042 chi2Matrix[0](7, 8) = -0.124291;
2043 chi2Matrix[0](7, 9) = 0.;
2044 chi2Matrix[0](8, 0) = 0.;
2045 chi2Matrix[0](8, 1) = 0.;
2046 chi2Matrix[0](8, 2) = 0.;
2047 chi2Matrix[0](8, 3) = 0.;
2048 chi2Matrix[0](8, 4) = -0.1239006;
2049 chi2Matrix[0](8, 5) = -0.1230729;
2050 chi2Matrix[0](8, 6) = -0.1235052;
2051 chi2Matrix[0](8, 7) = -0.124291;
2052 chi2Matrix[0](8, 8) = 0.8749833;
2053 chi2Matrix[0](8, 9) = 0.;
2054 chi2Matrix[0](9, 0) = 0.;
2055 chi2Matrix[0](9, 1) = 0.;
2056 chi2Matrix[0](9, 2) = 0.;
2057 chi2Matrix[0](9, 3) = 0.;
2058 chi2Matrix[0](9, 4) = 0.;
2059 chi2Matrix[0](9, 5) = 0.;
2060 chi2Matrix[0](9, 6) = 0.;
2061 chi2Matrix[0](9, 7) = 0.;
2062 chi2Matrix[0](9, 8) = 0.;
2063 chi2Matrix[0](9, 9) = 0.;
2064 } else if (getWeightsFromFile_) {
2065
2066 edm::LogInfo("EcalTrivialConditionRetriever")
2067 << "Reading chi2Matrix from file " << edm::FileInPath(chi2MatrixFile_).fullPath().c_str();
2068 std::ifstream chi2MatrixFile(edm::FileInPath(chi2MatrixFile_).fullPath().c_str());
2069 int tdcBin = 0;
2070 while (!chi2MatrixFile.eof() && tdcBin < nTDCbins_) {
2071
2072 for (int j = 0; j < 10; ++j) {
2073 for (int l = 0; l < 10; ++l) {
2074 float ww;
2075 chi2MatrixFile >> ww;
2076 chi2Matrix[tdcBin](j, l) = ww;
2077 }
2078 }
2079 ++tdcBin;
2080 }
2081 assert(tdcBin == nTDCbins_);
2082 } else {
2083
2084 edm::LogError("EcalTrivialConditionRetriever") << "Configuration not supported. Exception is raised ";
2085 throw cms::Exception("WrongConfig");
2086 }
2087
2088
2089
2090
2091 chi2Matrix_ = chi2Matrix;
2092
2093
2094 std::vector<EcalWeightSet::EcalChi2WeightMatrix> chi2MatrixAft(nTDCbins_);
2095 if (!getWeightsFromFile_ && nTDCbins_ == 1) {
2096
2097
2098
2099
2100 chi2MatrixAft[0](0, 0) = 0.;
2101 chi2MatrixAft[0](0, 1) = 0.;
2102 chi2MatrixAft[0](0, 2) = 0.;
2103 chi2MatrixAft[0](0, 3) = 0.;
2104 chi2MatrixAft[0](0, 4) = 0.;
2105 chi2MatrixAft[0](0, 5) = 0.;
2106 chi2MatrixAft[0](0, 6) = 0.;
2107 chi2MatrixAft[0](0, 7) = 0.;
2108 chi2MatrixAft[0](0, 8) = 0.;
2109 chi2MatrixAft[0](0, 9) = 0.;
2110 chi2MatrixAft[0](1, 0) = 0.;
2111 chi2MatrixAft[0](1, 1) = 0.;
2112 chi2MatrixAft[0](1, 2) = 0.;
2113 chi2MatrixAft[0](1, 3) = 0.;
2114 chi2MatrixAft[0](1, 4) = 0.;
2115 chi2MatrixAft[0](1, 5) = 0.;
2116 chi2MatrixAft[0](1, 6) = 0.;
2117 chi2MatrixAft[0](1, 7) = 0.;
2118 chi2MatrixAft[0](1, 8) = 0.;
2119 chi2MatrixAft[0](1, 9) = 0.;
2120 chi2MatrixAft[0](2, 0) = 0.;
2121 chi2MatrixAft[0](2, 1) = 0.;
2122 chi2MatrixAft[0](2, 2) = 0.;
2123 chi2MatrixAft[0](2, 3) = 0.;
2124 chi2MatrixAft[0](2, 4) = 0.;
2125 chi2MatrixAft[0](2, 5) = 0.;
2126 chi2MatrixAft[0](2, 6) = 0.;
2127 chi2MatrixAft[0](2, 7) = 0.;
2128 chi2MatrixAft[0](2, 8) = 0.;
2129 chi2MatrixAft[0](2, 9) = 0.;
2130 chi2MatrixAft[0](3, 0) = 0.;
2131 chi2MatrixAft[0](3, 1) = 0.;
2132 chi2MatrixAft[0](3, 2) = 0.;
2133 chi2MatrixAft[0](3, 3) = 0.;
2134 chi2MatrixAft[0](3, 4) = 0.;
2135 chi2MatrixAft[0](3, 5) = 0.;
2136 chi2MatrixAft[0](3, 6) = 0.;
2137 chi2MatrixAft[0](3, 7) = 0.;
2138 chi2MatrixAft[0](3, 8) = 0.;
2139 chi2MatrixAft[0](3, 9) = 0.;
2140 chi2MatrixAft[0](4, 0) = 0.;
2141 chi2MatrixAft[0](4, 1) = 0.;
2142 chi2MatrixAft[0](4, 2) = 0.;
2143 chi2MatrixAft[0](4, 3) = 0.;
2144 chi2MatrixAft[0](4, 4) = 0.8030884;
2145 chi2MatrixAft[0](4, 5) = -0.2543541;
2146 chi2MatrixAft[0](4, 6) = -0.2243544;
2147 chi2MatrixAft[0](4, 7) = -0.1698177;
2148 chi2MatrixAft[0](4, 8) = -0.1194506;
2149 chi2MatrixAft[0](4, 9) = 0.;
2150 chi2MatrixAft[0](5, 0) = 0.;
2151 chi2MatrixAft[0](5, 1) = 0.;
2152 chi2MatrixAft[0](5, 2) = 0.;
2153 chi2MatrixAft[0](5, 3) = 0.;
2154 chi2MatrixAft[0](5, 4) = -0.2543541;
2155 chi2MatrixAft[0](5, 5) = 0.6714465;
2156 chi2MatrixAft[0](5, 6) = -0.2898025;
2157 chi2MatrixAft[0](5, 7) = -0.2193564;
2158 chi2MatrixAft[0](5, 8) = -0.1542964;
2159 chi2MatrixAft[0](5, 9) = 0.;
2160 chi2MatrixAft[0](6, 0) = 0.;
2161 chi2MatrixAft[0](6, 1) = 0.;
2162 chi2MatrixAft[0](6, 2) = 0.;
2163 chi2MatrixAft[0](6, 3) = 0.;
2164 chi2MatrixAft[0](6, 4) = -0.2243544;
2165 chi2MatrixAft[0](6, 5) = -0.2898025;
2166 chi2MatrixAft[0](6, 6) = 0.7443781;
2167 chi2MatrixAft[0](6, 7) = -0.1934846;
2168 chi2MatrixAft[0](6, 8) = -0.136098;
2169 chi2MatrixAft[0](6, 9) = 0.;
2170 chi2MatrixAft[0](7, 0) = 0.;
2171 chi2MatrixAft[0](7, 1) = 0.;
2172 chi2MatrixAft[0](7, 2) = 0.;
2173 chi2MatrixAft[0](7, 3) = 0.;
2174 chi2MatrixAft[0](7, 4) = -0.1698177;
2175 chi2MatrixAft[0](7, 5) = -0.2193564;
2176 chi2MatrixAft[0](7, 6) = -0.1934846;
2177 chi2MatrixAft[0](7, 7) = 0.8535482;
2178 chi2MatrixAft[0](7, 8) = -0.1030149;
2179 chi2MatrixAft[0](7, 9) = 0.;
2180 chi2MatrixAft[0](8, 0) = 0.;
2181 chi2MatrixAft[0](8, 1) = 0.;
2182 chi2MatrixAft[0](8, 2) = 0.;
2183 chi2MatrixAft[0](8, 3) = 0.;
2184 chi2MatrixAft[0](8, 4) = -0.1194506;
2185 chi2MatrixAft[0](8, 5) = -0.1542964;
2186 chi2MatrixAft[0](8, 6) = -0.136098;
2187 chi2MatrixAft[0](8, 7) = -0.1030149;
2188 chi2MatrixAft[0](8, 8) = 0.9275388;
2189 chi2MatrixAft[0](8, 9) = 0.;
2190 chi2MatrixAft[0](9, 0) = 0.;
2191 chi2MatrixAft[0](9, 1) = 0.;
2192 chi2MatrixAft[0](9, 2) = 0.;
2193 chi2MatrixAft[0](9, 3) = 0.;
2194 chi2MatrixAft[0](9, 4) = 0.;
2195 chi2MatrixAft[0](9, 5) = 0.;
2196 chi2MatrixAft[0](9, 6) = 0.;
2197 chi2MatrixAft[0](9, 7) = 0.;
2198 chi2MatrixAft[0](9, 8) = 0.;
2199 chi2MatrixAft[0](9, 9) = 0.;
2200 } else if (getWeightsFromFile_) {
2201
2202 edm::LogInfo("EcalTrivialConditionRetriever")
2203 << "Reading chi2MatrixAft from file " << edm::FileInPath(chi2MatrixAftFile_).fullPath().c_str();
2204 std::ifstream chi2MatrixAftFile(edm::FileInPath(chi2MatrixAftFile_).fullPath().c_str());
2205 int tdcBin = 0;
2206 while (!chi2MatrixAftFile.eof() && tdcBin < nTDCbins_) {
2207
2208 for (int j = 0; j < 10; ++j) {
2209 for (int l = 0; l < 10; ++l) {
2210 float ww;
2211 chi2MatrixAftFile >> ww;
2212 chi2MatrixAft[tdcBin](j, l) = ww;
2213 }
2214 }
2215 ++tdcBin;
2216 }
2217 assert(tdcBin == nTDCbins_);
2218 } else {
2219
2220 edm::LogError("EcalTrivialConditionRetriever") << "Configuration not supported. Exception is raised ";
2221 throw cms::Exception("WrongConfig");
2222 }
2223
2224
2225
2226
2227 chi2MatrixAft_ = chi2MatrixAft;
2228
2229 }
2230
2231
2232
2233 std::unique_ptr<EcalChannelStatus> EcalTrivialConditionRetriever::getChannelStatusFromConfiguration(
2234 const EcalChannelStatusRcd&) {
2235 auto ecalStatus = std::make_unique<EcalChannelStatus>();
2236
2237
2238
2239
2240 for (int ieta = -EBDetId::MAX_IETA; ieta <= EBDetId::MAX_IETA; ++ieta) {
2241 if (ieta == 0)
2242 continue;
2243 for (int iphi = EBDetId::MIN_IPHI; iphi <= EBDetId::MAX_IPHI; ++iphi) {
2244 if (EBDetId::validDetId(ieta, iphi)) {
2245 EBDetId ebid(ieta, iphi);
2246 ecalStatus->setValue(ebid, 0);
2247 }
2248 }
2249 }
2250
2251 for (int iX = EEDetId::IX_MIN; iX <= EEDetId::IX_MAX; ++iX) {
2252 for (int iY = EEDetId::IY_MIN; iY <= EEDetId::IY_MAX; ++iY) {
2253
2254 if (EEDetId::validDetId(iX, iY, 1)) {
2255 EEDetId eedetidpos(iX, iY, 1);
2256 ecalStatus->setValue(eedetidpos, 0);
2257 }
2258 if (EEDetId::validDetId(iX, iY, -1)) {
2259 EEDetId eedetidneg(iX, iY, -1);
2260 ecalStatus->setValue(eedetidneg, 0);
2261 }
2262 }
2263 }
2264
2265
2266
2267 edm::LogInfo("EcalTrivialConditionRetriever")
2268 << "Reading channel statuses from file " << edm::FileInPath(channelStatusFile_).fullPath().c_str();
2269 std::ifstream statusFile(edm::FileInPath(channelStatusFile_).fullPath().c_str());
2270 if (!statusFile.good()) {
2271 edm::LogError("EcalTrivialConditionRetriever") << "*** Problems opening file: " << channelStatusFile_;
2272 throw cms::Exception("Cannot open ECAL channel status file");
2273 }
2274
2275 std::string EcalSubDet;
2276 std::string str;
2277 int hashIndex(0);
2278 int status(0);
2279
2280 while (!statusFile.eof()) {
2281 statusFile >> EcalSubDet;
2282 if (EcalSubDet != std::string("EB") && EcalSubDet != std::string("EE")) {
2283 std::getline(statusFile, str);
2284 continue;
2285 } else {
2286 statusFile >> hashIndex >> status;
2287 }
2288
2289
2290 if (EcalSubDet == std::string("EB")) {
2291 EBDetId ebid = EBDetId::unhashIndex(hashIndex);
2292 ecalStatus->setValue(ebid, status);
2293 } else if (EcalSubDet == std::string("EE")) {
2294 EEDetId eedetid = EEDetId::unhashIndex(hashIndex);
2295 ecalStatus->setValue(eedetid, status);
2296 } else {
2297 edm::LogError("EcalTrivialConditionRetriever") << " *** " << EcalSubDet << " is neither EB nor EE ";
2298 }
2299 }
2300
2301
2302 statusFile.close();
2303 return ecalStatus;
2304 }
2305
2306 std::unique_ptr<EcalChannelStatus> EcalTrivialConditionRetriever::produceEcalChannelStatus(const EcalChannelStatusRcd&) {
2307 auto ical = std::make_unique<EcalChannelStatus>();
2308
2309 for (int ieta = -EBDetId::MAX_IETA; ieta <= EBDetId::MAX_IETA; ++ieta) {
2310 if (ieta == 0)
2311 continue;
2312 for (int iphi = EBDetId::MIN_IPHI; iphi <= EBDetId::MAX_IPHI; ++iphi) {
2313 if (EBDetId::validDetId(ieta, iphi)) {
2314 EBDetId ebid(ieta, iphi);
2315 ical->setValue(ebid, 0);
2316 }
2317 }
2318 }
2319
2320 for (int iX = EEDetId::IX_MIN; iX <= EEDetId::IX_MAX; ++iX) {
2321 for (int iY = EEDetId::IY_MIN; iY <= EEDetId::IY_MAX; ++iY) {
2322
2323 if (EEDetId::validDetId(iX, iY, 1)) {
2324 EEDetId eedetidpos(iX, iY, 1);
2325 ical->setValue(eedetidpos, 0);
2326 }
2327 if (EEDetId::validDetId(iX, iY, -1)) {
2328 EEDetId eedetidneg(iX, iY, -1);
2329 ical->setValue(eedetidneg, 0);
2330 }
2331 }
2332 }
2333 return ical;
2334 }
2335
2336
2337 std::unique_ptr<EcalDQMChannelStatus> EcalTrivialConditionRetriever::produceEcalDQMChannelStatus(
2338 const EcalDQMChannelStatusRcd&) {
2339 uint32_t sta(0);
2340
2341 auto ical = std::make_unique<EcalDQMChannelStatus>();
2342
2343 for (int ieta = -EBDetId::MAX_IETA; ieta <= EBDetId::MAX_IETA; ++ieta) {
2344 if (ieta == 0)
2345 continue;
2346 for (int iphi = EBDetId::MIN_IPHI; iphi <= EBDetId::MAX_IPHI; ++iphi) {
2347 if (EBDetId::validDetId(ieta, iphi)) {
2348 EBDetId ebid(ieta, iphi);
2349 ical->setValue(ebid, sta);
2350 }
2351 }
2352 }
2353
2354 for (int iX = EEDetId::IX_MIN; iX <= EEDetId::IX_MAX; ++iX) {
2355 for (int iY = EEDetId::IY_MIN; iY <= EEDetId::IY_MAX; ++iY) {
2356
2357 if (EEDetId::validDetId(iX, iY, 1)) {
2358 EEDetId eedetidpos(iX, iY, 1);
2359 ical->setValue(eedetidpos, sta);
2360 }
2361 if (EEDetId::validDetId(iX, iY, -1)) {
2362 EEDetId eedetidneg(iX, iY, -1);
2363 ical->setValue(eedetidneg, sta);
2364 }
2365 }
2366 }
2367 return ical;
2368 }
2369
2370
2371 std::unique_ptr<EcalDQMTowerStatus> EcalTrivialConditionRetriever::produceEcalDQMTowerStatus(
2372 const EcalDQMTowerStatusRcd&) {
2373 auto ical = std::make_unique<EcalDQMTowerStatus>();
2374
2375 uint32_t sta(0);
2376
2377
2378 int iz = 0;
2379 for (int k = 0; k < 2; k++) {
2380 if (k == 0)
2381 iz = -1;
2382 if (k == 1)
2383 iz = +1;
2384 for (int i = 1; i < 73; i++) {
2385 for (int j = 1; j < 18; j++) {
2386 if (EcalTrigTowerDetId::validDetId(iz, EcalBarrel, j, i)) {
2387 EcalTrigTowerDetId ebid(iz, EcalBarrel, j, i);
2388
2389 ical->setValue(ebid, sta);
2390 }
2391 }
2392 }
2393 }
2394
2395
2396 for (int k = 0; k < 2; k++) {
2397 if (k == 0)
2398 iz = -1;
2399 if (k == 1)
2400 iz = +1;
2401 for (int i = 1; i < 21; i++) {
2402 for (int j = 1; j < 21; j++) {
2403 if (EcalScDetId::validDetId(i, j, iz)) {
2404 EcalScDetId eeid(i, j, iz);
2405 ical->setValue(eeid, sta);
2406 }
2407 }
2408 }
2409 }
2410
2411 return ical;
2412 }
2413
2414
2415 std::unique_ptr<EcalDCSTowerStatus> EcalTrivialConditionRetriever::produceEcalDCSTowerStatus(
2416 const EcalDCSTowerStatusRcd&) {
2417 auto ical = std::make_unique<EcalDCSTowerStatus>();
2418
2419 int status(0);
2420
2421
2422 int iz = 0;
2423 for (int k = 0; k < 2; k++) {
2424 if (k == 0)
2425 iz = -1;
2426 if (k == 1)
2427 iz = +1;
2428 for (int i = 1; i < 73; i++) {
2429 for (int j = 1; j < 18; j++) {
2430 if (EcalTrigTowerDetId::validDetId(iz, EcalBarrel, j, i)) {
2431 EcalTrigTowerDetId ebid(iz, EcalBarrel, j, i);
2432
2433 ical->setValue(ebid, status);
2434 }
2435 }
2436 }
2437 }
2438
2439
2440 for (int k = 0; k < 2; k++) {
2441 if (k == 0)
2442 iz = -1;
2443 if (k == 1)
2444 iz = +1;
2445 for (int i = 1; i < 21; i++) {
2446 for (int j = 1; j < 21; j++) {
2447 if (EcalScDetId::validDetId(i, j, iz)) {
2448 EcalScDetId eeid(i, j, iz);
2449 ical->setValue(eeid, status);
2450 }
2451 }
2452 }
2453 }
2454
2455 return ical;
2456 }
2457
2458
2459 std::unique_ptr<EcalDAQTowerStatus> EcalTrivialConditionRetriever::produceEcalDAQTowerStatus(
2460 const EcalDAQTowerStatusRcd&) {
2461 auto ical = std::make_unique<EcalDAQTowerStatus>();
2462
2463 int status(0);
2464
2465
2466 int iz = 0;
2467 for (int k = 0; k < 2; k++) {
2468 if (k == 0)
2469 iz = -1;
2470 if (k == 1)
2471 iz = +1;
2472 for (int i = 1; i < 73; i++) {
2473 for (int j = 1; j < 18; j++) {
2474 if (EcalTrigTowerDetId::validDetId(iz, EcalBarrel, j, i)) {
2475 EcalTrigTowerDetId ebid(iz, EcalBarrel, j, i);
2476
2477 ical->setValue(ebid, status);
2478 }
2479 }
2480 }
2481 }
2482
2483
2484 for (int k = 0; k < 2; k++) {
2485 if (k == 0)
2486 iz = -1;
2487 if (k == 1)
2488 iz = +1;
2489 for (int i = 1; i < 21; i++) {
2490 for (int j = 1; j < 21; j++) {
2491 if (EcalScDetId::validDetId(i, j, iz)) {
2492 EcalScDetId eeid(i, j, iz);
2493 ical->setValue(eeid, status);
2494 }
2495 }
2496 }
2497 }
2498
2499 return ical;
2500 }
2501
2502
2503 std::unique_ptr<EcalTPGCrystalStatus> EcalTrivialConditionRetriever::getTrgChannelStatusFromConfiguration(
2504 const EcalTPGCrystalStatusRcd&) {
2505 auto ecalStatus = std::make_unique<EcalTPGCrystalStatus>();
2506
2507
2508
2509
2510 for (int ieta = -EBDetId::MAX_IETA; ieta <= EBDetId::MAX_IETA; ++ieta) {
2511 if (ieta == 0)
2512 continue;
2513 for (int iphi = EBDetId::MIN_IPHI; iphi <= EBDetId::MAX_IPHI; ++iphi) {
2514 if (EBDetId::validDetId(ieta, iphi)) {
2515 EBDetId ebid(ieta, iphi);
2516 ecalStatus->setValue(ebid, 0);
2517 }
2518 }
2519 }
2520
2521 for (int iX = EEDetId::IX_MIN; iX <= EEDetId::IX_MAX; ++iX) {
2522 for (int iY = EEDetId::IY_MIN; iY <= EEDetId::IY_MAX; ++iY) {
2523
2524 if (EEDetId::validDetId(iX, iY, 1)) {
2525 EEDetId eedetidpos(iX, iY, 1);
2526 ecalStatus->setValue(eedetidpos, 0);
2527 }
2528 if (EEDetId::validDetId(iX, iY, -1)) {
2529 EEDetId eedetidneg(iX, iY, -1);
2530 ecalStatus->setValue(eedetidneg, 0);
2531 }
2532 }
2533 }
2534
2535
2536
2537 edm::LogInfo("EcalTrivialConditionRetriever")
2538 << "Reading channel statuses from file " << edm::FileInPath(channelStatusFile_).fullPath().c_str();
2539 std::ifstream statusFile(edm::FileInPath(channelStatusFile_).fullPath().c_str());
2540 if (!statusFile.good()) {
2541 edm::LogError("EcalTrivialConditionRetriever") << "*** Problems opening file: " << channelStatusFile_;
2542 throw cms::Exception("Cannot open ECAL channel status file");
2543 }
2544
2545 std::string EcalSubDet;
2546 std::string str;
2547 int hashIndex(0);
2548 int status(0);
2549
2550 while (!statusFile.eof()) {
2551 statusFile >> EcalSubDet;
2552 if (EcalSubDet != std::string("EB") && EcalSubDet != std::string("EE")) {
2553 std::getline(statusFile, str);
2554 continue;
2555 } else {
2556 statusFile >> hashIndex >> status;
2557 }
2558
2559
2560 if (EcalSubDet == std::string("EB")) {
2561 EBDetId ebid = EBDetId::unhashIndex(hashIndex);
2562 ecalStatus->setValue(ebid, status);
2563 } else if (EcalSubDet == std::string("EE")) {
2564 EEDetId eedetid = EEDetId::unhashIndex(hashIndex);
2565 ecalStatus->setValue(eedetid, status);
2566 } else {
2567 edm::LogError("EcalTrivialConditionRetriever") << " *** " << EcalSubDet << " is neither EB nor EE ";
2568 }
2569 }
2570
2571
2572 statusFile.close();
2573 return ecalStatus;
2574 }
2575
2576 std::unique_ptr<EcalTPGCrystalStatus> EcalTrivialConditionRetriever::produceEcalTrgChannelStatus(
2577 const EcalTPGCrystalStatusRcd&) {
2578 auto ical = std::make_unique<EcalTPGCrystalStatus>();
2579
2580 for (int ieta = -EBDetId::MAX_IETA; ieta <= EBDetId::MAX_IETA; ++ieta) {
2581 if (ieta == 0)
2582 continue;
2583 for (int iphi = EBDetId::MIN_IPHI; iphi <= EBDetId::MAX_IPHI; ++iphi) {
2584 if (EBDetId::validDetId(ieta, iphi)) {
2585 EBDetId ebid(ieta, iphi);
2586 ical->setValue(ebid, 0);
2587 }
2588 }
2589 }
2590
2591 for (int iX = EEDetId::IX_MIN; iX <= EEDetId::IX_MAX; ++iX) {
2592 for (int iY = EEDetId::IY_MIN; iY <= EEDetId::IY_MAX; ++iY) {
2593
2594 if (EEDetId::validDetId(iX, iY, 1)) {
2595 EEDetId eedetidpos(iX, iY, 1);
2596 ical->setValue(eedetidpos, 0);
2597 }
2598 if (EEDetId::validDetId(iX, iY, -1)) {
2599 EEDetId eedetidneg(iX, iY, -1);
2600 ical->setValue(eedetidneg, 0);
2601 }
2602 }
2603 }
2604 return ical;
2605 }
2606
2607 std::unique_ptr<EcalIntercalibConstants> EcalTrivialConditionRetriever::getIntercalibConstantsFromConfiguration(
2608 const EcalIntercalibConstantsRcd&) {
2609 std::unique_ptr<EcalIntercalibConstants> ical;
2610
2611
2612
2613
2614
2615 edm::LogInfo("EcalTrivialConditionRetriever")
2616 << "Reading intercalibration constants from file " << intercalibConstantsFile_.c_str();
2617
2618 if (intercalibConstantsFile_.find(".xml") != std::string::npos) {
2619 edm::LogInfo("generating Intercalib from xml file");
2620
2621 EcalCondHeader h;
2622 EcalIntercalibConstants* rcd = new EcalIntercalibConstants;
2623 EcalIntercalibConstantsXMLTranslator::readXML(intercalibConstantsFile_, h, *rcd);
2624
2625 if (totLumi_ != 0 || instLumi_ != 0) {
2626 edm::LogInfo("implementing ageing for intercalib");
2627
2628 EcalIntercalibConstantsMC* rcdMC = new EcalIntercalibConstantsMC;
2629
2630 if (intercalibConstantsMCFile_.find(".xml") != std::string::npos) {
2631 edm::LogInfo("generating IntercalibMC from xml file");
2632
2633 EcalCondHeader h;
2634 EcalIntercalibConstantsMCXMLTranslator::readXML(intercalibConstantsMCFile_, h, *rcdMC);
2635
2636 } else {
2637 edm::LogInfo("please provide the xml file of the EcalIntercalibConstantsMC");
2638 }
2639
2640 TRandom3* gRandom = new TRandom3();
2641
2642 EnergyResolutionVsLumi ageing;
2643 ageing.setLumi(totLumi_);
2644 ageing.setInstLumi(instLumi_);
2645
2646 const EcalIntercalibConstantMap& mymap = rcd->getMap();
2647 const EcalIntercalibConstantMCMap& mymapMC = rcdMC->getMap();
2648
2649 for (int ieta = -EBDetId::MAX_IETA; ieta <= EBDetId::MAX_IETA; ++ieta) {
2650 if (ieta == 0)
2651 continue;
2652
2653 double eta = EBDetId::approxEta(EBDetId(ieta, 1));
2654 eta = fabs(eta);
2655 double constantTerm = ageing.calcresolutitonConstantTerm(eta);
2656 edm::LogInfo("EB at eta=") << eta << " constant term is " << constantTerm;
2657
2658 for (int iphi = EBDetId::MIN_IPHI; iphi <= EBDetId::MAX_IPHI; ++iphi) {
2659
2660 if (EBDetId::validDetId(ieta, iphi)) {
2661 EBDetId ebid(ieta, iphi);
2662 EcalIntercalibConstants::const_iterator idref = mymap.find(ebid);
2663 EcalIntercalibConstant icalconstant = 1;
2664 if (idref != mymap.end())
2665 icalconstant = (*idref);
2666
2667 EcalIntercalibConstantsMC::const_iterator idrefMC = mymapMC.find(ebid);
2668 EcalIntercalibConstantMC icalconstantMC = 1;
2669 if (idrefMC != mymapMC.end())
2670 icalconstantMC = (*idrefMC);
2671
2672 double r = gRandom->Gaus(0, constantTerm);
2673
2674 if (iphi == 10)
2675 edm::LogInfo("EB at eta=") << eta << " IC=" << icalconstant << " ICMC=" << icalconstantMC
2676 << " smear=" << r << " ";
2677
2678 icalconstant = icalconstant + r * 1.29 * icalconstantMC;
2679 rcd->setValue(ebid.rawId(), icalconstant);
2680
2681 if (iphi == 10)
2682 edm::LogInfo("newIC=") << icalconstant;
2683
2684 EcalIntercalibConstant icalconstant2 = (*idref);
2685 if (icalconstant != icalconstant2)
2686 edm::LogInfo(">>>> error in smearing intercalib");
2687 }
2688 }
2689 }
2690
2691 for (int iX = EEDetId::IX_MIN; iX <= EEDetId::IX_MAX; ++iX) {
2692 for (int iY = EEDetId::IY_MIN; iY <= EEDetId::IY_MAX; ++iY) {
2693
2694 if (EEDetId::validDetId(iX, iY, 1)) {
2695 EEDetId eedetidpos(iX, iY, 1);
2696 double eta =
2697 -log(tan(0.5 * atan(sqrt((iX - 50.0) * (iX - 50.0) + (iY - 50.0) * (iY - 50.0)) * 2.98 / 328.)));
2698 eta = fabs(eta);
2699 double constantTerm = ageing.calcresolutitonConstantTerm(eta);
2700 if (iX == 50)
2701 edm::LogInfo("EE at eta=") << eta << " constant term is " << constantTerm;
2702
2703 EcalIntercalibConstants::const_iterator idref = mymap.find(eedetidpos);
2704 EcalIntercalibConstant icalconstant = 1;
2705 if (idref != mymap.end())
2706 icalconstant = (*idref);
2707
2708 EcalIntercalibConstantsMC::const_iterator idrefMC = mymapMC.find(eedetidpos);
2709 EcalIntercalibConstantMC icalconstantMC = 1;
2710 if (idrefMC != mymapMC.end())
2711 icalconstantMC = (*idrefMC);
2712
2713 double r = gRandom->Gaus(0, constantTerm);
2714
2715 if (iX == 10)
2716 edm::LogInfo("EE at eta=") << eta << " IC=" << icalconstant << " ICMC=" << icalconstantMC
2717 << " smear=" << r << " ";
2718 icalconstant = icalconstant + r * 1.29 * icalconstantMC;
2719 rcd->setValue(eedetidpos.rawId(), icalconstant);
2720 if (iX == 10)
2721 edm::LogInfo("newIC=") << icalconstant;
2722 }
2723 if (EEDetId::validDetId(iX, iY, -1)) {
2724 EEDetId eedetidneg(iX, iY, -1);
2725 double eta =
2726 -log(tan(0.5 * atan(sqrt((iX - 50.0) * (iX - 50.0) + (iY - 50.0) * (iY - 50.0)) * 2.98 / 328.)));
2727 eta = fabs(eta);
2728 double constantTerm = ageing.calcresolutitonConstantTerm(eta);
2729 EcalIntercalibConstant icalconstant = 1;
2730
2731 EcalIntercalibConstantsMC::const_iterator idrefMC = mymapMC.find(eedetidneg);
2732 EcalIntercalibConstantMC icalconstantMC = 1;
2733 if (idrefMC != mymapMC.end())
2734 icalconstantMC = (*idrefMC);
2735
2736 double r = gRandom->Gaus(0, constantTerm);
2737 icalconstant = icalconstant + r * 1.29 * icalconstantMC;
2738 rcd->setValue(eedetidneg.rawId(), icalconstant);
2739 }
2740 }
2741 }
2742
2743 ical = std::unique_ptr<EcalIntercalibConstants>(rcd);
2744
2745 delete gRandom;
2746 }
2747
2748 } else {
2749 ical = std::make_unique<EcalIntercalibConstants>();
2750
2751 FILE* inpFile;
2752 inpFile = fopen(intercalibConstantsFile_.c_str(), "r");
2753 if (!inpFile) {
2754 edm::LogError("EcalTrivialConditionRetriever") << "*** Can not open file: " << intercalibConstantsFile_;
2755 throw cms::Exception("Cannot open inter-calibration coefficients txt file");
2756 }
2757
2758 char line[256];
2759 std::ostringstream str;
2760 fgets(line, 255, inpFile);
2761 int sm_number = atoi(line);
2762 str << "sm: " << sm_number;
2763
2764 fgets(line, 255, inpFile);
2765
2766
2767 fgets(line, 255, inpFile);
2768 std::string gen_tag = line;
2769 str << "gen tag: " << gen_tag;
2770
2771 fgets(line, 255, inpFile);
2772 std::string cali_method = line;
2773 str << "cali method: " << cali_method << std::endl;
2774
2775 fgets(line, 255, inpFile);
2776 std::string cali_version = line;
2777 str << "cali version: " << cali_version << std::endl;
2778
2779 fgets(line, 255, inpFile);
2780 std::string cali_type = line;
2781 str << "cali type: " << cali_type;
2782
2783 edm::LogInfo("EcalTrivialConditionRetriever") << "[PIETRO] Intercalibration file - " << str.str();
2784
2785 float calib[1700] = {1};
2786 int calib_status[1700] = {0};
2787
2788 int ii = 0;
2789
2790 while (fgets(line, 255, inpFile)) {
2791 ii++;
2792 int dmy_num = 0;
2793 float dmy_calib = 0.;
2794 float dmy_RMS = 0.;
2795 int dmy_events = 0;
2796 int dmy_status = 0;
2797 sscanf(line, "%d %f %f %d %d", &dmy_num, &dmy_calib, &dmy_RMS, &dmy_events, &dmy_status);
2798 assert(dmy_num >= 1);
2799 assert(dmy_num <= 1700);
2800 calib[dmy_num - 1] = dmy_calib;
2801 calib_status[dmy_num - 1] = dmy_status;
2802
2803
2804
2805
2806
2807
2808
2809
2810 }
2811
2812 fclose(inpFile);
2813 edm::LogInfo("EcalTrivialConditionRetriever") << "Read intercalibrations for " << ii << " xtals ";
2814 if (ii != 1700)
2815 edm::LogWarning("StoreEcalCondition") << "Some crystals missing, set to 1" << std::endl;
2816
2817
2818
2819
2820
2821 int sm_db = 1;
2822
2823 for (int i = 0; i < 1700; i++) {
2824
2825
2826
2827
2828
2829
2830
2831 if (sm_db >= EBDetId::MIN_SM && sm_db <= EBDetId::MAX_SM) {
2832 EBDetId ebid(sm_db, i + 1, EBDetId::SMCRYSTALMODE);
2833 if (calib_status[i])
2834 ical->setValue(ebid.rawId(), calib[i]);
2835 else
2836 ical->setValue(ebid.rawId(), 1.);
2837 }
2838
2839 }
2840 }
2841
2842 return ical;
2843 }
2844
2845
2846
2847 std::unique_ptr<EcalPFRecHitThresholds> EcalTrivialConditionRetriever::getPFRecHitThresholdsFromConfiguration(
2848 const EcalPFRecHitThresholdsRcd&) {
2849 std::unique_ptr<EcalPFRecHitThresholds> ical;
2850
2851
2852 edm::LogInfo("EcalTrivialConditionRetriever")
2853 << "Reading PF RecHit Thresholds from file " << edm::FileInPath(pfRecHitFile_).fullPath().c_str();
2854
2855 std::ifstream PFRecHitsFile(edm::FileInPath(pfRecHitFile_).fullPath().c_str());
2856
2857 ical = std::make_unique<EcalPFRecHitThresholds>();
2858
2859
2860
2861 int nxt = 0;
2862
2863 edm::LogInfo("Going to multiply the sigmas by ") << pfRecHitThresholdsNSigmas_;
2864 edm::LogInfo("We will print some values ");
2865
2866 while (!PFRecHitsFile.eof()) {
2867
2868 float thresh;
2869 int eta = 0;
2870 int phi = 0;
2871 int zeta = 0;
2872 PFRecHitsFile >> eta >> phi >> zeta >> thresh;
2873
2874
2875 thresh = thresh * pfRecHitThresholdsNSigmas_;
2876
2877 if (phi == 50)
2878 edm::LogInfo("EB ") << std::dec << eta << "/" << std::dec << phi << "/" << std::dec << zeta
2879 << " thresh: " << thresh;
2880 nxt = nxt + 1;
2881 if (EBDetId::validDetId(eta, phi)) {
2882 EBDetId ebid(eta, phi);
2883 ical->setValue(ebid.rawId(), thresh);
2884 }
2885 }
2886 PFRecHitsFile.close();
2887
2888
2889 edm::LogInfo("Read number of EB crystals: ") << nxt;
2890
2891
2892 edm::LogInfo("Now reading the EE file ... ");
2893 edm::LogInfo("We will multiply the sigma in EE by ") << pfRecHitThresholdsNSigmas_;
2894 edm::LogInfo("We will multiply the sigma in EE at high eta by") << pfRecHitThresholdsNSigmasHEta_;
2895 edm::LogInfo("We will print some values ");
2896
2897 edm::LogInfo("EcalTrivialConditionRetriever")
2898 << "Reading PF RecHit Thresholds EE from file " << edm::FileInPath(pfRecHitFileEE_).fullPath().c_str();
2899 std::ifstream PFRecHitsFileEE(edm::FileInPath(pfRecHitFileEE_).fullPath().c_str());
2900
2901 nxt = 0;
2902
2903 while (!PFRecHitsFileEE.eof()) {
2904
2905 float thresh;
2906 int ix = 0;
2907 int iy = 0;
2908 int iz = 0;
2909 PFRecHitsFileEE >> ix >> iy >> iz >> thresh;
2910
2911
2912 double eta =
2913 -log(tan(0.5 * atan(sqrt((ix - 50.5) * (ix - 50.5) + (iy - 50.5) * (iy - 50.5)) * 2.98 / 328.)));
2914
2915 if (eta > 2.5) {
2916 thresh = thresh * pfRecHitThresholdsNSigmasHEta_;
2917 } else {
2918 thresh = thresh * pfRecHitThresholdsNSigmas_;
2919 }
2920
2921 if (ix == 50)
2922 edm::LogInfo("EE ") << std::dec << ix << "/" << std::dec << iy << "/" << std::dec << iz << " thresh: " << thresh;
2923 if (EEDetId::validDetId(ix, iy, iz)) {
2924 EEDetId eeid(ix, iy, iz);
2925 ical->setValue(eeid.rawId(), thresh);
2926 }
2927 nxt = nxt + 1;
2928 }
2929 PFRecHitsFileEE.close();
2930
2931 edm::LogInfo("Read number of EE crystals: ") << nxt;
2932 edm::LogInfo("end PF Rec Hits ... ");
2933
2934 return ical;
2935 }
2936
2937 std::unique_ptr<EcalIntercalibConstantsMC> EcalTrivialConditionRetriever::getIntercalibConstantsMCFromConfiguration(
2938 const EcalIntercalibConstantsMCRcd&) {
2939 std::unique_ptr<EcalIntercalibConstantsMC> ical;
2940
2941
2942
2943
2944
2945 edm::LogInfo("EcalTrivialConditionRetriever")
2946 << "Reading intercalibration constants MC from file " << intercalibConstantsMCFile_.c_str();
2947
2948 if (intercalibConstantsMCFile_.find(".xml") != std::string::npos) {
2949 edm::LogInfo("generating Intercalib MC from xml file");
2950
2951 EcalCondHeader h;
2952 EcalIntercalibConstantsMC* rcd = new EcalIntercalibConstantsMC;
2953 EcalIntercalibConstantsMCXMLTranslator::readXML(intercalibConstantsMCFile_, h, *rcd);
2954
2955 ical = std::unique_ptr<EcalIntercalibConstants>(rcd);
2956
2957 } else {
2958 edm::LogInfo("ERROR>>> please provide a xml file");
2959 }
2960
2961 return ical;
2962 }
2963
2964 std::unique_ptr<EcalIntercalibErrors> EcalTrivialConditionRetriever::getIntercalibErrorsFromConfiguration(
2965 const EcalIntercalibErrorsRcd&) {
2966 auto ical = std::make_unique<EcalIntercalibErrors>();
2967
2968
2969
2970
2971 edm::LogInfo("EcalTrivialConditionRetriever")
2972 << "Reading intercalibration constants from file " << intercalibErrorsFile_.c_str();
2973
2974 FILE* inpFile;
2975 inpFile = fopen(intercalibErrorsFile_.c_str(), "r");
2976 if (!inpFile) {
2977 edm::LogError("EcalTrivialConditionRetriever") << "*** Can not open file: " << intercalibErrorsFile_;
2978 throw cms::Exception("Cannot open inter-calibration coefficients txt file");
2979 }
2980
2981 char line[256];
2982 std::ostringstream str;
2983 fgets(line, 255, inpFile);
2984 int sm_number = atoi(line);
2985 str << "sm: " << sm_number;
2986
2987 fgets(line, 255, inpFile);
2988
2989
2990 fgets(line, 255, inpFile);
2991 std::string gen_tag = line;
2992 str << "gen tag: " << gen_tag;
2993
2994 fgets(line, 255, inpFile);
2995 std::string cali_method = line;
2996 str << "cali method: " << cali_method << std::endl;
2997
2998 fgets(line, 255, inpFile);
2999 std::string cali_version = line;
3000 str << "cali version: " << cali_version << std::endl;
3001
3002 fgets(line, 255, inpFile);
3003 std::string cali_type = line;
3004 str << "cali type: " << cali_type;
3005
3006 edm::LogInfo("EcalTrivialConditionRetriever") << "[PIETRO] Intercalibration file - " << str.str() << std::endl;
3007
3008 float calib[1700] = {1};
3009 int calib_status[1700] = {0};
3010
3011 int ii = 0;
3012
3013 while (fgets(line, 255, inpFile)) {
3014 ii++;
3015 int dmy_num = 0;
3016 float dmy_calib = 0.;
3017 float dmy_RMS = 0.;
3018 int dmy_events = 0;
3019 int dmy_status = 0;
3020 sscanf(line, "%d %f %f %d %d", &dmy_num, &dmy_calib, &dmy_RMS, &dmy_events, &dmy_status);
3021 assert(dmy_num >= 1);
3022 assert(dmy_num <= 1700);
3023 calib[dmy_num - 1] = dmy_calib;
3024 calib_status[dmy_num - 1] = dmy_status;
3025
3026
3027
3028
3029
3030
3031
3032
3033 }
3034
3035 fclose(inpFile);
3036 edm::LogInfo("EcalTrivialConditionRetriever") << "Read intercalibrations for " << ii << " xtals ";
3037 if (ii != 1700)
3038 edm::LogWarning("StoreEcalCondition") << "Some crystals missing, set to 1" << std::endl;
3039
3040
3041
3042
3043
3044 int sm_db = 1;
3045
3046 for (int i = 0; i < 1700; i++) {
3047
3048
3049
3050
3051
3052
3053
3054 if (sm_db >= EBDetId::MIN_SM && sm_db <= EBDetId::MAX_SM) {
3055 EBDetId ebid(sm_db, i + 1, EBDetId::SMCRYSTALMODE);
3056 if (calib_status[i])
3057 ical->setValue(ebid.rawId(), calib[i]);
3058 else
3059 ical->setValue(ebid.rawId(), 1.);
3060 }
3061
3062 }
3063
3064
3065 return ical;
3066 }
3067
3068
3069
3070 std::unique_ptr<EcalTimeCalibConstants> EcalTrivialConditionRetriever::getTimeCalibConstantsFromConfiguration(
3071 const EcalTimeCalibConstantsRcd&) {
3072 auto ical = std::make_unique<EcalTimeCalibConstants>();
3073
3074
3075
3076
3077 edm::LogInfo("EcalTrivialConditionRetriever")
3078 << "Reading time calibration constants from file " << timeCalibConstantsFile_.c_str();
3079
3080 FILE* inpFile;
3081 inpFile = fopen(timeCalibConstantsFile_.c_str(), "r");
3082 if (!inpFile) {
3083 edm::LogError("EcalTrivialConditionRetriever") << "*** Can not open file: " << timeCalibConstantsFile_;
3084 throw cms::Exception("Cannot open inter-calibration coefficients txt file");
3085 }
3086
3087 char line[256];
3088 std::ostringstream str;
3089 fgets(line, 255, inpFile);
3090 int sm_number = atoi(line);
3091 str << "sm: " << sm_number;
3092
3093 fgets(line, 255, inpFile);
3094
3095
3096 fgets(line, 255, inpFile);
3097 std::string gen_tag = line;
3098 str << "gen tag: " << gen_tag;
3099
3100 fgets(line, 255, inpFile);
3101 std::string cali_method = line;
3102 str << "cali method: " << cali_method << std::endl;
3103
3104 fgets(line, 255, inpFile);
3105 std::string cali_version = line;
3106 str << "cali version: " << cali_version << std::endl;
3107
3108 fgets(line, 255, inpFile);
3109 std::string cali_type = line;
3110 str << "cali type: " << cali_type;
3111
3112 edm::LogInfo("EcalTrivialConditionRetriever") << "TimeCalibration file - " << str.str() << std::endl;
3113
3114 float calib[1700] = {1};
3115 int calib_status[1700] = {0};
3116
3117 int ii = 0;
3118
3119 while (fgets(line, 255, inpFile)) {
3120 ii++;
3121 int dmy_num = 0;
3122 float dmy_calib = 0.;
3123 float dmy_RMS = 0.;
3124 int dmy_events = 0;
3125 int dmy_status = 0;
3126 sscanf(line, "%d %f %f %d %d", &dmy_num, &dmy_calib, &dmy_RMS, &dmy_events, &dmy_status);
3127 assert(dmy_num >= 1);
3128 assert(dmy_num <= 1700);
3129 calib[dmy_num - 1] = dmy_calib;
3130 calib_status[dmy_num - 1] = dmy_status;
3131
3132
3133
3134
3135
3136
3137
3138
3139 }
3140
3141 fclose(inpFile);
3142 edm::LogInfo("EcalTrivialConditionRetriever") << "Read timeCalibrations for " << ii << " xtals ";
3143 if (ii != 1700)
3144 edm::LogWarning("StoreEcalCondition") << "Some crystals missing, set to 1" << std::endl;
3145
3146
3147
3148
3149
3150 int sm_db = 1;
3151
3152 for (int i = 0; i < 1700; i++) {
3153
3154
3155
3156
3157
3158
3159
3160 if (sm_db >= EBDetId::MIN_SM && sm_db <= EBDetId::MAX_SM) {
3161 EBDetId ebid(sm_db, i + 1, EBDetId::SMCRYSTALMODE);
3162 if (calib_status[i])
3163 ical->setValue(ebid.rawId(), calib[i]);
3164 else
3165 ical->setValue(ebid.rawId(), 1.);
3166 }
3167
3168 }
3169
3170
3171 return ical;
3172 }
3173
3174 std::unique_ptr<EcalTimeCalibErrors> EcalTrivialConditionRetriever::getTimeCalibErrorsFromConfiguration(
3175 const EcalTimeCalibErrorsRcd&) {
3176 auto ical = std::make_unique<EcalTimeCalibErrors>();
3177
3178
3179
3180
3181 edm::LogInfo("EcalTrivialConditionRetriever")
3182 << "Reading timeCalibration constants from file " << timeCalibErrorsFile_.c_str();
3183
3184 FILE* inpFile;
3185 inpFile = fopen(timeCalibErrorsFile_.c_str(), "r");
3186 if (!inpFile) {
3187 edm::LogError("EcalTrivialConditionRetriever") << "*** Can not open file: " << timeCalibErrorsFile_;
3188 throw cms::Exception("Cannot open inter-calibration coefficients txt file");
3189 }
3190
3191 char line[256];
3192 std::ostringstream str;
3193 fgets(line, 255, inpFile);
3194 int sm_number = atoi(line);
3195 str << "sm: " << sm_number;
3196
3197 fgets(line, 255, inpFile);
3198
3199
3200 fgets(line, 255, inpFile);
3201 std::string gen_tag = line;
3202 str << "gen tag: " << gen_tag;
3203
3204 fgets(line, 255, inpFile);
3205 std::string cali_method = line;
3206 str << "cali method: " << cali_method << std::endl;
3207
3208 fgets(line, 255, inpFile);
3209 std::string cali_version = line;
3210 str << "cali version: " << cali_version << std::endl;
3211
3212 fgets(line, 255, inpFile);
3213 std::string cali_type = line;
3214 str << "cali type: " << cali_type;
3215
3216 edm::LogInfo("EcalTrivialConditionRetriever") << "TimeCalibration file - " << str.str() << std::endl;
3217
3218 float calib[1700] = {1};
3219 int calib_status[1700] = {0};
3220
3221 int ii = 0;
3222
3223 while (fgets(line, 255, inpFile)) {
3224 ii++;
3225 int dmy_num = 0;
3226 float dmy_calib = 0.;
3227 float dmy_RMS = 0.;
3228 int dmy_events = 0;
3229 int dmy_status = 0;
3230 sscanf(line, "%d %f %f %d %d", &dmy_num, &dmy_calib, &dmy_RMS, &dmy_events, &dmy_status);
3231 assert(dmy_num >= 1);
3232 assert(dmy_num <= 1700);
3233 calib[dmy_num - 1] = dmy_calib;
3234 calib_status[dmy_num - 1] = dmy_status;
3235
3236
3237
3238
3239
3240
3241
3242
3243 }
3244
3245 fclose(inpFile);
3246 edm::LogInfo("EcalTrivialConditionRetriever") << "Read time calibrations for " << ii << " xtals ";
3247 if (ii != 1700)
3248 edm::LogWarning("StoreEcalCondition") << "Some crystals missing, set to 1" << std::endl;
3249
3250
3251
3252
3253
3254 int sm_db = 1;
3255
3256 for (int i = 0; i < 1700; i++) {
3257
3258
3259
3260
3261
3262
3263
3264 if (sm_db >= EBDetId::MIN_SM && sm_db <= EBDetId::MAX_SM) {
3265 EBDetId ebid(sm_db, i + 1, EBDetId::SMCRYSTALMODE);
3266 if (calib_status[i])
3267 ical->setValue(ebid.rawId(), calib[i]);
3268 else
3269 ical->setValue(ebid.rawId(), 1.);
3270 }
3271
3272 }
3273
3274
3275 return ical;
3276 }
3277
3278
3279
3280 std::unique_ptr<EcalMappingElectronics> EcalTrivialConditionRetriever::getMappingFromConfiguration(
3281 const EcalMappingElectronicsRcd&) {
3282 auto mapping = std::make_unique<EcalMappingElectronics>();
3283 edm::LogInfo("EcalTrivialConditionRetriever")
3284 << "Reading mapping from file " << edm::FileInPath(mappingFile_).fullPath().c_str();
3285
3286 std::ifstream f(edm::FileInPath(mappingFile_).fullPath().c_str());
3287 if (!f.good()) {
3288 edm::LogError("EcalTrivialConditionRetriever") << "File not found";
3289 throw cms::Exception("FileNotFound");
3290 }
3291
3292
3293
3294 int ix, iy, iz, CL;
3295
3296
3297 int dccid, towerid, pseudostrip_in_SC, xtal_in_pseudostrip;
3298 int tccid, tower, pseudostrip_in_TCC, pseudostrip_in_TT;
3299
3300 while (!f.eof()) {
3301
3302 f >> ix >> iy >> iz >> CL >> dccid >> towerid >> pseudostrip_in_SC >> xtal_in_pseudostrip >> tccid >> tower >>
3303 pseudostrip_in_TCC >> pseudostrip_in_TT;
3304
3305
3306
3307
3308 EEDetId detid(ix, iy, iz, EEDetId::XYMODE);
3309
3310 EcalElectronicsId elecid(dccid, towerid, pseudostrip_in_SC, xtal_in_pseudostrip);
3311
3312 EcalTriggerElectronicsId triggerid(tccid, tower, pseudostrip_in_TT, xtal_in_pseudostrip);
3313 EcalMappingElement aElement;
3314 aElement.electronicsid = elecid.rawId();
3315 aElement.triggerid = triggerid.rawId();
3316 (*mapping).setValue(detid, aElement);
3317 }
3318
3319 f.close();
3320 return mapping;
3321 }
3322
3323 std::unique_ptr<EcalMappingElectronics> EcalTrivialConditionRetriever::produceEcalMappingElectronics(
3324 const EcalMappingElectronicsRcd&) {
3325 auto ical = std::make_unique<EcalMappingElectronics>();
3326 return ical;
3327 }
3328
3329
3330
3331 std::unique_ptr<Alignments> EcalTrivialConditionRetriever::produceEcalAlignmentEB(const EBAlignmentRcd&) {
3332 double mytrans[3] = {0., 0., 0.};
3333 double myeuler[3] = {0., 0., 0.};
3334 std::ifstream f;
3335 if (getEBAlignmentFromFile_)
3336 f.open(edm::FileInPath(EBAlignmentFile_).fullPath().c_str());
3337 std::vector<AlignTransform> my_align;
3338 int ieta = 1;
3339 int iphi = 0;
3340 for (int SM = 1; SM < 37; SM++) {
3341
3342 if (SM > 18) {
3343 iphi = 1 + (SM - 19) * 20;
3344 ieta = -1;
3345 } else
3346 iphi = SM * 20;
3347 EBDetId ebdetId(ieta, iphi);
3348 if (getEBAlignmentFromFile_) {
3349 f >> myeuler[0] >> myeuler[1] >> myeuler[2] >> mytrans[0] >> mytrans[1] >> mytrans[2];
3350 edm::LogInfo(" translation ") << mytrans[0] << " " << mytrans[1] << " " << mytrans[2] << "\n"
3351 << " euler " << myeuler[0] << " " << myeuler[1] << " " << myeuler[2];
3352 }
3353 CLHEP::Hep3Vector translation(mytrans[0], mytrans[1], mytrans[2]);
3354 CLHEP::HepEulerAngles euler(myeuler[0], myeuler[1], myeuler[2]);
3355 AlignTransform transform(translation, euler, ebdetId);
3356 my_align.push_back(transform);
3357 }
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379 Alignments a;
3380 a.m_align = my_align;
3381
3382 return std::make_unique<Alignments>(a);
3383 }
3384
3385 std::unique_ptr<Alignments> EcalTrivialConditionRetriever::produceEcalAlignmentEE(const EEAlignmentRcd&) {
3386 double mytrans[3] = {0., 0., 0.};
3387 double myeuler[3] = {0., 0., 0.};
3388 std::ifstream f;
3389 if (getEEAlignmentFromFile_)
3390 f.open(edm::FileInPath(EEAlignmentFile_).fullPath().c_str());
3391 std::vector<AlignTransform> my_align;
3392 int ix = 20;
3393 int iy = 50;
3394 int side = -1;
3395 for (int Dee = 0; Dee < 4; Dee++) {
3396
3397 if (Dee == 1 || Dee == 3)
3398 ix = 70;
3399 else
3400 ix = 20;
3401 if (Dee == 2)
3402 side = 1;
3403 EEDetId eedetId(ix, iy, side);
3404 if (getEEAlignmentFromFile_) {
3405 f >> myeuler[0] >> myeuler[1] >> myeuler[2] >> mytrans[0] >> mytrans[1] >> mytrans[2];
3406 edm::LogInfo(" translation ") << mytrans[0] << " " << mytrans[1] << " " << mytrans[2] << "\n"
3407 << " euler " << myeuler[0] << " " << myeuler[1] << " " << myeuler[2];
3408 }
3409 CLHEP::Hep3Vector translation(mytrans[0], mytrans[1], mytrans[2]);
3410 CLHEP::HepEulerAngles euler(myeuler[0], myeuler[1], myeuler[2]);
3411 AlignTransform transform(translation, euler, eedetId);
3412 my_align.push_back(transform);
3413 }
3414 Alignments a;
3415 a.m_align = my_align;
3416 return std::make_unique<Alignments>(a);
3417 }
3418
3419 std::unique_ptr<Alignments> EcalTrivialConditionRetriever::produceEcalAlignmentES(const ESAlignmentRcd&) {
3420 double mytrans[3] = {0., 0., 0.};
3421 double myeuler[3] = {0., 0., 0.};
3422 std::ifstream f;
3423 if (getESAlignmentFromFile_)
3424 f.open(edm::FileInPath(ESAlignmentFile_).fullPath().c_str());
3425 std::vector<AlignTransform> my_align;
3426
3427 int pl_vect[10] = {2, 2, 1, 1, 1, 1, 2, 2};
3428 int iy = 10;
3429 int side = -1;
3430 int strip = 1;
3431 for (int layer = 0; layer < 8; layer++) {
3432
3433 int ix = 10 + (layer % 2) * 20;
3434 int plane = pl_vect[layer];
3435 if (layer > 3)
3436 side = 1;
3437 ESDetId esdetId(strip, ix, iy, plane, side);
3438 if (getESAlignmentFromFile_) {
3439 f >> myeuler[0] >> myeuler[1] >> myeuler[2] >> mytrans[0] >> mytrans[1] >> mytrans[2];
3440 edm::LogInfo(" translation ") << mytrans[0] << " " << mytrans[1] << " " << mytrans[2] << "\n"
3441 << " euler " << myeuler[0] << " " << myeuler[1] << " " << myeuler[2];
3442 }
3443 CLHEP::Hep3Vector translation(mytrans[0], mytrans[1], mytrans[2]);
3444 CLHEP::HepEulerAngles euler(myeuler[0], myeuler[1], myeuler[2]);
3445 AlignTransform transform(translation, euler, esdetId);
3446 my_align.push_back(transform);
3447 }
3448 Alignments a;
3449 a.m_align = my_align;
3450 return std::make_unique<Alignments>(a);
3451 }
3452
3453 std::unique_ptr<EcalSampleMask> EcalTrivialConditionRetriever::produceEcalSampleMask(const EcalSampleMaskRcd&) {
3454 return std::make_unique<EcalSampleMask>(sampleMaskEB_, sampleMaskEE_);
3455 }
3456
3457 std::unique_ptr<EcalTimeBiasCorrections> EcalTrivialConditionRetriever::produceEcalTimeBiasCorrections(
3458 const EcalTimeBiasCorrectionsRcd&) {
3459 auto ipar = std::make_unique<EcalTimeBiasCorrections>();
3460 copy(EBtimeCorrAmplitudeBins_.begin(), EBtimeCorrAmplitudeBins_.end(), back_inserter(ipar->EBTimeCorrAmplitudeBins));
3461 copy(EBtimeCorrShiftBins_.begin(), EBtimeCorrShiftBins_.end(), back_inserter(ipar->EBTimeCorrShiftBins));
3462 copy(EEtimeCorrAmplitudeBins_.begin(), EEtimeCorrAmplitudeBins_.end(), back_inserter(ipar->EETimeCorrAmplitudeBins));
3463 copy(EEtimeCorrShiftBins_.begin(), EEtimeCorrShiftBins_.end(), back_inserter(ipar->EETimeCorrShiftBins));
3464 return ipar;
3465 }
3466
3467 std::unique_ptr<EcalSamplesCorrelation> EcalTrivialConditionRetriever::produceEcalSamplesCorrelation(
3468 const EcalSamplesCorrelationRcd&) {
3469 if (getSamplesCorrelationFromFile_) {
3470 std::ifstream f;
3471 f.open(edm::FileInPath(SamplesCorrelationFile_).fullPath().c_str());
3472 float ww;
3473 for (int j = 0; j < 10; ++j) {
3474 f >> ww;
3475 EBG12samplesCorrelation_.push_back(ww);
3476 }
3477 for (int j = 0; j < 10; ++j) {
3478 f >> ww;
3479 EBG6samplesCorrelation_.push_back(ww);
3480 }
3481 for (int j = 0; j < 10; ++j) {
3482 f >> ww;
3483 EBG1samplesCorrelation_.push_back(ww);
3484 }
3485 for (int j = 0; j < 10; ++j) {
3486 f >> ww;
3487 EEG12samplesCorrelation_.push_back(ww);
3488 }
3489 for (int j = 0; j < 10; ++j) {
3490 f >> ww;
3491 EEG6samplesCorrelation_.push_back(ww);
3492 }
3493 for (int j = 0; j < 10; ++j) {
3494 f >> ww;
3495 EEG1samplesCorrelation_.push_back(ww);
3496 }
3497 f.close();
3498 }
3499 auto ipar = std::make_unique<EcalSamplesCorrelation>();
3500 copy(EBG12samplesCorrelation_.begin(), EBG12samplesCorrelation_.end(), back_inserter(ipar->EBG12SamplesCorrelation));
3501 copy(EBG6samplesCorrelation_.begin(), EBG6samplesCorrelation_.end(), back_inserter(ipar->EBG6SamplesCorrelation));
3502 copy(EBG1samplesCorrelation_.begin(), EBG1samplesCorrelation_.end(), back_inserter(ipar->EBG1SamplesCorrelation));
3503 copy(EEG12samplesCorrelation_.begin(), EEG12samplesCorrelation_.end(), back_inserter(ipar->EEG12SamplesCorrelation));
3504 copy(EEG6samplesCorrelation_.begin(), EEG6samplesCorrelation_.end(), back_inserter(ipar->EEG6SamplesCorrelation));
3505 copy(EEG1samplesCorrelation_.begin(), EEG1samplesCorrelation_.end(), back_inserter(ipar->EEG1SamplesCorrelation));
3506 return ipar;
3507 }
3508
3509 std::unique_ptr<EcalSimPulseShape> EcalTrivialConditionRetriever::getEcalSimPulseShapeFromConfiguration(
3510 const EcalSimPulseShapeRcd&) {
3511 auto result = std::make_unique<EcalSimPulseShape>();
3512
3513
3514 result->time_interval = sim_pulse_shape_TI_;
3515
3516
3517 std::vector<double> EBshape;
3518 std::vector<double> EEshape;
3519 std::vector<double> APDshape;
3520
3521
3522 if (!EBSimPulseShapeFile_.empty()) {
3523 std::ifstream shapeEBFile;
3524 shapeEBFile.open(EBSimPulseShapeFile_.c_str());
3525 double ww;
3526 while (shapeEBFile >> ww)
3527 EBshape.push_back(ww);
3528 shapeEBFile.close();
3529 }
3530 if (!EESimPulseShapeFile_.empty()) {
3531 std::ifstream shapeEEFile;
3532 shapeEEFile.open(EESimPulseShapeFile_.c_str());
3533 double ww;
3534 while (shapeEEFile >> ww)
3535 EEshape.push_back(ww);
3536 shapeEEFile.close();
3537 }
3538 if (!APDSimPulseShapeFile_.empty()) {
3539 std::ifstream shapeAPDFile;
3540 shapeAPDFile.open(APDSimPulseShapeFile_.c_str());
3541 double ww;
3542 while (shapeAPDFile >> ww)
3543 APDshape.push_back(ww);
3544 shapeAPDFile.close();
3545 }
3546
3547
3548 result->barrel_thresh = sim_pulse_shape_EB_thresh_;
3549 result->endcap_thresh = sim_pulse_shape_EE_thresh_;
3550 result->apd_thresh = sim_pulse_shape_APD_thresh_;
3551
3552
3553 copy(EBshape.begin(), EBshape.end(), back_inserter(result->barrel_shape));
3554 copy(EEshape.begin(), EEshape.end(), back_inserter(result->endcap_shape));
3555 copy(APDshape.begin(), APDshape.end(), back_inserter(result->apd_shape));
3556
3557 return result;
3558 }
3559
3560 std::unique_ptr<EcalSimComponentShape> EcalTrivialConditionRetriever::getEcalSimComponentShapeFromConfiguration(
3561 const EcalSimComponentShapeRcd&) {
3562 auto result = std::make_unique<EcalSimComponentShape>();
3563
3564
3565 result->time_interval = sim_pulse_shape_TI_;
3566
3567
3568 std::vector<std::vector<float> > EBshapes;
3569
3570
3571 if (!EBSimComponentShapeFiles_.empty()) {
3572 int iShape(0);
3573 for (auto filename : EBSimComponentShapeFiles_) {
3574 std::ifstream shapeEBFile;
3575 EBshapes.emplace_back();
3576 shapeEBFile.open(EBSimComponentShapeFiles_[iShape].c_str());
3577 float ww;
3578 while (shapeEBFile >> ww)
3579 EBshapes[iShape].push_back(ww);
3580 shapeEBFile.close();
3581 ++iShape;
3582 }
3583 }
3584
3585
3586 result->barrel_thresh = sim_pulse_shape_EB_thresh_;
3587
3588
3589 copy(EBshapes.begin(), EBshapes.end(), back_inserter(result->barrel_shapes));
3590
3591 return result;
3592 }