CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions
EcalUncalibRecHitRecAnalFitAlgo< C > Class Template Reference

#include <EcalUncalibRecHitRecAnalFitAlgo.h>

Inheritance diagram for EcalUncalibRecHitRecAnalFitAlgo< C >:
EcalUncalibRecHitRecAbsAlgo< C >

Public Member Functions

EcalUncalibratedRecHit makeRecHit (const C &dataFrame, const double *pedestals, const double *gainRatios, const EcalWeightSet::EcalWeightMatrix **weights, const EcalWeightSet::EcalChi2WeightMatrix **chi2Matrix) override
 Compute parameters. More...
 
 ~EcalUncalibRecHitRecAnalFitAlgo () override
 
- Public Member Functions inherited from EcalUncalibRecHitRecAbsAlgo< C >
virtual ~EcalUncalibRecHitRecAbsAlgo ()=default
 Constructor. More...
 

Private Member Functions

double pedestalFunction (double *var, double *par)
 
double pulseShapeFunction (double *var, double *par)
 

Additional Inherited Members

- Public Types inherited from EcalUncalibRecHitRecAbsAlgo< C >
enum  { nWeightsRows = 3, iAmplitude = 0, iPedestal = 1, iTime = 2 }
 

Detailed Description

template<class C>
class EcalUncalibRecHitRecAnalFitAlgo< C >

Template used to compute amplitude, pedestal, time jitter, chi2 of a pulse using an analytical fit

Author
A. Palma, Sh. Rahatlou Roma1

Definition at line 23 of file EcalUncalibRecHitRecAnalFitAlgo.h.

Constructor & Destructor Documentation

◆ ~EcalUncalibRecHitRecAnalFitAlgo()

template<class C>
EcalUncalibRecHitRecAnalFitAlgo< C >::~EcalUncalibRecHitRecAnalFitAlgo ( )
inlineoverride

Definition at line 43 of file EcalUncalibRecHitRecAnalFitAlgo.h.

43 {};

Member Function Documentation

◆ makeRecHit()

template<class C>
EcalUncalibratedRecHit EcalUncalibRecHitRecAnalFitAlgo< C >::makeRecHit ( const C &  dataFrame,
const double *  pedestals,
const double *  gainRatios,
const EcalWeightSet::EcalWeightMatrix **  weights,
const EcalWeightSet::EcalChi2WeightMatrix **  chi2Matrix 
)
inlineoverridevirtual

Compute parameters.

Implements EcalUncalibRecHitRecAbsAlgo< C >.

Definition at line 46 of file EcalUncalibRecHitRecAnalFitAlgo.h.

Referenced by EcalUncalibRecHitWorkerAnalFit::run().

50  {
51  double amplitude_(-1.), pedestal_(-1.), jitter_(-1.), chi2_(-1.);
52 
53  // Get time samples
54  //HepMatrix frame(C::MAXSAMPLES, 1);
55  double frame[C::MAXSAMPLES];
56  // int gainId0 = dataFrame.sample(0).gainId();
57  int gainId0 = 1;
58  int iGainSwitch = 0;
59  double maxsample(-1);
60  int imax(-1);
61  bool isSaturated = false;
62  uint32_t flag = 0;
63  for (int iSample = 0; iSample < C::MAXSAMPLES; iSample++) {
64  int gainId = dataFrame.sample(iSample).gainId();
65  if (dataFrame.isSaturated()) {
66  gainId = 3;
67  isSaturated = true;
68  }
69 
70  if (gainId != gainId0)
71  ++iGainSwitch;
72  if (!iGainSwitch)
73  frame[iSample] = double(dataFrame.sample(iSample).adc());
74  else
75  frame[iSample] =
76  double(((double)(dataFrame.sample(iSample).adc()) - pedestals[gainId - 1]) * gainRatios[gainId - 1]);
77 
78  if (frame[iSample] > maxsample) {
79  maxsample = frame[iSample];
80  imax = iSample;
81  }
82  }
83 
84  // Compute parameters
85  //std::cout << "EcalUncalibRecHitRecAnalFitAlgo::makeRecHit() not yey implemented. returning dummy rechit" << std::endl;
86 
87  // prepare TGraph for analytic fit
88  double xarray[10] = {0., 1., 2., 3., 4., 5., 6., 7., 8., 9.};
89  TGraph graph(10, xarray, frame);
90 
91  // fit functions
92  TF1 pulseShape =
93  TF1("pulseShape", "[0]*pow((x - [3])/[1],[2])*exp(-[2]*(x - [1] - [3])/[1])", imax - 1., imax + 3.);
94  TF1 pedestal = TF1("pedestal", "[0]", 0., 2.);
95 
96  //TF1 pulseShape = TF1("pulseShape",pulseShapeFunction,imax-1.,imax+3.);
97  //TF1 pedestal = TF1("pedestal",pedestalFunction,0.,2.);
98  TF1 pluseAndPed = TF1("pulseAndPed", "pedestal+pulseShape");
99 
100  //pulseShape parameters
101  // Amplitude
102  double FIT_A = (double)maxsample; //Amplitude
103  pulseShape.SetParameter(0, FIT_A);
104  pulseShape.SetParName(0, "Amplitude");
105  // T peak
106  double FIT_Tp = (double)imax; //T peak
107  pulseShape.SetParameter(1, FIT_Tp);
108  pulseShape.SetParName(1, "t_{P}");
109  // Alpha
110  double FIT_ALFA = 1.5; //Alpha
111  pulseShape.SetParameter(2, FIT_ALFA);
112  pulseShape.SetParName(2, "\\alpha");
113  // T off
114  double FIT_To = 3.; //T off
115  pulseShape.SetParameter(3, FIT_To);
116  pulseShape.SetParName(3, "t_{0}");
117 
118  // pedestal
119  pedestal.SetParameter(0, frame[0]);
120  pedestal.SetParName(0, "Pedestal");
121 
122  graph.Fit(&pulseShape, "QRM");
123  //TF1 *pulseShape2=graph.GetFunction("pulseShape");
124 
125  if (std::string(gMinuit->fCstatu.Data()) == std::string("CONVERGED ")) {
126  double amplitude_value = pulseShape.GetParameter(0);
127 
128  graph.Fit(&pedestal, "QRL");
129  //TF1 *pedestal2=graph.GetFunction("pedestal");
130  double pedestal_value = pedestal.GetParameter(0);
131 
132  if (!iGainSwitch)
133  amplitude_ = amplitude_value - pedestal_value;
134  else
135  amplitude_ = amplitude_value;
136 
137  pedestal_ = pedestal_value;
138  jitter_ = pulseShape.GetParameter(3);
139  chi2_ = 1.; // successful fit
140  if (isSaturated)
142  /*
143  std::cout << "separate fits\nA: " << amplitude_value << ", Ped: " << pedestal_value
144  << ", t0: " << jitter_ << ", tp: " << pulseShape.GetParameter(1)
145  << ", alpha: " << pulseShape.GetParameter(2)
146  << std::endl;
147  */
148  }
149 
150  return EcalUncalibratedRecHit(dataFrame.id(), amplitude_, pedestal_, jitter_ - 6, chi2_, flag);
151  }
constexpr int gainId(sample_type sample)
get the gainId (2 bits)
bool isSaturated(const Digi &digi, const int &maxADCvalue, int ifirst, int n)

◆ pedestalFunction()

template<class C>
double EcalUncalibRecHitRecAnalFitAlgo< C >::pedestalFunction ( double *  var,
double *  par 
)
inlineprivate

Definition at line 36 of file EcalUncalibRecHitRecAnalFitAlgo.h.

36  {
37  double ped = par[0];
38  return ped;
39  };

◆ pulseShapeFunction()

template<class C>
double EcalUncalibRecHitRecAnalFitAlgo< C >::pulseShapeFunction ( double *  var,
double *  par 
)
inlineprivate

Definition at line 25 of file EcalUncalibRecHitRecAnalFitAlgo.h.

25  {
26  double x = var[0];
27  double ampl = par[0];
28  double tp = par[1];
29  double alpha = par[2];
30  double t0 = par[3];
31 
32  double f = pow((x - t0) / tp, alpha) * exp(-alpha * (x - tp - t0) / tp);
33  return ampl * f;
34  };
float alpha
Definition: AMPTWrapper.h:105
double f[11][100]
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29