1 //-----------------------------------------------------------------------------
5 // Origin: Marian Ivanov, Uni. of Bratislava, ivanov@fmph.uniba.sk
7 // Declaration of class AliTPCRF1D
9 //-----------------------------------------------------------------------------
11 #include "AliTPCRF1D.h"
19 extern TStyle * gStyle;
21 static Double_t funGauss(Double_t *x, Double_t * par)
23 return TMath::Exp(-(x[0]*x[0])/(2*par[0]*par[0]));
26 static Double_t funCosh(Double_t *x, Double_t * par)
28 return 1/TMath::CosH(3.14159*x[0]/(2*par[0]));
31 static Double_t funGati(Double_t *x, Double_t * par)
33 //par[1] = is equal to k3
34 //par[0] is equal to pad wire distance
36 Float_t K3R=TMath::Sqrt(K3);
37 Float_t K2=(TMath::Pi()/2)*(1-K3R/2.);
38 Float_t K1=K2*K3R/(4*TMath::ATan(K3R));
39 Float_t l=x[0]/par[0];
40 Float_t tan2=TMath::TanH(K2*l);
42 Float_t res = K1*(1-tan2)/(1+K3*tan2);
49 ///////////////////////////////////////////////////////////////////////////
50 ///////////////////////////////////////////////////////////////////////////
51 ///////////////////////////////////////////////////////////////////////////
52 ///////////////////////////////////////////////////////////////////////////
58 AliTPCRF1D::AliTPCRF1D(Bool_t direct,Int_t np,Float_t step)
62 fcharge = new Float_t[fNRF];
74 AliTPCRF1D::~AliTPCRF1D()
76 if (fcharge!=0) delete fcharge;
77 if (fGRF !=0 ) fGRF->Delete();
80 Float_t AliTPCRF1D::GetRF(Float_t xin)
83 //return linear aproximation of RF
84 Float_t x = TMath::Abs((xin-fOffset)*fDSTEPM1)+fNRF/2;
89 res = fcharge[i1]*(Float_t(i1+1)-x)+fcharge[i1+1]*(x-Float_t(i1));
93 Float_t AliTPCRF1D::GetGRF(Float_t xin)
96 return fkNorm*fGRF->Eval(xin)/fInteg;
102 void AliTPCRF1D::SetParam( TF1 * GRF,Float_t padwidth,
103 Float_t kNorm, Float_t sigma)
105 fpadWidth = padwidth;
108 if (sigma==0) sigma= fpadWidth/TMath::Sqrt(12.);
110 fDSTEPM1 = 10/TMath::Sqrt(sigma*sigma+fpadWidth*fpadWidth/12);
111 sprintf(fType,"User");
116 void AliTPCRF1D::SetGauss(Float_t sigma, Float_t padWidth,
120 fpadWidth = padWidth;
122 if (fGRF !=0 ) fGRF->Delete();
123 fGRF = new TF1("fun",funGauss,-5,5,2);
126 fGRF->SetParameters(funParam);
127 fDSTEPM1 = 10./TMath::Sqrt(sigma*sigma+fpadWidth*fpadWidth/12);
128 //by default I set the step as one tenth of sigma
130 sprintf(fType,"Gauss");
133 void AliTPCRF1D::SetCosh(Float_t sigma, Float_t padWidth,
137 fpadWidth = padWidth;
139 if (fGRF !=0 ) fGRF->Delete();
140 fGRF = new TF1("fun", funCosh, -5.,5.,2);
142 fGRF->SetParameters(funParam);
144 fDSTEPM1 = 10./TMath::Sqrt(sigma*sigma+fpadWidth*fpadWidth/12);
145 //by default I set the step as one tenth of sigma
147 sprintf(fType,"Cosh");
150 void AliTPCRF1D::SetGati(Float_t K3, Float_t padDistance, Float_t padWidth,
154 fpadWidth = padWidth;
156 if (fGRF !=0 ) fGRF->Delete();
157 fGRF = new TF1("fun", funGati, -5.,5.,2);
158 funParam[0]=padDistance;
160 fGRF->SetParameters(funParam);
161 forigsigma=padDistance;
162 fDSTEPM1 = 10./TMath::Sqrt(padDistance*padDistance+fpadWidth*fpadWidth/12);
163 //by default I set the step as one tenth of sigma
165 sprintf(fType,"Gati");
168 void AliTPCRF1D::Draw(Float_t x1,Float_t x2,Int_t N)
171 TCanvas * c1 = new TCanvas("canRF","Pad response function",700,900);
173 TPad * pad1 = new TPad("pad1RF","",0.05,0.55,0.95,0.95,21);
175 TPad * pad2 = new TPad("pad2RF","",0.05,0.05,0.95,0.45,21);
178 sprintf(s,"RF response function for %1.2f cm pad width",
181 TH1F * hRFo = new TH1F("hRFo","Original charge distribution",N+1,x1,x2);
183 gStyle->SetOptFit(1);
184 gStyle->SetOptStat(0);
185 TH1F * hRFc = new TH1F("hRFc",s,N+1,x1,x2);
190 for (Float_t i = 0;i<N+1;i++)
192 x+=(x2-x1)/Float_t(N);
204 void AliTPCRF1D::Update()
207 for (Int_t i =0; i<fNRF;i++) fcharge[i] = 0;
208 if ( fGRF == 0 ) return;
209 fInteg = fGRF->Integral(-5*forigsigma,5*forigsigma,funParam,0.00001);
210 if ( fInteg == 0 ) fInteg = 1;
211 if (fDirect==kFALSE){
212 //integrate charge over pad for different distance of pad
213 for (Int_t i =0; i<fNRF;i++)
214 { //x in cm fpadWidth in cm
215 Float_t x = (Float_t)(i-fNRF/2)/fDSTEPM1;
216 Float_t x1=TMath::Max(x-fpadWidth/2,-5*forigsigma);
217 Float_t x2=TMath::Min(x+fpadWidth/2,5*forigsigma);
219 fkNorm*fGRF->Integral(x1,x2,funParam,0.0001)/fInteg;
223 for (Int_t i =0; i<fNRF;i++)
224 { //x in cm fpadWidth in cm
225 Float_t x = (Float_t)(i-fNRF/2)/fDSTEPM1;
226 fcharge[i] = fkNorm*fGRF->Eval(x);
232 for (Float_t x =-fNRF/fDSTEPM1; x<fNRF/fDSTEPM1;x+=1/fDSTEPM1)
233 { //x in cm fpadWidth in cm
234 Float_t weight = GetRF(x+fOffset);
241 fSigma = TMath::Sqrt(fSigma/sum-mean*mean);
246 void AliTPCRF1D::Streamer(TBuffer &R__b)
248 // Stream an object of class AliTPC.
250 if (R__b.IsReading()) {
251 Version_t R__v = R__b.ReadVersion(); if (R__v) { }
252 TObject::Streamer(R__b);
253 //read pad parameters
255 //read charge parameters
264 R__b >> fPadDistance;
272 if (strncmp(fType,"User",3)==0){
277 if (strncmp(fType,"Gauss",3)==0)
278 fGRF = new TF1("fun",funGauss,-5.,5.,4);
279 if (strncmp(fType,"Cosh",3)==0)
280 fGRF = new TF1("fun",funCosh,-5.,5.,4);
281 if (strncmp(fType,"Gati",3)==0)
282 fGRF = new TF1("fun",funGati,-5.,5.,4);
285 R__b.ReadFastArray(fcharge,fNRF);
286 R__b.ReadFastArray(funParam,5);
287 if (fGRF!=0) fGRF->SetParameters(funParam);
290 R__b.WriteVersion(AliTPCRF1D::IsA());
291 TObject::Streamer(R__b);
294 //write charge parameters
303 R__b << fPadDistance;
306 //write interpolation parameters
307 if (strncmp(fType,"User",3)==0) R__b <<fGRF;
310 R__b.WriteFastArray(fcharge,fNRF);
311 R__b.WriteFastArray(funParam,5);