CMS 3D CMS Logo

EcalUncalibRecHitRecWeightsAlgo.h
Go to the documentation of this file.
1 #ifndef RecoLocalCalo_EcalRecAlgos_EcalUncalibRecHitRecWeightsAlgo_HH
2 #define RecoLocalCalo_EcalRecAlgos_EcalUncalibRecHitRecWeightsAlgo_HH
3 
15 #include "Math/SVector.h"
16 #include "Math/SMatrix.h"
20 
21 #include <vector>
22 
23 template<class C> class EcalUncalibRecHitRecWeightsAlgo
24 {
25  public:
26  // destructor
28 
31  const C& dataFrame
32  , const double* pedestals
33  , const double* pedestalsRMS
34  , const double* gainRatios
36  , const EcalShapeBase & testbeamPulseShape
37  ) {
38  double amplitude_(-1.), pedestal_(-1.), jitter_(-1.), chi2_(-1.);
39  uint32_t flag = 0;
40 
41 
42  // Get time samples
43  ROOT::Math::SVector<double,C::MAXSAMPLES> frame;
44  int gainId0 = 1;
45  int iGainSwitch = 0;
46  bool isSaturated = false;
47  for(int iSample = 0; iSample < C::MAXSAMPLES; iSample++) {
48  int gainId = dataFrame.sample(iSample).gainId();
49  //Handling saturation (treating saturated gainId as maximum gain)
50  if ( gainId == 0 )
51  {
52  gainId = 3;
53  //isSaturated = 1;
54  // in pileup run May2012 samples 7,8,9,10 have gainid ==0
55  // fix it like this: it won't hurt for the future SA20120512
56  if(iSample==4 || iSample ==5 || iSample==6) isSaturated = true;
57  }
58 
59  // if (gainId != gainId0) iGainSwitch = 1;
60  // same problem as above: mark saturation only when physically
61  // expected to occur SA20120513
62  if ( (gainId != gainId0) && (iSample==4 || iSample ==5 || iSample==6) ) iGainSwitch = 1;
63  if (!iGainSwitch)
64  frame(iSample) = double(dataFrame.sample(iSample).adc());
65  else
66  frame(iSample) = double(((double)(dataFrame.sample(iSample).adc()) - pedestals[gainId-1]) * gainRatios[gainId-1]);
67  }
68 
69  // Compute parameters
70  ROOT::Math::SVector <double,3> param = (*(weights[iGainSwitch])) * frame;
73  if (amplitude_) jitter_ = -param(EcalUncalibRecHitRecAbsAlgo<C>::iTime) / amplitude_;
74  else jitter_ = 0.;
75 
76  //When saturated gain flag i
77  if (isSaturated)
78  {
80  amplitude_ = double((4095. - pedestals[2]) * gainRatios[2]);
81  }
82  return EcalUncalibratedRecHit( dataFrame.id(), amplitude_, pedestal_, jitter_, chi2_, flag);
83  }
84 
86 };
87 #endif
int gainId(sample_type sample)
get the gainId (2 bits)
virtual EcalUncalibratedRecHit makeRecHit(const C &dataFrame, const double *pedestals, const double *pedestalsRMS, const double *gainRatios, const EcalWeightSet::EcalWeightMatrix **weights, const EcalShapeBase &testbeamPulseShape)
Compute parameters.
bool isSaturated(const Digi &digi, const int &maxADCvalue, int ifirst, int n)
math::Matrix< 3, 10 >::type EcalWeightMatrix
Definition: EcalWeightSet.h:22