]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TPC/AliTPCRF1D.cxx
Analysis code updated
[u/mrichter/AliRoot.git] / TPC / AliTPCRF1D.cxx
index cd3fd2e933ee797eba1e7a50e9fba596dee5f9ed..91828b17c80fbfe41906d92f2994591f7fa92811 100644 (file)
 
 //
 
-#include "TMath.h"
-#include "AliTPCRF1D.h"
-#include "TF2.h"
 #include <Riostream.h>
-#include "TCanvas.h"
-#include "TPad.h"
-#include "TStyle.h"
-#include "TH1.h"
+#include <TCanvas.h>
+#include <TClass.h>
+#include <TF2.h>
+#include <TH1.h>
+#include <TMath.h>
+#include <TPad.h>
+#include <TString.h>
+#include <TStyle.h>
+
+#include "AliTPCRF1D.h"
 
 extern TStyle * gStyle; 
 
@@ -75,6 +78,19 @@ ClassImp(AliTPCRF1D)
 
 
 AliTPCRF1D::AliTPCRF1D(Bool_t direct,Int_t np,Float_t step)
+           :TObject(),
+           fNRF(0),
+            fDSTEPM1(0.),
+            fcharge(0),
+            forigsigma(0.),
+            fpadWidth(3.5),
+            fkNorm(0.5),
+            fInteg(0.),
+            fGRF(0),
+            fSigma(0.),
+            fOffset(0.),
+            fDirect(kFALSE),
+            fPadDistance(0.)
 {
   //default constructor for response function object
   fDirect=direct;
@@ -83,33 +99,68 @@ AliTPCRF1D::AliTPCRF1D(Bool_t direct,Int_t np,Float_t step)
   fcharge = new Float_t[fNRF];
   if (step>0) fDSTEPM1=1./step;
   else fDSTEPM1 = 1./fgRFDSTEP;
-  fSigma = 0;
-  fGRF = 0;
-  fkNorm = 0.5;
-  fpadWidth = 3.5;
-  forigsigma=0.;
-  fOffset = 0.;
+  for(Int_t i=0;i<5;i++) {
+    funParam[i]=0.;
+    fType[i]=0;
+  }
+  
 }
 
 AliTPCRF1D::AliTPCRF1D(const AliTPCRF1D &prf)
+           :TObject(prf),
+           fNRF(prf.fNRF),
+            fDSTEPM1(prf.fDSTEPM1),
+            fcharge(0),
+            forigsigma(prf.forigsigma),
+            fpadWidth(prf.fpadWidth),
+            fkNorm(prf.fkNorm),
+            fInteg(prf.fInteg),
+            fGRF(new TF1(*(prf.fGRF))),
+            fSigma(prf.fSigma),
+            fOffset(prf.fOffset),
+            fDirect(prf.fDirect),
+            fPadDistance(prf.fPadDistance)
 {
   //
-  memcpy(this, &prf, sizeof(prf)); 
+  //
+  for(Int_t i=0;i<5;i++) {
+    funParam[i]=0.;
+    fType[i]=0;
+  }
   fcharge = new Float_t[fNRF];
-  memcpy(fcharge,prf.fcharge, fNRF);
-  fGRF = new TF1(*(prf.fGRF)); 
+  memcpy(fcharge,prf.fcharge, fNRF*sizeof(Float_t));
+
+  //PH Change the name (add 0 to the end)
+  TString s(fGRF->GetName());
+  s+="0";
+  fGRF->SetName(s.Data());
 }
 
 AliTPCRF1D & AliTPCRF1D::operator = (const AliTPCRF1D &prf)
 {
-  //  
-  if (fcharge) delete fcharge;
-  if (fGRF) delete fGRF;
-  memcpy(this, &prf, sizeof(prf)); 
-  fcharge = new Float_t[fNRF];
-  memcpy(fcharge,prf.fcharge, fNRF);
-  fGRF = new TF1(*(prf.fGRF));
-  return (*this);
+  if(this!=&prf) {
+    TObject::operator=(prf);
+    fNRF=prf.fNRF;
+    fDSTEPM1=prf.fDSTEPM1;
+    delete [] fcharge;
+    fcharge = new Float_t[fNRF];
+    memcpy(fcharge,prf.fcharge, fNRF*sizeof(Float_t));
+    forigsigma=prf.forigsigma;
+    fpadWidth=prf.fpadWidth;
+    fkNorm=prf.fkNorm;
+    fInteg=prf.fInteg;
+    delete fGRF;
+    fGRF=new TF1(*(prf.fGRF));
+   //PH Change the name (add 0 to the end)
+    TString s(fGRF->GetName());
+    s+="0";
+    fGRF->SetName(s.Data());
+    fSigma=prf.fSigma;
+    fOffset=prf.fOffset;
+    fDirect=prf.fDirect;
+    fPadDistance=prf.fPadDistance;
+  }
+  return *this;
 }
 
 
@@ -117,8 +168,8 @@ AliTPCRF1D & AliTPCRF1D::operator = (const AliTPCRF1D &prf)
 AliTPCRF1D::~AliTPCRF1D()
 {
   //
-  if (fcharge!=0) delete [] fcharge;
-  if (fGRF !=0 ) fGRF->Delete();
+  delete [] fcharge;
+  delete fGRF;
 }
 
 Float_t AliTPCRF1D::GetRF(Float_t xin)
@@ -126,11 +177,11 @@ Float_t AliTPCRF1D::GetRF(Float_t xin)
   //function which return response
   //for the charge in distance xin 
   //return linear aproximation of RF
-  Float_t x = TMath::Abs((xin-fOffset)*fDSTEPM1)+fNRF/2;
+  Float_t x = (xin-fOffset)*fDSTEPM1+fNRF/2;
   Int_t i1=Int_t(x);
   if (x<0) i1-=1;
   Float_t res=0;
-  if (i1+1<fNRF)
+  if (i1+1<fNRF &&i1>0)
     res = fcharge[i1]*(Float_t(i1+1)-x)+fcharge[i1+1]*(x-Float_t(i1));    
   return res;
 }
@@ -157,7 +208,8 @@ void AliTPCRF1D::SetParam( TF1 * GRF,Float_t padwidth,
    if (sigma==0) sigma= fpadWidth/TMath::Sqrt(12.);
    forigsigma=sigma;
    fDSTEPM1 = 10/TMath::Sqrt(sigma*sigma+fpadWidth*fpadWidth/12); 
-   sprintf(fType,"User");
+   //sprintf(fType,"User");
+   snprintf(fType,5,"User");
    //   Update();   
 }
   
@@ -171,13 +223,14 @@ void AliTPCRF1D::SetGauss(Float_t sigma, Float_t padWidth,
   fpadWidth = padWidth;
   fkNorm = kNorm;
   if (fGRF !=0 ) fGRF->Delete();
-  fGRF = new TF1("fun",funGauss,-5,5,1);
+  fGRF = new TF1("funGauss",funGauss,-5,5,1);
   funParam[0]=sigma;
   forigsigma=sigma;
   fGRF->SetParameters(funParam);
    fDSTEPM1 = 10./TMath::Sqrt(sigma*sigma+fpadWidth*fpadWidth/12); 
   //by default I set the step as one tenth of sigma  
-  sprintf(fType,"Gauss");
+  //sprintf(fType,"Gauss");
+   snprintf(fType,5,"Gauss");
 }
 
 void AliTPCRF1D::SetCosh(Float_t sigma, Float_t padWidth,
@@ -189,13 +242,14 @@ void AliTPCRF1D::SetCosh(Float_t sigma, Float_t padWidth,
   fpadWidth = padWidth;
   fkNorm = kNorm;
   if (fGRF !=0 ) fGRF->Delete();
-  fGRF = new TF1("fun",        funCosh, -5.,5.,2);   
+  fGRF = new TF1("funCosh",    funCosh, -5.,5.,2);   
   funParam[0]=sigma;
   fGRF->SetParameters(funParam);
   forigsigma=sigma;
   fDSTEPM1 = 10./TMath::Sqrt(sigma*sigma+fpadWidth*fpadWidth/12); 
   //by default I set the step as one tenth of sigma
-  sprintf(fType,"Cosh");
+  //sprintf(fType,"Cosh");
+  snprintf(fType,5,"Cosh");
 }
 
 void AliTPCRF1D::SetGati(Float_t K3, Float_t padDistance, Float_t padWidth,
@@ -207,16 +261,19 @@ void AliTPCRF1D::SetGati(Float_t K3, Float_t padDistance, Float_t padWidth,
   fpadWidth = padWidth;
   fkNorm = kNorm;
   if (fGRF !=0 ) fGRF->Delete();
-  fGRF = new TF1("fun",        funGati, -5.,5.,2);   
+  fGRF = new TF1("funGati",    funGati, -5.,5.,2);   
   funParam[0]=padDistance;
   funParam[1]=K3;  
   fGRF->SetParameters(funParam);
   forigsigma=padDistance;
   fDSTEPM1 = 10./TMath::Sqrt(padDistance*padDistance+fpadWidth*fpadWidth/12); 
   //by default I set the step as one tenth of sigma
-  sprintf(fType,"Gati");
+  //sprintf(fType,"Gati");
+  snprintf(fType,5,"Gati");
 }
 
+
+
 void AliTPCRF1D::DrawRF(Float_t x1,Float_t x2,Int_t N)
 { 
   //
@@ -230,8 +287,9 @@ void AliTPCRF1D::DrawRF(Float_t x1,Float_t x2,Int_t N)
   TPad * pad2 = new TPad("pad2RF","",0.05,0.05,0.95,0.45,21);
   pad2->Draw();
 
-  sprintf(s,"RF response function for %1.2f cm pad width",
-         fpadWidth);  
+  //sprintf(s,"RF response function for %1.2f cm pad width",
+  //     fpadWidth); 
+  snprintf(s,60,"RF response function for %1.2f cm pad width",fpadWidth); 
   pad1->cd();
   TH1F * hRFo = new TH1F("hRFo","Original charge distribution",N+1,x1,x2);
   pad2->cd();
@@ -309,13 +367,24 @@ void AliTPCRF1D::Streamer(TBuffer &R__b)
       AliTPCRF1D::Class()->ReadBuffer(R__b, this);
       //read functions
  
-      if (strncmp(fType,"Gauss",3)==0) {delete fGRF; fGRF = new TF1("fun",funGauss,-5.,5.,4);}
-      if (strncmp(fType,"Cosh",3)==0)  {delete fGRF; fGRF = new TF1("fun",funCosh,-5.,5.,4);}
-      if (strncmp(fType,"Gati",3)==0)  {delete fGRF; fGRF = new TF1("fun",funGati,-5.,5.,4);}  
+      if (strncmp(fType,"Gauss",3)==0) {delete fGRF; fGRF = new TF1("funGauss",funGauss,-5.,5.,4);}
+      if (strncmp(fType,"Cosh",3)==0)  {delete fGRF; fGRF = new TF1("funCosh",funCosh,-5.,5.,4);}
+      if (strncmp(fType,"Gati",3)==0)  {delete fGRF; fGRF = new TF1("funGati",funGati,-5.,5.,4);}  
       if (fGRF) fGRF->SetParameters(funParam);     
 
    } else {
       AliTPCRF1D::Class()->WriteBuffer(R__b, this);
    }
 }
+
+
+Double_t  AliTPCRF1D::Gamma4(Double_t x, Double_t p0, Double_t p1){
+  //
+  // Gamma 4 Time response function of ALTRO
+  //
+  if (x<0) return 0;
+  Double_t g1 = TMath::Exp(-4.*x/p1);
+  Double_t g2 = TMath::Power(x/p1,4);
+  return p0*g1*g2;
+}