CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Protected Member Functions | Protected Attributes
EcalUncalibRecHitWorkerGlobal Class Reference

#include <EcalUncalibRecHitWorkerGlobal.h>

Inheritance diagram for EcalUncalibRecHitWorkerGlobal:
EcalUncalibRecHitWorkerBaseClass

Public Member Functions

 EcalUncalibRecHitWorkerGlobal (const edm::ParameterSet &)
 
bool run (const edm::Event &evt, const EcalDigiCollection::const_iterator &digi, EcalUncalibratedRecHitCollection &result)
 
void set (const edm::EventSetup &es)
 
virtual ~EcalUncalibRecHitWorkerGlobal ()
 
- Public Member Functions inherited from EcalUncalibRecHitWorkerBaseClass
 EcalUncalibRecHitWorkerBaseClass (const edm::ParameterSet &)
 
virtual ~EcalUncalibRecHitWorkerBaseClass ()
 

Protected Member Functions

template<class C >
int isSaturated (const C &digi)
 
double timeCorrectionEB (float ampliEB)
 
double timeCorrectionEE (float ampliEE)
 

Protected Attributes

double amplitudeThreshEB_
 
double amplitudeThreshEE_
 
const
EcalWeightSet::EcalChi2WeightMatrix
chi2mat [2]
 
double chi2ThreshEB_
 
double chi2ThreshEE_
 
bool doEBtimeCorrection_
 
bool doEEtimeCorrection_
 
std::vector< double > EBamplitudeFitParameters_
 
std::vector< double > EBchi2Parameters_
 
std::vector< double > ebPulseShape_
 
double ebSpikeThresh_
 
double EBtimeConstantTerm_
 
std::vector< double > EBtimeCorrAmplitudeBins_
 
std::vector< double > EBtimeCorrShiftBins_
 
std::pair< double, double > EBtimeFitLimits_
 
std::vector< double > EBtimeFitParameters_
 
double EBtimeNconst_
 
std::vector< double > EEamplitudeFitParameters_
 
std::vector< double > EEchi2Parameters_
 
std::vector< double > eePulseShape_
 
double EEtimeConstantTerm_
 
std::vector< double > EEtimeCorrAmplitudeBins_
 
std::vector< double > EEtimeCorrShiftBins_
 
std::pair< double, double > EEtimeFitLimits_
 
std::vector< double > EEtimeFitParameters_
 
double EEtimeNconst_
 
double gainRatios [3]
 
edm::ESHandle< EcalGainRatiosgains
 
edm::ESHandle
< EcalWeightXtalGroups
grps
 
edm::ESHandle
< EcalTimeCalibConstants
itime
 
bool kPoorRecoFlagEB_
 
bool kPoorRecoFlagEE_
 
EcalUncalibRecHitLeadingEdgeAlgo
< EBDataFrame
leadingEdgeMethod_barrel_
 
EcalUncalibRecHitLeadingEdgeAlgo
< EEDataFrame
leadingEdgeMethod_endcap_
 
edm::ESHandle
< EcalTimeOffsetConstant
offtime
 
double outOfTimeThreshG12mEB_
 
double outOfTimeThreshG12mEE_
 
double outOfTimeThreshG12pEB_
 
double outOfTimeThreshG12pEE_
 
double outOfTimeThreshG61mEB_
 
double outOfTimeThreshG61mEE_
 
double outOfTimeThreshG61pEB_
 
double outOfTimeThreshG61pEE_
 
double pedRMSVec [3]
 
edm::ESHandle< EcalPedestalspeds
 
double pedVec [3]
 
EcalUncalibRecHitRatioMethodAlgo
< EBDataFrame
ratioMethod_barrel_
 
EcalUncalibRecHitRatioMethodAlgo
< EEDataFrame
ratioMethod_endcap_
 
edm::ESHandle< EcalSampleMasksampleMaskHand_
 
const EBShape testbeamEBShape
 
const EEShape testbeamEEShape
 
const
EcalWeightSet::EcalWeightMatrix
weights [2]
 
EcalUncalibRecHitRecWeightsAlgo
< EBDataFrame
weightsMethod_barrel_
 
EcalUncalibRecHitRecWeightsAlgo
< EEDataFrame
weightsMethod_endcap_
 
edm::ESHandle< EcalTBWeightswgts
 

Detailed Description

Definition at line 38 of file EcalUncalibRecHitWorkerGlobal.h.

Constructor & Destructor Documentation

EcalUncalibRecHitWorkerGlobal::EcalUncalibRecHitWorkerGlobal ( const edm::ParameterSet ps)

Definition at line 16 of file EcalUncalibRecHitWorkerGlobal.cc.

References amplitudeThreshEB_, amplitudeThreshEE_, chi2ThreshEB_, chi2ThreshEE_, doEBtimeCorrection_, doEEtimeCorrection_, EBamplitudeFitParameters_, EBchi2Parameters_, ebPulseShape_, ebSpikeThresh_, EBtimeConstantTerm_, EBtimeCorrAmplitudeBins_, EBtimeCorrShiftBins_, EBtimeFitLimits_, EBtimeFitParameters_, EBtimeNconst_, EEamplitudeFitParameters_, EEchi2Parameters_, eePulseShape_, EEtimeConstantTerm_, EEtimeCorrAmplitudeBins_, EEtimeCorrShiftBins_, EEtimeFitLimits_, EEtimeFitParameters_, EEtimeNconst_, edm::ParameterSet::getParameter(), kPoorRecoFlagEB_, kPoorRecoFlagEE_, outOfTimeThreshG12mEB_, outOfTimeThreshG12mEE_, outOfTimeThreshG12pEB_, outOfTimeThreshG12pEE_, outOfTimeThreshG61mEB_, outOfTimeThreshG61mEE_, outOfTimeThreshG61pEB_, and outOfTimeThreshG61pEE_.

16  :
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 }
T getParameter(std::string const &) const
std::pair< double, double > EBtimeFitLimits_
std::pair< double, double > EEtimeFitLimits_
EcalUncalibRecHitWorkerBaseClass(const edm::ParameterSet &)
virtual EcalUncalibRecHitWorkerGlobal::~EcalUncalibRecHitWorkerGlobal ( )
inlinevirtual

Definition at line 42 of file EcalUncalibRecHitWorkerGlobal.h.

42 {};

Member Function Documentation

template<class C >
int EcalUncalibRecHitWorkerGlobal::isSaturated ( const C &  digi)
protected

Definition at line 96 of file EcalUncalibRecHitWorkerGlobal.cc.

References i, and j.

97 {
98  //bool saturated_ = 0;
99  int cnt;
100  for (int j = 0; j < C::MAXSAMPLES - 5; ++j) {
101  cnt = 0;
102  for (int i = j; i < (j + 5) && i < C::MAXSAMPLES; ++i) {
103  if ( dataFrame.sample(i).gainId() == 0 ) ++cnt;
104  }
105  if ( cnt == 5 ) return j-1 ; // the last unsaturated sample
106  }
107  return -1; // no saturation found
108 }
int i
Definition: DBlmapReader.cc:9
int j
Definition: DBlmapReader.cc:9
bool EcalUncalibRecHitWorkerGlobal::run ( const edm::Event evt,
const EcalDigiCollection::const_iterator digi,
EcalUncalibratedRecHitCollection result 
)
virtual

Implements EcalUncalibRecHitWorkerBaseClass.

Definition at line 189 of file EcalUncalibRecHitWorkerGlobal.cc.

References EcalUncalibratedRecHit::amplitude(), amplitudeThreshEB_, amplitudeThreshEE_, EcalUncalibRecHitRecChi2Algo< C >::chi2(), EcalUncalibRecHitRecChi2Algo< C >::chi2OutOfTime(), chi2ThreshEB_, chi2ThreshEE_, EcalUncalibRecHitRatioMethodAlgo< C >::computeAmplitude(), EcalUncalibRecHitRatioMethodAlgo< C >::computeTime(), cond::rpcobgas::detid, doEBtimeCorrection_, doEEtimeCorrection_, EBamplitudeFitParameters_, EBchi2Parameters_, ebPulseShape_, EBtimeConstantTerm_, EBtimeFitLimits_, EBtimeFitParameters_, EBtimeNconst_, EcalBarrel, EcalEndcap, EEamplitudeFitParameters_, EEchi2Parameters_, eePulseShape_, EEtimeConstantTerm_, EEtimeFitLimits_, EEtimeFitParameters_, EEtimeNconst_, EcalUncalibRecHitRatioMethodAlgo< C >::fixMGPAslew(), EcalMGPAGainRatio::gain12Over6(), EcalMGPAGainRatio::gain6Over1(), gainRatios, gains, EcalUncalibRecHitRatioMethodAlgo< C >::getCalculatedRecHit(), EcalWeightSet::getWeightsAfterGainSwitch(), EcalWeightSet::getWeightsBeforeGainSwitch(), grps, ecalpyutils::hashedIndex(), EBDetId::hashedIndex(), EEDetId::hashedIndex(), EcalXtalGroupId::id(), EcalUncalibRecHitRatioMethodAlgo< C >::init(), itime, EcalUncalibratedRecHit::jitter(), EcalUncalibratedRecHit::kHasSwitchToGain1, EcalUncalibratedRecHit::kHasSwitchToGain6, EcalUncalibratedRecHit::kLeadingEdgeRecovered, EcalUncalibratedRecHit::kOutOfTime, EcalUncalibratedRecHit::kPoorReco, kPoorRecoFlagEB_, kPoorRecoFlagEE_, EcalUncalibratedRecHit::kSaturated, leadingEdgeMethod_barrel_, leadingEdgeMethod_endcap_, EcalUncalibRecHitRecWeightsAlgo< C >::makeRecHit(), EcalUncalibRecHitLeadingEdgeAlgo< C >::makeRecHit(), EcalDataFrame::MAXSAMPLES, offtime, EcalUncalibratedRecHit::outOfTimeEnergy(), outOfTimeThreshG12mEB_, outOfTimeThreshG12mEE_, outOfTimeThreshG12pEB_, outOfTimeThreshG12pEE_, outOfTimeThreshG61mEB_, outOfTimeThreshG61mEE_, outOfTimeThreshG61pEB_, outOfTimeThreshG61pEE_, pedRMSVec, peds, pedVec, funct::pow(), edm::ESHandle< class >::product(), edm::SortedCollection< T, SORT >::push_back(), ratioMethod_barrel_, ratioMethod_endcap_, compare_using_db::sample, sampleMaskHand_, EcalUncalibratedRecHit::setChi2(), EcalUncalibratedRecHit::setFlagBit(), EcalUncalibratedRecHit::setJitter(), EcalUncalibratedRecHit::setJitterError(), EcalUncalibRecHitLeadingEdgeAlgo< C >::setLeadingEdgeSample(), EcalUncalibratedRecHit::setOutOfTimeChi2(), EcalUncalibratedRecHit::setOutOfTimeEnergy(), EcalUncalibRecHitLeadingEdgeAlgo< C >::setPulseShape(), mathSSE::sqrt(), testbeamEBShape, testbeamEEShape, timeCorrectionEB(), timeCorrectionEE(), weights, weightsMethod_barrel_, weightsMethod_endcap_, and wgts.

192 {
193  DetId detid(itdg->id());
194 
195  const EcalSampleMask *sampleMask_ = sampleMaskHand_.product();
196 
197  // intelligence for recHit computation
198  EcalUncalibratedRecHit uncalibRecHit;
199 
200 
201  const EcalPedestals::Item * aped = 0;
202  const EcalMGPAGainRatio * aGain = 0;
203  const EcalXtalGroupId * gid = 0;
204  float offsetTime = 0;
205 
206  if (detid.subdetId()==EcalEndcap) {
207  unsigned int hashedIndex = EEDetId(detid).hashedIndex();
208  aped = &peds->endcap(hashedIndex);
209  aGain = &gains->endcap(hashedIndex);
210  gid = &grps->endcap(hashedIndex);
211  offsetTime = offtime->getEEValue();
212  } else {
213  unsigned int hashedIndex = EBDetId(detid).hashedIndex();
214  aped = &peds->barrel(hashedIndex);
215  aGain = &gains->barrel(hashedIndex);
216  gid = &grps->barrel(hashedIndex);
217  offsetTime = offtime->getEBValue();
218  }
219 
220  pedVec[0] = aped->mean_x12;
221  pedVec[1] = aped->mean_x6;
222  pedVec[2] = aped->mean_x1;
223  pedRMSVec[0] = aped->rms_x12;
224  pedRMSVec[1] = aped->rms_x6;
225  pedRMSVec[2] = aped->rms_x1;
226  gainRatios[0] = 1.;
227  gainRatios[1] = aGain->gain12Over6();
228  gainRatios[2] = aGain->gain6Over1()*aGain->gain12Over6();
229 
230  // compute the right bin of the pulse shape using time calibration constants
232  EcalTimeCalibConstant itimeconst = 0;
233  if( it != itime->end() ) {
234  itimeconst = (*it);
235  } else {
236  edm::LogError("EcalRecHitError") << "No time intercalib const found for xtal "
237  << detid.rawId()
238  << "! something wrong with EcalTimeCalibConstants in your DB? ";
239  }
240 
241 
242  // === amplitude computation ===
243  int leadingSample = -1;
244  if (detid.subdetId()==EcalEndcap) {
245  leadingSample = ((EcalDataFrame)(*itdg)).lastUnsaturatedSample();
246  } else {
247  leadingSample = ((EcalDataFrame)(*itdg)).lastUnsaturatedSample();
248  }
249 
250  if ( leadingSample >= 0 ) { // saturation
251  if ( leadingSample != 4 ) {
252  // all samples different from the fifth are not reliable for the amplitude estimation
253  // put by default the energy at the saturation threshold and flag as saturated
254  float sratio = 1;
255  if ( detid.subdetId()==EcalBarrel) {
256  sratio = ebPulseShape_[5] / ebPulseShape_[4];
257  } else {
258  sratio = eePulseShape_[5] / eePulseShape_[4];
259  }
260  uncalibRecHit = EcalUncalibratedRecHit( (*itdg).id(), 4095*12*sratio, 0, 0, 0);
262  } else {
263  // float clockToNsConstant = 25.;
264  // reconstruct the rechit
265  if (detid.subdetId()==EcalEndcap) {
267  // float mult = (float)eePulseShape_.size() / (float)(*itdg).size();
268  // bin (or some analogous mapping) will be used instead of the leadingSample
269  //int bin = (int)(( (mult * leadingSample + mult/2) * clockToNsConstant + itimeconst ) / clockToNsConstant);
270  // bin is not uset for the moment
272  uncalibRecHit = leadingEdgeMethod_endcap_.makeRecHit(*itdg, pedVec, gainRatios, 0, 0);
275  } else {
277  // float mult = (float)ebPulseShape_.size() / (float)(*itdg).size();
278  // bin (or some analogous mapping) will be used instead of the leadingSample
279  //int bin = (int)(( (mult * leadingSample + mult/2) * clockToNsConstant + itimeconst ) / clockToNsConstant);
280  // bin is not uset for the moment
282  uncalibRecHit = leadingEdgeMethod_barrel_.makeRecHit(*itdg, pedVec, gainRatios, 0, 0);
285  }
286  }
287  // do not propagate the default chi2 = -1 value to the calib rechit (mapped to 64), set it to 0 when saturation
288  uncalibRecHit.setChi2(0);
289  uncalibRecHit.setOutOfTimeChi2(0);
290  } else {
291  // weights method
292  EcalTBWeights::EcalTDCId tdcid(1);
293  EcalTBWeights::EcalTBWeightMap const & wgtsMap = wgts->getMap();
294  EcalTBWeights::EcalTBWeightMap::const_iterator wit;
295  wit = wgtsMap.find( std::make_pair(*gid,tdcid) );
296  if( wit == wgtsMap.end() ) {
297  edm::LogError("EcalUncalibRecHitError") << "No weights found for EcalGroupId: "
298  << gid->id() << " and EcalTDCId: " << tdcid
299  << "\n skipping digi with id: " << detid.rawId();
300 
301  return false;
302  }
303  const EcalWeightSet& wset = wit->second; // this is the EcalWeightSet
304 
307 
308  weights[0] = &mat1;
309  weights[1] = &mat2;
310 
311  // get uncalibrated recHit from weights
312  if (detid.subdetId()==EcalEndcap) {
314  } else {
316  }
317 
318  // === time computation ===
319  // ratio method
320  float const clockToNsConstant = 25.;
321  if (detid.subdetId()==EcalEndcap) {
322  ratioMethod_endcap_.init( *itdg, *sampleMask_, pedVec, pedRMSVec, gainRatios );
326  double theTimeCorrectionEE=0;
327  if(doEEtimeCorrection_) theTimeCorrectionEE = timeCorrectionEE( uncalibRecHit.amplitude() );
328  uncalibRecHit.setJitter( crh.timeMax - 5 + theTimeCorrectionEE);
329  uncalibRecHit.setJitterError( std::sqrt(pow(crh.timeError,2) + std::pow(EEtimeConstantTerm_,2)/std::pow(clockToNsConstant,2)) );
330  uncalibRecHit.setOutOfTimeEnergy( crh.amplitudeMax );
331  // consider flagging as kOutOfTime only if above noise
332  if (uncalibRecHit.amplitude() > pedRMSVec[0] * amplitudeThreshEE_){
333  float outOfTimeThreshP = outOfTimeThreshG12pEE_;
334  float outOfTimeThreshM = outOfTimeThreshG12mEE_;
335  // determine if gain has switched away from gainId==1 (x12 gain)
336  // and determine cuts (number of 'sigmas') to ose for kOutOfTime
337  // >3k ADC is necessasry condition for gain switch to occur
338  if (uncalibRecHit.amplitude() > 3000.){
339  for (int iSample = 0; iSample < EEDataFrame::MAXSAMPLES; iSample++) {
340  int GainId = ((EcalDataFrame)(*itdg)).sample(iSample).gainId();
341  if (GainId!=1) {
342  outOfTimeThreshP = outOfTimeThreshG61pEE_;
343  outOfTimeThreshM = outOfTimeThreshG61mEE_;
344  break;
345  }
346  }}
347  float correctedTime = (crh.timeMax-5) * clockToNsConstant + itimeconst + offsetTime;
348  float cterm = EEtimeConstantTerm_;
349  float sigmaped = pedRMSVec[0]; // approx for lower gains
350  float nterm = EEtimeNconst_*sigmaped/uncalibRecHit.amplitude();
351  float sigmat = std::sqrt( nterm*nterm + cterm*cterm );
352  if ( ( correctedTime > sigmat*outOfTimeThreshP ) ||
353  ( correctedTime < (-1.*sigmat*outOfTimeThreshM) ))
354  { uncalibRecHit.setFlagBit( EcalUncalibratedRecHit::kOutOfTime ); }
355  }
356 
357  } else {
358  ratioMethod_barrel_.init( *itdg, *sampleMask_, pedVec, pedRMSVec, gainRatios );
363  double theTimeCorrectionEB=0;
364  if(doEBtimeCorrection_) theTimeCorrectionEB = timeCorrectionEB( uncalibRecHit.amplitude() );
365 
366  uncalibRecHit.setJitter( crh.timeMax - 5 + theTimeCorrectionEB);
367 
368  uncalibRecHit.setJitterError( std::sqrt(std::pow(crh.timeError,2) + std::pow(EBtimeConstantTerm_,2)/std::pow(clockToNsConstant,2)) );
369  uncalibRecHit.setOutOfTimeEnergy( crh.amplitudeMax );
370  // consider flagging as kOutOfTime only if above noise
371  if (uncalibRecHit.amplitude() > pedRMSVec[0] * amplitudeThreshEB_){
372  float outOfTimeThreshP = outOfTimeThreshG12pEB_;
373  float outOfTimeThreshM = outOfTimeThreshG12mEB_;
374  // determine if gain has switched away from gainId==1 (x12 gain)
375  // and determine cuts (number of 'sigmas') to ose for kOutOfTime
376  // >3k ADC is necessasry condition for gain switch to occur
377  if (uncalibRecHit.amplitude() > 3000.){
378  for (int iSample = 0; iSample < EBDataFrame::MAXSAMPLES; iSample++) {
379  int GainId = ((EcalDataFrame)(*itdg)).sample(iSample).gainId();
380  if (GainId!=1) {
381  outOfTimeThreshP = outOfTimeThreshG61pEB_;
382  outOfTimeThreshM = outOfTimeThreshG61mEB_;
383  break;}
384  } }
385  float correctedTime = (crh.timeMax-5) * clockToNsConstant + itimeconst + offsetTime;
386  float cterm = EBtimeConstantTerm_;
387  float sigmaped = pedRMSVec[0]; // approx for lower gains
388  float nterm = EBtimeNconst_*sigmaped/uncalibRecHit.amplitude();
389  float sigmat = std::sqrt( nterm*nterm + cterm*cterm );
390  if ( ( correctedTime > sigmat*outOfTimeThreshP ) ||
391  ( correctedTime < (-1.*sigmat*outOfTimeThreshM) ))
392  { uncalibRecHit.setFlagBit( EcalUncalibratedRecHit::kOutOfTime ); }
393  }
394  }
395 
396  // === chi2express ===
397  if (detid.subdetId()==EcalEndcap) {
398 
399  double amplitude = uncalibRecHit.amplitude();
400  double amplitudeOutOfTime = uncalibRecHit.outOfTimeEnergy();
401  double jitter= uncalibRecHit.jitter();
402 
403 
404 
406  *itdg,
407  amplitude,
408  (itimeconst + offsetTime),
409  amplitudeOutOfTime,
410  jitter,
411  pedVec,
412  pedRMSVec,
413  gainRatios,
416  );
417  double chi2 = chi2expressEE_.chi2();
418  uncalibRecHit.setChi2(chi2);
419  double chi2OutOfTime = chi2expressEE_.chi2OutOfTime();
420  uncalibRecHit.setOutOfTimeChi2(chi2OutOfTime);
421 
422  if(kPoorRecoFlagEE_)
423  {
425  }
426 
427  } else {
428  double amplitude = uncalibRecHit.amplitude();
429  double amplitudeOutOfTime = uncalibRecHit.outOfTimeEnergy();
430  double jitter= uncalibRecHit.jitter();
431 
433  *itdg,
434  amplitude,
435  (itimeconst + offsetTime),
436  amplitudeOutOfTime,
437  jitter,
438  pedVec,
439  pedRMSVec,
440  gainRatios,
443  );
444  double chi2 = chi2expressEB_.chi2();
445  uncalibRecHit.setChi2(chi2);
446  double chi2OutOfTime = chi2expressEB_.chi2OutOfTime();
447  uncalibRecHit.setOutOfTimeChi2(chi2OutOfTime);
448 
449  if(kPoorRecoFlagEB_)
450  {
452  }
453  }
454  }
455 
456  // set flags if gain switch has occurred
457  if( ((EcalDataFrame)(*itdg)).hasSwitchToGain6() ) uncalibRecHit.setFlagBit( EcalUncalibratedRecHit::kHasSwitchToGain6 );
458  if( ((EcalDataFrame)(*itdg)).hasSwitchToGain1() ) uncalibRecHit.setFlagBit( EcalUncalibratedRecHit::kHasSwitchToGain1 );
459 
460  // put the recHit in the collection
461  if (detid.subdetId()==EcalEndcap) {
462  result.push_back( uncalibRecHit );
463  } else {
464  result.push_back( uncalibRecHit );
465  }
466 
467  return true;
468 }
edm::ESHandle< EcalTimeOffsetConstant > offtime
std::map< std::pair< EcalXtalGroupId, EcalTDCId >, EcalWeightSet > EcalTBWeightMap
Definition: EcalTBWeights.h:19
int hashedIndex() const
get a compact index for arrays
Definition: EBDetId.h:73
void computeAmplitude(std::vector< double > &amplitudeFitParameters)
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:46
edm::ESHandle< EcalPedestals > peds
virtual EcalUncalibratedRecHit makeRecHit(const C &dataFrame, const double *pedestals, const double *pedestalsRMS, const double *gainRatios, const EcalWeightSet::EcalWeightMatrix **weights, const EcalShapeBase &testbeamPulseShape)
Compute parameters.
edm::ESHandle< EcalTBWeights > wgts
float gain6Over1() const
edm::ESHandle< EcalWeightXtalGroups > grps
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:20
int hashedIndex() const
Definition: EEDetId.h:177
EcalWeightMatrix & getWeightsBeforeGainSwitch()
Definition: EcalWeightSet.h:27
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
edm::ESHandle< EcalTimeCalibConstants > itime
EcalUncalibRecHitRecWeightsAlgo< EEDataFrame > weightsMethod_endcap_
math::Matrix< 3, 10 >::type EcalWeightMatrix
Definition: EcalWeightSet.h:20
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:49
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
void EcalUncalibRecHitWorkerGlobal::set ( const edm::EventSetup es)
virtual

Implements EcalUncalibRecHitWorkerBaseClass.

Definition at line 73 of file EcalUncalibRecHitWorkerGlobal.cc.

References gains, edm::EventSetup::get(), grps, itime, offtime, peds, sampleMaskHand_, and wgts.

Referenced by betterConfigParser.BetterConfigParser::getGeneral().

74 {
75  // common setup
76  es.get<EcalGainRatiosRcd>().get(gains);
77  es.get<EcalPedestalsRcd>().get(peds);
78 
79  // for the weights method
80  es.get<EcalWeightXtalGroupsRcd>().get(grps);
81  es.get<EcalTBWeightsRcd>().get(wgts);
82 
83  // which of the samples need be used
85 
86  // for the ratio method
87 
88  // for the leading edge method
91 }
edm::ESHandle< EcalTimeOffsetConstant > offtime
edm::ESHandle< EcalGainRatios > gains
edm::ESHandle< EcalPedestals > peds
edm::ESHandle< EcalTBWeights > wgts
edm::ESHandle< EcalWeightXtalGroups > grps
const T & get() const
Definition: EventSetup.h:55
edm::ESHandle< EcalTimeCalibConstants > itime
edm::ESHandle< EcalSampleMask > sampleMaskHand_
double EcalUncalibRecHitWorkerGlobal::timeCorrectionEB ( float  ampliEB)
protected

Definition at line 111 of file EcalUncalibRecHitWorkerGlobal.cc.

References newFWLiteAna::bin, EBtimeCorrAmplitudeBins_, and EBtimeCorrShiftBins_.

Referenced by run().

111  {
112  // computed initially in ns. Than turned in the BX's, as EcalUncalibratedRecHit need be.
113  double theCorrection=0;
114 
115 
116  int myBin = -1;
117  for (int bin=0; bin<(int)EBtimeCorrAmplitudeBins_.size(); bin++ ){
118  if(ampliEB > EBtimeCorrAmplitudeBins_.at(bin)) {
119  myBin = bin; }
120  else break;
121  }
122 
123  if (myBin == -1)
124  {
125  theCorrection = EBtimeCorrShiftBins_.at(0);
126  }
127  else if ( myBin == ((int)(EBtimeCorrAmplitudeBins_.size()-1)) )
128  {
129  theCorrection = EBtimeCorrShiftBins_.at( myBin );
130  }
131  else if ( -1 < myBin && myBin < ((int)EBtimeCorrAmplitudeBins_.size()-1) )
132  {
133  // interpolate linearly between two assingned points
134  theCorrection = ( EBtimeCorrShiftBins_.at(myBin+1) - EBtimeCorrShiftBins_.at(myBin) );
135  theCorrection *= ( ((double)ampliEB) - EBtimeCorrAmplitudeBins_.at(myBin) ) / ( EBtimeCorrAmplitudeBins_.at(myBin+1) - EBtimeCorrAmplitudeBins_.at(myBin) );
136  theCorrection += EBtimeCorrShiftBins_.at(myBin);
137  }
138  else
139  {
140  edm::LogError("EcalRecHitError") << "Assigning time correction impossible. Setting it to 0 ";
141  theCorrection = 0.;
142  }
143 
144  // convert ns into clocks
145  return theCorrection/25.;
146 }
double EcalUncalibRecHitWorkerGlobal::timeCorrectionEE ( float  ampliEE)
protected

Definition at line 149 of file EcalUncalibRecHitWorkerGlobal.cc.

References newFWLiteAna::bin, EEtimeCorrAmplitudeBins_, and EEtimeCorrShiftBins_.

Referenced by run().

149  {
150  // computed initially in ns. Than turned in the BX's, as EcalUncalibratedRecHit need be.
151  double theCorrection=0;
152 
153  int myBin = -1;
154  for (int bin=0; bin<(int)EEtimeCorrAmplitudeBins_.size(); bin++ ){
155  if(ampliEE > EEtimeCorrAmplitudeBins_.at(bin)) {
156  myBin = bin; }
157  else break;
158  }
159 
160  if (myBin == -1)
161  {
162  theCorrection = EEtimeCorrShiftBins_.at(0);
163  }
164  else if ( myBin == ((int)(EEtimeCorrAmplitudeBins_.size()-1)) )
165  {
166  theCorrection = EEtimeCorrShiftBins_.at( myBin );
167  }
168  else if ( -1 < myBin && myBin < ((int)EEtimeCorrAmplitudeBins_.size()-1) )
169  {
170  // interpolate linearly between two assingned points
171  theCorrection = ( EEtimeCorrShiftBins_.at(myBin+1) - EEtimeCorrShiftBins_.at(myBin) );
172  theCorrection *= ( ((double)ampliEE) - EEtimeCorrAmplitudeBins_.at(myBin) ) / ( EEtimeCorrAmplitudeBins_.at(myBin+1) - EEtimeCorrAmplitudeBins_.at(myBin) );
173  theCorrection += EEtimeCorrShiftBins_.at(myBin);
174  }
175  else
176  {
177  edm::LogError("EcalRecHitError") << "Assigning time correction impossible. Setting it to 0 ";
178  theCorrection = 0.;
179  }
180 
181  // convert ns into clocks
182  return theCorrection/25.;
183 }

Member Data Documentation

double EcalUncalibRecHitWorkerGlobal::amplitudeThreshEB_
protected

Definition at line 102 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by EcalUncalibRecHitWorkerGlobal(), and run().

double EcalUncalibRecHitWorkerGlobal::amplitudeThreshEE_
protected

Definition at line 103 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by EcalUncalibRecHitWorkerGlobal(), and run().

const EcalWeightSet::EcalChi2WeightMatrix* EcalUncalibRecHitWorkerGlobal::chi2mat[2]
protected

Definition at line 65 of file EcalUncalibRecHitWorkerGlobal.h.

double EcalUncalibRecHitWorkerGlobal::chi2ThreshEB_
protected

Definition at line 117 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by EcalUncalibRecHitWorkerGlobal(), and run().

double EcalUncalibRecHitWorkerGlobal::chi2ThreshEE_
protected

Definition at line 118 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by EcalUncalibRecHitWorkerGlobal(), and run().

bool EcalUncalibRecHitWorkerGlobal::doEBtimeCorrection_
protected

Definition at line 81 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by EcalUncalibRecHitWorkerGlobal(), and run().

bool EcalUncalibRecHitWorkerGlobal::doEEtimeCorrection_
protected

Definition at line 82 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by EcalUncalibRecHitWorkerGlobal(), and run().

std::vector<double> EcalUncalibRecHitWorkerGlobal::EBamplitudeFitParameters_
protected

Definition at line 77 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by EcalUncalibRecHitWorkerGlobal(), and run().

std::vector<double> EcalUncalibRecHitWorkerGlobal::EBchi2Parameters_
protected

Definition at line 119 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by EcalUncalibRecHitWorkerGlobal(), and run().

std::vector<double> EcalUncalibRecHitWorkerGlobal::ebPulseShape_
protected

Definition at line 109 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by EcalUncalibRecHitWorkerGlobal(), and run().

double EcalUncalibRecHitWorkerGlobal::ebSpikeThresh_
protected

Definition at line 104 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by EcalUncalibRecHitWorkerGlobal().

double EcalUncalibRecHitWorkerGlobal::EBtimeConstantTerm_
protected

Definition at line 90 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by EcalUncalibRecHitWorkerGlobal(), and run().

std::vector<double> EcalUncalibRecHitWorkerGlobal::EBtimeCorrAmplitudeBins_
protected
std::vector<double> EcalUncalibRecHitWorkerGlobal::EBtimeCorrShiftBins_
protected
std::pair<double,double> EcalUncalibRecHitWorkerGlobal::EBtimeFitLimits_
protected

Definition at line 79 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by EcalUncalibRecHitWorkerGlobal(), and run().

std::vector<double> EcalUncalibRecHitWorkerGlobal::EBtimeFitParameters_
protected

Definition at line 75 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by EcalUncalibRecHitWorkerGlobal(), and run().

double EcalUncalibRecHitWorkerGlobal::EBtimeNconst_
protected

Definition at line 91 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by EcalUncalibRecHitWorkerGlobal(), and run().

std::vector<double> EcalUncalibRecHitWorkerGlobal::EEamplitudeFitParameters_
protected

Definition at line 78 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by EcalUncalibRecHitWorkerGlobal(), and run().

std::vector<double> EcalUncalibRecHitWorkerGlobal::EEchi2Parameters_
protected

Definition at line 120 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by EcalUncalibRecHitWorkerGlobal(), and run().

std::vector<double> EcalUncalibRecHitWorkerGlobal::eePulseShape_
protected

Definition at line 110 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by EcalUncalibRecHitWorkerGlobal(), and run().

double EcalUncalibRecHitWorkerGlobal::EEtimeConstantTerm_
protected

Definition at line 92 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by EcalUncalibRecHitWorkerGlobal(), and run().

std::vector<double> EcalUncalibRecHitWorkerGlobal::EEtimeCorrAmplitudeBins_
protected
std::vector<double> EcalUncalibRecHitWorkerGlobal::EEtimeCorrShiftBins_
protected
std::pair<double,double> EcalUncalibRecHitWorkerGlobal::EEtimeFitLimits_
protected

Definition at line 80 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by EcalUncalibRecHitWorkerGlobal(), and run().

std::vector<double> EcalUncalibRecHitWorkerGlobal::EEtimeFitParameters_
protected

Definition at line 76 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by EcalUncalibRecHitWorkerGlobal(), and run().

double EcalUncalibRecHitWorkerGlobal::EEtimeNconst_
protected

Definition at line 93 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by EcalUncalibRecHitWorkerGlobal(), and run().

double EcalUncalibRecHitWorkerGlobal::gainRatios[3]
protected

Definition at line 51 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by run().

edm::ESHandle<EcalGainRatios> EcalUncalibRecHitWorkerGlobal::gains
protected

Definition at line 54 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by run(), and set().

edm::ESHandle<EcalWeightXtalGroups> EcalUncalibRecHitWorkerGlobal::grps
protected

Definition at line 62 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by run(), and set().

edm::ESHandle<EcalTimeCalibConstants> EcalUncalibRecHitWorkerGlobal::itime
protected

Definition at line 107 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by run(), and set().

bool EcalUncalibRecHitWorkerGlobal::kPoorRecoFlagEB_
protected

Definition at line 115 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by EcalUncalibRecHitWorkerGlobal(), and run().

bool EcalUncalibRecHitWorkerGlobal::kPoorRecoFlagEE_
protected

Definition at line 116 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by EcalUncalibRecHitWorkerGlobal(), and run().

EcalUncalibRecHitLeadingEdgeAlgo<EBDataFrame> EcalUncalibRecHitWorkerGlobal::leadingEdgeMethod_barrel_
protected

Definition at line 111 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by run().

EcalUncalibRecHitLeadingEdgeAlgo<EEDataFrame> EcalUncalibRecHitWorkerGlobal::leadingEdgeMethod_endcap_
protected

Definition at line 112 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by run().

edm::ESHandle<EcalTimeOffsetConstant> EcalUncalibRecHitWorkerGlobal::offtime
protected

Definition at line 108 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by run(), and set().

double EcalUncalibRecHitWorkerGlobal::outOfTimeThreshG12mEB_
protected

Definition at line 95 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by EcalUncalibRecHitWorkerGlobal(), and run().

double EcalUncalibRecHitWorkerGlobal::outOfTimeThreshG12mEE_
protected

Definition at line 99 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by EcalUncalibRecHitWorkerGlobal(), and run().

double EcalUncalibRecHitWorkerGlobal::outOfTimeThreshG12pEB_
protected

Definition at line 94 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by EcalUncalibRecHitWorkerGlobal(), and run().

double EcalUncalibRecHitWorkerGlobal::outOfTimeThreshG12pEE_
protected

Definition at line 98 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by EcalUncalibRecHitWorkerGlobal(), and run().

double EcalUncalibRecHitWorkerGlobal::outOfTimeThreshG61mEB_
protected

Definition at line 97 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by EcalUncalibRecHitWorkerGlobal(), and run().

double EcalUncalibRecHitWorkerGlobal::outOfTimeThreshG61mEE_
protected

Definition at line 101 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by EcalUncalibRecHitWorkerGlobal(), and run().

double EcalUncalibRecHitWorkerGlobal::outOfTimeThreshG61pEB_
protected

Definition at line 96 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by EcalUncalibRecHitWorkerGlobal(), and run().

double EcalUncalibRecHitWorkerGlobal::outOfTimeThreshG61pEE_
protected

Definition at line 100 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by EcalUncalibRecHitWorkerGlobal(), and run().

double EcalUncalibRecHitWorkerGlobal::pedRMSVec[3]
protected

Definition at line 50 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by run().

edm::ESHandle<EcalPedestals> EcalUncalibRecHitWorkerGlobal::peds
protected

Definition at line 53 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by run(), and set().

double EcalUncalibRecHitWorkerGlobal::pedVec[3]
protected

Definition at line 49 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by run().

EcalUncalibRecHitRatioMethodAlgo<EBDataFrame> EcalUncalibRecHitWorkerGlobal::ratioMethod_barrel_
protected

Definition at line 87 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by run().

EcalUncalibRecHitRatioMethodAlgo<EEDataFrame> EcalUncalibRecHitWorkerGlobal::ratioMethod_endcap_
protected

Definition at line 88 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by run().

edm::ESHandle<EcalSampleMask> EcalUncalibRecHitWorkerGlobal::sampleMaskHand_
protected

Definition at line 72 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by run(), and set().

const EBShape EcalUncalibRecHitWorkerGlobal::testbeamEBShape
protected

Definition at line 69 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by run().

const EEShape EcalUncalibRecHitWorkerGlobal::testbeamEEShape
protected

Definition at line 68 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by run().

const EcalWeightSet::EcalWeightMatrix* EcalUncalibRecHitWorkerGlobal::weights[2]
protected

Definition at line 64 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by run().

EcalUncalibRecHitRecWeightsAlgo<EBDataFrame> EcalUncalibRecHitWorkerGlobal::weightsMethod_barrel_
protected

Definition at line 66 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by run().

EcalUncalibRecHitRecWeightsAlgo<EEDataFrame> EcalUncalibRecHitWorkerGlobal::weightsMethod_endcap_
protected

Definition at line 67 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by run().

edm::ESHandle<EcalTBWeights> EcalUncalibRecHitWorkerGlobal::wgts
protected

Definition at line 63 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by run(), and set().