CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EcalUncalibRecHitWorkerGlobal.cc
Go to the documentation of this file.
2 
7 
15 
18 {
19  // ratio method parameters
20  EBtimeFitParameters_ = ps.getParameter<std::vector<double> >("EBtimeFitParameters");
21  EEtimeFitParameters_ = ps.getParameter<std::vector<double> >("EEtimeFitParameters");
22  EBamplitudeFitParameters_ = ps.getParameter<std::vector<double> >("EBamplitudeFitParameters");
23  EEamplitudeFitParameters_ = ps.getParameter<std::vector<double> >("EEamplitudeFitParameters");
24  EBtimeFitLimits_.first = ps.getParameter<double>("EBtimeFitLimits_Lower");
25  EBtimeFitLimits_.second = ps.getParameter<double>("EBtimeFitLimits_Upper");
26  EEtimeFitLimits_.first = ps.getParameter<double>("EEtimeFitLimits_Lower");
27  EEtimeFitLimits_.second = ps.getParameter<double>("EEtimeFitLimits_Upper");
28  EBtimeConstantTerm_=ps.getParameter<double>("EBtimeConstantTerm");
29  EBtimeNconst_=ps.getParameter<double>("EBtimeNconst");
30  EEtimeConstantTerm_=ps.getParameter<double>("EEtimeConstantTerm");
31  EEtimeNconst_=ps.getParameter<double>("EEtimeNconst");
32  outOfTimeThreshG12pEB_ = ps.getParameter<double>("outOfTimeThresholdGain12pEB");
33  outOfTimeThreshG12mEB_ = ps.getParameter<double>("outOfTimeThresholdGain12mEB");
34  outOfTimeThreshG61pEB_ = ps.getParameter<double>("outOfTimeThresholdGain61pEB");
35  outOfTimeThreshG61mEB_ = ps.getParameter<double>("outOfTimeThresholdGain61mEB");
36  outOfTimeThreshG12pEE_ = ps.getParameter<double>("outOfTimeThresholdGain12pEE");
37  outOfTimeThreshG12mEE_ = ps.getParameter<double>("outOfTimeThresholdGain12mEE");
38  outOfTimeThreshG61pEE_ = ps.getParameter<double>("outOfTimeThresholdGain61pEE");
39  outOfTimeThreshG61mEE_ = ps.getParameter<double>("outOfTimeThresholdGain61mEE");
40  amplitudeThreshEB_ = ps.getParameter<double>("amplitudeThresholdEB");
41  amplitudeThreshEE_ = ps.getParameter<double>("amplitudeThresholdEE");
42  // amplitude-dependent correction of time
43  doEBtimeCorrection_ = ps.getParameter<bool>("doEBtimeCorrection");
44  doEEtimeCorrection_ = ps.getParameter<bool>("doEEtimeCorrection");
45  EBtimeCorrAmplitudeBins_ = ps.getParameter<std::vector<double> >("EBtimeCorrAmplitudeBins");
46  EBtimeCorrShiftBins_ = ps.getParameter<std::vector<double> >("EBtimeCorrShiftBins");
47  EEtimeCorrAmplitudeBins_ = ps.getParameter<std::vector<double> >("EEtimeCorrAmplitudeBins");
48  EEtimeCorrShiftBins_ = ps.getParameter<std::vector<double> >("EEtimeCorrShiftBins");
49  if(EBtimeCorrAmplitudeBins_.size() != EBtimeCorrShiftBins_.size()) {
50  doEBtimeCorrection_ = false;
51  edm::LogError("EcalRecHitError") << "Size of EBtimeCorrAmplitudeBins different from EBtimeCorrShiftBins. Forcing no time corrections for EB. ";
52  }
53  if(EEtimeCorrAmplitudeBins_.size() != EEtimeCorrShiftBins_.size()) {
54  doEEtimeCorrection_ = false;
55  edm::LogError("EcalRecHitError") << "Size of EEtimeCorrAmplitudeBins different from EEtimeCorrShiftBins. Forcing no time corrections for EE. ";
56  }
57 
58  // spike threshold
59  ebSpikeThresh_ = ps.getParameter<double>("ebSpikeThreshold");
60  // leading edge parameters
61  ebPulseShape_ = ps.getParameter<std::vector<double> >("ebPulseShape");
62  eePulseShape_ = ps.getParameter<std::vector<double> >("eePulseShape");
63  // chi2 parameters
64  kPoorRecoFlagEB_ = ps.getParameter<bool>("kPoorRecoFlagEB");
65  kPoorRecoFlagEE_ = ps.getParameter<bool>("kPoorRecoFlagEE");;
66  chi2ThreshEB_=ps.getParameter<double>("chi2ThreshEB_");
67  chi2ThreshEE_=ps.getParameter<double>("chi2ThreshEE_");
68  EBchi2Parameters_ = ps.getParameter<std::vector<double> >("EBchi2Parameters");
69  EEchi2Parameters_ = ps.getParameter<std::vector<double> >("EEchi2Parameters");
70 }
71 
72 
73 
76 {
77  // ratio method parameters
78  EBtimeFitParameters_ = ps.getParameter<std::vector<double> >("EBtimeFitParameters");
79  EEtimeFitParameters_ = ps.getParameter<std::vector<double> >("EEtimeFitParameters");
80  EBamplitudeFitParameters_ = ps.getParameter<std::vector<double> >("EBamplitudeFitParameters");
81  EEamplitudeFitParameters_ = ps.getParameter<std::vector<double> >("EEamplitudeFitParameters");
82  EBtimeFitLimits_.first = ps.getParameter<double>("EBtimeFitLimits_Lower");
83  EBtimeFitLimits_.second = ps.getParameter<double>("EBtimeFitLimits_Upper");
84  EEtimeFitLimits_.first = ps.getParameter<double>("EEtimeFitLimits_Lower");
85  EEtimeFitLimits_.second = ps.getParameter<double>("EEtimeFitLimits_Upper");
86  EBtimeConstantTerm_=ps.getParameter<double>("EBtimeConstantTerm");
87  EBtimeNconst_=ps.getParameter<double>("EBtimeNconst");
88  EEtimeConstantTerm_=ps.getParameter<double>("EEtimeConstantTerm");
89  EEtimeNconst_=ps.getParameter<double>("EEtimeNconst");
90  outOfTimeThreshG12pEB_ = ps.getParameter<double>("outOfTimeThresholdGain12pEB");
91  outOfTimeThreshG12mEB_ = ps.getParameter<double>("outOfTimeThresholdGain12mEB");
92  outOfTimeThreshG61pEB_ = ps.getParameter<double>("outOfTimeThresholdGain61pEB");
93  outOfTimeThreshG61mEB_ = ps.getParameter<double>("outOfTimeThresholdGain61mEB");
94  outOfTimeThreshG12pEE_ = ps.getParameter<double>("outOfTimeThresholdGain12pEE");
95  outOfTimeThreshG12mEE_ = ps.getParameter<double>("outOfTimeThresholdGain12mEE");
96  outOfTimeThreshG61pEE_ = ps.getParameter<double>("outOfTimeThresholdGain61pEE");
97  outOfTimeThreshG61mEE_ = ps.getParameter<double>("outOfTimeThresholdGain61mEE");
98  amplitudeThreshEB_ = ps.getParameter<double>("amplitudeThresholdEB");
99  amplitudeThreshEE_ = ps.getParameter<double>("amplitudeThresholdEE");
100  // amplitude-dependent correction of time
101  doEBtimeCorrection_ = ps.getParameter<bool>("doEBtimeCorrection");
102  doEEtimeCorrection_ = ps.getParameter<bool>("doEEtimeCorrection");
103  EBtimeCorrAmplitudeBins_ = ps.getParameter<std::vector<double> >("EBtimeCorrAmplitudeBins");
104  EBtimeCorrShiftBins_ = ps.getParameter<std::vector<double> >("EBtimeCorrShiftBins");
105  EEtimeCorrAmplitudeBins_ = ps.getParameter<std::vector<double> >("EEtimeCorrAmplitudeBins");
106  EEtimeCorrShiftBins_ = ps.getParameter<std::vector<double> >("EEtimeCorrShiftBins");
107  if(EBtimeCorrAmplitudeBins_.size() != EBtimeCorrShiftBins_.size()) {
108  doEBtimeCorrection_ = false;
109  edm::LogError("EcalRecHitError") << "Size of EBtimeCorrAmplitudeBins different from EBtimeCorrShiftBins. Forcing no time corrections for EB. ";
110  }
111  if(EEtimeCorrAmplitudeBins_.size() != EEtimeCorrShiftBins_.size()) {
112  doEEtimeCorrection_ = false;
113  edm::LogError("EcalRecHitError") << "Size of EEtimeCorrAmplitudeBins different from EEtimeCorrShiftBins. Forcing no time corrections for EE. ";
114  }
115 
116  // spike threshold
117  ebSpikeThresh_ = ps.getParameter<double>("ebSpikeThreshold");
118  // leading edge parameters
119  ebPulseShape_ = ps.getParameter<std::vector<double> >("ebPulseShape");
120  eePulseShape_ = ps.getParameter<std::vector<double> >("eePulseShape");
121  // chi2 parameters
122  kPoorRecoFlagEB_ = ps.getParameter<bool>("kPoorRecoFlagEB");
123  kPoorRecoFlagEE_ = ps.getParameter<bool>("kPoorRecoFlagEE");;
124  chi2ThreshEB_=ps.getParameter<double>("chi2ThreshEB_");
125  chi2ThreshEE_=ps.getParameter<double>("chi2ThreshEE_");
126  EBchi2Parameters_ = ps.getParameter<std::vector<double> >("EBchi2Parameters");
127  EEchi2Parameters_ = ps.getParameter<std::vector<double> >("EEchi2Parameters");
128 }
129 
130 
131 
132 
133 
134 
135 
136 
137 
138 
139 
140 
141 
142 void
144 {
145  // common setup
146  es.get<EcalGainRatiosRcd>().get(gains);
147  es.get<EcalPedestalsRcd>().get(peds);
148 
149  // for the weights method
150  es.get<EcalWeightXtalGroupsRcd>().get(grps);
151  es.get<EcalTBWeightsRcd>().get(wgts);
152 
153  // which of the samples need be used
155 
156  // for the ratio method
157 
158  // for the leading edge method
161 }
162 
163 
164 // check saturation: 5 samples with gainId = 0
165 template < class C >
167 {
168  //bool saturated_ = 0;
169  int cnt;
170  for (int j = 0; j < C::MAXSAMPLES - 5; ++j) {
171  cnt = 0;
172  for (int i = j; i < (j + 5) && i < C::MAXSAMPLES; ++i) {
173  if ( dataFrame.sample(i).gainId() == 0 ) ++cnt;
174  }
175  if ( cnt == 5 ) return j-1 ; // the last unsaturated sample
176  }
177  return -1; // no saturation found
178 }
179 
180 
182  // computed initially in ns. Than turned in the BX's, as EcalUncalibratedRecHit need be.
183  double theCorrection=0;
184 
185 
186  int myBin = -1;
187  for (int bin=0; bin<(int)EBtimeCorrAmplitudeBins_.size(); bin++ ){
188  if(ampliEB > EBtimeCorrAmplitudeBins_.at(bin)) {
189  myBin = bin; }
190  else break;
191  }
192 
193  if (myBin == -1)
194  {
195  theCorrection = EBtimeCorrShiftBins_.at(0);
196  }
197  else if ( myBin == ((int)(EBtimeCorrAmplitudeBins_.size()-1)) )
198  {
199  theCorrection = EBtimeCorrShiftBins_.at( myBin );
200  }
201  else if ( -1 < myBin && myBin < ((int)EBtimeCorrAmplitudeBins_.size()-1) )
202  {
203  // interpolate linearly between two assingned points
204  theCorrection = ( EBtimeCorrShiftBins_.at(myBin+1) - EBtimeCorrShiftBins_.at(myBin) );
205  theCorrection *= ( ((double)ampliEB) - EBtimeCorrAmplitudeBins_.at(myBin) ) / ( EBtimeCorrAmplitudeBins_.at(myBin+1) - EBtimeCorrAmplitudeBins_.at(myBin) );
206  theCorrection += EBtimeCorrShiftBins_.at(myBin);
207  }
208  else
209  {
210  edm::LogError("EcalRecHitError") << "Assigning time correction impossible. Setting it to 0 ";
211  theCorrection = 0.;
212  }
213 
214  // convert ns into clocks
215  return theCorrection/25.;
216 }
217 
218 
220  // computed initially in ns. Than turned in the BX's, as EcalUncalibratedRecHit need be.
221  double theCorrection=0;
222 
223  int myBin = -1;
224  for (int bin=0; bin<(int)EEtimeCorrAmplitudeBins_.size(); bin++ ){
225  if(ampliEE > EEtimeCorrAmplitudeBins_.at(bin)) {
226  myBin = bin; }
227  else break;
228  }
229 
230  if (myBin == -1)
231  {
232  theCorrection = EEtimeCorrShiftBins_.at(0);
233  }
234  else if ( myBin == ((int)(EEtimeCorrAmplitudeBins_.size()-1)) )
235  {
236  theCorrection = EEtimeCorrShiftBins_.at( myBin );
237  }
238  else if ( -1 < myBin && myBin < ((int)EEtimeCorrAmplitudeBins_.size()-1) )
239  {
240  // interpolate linearly between two assingned points
241  theCorrection = ( EEtimeCorrShiftBins_.at(myBin+1) - EEtimeCorrShiftBins_.at(myBin) );
242  theCorrection *= ( ((double)ampliEE) - EEtimeCorrAmplitudeBins_.at(myBin) ) / ( EEtimeCorrAmplitudeBins_.at(myBin+1) - EEtimeCorrAmplitudeBins_.at(myBin) );
243  theCorrection += EEtimeCorrShiftBins_.at(myBin);
244  }
245  else
246  {
247  edm::LogError("EcalRecHitError") << "Assigning time correction impossible. Setting it to 0 ";
248  theCorrection = 0.;
249  }
250 
251  // convert ns into clocks
252  return theCorrection/25.;
253 }
254 
255 
256 
257 
258 bool
262 {
263  DetId detid(itdg->id());
264 
265  const EcalSampleMask *sampleMask_ = sampleMaskHand_.product();
266 
267  // intelligence for recHit computation
268  EcalUncalibratedRecHit uncalibRecHit;
269 
270 
271  const EcalPedestals::Item * aped = 0;
272  const EcalMGPAGainRatio * aGain = 0;
273  const EcalXtalGroupId * gid = 0;
274  float offsetTime = 0;
275 
276  if (detid.subdetId()==EcalEndcap) {
277  unsigned int hashedIndex = EEDetId(detid).hashedIndex();
278  aped = &peds->endcap(hashedIndex);
279  aGain = &gains->endcap(hashedIndex);
280  gid = &grps->endcap(hashedIndex);
281  offsetTime = offtime->getEEValue();
282  } else {
283  unsigned int hashedIndex = EBDetId(detid).hashedIndex();
284  aped = &peds->barrel(hashedIndex);
285  aGain = &gains->barrel(hashedIndex);
286  gid = &grps->barrel(hashedIndex);
287  offsetTime = offtime->getEBValue();
288  }
289 
290  pedVec[0] = aped->mean_x12;
291  pedVec[1] = aped->mean_x6;
292  pedVec[2] = aped->mean_x1;
293  pedRMSVec[0] = aped->rms_x12;
294  pedRMSVec[1] = aped->rms_x6;
295  pedRMSVec[2] = aped->rms_x1;
296  gainRatios[0] = 1.;
297  gainRatios[1] = aGain->gain12Over6();
298  gainRatios[2] = aGain->gain6Over1()*aGain->gain12Over6();
299 
300  // compute the right bin of the pulse shape using time calibration constants
302  EcalTimeCalibConstant itimeconst = 0;
303  if( it != itime->end() ) {
304  itimeconst = (*it);
305  } else {
306  edm::LogError("EcalRecHitError") << "No time intercalib const found for xtal "
307  << detid.rawId()
308  << "! something wrong with EcalTimeCalibConstants in your DB? ";
309  }
310 
311 
312  // === amplitude computation ===
313  int leadingSample = -1;
314  if (detid.subdetId()==EcalEndcap) {
315  leadingSample = ((EcalDataFrame)(*itdg)).lastUnsaturatedSample();
316  } else {
317  leadingSample = ((EcalDataFrame)(*itdg)).lastUnsaturatedSample();
318  }
319 
320  if ( leadingSample >= 0 ) { // saturation
321  if ( leadingSample != 4 ) {
322  // all samples different from the fifth are not reliable for the amplitude estimation
323  // put by default the energy at the saturation threshold and flag as saturated
324  float sratio = 1;
325  if ( detid.subdetId()==EcalBarrel) {
326  sratio = ebPulseShape_[5] / ebPulseShape_[4];
327  } else {
328  sratio = eePulseShape_[5] / eePulseShape_[4];
329  }
330  uncalibRecHit = EcalUncalibratedRecHit( (*itdg).id(), 4095*12*sratio, 0, 0, 0);
332  } else {
333  // float clockToNsConstant = 25.;
334  // reconstruct the rechit
335  if (detid.subdetId()==EcalEndcap) {
337  // float mult = (float)eePulseShape_.size() / (float)(*itdg).size();
338  // bin (or some analogous mapping) will be used instead of the leadingSample
339  //int bin = (int)(( (mult * leadingSample + mult/2) * clockToNsConstant + itimeconst ) / clockToNsConstant);
340  // bin is not uset for the moment
342  uncalibRecHit = leadingEdgeMethod_endcap_.makeRecHit(*itdg, pedVec, gainRatios, 0, 0);
345  } else {
347  // float mult = (float)ebPulseShape_.size() / (float)(*itdg).size();
348  // bin (or some analogous mapping) will be used instead of the leadingSample
349  //int bin = (int)(( (mult * leadingSample + mult/2) * clockToNsConstant + itimeconst ) / clockToNsConstant);
350  // bin is not uset for the moment
352  uncalibRecHit = leadingEdgeMethod_barrel_.makeRecHit(*itdg, pedVec, gainRatios, 0, 0);
355  }
356  }
357  // do not propagate the default chi2 = -1 value to the calib rechit (mapped to 64), set it to 0 when saturation
358  uncalibRecHit.setChi2(0);
359  uncalibRecHit.setOutOfTimeChi2(0);
360  } else {
361  // weights method
362  EcalTBWeights::EcalTDCId tdcid(1);
363  EcalTBWeights::EcalTBWeightMap const & wgtsMap = wgts->getMap();
364  EcalTBWeights::EcalTBWeightMap::const_iterator wit;
365  wit = wgtsMap.find( std::make_pair(*gid,tdcid) );
366  if( wit == wgtsMap.end() ) {
367  edm::LogError("EcalUncalibRecHitError") << "No weights found for EcalGroupId: "
368  << gid->id() << " and EcalTDCId: " << tdcid
369  << "\n skipping digi with id: " << detid.rawId();
370 
371  return false;
372  }
373  const EcalWeightSet& wset = wit->second; // this is the EcalWeightSet
374 
377 
378  weights[0] = &mat1;
379  weights[1] = &mat2;
380 
381  // get uncalibrated recHit from weights
382  if (detid.subdetId()==EcalEndcap) {
384  } else {
386  }
387 
388  // === time computation ===
389  // ratio method
390  float const clockToNsConstant = 25.;
391  if (detid.subdetId()==EcalEndcap) {
392  ratioMethod_endcap_.init( *itdg, *sampleMask_, pedVec, pedRMSVec, gainRatios );
396  double theTimeCorrectionEE=0;
397  if(doEEtimeCorrection_) theTimeCorrectionEE = timeCorrectionEE( uncalibRecHit.amplitude() );
398  uncalibRecHit.setJitter( crh.timeMax - 5 + theTimeCorrectionEE);
399  uncalibRecHit.setJitterError( std::sqrt(pow(crh.timeError,2) + std::pow(EEtimeConstantTerm_,2)/std::pow(clockToNsConstant,2)) );
400  uncalibRecHit.setOutOfTimeEnergy( crh.amplitudeMax );
401  // consider flagging as kOutOfTime only if above noise
402  if (uncalibRecHit.amplitude() > pedRMSVec[0] * amplitudeThreshEE_){
403  float outOfTimeThreshP = outOfTimeThreshG12pEE_;
404  float outOfTimeThreshM = outOfTimeThreshG12mEE_;
405  // determine if gain has switched away from gainId==1 (x12 gain)
406  // and determine cuts (number of 'sigmas') to ose for kOutOfTime
407  // >3k ADC is necessasry condition for gain switch to occur
408  if (uncalibRecHit.amplitude() > 3000.){
409  for (int iSample = 0; iSample < EEDataFrame::MAXSAMPLES; iSample++) {
410  int GainId = ((EcalDataFrame)(*itdg)).sample(iSample).gainId();
411  if (GainId!=1) {
412  outOfTimeThreshP = outOfTimeThreshG61pEE_;
413  outOfTimeThreshM = outOfTimeThreshG61mEE_;
414  break;
415  }
416  }}
417  float correctedTime = (crh.timeMax-5) * clockToNsConstant + itimeconst + offsetTime;
418  float cterm = EEtimeConstantTerm_;
419  float sigmaped = pedRMSVec[0]; // approx for lower gains
420  float nterm = EEtimeNconst_*sigmaped/uncalibRecHit.amplitude();
421  float sigmat = std::sqrt( nterm*nterm + cterm*cterm );
422  if ( ( correctedTime > sigmat*outOfTimeThreshP ) ||
423  ( correctedTime < (-1.*sigmat*outOfTimeThreshM) ))
424  { uncalibRecHit.setFlagBit( EcalUncalibratedRecHit::kOutOfTime ); }
425  }
426 
427  } else {
428  ratioMethod_barrel_.init( *itdg, *sampleMask_, pedVec, pedRMSVec, gainRatios );
433  double theTimeCorrectionEB=0;
434  if(doEBtimeCorrection_) theTimeCorrectionEB = timeCorrectionEB( uncalibRecHit.amplitude() );
435 
436  uncalibRecHit.setJitter( crh.timeMax - 5 + theTimeCorrectionEB);
437 
438  uncalibRecHit.setJitterError( std::sqrt(std::pow(crh.timeError,2) + std::pow(EBtimeConstantTerm_,2)/std::pow(clockToNsConstant,2)) );
439  uncalibRecHit.setOutOfTimeEnergy( crh.amplitudeMax );
440  // consider flagging as kOutOfTime only if above noise
441  if (uncalibRecHit.amplitude() > pedRMSVec[0] * amplitudeThreshEB_){
442  float outOfTimeThreshP = outOfTimeThreshG12pEB_;
443  float outOfTimeThreshM = outOfTimeThreshG12mEB_;
444  // determine if gain has switched away from gainId==1 (x12 gain)
445  // and determine cuts (number of 'sigmas') to ose for kOutOfTime
446  // >3k ADC is necessasry condition for gain switch to occur
447  if (uncalibRecHit.amplitude() > 3000.){
448  for (int iSample = 0; iSample < EBDataFrame::MAXSAMPLES; iSample++) {
449  int GainId = ((EcalDataFrame)(*itdg)).sample(iSample).gainId();
450  if (GainId!=1) {
451  outOfTimeThreshP = outOfTimeThreshG61pEB_;
452  outOfTimeThreshM = outOfTimeThreshG61mEB_;
453  break;}
454  } }
455  float correctedTime = (crh.timeMax-5) * clockToNsConstant + itimeconst + offsetTime;
456  float cterm = EBtimeConstantTerm_;
457  float sigmaped = pedRMSVec[0]; // approx for lower gains
458  float nterm = EBtimeNconst_*sigmaped/uncalibRecHit.amplitude();
459  float sigmat = std::sqrt( nterm*nterm + cterm*cterm );
460  if ( ( correctedTime > sigmat*outOfTimeThreshP ) ||
461  ( correctedTime < (-1.*sigmat*outOfTimeThreshM) ))
462  { uncalibRecHit.setFlagBit( EcalUncalibratedRecHit::kOutOfTime ); }
463  }
464  }
465 
466  // === chi2express ===
467  if (detid.subdetId()==EcalEndcap) {
468 
469  double amplitude = uncalibRecHit.amplitude();
470  double amplitudeOutOfTime = uncalibRecHit.outOfTimeEnergy();
471  double jitter= uncalibRecHit.jitter();
472 
473 
474 
476  *itdg,
477  amplitude,
478  (itimeconst + offsetTime),
479  amplitudeOutOfTime,
480  jitter,
481  pedVec,
482  pedRMSVec,
483  gainRatios,
486  );
487  double chi2 = chi2expressEE_.chi2();
488  uncalibRecHit.setChi2(chi2);
489  double chi2OutOfTime = chi2expressEE_.chi2OutOfTime();
490  uncalibRecHit.setOutOfTimeChi2(chi2OutOfTime);
491 
492  if(kPoorRecoFlagEE_)
493  {
494 
495  if (chi2>chi2ThreshEE_) {
496 
497  // first check if all samples are ok, if not don't use chi2 to flag
498  bool samplesok = true;
499  for (int sample =0; sample < EcalDataFrame::MAXSAMPLES; ++sample) {
500  if (!sampleMask_->useSampleEE(sample)) {
501  samplesok = false;
502  break;
503  }
504  }
505  if (samplesok) uncalibRecHit.setFlagBit(EcalUncalibratedRecHit::kPoorReco);
506  }
507 
508 
509  }
510 
511  } else {
512  double amplitude = uncalibRecHit.amplitude();
513  double amplitudeOutOfTime = uncalibRecHit.outOfTimeEnergy();
514  double jitter= uncalibRecHit.jitter();
515 
517  *itdg,
518  amplitude,
519  (itimeconst + offsetTime),
520  amplitudeOutOfTime,
521  jitter,
522  pedVec,
523  pedRMSVec,
524  gainRatios,
527  );
528  double chi2 = chi2expressEB_.chi2();
529  uncalibRecHit.setChi2(chi2);
530  double chi2OutOfTime = chi2expressEB_.chi2OutOfTime();
531  uncalibRecHit.setOutOfTimeChi2(chi2OutOfTime);
532 
533  if(kPoorRecoFlagEB_)
534  {
535 
536  if(chi2>chi2ThreshEB_){
537  // first check if all samples are ok, if not don't use chi2 to flag
538  bool samplesok = true;
539  for (int sample =0; sample < EcalDataFrame::MAXSAMPLES; ++sample) {
540  if (!sampleMask_->useSampleEB(sample)) {
541  samplesok = false;
542  break;
543  }
544  }
545  if (samplesok) uncalibRecHit.setFlagBit(EcalUncalibratedRecHit::kPoorReco);
546  }
547 
548  }
549  }
550  }
551 
552  // set flags if gain switch has occurred
553  if( ((EcalDataFrame)(*itdg)).hasSwitchToGain6() ) uncalibRecHit.setFlagBit( EcalUncalibratedRecHit::kHasSwitchToGain6 );
554  if( ((EcalDataFrame)(*itdg)).hasSwitchToGain1() ) uncalibRecHit.setFlagBit( EcalUncalibratedRecHit::kHasSwitchToGain1 );
555 
556  // put the recHit in the collection
557  if (detid.subdetId()==EcalEndcap) {
558  result.push_back( uncalibRecHit );
559  } else {
560  result.push_back( uncalibRecHit );
561  }
562 
563  return true;
564 }
565 
edm::ESHandle< EcalTimeOffsetConstant > offtime
std::map< std::pair< EcalXtalGroupId, EcalTDCId >, EcalWeightSet > EcalTBWeightMap
Definition: EcalTBWeights.h:19
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
bool run(const edm::Event &evt, const EcalDigiCollection::const_iterator &digi, EcalUncalibratedRecHitCollection &result)
int hashedIndex() const
get a compact index for arrays
Definition: EBDetId.h:86
void computeAmplitude(std::vector< double > &amplitudeFitParameters)
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
void setJitter(float jitter)
std::pair< double, double > EBtimeFitLimits_
void computeTime(std::vector< double > &timeFitParameters, std::pair< double, double > &timeFitLimits, std::vector< double > &amplitudeFitParameters)
void push_back(T const &t)
EcalUncalibRecHitRecWeightsAlgo< EBDataFrame > weightsMethod_barrel_
void setJitterError(float jitterErr)
std::pair< double, double > EEtimeFitLimits_
void setPulseShape(std::vector< double > &shape)
EcalUncalibRecHitRatioMethodAlgo< EEDataFrame > ratioMethod_endcap_
const unsigned int id() const
EcalUncalibRecHitLeadingEdgeAlgo< EBDataFrame > leadingEdgeMethod_barrel_
void setOutOfTimeChi2(float chi2)
int hashedIndex(int ieta, int iphi)
Definition: EcalPyUtils.cc:42
EcalUncalibRecHitRatioMethodAlgo< EBDataFrame > ratioMethod_barrel_
edm::ESHandle< EcalGainRatios > gains
EcalUncalibRecHitLeadingEdgeAlgo< EEDataFrame > leadingEdgeMethod_endcap_
T sqrt(T t)
Definition: SSEVec.h:48
edm::ESHandle< EcalPedestals > peds
tuple result
Definition: query.py:137
virtual EcalUncalibratedRecHit makeRecHit(const C &dataFrame, const double *pedestals, const double *pedestalsRMS, const double *gainRatios, const EcalWeightSet::EcalWeightMatrix **weights, const EcalShapeBase &testbeamPulseShape)
Compute parameters.
int j
Definition: DBlmapReader.cc:9
edm::ESHandle< EcalTBWeights > wgts
float gain6Over1() const
edm::ESHandle< EcalWeightXtalGroups > grps
EcalUncalibRecHitWorkerGlobal(const edm::ParameterSet &, edm::ConsumesCollector &c)
EcalWeightMatrix & getWeightsAfterGainSwitch()
Definition: EcalWeightSet.h:28
virtual EcalUncalibratedRecHit makeRecHit(const C &dataFrame, const double *pedestals, const double *gainRatios, const EcalWeightSet::EcalWeightMatrix **weights, const EcalWeightSet::EcalChi2WeightMatrix **chi2Matrix)
Compute parameters.
Definition: DetId.h:18
int hashedIndex() const
Definition: EEDetId.h:182
EcalWeightMatrix & getWeightsBeforeGainSwitch()
Definition: EcalWeightSet.h:27
const T & get() const
Definition: EventSetup.h:55
std::vector< Item >::const_iterator const_iterator
T const * product() const
Definition: ESHandle.h:62
float gain12Over6() const
const EcalWeightSet::EcalWeightMatrix * weights[2]
float EcalTimeCalibConstant
void set(const edm::EventSetup &es)
edm::ESHandle< EcalTimeCalibConstants > itime
EcalUncalibRecHitRecWeightsAlgo< EEDataFrame > weightsMethod_endcap_
math::Matrix< 3, 10 >::type EcalWeightMatrix
Definition: EcalWeightSet.h:20
#define DEFINE_EDM_PLUGIN(factory, type, name)
void setOutOfTimeEnergy(float energy)
edm::ESHandle< EcalSampleMask > sampleMaskHand_
void init(const C &dataFrame, const EcalSampleMask &sampleMask, const double *pedestals, const double *pedestalRMSes, const double *gainRatios)
static const int MAXSAMPLES
Definition: EcalDataFrame.h:48
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40