1 #ifndef RecoLocalCalo_EcalRecAlgos_EcalUncalibRecHitRecAnalFitAlgo_HH 2 #define RecoLocalCalo_EcalRecAlgos_EcalUncalibRecHitRecAnalFitAlgo_HH 11 #include "CLHEP/Matrix/Matrix.h" 12 #include "CLHEP/Matrix/SymMatrix.h" 21 #include "TMinuitMinimizer.h" 30 double alpha = par[2];
46 TMinuitMinimizer::UseStaticMinuit(
false);
54 const double* pedestals,
55 const double* gainRatios,
58 double amplitude_(-1.), pedestal_(-1.), jitter_(-1.), chi2_(-1.);
62 double frame[C::MAXSAMPLES];
70 for (
int iSample = 0; iSample < C::MAXSAMPLES; iSample++) {
71 int gainId = dataFrame.sample(iSample).gainId();
72 if (dataFrame.isSaturated()) {
80 frame[iSample] = double(dataFrame.sample(iSample).adc());
83 double(((
double)(dataFrame.sample(iSample).adc()) - pedestals[
gainId - 1]) * gainRatios[
gainId - 1]);
85 if (
frame[iSample] > maxsample) {
86 maxsample =
frame[iSample];
95 double xarray[10] = {0., 1., 2., 3., 4., 5., 6., 7., 8., 9.};
96 TGraph graph(10, xarray,
frame);
99 TF1 pulseShape = TF1(
"pulseShape",
100 "[0]*pow((x - [3])/[1],[2])*exp(-[2]*(x - [1] - [3])/[1])",
103 TF1::EAddToList::kNo);
104 TF1
pedestal = TF1(
"pedestal",
"[0]", 0., 2., TF1::EAddToList::kNo);
108 double FIT_A = (double)maxsample;
109 pulseShape.SetParameter(0, FIT_A);
110 pulseShape.SetParName(0,
"Amplitude");
112 double FIT_Tp = (double)imax;
113 pulseShape.SetParameter(1, FIT_Tp);
114 pulseShape.SetParName(1,
"t_{P}");
116 double FIT_ALFA = 1.5;
117 pulseShape.SetParameter(2, FIT_ALFA);
118 pulseShape.SetParName(2,
"\\alpha");
121 pulseShape.SetParameter(3, FIT_To);
122 pulseShape.SetParName(3,
"t_{0}");
128 int result = graph.Fit(&pulseShape,
"QRMN SERIAL");
131 double amplitude_value = pulseShape.GetParameter(0);
133 graph.Fit(&
pedestal,
"QRLN SERIAL");
134 double pedestal_value =
pedestal.GetParameter(0);
137 amplitude_ = amplitude_value - pedestal_value;
139 amplitude_ = amplitude_value;
141 pedestal_ = pedestal_value;
142 jitter_ = pulseShape.GetParameter(3);
EcalUncalibRecHitRecAnalFitAlgo()
double pedestalFunction(double *var, double *par)
math::Matrix< 10, 10 >::type EcalChi2WeightMatrix
math::Matrix< 3, 10 >::type EcalWeightMatrix
~EcalUncalibRecHitRecAnalFitAlgo() override
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)