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