CMS 3D CMS Logo

EcalTrivialConditionRetriever.cc
Go to the documentation of this file.
1 //
2 // Created: 2 Mar 2006
3 // Shahram Rahatlou, University of Rome & INFN
4 //
5 #include <fstream>
6 #include <iostream>
7 #include <memory>
8 
9 #include "TRandom3.h"
10 
15 
22 
23 //#include "DataFormats/Provenance/interface/Timestamp.h"
24 
28 
29 using namespace edm;
30 
32  std::string dataPath_ =
33  ps.getUntrackedParameter<std::string>("dataPath", "CalibCalorimetry/EcalTrivialCondModules/data/");
34  // std::string dataPath_ = "CalibCalorimetry/EcalTrivialCondModules/data_test/";
35 
36  /*since CMSSW_10_6_0, this dataPath_ points to https://github.com/cms-data/CalibCalorimetry-EcalTrivialCondModules (extra package).
37 To modify the default values :
38 $ git clone https://github.com/cms-data/CalibCalorimetry-EcalTrivialCondModules.git
39 $ cd CalibCalorimetry-EcalTrivialCondModules
40 $ modify what you want
41 $ git commit -a
42 $ git remote add ModifyCalibCalorimetryExtraPackage git@github.com:yourName/CalibCalorimetry-EcalTrivialCondModules
43 $ git push ModifyCalibCalorimetryExtraPackage master:building-calibCalorimetry-extra-package
44 
45 other solution : change this dataPath name to work directly in afs, ex. :
46 
47  std::string dataPath_="CalibCalorimetry/EcalTrivialCondModules/data_test/";
48 
49  */
50 
51  // initialize parameters used to produce cond DB objects
52  totLumi_ = ps.getUntrackedParameter<double>("TotLumi", 0.0);
53  instLumi_ = ps.getUntrackedParameter<double>("InstLumi", 0.0);
54 
55  // initilize parameters used to produce cond DB objects
56  adcToGeVEBConstant_ = ps.getUntrackedParameter<double>("adcToGeVEBConstant", 0.035);
57  adcToGeVEEConstant_ = ps.getUntrackedParameter<double>("adcToGeVEEConstant", 0.060);
58 
59  intercalibConstantMeanMC_ = ps.getUntrackedParameter<double>("intercalibConstantMeanMC", 1.0);
60  intercalibConstantSigmaMC_ = ps.getUntrackedParameter<double>("intercalibConstantSigmaMC", 0.0);
61 
62  linCorrMean_ = ps.getUntrackedParameter<double>("linCorrMean", 1.0);
63  linCorrSigma_ = ps.getUntrackedParameter<double>("linCorrSigma", 0.0);
64 
65  linearTime1_ = (unsigned long)atoi(ps.getUntrackedParameter<std::string>("linearTime1", "1").c_str());
66  linearTime2_ = (unsigned long)atoi(ps.getUntrackedParameter<std::string>("linearTime2", "0").c_str());
67  linearTime3_ = (unsigned long)atoi(ps.getUntrackedParameter<std::string>("linearTime3", "0").c_str());
68 
69  intercalibConstantMean_ = ps.getUntrackedParameter<double>("intercalibConstantMean", 1.0);
70  intercalibConstantSigma_ = ps.getUntrackedParameter<double>("intercalibConstantSigma", 0.0);
71  intercalibErrorMean_ = ps.getUntrackedParameter<double>("IntercalibErrorMean", 0.0);
72 
73  timeCalibConstantMean_ = ps.getUntrackedParameter<double>("timeCalibConstantMean", 0.0);
74  timeCalibConstantSigma_ = ps.getUntrackedParameter<double>("timeCalibConstantSigma", 0.0);
75  timeCalibErrorMean_ = ps.getUntrackedParameter<double>("timeCalibErrorMean", 0.0);
76 
77  timeOffsetEBConstant_ = ps.getUntrackedParameter<double>("timeOffsetEBConstant", 0.0);
78  timeOffsetEEConstant_ = ps.getUntrackedParameter<double>("timeOffsetEEConstant", 0.0);
79 
80  laserAlphaMean_ = ps.getUntrackedParameter<double>("laserAlphaMean", 1.55);
81  laserAlphaSigma_ = ps.getUntrackedParameter<double>("laserAlphaSigma", 0);
82 
83  laserAPDPNTime1_ = (unsigned long)atoi(ps.getUntrackedParameter<std::string>("laserAPDPNTime1", "1").c_str());
84  laserAPDPNTime2_ = (unsigned long)atoi(ps.getUntrackedParameter<std::string>("laserAPDPNTime2", "0").c_str());
85  laserAPDPNTime3_ = (unsigned long)atoi(ps.getUntrackedParameter<std::string>("laserAPDPNTime3", "0").c_str());
86 
87  laserAPDPNRefMean_ = ps.getUntrackedParameter<double>("laserAPDPNRefMean", 1.0);
88  laserAPDPNRefSigma_ = ps.getUntrackedParameter<double>("laserAPDPNRefSigma", 0.0);
89 
90  laserAPDPNMean_ = ps.getUntrackedParameter<double>("laserAPDPNMean", 1.0);
91  laserAPDPNSigma_ = ps.getUntrackedParameter<double>("laserAPDPNSigma", 0.0);
92 
93  pfRecHitThresholdsNSigmas_ = ps.getUntrackedParameter<double>("EcalPFRecHitThresholdNSigmas", 1.0);
94  pfRecHitThresholdsNSigmasHEta_ = ps.getUntrackedParameter<double>("EcalPFRecHitThresholdNSigmasHEta", 1.0);
95  pfRecHitThresholdsEB_ = ps.getUntrackedParameter<double>("EcalPFRecHitThresholdEB", 0.0);
96  pfRecHitThresholdsEE_ = ps.getUntrackedParameter<double>("EcalPFRecHitThresholdEE", 0.0);
97 
98  localContCorrParameters_ =
99  ps.getUntrackedParameter<std::vector<double> >("localContCorrParameters", std::vector<double>(0));
100  crackCorrParameters_ = ps.getUntrackedParameter<std::vector<double> >("crackCorrParameters", std::vector<double>(0));
101  energyCorrectionParameters_ =
102  ps.getUntrackedParameter<std::vector<double> >("energyCorrectionParameters", std::vector<double>(0));
103  energyUncertaintyParameters_ =
104  ps.getUntrackedParameter<std::vector<double> >("energyUncertaintyParameters", std::vector<double>(0));
105  energyCorrectionObjectSpecificParameters_ = ps.getUntrackedParameter<std::vector<double> >(
106  "energyCorrectionObjectSpecificParameters", std::vector<double>(0));
107 
108  EBpedMeanX12_ = ps.getUntrackedParameter<double>("EBpedMeanX12", 200.);
109  EBpedRMSX12_ = ps.getUntrackedParameter<double>("EBpedRMSX12", 1.10);
110  EBpedMeanX6_ = ps.getUntrackedParameter<double>("EBpedMeanX6", 200.);
111  EBpedRMSX6_ = ps.getUntrackedParameter<double>("EBpedRMSX6", 0.90);
112  EBpedMeanX1_ = ps.getUntrackedParameter<double>("EBpedMeanX1", 200.);
113  EBpedRMSX1_ = ps.getUntrackedParameter<double>("EBpedRMSX1", 0.62);
114 
115  EEpedMeanX12_ = ps.getUntrackedParameter<double>("EEpedMeanX12", 200.);
116  EEpedRMSX12_ = ps.getUntrackedParameter<double>("EEpedRMSX12", 2.50);
117  EEpedMeanX6_ = ps.getUntrackedParameter<double>("EEpedMeanX6", 200.);
118  EEpedRMSX6_ = ps.getUntrackedParameter<double>("EEpedRMSX6", 2.00);
119  EEpedMeanX1_ = ps.getUntrackedParameter<double>("EEpedMeanX1", 200.);
120  EEpedRMSX1_ = ps.getUntrackedParameter<double>("EEpedRMSX1", 1.40);
121 
122  gainRatio12over6_ = ps.getUntrackedParameter<double>("gainRatio12over6", 2.0);
123  gainRatio6over1_ = ps.getUntrackedParameter<double>("gainRatio6over1", 6.0);
124 
125  getWeightsFromFile_ = ps.getUntrackedParameter<bool>("getWeightsFromFile", false);
126 
127  sampleMaskEB_ = ps.getUntrackedParameter<unsigned int>("sampleMaskEB", 1023);
128  sampleMaskEE_ = ps.getUntrackedParameter<unsigned int>("sampleMaskEB", 1023);
129 
130  EBtimeCorrAmplitudeBins_ =
131  ps.getUntrackedParameter<std::vector<double> >("EBtimeCorrAmplitudeBins", std::vector<double>());
132  EBtimeCorrShiftBins_ = ps.getUntrackedParameter<std::vector<double> >("EBtimeCorrShiftBins", std::vector<double>());
133  EEtimeCorrAmplitudeBins_ =
134  ps.getUntrackedParameter<std::vector<double> >("EEtimeCorrAmplitudeBins", std::vector<double>());
135  EEtimeCorrShiftBins_ = ps.getUntrackedParameter<std::vector<double> >("EEtimeCorrShiftBins", std::vector<double>());
136 
137  EBG12samplesCorrelation_ =
138  ps.getUntrackedParameter<std::vector<double> >("EBG12samplesCorrelation", std::vector<double>());
139  EBG6samplesCorrelation_ =
140  ps.getUntrackedParameter<std::vector<double> >("EBG6samplesCorrelation", std::vector<double>());
141  EBG1samplesCorrelation_ =
142  ps.getUntrackedParameter<std::vector<double> >("EBG1samplesCorrelation", std::vector<double>());
143  EEG12samplesCorrelation_ =
144  ps.getUntrackedParameter<std::vector<double> >("EEG12samplesCorrelation", std::vector<double>());
145  EEG6samplesCorrelation_ =
146  ps.getUntrackedParameter<std::vector<double> >("EEG6samplesCorrelation", std::vector<double>());
147  EEG1samplesCorrelation_ =
148  ps.getUntrackedParameter<std::vector<double> >("EEG1samplesCorrelation", std::vector<double>());
149 
150  sim_pulse_shape_EB_thresh_ = ps.getParameter<double>("sim_pulse_shape_EB_thresh");
151  sim_pulse_shape_EE_thresh_ = ps.getParameter<double>("sim_pulse_shape_EE_thresh");
152  sim_pulse_shape_APD_thresh_ = ps.getParameter<double>("sim_pulse_shape_APD_thresh");
153 
154  sim_pulse_shape_TI_ = ps.getUntrackedParameter<double>("sim_pulse_shape_TI", 1.0);
155 
156  nTDCbins_ = 1;
157 
158  weightsForAsynchronousRunning_ = ps.getUntrackedParameter<bool>("weightsForTB", false);
159 
160  edm::LogInfo(" EcalTrivialConditionRetriever ");
161 
162  if (totLumi_ > 0) {
163  edm::LogInfo(" EcalTrivialConditionRetriever going to create conditions based on the damage due to ")
164  << totLumi_ << " fb-1 integrated luminosity";
165  }
166 
167  if (weightsForAsynchronousRunning_) {
168  getWeightsFromFile_ = true; //override user request
169  //nTDCbins_ = 25;
170  nTDCbins_ = 50; //modif Alex-21-07-2006
171  }
172 
173  std::string weightType;
174  std::ostringstream str;
175 
176  if (!weightsForAsynchronousRunning_)
177  str << "_CMS.txt";
178  else
179  str << "_TB.txt";
180 
181  weightType = str.str();
182 
183  amplWeightsFile_ = ps.getUntrackedParameter<std::string>("amplWeightsFile", dataPath_ + "ampWeights" + weightType);
184  amplWeightsAftFile_ =
185  ps.getUntrackedParameter<std::string>("amplWeightsAftFile", dataPath_ + "ampWeightsAfterGainSwitch" + weightType);
186  pedWeightsFile_ = ps.getUntrackedParameter<std::string>("pedWeightsFile", dataPath_ + "pedWeights" + weightType);
187  pedWeightsAftFile_ =
188  ps.getUntrackedParameter<std::string>("pedWeightsAftFile", dataPath_ + "pedWeightsAfterGainSwitch" + weightType);
189  jittWeightsFile_ = ps.getUntrackedParameter<std::string>("jittWeightsFile", dataPath_ + "timeWeights" + weightType);
190  jittWeightsAftFile_ = ps.getUntrackedParameter<std::string>("jittWeightsAftFile",
191  dataPath_ + "timeWeightsAfterGainSwitch" + weightType);
192  chi2MatrixFile_ = ps.getUntrackedParameter<std::string>("chi2MatrixFile", dataPath_ + "chi2Matrix" + weightType);
193  chi2MatrixAftFile_ =
194  ps.getUntrackedParameter<std::string>("chi2MatrixAftFile", dataPath_ + "chi2MatrixAfterGainSwitch" + weightType);
195 
196  amplWeights_.resize(nTDCbins_);
197  amplWeightsAft_.resize(nTDCbins_);
198  pedWeights_.resize(nTDCbins_);
199  pedWeightsAft_.resize(nTDCbins_);
200  jittWeights_.resize(nTDCbins_);
201  jittWeightsAft_.resize(nTDCbins_);
202  chi2Matrix_.resize(nTDCbins_);
203  chi2MatrixAft_.resize(nTDCbins_);
204 
205  // default weights for MGPA shape after pedestal subtraction
206  getWeightsFromConfiguration(ps);
207 
208  producedEcalPedestals_ = ps.getUntrackedParameter<bool>("producedEcalPedestals", true);
209  producedEcalWeights_ = ps.getUntrackedParameter<bool>("producedEcalWeights", true);
210 
211  producedEcalGainRatios_ = ps.getUntrackedParameter<bool>("producedEcalGainRatios", true);
212  producedEcalADCToGeVConstant_ = ps.getUntrackedParameter<bool>("producedEcalADCToGeVConstant", true);
213 
214  producedEcalMappingElectronics_ = ps.getUntrackedParameter<bool>("producedEcalMappingElectronics", true);
215  mappingFile_ = ps.getUntrackedParameter<std::string>("mappingFile", "");
216 
217  if (producedEcalMappingElectronics_) {
218  if (!mappingFile_.empty()) { // if file provided read channel map
220  } else {
222  }
223  findingRecord<EcalMappingElectronicsRcd>();
224  }
225  // Alignment from file
226  getEBAlignmentFromFile_ = ps.getUntrackedParameter<bool>("getEBAlignmentFromFile", false);
227  if (getEBAlignmentFromFile_) {
228  EBAlignmentFile_ = ps.getUntrackedParameter<std::string>("EBAlignmentFile", dataPath_ + "EBAlignment.txt");
229  }
230 
231  getEEAlignmentFromFile_ = ps.getUntrackedParameter<bool>("getEEAlignmentFromFile", false);
232  if (getEEAlignmentFromFile_) {
233  EEAlignmentFile_ = ps.getUntrackedParameter<std::string>("EEAlignmentFile", dataPath_ + "EEAlignment.txt");
234  }
235 
236  getESAlignmentFromFile_ = ps.getUntrackedParameter<bool>("getESAlignmentFromFile", false);
237  if (getESAlignmentFromFile_)
238  ESAlignmentFile_ = ps.getUntrackedParameter<std::string>("ESAlignmentFile", dataPath_ + "ESAlignment.txt");
239 
240  verbose_ = ps.getUntrackedParameter<int>("verbose", 0);
241 
242  //Tell Producer what we produce
243  //setWhatproduce(this);
244  if (producedEcalPedestals_)
246 
247  if (producedEcalWeights_) {
250  }
251 
252  if (producedEcalGainRatios_)
254 
255  if (producedEcalADCToGeVConstant_)
257 
258  // TimeOffsetConstant
259  producedEcalTimeOffsetConstant_ = ps.getUntrackedParameter<bool>("producedEcalTimeOffsetConstant", true);
260  //std::cout << " EcalTrivialConditionRetriever : producedEcalTimeOffsetConstant_" << producedEcalTimeOffsetConstant_ << std::endl;
261  if (producedEcalTimeOffsetConstant_) {
263  findingRecord<EcalTimeOffsetConstantRcd>();
264  }
265 
266  // linear corrections
267  producedEcalLinearCorrections_ = ps.getUntrackedParameter<bool>("producedEcalLinearCorrections", true);
268  linearCorrectionsFile_ = ps.getUntrackedParameter<std::string>("linearCorrectionsFile", "");
269 
270  if (producedEcalLinearCorrections_) { // user asks to produce constants
271  if (!linearCorrectionsFile_.empty()) { // if file provided read constants
273  } else { // set all constants to 1. or smear as specified by user
275  }
276  findingRecord<EcalLinearCorrectionsRcd>();
277  }
278 
279  // intercalibration constants
280  producedEcalIntercalibConstants_ = ps.getUntrackedParameter<bool>("producedEcalIntercalibConstants", true);
281  intercalibConstantsFile_ = ps.getUntrackedParameter<std::string>("intercalibConstantsFile", "");
282 
283  intercalibConstantsMCFile_ = ps.getUntrackedParameter<std::string>("intercalibConstantsMCFile", "");
284 
285  if (producedEcalIntercalibConstants_) { // user asks to produce constants
286  if (!intercalibConstantsFile_.empty()) { // if file provided read constants
288  } else { // set all constants to 1. or smear as specified by user
290  }
291  findingRecord<EcalIntercalibConstantsRcd>();
292  }
293  // MC intercalibrations
294  producedEcalIntercalibConstantsMC_ = ps.getUntrackedParameter<bool>("producedEcalIntercalibConstantsMC", true);
295 
296  if (producedEcalIntercalibConstantsMC_) { // user asks to produce constants
297  if (!intercalibConstantsMCFile_.empty()) { // if file provided read constants
299  } else { // set all constants to 1. or smear as specified by user
301  }
302  findingRecord<EcalIntercalibConstantsMCRcd>();
303  }
304 
305  // intercalibration constants
306  producedEcalIntercalibErrors_ = ps.getUntrackedParameter<bool>("producedEcalIntercalibErrors", true);
307  intercalibErrorsFile_ = ps.getUntrackedParameter<std::string>("intercalibErrorsFile", "");
308 
309  if (producedEcalIntercalibErrors_) { // user asks to produce constants
310  if (!intercalibErrorsFile_.empty()) { // if file provided read constants
312  } else { // set all constants to 1. or smear as specified by user
314  }
315  findingRecord<EcalIntercalibErrorsRcd>();
316  }
317 
318  // time calibration constants
319  producedEcalTimeCalibConstants_ = ps.getUntrackedParameter<bool>("producedEcalTimeCalibConstants", true);
320  timeCalibConstantsFile_ = ps.getUntrackedParameter<std::string>("timeCalibConstantsFile", "");
321 
322  if (producedEcalTimeCalibConstants_) { // user asks to produce constants
323  if (!timeCalibConstantsFile_.empty()) { // if file provided read constants
325  } else { // set all constants to 1. or smear as specified by user
327  }
328  findingRecord<EcalTimeCalibConstantsRcd>();
329  }
330 
331  // time calibration constants
332  producedEcalTimeCalibErrors_ = ps.getUntrackedParameter<bool>("producedEcalTimeCalibErrors", true);
333  timeCalibErrorsFile_ = ps.getUntrackedParameter<std::string>("timeCalibErrorsFile", "");
334 
335  if (producedEcalTimeCalibErrors_) { // user asks to produce constants
336  if (!timeCalibErrorsFile_.empty()) { // if file provided read constants
338  } else { // set all constants to 1. or smear as specified by user
340  }
341  findingRecord<EcalTimeCalibErrorsRcd>();
342  }
343 
344  // sim pulse shape
345  getSimPulseShapeFromFile_ = ps.getUntrackedParameter<bool>("getSimPulseShapeFromFile", false);
346  producedEcalSimPulseShape_ = ps.getUntrackedParameter<bool>("producedEcalSimPulseShape", true);
347  EBSimPulseShapeFile_ = ps.getUntrackedParameter<std::string>("EBSimPulseShapeFile", "");
348  EESimPulseShapeFile_ = ps.getUntrackedParameter<std::string>("EESimPulseShapeFile", "");
349  APDSimPulseShapeFile_ = ps.getUntrackedParameter<std::string>("APDSimPulseShapeFile", "");
350 
351  if (producedEcalSimPulseShape_) { // user asks to produce constants
353  findingRecord<EcalSimPulseShapeRcd>();
354  }
355 
356  producedEcalPFRecHitThresholds_ = ps.getUntrackedParameter<bool>("producedEcalPFRecHitThresholds", false);
357 
358  // new for PFRecHit Thresholds
359  pfRecHitFile_ = ps.getUntrackedParameter<std::string>("pFRecHitFile", dataPath_ + "EB_product_TL235.txt");
360  pfRecHitFileEE_ = ps.getUntrackedParameter<std::string>("pFRecHitFileEE", dataPath_ + "EE_product_TL235.txt");
361 
362  if (producedEcalPFRecHitThresholds_) { // user asks to produce constants
363  if (!pfRecHitFile_.empty()) { // if file provided read constants
365  } else { // set all constants to 0
367  }
368  findingRecord<EcalPFRecHitThresholdsRcd>();
369  }
370 
371  // cluster corrections
372  producedEcalClusterLocalContCorrParameters_ =
373  ps.getUntrackedParameter<bool>("producedEcalClusterLocalContCorrParameters", false);
374  producedEcalClusterCrackCorrParameters_ =
375  ps.getUntrackedParameter<bool>("producedEcalClusterCrackCorrParameters", false);
376  producedEcalClusterEnergyCorrectionParameters_ =
377  ps.getUntrackedParameter<bool>("producedEcalClusterEnergyCorrectionParameters", false);
378  producedEcalClusterEnergyUncertaintyParameters_ =
379  ps.getUntrackedParameter<bool>("producedEcalClusterEnergyUncertaintyParameters", false);
380  producedEcalClusterEnergyCorrectionObjectSpecificParameters_ =
381  ps.getUntrackedParameter<bool>("producedEcalClusterEnergyCorrectionObjectSpecificParameters", false);
382  if (producedEcalClusterLocalContCorrParameters_) {
384  findingRecord<EcalClusterLocalContCorrParametersRcd>();
385  }
386  if (producedEcalClusterCrackCorrParameters_) {
388  findingRecord<EcalClusterCrackCorrParametersRcd>();
389  }
390  if (producedEcalClusterEnergyCorrectionParameters_) {
392  findingRecord<EcalClusterEnergyCorrectionParametersRcd>();
393  }
394  if (producedEcalClusterEnergyUncertaintyParameters_) {
396  findingRecord<EcalClusterEnergyUncertaintyParametersRcd>();
397  }
398  if (producedEcalClusterEnergyCorrectionObjectSpecificParameters_) {
400  findingRecord<EcalClusterEnergyCorrectionObjectSpecificParametersRcd>();
401  }
402 
403  // laser correction
404  producedEcalLaserCorrection_ = ps.getUntrackedParameter<bool>("producedEcalLaserCorrection", false);
405  if (producedEcalLaserCorrection_) { // user asks to produce constants
406  // set all constants to 1. or smear as specified by user
408  findingRecord<EcalLaserAlphasRcd>();
409  getLaserAlphaFromFileEB_ = ps.getUntrackedParameter<bool>("getLaserAlphaFromFileEB", false);
410  getLaserAlphaFromFileEE_ = ps.getUntrackedParameter<bool>("getLaserAlphaFromFileEE", false);
411  getLaserAlphaFromTypeEB_ = ps.getUntrackedParameter<bool>("getLaserAlphaFromTypeEB", false);
412  getLaserAlphaFromTypeEE_ = ps.getUntrackedParameter<bool>("getLaserAlphaFromTypeEE", false);
413  edm::LogInfo(" getLaserAlphaFromFileEB_ ") << getLaserAlphaFromFileEB_;
414  edm::LogInfo(" getLaserAlphaFromFileEE_ ") << getLaserAlphaFromFileEE_;
415  edm::LogInfo(" getLaserAlphaFromTypeEB_ ") << getLaserAlphaFromTypeEB_;
416  edm::LogInfo(" getLaserAlphaFromTypeEE_ ") << getLaserAlphaFromTypeEE_;
417  if (getLaserAlphaFromFileEB_) {
418  EBLaserAlphaFile_ = ps.getUntrackedParameter<std::string>(
419  "EBLaserAlphaFile", dataPath_ + "EBLaserAlpha.txt"); // file is used to read the alphas
420  }
421  if (getLaserAlphaFromFileEE_) {
422  EELaserAlphaFile_ = ps.getUntrackedParameter<std::string>(
423  "EELaserAlphaFile", dataPath_ + "EELaserAlpha.txt"); // file is used to read the alphas
424  }
425  if (getLaserAlphaFromTypeEB_) {
426  laserAlphaMeanEBR_ = ps.getUntrackedParameter<double>("laserAlphaMeanEBR", 1.55); // alpha russian crystals in EB
427  laserAlphaMeanEBC_ = ps.getUntrackedParameter<double>("laserAlphaMeanEBC", 1.00); // alpha chinese crystals in EB
428  EBLaserAlphaFile_ = ps.getUntrackedParameter<std::string>(
429  "EBLaserAlphaFile", dataPath_ + "EBLaserAlpha.txt"); // file to find out which one is russian/chinese
430  }
431  if (getLaserAlphaFromTypeEE_) {
432  laserAlphaMeanEEC_higheta_ = ps.getUntrackedParameter<double>("laserAlphaMeanEEC_higheta",
433  1.00); // alpha chinese crystals in EE for eta>2.5
434  laserAlphaMeanEER_higheta_ = ps.getUntrackedParameter<double>("laserAlphaMeanEER_higheta",
435  1.16); // alpha russian crystals in EE for eta>2
436  laserAlphaMeanEER_ = ps.getUntrackedParameter<double>("laserAlphaMeanEER", 1.16); // alpha russian crystals in EE
437  laserAlphaMeanEEC_ = ps.getUntrackedParameter<double>("laserAlphaMeanEEC", 1.00); // alpha chinese crystals in EE
438  EELaserAlphaFile_ = ps.getUntrackedParameter<std::string>(
439  "EELaserAlphaFile",
440  dataPath_ + "EELaserAlpha.txt"); // file is used to find out which one is russian or chinese
441  EELaserAlphaFile2_ = ps.getUntrackedParameter<std::string>(
442  "EELaserAlphaFile2", dataPath_ + "EELaserAlpha2.txt"); // file is used to read the alphas
443  }
445  findingRecord<EcalLaserAPDPNRatiosRefRcd>();
447  findingRecord<EcalLaserAPDPNRatiosRcd>();
448  }
449 
450  // channel status
451  producedEcalChannelStatus_ = ps.getUntrackedParameter<bool>("producedEcalChannelStatus", true);
452  channelStatusFile_ = ps.getUntrackedParameter<std::string>("channelStatusFile", "");
453 
454  if (producedEcalChannelStatus_) {
455  if (!channelStatusFile_.empty()) { // if file provided read channel map
457  } else { // set all channels to working -- FIXME might be changed
459  }
460  findingRecord<EcalChannelStatusRcd>();
461  }
462  // DQM channel status
463  producedEcalDQMChannelStatus_ = ps.getUntrackedParameter<bool>("producedEcalDQMChannelStatus", true);
464  if (producedEcalDQMChannelStatus_) {
466  findingRecord<EcalDQMChannelStatusRcd>();
467  }
468  // DCS Tower status
469  producedEcalDCSTowerStatus_ = ps.getUntrackedParameter<bool>("producedEcalDCSTowerStatus", true);
470  if (producedEcalDCSTowerStatus_) {
472  findingRecord<EcalDCSTowerStatusRcd>();
473  }
474  // DAQ Tower status
475  producedEcalDAQTowerStatus_ = ps.getUntrackedParameter<bool>("producedEcalDAQTowerStatus", true);
476  if (producedEcalDAQTowerStatus_) {
478  findingRecord<EcalDAQTowerStatusRcd>();
479  }
480  // DQM Tower status
481  producedEcalDQMTowerStatus_ = ps.getUntrackedParameter<bool>("producedEcalDQMTowerStatus", true);
482  if (producedEcalDQMTowerStatus_) {
484  findingRecord<EcalDQMTowerStatusRcd>();
485  }
486 
487  // trigger channel status
488  producedEcalTrgChannelStatus_ = ps.getUntrackedParameter<bool>("producedEcalTrgChannelStatus", true);
489  trgChannelStatusFile_ = ps.getUntrackedParameter<std::string>("trgChannelStatusFile", "");
490 
491  if (producedEcalTrgChannelStatus_) {
492  if (!trgChannelStatusFile_.empty()) { // if file provided read channel map
494  } else { // set all channels to working -- FIXME might be changed
496  }
497  findingRecord<EcalTPGCrystalStatusRcd>();
498  }
499 
500  // Alignment
501  producedEcalAlignmentEB_ = ps.getUntrackedParameter<bool>("producedEcalAlignmentEB", true);
502  if (producedEcalAlignmentEB_) {
504  findingRecord<EBAlignmentRcd>();
505  }
506  producedEcalAlignmentEE_ = ps.getUntrackedParameter<bool>("producedEcalAlignmentEE", true);
507  if (producedEcalAlignmentEE_) {
509  findingRecord<EEAlignmentRcd>();
510  }
511  producedEcalAlignmentES_ = ps.getUntrackedParameter<bool>("producedEcalAlignmentES", true);
512  if (producedEcalAlignmentES_) {
514  findingRecord<ESAlignmentRcd>();
515  }
516  //Tell Finder what records we find
517  if (producedEcalPedestals_)
518  findingRecord<EcalPedestalsRcd>();
519 
520  if (producedEcalWeights_) {
521  findingRecord<EcalWeightXtalGroupsRcd>();
522  findingRecord<EcalTBWeightsRcd>();
523  }
524 
525  if (producedEcalGainRatios_)
526  findingRecord<EcalGainRatiosRcd>();
527 
528  if (producedEcalADCToGeVConstant_)
529  findingRecord<EcalADCToGeVConstantRcd>();
530 
531  producedEcalSampleMask_ = ps.getUntrackedParameter<bool>("producedEcalSampleMask", true);
532  if (producedEcalSampleMask_) {
534  findingRecord<EcalSampleMaskRcd>();
535  }
536  producedEcalTimeBiasCorrections_ = ps.getUntrackedParameter<bool>("producedEcalTimeBiasCorrections", false);
537  if (producedEcalTimeBiasCorrections_) {
539  findingRecord<EcalTimeBiasCorrectionsRcd>();
540  }
541  producedEcalSamplesCorrelation_ = ps.getUntrackedParameter<bool>("producedEcalSamplesCorrelation", false);
542  if (producedEcalSamplesCorrelation_) {
544  findingRecord<EcalSamplesCorrelationRcd>();
545  getSamplesCorrelationFromFile_ = ps.getUntrackedParameter<bool>("getSamplesCorrelationFromFile", false);
546  if (getSamplesCorrelationFromFile_) {
547  SamplesCorrelationFile_ =
548  ps.getUntrackedParameter<std::string>("SamplesCorrelationFile", "EcalSamplesCorrelation.txt");
549  }
550  }
551 }
552 
554 
555 //
556 // member functions
557 //
559  const edm::IOVSyncValue& iTime,
560  edm::ValidityInterval& oValidity) {
561  if (verbose_ >= 1)
562  edm::LogInfo("EcalTrivialConditionRetriever::setIntervalFor(): record key = ")
563  << rk.name() << "\ttime: " << iTime.time().value();
564  //For right now, we will just use an infinite interval of validity
566 }
567 
568 //produce methods
570  auto peds = std::make_unique<EcalPedestals>();
571  EcalPedestals::Item EBitem;
572  EcalPedestals::Item EEitem;
573 
574  EBitem.mean_x1 = EBpedMeanX1_;
575  EBitem.rms_x1 = EBpedRMSX1_;
576  EBitem.mean_x6 = EBpedMeanX6_;
577  EBitem.rms_x6 = EBpedRMSX6_;
578  EBitem.mean_x12 = EBpedMeanX12_;
579  EBitem.rms_x12 = EBpedRMSX12_;
580 
581  EEitem.mean_x1 = EEpedMeanX1_;
582  EEitem.rms_x1 = EEpedRMSX1_;
583  EEitem.mean_x6 = EEpedMeanX6_;
584  EEitem.rms_x6 = EEpedRMSX6_;
585  EEitem.mean_x12 = EEpedMeanX12_;
586  EEitem.rms_x12 = EEpedRMSX12_;
587 
588  for (int iEta = -EBDetId::MAX_IETA; iEta <= EBDetId::MAX_IETA; ++iEta) {
589  if (iEta == 0)
590  continue;
591 
592  if (totLumi_ > 0) {
593  double eta = EBDetId::approxEta(EBDetId(iEta, 1));
594 
595  EnergyResolutionVsLumi ageing;
596  ageing.setLumi(totLumi_);
597  ageing.setInstLumi(instLumi_);
598  eta = fabs(eta);
599  double noisefactor = ageing.calcnoiseIncreaseADC(eta);
600 
601  EBitem.rms_x1 = EBpedRMSX1_ * noisefactor;
602  EBitem.rms_x6 = EBpedRMSX6_ * noisefactor;
603  EBitem.rms_x12 = EBpedRMSX12_ * noisefactor;
604  edm::LogInfo("rms ped at eta:") << eta << " =" << EBitem.rms_x12;
605  }
606 
607  for (int iPhi = EBDetId::MIN_IPHI; iPhi <= EBDetId::MAX_IPHI; ++iPhi) {
608  // make an EBDetId since we need EBDetId::rawId() to be used as the key for the pedestals
609  if (EBDetId::validDetId(iEta, iPhi)) {
610  EBDetId ebdetid(iEta, iPhi);
611  peds->insert(std::make_pair(ebdetid.rawId(), EBitem));
612  }
613  }
614  }
615 
616  for (int iX = EEDetId::IX_MIN; iX <= EEDetId::IX_MAX; ++iX) {
617  for (int iY = EEDetId::IY_MIN; iY <= EEDetId::IY_MAX; ++iY) {
618  // make an EEDetId since we need EEDetId::rawId() to be used as the key for the pedestals
619  if (EEDetId::validDetId(iX, iY, 1)) {
620  EEDetId eedetidpos(iX, iY, 1);
621  peds->insert(std::make_pair(eedetidpos.rawId(), EEitem));
622  }
623  if (EEDetId::validDetId(iX, iY, -1)) {
624  EEDetId eedetidneg(iX, iY, -1);
625  peds->insert(std::make_pair(eedetidneg.rawId(), EEitem));
626  }
627  }
628  }
629 
630  //return std::unique_ptr<EcalPedestals>( peds );
631  return peds;
632 }
633 
635  const EcalWeightXtalGroupsRcd&) {
636  auto xtalGroups = std::make_unique<EcalWeightXtalGroups>();
637  EcalXtalGroupId defaultGroupId(1);
638  for (int ieta = -EBDetId::MAX_IETA; ieta <= EBDetId::MAX_IETA; ++ieta) {
639  if (ieta == 0)
640  continue;
641  for (int iphi = EBDetId::MIN_IPHI; iphi <= EBDetId::MAX_IPHI; ++iphi) {
642  // make an EBDetId since we need EBDetId::rawId() to be used as the key for the pedestals
643  if (EBDetId::validDetId(ieta, iphi)) {
644  EBDetId ebid(ieta, iphi);
645  // xtalGroups->setValue(ebid.rawId(), EcalXtalGroupId(ieta) ); // define rings in eta
646  xtalGroups->setValue(ebid.rawId(), defaultGroupId); // define rings in eta
647  }
648  }
649  }
650 
651  for (int iX = EEDetId::IX_MIN; iX <= EEDetId::IX_MAX; ++iX) {
652  for (int iY = EEDetId::IY_MIN; iY <= EEDetId::IY_MAX; ++iY) {
653  // make an EEDetId since we need EEDetId::rawId() to be used as the key for the pedestals
654  if (EEDetId::validDetId(iX, iY, 1)) {
655  EEDetId eedetidpos(iX, iY, 1);
656  xtalGroups->setValue(eedetidpos.rawId(), defaultGroupId);
657  }
658  if (EEDetId::validDetId(iX, iY, -1)) {
659  EEDetId eedetidneg(iX, iY, -1);
660  xtalGroups->setValue(eedetidneg.rawId(), defaultGroupId);
661  }
662  }
663  }
664  return xtalGroups;
665 }
666 
667 std::unique_ptr<EcalLinearCorrections> EcalTrivialConditionRetriever::produceEcalLinearCorrections(
668  const EcalLinearCorrectionsRcd&) {
669  auto ical = std::make_unique<EcalLinearCorrections>();
670 
671  for (int ieta = -EBDetId::MAX_IETA; ieta <= EBDetId::MAX_IETA; ++ieta) {
672  if (ieta == 0)
673  continue;
674  for (int iphi = EBDetId::MIN_IPHI; iphi <= EBDetId::MAX_IPHI; ++iphi) {
675  if (EBDetId::validDetId(ieta, iphi)) {
676  EBDetId ebid(ieta, iphi);
677  double r = (double)std::rand() / (double(RAND_MAX) + double(1));
678 
680  pairAPDPN.p1 = linCorrMean_ + r * linCorrSigma_;
681  pairAPDPN.p2 = linCorrMean_ + r * linCorrSigma_;
682  pairAPDPN.p3 = linCorrMean_ + r * linCorrSigma_;
683  ical->setValue(ebid, pairAPDPN);
684  }
685  }
686  }
687 
688  for (int iX = EEDetId::IX_MIN; iX <= EEDetId::IX_MAX; ++iX) {
689  for (int iY = EEDetId::IY_MIN; iY <= EEDetId::IY_MAX; ++iY) {
690  // make an EEDetId since we need EEDetId::rawId() to be used as the key for the pedestals
691  if (EEDetId::validDetId(iX, iY, 1)) {
692  double r = (double)std::rand() / (double(RAND_MAX) + double(1));
693  EEDetId eedetidpos(iX, iY, 1);
694 
696  pairAPDPN.p1 = linCorrMean_ + r * linCorrSigma_;
697  pairAPDPN.p2 = linCorrMean_ + r * linCorrSigma_;
698  pairAPDPN.p3 = linCorrMean_ + r * linCorrSigma_;
699 
700  ical->setValue(eedetidpos, pairAPDPN);
701  }
702 
703  if (EEDetId::validDetId(iX, iY, -1)) {
704  double r1 = (double)std::rand() / (double(RAND_MAX) + double(1));
705  EEDetId eedetidneg(iX, iY, -1);
706 
708  pairAPDPN.p1 = linCorrMean_ + r1 * linCorrSigma_;
709  pairAPDPN.p2 = linCorrMean_ + r1 * linCorrSigma_;
710  pairAPDPN.p3 = linCorrMean_ + r1 * linCorrSigma_;
711 
712  ical->setValue(eedetidneg, pairAPDPN);
713  }
714  }
715  }
716 
718  // for(int i=1; i<=92; i++){
719  for (int i = 0; i < 92; i++) {
720  TimeStamp.t1 = Timestamp(linearTime1_);
721  if (linearTime2_ == 0) {
722  TimeStamp.t2 = Timestamp(edm::Timestamp::endOfTime().value());
723  } else {
724  TimeStamp.t2 = Timestamp(linearTime2_);
725  }
726  if (linearTime3_ == 0) {
727  TimeStamp.t3 = Timestamp(edm::Timestamp::endOfTime().value());
728  } else {
729  TimeStamp.t3 = Timestamp(linearTime3_);
730  }
731 
732  ical->setTime(i, TimeStamp);
733  }
734 
735  return ical;
736 }
737 
738 // new for the PF Rec Hit Thresholds
739 
740 std::unique_ptr<EcalPFRecHitThresholds> EcalTrivialConditionRetriever::produceEcalPFRecHitThresholds(
741  const EcalPFRecHitThresholdsRcd&) {
742  auto ical = std::make_unique<EcalPFRecHitThresholds>();
743 
744  for (int ieta = -EBDetId::MAX_IETA; ieta <= EBDetId::MAX_IETA; ++ieta) {
745  if (ieta == 0)
746  continue;
747  for (int iphi = EBDetId::MIN_IPHI; iphi <= EBDetId::MAX_IPHI; ++iphi) {
748  // make an EBDetId since we need EBDetId::rawId() to be used as the key for the pedestals
749  if (EBDetId::validDetId(ieta, iphi)) {
750  EBDetId ebid(ieta, iphi);
751  ical->setValue(ebid.rawId(), pfRecHitThresholdsEB_);
752  }
753  }
754  }
755 
756  for (int iX = EEDetId::IX_MIN; iX <= EEDetId::IX_MAX; ++iX) {
757  for (int iY = EEDetId::IY_MIN; iY <= EEDetId::IY_MAX; ++iY) {
758  // make an EEDetId since we need EEDetId::rawId() to be used as the key for the pedestals
759  if (EEDetId::validDetId(iX, iY, 1)) {
760  EEDetId eedetidpos(iX, iY, 1);
761  ical->setValue(eedetidpos.rawId(), pfRecHitThresholdsEE_);
762  }
763  if (EEDetId::validDetId(iX, iY, -1)) {
764  EEDetId eedetidneg(iX, iY, -1);
765  ical->setValue(eedetidneg.rawId(), pfRecHitThresholdsEE_);
766  }
767  }
768  }
769 
770  return ical;
771 }
772 
773 //------------------------------
774 
775 std::unique_ptr<EcalIntercalibConstants> EcalTrivialConditionRetriever::produceEcalIntercalibConstants(
777  auto ical = std::make_unique<EcalIntercalibConstants>();
778 
779  for (int ieta = -EBDetId::MAX_IETA; ieta <= EBDetId::MAX_IETA; ++ieta) {
780  if (ieta == 0)
781  continue;
782  for (int iphi = EBDetId::MIN_IPHI; iphi <= EBDetId::MAX_IPHI; ++iphi) {
783  // make an EBDetId since we need EBDetId::rawId() to be used as the key for the pedestals
784  if (EBDetId::validDetId(ieta, iphi)) {
785  EBDetId ebid(ieta, iphi);
786  double r = (double)std::rand() / (double(RAND_MAX) + double(1));
787  ical->setValue(ebid.rawId(), intercalibConstantMean_ + r * intercalibConstantSigma_);
788  }
789  }
790  }
791 
792  for (int iX = EEDetId::IX_MIN; iX <= EEDetId::IX_MAX; ++iX) {
793  for (int iY = EEDetId::IY_MIN; iY <= EEDetId::IY_MAX; ++iY) {
794  // make an EEDetId since we need EEDetId::rawId() to be used as the key for the pedestals
795  if (EEDetId::validDetId(iX, iY, 1)) {
796  double r = (double)std::rand() / (double(RAND_MAX) + double(1));
797  EEDetId eedetidpos(iX, iY, 1);
798  ical->setValue(eedetidpos.rawId(), intercalibConstantMean_ + r * intercalibConstantSigma_);
799  }
800  if (EEDetId::validDetId(iX, iY, -1)) {
801  double r1 = (double)std::rand() / (double(RAND_MAX) + double(1));
802  EEDetId eedetidneg(iX, iY, -1);
803  ical->setValue(eedetidneg.rawId(), intercalibConstantMean_ + r1 * intercalibConstantSigma_);
804  }
805  }
806  }
807 
808  return ical;
809 }
810 
811 std::unique_ptr<EcalIntercalibConstantsMC> EcalTrivialConditionRetriever::produceEcalIntercalibConstantsMC(
813  auto ical = std::make_unique<EcalIntercalibConstantsMC>();
814 
815  for (int ieta = -EBDetId::MAX_IETA; ieta <= EBDetId::MAX_IETA; ++ieta) {
816  if (ieta == 0)
817  continue;
818  for (int iphi = EBDetId::MIN_IPHI; iphi <= EBDetId::MAX_IPHI; ++iphi) {
819  // make an EBDetId since we need EBDetId::rawId() to be used as the key for the pedestals
820  if (EBDetId::validDetId(ieta, iphi)) {
821  EBDetId ebid(ieta, iphi);
822  double r = (double)std::rand() / (double(RAND_MAX) + double(1));
823  ical->setValue(ebid.rawId(), intercalibConstantMeanMC_ + r * intercalibConstantSigmaMC_);
824  }
825  }
826  }
827 
828  for (int iX = EEDetId::IX_MIN; iX <= EEDetId::IX_MAX; ++iX) {
829  for (int iY = EEDetId::IY_MIN; iY <= EEDetId::IY_MAX; ++iY) {
830  // make an EEDetId since we need EEDetId::rawId() to be used as the key for the pedestals
831  if (EEDetId::validDetId(iX, iY, 1)) {
832  double r = (double)std::rand() / (double(RAND_MAX) + double(1));
833  EEDetId eedetidpos(iX, iY, 1);
834  ical->setValue(eedetidpos.rawId(), intercalibConstantMeanMC_ + r * intercalibConstantSigmaMC_);
835  }
836  if (EEDetId::validDetId(iX, iY, -1)) {
837  double r1 = (double)std::rand() / (double(RAND_MAX) + double(1));
838  EEDetId eedetidneg(iX, iY, -1);
839  ical->setValue(eedetidneg.rawId(), intercalibConstantMeanMC_ + r1 * intercalibConstantSigmaMC_);
840  }
841  }
842  }
843 
844  return ical;
845 }
846 
848  const EcalIntercalibErrorsRcd&) {
849  auto ical = std::make_unique<EcalIntercalibErrors>();
850 
851  for (int ieta = -EBDetId::MAX_IETA; ieta <= EBDetId::MAX_IETA; ++ieta) {
852  if (ieta == 0)
853  continue;
854  for (int iphi = EBDetId::MIN_IPHI; iphi <= EBDetId::MAX_IPHI; ++iphi) {
855  // make an EBDetId since we need EBDetId::rawId() to be used as the key for the pedestals
856  if (EBDetId::validDetId(ieta, iphi)) {
857  EBDetId ebid(ieta, iphi);
858  ical->setValue(ebid.rawId(), intercalibErrorMean_);
859  }
860  }
861  }
862 
863  for (int iX = EEDetId::IX_MIN; iX <= EEDetId::IX_MAX; ++iX) {
864  for (int iY = EEDetId::IY_MIN; iY <= EEDetId::IY_MAX; ++iY) {
865  // make an EEDetId since we need EEDetId::rawId() to be used as the key for the pedestals
866  if (EEDetId::validDetId(iX, iY, 1)) {
867  EEDetId eedetidpos(iX, iY, 1);
868  ical->setValue(eedetidpos.rawId(), intercalibErrorMean_);
869  }
870  if (EEDetId::validDetId(iX, iY, -1)) {
871  EEDetId eedetidneg(iX, iY, -1);
872  ical->setValue(eedetidneg.rawId(), intercalibErrorMean_);
873  }
874  }
875  }
876 
877  return ical;
878 }
879 
880 std::unique_ptr<EcalTimeCalibConstants> EcalTrivialConditionRetriever::produceEcalTimeCalibConstants(
881  const EcalTimeCalibConstantsRcd&) {
882  auto ical = std::make_unique<EcalTimeCalibConstants>();
883 
884  for (int ieta = -EBDetId::MAX_IETA; ieta <= EBDetId::MAX_IETA; ++ieta) {
885  if (ieta == 0)
886  continue;
887  for (int iphi = EBDetId::MIN_IPHI; iphi <= EBDetId::MAX_IPHI; ++iphi) {
888  // make an EBDetId since we need EBDetId::rawId() to be used as the key for the pedestals
889  if (EBDetId::validDetId(ieta, iphi)) {
890  EBDetId ebid(ieta, iphi);
891  double r = (double)std::rand() / (double(RAND_MAX) + double(1));
892  ical->setValue(ebid.rawId(), timeCalibConstantMean_ + r * timeCalibConstantSigma_);
893  }
894  }
895  }
896 
897  for (int iX = EEDetId::IX_MIN; iX <= EEDetId::IX_MAX; ++iX) {
898  for (int iY = EEDetId::IY_MIN; iY <= EEDetId::IY_MAX; ++iY) {
899  // make an EEDetId since we need EEDetId::rawId() to be used as the key for the pedestals
900  if (EEDetId::validDetId(iX, iY, 1)) {
901  double r = (double)std::rand() / (double(RAND_MAX) + double(1));
902  EEDetId eedetidpos(iX, iY, 1);
903  ical->setValue(eedetidpos.rawId(), timeCalibConstantMean_ + r * timeCalibConstantSigma_);
904  }
905  if (EEDetId::validDetId(iX, iY, -1)) {
906  double r1 = (double)std::rand() / (double(RAND_MAX) + double(1));
907  EEDetId eedetidneg(iX, iY, -1);
908  ical->setValue(eedetidneg.rawId(), timeCalibConstantMean_ + r1 * timeCalibConstantSigma_);
909  }
910  }
911  }
912 
913  return ical;
914 }
915 
917  const EcalTimeCalibErrorsRcd&) {
918  auto ical = std::make_unique<EcalTimeCalibErrors>();
919 
920  for (int ieta = -EBDetId::MAX_IETA; ieta <= EBDetId::MAX_IETA; ++ieta) {
921  if (ieta == 0)
922  continue;
923  for (int iphi = EBDetId::MIN_IPHI; iphi <= EBDetId::MAX_IPHI; ++iphi) {
924  // make an EBDetId since we need EBDetId::rawId() to be used as the key for the pedestals
925  if (EBDetId::validDetId(ieta, iphi)) {
926  EBDetId ebid(ieta, iphi);
927  ical->setValue(ebid.rawId(), timeCalibErrorMean_);
928  }
929  }
930  }
931 
932  for (int iX = EEDetId::IX_MIN; iX <= EEDetId::IX_MAX; ++iX) {
933  for (int iY = EEDetId::IY_MIN; iY <= EEDetId::IY_MAX; ++iY) {
934  // make an EEDetId since we need EEDetId::rawId() to be used as the key for the pedestals
935  if (EEDetId::validDetId(iX, iY, 1)) {
936  EEDetId eedetidpos(iX, iY, 1);
937  ical->setValue(eedetidpos.rawId(), timeCalibErrorMean_);
938  }
939  if (EEDetId::validDetId(iX, iY, -1)) {
940  EEDetId eedetidneg(iX, iY, -1);
941  ical->setValue(eedetidneg.rawId(), timeCalibErrorMean_);
942  }
943  }
944  }
945 
946  return ical;
947 }
948 
949 std::unique_ptr<EcalTimeOffsetConstant> EcalTrivialConditionRetriever::produceEcalTimeOffsetConstant(
950  const EcalTimeOffsetConstantRcd&) {
951  edm::LogInfo(" produceEcalTimeOffsetConstant: ");
952  edm::LogInfo(" EB ") << timeOffsetEBConstant_ << " EE " << timeOffsetEEConstant_;
953  return std::make_unique<EcalTimeOffsetConstant>(timeOffsetEBConstant_, timeOffsetEEConstant_);
954 }
955 
957  auto gratio = std::make_unique<EcalGainRatios>();
959  gr.setGain12Over6(gainRatio12over6_);
960  gr.setGain6Over1(gainRatio6over1_);
961 
962  for (int ieta = -EBDetId::MAX_IETA; ieta <= EBDetId::MAX_IETA; ++ieta) {
963  if (ieta == 0)
964  continue;
965  for (int iphi = EBDetId::MIN_IPHI; iphi <= EBDetId::MAX_IPHI; ++iphi) {
966  if (EBDetId::validDetId(ieta, iphi)) {
967  EBDetId ebid(ieta, iphi);
968  gratio->setValue(ebid.rawId(), gr);
969  }
970  }
971  }
972 
973  for (int iX = EEDetId::IX_MIN; iX <= EEDetId::IX_MAX; ++iX) {
974  for (int iY = EEDetId::IY_MIN; iY <= EEDetId::IY_MAX; ++iY) {
975  // make an EEDetId since we need EEDetId::rawId() to be used as the key for the pedestals
976  if (EEDetId::validDetId(iX, iY, 1)) {
977  EEDetId eedetidpos(iX, iY, 1);
978  gratio->setValue(eedetidpos.rawId(), gr);
979  }
980  if (EEDetId::validDetId(iX, iY, -1)) {
981  EEDetId eedetidneg(iX, iY, -1);
982  gratio->setValue(eedetidneg.rawId(), gr);
983  }
984  }
985  }
986 
987  return gratio;
988 }
989 
991  const EcalADCToGeVConstantRcd&) {
992  return std::make_unique<EcalADCToGeVConstant>(adcToGeVEBConstant_, adcToGeVEEConstant_);
993 }
994 
996  // create weights for the test-beam
997  auto tbwgt = std::make_unique<EcalTBWeights>();
998 
999  // create weights for each distinct group ID
1000  // int nMaxTDC = 10;
1001  // for(int igrp=-EBDetId::MAX_IETA; igrp<=EBDetId::MAX_IETA; ++igrp) {
1002  // if(igrp==0) continue;
1003  int igrp = 1;
1004  for (int itdc = 1; itdc <= nTDCbins_; ++itdc) {
1005  // generate random number
1006  // double r = (double)std::rand()/( double(RAND_MAX)+double(1) );
1007 
1008  // make a new set of weights
1009  EcalWeightSet wgt;
1010  //typedef std::vector< std::vector<EcalWeight> > EcalWeightSet::EcalWeightMatrix;
1013 
1014  // if(verbose_>=1) {
1015  // std::cout << "initial size of mat1: " << mat1.size() << std::endl;
1016  // std::cout << "initial size of mat2: " << mat2.size() << std::endl;
1017  // }
1018 
1019  // generate random numbers to use as weights
1034  // use values provided by user
1035  mat1.Place_in_row(amplWeights_[itdc - 1], 0, 0);
1036  mat1.Place_in_row(pedWeights_[itdc - 1], 1, 0);
1037  mat1.Place_in_row(jittWeights_[itdc - 1], 2, 0);
1038 
1039  // wdights after gain switch
1040  mat2.Place_in_row(amplWeightsAft_[itdc - 1], 0, 0);
1041  mat2.Place_in_row(pedWeightsAft_[itdc - 1], 1, 0);
1042  mat2.Place_in_row(jittWeightsAft_[itdc - 1], 2, 0);
1043 
1044  // fill the chi2 matrcies with random numbers
1045  // r = (double)std::rand()/( double(RAND_MAX)+double(1) );
1048  mat3 = chi2Matrix_[itdc - 1];
1049  mat4 = chi2MatrixAft_[itdc - 1];
1050 
1051  // for(size_t i=0; i<10; ++i)
1052  // {
1053  // mat3.push_back(chi2Matrix_[itdc-1][i]);
1054  // mat4.push_back(chi2MatrixAft_[itdc-1][i]);
1055  // }
1056  // std::vector<EcalWeight> tv1, tv2;
1057  // for(size_t j=0; j<10; ++j) {
1058  // double ww = igrp*itdc*r + i*10. + j;
1059  // tv1.push_back( EcalWeight(1000+ww) );
1060  // tv2.push_back( EcalWeight(1000+100+ww) );
1061  // }
1062 
1063  // if(verbose_>=1) {
1064  // std::cout << "group: " << igrp << " TDC: " << itdc
1065  // << " mat1: " << mat1.size() << " mat2: " << mat2.size()
1066  // << " mat3: " << mat3.size() << " mat4: " << mat4.size()
1067  // << std::endl;
1068  // }
1069 
1070  // put the weight in the container
1071  tbwgt->setValue(std::make_pair(igrp, itdc), wgt);
1072  }
1073  // }
1074  return tbwgt;
1075 }
1076 
1077 // cluster functions/corrections
1078 std::unique_ptr<EcalClusterLocalContCorrParameters>
1080  auto ipar = std::make_unique<EcalClusterLocalContCorrParameters>();
1081  for (size_t i = 0; i < localContCorrParameters_.size(); ++i) {
1082  ipar->params().push_back(localContCorrParameters_[i]);
1083  }
1084  return ipar;
1085 }
1086 std::unique_ptr<EcalClusterCrackCorrParameters> EcalTrivialConditionRetriever::produceEcalClusterCrackCorrParameters(
1088  auto ipar = std::make_unique<EcalClusterCrackCorrParameters>();
1089  for (size_t i = 0; i < crackCorrParameters_.size(); ++i) {
1090  ipar->params().push_back(crackCorrParameters_[i]);
1091  }
1092  return ipar;
1093 }
1094 std::unique_ptr<EcalClusterEnergyCorrectionParameters>
1097  auto ipar = std::make_unique<EcalClusterEnergyCorrectionParameters>();
1098  for (size_t i = 0; i < energyCorrectionParameters_.size(); ++i) {
1099  ipar->params().push_back(energyCorrectionParameters_[i]);
1100  }
1101  return ipar;
1102 }
1103 std::unique_ptr<EcalClusterEnergyUncertaintyParameters>
1106  auto ipar = std::make_unique<EcalClusterEnergyUncertaintyParameters>();
1107  for (size_t i = 0; i < energyUncertaintyParameters_.size(); ++i) {
1108  ipar->params().push_back(energyUncertaintyParameters_[i]);
1109  }
1110  return ipar;
1111 }
1112 std::unique_ptr<EcalClusterEnergyCorrectionObjectSpecificParameters>
1115  auto ipar = std::make_unique<EcalClusterEnergyCorrectionObjectSpecificParameters>();
1116  for (size_t i = 0; i < energyCorrectionObjectSpecificParameters_.size(); ++i) {
1117  ipar->params().push_back(energyCorrectionObjectSpecificParameters_[i]);
1118  }
1119  return ipar;
1120 }
1121 
1122 /*
1123 // laser records
1124 std::unique_ptr<EcalLaserAlphas>
1125 EcalTrivialConditionRetriever::produceEcalLaserAlphas( const EcalLaserAlphasRcd& )
1126 {
1127 
1128  std::cout << " produceEcalLaserAlphas " << std::endl;
1129  auto ical = std::make_unique<EcalLaserAlphas>();
1130 
1131  // get Barrel alpha from type
1132  if(getLaserAlphaFromTypeEB_) {
1133  std::ifstream fEB(edm::FileInPath(EBLaserAlphaFile_).fullPath().c_str());
1134  int SMpos[36] = {-10, 4, -7, -16, 6, -9, 11, -17, 5, 18, 3, -8, 1, -3, -13, 14, -6, 2,
1135  15, -18, 8, 17, -2, 9, -1, 10, -5, 7, -12, -11, 16, -4, -15, -14, 12, 13};
1136  // check!
1137  int SMCal[36] = {12,17,10, 1, 8, 4,27,20,23,25, 6,34,35,15,18,30,21, 9,
1138  24,22,13,31,26,16, 2,11, 5, 0,29,28,14,33,32, 3, 7,19};
1139 
1140  for(int SMcons = 0; SMcons < 36; SMcons++) {
1141  int SM = SMpos[SMcons];
1142  if(SM < 0) SM = 17 + abs(SM);
1143  else SM--;
1144  if(SMCal[SM] != SMcons)
1145  std::cout << " SM pb : read SM " << SMcons<< " SMpos " << SM
1146  << " SMCal " << SMCal[SM] << std::endl;
1147  }
1148 
1149  std::string type, batch;
1150  int readSM, pos, bar, bar2;
1151  float alpha = 0;
1152  for(int SMcons = 0; SMcons < 36; SMcons++) {
1153  int SM = SMpos[SMcons];
1154  for(int ic = 0; ic < 1700; ic++) {
1155  fEB >> readSM >> pos >> bar >> bar2 >> type >> batch;
1156 
1157  if(readSM != SMcons || pos != ic + 1)
1158  std::cout << " barrel read pb read SM " << readSM << " const SM " << SMcons
1159  << " read pos " << pos << " ic " << ic << std::endl;
1160  if(SM < 0) SM = 18 + abs(SM);
1161  EBDetId ebdetid(SM, pos, EBDetId::SMCRYSTALMODE);
1162  if(bar == 33101 || bar == 30301 )
1163  alpha = laserAlphaMeanEBR_;
1164  else if(bar == 33106) {
1165  if(bar2 <= 2000)
1166  alpha = laserAlphaMeanEBC_;
1167  else {
1168  std::cout << " problem with barcode first " << bar << " last " << bar2
1169  << " read SM " << readSM << " read pos " << pos << std::endl;
1170  alpha = laserAlphaMeanEBR_;
1171  }
1172  }
1173  ical->setValue( ebdetid, alpha );
1174 
1175  if( ic==1650 ){
1176  std::cout << " ic/alpha "<<ic<<"/"<<alpha<<std::endl;
1177  }
1178 
1179  }
1180  } // loop over SMcons
1181  fEB.close();
1182  // end laserAlpha from type
1183  } else if(getLaserAlphaFromFileEB_) {
1184  // laser alpha from file
1185  std::cout <<"Laser alpha for EB will be taken from File"<<std::endl;
1186  int ieta, iphi;
1187  float alpha;
1188  std::ifstream fEB(edm::FileInPath(EBLaserAlphaFile_).fullPath().c_str());
1189  // std::ifstream fEB(EBLaserAlphaFile_.c_str());
1190  for(int ic = 0; ic < 61200; ic++) {
1191  fEB >> ieta>> iphi>>alpha;
1192 
1193  if (EBDetId::validDetId(ieta,iphi)) {
1194  EBDetId ebid(ieta,iphi);
1195  ical->setValue( ebid, alpha );
1196  std::cout << " ieta/iphi/alpha "<<ieta<<"/"<<iphi<<"/"<<alpha<<std::endl;
1197  }
1198  if( ieta==10 ){
1199  std::cout << "I will print some alphas from the file... ieta/iphi/alpha "<<ieta<<"/"<<iphi<<"/"<<alpha<<std::endl;
1200  }
1201  }
1202  fEB.close();
1203 
1204  } else {
1205  // laser alpha from mean and smearing
1206  for(int ieta=-EBDetId::MAX_IETA; ieta<=EBDetId::MAX_IETA; ++ieta) {
1207  if(ieta==0) continue;
1208  for(int iphi=EBDetId::MIN_IPHI; iphi<=EBDetId::MAX_IPHI; ++iphi) {
1209  if (EBDetId::validDetId(ieta,iphi)) {
1210  EBDetId ebid(ieta,iphi);
1211  double r = (double)std::rand()/( double(RAND_MAX)+double(1) );
1212  ical->setValue( ebid, laserAlphaMean_ + r*laserAlphaSigma_ );
1213  }
1214  } // loop over iphi
1215  } // loop over ieta
1216  } // do not read a file
1217 
1218  std::cout << " produceEcalLaserAlphas EE" << std::endl;
1219  if(getLaserAlphaFromTypeEE_) {
1220  std::ifstream fEE(edm::FileInPath(EELaserAlphaFile_).fullPath().c_str());
1221 
1222  for(int crystal = 0; crystal < 14648; crystal++) {
1223  int x, y ,z, bid, bar, bar2;
1224  float LY, alpha = 0;
1225  fEE >> z >> x >> y >> LY >> bid >> bar >> bar2;
1226  if(x < 1 || x > 100 || y < 1 || y > 100)
1227  std::cout << " wrong coordinates for barcode " << bar
1228  << " x " << x << " y " << y << " z " << z << std::endl;
1229  else {
1230  if(bar == 33201 || (bar == 30399 && bar2 < 568))
1231  alpha = laserAlphaMeanEER_;
1232  else if((bar == 33106 && bar2 > 2000 && bar2 < 4669)
1233  || (bar == 30399 && bar2 > 567))
1234  alpha = laserAlphaMeanEEC_;
1235  else {
1236  std::cout << " problem with barcode " << bar << " " << bar2
1237  << " x " << x << " y " << y << " z " << z << std::endl;
1238  alpha = laserAlphaMeanEER_;
1239  }
1240  }
1241  if (EEDetId::validDetId(x, y, z)) {
1242  EEDetId eedetidpos(x, y, z);
1243  ical->setValue( eedetidpos, alpha );
1244  }
1245  else // should not occur
1246  std::cout << " problem with EEDetId " << " x " << x << " y " << y << " z " << z << std::endl;
1247  }
1248  fEE.close();
1249 
1250  // end laserAlpha from type EE
1251 
1252  } else if (getLaserAlphaFromFileEE_) {
1253 
1254  std::ifstream fEE(edm::FileInPath(EELaserAlphaFile_).fullPath().c_str());
1255 
1256  for(int crystal = 0; crystal < 14648; crystal++) {
1257  int x, y ,z;
1258  float alpha = 1;
1259  fEE >> z >> x >> y >> alpha;
1260  if(x < 1 || x > 100 || y < 1 || y > 100 || z==0 || z>1 || z<-1 ) {
1261  std::cout << "ERROR: wrong coordinates for crystal "
1262  << " x " << x << " y " << y << " z " << z << std::endl;
1263  std::cout << " the format of the file should be z x y alpha " << std::endl;
1264  } else {
1265  if (EEDetId::validDetId(x, y, z)) {
1266  EEDetId eedetidpos(x, y, z);
1267  ical->setValue( eedetidpos, alpha );
1268  }
1269  else // should not occur
1270  std::cout << " problem with EEDetId " << " x " << x << " y " << y << " z " << z << std::endl;
1271  }
1272  }
1273  fEE.close();
1274 
1275  // end laser alpha from file EE
1276  } else {
1277  // alphas from python config file
1278  for(int iX=EEDetId::IX_MIN; iX<=EEDetId::IX_MAX ;++iX) {
1279  for(int iY=EEDetId::IY_MIN; iY<=EEDetId::IY_MAX; ++iY) {
1280  // make an EEDetId since we need EEDetId::rawId() to be used as the key for the pedestals
1281  if (EEDetId::validDetId(iX,iY,1)) {
1282  double r = (double)std::rand()/( double(RAND_MAX)+double(1) );
1283  EEDetId eedetidpos(iX,iY,1);
1284  ical->setValue( eedetidpos, laserAlphaMean_ + r*laserAlphaSigma_ );
1285  }
1286  if (EEDetId::validDetId(iX,iY,-1)) {
1287  double r1 = (double)std::rand()/( double(RAND_MAX)+double(1) );
1288  EEDetId eedetidneg(iX,iY,-1);
1289  ical->setValue( eedetidneg, laserAlphaMean_ + r1*laserAlphaSigma_ );
1290  }
1291  } // loop over iY
1292  } // loop over iX
1293  }
1294 
1295  return ical;
1296 }
1297 */
1298 
1299 // laser alphas
1301  edm::LogInfo(" produceEcalLaserAlphas ");
1302  auto ical = std::make_unique<EcalLaserAlphas>();
1303 
1304  // get Barrel alpha from type
1305  if (getLaserAlphaFromTypeEB_) {
1306  std::ifstream fEB(edm::FileInPath(EBLaserAlphaFile_).fullPath().c_str());
1307  int SMpos[36] = {-10, 4, -7, -16, 6, -9, 11, -17, 5, 18, 3, -8, 1, -3, -13, 14, -6, 2,
1308  15, -18, 8, 17, -2, 9, -1, 10, -5, 7, -12, -11, 16, -4, -15, -14, 12, 13};
1309  // check!
1310  int SMCal[36] = {12, 17, 10, 1, 8, 4, 27, 20, 23, 25, 6, 34, 35, 15, 18, 30, 21, 9,
1311  24, 22, 13, 31, 26, 16, 2, 11, 5, 0, 29, 28, 14, 33, 32, 3, 7, 19};
1312 
1313  for (int SMcons = 0; SMcons < 36; SMcons++) {
1314  int SM = SMpos[SMcons];
1315  if (SM < 0)
1316  SM = 17 + abs(SM);
1317  else
1318  SM--;
1319  if (SMCal[SM] != SMcons)
1320  edm::LogInfo(" SM pb : read SM ") << SMcons << " SMpos " << SM << " SMCal " << SMCal[SM];
1321  }
1322 
1324  int readSM, pos, bar, bar2;
1325  float alpha = 0;
1326  for (int SMcons = 0; SMcons < 36; SMcons++) {
1327  int SM = SMpos[SMcons];
1328  for (int ic = 0; ic < 1700; ic++) {
1329  fEB >> readSM >> pos >> bar >> bar2 >> type >> batch;
1330 
1331  if (readSM != SMcons || pos != ic + 1)
1332  edm::LogInfo(" barrel read pb read SM ")
1333  << readSM << " const SM " << SMcons << " read pos " << pos << " ic " << ic;
1334  if (SM < 0)
1335  SM = 18 + abs(SM);
1336  EBDetId ebdetid(SM, pos, EBDetId::SMCRYSTALMODE);
1337  if (bar == 33101 || bar == 30301)
1338  alpha = laserAlphaMeanEBR_;
1339  else if (bar == 33106) {
1340  if (bar2 <= 2000)
1341  alpha = laserAlphaMeanEBC_;
1342  else {
1343  edm::LogInfo(" problem with barcode first ")
1344  << bar << " last " << bar2 << " read SM " << readSM << " read pos " << pos;
1345  alpha = laserAlphaMeanEBR_;
1346  }
1347  }
1348  ical->setValue(ebdetid, alpha);
1349 
1350  if (ic == 1650) {
1351  edm::LogInfo(" ic/alpha ") << ic << "/" << alpha;
1352  }
1353  }
1354  } // loop over SMcons
1355  fEB.close();
1356  // end laserAlpha from type
1357  } else if (getLaserAlphaFromFileEB_) {
1358  // laser alpha from file
1359  edm::LogInfo("Laser alpha for EB will be taken from File");
1360  int ieta, iphi;
1361  float alpha;
1362  std::ifstream fEB(edm::FileInPath(EBLaserAlphaFile_).fullPath().c_str());
1363  // std::ifstream fEB(EBLaserAlphaFile_.c_str());
1364  for (int ic = 0; ic < 61200; ic++) {
1365  fEB >> ieta >> iphi >> alpha;
1366 
1367  if (EBDetId::validDetId(ieta, iphi)) {
1368  EBDetId ebid(ieta, iphi);
1369  ical->setValue(ebid, alpha);
1370  //std::cout << " ieta/iphi/alpha "<<ieta<<"/"<<iphi<<"/"<<alpha<<std::endl;
1371  }
1372  if (ieta == 10) {
1373  edm::LogInfo("I will print some alphas from the file... ieta/iphi/alpha ")
1374  << ieta << "/" << iphi << "/" << alpha;
1375  }
1376  }
1377  fEB.close();
1378 
1379  } else {
1380  edm::LogInfo("laser alphas from default values");
1381 
1382  // laser alpha from mean and smearing
1383  for (int ieta = -EBDetId::MAX_IETA; ieta <= EBDetId::MAX_IETA; ++ieta) {
1384  if (ieta == 0)
1385  continue;
1386  for (int iphi = EBDetId::MIN_IPHI; iphi <= EBDetId::MAX_IPHI; ++iphi) {
1387  if (EBDetId::validDetId(ieta, iphi)) {
1388  EBDetId ebid(ieta, iphi);
1389  double r = (double)std::rand() / (double(RAND_MAX) + double(1));
1390  ical->setValue(ebid, laserAlphaMean_ + r * laserAlphaSigma_);
1391  }
1392  } // loop over iphi
1393  } // loop over ieta
1394  } // do not read a file
1395 
1396  edm::LogInfo(" produceEcalLaserAlphas EE");
1397  // read mean laser per ring per year
1398 
1399  int itype, iring, iyear;
1400  float laser = 0;
1401  float las[2][140][6];
1402 
1403  if (getLaserAlphaFromTypeEE_) {
1404  edm::LogInfo(" EE laser alphas from type");
1405 
1406  std::ifstream fRing(edm::FileInPath(EELaserAlphaFile2_).fullPath().c_str());
1407  for (int i = 0; i < 1681; i++) {
1408  fRing >> itype >> iring >> iyear >> laser;
1409  edm::LogInfo(" ") << itype << " " << iring << " " << iyear << " " << laser << std::endl;
1410  las[itype][iring][iyear] = laser;
1411  }
1412  fRing.close();
1413 
1414  std::ifstream fEE(edm::FileInPath(EELaserAlphaFile_).fullPath().c_str());
1415  int nxt = 0;
1416  for (int crystal = 0; crystal < 14648; crystal++) {
1417  int x, y, z, bid, bar, bar2;
1418  float LY, alpha = 0;
1419  fEE >> z >> x >> y >> LY >> bid >> bar >> bar2;
1420  if (x < 1 || x > 100 || y < 1 || y > 100)
1421  edm::LogInfo(" wrong coordinates for barcode ") << bar << " x " << x << " y " << y << " z " << z;
1422  else {
1423  int iyear = 4;
1424  int iring = (int)(sqrt(((float)x - 50.5) * ((float)x - 50.5) + ((float)y - 50.5) * ((float)y - 50.5)) + 85);
1425 
1426  double eta = -log(tan(0.5 * atan(sqrt((x - 50.5) * (x - 50.5) + (y - 50.5) * (y - 50.5)) * 2.98 / 328.)));
1427 
1428  if (bar == 33201 || (bar == 30399 && bar2 < 568)) {
1429  // russian
1430  alpha = laserAlphaMeanEER_;
1431 
1432  double raggio = 50.5 - sqrt(((float)x - 50.5) * ((float)x - 50.5) + ((float)y - 50.5) * ((float)y - 50.5));
1433 
1434  if (raggio >= 25) {
1435  alpha = 1.07;
1436  }
1437  /*
1438  if(raggio>=34){
1439 
1440  if(eta>2.0) {
1441  itype=0;
1442  if(las[itype][iring][iyear]!=999){
1443  alpha=0.8044+0.3555*las[itype][iring][iyear];
1444  }
1445  }
1446 
1447  }
1448  */
1449 
1450  if (x == 50)
1451  edm::LogInfo("R=") << raggio << " x " << x << " y " << y << " z " << z << "eta=" << eta
1452  << " alpha=" << alpha << " R";
1453 
1454  } else if ((bar == 33106 && bar2 > 2000 && bar2 < 4669) || (bar == 30399 && bar2 > 567)) {
1455  // SIC
1456  itype = 1;
1457  alpha = laserAlphaMeanEEC_;
1458 
1459  double raggio = 50.5 - sqrt(((float)x - 50.5) * ((float)x - 50.5) + ((float)y - 50.5) * ((float)y - 50.5));
1460 
1461  if (raggio >= 25) {
1462  alpha = 0.80;
1463  }
1464  if (raggio >= 34) {
1465  float r = sqrt((x - 50.5) * (x - 50.5) + (y - 50.5) * (y - 50.5));
1466  if (r < 21) {
1467  nxt = nxt + 1;
1468  // inner SIC crystals
1469 
1470  if (las[itype][iring][iyear] != 999) {
1471  alpha = 0.7312 + 0.2688 * las[itype][iring][iyear];
1472  }
1473  }
1474  }
1475  if (x == 50)
1476  edm::LogInfo("R=") << raggio << " x " << x << " y " << y << " z " << z << "eta=" << eta
1477  << " alpha=" << alpha << " C";
1478 
1479  } else {
1480  edm::LogInfo(" problem with barcode ") << bar << " " << bar2 << " x " << x << " y " << y << " z " << z;
1481  alpha = laserAlphaMeanEER_;
1482  }
1483  }
1484 
1485  if (EEDetId::validDetId(x, y, z)) {
1486  EEDetId eedetidpos(x, y, z);
1487  ical->setValue(eedetidpos, alpha);
1488  if (x == 50)
1489  edm::LogInfo(" x ") << x << " y " << y << " alpha " << alpha;
1490  } else // should not occur
1491  edm::LogInfo(" problem with EEDetId ") << " x " << x << " y " << y << " z " << z;
1492  }
1493  fEE.close();
1494  edm::LogInfo("Number of inner SIC crystals with different alpha= ") << nxt;
1495  // end laserAlpha from type EE
1496 
1497  } else if (getLaserAlphaFromFileEE_) {
1498  edm::LogInfo(" EE laser alphas from file");
1499 
1500  std::ifstream fEE(edm::FileInPath(EELaserAlphaFile_).fullPath().c_str());
1501 
1502  for (int crystal = 0; crystal < 14648; crystal++) {
1503  int x, y, z;
1504  float alpha = 1;
1505  fEE >> z >> x >> y >> alpha;
1506  if (x < 1 || x > 100 || y < 1 || y > 100 || z == 0 || z > 1 || z < -1) {
1507  edm::LogInfo("ERROR: wrong coordinates for crystal ") << " x " << x << " y " << y << " z " << z;
1508  edm::LogInfo(" the format of the file should be z x y alpha ");
1509  } else {
1510  if (EEDetId::validDetId(x, y, z)) {
1511  EEDetId eedetidpos(x, y, z);
1512  ical->setValue(eedetidpos, alpha);
1513  } else // should not occur
1514  edm::LogInfo(" problem with EEDetId ") << " x " << x << " y " << y << " z " << z;
1515  }
1516  }
1517  fEE.close();
1518 
1519  // end laser alpha from file EE
1520  } else {
1521  // alphas from python config file
1522  edm::LogInfo(" EE laser alphas from default values");
1523  for (int iX = EEDetId::IX_MIN; iX <= EEDetId::IX_MAX; ++iX) {
1524  for (int iY = EEDetId::IY_MIN; iY <= EEDetId::IY_MAX; ++iY) {
1525  // make an EEDetId since we need EEDetId::rawId() to be used as the key for the pedestals
1526  if (EEDetId::validDetId(iX, iY, 1)) {
1527  double r = (double)std::rand() / (double(RAND_MAX) + double(1));
1528  EEDetId eedetidpos(iX, iY, 1);
1529  ical->setValue(eedetidpos, laserAlphaMean_ + r * laserAlphaSigma_);
1530  }
1531  if (EEDetId::validDetId(iX, iY, -1)) {
1532  double r1 = (double)std::rand() / (double(RAND_MAX) + double(1));
1533  EEDetId eedetidneg(iX, iY, -1);
1534  ical->setValue(eedetidneg, laserAlphaMean_ + r1 * laserAlphaSigma_);
1535  }
1536  } // loop over iY
1537  } // loop over iX
1538  }
1539 
1540  return ical;
1541 }
1542 
1543 std::unique_ptr<EcalLaserAPDPNRatiosRef> EcalTrivialConditionRetriever::produceEcalLaserAPDPNRatiosRef(
1544  const EcalLaserAPDPNRatiosRefRcd&) {
1545  auto ical = std::make_unique<EcalLaserAPDPNRatiosRef>();
1546  for (int ieta = -EBDetId::MAX_IETA; ieta <= EBDetId::MAX_IETA; ++ieta) {
1547  if (ieta == 0)
1548  continue;
1549  for (int iphi = EBDetId::MIN_IPHI; iphi <= EBDetId::MAX_IPHI; ++iphi) {
1550  if (EBDetId::validDetId(ieta, iphi)) {
1551  EBDetId ebid(ieta, iphi);
1552  double r = (double)std::rand() / (double(RAND_MAX) + double(1));
1553  ical->setValue(ebid, laserAPDPNRefMean_ + r * laserAPDPNRefSigma_);
1554  }
1555  }
1556  }
1557 
1558  for (int iX = EEDetId::IX_MIN; iX <= EEDetId::IX_MAX; ++iX) {
1559  for (int iY = EEDetId::IY_MIN; iY <= EEDetId::IY_MAX; ++iY) {
1560  // make an EEDetId since we need EEDetId::rawId() to be used as the key for the pedestals
1561  if (EEDetId::validDetId(iX, iY, 1)) {
1562  double r = (double)std::rand() / (double(RAND_MAX) + double(1));
1563  EEDetId eedetidpos(iX, iY, 1);
1564  ical->setValue(eedetidpos, laserAPDPNRefMean_ + r * laserAPDPNRefSigma_);
1565  }
1566 
1567  if (EEDetId::validDetId(iX, iY, -1)) {
1568  double r1 = (double)std::rand() / (double(RAND_MAX) + double(1));
1569  EEDetId eedetidneg(iX, iY, -1);
1570  ical->setValue(eedetidneg, laserAPDPNRefMean_ + r1 * laserAPDPNRefSigma_);
1571  }
1572  }
1573  }
1574 
1575  return ical;
1576 }
1577 
1579  const EcalLaserAPDPNRatiosRcd&) {
1580  EnergyResolutionVsLumi ageing;
1581  ageing.setLumi(totLumi_);
1582  ageing.setInstLumi(instLumi_);
1583 
1584  auto ical = std::make_unique<EcalLaserAPDPNRatios>();
1585  for (int ieta = -EBDetId::MAX_IETA; ieta <= EBDetId::MAX_IETA; ++ieta) {
1586  if (ieta == 0)
1587  continue;
1588 
1589  double eta = EBDetId::approxEta(EBDetId(ieta, 1));
1590 
1591  eta = fabs(eta);
1592  double drop = ageing.calcampDropTotal(eta);
1593  // edm::LogInfo("EB at eta=")<<eta<<" dropping by "<<drop;
1594 
1595  for (int iphi = EBDetId::MIN_IPHI; iphi <= EBDetId::MAX_IPHI; ++iphi) {
1596  if (EBDetId::validDetId(ieta, iphi)) {
1597  EBDetId ebid(ieta, iphi);
1598  double r = (double)std::rand() / (double(RAND_MAX) + double(1));
1599 
1601  pairAPDPN.p1 = laserAPDPNMean_ * drop + r * laserAPDPNSigma_;
1602  pairAPDPN.p2 = laserAPDPNMean_ * drop + r * laserAPDPNSigma_;
1603  pairAPDPN.p3 = laserAPDPNMean_ * drop + r * laserAPDPNSigma_;
1604  ical->setValue(ebid, pairAPDPN);
1605  }
1606  }
1607  }
1608 
1609  edm::LogInfo("----- EE -----");
1610 
1611  for (int iX = EEDetId::IX_MIN; iX <= EEDetId::IX_MAX; ++iX) {
1612  for (int iY = EEDetId::IY_MIN; iY <= EEDetId::IY_MAX; ++iY) {
1613  // make an EEDetId since we need EEDetId::rawId() to be used as the key for the pedestals
1614 
1615  if (EEDetId::validDetId(iX, iY, 1)) {
1616  double r = (double)std::rand() / (double(RAND_MAX) + double(1));
1617  EEDetId eedetidpos(iX, iY, 1);
1618 
1619  double eta = -log(tan(0.5 * atan(sqrt((iX - 50.0) * (iX - 50.0) + (iY - 50.0) * (iY - 50.0)) * 2.98 / 328.)));
1620  eta = fabs(eta);
1621  double drop = ageing.calcampDropTotal(eta);
1622  // if(iX==50) edm::LogInfo("EE at eta=")<<eta<<" dropping by "<<drop;
1623 
1625  pairAPDPN.p1 = laserAPDPNMean_ * drop + r * laserAPDPNSigma_;
1626  pairAPDPN.p2 = laserAPDPNMean_ * drop + r * laserAPDPNSigma_;
1627  pairAPDPN.p3 = laserAPDPNMean_ * drop + r * laserAPDPNSigma_;
1628  ical->setValue(eedetidpos, pairAPDPN);
1629  }
1630 
1631  if (EEDetId::validDetId(iX, iY, -1)) {
1632  double r1 = (double)std::rand() / (double(RAND_MAX) + double(1));
1633  EEDetId eedetidneg(iX, iY, -1);
1634 
1635  double eta = -log(tan(0.5 * atan(sqrt((iX - 50.0) * (iX - 50.0) + (iY - 50.0) * (iY - 50.0)) * 2.98 / 328.)));
1636  eta = fabs(eta);
1637  double drop = ageing.calcampDropTotal(eta);
1638  // if(iX==50) edm::LogInfo("EE at eta=")<<eta<<" dropping by "<<drop;
1639 
1641  pairAPDPN.p1 = laserAPDPNMean_ * drop + r1 * laserAPDPNSigma_;
1642  pairAPDPN.p2 = laserAPDPNMean_ * drop + r1 * laserAPDPNSigma_;
1643  pairAPDPN.p3 = laserAPDPNMean_ * drop + r1 * laserAPDPNSigma_;
1644  ical->setValue(eedetidneg, pairAPDPN);
1645  }
1646  }
1647  }
1648 
1650  // for(int i=1; i<=92; i++){
1651  for (int i = 0; i < 92; i++) {
1652  TimeStamp.t1 = Timestamp(laserAPDPNTime1_);
1653  if (laserAPDPNTime2_ == 0) {
1654  TimeStamp.t2 = Timestamp(edm::Timestamp::endOfTime().value());
1655  } else {
1656  TimeStamp.t2 = Timestamp(laserAPDPNTime2_);
1657  }
1658  if (laserAPDPNTime3_ == 0) {
1659  TimeStamp.t3 = Timestamp(edm::Timestamp::endOfTime().value());
1660  } else {
1661  TimeStamp.t3 = Timestamp(laserAPDPNTime3_);
1662  }
1663 
1664  ical->setTime(i, TimeStamp);
1665  }
1666 
1667  return ical;
1668 }
1669 
1671  std::vector<std::vector<double> > amplwgtv(nTDCbins_);
1672 
1673  if (!getWeightsFromFile_ && nTDCbins_ == 1) {
1674  std::vector<double> vampl;
1675  //As default using simple 3+1 weights
1676  vampl.push_back(-0.33333);
1677  vampl.push_back(-0.33333);
1678  vampl.push_back(-0.33333);
1679  vampl.push_back(0.);
1680  vampl.push_back(0.);
1681  vampl.push_back(1.);
1682  vampl.push_back(0.);
1683  vampl.push_back(0.);
1684  vampl.push_back(0.);
1685  vampl.push_back(0.);
1686  amplwgtv[0] = ps.getUntrackedParameter<std::vector<double> >("amplWeights", vampl);
1687  } else if (getWeightsFromFile_) {
1688  edm::LogInfo("EcalTrivialConditionRetriever")
1689  << "Reading amplitude weights from file " << edm::FileInPath(amplWeightsFile_).fullPath().c_str();
1690  std::ifstream amplFile(edm::FileInPath(amplWeightsFile_).fullPath().c_str());
1691  int tdcBin = 0;
1692  while (!amplFile.eof() && tdcBin < nTDCbins_) {
1693  for (int j = 0; j < 10; ++j) {
1694  float ww;
1695  amplFile >> ww;
1696  amplwgtv[tdcBin].push_back(ww);
1697  }
1698  ++tdcBin;
1699  }
1700  assert(tdcBin == nTDCbins_);
1701  //Read from file
1702  } else {
1703  //Not supported
1704  edm::LogError("EcalTrivialConditionRetriever") << "Configuration not supported. Exception is raised ";
1705  throw cms::Exception("WrongConfig");
1706  }
1707 
1708  for (int i = 0; i < nTDCbins_; i++) {
1709  assert(amplwgtv[i].size() == 10);
1710  int j = 0;
1711  for (std::vector<double>::const_iterator it = amplwgtv[i].begin(); it != amplwgtv[i].end(); ++it) {
1712  (amplWeights_[i])[j] = *it;
1713  j++;
1714  }
1715  }
1716 
1717  std::vector<std::vector<double> > amplwgtvAftGain(nTDCbins_);
1718 
1719  if (!getWeightsFromFile_ && nTDCbins_ == 1) {
1720  std::vector<double> vamplAftGain;
1721  vamplAftGain.push_back(0.);
1722  vamplAftGain.push_back(0.);
1723  vamplAftGain.push_back(0.);
1724  vamplAftGain.push_back(0.);
1725  vamplAftGain.push_back(0.);
1726  vamplAftGain.push_back(1.);
1727  vamplAftGain.push_back(0.);
1728  vamplAftGain.push_back(0.);
1729  vamplAftGain.push_back(0.);
1730  vamplAftGain.push_back(0.);
1731  amplwgtvAftGain[0] = ps.getUntrackedParameter<std::vector<double> >("amplWeightsAftGain", vamplAftGain);
1732  } else if (getWeightsFromFile_) {
1733  //Read from file
1734  edm::LogInfo("EcalTrivialConditionRetriever") << "Reading amplitude weights aftre gain switch from file "
1735  << edm::FileInPath(amplWeightsAftFile_).fullPath().c_str();
1736  std::ifstream amplFile(edm::FileInPath(amplWeightsAftFile_).fullPath().c_str());
1737  int tdcBin = 0;
1738  while (!amplFile.eof() && tdcBin < nTDCbins_) {
1739  for (int j = 0; j < 10; ++j) {
1740  float ww;
1741  amplFile >> ww;
1742  amplwgtvAftGain[tdcBin].push_back(ww);
1743  }
1744  ++tdcBin;
1745  }
1746  assert(tdcBin == nTDCbins_);
1747  } else {
1748  //Not supported
1749  edm::LogError("EcalTrivialConditionRetriever") << "Configuration not supported. Exception is raised ";
1750  throw cms::Exception("WrongConfig");
1751  }
1752 
1753  for (int i = 0; i < nTDCbins_; i++) {
1754  assert(amplwgtvAftGain[i].size() == 10);
1755  int j = 0;
1756  for (std::vector<double>::const_iterator it = amplwgtvAftGain[i].begin(); it != amplwgtvAftGain[i].end(); ++it) {
1757  (amplWeightsAft_[i])[j] = *it;
1758  j++;
1759  }
1760  }
1761 
1762  // default weights to reco amplitude w/o pedestal subtraction
1763 
1764  std::vector<std::vector<double> > pedwgtv(nTDCbins_);
1765 
1766  if (!getWeightsFromFile_ && nTDCbins_ == 1) {
1767  std::vector<double> vped;
1768  vped.push_back(0.33333);
1769  vped.push_back(0.33333);
1770  vped.push_back(0.33333);
1771  vped.push_back(0.);
1772  vped.push_back(0.);
1773  vped.push_back(0.);
1774  vped.push_back(0.);
1775  vped.push_back(0.);
1776  vped.push_back(0.);
1777  vped.push_back(0.);
1778  pedwgtv[0] = ps.getUntrackedParameter<std::vector<double> >("pedWeights", vped);
1779  } else if (getWeightsFromFile_) {
1780  //Read from file
1781  edm::LogInfo("EcalTrivialConditionRetriever")
1782  << "Reading pedestal weights from file " << edm::FileInPath(pedWeightsFile_).fullPath().c_str();
1783  std::ifstream pedFile(edm::FileInPath(pedWeightsFile_).fullPath().c_str());
1784  int tdcBin = 0;
1785  while (!pedFile.eof() && tdcBin < nTDCbins_) {
1786  for (int j = 0; j < 10; ++j) {
1787  float ww;
1788  pedFile >> ww;
1789  pedwgtv[tdcBin].push_back(ww);
1790  }
1791  ++tdcBin;
1792  }
1793  assert(tdcBin == nTDCbins_);
1794  } else {
1795  //Not supported
1796  edm::LogError("EcalTrivialConditionRetriever") << "Configuration not supported. Exception is raised ";
1797  throw cms::Exception("WrongConfig");
1798  }
1799 
1800  for (int i = 0; i < nTDCbins_; i++) {
1801  assert(pedwgtv[i].size() == 10);
1802  int j = 0;
1803  for (std::vector<double>::const_iterator it = pedwgtv[i].begin(); it != pedwgtv[i].end(); ++it) {
1804  (pedWeights_[i])[j] = *it;
1805  j++;
1806  }
1807  }
1808 
1809  std::vector<std::vector<double> > pedwgtvaft(nTDCbins_);
1810 
1811  if (!getWeightsFromFile_ && nTDCbins_ == 1) {
1812  std::vector<double> vped;
1813  vped.push_back(0.);
1814  vped.push_back(0.);
1815  vped.push_back(0.);
1816  vped.push_back(0.);
1817  vped.push_back(0.);
1818  vped.push_back(0.);
1819  vped.push_back(0.);
1820  vped.push_back(0.);
1821  vped.push_back(0.);
1822  vped.push_back(0.);
1823  pedwgtvaft[0] = ps.getUntrackedParameter<std::vector<double> >("pedWeightsAft", vped);
1824  } else if (getWeightsFromFile_) {
1825  //Read from file
1826  edm::LogInfo("EcalTrivialConditionRetriever") << "Reading pedestal after gain switch weights from file "
1827  << edm::FileInPath(pedWeightsAftFile_).fullPath().c_str();
1828  std::ifstream pedFile(edm::FileInPath(pedWeightsAftFile_).fullPath().c_str());
1829  int tdcBin = 0;
1830  while (!pedFile.eof() && tdcBin < nTDCbins_) {
1831  for (int j = 0; j < 10; ++j) {
1832  float ww;
1833  pedFile >> ww;
1834  pedwgtvaft[tdcBin].push_back(ww);
1835  }
1836  ++tdcBin;
1837  }
1838  assert(tdcBin == nTDCbins_);
1839  } else {
1840  //Not supported
1841  edm::LogError("EcalTrivialConditionRetriever") << "Configuration not supported. Exception is raised ";
1842  throw cms::Exception("WrongConfig");
1843  }
1844 
1845  for (int i = 0; i < nTDCbins_; i++) {
1846  assert(pedwgtvaft[i].size() == 10);
1847  int j = 0;
1848  for (std::vector<double>::const_iterator it = pedwgtvaft[i].begin(); it != pedwgtvaft[i].end(); ++it) {
1849  (pedWeightsAft_[i])[j] = *it;
1850  j++;
1851  }
1852  }
1853 
1854  // default weights to reco jitter
1855 
1856  std::vector<std::vector<double> > jittwgtv(nTDCbins_);
1857 
1858  if (!getWeightsFromFile_ && nTDCbins_ == 1) {
1859  std::vector<double> vjitt;
1860  vjitt.push_back(0.04066309);
1861  vjitt.push_back(0.04066309);
1862  vjitt.push_back(0.04066309);
1863  vjitt.push_back(0.000);
1864  vjitt.push_back(1.325176);
1865  vjitt.push_back(-0.04997078);
1866  vjitt.push_back(-0.504338);
1867  vjitt.push_back(-0.5024844);
1868  vjitt.push_back(-0.3903718);
1869  vjitt.push_back(0.000);
1870  jittwgtv[0] = ps.getUntrackedParameter<std::vector<double> >("jittWeights", vjitt);
1871  } else if (getWeightsFromFile_) {
1872  //Read from file
1873  edm::LogInfo("EcalTrivialConditionRetriever")
1874  << "Reading jitter weights from file " << edm::FileInPath(jittWeightsFile_).fullPath().c_str();
1875  std::ifstream jittFile(edm::FileInPath(jittWeightsFile_).fullPath().c_str());
1876  int tdcBin = 0;
1877  while (!jittFile.eof() && tdcBin < nTDCbins_) {
1878  for (int j = 0; j < 10; ++j) {
1879  float ww;
1880  jittFile >> ww;
1881  jittwgtv[tdcBin].push_back(ww);
1882  }
1883  ++tdcBin;
1884  }
1885  assert(tdcBin == nTDCbins_);
1886  } else {
1887  //Not supported
1888  edm::LogError("EcalTrivialConditionRetriever") << "Configuration not supported. Exception is raised ";
1889  throw cms::Exception("WrongConfig");
1890  }
1891 
1892  for (int i = 0; i < nTDCbins_; i++) {
1893  assert(jittwgtv[i].size() == 10);
1894  int j = 0;
1895  for (std::vector<double>::const_iterator it = jittwgtv[i].begin(); it != jittwgtv[i].end(); ++it) {
1896  (jittWeights_[i])[j] = *it;
1897  j++;
1898  }
1899  }
1900 
1901  std::vector<std::vector<double> > jittwgtvaft(nTDCbins_);
1902 
1903  if (!getWeightsFromFile_ && nTDCbins_ == 1) {
1904  std::vector<double> vjitt;
1905  vjitt.push_back(0.);
1906  vjitt.push_back(0.);
1907  vjitt.push_back(0.);
1908  vjitt.push_back(0.);
1909  vjitt.push_back(1.097871);
1910  vjitt.push_back(-0.04551035);
1911  vjitt.push_back(-0.4159156);
1912  vjitt.push_back(-0.4185352);
1913  vjitt.push_back(-0.3367127);
1914  vjitt.push_back(0.);
1915  jittwgtvaft[0] = ps.getUntrackedParameter<std::vector<double> >("jittWeightsAft", vjitt);
1916  } else if (getWeightsFromFile_) {
1917  //Read from file
1918  edm::LogInfo("EcalTrivialConditionRetriever") << "Reading jitter after gain switch weights from file "
1919  << edm::FileInPath(jittWeightsAftFile_).fullPath().c_str();
1920  std::ifstream jittFile(edm::FileInPath(jittWeightsAftFile_).fullPath().c_str());
1921  int tdcBin = 0;
1922  while (!jittFile.eof() && tdcBin < nTDCbins_) {
1923  for (int j = 0; j < 10; ++j) {
1924  float ww;
1925  jittFile >> ww;
1926  jittwgtvaft[tdcBin].push_back(ww);
1927  }
1928  ++tdcBin;
1929  }
1930  assert(tdcBin == nTDCbins_);
1931  } else {
1932  //Not supported
1933  edm::LogError("EcalTrivialConditionRetriever") << "Configuration not supported. Exception is raised ";
1934  throw cms::Exception("WrongConfig");
1935  }
1936 
1937  for (int i = 0; i < nTDCbins_; i++) {
1938  assert(jittwgtvaft[i].size() == 10);
1939  int j = 0;
1940  for (std::vector<double>::const_iterator it = jittwgtvaft[i].begin(); it != jittwgtvaft[i].end(); ++it) {
1941  (jittWeightsAft_[i])[j] = *it;
1942  j++;
1943  }
1944  }
1945 
1946  std::vector<EcalWeightSet::EcalChi2WeightMatrix> chi2Matrix(nTDCbins_);
1947  if (!getWeightsFromFile_ && nTDCbins_ == 1) {
1948  // chi2Matrix[0].resize(10);
1949  // for (int i=0;i<10;i++)
1950  // chi2Matrix[0][i].resize(10);
1951 
1952  chi2Matrix[0](0, 0) = 0.694371;
1953  chi2Matrix[0](0, 1) = -0.305629;
1954  chi2Matrix[0](0, 2) = -0.305629;
1955  chi2Matrix[0](0, 3) = 0.;
1956  chi2Matrix[0](0, 4) = 0.;
1957  chi2Matrix[0](0, 5) = 0.;
1958  chi2Matrix[0](0, 6) = 0.;
1959  chi2Matrix[0](0, 7) = 0.;
1960  chi2Matrix[0](0, 8) = 0.;
1961  chi2Matrix[0](0, 9) = 0.;
1962  chi2Matrix[0](1, 0) = -0.305629;
1963  chi2Matrix[0](1, 1) = 0.694371;
1964  chi2Matrix[0](1, 2) = -0.305629;
1965  chi2Matrix[0](1, 3) = 0.;
1966  chi2Matrix[0](1, 4) = 0.;
1967  chi2Matrix[0](1, 5) = 0.;
1968  chi2Matrix[0](1, 6) = 0.;
1969  chi2Matrix[0](1, 7) = 0.;
1970  chi2Matrix[0](1, 8) = 0.;
1971  chi2Matrix[0](1, 9) = 0.;
1972  chi2Matrix[0](2, 0) = -0.305629;
1973  chi2Matrix[0](2, 1) = -0.305629;
1974  chi2Matrix[0](2, 2) = 0.694371;
1975  chi2Matrix[0](2, 3) = 0.;
1976  chi2Matrix[0](2, 4) = 0.;
1977  chi2Matrix[0](2, 5) = 0.;
1978  chi2Matrix[0](2, 6) = 0.;
1979  chi2Matrix[0](2, 7) = 0.;
1980  chi2Matrix[0](2, 8) = 0.;
1981  chi2Matrix[0](2, 9) = 0.;
1982  chi2Matrix[0](3, 0) = 0.;
1983  chi2Matrix[0](3, 1) = 0.;
1984  chi2Matrix[0](3, 2) = 0.;
1985  chi2Matrix[0](3, 3) = 0.;
1986  chi2Matrix[0](3, 4) = 0.;
1987  chi2Matrix[0](3, 5) = 0.;
1988  chi2Matrix[0](3, 6) = 0.;
1989  chi2Matrix[0](3, 7) = 0.;
1990  chi2Matrix[0](3, 8) = 0.;
1991  chi2Matrix[0](3, 9) = 0.;
1992  chi2Matrix[0](4, 0) = 0.;
1993  chi2Matrix[0](4, 1) = 0.;
1994  chi2Matrix[0](4, 2) = 0.;
1995  chi2Matrix[0](4, 3) = 0.;
1996  chi2Matrix[0](4, 4) = 0.8027116;
1997  chi2Matrix[0](4, 5) = -0.2517103;
1998  chi2Matrix[0](4, 6) = -0.2232882;
1999  chi2Matrix[0](4, 7) = -0.1716192;
2000  chi2Matrix[0](4, 8) = -0.1239006;
2001  chi2Matrix[0](4, 9) = 0.;
2002  chi2Matrix[0](5, 0) = 0.;
2003  chi2Matrix[0](5, 1) = 0.;
2004  chi2Matrix[0](5, 2) = 0.;
2005  chi2Matrix[0](5, 3) = 0.;
2006  chi2Matrix[0](5, 4) = -0.2517103;
2007  chi2Matrix[0](5, 5) = 0.6528964;
2008  chi2Matrix[0](5, 6) = -0.2972839;
2009  chi2Matrix[0](5, 7) = -0.2067162;
2010  chi2Matrix[0](5, 8) = -0.1230729;
2011  chi2Matrix[0](5, 9) = 0.;
2012  chi2Matrix[0](6, 0) = 0.;
2013  chi2Matrix[0](6, 1) = 0.;
2014  chi2Matrix[0](6, 2) = 0.;
2015  chi2Matrix[0](6, 3) = 0.;
2016  chi2Matrix[0](6, 4) = -0.2232882;
2017  chi2Matrix[0](6, 5) = -0.2972839;
2018  chi2Matrix[0](6, 6) = 0.7413607;
2019  chi2Matrix[0](6, 7) = -0.1883866;
2020  chi2Matrix[0](6, 8) = -0.1235052;
2021  chi2Matrix[0](6, 9) = 0.;
2022  chi2Matrix[0](7, 0) = 0.;
2023  chi2Matrix[0](7, 1) = 0.;
2024  chi2Matrix[0](7, 2) = 0.;
2025  chi2Matrix[0](7, 3) = 0.;
2026  chi2Matrix[0](7, 4) = -0.1716192;
2027  chi2Matrix[0](7, 5) = -0.2067162;
2028  chi2Matrix[0](7, 6) = -0.1883866;
2029  chi2Matrix[0](7, 7) = 0.844935;
2030  chi2Matrix[0](7, 8) = -0.124291;
2031  chi2Matrix[0](7, 9) = 0.;
2032  chi2Matrix[0](8, 0) = 0.;
2033  chi2Matrix[0](8, 1) = 0.;
2034  chi2Matrix[0](8, 2) = 0.;
2035  chi2Matrix[0](8, 3) = 0.;
2036  chi2Matrix[0](8, 4) = -0.1239006;
2037  chi2Matrix[0](8, 5) = -0.1230729;
2038  chi2Matrix[0](8, 6) = -0.1235052;
2039  chi2Matrix[0](8, 7) = -0.124291;
2040  chi2Matrix[0](8, 8) = 0.8749833;
2041  chi2Matrix[0](8, 9) = 0.;
2042  chi2Matrix[0](9, 0) = 0.;
2043  chi2Matrix[0](9, 1) = 0.;
2044  chi2Matrix[0](9, 2) = 0.;
2045  chi2Matrix[0](9, 3) = 0.;
2046  chi2Matrix[0](9, 4) = 0.;
2047  chi2Matrix[0](9, 5) = 0.;
2048  chi2Matrix[0](9, 6) = 0.;
2049  chi2Matrix[0](9, 7) = 0.;
2050  chi2Matrix[0](9, 8) = 0.;
2051  chi2Matrix[0](9, 9) = 0.;
2052  } else if (getWeightsFromFile_) {
2053  //Read from file
2054  edm::LogInfo("EcalTrivialConditionRetriever")
2055  << "Reading chi2Matrix from file " << edm::FileInPath(chi2MatrixFile_).fullPath().c_str();
2056  std::ifstream chi2MatrixFile(edm::FileInPath(chi2MatrixFile_).fullPath().c_str());
2057  int tdcBin = 0;
2058  while (!chi2MatrixFile.eof() && tdcBin < nTDCbins_) {
2059  // chi2Matrix[tdcBin].resize(10);
2060  for (int j = 0; j < 10; ++j) {
2061  for (int l = 0; l < 10; ++l) {
2062  float ww;
2063  chi2MatrixFile >> ww;
2064  chi2Matrix[tdcBin](j, l) = ww;
2065  }
2066  }
2067  ++tdcBin;
2068  }
2069  assert(tdcBin == nTDCbins_);
2070  } else {
2071  //Not supported
2072  edm::LogError("EcalTrivialConditionRetriever") << "Configuration not supported. Exception is raised ";
2073  throw cms::Exception("WrongConfig");
2074  }
2075 
2076  // for (int i=0;i<nTDCbins_;i++)
2077  // {
2078  // assert(chi2Matrix[i].size() == 10);
2079  chi2Matrix_ = chi2Matrix;
2080  // }
2081 
2082  std::vector<EcalWeightSet::EcalChi2WeightMatrix> chi2MatrixAft(nTDCbins_);
2083  if (!getWeightsFromFile_ && nTDCbins_ == 1) {
2084  // chi2MatrixAft[0].resize(10);
2085  // for (int i=0;i<10;i++)
2086  // chi2MatrixAft[0][i].resize(10);
2087 
2088  chi2MatrixAft[0](0, 0) = 0.;
2089  chi2MatrixAft[0](0, 1) = 0.;
2090  chi2MatrixAft[0](0, 2) = 0.;
2091  chi2MatrixAft[0](0, 3) = 0.;
2092  chi2MatrixAft[0](0, 4) = 0.;
2093  chi2MatrixAft[0](0, 5) = 0.;
2094  chi2MatrixAft[0](0, 6) = 0.;
2095  chi2MatrixAft[0](0, 7) = 0.;
2096  chi2MatrixAft[0](0, 8) = 0.;
2097  chi2MatrixAft[0](0, 9) = 0.;
2098  chi2MatrixAft[0](1, 0) = 0.;
2099  chi2MatrixAft[0](1, 1) = 0.;
2100  chi2MatrixAft[0](1, 2) = 0.;
2101  chi2MatrixAft[0](1, 3) = 0.;
2102  chi2MatrixAft[0](1, 4) = 0.;
2103  chi2MatrixAft[0](1, 5) = 0.;
2104  chi2MatrixAft[0](1, 6) = 0.;
2105  chi2MatrixAft[0](1, 7) = 0.;
2106  chi2MatrixAft[0](1, 8) = 0.;
2107  chi2MatrixAft[0](1, 9) = 0.;
2108  chi2MatrixAft[0](2, 0) = 0.;
2109  chi2MatrixAft[0](2, 1) = 0.;
2110  chi2MatrixAft[0](2, 2) = 0.;
2111  chi2MatrixAft[0](2, 3) = 0.;
2112  chi2MatrixAft[0](2, 4) = 0.;
2113  chi2MatrixAft[0](2, 5) = 0.;
2114  chi2MatrixAft[0](2, 6) = 0.;
2115  chi2MatrixAft[0](2, 7) = 0.;
2116  chi2MatrixAft[0](2, 8) = 0.;
2117  chi2MatrixAft[0](2, 9) = 0.;
2118  chi2MatrixAft[0](3, 0) = 0.;
2119  chi2MatrixAft[0](3, 1) = 0.;
2120  chi2MatrixAft[0](3, 2) = 0.;
2121  chi2MatrixAft[0](3, 3) = 0.;
2122  chi2MatrixAft[0](3, 4) = 0.;
2123  chi2MatrixAft[0](3, 5) = 0.;
2124  chi2MatrixAft[0](3, 6) = 0.;
2125  chi2MatrixAft[0](3, 7) = 0.;
2126  chi2MatrixAft[0](3, 8) = 0.;
2127  chi2MatrixAft[0](3, 9) = 0.;
2128  chi2MatrixAft[0](4, 0) = 0.;
2129  chi2MatrixAft[0](4, 1) = 0.;
2130  chi2MatrixAft[0](4, 2) = 0.;
2131  chi2MatrixAft[0](4, 3) = 0.;
2132  chi2MatrixAft[0](4, 4) = 0.8030884;
2133  chi2MatrixAft[0](4, 5) = -0.2543541;
2134  chi2MatrixAft[0](4, 6) = -0.2243544;
2135  chi2MatrixAft[0](4, 7) = -0.1698177;
2136  chi2MatrixAft[0](4, 8) = -0.1194506;
2137  chi2MatrixAft[0](4, 9) = 0.;
2138  chi2MatrixAft[0](5, 0) = 0.;
2139  chi2MatrixAft[0](5, 1) = 0.;
2140  chi2MatrixAft[0](5, 2) = 0.;
2141  chi2MatrixAft[0](5, 3) = 0.;
2142  chi2MatrixAft[0](5, 4) = -0.2543541;
2143  chi2MatrixAft[0](5, 5) = 0.6714465;
2144  chi2MatrixAft[0](5, 6) = -0.2898025;
2145  chi2MatrixAft[0](5, 7) = -0.2193564;
2146  chi2MatrixAft[0](5, 8) = -0.1542964;
2147  chi2MatrixAft[0](5, 9) = 0.;
2148  chi2MatrixAft[0](6, 0) = 0.;
2149  chi2MatrixAft[0](6, 1) = 0.;
2150  chi2MatrixAft[0](6, 2) = 0.;
2151  chi2MatrixAft[0](6, 3) = 0.;
2152  chi2MatrixAft[0](6, 4) = -0.2243544;
2153  chi2MatrixAft[0](6, 5) = -0.2898025;
2154  chi2MatrixAft[0](6, 6) = 0.7443781;
2155  chi2MatrixAft[0](6, 7) = -0.1934846;
2156  chi2MatrixAft[0](6, 8) = -0.136098;
2157  chi2MatrixAft[0](6, 9) = 0.;
2158  chi2MatrixAft[0](7, 0) = 0.;
2159  chi2MatrixAft[0](7, 1) = 0.;
2160  chi2MatrixAft[0](7, 2) = 0.;
2161  chi2MatrixAft[0](7, 3) = 0.;
2162  chi2MatrixAft[0](7, 4) = -0.1698177;
2163  chi2MatrixAft[0](7, 5) = -0.2193564;
2164  chi2MatrixAft[0](7, 6) = -0.1934846;
2165  chi2MatrixAft[0](7, 7) = 0.8535482;
2166  chi2MatrixAft[0](7, 8) = -0.1030149;
2167  chi2MatrixAft[0](7, 9) = 0.;
2168  chi2MatrixAft[0](8, 0) = 0.;
2169  chi2MatrixAft[0](8, 1) = 0.;
2170  chi2MatrixAft[0](8, 2) = 0.;
2171  chi2MatrixAft[0](8, 3) = 0.;
2172  chi2MatrixAft[0](8, 4) = -0.1194506;
2173  chi2MatrixAft[0](8, 5) = -0.1542964;
2174  chi2MatrixAft[0](8, 6) = -0.136098;
2175  chi2MatrixAft[0](8, 7) = -0.1030149;
2176  chi2MatrixAft[0](8, 8) = 0.9275388;
2177  chi2MatrixAft[0](8, 9) = 0.;
2178  chi2MatrixAft[0](9, 0) = 0.;
2179  chi2MatrixAft[0](9, 1) = 0.;
2180  chi2MatrixAft[0](9, 2) = 0.;
2181  chi2MatrixAft[0](9, 3) = 0.;
2182  chi2MatrixAft[0](9, 4) = 0.;
2183  chi2MatrixAft[0](9, 5) = 0.;
2184  chi2MatrixAft[0](9, 6) = 0.;
2185  chi2MatrixAft[0](9, 7) = 0.;
2186  chi2MatrixAft[0](9, 8) = 0.;
2187  chi2MatrixAft[0](9, 9) = 0.;
2188  } else if (getWeightsFromFile_) {
2189  //Read from file
2190  edm::LogInfo("EcalTrivialConditionRetriever")
2191  << "Reading chi2MatrixAft from file " << edm::FileInPath(chi2MatrixAftFile_).fullPath().c_str();
2192  std::ifstream chi2MatrixAftFile(edm::FileInPath(chi2MatrixAftFile_).fullPath().c_str());
2193  int tdcBin = 0;
2194  while (!chi2MatrixAftFile.eof() && tdcBin < nTDCbins_) {
2195  // chi2MatrixAft[tdcBin].resize(10);
2196  for (int j = 0; j < 10; ++j) {
2197  for (int l = 0; l < 10; ++l) {
2198  float ww;
2199  chi2MatrixAftFile >> ww;
2200  chi2MatrixAft[tdcBin](j, l) = ww;
2201  }
2202  }
2203  ++tdcBin;
2204  }
2205  assert(tdcBin == nTDCbins_);
2206  } else {
2207  //Not supported
2208  edm::LogError("EcalTrivialConditionRetriever") << "Configuration not supported. Exception is raised ";
2209  throw cms::Exception("WrongConfig");
2210  }
2211 
2212  // for (int i=0;i<nTDCbins_;i++)
2213  // {
2214  // assert(chi2MatrixAft[i].size() == 10);
2215  chi2MatrixAft_ = chi2MatrixAft;
2216  // }
2217 }
2218 
2219 // --------------------------------------------------------------------------------
2220 
2222  const EcalChannelStatusRcd&) {
2223  auto ecalStatus = std::make_unique<EcalChannelStatus>();
2224 
2225  // start by setting all statuses to 0
2226 
2227  // barrel
2228  for (int ieta = -EBDetId::MAX_IETA; ieta <= EBDetId::MAX_IETA; ++ieta) {
2229  if (ieta == 0)
2230  continue;
2231  for (int iphi = EBDetId::MIN_IPHI; iphi <= EBDetId::MAX_IPHI; ++iphi) {
2232  if (EBDetId::validDetId(ieta, iphi)) {
2233  EBDetId ebid(ieta, iphi);
2234  ecalStatus->setValue(ebid, 0);
2235  }
2236  }
2237  }
2238  // endcap
2239  for (int iX = EEDetId::IX_MIN; iX <= EEDetId::IX_MAX; ++iX) {
2240  for (int iY = EEDetId::IY_MIN; iY <= EEDetId::IY_MAX; ++iY) {
2241  // make an EEDetId since we need EEDetId::rawId() to be used as the key for the pedestals
2242  if (EEDetId::validDetId(iX, iY, 1)) {
2243  EEDetId eedetidpos(iX, iY, 1);
2244  ecalStatus->setValue(eedetidpos, 0);
2245  }
2246  if (EEDetId::validDetId(iX, iY, -1)) {
2247  EEDetId eedetidneg(iX, iY, -1);
2248  ecalStatus->setValue(eedetidneg, 0);
2249  }
2250  }
2251  }
2252 
2253  // overwrite the statuses which are in the file
2254 
2255  edm::LogInfo("EcalTrivialConditionRetriever")
2256  << "Reading channel statuses from file " << edm::FileInPath(channelStatusFile_).fullPath().c_str();
2257  std::ifstream statusFile(edm::FileInPath(channelStatusFile_).fullPath().c_str());
2258  if (!statusFile.good()) {
2259  edm::LogError("EcalTrivialConditionRetriever") << "*** Problems opening file: " << channelStatusFile_;
2260  throw cms::Exception("Cannot open ECAL channel status file");
2261  }
2262 
2263  std::string EcalSubDet;
2264  std::string str;
2265  int hashIndex(0);
2266  int status(0);
2267 
2268  while (!statusFile.eof()) {
2269  statusFile >> EcalSubDet;
2270  if (EcalSubDet != std::string("EB") && EcalSubDet != std::string("EE")) {
2271  std::getline(statusFile, str);
2272  continue;
2273  } else {
2274  statusFile >> hashIndex >> status;
2275  }
2276  // std::cout << EcalSubDet << " " << hashIndex << " " << status;
2277 
2278  if (EcalSubDet == std::string("EB")) {
2279  EBDetId ebid = EBDetId::unhashIndex(hashIndex);
2280  ecalStatus->setValue(ebid, status);
2281  } else if (EcalSubDet == std::string("EE")) {
2282  EEDetId eedetid = EEDetId::unhashIndex(hashIndex);
2283  ecalStatus->setValue(eedetid, status);
2284  } else {
2285  edm::LogError("EcalTrivialConditionRetriever") << " *** " << EcalSubDet << " is neither EB nor EE ";
2286  }
2287  }
2288  // the file is supposed to be in the form -- FIXME
2289 
2290  statusFile.close();
2291  return ecalStatus;
2292 }
2293 
2295  auto ical = std::make_unique<EcalChannelStatus>();
2296  // barrel
2297  for (int ieta = -EBDetId::MAX_IETA; ieta <= EBDetId::MAX_IETA; ++ieta) {
2298  if (ieta == 0)
2299  continue;
2300  for (int iphi = EBDetId::MIN_IPHI; iphi <= EBDetId::MAX_IPHI; ++iphi) {
2301  if (EBDetId::validDetId(ieta, iphi)) {
2302  EBDetId ebid(ieta, iphi);
2303  ical->setValue(ebid, 0);
2304  }
2305  }
2306  }
2307  // endcap
2308  for (int iX = EEDetId::IX_MIN; iX <= EEDetId::IX_MAX; ++iX) {
2309  for (int iY = EEDetId::IY_MIN; iY <= EEDetId::IY_MAX; ++iY) {
2310  // make an EEDetId since we need EEDetId::rawId() to be used as the key for the pedestals
2311  if (EEDetId::validDetId(iX, iY, 1)) {
2312  EEDetId eedetidpos(iX, iY, 1);
2313  ical->setValue(eedetidpos, 0);
2314  }
2315  if (EEDetId::validDetId(iX, iY, -1)) {
2316  EEDetId eedetidneg(iX, iY, -1);
2317  ical->setValue(eedetidneg, 0);
2318  }
2319  }
2320  }
2321  return ical;
2322 }
2323 
2324 // --------------------------------------------------------------------------------
2326  const EcalDQMChannelStatusRcd&) {
2327  uint32_t sta(0);
2328 
2329  auto ical = std::make_unique<EcalDQMChannelStatus>();
2330  // barrel
2331  for (int ieta = -EBDetId::MAX_IETA; ieta <= EBDetId::MAX_IETA; ++ieta) {
2332  if (ieta == 0)
2333  continue;
2334  for (int iphi = EBDetId::MIN_IPHI; iphi <= EBDetId::MAX_IPHI; ++iphi) {
2335  if (EBDetId::validDetId(ieta, iphi)) {
2336  EBDetId ebid(ieta, iphi);
2337  ical->setValue(ebid, sta);
2338  }
2339  }
2340  }
2341  // endcap
2342  for (int iX = EEDetId::IX_MIN; iX <= EEDetId::IX_MAX; ++iX) {
2343  for (int iY = EEDetId::IY_MIN; iY <= EEDetId::IY_MAX; ++iY) {
2344  // make an EEDetId since we need EEDetId::rawId() to be used as the key for the pedestals
2345  if (EEDetId::validDetId(iX, iY, 1)) {
2346  EEDetId eedetidpos(iX, iY, 1);
2347  ical->setValue(eedetidpos, sta);
2348  }
2349  if (EEDetId::validDetId(iX, iY, -1)) {
2350  EEDetId eedetidneg(iX, iY, -1);
2351  ical->setValue(eedetidneg, sta);
2352  }
2353  }
2354  }
2355  return ical;
2356 }
2357 // --------------------------------------------------------------------------------
2358 
2360  const EcalDQMTowerStatusRcd&) {
2361  auto ical = std::make_unique<EcalDQMTowerStatus>();
2362 
2363  uint32_t sta(0);
2364 
2365  // barrel
2366  int iz = 0;
2367  for (int k = 0; k < 2; k++) {
2368  if (k == 0)
2369  iz = -1;
2370  if (k == 1)
2371  iz = +1;
2372  for (int i = 1; i < 73; i++) {
2373  for (int j = 1; j < 18; j++) {
2375  EcalTrigTowerDetId ebid(iz, EcalBarrel, j, i);
2376 
2377  ical->setValue(ebid, sta);
2378  }
2379  }
2380  }
2381  }
2382 
2383  // endcap
2384  for (int k = 0; k < 2; k++) {
2385  if (k == 0)
2386  iz = -1;
2387  if (k == 1)
2388  iz = +1;
2389  for (int i = 1; i < 21; i++) {
2390  for (int j = 1; j < 21; j++) {
2391  if (EcalScDetId::validDetId(i, j, iz)) {
2392  EcalScDetId eeid(i, j, iz);
2393  ical->setValue(eeid, sta);
2394  }
2395  }
2396  }
2397  }
2398 
2399  return ical;
2400 }
2401 
2402 // --------------------------------------------------------------------------------
2404  const EcalDCSTowerStatusRcd&) {
2405  auto ical = std::make_unique<EcalDCSTowerStatus>();
2406 
2407  int status(0);
2408 
2409  // barrel
2410  int iz = 0;
2411  for (int k = 0; k < 2; k++) {
2412  if (k == 0)
2413  iz = -1;
2414  if (k == 1)
2415  iz = +1;
2416  for (int i = 1; i < 73; i++) {
2417  for (int j = 1; j < 18; j++) {
2419  EcalTrigTowerDetId ebid(iz, EcalBarrel, j, i);
2420 
2421  ical->setValue(ebid, status);
2422  }
2423  }
2424  }
2425  }
2426 
2427  // endcap
2428  for (int k = 0; k < 2; k++) {
2429  if (k == 0)
2430  iz = -1;
2431  if (k == 1)
2432  iz = +1;
2433  for (int i = 1; i < 21; i++) {
2434  for (int j = 1; j < 21; j++) {
2435  if (EcalScDetId::validDetId(i, j, iz)) {
2436  EcalScDetId eeid(i, j, iz);
2437  ical->setValue(eeid, status);
2438  }
2439  }
2440  }
2441  }
2442 
2443  return ical;
2444 }
2445 // --------------------------------------------------------------------------------
2446 
2448  const EcalDAQTowerStatusRcd&) {
2449  auto ical = std::make_unique<EcalDAQTowerStatus>();
2450 
2451  int status(0);
2452 
2453  // barrel
2454  int iz = 0;
2455  for (int k = 0; k < 2; k++) {
2456  if (k == 0)
2457  iz = -1;
2458  if (k == 1)
2459  iz = +1;
2460  for (int i = 1; i < 73; i++) {
2461  for (int j = 1; j < 18; j++) {
2463  EcalTrigTowerDetId ebid(iz, EcalBarrel, j, i);
2464 
2465  ical->setValue(ebid, status);
2466  }
2467  }
2468  }
2469  }
2470 
2471  // endcap
2472  for (int k = 0; k < 2; k++) {
2473  if (k == 0)
2474  iz = -1;
2475  if (k == 1)
2476  iz = +1;
2477  for (int i = 1; i < 21; i++) {
2478  for (int j = 1; j < 21; j++) {
2479  if (EcalScDetId::validDetId(i, j, iz)) {
2480  EcalScDetId eeid(i, j, iz);
2481  ical->setValue(eeid, status);
2482  }
2483  }
2484  }
2485  }
2486 
2487  return ical;
2488 }
2489 // --------------------------------------------------------------------------------
2490 
2492  const EcalTPGCrystalStatusRcd&) {
2493  auto ecalStatus = std::make_unique<EcalTPGCrystalStatus>();
2494 
2495  // start by setting all statuses to 0
2496 
2497  // barrel
2498  for (int ieta = -EBDetId::MAX_IETA; ieta <= EBDetId::MAX_IETA; ++ieta) {
2499  if (ieta == 0)
2500  continue;
2501  for (int iphi = EBDetId::MIN_IPHI; iphi <= EBDetId::MAX_IPHI; ++iphi) {
2502  if (EBDetId::validDetId(ieta, iphi)) {
2503  EBDetId ebid(ieta, iphi);
2504  ecalStatus->setValue(ebid, 0);
2505  }
2506  }
2507  }
2508  // endcap
2509  for (int iX = EEDetId::IX_MIN; iX <= EEDetId::IX_MAX; ++iX) {
2510  for (int iY = EEDetId::IY_MIN; iY <= EEDetId::IY_MAX; ++iY) {
2511  // make an EEDetId since we need EEDetId::rawId() to be used as the key for the pedestals
2512  if (EEDetId::validDetId(iX, iY, 1)) {
2513  EEDetId eedetidpos(iX, iY, 1);
2514  ecalStatus->setValue(eedetidpos, 0);
2515  }
2516  if (EEDetId::validDetId(iX, iY, -1)) {
2517  EEDetId eedetidneg(iX, iY, -1);
2518  ecalStatus->setValue(eedetidneg, 0);
2519  }
2520  }
2521  }
2522 
2523  // overwrite the statuses which are in the file
2524 
2525  edm::LogInfo("EcalTrivialConditionRetriever")
2526  << "Reading channel statuses from file " << edm::FileInPath(channelStatusFile_).fullPath().c_str();
2527  std::ifstream statusFile(edm::FileInPath(channelStatusFile_).fullPath().c_str());
2528  if (!statusFile.good()) {
2529  edm::LogError("EcalTrivialConditionRetriever") << "*** Problems opening file: " << channelStatusFile_;
2530  throw cms::Exception("Cannot open ECAL channel status file");
2531  }
2532 
2533  std::string EcalSubDet;
2534  std::string str;
2535  int hashIndex(0);
2536  int status(0);
2537 
2538  while (!statusFile.eof()) {
2539  statusFile >> EcalSubDet;
2540  if (EcalSubDet != std::string("EB") && EcalSubDet != std::string("EE")) {
2541  std::getline(statusFile, str);
2542  continue;
2543  } else {
2544  statusFile >> hashIndex >> status;
2545  }
2546  // std::cout << EcalSubDet << " " << hashIndex << " " << status;
2547 
2548  if (EcalSubDet == std::string("EB")) {
2549  EBDetId ebid = EBDetId::unhashIndex(hashIndex);
2550  ecalStatus->setValue(ebid, status);
2551  } else if (EcalSubDet == std::string("EE")) {
2552  EEDetId eedetid = EEDetId::unhashIndex(hashIndex);
2553  ecalStatus->setValue(eedetid, status);
2554  } else {
2555  edm::LogError("EcalTrivialConditionRetriever") << " *** " << EcalSubDet << " is neither EB nor EE ";
2556  }
2557  }
2558  // the file is supposed to be in the form -- FIXME
2559 
2560  statusFile.close();
2561  return ecalStatus;
2562 }
2563 
2565  const EcalTPGCrystalStatusRcd&) {
2566  auto ical = std::make_unique<EcalTPGCrystalStatus>();
2567  // barrel
2568  for (int ieta = -EBDetId::MAX_IETA; ieta <= EBDetId::MAX_IETA; ++ieta) {
2569  if (ieta == 0)
2570  continue;
2571  for (int iphi = EBDetId::MIN_IPHI; iphi <= EBDetId::MAX_IPHI; ++iphi) {
2572  if (EBDetId::validDetId(ieta, iphi)) {
2573  EBDetId ebid(ieta, iphi);
2574  ical->setValue(ebid, 0);
2575  }
2576  }
2577  }
2578  // endcap
2579  for (int iX = EEDetId::IX_MIN; iX <= EEDetId::IX_MAX; ++iX) {
2580  for (int iY = EEDetId::IY_MIN; iY <= EEDetId::IY_MAX; ++iY) {
2581  // make an EEDetId since we need EEDetId::rawId() to be used as the key for the pedestals
2582  if (EEDetId::validDetId(iX, iY, 1)) {
2583  EEDetId eedetidpos(iX, iY, 1);
2584  ical->setValue(eedetidpos, 0);
2585  }
2586  if (EEDetId::validDetId(iX, iY, -1)) {
2587  EEDetId eedetidneg(iX, iY, -1);
2588  ical->setValue(eedetidneg, 0);
2589  }
2590  }
2591  }
2592  return ical;
2593 }
2594 
2596  const EcalIntercalibConstantsRcd&) {
2597  std::unique_ptr<EcalIntercalibConstants> ical;
2598  // std::make_unique<EcalIntercalibConstants>();
2599 
2600  // Read the values from a txt file
2601  // -------------------------------
2602 
2603  edm::LogInfo("EcalTrivialConditionRetriever")
2604  << "Reading intercalibration constants from file " << intercalibConstantsFile_.c_str();
2605 
2606  if (intercalibConstantsFile_.find(".xml") != std::string::npos) {
2607  edm::LogInfo("generating Intercalib from xml file");
2608 
2609  EcalCondHeader h;
2611  EcalIntercalibConstantsXMLTranslator::readXML(intercalibConstantsFile_, h, *rcd);
2612 
2613  if (totLumi_ != 0 || instLumi_ != 0) {
2614  edm::LogInfo("implementing ageing for intercalib");
2615 
2617 
2618  if (intercalibConstantsMCFile_.find(".xml") != std::string::npos) {
2619  edm::LogInfo("generating IntercalibMC from xml file");
2620 
2621  EcalCondHeader h;
2622  EcalIntercalibConstantsMCXMLTranslator::readXML(intercalibConstantsMCFile_, h, *rcdMC);
2623 
2624  } else {
2625  edm::LogInfo("please provide the xml file of the EcalIntercalibConstantsMC");
2626  }
2627 
2628  TRandom3* gRandom = new TRandom3();
2629 
2630  EnergyResolutionVsLumi ageing;
2631  ageing.setLumi(totLumi_);
2632  ageing.setInstLumi(instLumi_);
2633 
2634  const EcalIntercalibConstantMap& mymap = rcd->getMap();
2635  const EcalIntercalibConstantMCMap& mymapMC = rcdMC->getMap();
2636 
2637  for (int ieta = -EBDetId::MAX_IETA; ieta <= EBDetId::MAX_IETA; ++ieta) {
2638  if (ieta == 0)
2639  continue;
2640 
2641  double eta = EBDetId::approxEta(EBDetId(ieta, 1));
2642  eta = fabs(eta);
2643  double constantTerm = ageing.calcresolutitonConstantTerm(eta);
2644  edm::LogInfo("EB at eta=") << eta << " constant term is " << constantTerm;
2645 
2646  for (int iphi = EBDetId::MIN_IPHI; iphi <= EBDetId::MAX_IPHI; ++iphi) {
2647  // make an EBDetId since we need EBDetId::rawId() to be used as the key for the pedestals
2648  if (EBDetId::validDetId(ieta, iphi)) {
2649  EBDetId ebid(ieta, iphi);
2650  EcalIntercalibConstants::const_iterator idref = mymap.find(ebid);
2651  EcalIntercalibConstant icalconstant = 1;
2652  if (idref != mymap.end())
2653  icalconstant = (*idref);
2654 
2655  EcalIntercalibConstantsMC::const_iterator idrefMC = mymapMC.find(ebid);
2656  EcalIntercalibConstantMC icalconstantMC = 1;
2657  if (idrefMC != mymapMC.end())
2658  icalconstantMC = (*idrefMC);
2659 
2660  double r = gRandom->Gaus(0, constantTerm);
2661 
2662  if (iphi == 10)
2663  edm::LogInfo("EB at eta=") << eta << " IC=" << icalconstant << " ICMC=" << icalconstantMC
2664  << " smear=" << r << " ";
2665 
2666  icalconstant = icalconstant + r * 1.29 * icalconstantMC;
2667  rcd->setValue(ebid.rawId(), icalconstant);
2668 
2669  if (iphi == 10)
2670  edm::LogInfo("newIC=") << icalconstant;
2671 
2672  EcalIntercalibConstant icalconstant2 = (*idref);
2673  if (icalconstant != icalconstant2)
2674  edm::LogInfo(">>>> error in smearing intercalib");
2675  }
2676  }
2677  }
2678 
2679  for (int iX = EEDetId::IX_MIN; iX <= EEDetId::IX_MAX; ++iX) {
2680  for (int iY = EEDetId::IY_MIN; iY <= EEDetId::IY_MAX; ++iY) {
2681  // make an EEDetId since we need EEDetId::rawId() to be used as the key for the pedestals
2682  if (EEDetId::validDetId(iX, iY, 1)) {
2683  EEDetId eedetidpos(iX, iY, 1);
2684  double eta =
2685  -log(tan(0.5 * atan(sqrt((iX - 50.0) * (iX - 50.0) + (iY - 50.0) * (iY - 50.0)) * 2.98 / 328.)));
2686  eta = fabs(eta);
2687  double constantTerm = ageing.calcresolutitonConstantTerm(eta);
2688  if (iX == 50)
2689  edm::LogInfo("EE at eta=") << eta << " constant term is " << constantTerm;
2690 
2691  EcalIntercalibConstants::const_iterator idref = mymap.find(eedetidpos);
2692  EcalIntercalibConstant icalconstant = 1;
2693  if (idref != mymap.end())
2694  icalconstant = (*idref);
2695 
2696  EcalIntercalibConstantsMC::const_iterator idrefMC = mymapMC.find(eedetidpos);
2697  EcalIntercalibConstantMC icalconstantMC = 1;
2698  if (idrefMC != mymapMC.end())
2699  icalconstantMC = (*idrefMC);
2700 
2701  double r = gRandom->Gaus(0, constantTerm);
2702 
2703  if (iX == 10)
2704  edm::LogInfo("EE at eta=") << eta << " IC=" << icalconstant << " ICMC=" << icalconstantMC
2705  << " smear=" << r << " ";
2706  icalconstant = icalconstant + r * 1.29 * icalconstantMC;
2707  rcd->setValue(eedetidpos.rawId(), icalconstant);
2708  if (iX == 10)
2709  edm::LogInfo("newIC=") << icalconstant;
2710  }
2711  if (EEDetId::validDetId(iX, iY, -1)) {
2712  EEDetId eedetidneg(iX, iY, -1);
2713  double eta =
2714  -log(tan(0.5 * atan(sqrt((iX - 50.0) * (iX - 50.0) + (iY - 50.0) * (iY - 50.0)) * 2.98 / 328.)));
2715  eta = fabs(eta);
2716  double constantTerm = ageing.calcresolutitonConstantTerm(eta);
2717  EcalIntercalibConstant icalconstant = 1;
2718 
2719  EcalIntercalibConstantsMC::const_iterator idrefMC = mymapMC.find(eedetidneg);
2720  EcalIntercalibConstantMC icalconstantMC = 1;
2721  if (idrefMC != mymapMC.end())
2722  icalconstantMC = (*idrefMC);
2723 
2724  double r = gRandom->Gaus(0, constantTerm);
2725  icalconstant = icalconstant + r * 1.29 * icalconstantMC;
2726  rcd->setValue(eedetidneg.rawId(), icalconstant);
2727  }
2728  }
2729  }
2730 
2731  ical = std::unique_ptr<EcalIntercalibConstants>(rcd);
2732 
2733  delete gRandom;
2734  }
2735 
2736  } else {
2737  ical = std::make_unique<EcalIntercalibConstants>();
2738 
2739  FILE* inpFile;
2740  inpFile = fopen(intercalibConstantsFile_.c_str(), "r");
2741  if (!inpFile) {
2742  edm::LogError("EcalTrivialConditionRetriever") << "*** Can not open file: " << intercalibConstantsFile_;
2743  throw cms::Exception("Cannot open inter-calibration coefficients txt file");
2744  }
2745 
2746  char line[256];
2747  std::ostringstream str;
2748  fgets(line, 255, inpFile);
2749  int sm_number = atoi(line);
2750  str << "sm: " << sm_number;
2751 
2752  fgets(line, 255, inpFile);
2753  //int nevents=atoi (line) ; // not necessary here just for online conddb
2754 
2755  fgets(line, 255, inpFile);
2756  std::string gen_tag = line;
2757  str << "gen tag: " << gen_tag; // should I use this?
2758 
2759  fgets(line, 255, inpFile);
2760  std::string cali_method = line;
2761  str << "cali method: " << cali_method << std::endl; // not important
2762 
2763  fgets(line, 255, inpFile);
2764  std::string cali_version = line;
2765  str << "cali version: " << cali_version << std::endl; // not important
2766 
2767  fgets(line, 255, inpFile);
2768  std::string cali_type = line;
2769  str << "cali type: " << cali_type; // not important
2770 
2771  edm::LogInfo("EcalTrivialConditionRetriever") << "[PIETRO] Intercalibration file - " << str.str();
2772 
2773  float calib[1700] = {1};
2774  int calib_status[1700] = {0};
2775 
2776  int ii = 0;
2777 
2778  while (fgets(line, 255, inpFile)) {
2779  ii++;
2780  int dmy_num = 0;
2781  float dmy_calib = 0.;
2782  float dmy_RMS = 0.;
2783  int dmy_events = 0;
2784  int dmy_status = 0;
2785  sscanf(line, "%d %f %f %d %d", &dmy_num, &dmy_calib, &dmy_RMS, &dmy_events, &dmy_status);
2786  assert(dmy_num >= 1);
2787  assert(dmy_num <= 1700);
2788  calib[dmy_num - 1] = dmy_calib;
2789  calib_status[dmy_num - 1] = dmy_status;
2790 
2791  // edm::LogInfo ("EcalTrivialConditionRetriever")
2792  // << "[PIETRO] cry = " << dmy_num
2793  // << " calib = " << calib[dmy_num-1]
2794  // << " RMS = " << dmy_RMS
2795  // << " events = " << dmy_events
2796  // << " status = " << calib_status[dmy_num-1]
2797  // << std::endl ;
2798  }
2799 
2800  fclose(inpFile); // close inp. file
2801  edm::LogInfo("EcalTrivialConditionRetriever") << "Read intercalibrations for " << ii << " xtals ";
2802  if (ii != 1700)
2803  edm::LogWarning("StoreEcalCondition") << "Some crystals missing, set to 1" << std::endl;
2804 
2805  // Transfer the data to the inter-calibration coefficients container
2806  // -----------------------------------------------------------------
2807 
2808  // DB supermodule always set to 1 for the TestBeam FIXME
2809  int sm_db = 1;
2810  // loop over channels
2811  for (int i = 0; i < 1700; i++) {
2812  //if (EBDetId::validDetId(iEta,iPhi)) {
2813  // CANNOT be used -- validDetId only checks ETA PHI method
2814  // doing a check by hand, here is the only place in CMSSW
2815  // outside TB code and EcalRawToDigi where needed
2816  // => no need for changing the DetId interface
2817  //
2818  // checking only sm_db -- guess can change with the above FIXME
2819  if (sm_db >= EBDetId::MIN_SM && sm_db <= EBDetId::MAX_SM) {
2820  EBDetId ebid(sm_db, i + 1, EBDetId::SMCRYSTALMODE);
2821  if (calib_status[i])
2822  ical->setValue(ebid.rawId(), calib[i]);
2823  else
2824  ical->setValue(ebid.rawId(), 1.);
2825  }
2826  //}
2827  } // loop over channels
2828  }
2829 
2830  return ical;
2831 }
2832 
2833 // new for the PF rec hit thresholds
2834 
2836  const EcalPFRecHitThresholdsRcd&) {
2837  std::unique_ptr<EcalPFRecHitThresholds> ical;
2838 
2839  // Reads the values from a txt file
2840  edm::LogInfo("EcalTrivialConditionRetriever")
2841  << "Reading PF RecHit Thresholds from file " << edm::FileInPath(pfRecHitFile_).fullPath().c_str();
2842 
2843  std::ifstream PFRecHitsFile(edm::FileInPath(pfRecHitFile_).fullPath().c_str());
2844 
2845  ical = std::make_unique<EcalPFRecHitThresholds>();
2846 
2847  // char line[50];
2848 
2849  int nxt = 0;
2850 
2851  edm::LogInfo("Going to multiply the sigmas by ") << pfRecHitThresholdsNSigmas_;
2852  edm::LogInfo("We will print some values ");
2853 
2854  while (!PFRecHitsFile.eof()) {
2855  // while (fgets(line,50,inpFile)) {
2856  float thresh;
2857  int eta = 0;
2858  int phi = 0;
2859  int zeta = 0;
2860  PFRecHitsFile >> eta >> phi >> zeta >> thresh;
2861  // sscanf(line, "%d %d %d %f", &eta, &phi, &zeta, &thresh);
2862 
2863  thresh = thresh * pfRecHitThresholdsNSigmas_;
2864 
2865  if (phi == 50)
2866  edm::LogInfo("EB ") << std::dec << eta << "/" << std::dec << phi << "/" << std::dec << zeta
2867  << " thresh: " << thresh;
2868  nxt = nxt + 1;
2869  if (EBDetId::validDetId(eta, phi)) {
2870  EBDetId ebid(eta, phi);
2871  ical->setValue(ebid.rawId(), thresh);
2872  }
2873  }
2874  PFRecHitsFile.close();
2875  // fclose(inpFile);
2876 
2877  edm::LogInfo("Read number of EB crystals: ") << nxt;
2878 
2879  //******************************************************
2880  edm::LogInfo("Now reading the EE file ... ");
2881  edm::LogInfo("We will multiply the sigma in EE by ") << pfRecHitThresholdsNSigmas_;
2882  edm::LogInfo("We will multiply the sigma in EE at high eta by") << pfRecHitThresholdsNSigmasHEta_;
2883  edm::LogInfo("We will print some values ");
2884 
2885  edm::LogInfo("EcalTrivialConditionRetriever")
2886  << "Reading PF RecHit Thresholds EE from file " << edm::FileInPath(pfRecHitFileEE_).fullPath().c_str();
2887  std::ifstream PFRecHitsFileEE(edm::FileInPath(pfRecHitFileEE_).fullPath().c_str());
2888 
2889  nxt = 0;
2890 
2891  while (!PFRecHitsFileEE.eof()) {
2892  // while (fgets(line,40,inpFileEE)) {
2893  float thresh;
2894  int ix = 0;
2895  int iy = 0;
2896  int iz = 0;
2897  PFRecHitsFileEE >> ix >> iy >> iz >> thresh;
2898  // sscanf(line, "%d %d %d %f", &ix, &iy,&iz, &thresh);
2899 
2900  double eta =
2901  -log(tan(0.5 * atan(sqrt((ix - 50.5) * (ix - 50.5) + (iy - 50.5) * (iy - 50.5)) * 2.98 / 328.))); // approx eta
2902 
2903  if (eta > 2.5) {
2904  thresh = thresh * pfRecHitThresholdsNSigmasHEta_;
2905  } else {
2906  thresh = thresh * pfRecHitThresholdsNSigmas_;
2907  }
2908 
2909  if (ix == 50)
2910  edm::LogInfo("EE ") << std::dec << ix << "/" << std::dec << iy << "/" << std::dec << iz << " thresh: " << thresh;
2911  if (EEDetId::validDetId(ix, iy, iz)) {
2912  EEDetId eeid(ix, iy, iz);
2913  ical->setValue(eeid.rawId(), thresh);
2914  }
2915  nxt = nxt + 1;
2916  }
2917  PFRecHitsFileEE.close();
2918  // fclose(inpFileEE);
2919  edm::LogInfo("Read number of EE crystals: ") << nxt;
2920  edm::LogInfo("end PF Rec Hits ... ");
2921 
2922  return ical;
2923 }
2924 
2927  std::unique_ptr<EcalIntercalibConstantsMC> ical;
2928  // std::make_unique<EcalIntercalibConstants>();
2929 
2930  // Read the values from a xml file
2931  // -------------------------------
2932 
2933  edm::LogInfo("EcalTrivialConditionRetriever")
2934  << "Reading intercalibration constants MC from file " << intercalibConstantsMCFile_.c_str();
2935 
2936  if (intercalibConstantsMCFile_.find(".xml") != std::string::npos) {
2937  edm::LogInfo("generating Intercalib MC from xml file");
2938 
2939  EcalCondHeader h;
2941  EcalIntercalibConstantsMCXMLTranslator::readXML(intercalibConstantsMCFile_, h, *rcd);
2942 
2943  ical = std::unique_ptr<EcalIntercalibConstants>(rcd);
2944 
2945  } else {
2946  edm::LogInfo("ERROR>>> please provide a xml file");
2947  }
2948 
2949  return ical;
2950 }
2951 
2953  const EcalIntercalibErrorsRcd&) {
2954  auto ical = std::make_unique<EcalIntercalibErrors>();
2955 
2956  // Read the values from a txt file
2957  // -------------------------------
2958 
2959  edm::LogInfo("EcalTrivialConditionRetriever")
2960  << "Reading intercalibration constants from file " << intercalibErrorsFile_.c_str();
2961 
2962  FILE* inpFile;
2963  inpFile = fopen(intercalibErrorsFile_.c_str(), "r");
2964  if (!inpFile) {
2965  edm::LogError("EcalTrivialConditionRetriever") << "*** Can not open file: " << intercalibErrorsFile_;
2966  throw cms::Exception("Cannot open inter-calibration coefficients txt file");
2967  }
2968 
2969  char line[256];
2970  std::ostringstream str;
2971  fgets(line, 255, inpFile);
2972  int sm_number = atoi(line);
2973  str << "sm: " << sm_number;
2974 
2975  fgets(line, 255, inpFile);
2976  //int nevents=atoi (line) ; // not necessary here just for online conddb
2977 
2978  fgets(line, 255, inpFile);
2979  std::string gen_tag = line;
2980  str << "gen tag: " << gen_tag; // should I use this?
2981 
2982  fgets(line, 255, inpFile);
2983  std::string cali_method = line;
2984  str << "cali method: " << cali_method << std::endl; // not important
2985 
2986  fgets(line, 255, inpFile);
2987  std::string cali_version = line;
2988  str << "cali version: " << cali_version << std::endl; // not important
2989 
2990  fgets(line, 255, inpFile);
2991  std::string cali_type = line;
2992  str << "cali type: " << cali_type; // not important
2993 
2994  edm::LogInfo("EcalTrivialConditionRetriever") << "[PIETRO] Intercalibration file - " << str.str() << std::endl;
2995 
2996  float calib[1700] = {1};
2997  int calib_status[1700] = {0};
2998 
2999  int ii = 0;
3000 
3001  while (fgets(line, 255, inpFile)) {
3002  ii++;
3003  int dmy_num = 0;
3004  float dmy_calib = 0.;
3005  float dmy_RMS = 0.;
3006  int dmy_events = 0;
3007  int dmy_status = 0;
3008  sscanf(line, "%d %f %f %d %d", &dmy_num, &dmy_calib, &dmy_RMS, &dmy_events, &dmy_status);
3009  assert(dmy_num >= 1);
3010  assert(dmy_num <= 1700);
3011  calib[dmy_num - 1] = dmy_calib;
3012  calib_status[dmy_num - 1] = dmy_status;
3013 
3014  // edm::LogInfo ("EcalTrivialConditionRetriever")
3015  // << "[PIETRO] cry = " << dmy_num
3016  // << " calib = " << calib[dmy_num-1]
3017  // << " RMS = " << dmy_RMS
3018  // << " events = " << dmy_events
3019  // << " status = " << calib_status[dmy_num-1]
3020  // << std::endl ;
3021  }
3022 
3023  fclose(inpFile); // close inp. file
3024  edm::LogInfo("EcalTrivialConditionRetriever") << "Read intercalibrations for " << ii << " xtals ";
3025  if (ii != 1700)
3026  edm::LogWarning("StoreEcalCondition") << "Some crystals missing, set to 1" << std::endl;
3027 
3028  // Transfer the data to the inter-calibration coefficients container
3029  // -----------------------------------------------------------------
3030 
3031  // DB supermodule always set to 1 for the TestBeam FIXME
3032  int sm_db = 1;
3033  // loop over channels
3034  for (int i = 0; i < 1700; i++) {
3035  //if (EBDetId::validDetId(iEta,iPhi)) {
3036  // CANNOT be used -- validDetId only checks ETA PHI method
3037  // doing a check by hand, here is the only place in CMSSW
3038  // outside TB code and EcalRawToDigi where needed
3039  // => no need for changing the DetId interface
3040  //
3041  // checking only sm_db -- guess can change with the above FIXME
3042  if (sm_db >= EBDetId::MIN_SM && sm_db <= EBDetId::MAX_SM) {
3043  EBDetId ebid(sm_db, i + 1, EBDetId::SMCRYSTALMODE);
3044  if (calib_status[i])
3045  ical->setValue(ebid.rawId(), calib[i]);
3046  else
3047  ical->setValue(ebid.rawId(), 1.);
3048  }
3049  //}
3050  } // loop over channels
3051 
3052  // edm::LogInfo ("EcalTrivialConditionRetriever") << "INTERCALIBRATION DONE" ;
3053  return ical;
3054 }
3055 
3056 // --------------------------------------------------------------------------------
3057 
3059  const EcalTimeCalibConstantsRcd&) {
3060  auto ical = std::make_unique<EcalTimeCalibConstants>();
3061 
3062  // Read the values from a txt file
3063  // -------------------------------
3064 
3065  edm::LogInfo("EcalTrivialConditionRetriever")
3066  << "Reading time calibration constants from file " << timeCalibConstantsFile_.c_str();
3067 
3068  FILE* inpFile;
3069  inpFile = fopen(timeCalibConstantsFile_.c_str(), "r");
3070  if (!inpFile) {
3071  edm::LogError("EcalTrivialConditionRetriever") << "*** Can not open file: " << timeCalibConstantsFile_;
3072  throw cms::Exception("Cannot open inter-calibration coefficients txt file");
3073  }
3074 
3075  char line[256];
3076  std::ostringstream str;
3077  fgets(line, 255, inpFile);
3078  int sm_number = atoi(line);
3079  str << "sm: " << sm_number;
3080 
3081  fgets(line, 255, inpFile);
3082  //int nevents=atoi (line) ; // not necessary here just for online conddb
3083 
3084  fgets(line, 255, inpFile);
3085  std::string gen_tag = line;
3086  str << "gen tag: " << gen_tag; // should I use this?
3087 
3088  fgets(line, 255, inpFile);
3089  std::string cali_method = line;
3090  str << "cali method: " << cali_method << std::endl; // not important
3091 
3092  fgets(line, 255, inpFile);
3093  std::string cali_version = line;
3094  str << "cali version: " << cali_version << std::endl; // not important
3095 
3096  fgets(line, 255, inpFile);
3097  std::string cali_type = line;
3098  str << "cali type: " << cali_type; // not important
3099 
3100  edm::LogInfo("EcalTrivialConditionRetriever") << "TimeCalibration file - " << str.str() << std::endl;
3101 
3102  float calib[1700] = {1};
3103  int calib_status[1700] = {0};
3104 
3105  int ii = 0;
3106 
3107  while (fgets(line, 255, inpFile)) {
3108  ii++;
3109  int dmy_num = 0;
3110  float dmy_calib = 0.;
3111  float dmy_RMS = 0.;
3112  int dmy_events = 0;
3113  int dmy_status = 0;
3114  sscanf(line, "%d %f %f %d %d", &dmy_num, &dmy_calib, &dmy_RMS, &dmy_events, &dmy_status);
3115  assert(dmy_num >= 1);
3116  assert(dmy_num <= 1700);
3117  calib[dmy_num - 1] = dmy_calib;
3118  calib_status[dmy_num - 1] = dmy_status;
3119 
3120  // edm::LogInfo ("EcalTrivialConditionRetriever")
3121  // << "[PIETRO] cry = " << dmy_num
3122  // << " calib = " << calib[dmy_num-1]
3123  // << " RMS = " << dmy_RMS
3124  // << " events = " << dmy_events
3125  // << " status = " << calib_status[dmy_num-1]
3126  // << std::endl ;
3127  }
3128 
3129  fclose(inpFile); // close inp. file
3130  edm::LogInfo("EcalTrivialConditionRetriever") << "Read timeCalibrations for " << ii << " xtals ";
3131  if (ii != 1700)
3132  edm::LogWarning("StoreEcalCondition") << "Some crystals missing, set to 1" << std::endl;
3133 
3134  // Transfer the data to the inter-calibration coefficients container
3135  // -----------------------------------------------------------------
3136 
3137  // DB supermodule always set to 1 for the TestBeam FIXME
3138  int sm_db = 1;
3139  // loop over channels
3140  for (int i = 0; i < 1700; i++) {
3141  //if (EBDetId::validDetId(iEta,iPhi)) {
3142  // CANNOT be used -- validDetId only checks ETA PHI method
3143  // doing a check by hand, here is the only place in CMSSW
3144  // outside TB code and EcalRawToDigi where needed
3145  // => no need for changing the DetId interface
3146  //
3147  // checking only sm_db -- guess can change with the above FIXME
3148  if (sm_db >= EBDetId::MIN_SM && sm_db <= EBDetId::MAX_SM) {
3149  EBDetId ebid(sm_db, i + 1, EBDetId::SMCRYSTALMODE);
3150  if (calib_status[i])
3151  ical->setValue(ebid.rawId(), calib[i]);
3152  else
3153  ical->setValue(ebid.rawId(), 1.);
3154  }
3155  //}
3156  } // loop over channels
3157 
3158  // edm::LogInfo ("EcalTrivialConditionRetriever") << "INTERCALIBRATION DONE" ;
3159  return ical;
3160 }
3161 
3163  const EcalTimeCalibErrorsRcd&) {
3164  auto ical = std::make_unique<EcalTimeCalibErrors>();
3165 
3166  // Read the values from a txt file
3167  // -------------------------------
3168 
3169  edm::LogInfo("EcalTrivialConditionRetriever")
3170  << "Reading timeCalibration constants from file " << timeCalibErrorsFile_.c_str();
3171 
3172  FILE* inpFile;
3173  inpFile = fopen(timeCalibErrorsFile_.c_str(), "r");
3174  if (!inpFile) {
3175  edm::LogError("EcalTrivialConditionRetriever") << "*** Can not open file: " << timeCalibErrorsFile_;
3176  throw cms::Exception("Cannot open inter-calibration coefficients txt file");
3177  }
3178 
3179  char line[256];
3180  std::ostringstream str;
3181  fgets(line, 255, inpFile);
3182  int sm_number = atoi(line);
3183  str << "sm: " << sm_number;
3184 
3185  fgets(line, 255, inpFile);
3186  //int nevents=atoi (line) ; // not necessary here just for online conddb
3187 
3188  fgets(line, 255, inpFile);
3189  std::string gen_tag = line;
3190  str << "gen tag: " << gen_tag; // should I use this?
3191 
3192  fgets(line, 255, inpFile);
3193  std::string cali_method = line;
3194  str << "cali method: " << cali_method << std::endl; // not important
3195 
3196  fgets(line, 255, inpFile);
3197  std::string cali_version = line;
3198  str << "cali version: " << cali_version << std::endl; // not important
3199 
3200  fgets(line, 255, inpFile);
3201  std::string cali_type = line;
3202  str << "cali type: " << cali_type; // not important
3203 
3204  edm::LogInfo("EcalTrivialConditionRetriever") << "TimeCalibration file - " << str.str() << std::endl;
3205 
3206  float calib[1700] = {1};
3207  int calib_status[1700] = {0};
3208 
3209  int ii = 0;
3210 
3211  while (fgets(line, 255, inpFile)) {
3212  ii++;
3213  int dmy_num = 0;
3214  float dmy_calib = 0.;
3215  float dmy_RMS = 0.;
3216  int dmy_events = 0;
3217  int dmy_status = 0;
3218  sscanf(line, "%d %f %f %d %d", &dmy_num, &dmy_calib, &dmy_RMS, &dmy_events, &dmy_status);
3219  assert(dmy_num >= 1);
3220  assert(dmy_num <= 1700);
3221  calib[dmy_num - 1] = dmy_calib;
3222  calib_status[dmy_num - 1] = dmy_status;
3223 
3224  // edm::LogInfo ("EcalTrivialConditionRetriever")
3225  // << "[PIETRO] cry = " << dmy_num
3226  // << " calib = " << calib[dmy_num-1]
3227  // << " RMS = " << dmy_RMS
3228  // << " events = " << dmy_events
3229  // << " status = " << calib_status[dmy_num-1]
3230  // << std::endl ;
3231  }
3232 
3233  fclose(inpFile); // close inp. file
3234  edm::LogInfo("EcalTrivialConditionRetriever") << "Read time calibrations for " << ii << " xtals ";
3235  if (ii != 1700)
3236  edm::LogWarning("StoreEcalCondition") << "Some crystals missing, set to 1" << std::endl;
3237 
3238  // Transfer the data to the inter-calibration coefficients container
3239  // -----------------------------------------------------------------
3240 
3241  // DB supermodule always set to 1 for the TestBeam FIXME
3242  int sm_db = 1;
3243  // loop over channels
3244  for (int i = 0; i < 1700; i++) {
3245  //if (EBDetId::validDetId(iEta,iPhi)) {
3246  // CANNOT be used -- validDetId only checks ETA PHI method
3247  // doing a check by hand, here is the only place in CMSSW
3248  // outside TB code and EcalRawToDigi where needed
3249  // => no need for changing the DetId interface
3250  //
3251  // checking only sm_db -- guess can change with the above FIXME
3252  if (sm_db >= EBDetId::MIN_SM && sm_db <= EBDetId::MAX_SM) {
3253  EBDetId ebid(sm_db, i + 1, EBDetId::SMCRYSTALMODE);
3254  if (calib_status[i])
3255  ical->setValue(ebid.rawId(), calib[i]);
3256  else
3257  ical->setValue(ebid.rawId(), 1.);
3258  }
3259  //}
3260  } // loop over channels
3261 
3262  // edm::LogInfo ("EcalTrivialConditionRetriever") << "INTERCALIBRATION DONE" ;
3263  return ical;
3264 }
3265 
3266 // --------------------------------------------------------------------------------
3267 
3268 std::unique_ptr<EcalMappingElectronics> EcalTrivialConditionRetriever::getMappingFromConfiguration(
3269  const EcalMappingElectronicsRcd&) {
3270  auto mapping = std::make_unique<EcalMappingElectronics>();
3271  edm::LogInfo("EcalTrivialConditionRetriever")
3272  << "Reading mapping from file " << edm::FileInPath(mappingFile_).fullPath().c_str();
3273 
3274  std::ifstream f(edm::FileInPath(mappingFile_).fullPath().c_str());
3275  if (!f.good()) {
3276  edm::LogError("EcalTrivialConditionRetriever") << "File not found";
3277  throw cms::Exception("FileNotFound");
3278  }
3279 
3280  // uint32_t detid, elecid, triggerid;
3281 
3282  int ix, iy, iz, CL;
3283  // int dccid, towerid, stripid, xtalid;
3284  // int tccid, tower, ipseudostrip, xtalinps;
3285  int dccid, towerid, pseudostrip_in_SC, xtal_in_pseudostrip;
3286  int tccid, tower, pseudostrip_in_TCC, pseudostrip_in_TT;
3287 
3288  while (!f.eof()) {
3289  // f >> detid >> elecid >> triggerid;
3290  f >> ix >> iy >> iz >> CL >> dccid >> towerid >> pseudostrip_in_SC >> xtal_in_pseudostrip >> tccid >> tower >>
3291  pseudostrip_in_TCC >> pseudostrip_in_TT;
3292 
3293  // if (!EEDetId::validDetId(ix,iy,iz))
3294  // continue;
3295 
3296  EEDetId detid(ix, iy, iz, EEDetId::XYMODE);
3297  // std::cout << " dcc tower ps_in_SC xtal_in_ps " << dccid << " " << towerid << " " << pseudostrip_in_SC << " " << xtal_in_pseudostrip << std::endl;
3298  EcalElectronicsId elecid(dccid, towerid, pseudostrip_in_SC, xtal_in_pseudostrip);
3299  // std::cout << " tcc tt ps_in_TT xtal_in_ps " << tccid << " " << tower << " " << pseudostrip_in_TT << " " << xtal_in_pseudostrip << std::endl;
3300  EcalTriggerElectronicsId triggerid(tccid, tower, pseudostrip_in_TT, xtal_in_pseudostrip);
3301  EcalMappingElement aElement;
3302  aElement.electronicsid = elecid.rawId();
3303  aElement.triggerid = triggerid.rawId();
3304  (*mapping).setValue(detid, aElement);
3305  }
3306 
3307  f.close();
3308  return mapping;
3309 }
3310 
3312  const EcalMappingElectronicsRcd&) {
3313  auto ical = std::make_unique<EcalMappingElectronics>();
3314  return ical;
3315 }
3316 
3317 // --------------------------------------------------------------------------------
3318 
3320  double mytrans[3] = {0., 0., 0.};
3321  double myeuler[3] = {0., 0., 0.};
3322  std::ifstream f;
3323  if (getEBAlignmentFromFile_)
3324  f.open(edm::FileInPath(EBAlignmentFile_).fullPath().c_str());
3325  std::vector<AlignTransform> my_align;
3326  int ieta = 1;
3327  int iphi = 0;
3328  for (int SM = 1; SM < 37; SM++) {
3329  // make an EBDetId since we need EBDetId::rawId()
3330  if (SM > 18) {
3331  iphi = 1 + (SM - 19) * 20;
3332  ieta = -1;
3333  } else
3334  iphi = SM * 20;
3335  EBDetId ebdetId(ieta, iphi);
3336  if (getEBAlignmentFromFile_) {
3337  f >> myeuler[0] >> myeuler[1] >> myeuler[2] >> mytrans[0] >> mytrans[1] >> mytrans[2];
3338  edm::LogInfo(" translation ") << mytrans[0] << " " << mytrans[1] << " " << mytrans[2] << "\n"
3339  << " euler " << myeuler[0] << " " << myeuler[1] << " " << myeuler[2];
3340  }
3341  CLHEP::Hep3Vector translation(mytrans[0], mytrans[1], mytrans[2]);
3342  CLHEP::HepEulerAngles euler(myeuler[0], myeuler[1], myeuler[2]);
3343  AlignTransform transform(translation, euler, ebdetId);
3344  my_align.push_back(transform);
3345  }
3346  /*
3347  // check
3348  uint32_t m_rawid;
3349  double m_x, m_y, m_z;
3350  double m_phi, m_theta, m_psi;
3351  int SM = 0;
3352  for (std::vector<AlignTransform>::const_iterator i = my_align.begin(); i != my_align.end(); ++i){
3353  m_rawid = i->rawId();
3354  CLHEP::Hep3Vector translation = i->translation();
3355  m_x = translation.x();
3356  m_y = translation.y();
3357  m_z = translation.z();
3358  CLHEP::HepRotation rotation = i->rotation();
3359  m_phi = rotation.getPhi();
3360  m_theta = rotation.getTheta();
3361  m_psi = rotation.getPsi();
3362  SM++;
3363  std::cout << " SM " << SM << " Id " << m_rawid << " x " << m_x << " y " << m_y << " z " << m_z
3364  << " phi " << m_phi << " theta " << m_theta << " psi " << m_psi << std::endl;
3365  }
3366  */
3367  Alignments a;
3368  a.m_align = my_align;
3369 
3370  return std::make_unique<Alignments>(a);
3371 }
3372 
3374  double mytrans[3] = {0., 0., 0.};
3375  double myeuler[3] = {0., 0., 0.};
3376  std::ifstream f;
3377  if (getEEAlignmentFromFile_)
3378  f.open(edm::FileInPath(EEAlignmentFile_).fullPath().c_str());
3379  std::vector<AlignTransform> my_align;
3380  int ix = 20;
3381  int iy = 50;
3382  int side = -1;
3383  for (int Dee = 0; Dee < 4; Dee++) {
3384  // make an EEDetId since we need EEDetId::rawId()
3385  if (Dee == 1 || Dee == 3)
3386  ix = 70;
3387  else
3388  ix = 20;
3389  if (Dee == 2)
3390  side = 1;
3391  EEDetId eedetId(ix, iy, side);
3392  if (getEEAlignmentFromFile_) {
3393  f >> myeuler[0] >> myeuler[1] >> myeuler[2] >> mytrans[0] >> mytrans[1] >> mytrans[2];
3394  edm::LogInfo(" translation ") << mytrans[0] << " " << mytrans[1] << " " << mytrans[2] << "\n"
3395  << " euler " << myeuler[0] << " " << myeuler[1] << " " << myeuler[2];
3396  }
3397  CLHEP::Hep3Vector translation(mytrans[0], mytrans[1], mytrans[2]);
3398  CLHEP::HepEulerAngles euler(myeuler[0], myeuler[1], myeuler[2]);
3399  AlignTransform transform(translation, euler, eedetId);
3400  my_align.push_back(transform);
3401  }
3402  Alignments a;
3403  a.m_align = my_align;
3404  return std::make_unique<Alignments>(a);
3405 }
3406 
3408  double mytrans[3] = {0., 0., 0.};
3409  double myeuler[3] = {0., 0., 0.};
3410  std::ifstream f;
3411  if (getESAlignmentFromFile_)
3412  f.open(edm::FileInPath(ESAlignmentFile_).fullPath().c_str());
3413  std::vector<AlignTransform> my_align;
3414  // int ix_vect[10] = {10, 30, 30, 50, 10, 30, 10, 30};
3415  int pl_vect[10] = {2, 2, 1, 1, 1, 1, 2, 2};
3416  int iy = 10;
3417  int side = -1;
3418  int strip = 1;
3419  for (int layer = 0; layer < 8; layer++) {
3420  // make an ESDetId since we need ESDetId::rawId()
3421  int ix = 10 + (layer % 2) * 20;
3422  int plane = pl_vect[layer];
3423  if (layer > 3)
3424  side = 1;
3425  ESDetId esdetId(strip, ix, iy, plane, side);
3426  if (getESAlignmentFromFile_) {
3427  f >> myeuler[0] >> myeuler[1] >> myeuler[2] >> mytrans[0] >> mytrans[1] >> mytrans[2];
3428  edm::LogInfo(" translation ") << mytrans[0] << " " << mytrans[1] << " " << mytrans[2] << "\n"
3429  << " euler " << myeuler[0] << " " << myeuler[1] << " " << myeuler[2];
3430  }
3431  CLHEP::Hep3Vector translation(mytrans[0], mytrans[1], mytrans[2]);
3432  CLHEP::HepEulerAngles euler(myeuler[0], myeuler[1], myeuler[2]);
3433  AlignTransform transform(translation, euler, esdetId);
3434  my_align.push_back(transform);
3435  }
3436  Alignments a;
3437  a.m_align = my_align;
3438  return std::make_unique<Alignments>(a);
3439 }
3440 
3442  return std::make_unique<EcalSampleMask>(sampleMaskEB_, sampleMaskEE_);
3443 }
3444 
3445 std::unique_ptr<EcalTimeBiasCorrections> EcalTrivialConditionRetriever::produceEcalTimeBiasCorrections(
3446  const EcalTimeBiasCorrectionsRcd&) {
3447  auto ipar = std::make_unique<EcalTimeBiasCorrections>();
3448  copy(EBtimeCorrAmplitudeBins_.begin(), EBtimeCorrAmplitudeBins_.end(), back_inserter(ipar->EBTimeCorrAmplitudeBins));
3449  copy(EBtimeCorrShiftBins_.begin(), EBtimeCorrShiftBins_.end(), back_inserter(ipar->EBTimeCorrShiftBins));
3450  copy(EEtimeCorrAmplitudeBins_.begin(), EEtimeCorrAmplitudeBins_.end(), back_inserter(ipar->EETimeCorrAmplitudeBins));
3451  copy(EEtimeCorrShiftBins_.begin(), EEtimeCorrShiftBins_.end(), back_inserter(ipar->EETimeCorrShiftBins));
3452  return ipar;
3453 }
3454 
3456  const EcalSamplesCorrelationRcd&) {
3457  if (getSamplesCorrelationFromFile_) {
3458  std::ifstream f;
3459  f.open(edm::FileInPath(SamplesCorrelationFile_).fullPath().c_str());
3460  float ww;
3461  for (int j = 0; j < 10; ++j) {
3462  f >> ww;
3463  EBG12samplesCorrelation_.push_back(ww);
3464  }
3465  for (int j = 0; j < 10; ++j) {
3466  f >> ww;
3467  EBG6samplesCorrelation_.push_back(ww);
3468  }
3469  for (int j = 0; j < 10; ++j) {
3470  f >> ww;
3471  EBG1samplesCorrelation_.push_back(ww);
3472  }
3473  for (int j = 0; j < 10; ++j) {
3474  f >> ww;
3475  EEG12samplesCorrelation_.push_back(ww);
3476  }
3477  for (int j = 0; j < 10; ++j) {
3478  f >> ww;
3479  EEG6samplesCorrelation_.push_back(ww);
3480  }
3481  for (int j = 0; j < 10; ++j) {
3482  f >> ww;
3483  EEG1samplesCorrelation_.push_back(ww);
3484  }
3485  f.close();
3486  }
3487  auto ipar = std::make_unique<EcalSamplesCorrelation>();
3488  copy(EBG12samplesCorrelation_.begin(), EBG12samplesCorrelation_.end(), back_inserter(ipar->EBG12SamplesCorrelation));
3489  copy(EBG6samplesCorrelation_.begin(), EBG6samplesCorrelation_.end(), back_inserter(ipar->EBG6SamplesCorrelation));
3490  copy(EBG1samplesCorrelation_.begin(), EBG1samplesCorrelation_.end(), back_inserter(ipar->EBG1SamplesCorrelation));
3491  copy(EEG12samplesCorrelation_.begin(), EEG12samplesCorrelation_.end(), back_inserter(ipar->EEG12SamplesCorrelation));
3492  copy(EEG6samplesCorrelation_.begin(), EEG6samplesCorrelation_.end(), back_inserter(ipar->EEG6SamplesCorrelation));
3493  copy(EEG1samplesCorrelation_.begin(), EEG1samplesCorrelation_.end(), back_inserter(ipar->EEG1SamplesCorrelation));
3494  return ipar;
3495 }
3496 
3498  const EcalSimPulseShapeRcd&) {
3499  auto result = std::make_unique<EcalSimPulseShape>();
3500 
3501  // save time interval to be used for the pulse shape
3502  result->time_interval = sim_pulse_shape_TI_;
3503 
3504  // containers to store the shape info
3505  std::vector<double> EBshape;
3506  std::vector<double> EEshape;
3507  std::vector<double> APDshape;
3508 
3509  // --- get the 3 shapes from the user provided txt files
3510  if (!EBSimPulseShapeFile_.empty()) {
3511  std::ifstream shapeEBFile;
3512  shapeEBFile.open(EBSimPulseShapeFile_.c_str());
3513  double ww;
3514  while (shapeEBFile >> ww)
3515  EBshape.push_back(ww);
3516  shapeEBFile.close();
3517  }
3518  if (!EESimPulseShapeFile_.empty()) {
3519  std::ifstream shapeEEFile;
3520  shapeEEFile.open(EESimPulseShapeFile_.c_str());
3521  double ww;
3522  while (shapeEEFile >> ww)
3523  EEshape.push_back(ww);
3524  shapeEEFile.close();
3525  }
3526  if (!APDSimPulseShapeFile_.empty()) {
3527  std::ifstream shapeAPDFile;
3528  shapeAPDFile.open(APDSimPulseShapeFile_.c_str());
3529  double ww;
3530  while (shapeAPDFile >> ww)
3531  APDshape.push_back(ww);
3532  shapeAPDFile.close();
3533  }
3534 
3535  // --- save threshold
3536  result->barrel_thresh = sim_pulse_shape_EB_thresh_;
3537  result->endcap_thresh = sim_pulse_shape_EE_thresh_;
3538  result->apd_thresh = sim_pulse_shape_APD_thresh_;
3539 
3540  // --- copy
3541  copy(EBshape.begin(), EBshape.end(), back_inserter(result->barrel_shape));
3542  copy(EEshape.begin(), EEshape.end(), back_inserter(result->endcap_shape));
3543  copy(APDshape.begin(), APDshape.end(), back_inserter(result->apd_shape));
3544 
3545  return result;
3546 }
Definition: mat4.h:9
size
Write out results.
EcalChi2WeightMatrix & getChi2WeightsBeforeGainSwitch()
Definition: EcalWeightSet.h:28
static bool validDetId(int ix, int iy, int iz)
Definition: EcalScDetId.cc:59
EcalIntercalibConstantMCMap EcalIntercalibConstantsMC
float alpha
Definition: AMPTWrapper.h:105
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
static const int MIN_IPHI
Definition: EBDetId.h:135
static Timestamp endOfTime()
Definition: Timestamp.h:83
void setIntervalFor(const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue &, edm::ValidityInterval &) override
virtual std::unique_ptr< EcalDQMChannelStatus > produceEcalDQMChannelStatus(const EcalDQMChannelStatusRcd &)
virtual std::unique_ptr< EcalIntercalibConstants > produceEcalIntercalibConstants(const EcalIntercalibConstantsRcd &)
virtual std::unique_ptr< EcalIntercalibErrors > produceEcalIntercalibErrors(const EcalIntercalibErrorsRcd &)
virtual std::unique_ptr< EcalLaserAPDPNRatiosRef > produceEcalLaserAPDPNRatiosRef(const EcalLaserAPDPNRatiosRefRcd &)
std::string fullPath() const
Definition: FileInPath.cc:161
virtual std::unique_ptr< EcalSamplesCorrelation > produceEcalSamplesCorrelation(const EcalSamplesCorrelationRcd &)
Ecal readout channel identification [32:20] Unused (so far) [19:13] DCC id [12:6] tower [5:3] strip [...
virtual std::unique_ptr< EcalTimeCalibConstants > produceEcalTimeCalibConstants(const EcalTimeCalibConstantsRcd &)
virtual std::unique_ptr< EcalMappingElectronics > getMappingFromConfiguration(const EcalMappingElectronicsRcd &)
static const int XYMODE
Definition: EEDetId.h:335
static const IOVSyncValue & endOfTime()
Definition: IOVSyncValue.cc:82
virtual std::unique_ptr< EcalADCToGeVConstant > produceEcalADCToGeVConstant(const EcalADCToGeVConstantRcd &)
virtual std::unique_ptr< EcalWeightXtalGroups > produceEcalWeightXtalGroups(const EcalWeightXtalGroupsRcd &)
virtual std::unique_ptr< EcalChannelStatus > produceEcalChannelStatus(const EcalChannelStatusRcd &)
std::pair< Time_t, Time_t > ValidityInterval
Definition: Time.h:17
math::Matrix< 10, 10 >::type EcalChi2WeightMatrix
Definition: EcalWeightSet.h:20
void getWeightsFromConfiguration(const edm::ParameterSet &ps)
math::Matrix< 3, 10 >::type EcalWeightMatrix
Definition: EcalWeightSet.h:19
double calcresolutitonConstantTerm(double eta)
Log< level::Error, false > LogError
static EEDetId unhashIndex(int hi)
Definition: EEDetId.cc:65
assert(be >=bs)
static const int IX_MIN
Definition: EEDetId.h:290
static int readXML(const std::string &filename, EcalCondHeader &header, EcalFloatCondObjectContainer &record)
static const int IY_MIN
Definition: EEDetId.h:294
float approxEta() const
Definition: EBDetId.h:102
static bool validDetId(int i, int j)
check if a valid index combination
Definition: EBDetId.h:118
constexpr std::array< uint8_t, layerIndexSize > layer
virtual std::unique_ptr< EcalLaserAlphas > produceEcalLaserAlphas(const EcalLaserAlphasRcd &)
static const int MIN_SM
Definition: EBDetId.h:145
void setGain12Over6(const float &g)
virtual std::unique_ptr< EcalClusterEnergyUncertaintyParameters > produceEcalClusterEnergyUncertaintyParameters(const EcalClusterEnergyUncertaintyParametersRcd &)
T getUntrackedParameter(std::string const &, T const &) const
virtual std::unique_ptr< Alignments > produceEcalAlignmentEB(const EBAlignmentRcd &)
void setValue(const uint32_t id, const Item &item)
virtual std::unique_ptr< EcalClusterEnergyCorrectionParameters > produceEcalClusterEnergyCorrectionParameters(const EcalClusterEnergyCorrectionParametersRcd &)
virtual std::unique_ptr< EcalIntercalibConstantsMC > getIntercalibConstantsMCFromConfiguration(const EcalIntercalibConstantsMCRcd &)
static const IOVSyncValue & beginOfTime()
Definition: IOVSyncValue.cc:88
double calcnoiseIncreaseADC(double eta)
virtual std::unique_ptr< EcalDQMTowerStatus > produceEcalDQMTowerStatus(const EcalDQMTowerStatusRcd &)
T sqrt(T t)
Definition: SSEVec.h:19
virtual std::unique_ptr< Alignments > produceEcalAlignmentEE(const EEAlignmentRcd &)
virtual std::unique_ptr< EcalLinearCorrections > produceEcalLinearCorrections(const EcalLinearCorrectionsRcd &)
virtual std::unique_ptr< EcalMappingElectronics > produceEcalMappingElectronics(const EcalMappingElectronicsRcd &)
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
EcalChi2WeightMatrix & getChi2WeightsAfterGainSwitch()
Definition: EcalWeightSet.h:29
virtual std::unique_ptr< EcalLaserAPDPNRatios > produceEcalLaserAPDPNRatios(const EcalLaserAPDPNRatiosRcd &)
virtual std::unique_ptr< EcalChannelStatus > getChannelStatusFromConfiguration(const EcalChannelStatusRcd &)
double f[11][100]
virtual std::unique_ptr< EcalTimeBiasCorrections > produceEcalTimeBiasCorrections(const EcalTimeBiasCorrectionsRcd &)
virtual std::unique_ptr< EcalIntercalibConstants > getIntercalibConstantsFromConfiguration(const EcalIntercalibConstantsRcd &)
virtual std::unique_ptr< EcalIntercalibConstantsMC > produceEcalIntercalibConstantsMC(const EcalIntercalibConstantsMCRcd &)
virtual std::unique_ptr< Alignments > produceEcalAlignmentES(const ESAlignmentRcd &)
EcalWeightMatrix & getWeightsAfterGainSwitch()
Definition: EcalWeightSet.h:27
const_iterator find(uint32_t rawId) const
ii
Definition: cuy.py:589
const int drop
static const int IX_MAX
Definition: EEDetId.h:298
Log< level::Info, false > LogInfo
virtual std::unique_ptr< EcalPedestals > produceEcalPedestals(const EcalPedestalsRcd &)
virtual std::unique_ptr< EcalClusterEnergyCorrectionObjectSpecificParameters > produceEcalClusterEnergyCorrectionObjectSpecificParameters(const EcalClusterEnergyCorrectionObjectSpecificParametersRcd &)
static const int MAX_IPHI
Definition: EBDetId.h:137
EcalWeightMatrix & getWeightsBeforeGainSwitch()
Definition: EcalWeightSet.h:26
uint32_t rawId() const
TimeValue_t value() const
Definition: Timestamp.h:45
virtual std::unique_ptr< EcalDCSTowerStatus > produceEcalDCSTowerStatus(const EcalDCSTowerStatusRcd &)
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
Definition: EEDetId.h:248
EcalTrivialConditionRetriever(const edm::ParameterSet &pset)
std::vector< Item >::const_iterator const_iterator
static const int MAX_IETA
Definition: EBDetId.h:136
virtual std::unique_ptr< EcalClusterLocalContCorrParameters > produceEcalClusterLocalContCorrParameters(const EcalClusterLocalContCorrParametersRcd &)
virtual std::unique_ptr< EcalTimeCalibErrors > getTimeCalibErrorsFromConfiguration(const EcalTimeCalibErrorsRcd &)
static EBDetId unhashIndex(int hi)
get a DetId from a compact index for arrays
Definition: EBDetId.h:110
EcalIntercalibConstantMap EcalIntercalibConstants
virtual std::unique_ptr< EcalGainRatios > produceEcalGainRatios(const EcalGainRatiosRcd &)
static bool validDetId(int iz, EcalSubdetector sd, int i, int j)
check if a valid index combination
const Timestamp & time() const
Definition: IOVSyncValue.h:42
virtual std::unique_ptr< EcalTPGCrystalStatus > produceEcalTrgChannelStatus(const EcalTPGCrystalStatusRcd &)
HLT enums.
virtual std::unique_ptr< EcalTimeCalibErrors > produceEcalTimeCalibErrors(const EcalTimeCalibErrorsRcd &)
double a
Definition: hdecay.h:119
virtual std::unique_ptr< EcalTBWeights > produceEcalTBWeights(const EcalTBWeightsRcd &)
virtual std::unique_ptr< EcalTimeOffsetConstant > produceEcalTimeOffsetConstant(const EcalTimeOffsetConstantRcd &)
virtual std::unique_ptr< EcalPFRecHitThresholds > getPFRecHitThresholdsFromConfiguration(const EcalPFRecHitThresholdsRcd &)
static const int MAX_SM
Definition: EBDetId.h:146
const_iterator end() const
virtual std::unique_ptr< EcalTimeCalibConstants > getTimeCalibConstantsFromConfiguration(const EcalTimeCalibConstantsRcd &)
static const int IY_MAX
Definition: EEDetId.h:302
virtual std::unique_ptr< EcalTPGCrystalStatus > getTrgChannelStatusFromConfiguration(const EcalTPGCrystalStatusRcd &)
virtual std::unique_ptr< EcalPFRecHitThresholds > produceEcalPFRecHitThresholds(const EcalPFRecHitThresholdsRcd &)
float EcalIntercalibConstantMC
virtual std::unique_ptr< EcalSampleMask > produceEcalSampleMask(const EcalSampleMaskRcd &)
Log< level::Warning, false > LogWarning
virtual std::unique_ptr< EcalIntercalibErrors > getIntercalibErrorsFromConfiguration(const EcalIntercalibErrorsRcd &)
static const int SMCRYSTALMODE
Definition: EBDetId.h:159
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
#define str(s)
double calcampDropTotal(double eta)
Ecal trigger electronics identification [32:20] Unused (so far) [19:13] TCC id [12:6] TT id [5:3] pse...
virtual std::unique_ptr< EcalDAQTowerStatus > produceEcalDAQTowerStatus(const EcalDAQTowerStatusRcd &)
virtual std::unique_ptr< EcalSimPulseShape > getEcalSimPulseShapeFromConfiguration(const EcalSimPulseShapeRcd &)
float EcalIntercalibConstant
virtual std::unique_ptr< EcalClusterCrackCorrParameters > produceEcalClusterCrackCorrParameters(const EcalClusterCrackCorrParametersRcd &)
unsigned transform(const HcalDetId &id, unsigned transformCode)