24 #include <Riostream.h>
35 #include "AliTPCRF1D.h"
37 extern TStyle * gStyle;
39 Int_t AliTPCRF1D::fgNRF=100;
40 Float_t AliTPCRF1D::fgRFDSTEP=0.01;
42 static Double_t funGauss(Double_t *x, Double_t * par)
46 return TMath::Exp(-(x[0]*x[0])/(2*par[0]*par[0]));
49 static Double_t funCosh(Double_t *x, Double_t * par)
53 return 1/TMath::CosH(3.14159*x[0]/(2*par[0]));
56 static Double_t funGati(Double_t *x, Double_t * par)
61 Float_t k3R=TMath::Sqrt(k3);
62 Float_t k2=(TMath::Pi()/2)*(1-k3R/2.);
63 Float_t k1=k2*k3R/(4*TMath::ATan(k3R));
64 Float_t l=x[0]/par[0];
65 Float_t tan2=TMath::TanH(k2*l);
67 Float_t res = k1*(1-tan2)/(1+k3*tan2);
98 fcharge =
new Float_t[fNRF];
99 if (step>0) fDSTEPM1=1./step;
100 else fDSTEPM1 = 1./fgRFDSTEP;
101 for(Int_t i=0;i<5;i++) {
111 fDSTEPM1(prf.fDSTEPM1),
113 forigsigma(prf.forigsigma),
114 fpadWidth(prf.fpadWidth),
117 fGRF(new TF1(*(prf.fGRF))),
119 fOffset(prf.fOffset),
120 fDirect(prf.fDirect),
121 fPadDistance(prf.fPadDistance)
125 for(Int_t i=0;i<5;i++) {
129 fcharge =
new Float_t[fNRF];
130 memcpy(fcharge,prf.fcharge, fNRF*
sizeof(Float_t));
133 TString s(fGRF->GetName());
135 fGRF->SetName(s.Data());
141 TObject::operator=(prf);
143 fDSTEPM1=prf.fDSTEPM1;
145 fcharge =
new Float_t[fNRF];
146 memcpy(fcharge,prf.fcharge, fNRF*
sizeof(Float_t));
147 forigsigma=prf.forigsigma;
148 fpadWidth=prf.fpadWidth;
152 fGRF=
new TF1(*(prf.fGRF));
154 TString s(fGRF->GetName());
156 fGRF->SetName(s.Data());
160 fPadDistance=prf.fPadDistance;
167 AliTPCRF1D::~AliTPCRF1D()
174 Float_t AliTPCRF1D::GetRF(Float_t xin)
179 Float_t x = (xin-fOffset)*fDSTEPM1+fNRF/2;
183 if (i1+1<fNRF &&i1>0)
184 res = fcharge[i1]*(Float_t(i1+1)-x)+fcharge[i1+1]*(x-Float_t(i1));
188 Float_t AliTPCRF1D::GetGRF(Float_t xin)
193 return fkNorm*fGRF->Eval(xin)/fInteg;
199 void AliTPCRF1D::SetParam( TF1 * GRF,Float_t padwidth,
200 Float_t kNorm, Float_t sigma)
204 fpadWidth = padwidth;
207 if (sigma==0) sigma= fpadWidth/TMath::Sqrt(12.);
209 fDSTEPM1 = 10/TMath::Sqrt(sigma*sigma+fpadWidth*fpadWidth/12);
211 snprintf(fType,5,
"User");
216 void AliTPCRF1D::SetGauss(Float_t sigma, Float_t padWidth,
222 fpadWidth = padWidth;
224 if (fGRF !=0 ) fGRF->Delete();
225 fGRF =
new TF1(
"funGauss",funGauss,-5,5,1);
228 fGRF->SetParameters(funParam);
229 fDSTEPM1 = 10./TMath::Sqrt(sigma*sigma+fpadWidth*fpadWidth/12);
232 snprintf(fType,5,
"Gauss");
235 void AliTPCRF1D::SetCosh(Float_t sigma, Float_t padWidth,
241 fpadWidth = padWidth;
243 if (fGRF !=0 ) fGRF->Delete();
244 fGRF =
new TF1(
"funCosh", funCosh, -5.,5.,2);
246 fGRF->SetParameters(funParam);
248 fDSTEPM1 = 10./TMath::Sqrt(sigma*sigma+fpadWidth*fpadWidth/12);
251 snprintf(fType,5,
"Cosh");
254 void AliTPCRF1D::SetGati(Float_t K3, Float_t padDistance, Float_t padWidth,
260 fpadWidth = padWidth;
262 if (fGRF !=0 ) fGRF->Delete();
263 fGRF =
new TF1(
"funGati", funGati, -5.,5.,2);
264 funParam[0]=padDistance;
266 fGRF->SetParameters(funParam);
267 forigsigma=padDistance;
268 fDSTEPM1 = 10./TMath::Sqrt(padDistance*padDistance+fpadWidth*fpadWidth/12);
271 snprintf(fType,5,
"Gati");
276 void AliTPCRF1D::DrawRF(Float_t x1,Float_t x2,Int_t N)
282 TCanvas * c1 =
new TCanvas(
"canRF",
"Pad response function",700,900);
284 TPad * pad1 =
new TPad(
"pad1RF",
"",0.05,0.55,0.95,0.95,21);
286 TPad * pad2 =
new TPad(
"pad2RF",
"",0.05,0.05,0.95,0.45,21);
291 snprintf(s,60,
"RF response function for %1.2f cm pad width",fpadWidth);
293 TH1F * hRFo =
new TH1F(
"hRFo",
"Original charge distribution",N+1,x1,x2);
295 gStyle->SetOptFit(1);
296 gStyle->SetOptStat(0);
297 TH1F * hRFc =
new TH1F(
"hRFc",s,N+1,x1,x2);
302 for (Float_t i = 0;i<N+1;i++)
304 x+=(x2-x1)/Float_t(N);
323 for (Int_t i =0; i<fNRF;i++) fcharge[i] = 0;
324 if ( fGRF == 0 )
return;
326 #if ROOT_VERSION_CODE < ROOT_VERSION(5,99,0)
327 fInteg = fGRF->Integral(-5*forigsigma,5*forigsigma,funParam,0.00001);
329 TArrayD savParam(fGRF->GetNpar(), fGRF->GetParameters());
330 fGRF->SetParameters(funParam);
331 fInteg = fGRF->Integral(-5*forigsigma,5*forigsigma,0.00001);
333 if ( fInteg == 0 ) fInteg = 1;
334 if (fDirect==kFALSE){
336 for (Int_t i =0; i<fNRF;i++)
338 Float_t x = (Float_t)(i-fNRF/2)/fDSTEPM1;
339 Float_t x1=TMath::Max(x-fpadWidth/2,-5*forigsigma);
340 Float_t x2=TMath::Min(x+fpadWidth/2,5*forigsigma);
341 #if ROOT_VERSION_CODE < ROOT_VERSION(5,99,0)
342 fcharge[i] = fkNorm*fGRF->Integral(x1,x2,funParam,0.0001)/fInteg;
344 fcharge[i] = fkNorm*fGRF->Integral(x1,x2,0.0001)/fInteg;
349 for (Int_t i =0; i<fNRF;i++)
351 Float_t x = (Float_t)(i-fNRF/2)/fDSTEPM1;
352 fcharge[i] = fkNorm*fGRF->Eval(x);
358 for (Float_t x =-fNRF/fDSTEPM1; x<fNRF/fDSTEPM1;x+=1/fDSTEPM1)
360 Float_t weight = GetRF(x+fOffset);
367 fSigma = TMath::Sqrt(fSigma/sum-mean*mean);
370 #if ROOT_VERSION_CODE >= ROOT_VERSION(5,99,0)
371 fGRF->SetParameters(savParam.GetArray());
375 void AliTPCRF1D::Streamer(TBuffer &R__b)
378 if (R__b.IsReading()) {
379 AliTPCRF1D::Class()->ReadBuffer(R__b,
this);
382 if (strncmp(fType,
"Gauss",3)==0) {
delete fGRF; fGRF =
new TF1(
"funGauss",funGauss,-5.,5.,4);}
383 if (strncmp(fType,
"Cosh",3)==0) {
delete fGRF; fGRF =
new TF1(
"funCosh",funCosh,-5.,5.,4);}
384 if (strncmp(fType,
"Gati",3)==0) {
delete fGRF; fGRF =
new TF1(
"funGati",funGati,-5.,5.,4);}
385 if (fGRF) fGRF->SetParameters(funParam);
388 AliTPCRF1D::Class()->WriteBuffer(R__b,
this);
393 Double_t AliTPCRF1D::Gamma4(Double_t x, Double_t p0, Double_t p1){
400 Double_t g1 = TMath::Exp(-4.*x/p1);
401 Double_t g2 = TMath::Power(x/p1,4);
Declaration of class AliTPCRF1D.
void Update()
it's on user !!!!