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