CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EcalUncalibRecHitRecWeightsAlgo.h
Go to the documentation of this file.
1 #ifndef RecoLocalCalo_EcalRecAlgos_EcalUncalibRecHitRecWeightsAlgo_HH
2 #define RecoLocalCalo_EcalRecAlgos_EcalUncalibRecHitRecWeightsAlgo_HH
3 
18 #include "Math/SVector.h"
19 #include "Math/SMatrix.h"
23 
24 #include <vector>
25 
26 template<class C> class EcalUncalibRecHitRecWeightsAlgo
27 {
28  public:
29  // destructor
31 
34  const C& dataFrame
35  , const double* pedestals
36  , const double* pedestalsRMS
37  , const double* gainRatios
39  , const EcalShapeBase & testbeamPulseShape
40  ) {
41  double amplitude_(-1.), pedestal_(-1.), jitter_(-1.), chi2_(-1.);
42  uint32_t flag = 0;
43 
44 
45  // Get time samples
46  ROOT::Math::SVector<double,C::MAXSAMPLES> frame;
47  int gainId0 = 1;
48  int iGainSwitch = 0;
49  bool isSaturated = 0;
50  for(int iSample = 0; iSample < C::MAXSAMPLES; iSample++) {
51  int gainId = dataFrame.sample(iSample).gainId();
52  //Handling saturation (treating saturated gainId as maximum gain)
53  if ( gainId == 0 )
54  {
55  gainId = 3;
56  isSaturated = 1;
57  }
58 
59  if (gainId != gainId0) iGainSwitch = 1;
60  if (!iGainSwitch)
61  frame(iSample) = double(dataFrame.sample(iSample).adc());
62  else
63  frame(iSample) = double(((double)(dataFrame.sample(iSample).adc()) - pedestals[gainId-1]) * gainRatios[gainId-1]);
64  }
65 
66  // Compute parameters
67  ROOT::Math::SVector <double,3> param = (*(weights[iGainSwitch])) * frame;
70  if (amplitude_) jitter_ = param(EcalUncalibRecHitRecAbsAlgo<C>::iTime);
71 
72 
73  //When saturated gain flag i
74  if (isSaturated)
75  {
77  amplitude_ = double((4095. - pedestals[2]) * gainRatios[2]);
78  }
79  return EcalUncalibratedRecHit( dataFrame.id(), amplitude_, pedestal_, jitter_, chi2_, flag);
80  }
81 
83 };
84 #endif
long int flag
Definition: mlp_lapack.h:47
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.
math::Matrix< 3, 10 >::type EcalWeightMatrix
Definition: EcalWeightSet.h:20