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