1 #ifndef RecoLocalCalo_EcalRecAlgos_EcalUncalibRecHitRecAnalFitAlgo_HH 2 #define RecoLocalCalo_EcalRecAlgos_EcalUncalibRecHitRecAnalFitAlgo_HH 11 #include "CLHEP/Matrix/Matrix.h" 12 #include "CLHEP/Matrix/SymMatrix.h" 29 double alpha = par[2];
47 const double* pedestals,
48 const double* gainRatios,
51 double amplitude_(-1.), pedestal_(-1.), jitter_(-1.), chi2_(-1.);
55 double frame[C::MAXSAMPLES];
63 for (
int iSample = 0; iSample < C::MAXSAMPLES; iSample++) {
64 int gainId = dataFrame.sample(iSample).gainId();
65 if (dataFrame.isSaturated()) {
73 frame[iSample] = double(dataFrame.sample(iSample).adc());
76 double(((
double)(dataFrame.sample(iSample).adc()) - pedestals[
gainId - 1]) * gainRatios[
gainId - 1]);
78 if (
frame[iSample] > maxsample) {
79 maxsample =
frame[iSample];
88 double xarray[10] = {0., 1., 2., 3., 4., 5., 6., 7., 8., 9.};
89 TGraph graph(10, xarray,
frame);
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.);
98 TF1 pluseAndPed = TF1(
"pulseAndPed",
"pedestal+pulseShape");
102 double FIT_A = (double)maxsample;
103 pulseShape.SetParameter(0, FIT_A);
104 pulseShape.SetParName(0,
"Amplitude");
106 double FIT_Tp = (double)imax;
107 pulseShape.SetParameter(1, FIT_Tp);
108 pulseShape.SetParName(1,
"t_{P}");
110 double FIT_ALFA = 1.5;
111 pulseShape.SetParameter(2, FIT_ALFA);
112 pulseShape.SetParName(2,
"\\alpha");
115 pulseShape.SetParameter(3, FIT_To);
116 pulseShape.SetParName(3,
"t_{0}");
122 graph.Fit(&pulseShape,
"QRM");
126 double amplitude_value = pulseShape.GetParameter(0);
130 double pedestal_value =
pedestal.GetParameter(0);
133 amplitude_ = amplitude_value - pedestal_value;
135 amplitude_ = amplitude_value;
137 pedestal_ = pedestal_value;
138 jitter_ = pulseShape.GetParameter(3);
double pedestalFunction(double *var, double *par)
math::Matrix< 10, 10 >::type EcalChi2WeightMatrix
math::Matrix< 3, 10 >::type EcalWeightMatrix
constexpr int gainId(sample_type sample)
get the gainId (2 bits)
EcalUncalibratedRecHit makeRecHit(const C &dataFrame, const double *pedestals, const double *gainRatios, const EcalWeightSet::EcalWeightMatrix **weights, const EcalWeightSet::EcalChi2WeightMatrix **chi2Matrix) override
Compute parameters.
bool isSaturated(const Digi &digi, const int &maxADCvalue, int ifirst, int n)
double pulseShapeFunction(double *var, double *par)
Power< A, B >::type pow(const A &a, const B &b)