CMS 3D CMS Logo

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