File indexing completed on 2024-04-06 12:31:00
0001
0002 #include "TF1.h"
0003
0004 namespace TkPulseShape {
0005
0006 Double_t fpeak(Double_t *x, Double_t *par)
0007 {
0008 if(x[0]+par[1]<0) return par[0];
0009 return par[0]+par[2]*(x[0]+par[1])*TMath::Exp(-(x[0]+par[1])/par[3]);
0010 }
0011
0012 Double_t fdeconv(Double_t *x, Double_t *par)
0013 {
0014 Double_t xm = par[4]*(x[0]-25);
0015 Double_t xp = par[4]*(x[0]+25);
0016 Double_t xz = par[4]*x[0];
0017 return 1.2131*TkPulseShape::fpeak(&xp,par)-1.4715*TkPulseShape::fpeak(&xz,par)+0.4463*TkPulseShape::fpeak(&xm,par);
0018 }
0019
0020 Double_t fpeak_convoluted(Double_t *x, Double_t *par)
0021 {
0022 TF1 f("peak_convoluted",TkPulseShape::fpeak,0,200,4);
0023 return f.Integral(x[0]-par[4]/2.,x[0]+par[4]/2.,par,1.)/(par[4]);
0024 }
0025
0026 Double_t fdeconv_convoluted(Double_t *x, Double_t *par)
0027 {
0028 Double_t xm = (x[0]-25);
0029 Double_t xp = (x[0]+25);
0030 Double_t xz = x[0];
0031 return 1.2131*TkPulseShape::fpeak_convoluted(&xp,par)-1.4715*TkPulseShape::fpeak_convoluted(&xz,par)+0.4463*TkPulseShape::fpeak_convoluted(&xm,par);
0032 }
0033
0034 TF1* GetDeconvFitter()
0035 {
0036 TF1* deconv_fitter = new TF1("deconv_fitter",TkPulseShape::fdeconv_convoluted,-50,50,5);
0037 deconv_fitter->SetParLimits(0,-10,10);
0038 deconv_fitter->SetParLimits(1,-100,0);
0039 deconv_fitter->SetParLimits(2,0,20);
0040 deconv_fitter->SetParLimits(3,5,100);
0041 deconv_fitter->SetParLimits(4,0,50);
0042 deconv_fitter->SetParameters(0.,-50,10,50,10);
0043 return deconv_fitter;
0044 }
0045
0046 TF1* GetPeakFitter()
0047 {
0048 TF1* peak_fitter = new TF1("peak_fitter",TkPulseShape::fpeak_convoluted,1,300,5);
0049 peak_fitter->SetParLimits(0,-10,10);
0050 peak_fitter->SetParLimits(1,-100,0);
0051 peak_fitter->SetParLimits(2,0,200);
0052 peak_fitter->SetParLimits(3,5,100);
0053 peak_fitter->FixParameter(4,22.5);
0054 peak_fitter->SetParameters(0.,-35,10,50,10);
0055 return peak_fitter;
0056 }
0057 }