1 #ifndef RecoLocalCalo_EcalRecAlgos_EcalUncalibRecHitRecAnalFitAlgo_HH
2 #define RecoLocalCalo_EcalRecAlgos_EcalUncalibRecHitRecAnalFitAlgo_HH
11 #include "CLHEP/Matrix/Matrix.h"
12 #include "CLHEP/Matrix/SymMatrix.h"
32 double alpha = par[2];
35 double f =
pow( (x-t0)/tp , alpha ) *
exp( -alpha*(x-tp-t0)/tp );
51 const double* gainRatios,
55 double amplitude_(-1.), pedestal_(-1.), jitter_(-1.), chi2_(-1.);
59 double frame[C::MAXSAMPLES];
67 for(
int iSample = 0; iSample < C::MAXSAMPLES; iSample++) {
68 int gainId = dataFrame.sample(iSample).gainId();
69 if ( dataFrame.isSaturated() != -1 )
75 if (gainId != gainId0) iGainSwitch++ ;
77 frame[iSample] = double(dataFrame.sample(iSample).adc());
79 frame[iSample] = double(((
double)(dataFrame.sample(iSample).adc()) - pedestals[gainId-1]) * gainRatios[gainId-1]);
81 if( frame[iSample]>maxsample ) {
82 maxsample= frame[iSample];
91 double xarray[10]={0.,1.,2.,3.,4.,5.,6.,7.,8.,9.};
92 TGraph
graph(10,xarray,frame);
95 TF1 pulseShape = TF1(
"pulseShape",
96 "[0]*pow((x - [3])/[1],[2])*exp(-[2]*(x - [1] - [3])/[1])",
98 TF1
pedestal = TF1(
"pedestal",
"[0]",0.,2.);
102 TF1 pluseAndPed = TF1(
"pulseAndPed",
"pedestal+pulseShape");
106 double FIT_A=(double)maxsample;
107 pulseShape.SetParameter(0,FIT_A);
108 pulseShape.SetParName(0,
"Amplitude");
110 double FIT_Tp=(double)imax;
111 pulseShape.SetParameter(1,FIT_Tp);
112 pulseShape.SetParName(1,
"t_{P}");
115 pulseShape.SetParameter(2,FIT_ALFA);
116 pulseShape.SetParName(2,
"\\alpha");
119 pulseShape.SetParameter(3,FIT_To);
120 pulseShape.SetParName(3,
"t_{0}");
123 pedestal.SetParameter(0,frame[0]);
124 pedestal.SetParName(0,
"Pedestal");
128 graph.Fit(&pulseShape,
"QRM");
133 double amplitude_value=pulseShape.GetParameter(0);
135 graph.Fit(&pedestal,
"QRL");
137 double pedestal_value=pedestal.GetParameter(0);
140 amplitude_ = amplitude_value - pedestal_value;
142 amplitude_ = amplitude_value;
144 pedestal_ = pedestal_value;
145 jitter_ = pulseShape.GetParameter(3);
double pedestalFunction(double *var, double *par)
int gainId(sample_type sample)
get the gainId (2 bits)
virtual EcalUncalibratedRecHit makeRecHit(const C &dataFrame, const double *pedestals, const double *gainRatios, const EcalWeightSet::EcalWeightMatrix **weights, const EcalWeightSet::EcalChi2WeightMatrix **chi2Matrix)
Compute parameters.
math::Matrix< 10, 10 >::type EcalChi2WeightMatrix
bool isSaturated(const Digi &digi, const int &maxADCvalue, int ifirst, int n)
math::Matrix< 3, 10 >::type EcalWeightMatrix
double pulseShapeFunction(double *var, double *par)
Power< A, B >::type pow(const A &a, const B &b)