]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TPC/AliTPCRF1D.cxx
Check on curvature not position
[u/mrichter/AliRoot.git] / TPC / AliTPCRF1D.cxx
index c80e6464b13c60e3e71d2c5b764cfb5e53bcb604..dd1c4c249eecd291af063fe94325caabcd647967 100644 (file)
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-/*
-$Log$
-Revision 1.4.8.2  2000/04/10 08:53:09  kowal2
+/* $Id$ */
 
-Updates by M. Ivanov
-
-
-Revision 1.4  1999/09/29 09:24:34  fca
-Introduction of the Copyright and cvs Log
-
-*/
 
 //-----------------------------------------------------------------------------
-//  $Header$
+//
 //
 //
 //  Origin:   Marian Ivanov, Uni. of Bratislava, ivanov@fmph.uniba.sk
@@ -35,16 +26,22 @@ Introduction of the Copyright and cvs Log
 //
 //-----------------------------------------------------------------------------
 
+//
+
 #include "TMath.h"
 #include "AliTPCRF1D.h"
 #include "TF2.h"
-#include <iostream.h>
+#include <Riostream.h>
 #include "TCanvas.h"
 #include "TPad.h"
 #include "TStyle.h"
 #include "TH1.h"
+#include <TString.h>
+
+extern TStyle * gStyle; 
 
-extern TStyle * gStyle;
+Int_t   AliTPCRF1D::fgNRF=100;  //default  number of interpolation points
+Float_t AliTPCRF1D::fgRFDSTEP=0.01; //default step in cm
 
 static Double_t funGauss(Double_t *x, Double_t * par)
 {
@@ -61,14 +58,14 @@ static Double_t funCosh(Double_t *x, Double_t * par)
 static Double_t funGati(Double_t *x, Double_t * par)
 {
   //Gati function  -needde by the generic function object 
-  Float_t K3=par[1];
-  Float_t K3R=TMath::Sqrt(K3);
-  Float_t K2=(TMath::Pi()/2)*(1-K3R/2.);
-  Float_t K1=K2*K3R/(4*TMath::ATan(K3R));
+  Float_t k3=par[1];
+  Float_t k3R=TMath::Sqrt(k3);
+  Float_t k2=(TMath::Pi()/2)*(1-k3R/2.);
+  Float_t k1=k2*k3R/(4*TMath::ATan(k3R));
   Float_t l=x[0]/par[0];
-  Float_t tan2=TMath::TanH(K2*l);
+  Float_t tan2=TMath::TanH(k2*l);
   tan2*=tan2;
-  Float_t res = K1*(1-tan2)/(1+K3*tan2);  
+  Float_t res = k1*(1-tan2)/(1+k3*tan2);  
   return res;  
 }    
 
@@ -82,9 +79,11 @@ AliTPCRF1D::AliTPCRF1D(Bool_t direct,Int_t np,Float_t step)
 {
   //default constructor for response function object
   fDirect=direct;
-  fNRF = np;
+  if (np!=0)fNRF = np;
+  else (fNRF=fgNRF);
   fcharge = new Float_t[fNRF];
-  fDSTEPM1=1./step;
+  if (step>0) fDSTEPM1=1./step;
+  else fDSTEPM1 = 1./fgRFDSTEP;
   fSigma = 0;
   fGRF = 0;
   fkNorm = 0.5;
@@ -93,9 +92,41 @@ AliTPCRF1D::AliTPCRF1D(Bool_t direct,Int_t np,Float_t step)
   fOffset = 0.;
 }
 
+AliTPCRF1D::AliTPCRF1D(const AliTPCRF1D &prf):TObject(prf)
+{
+  
+  //
+  memcpy(this, &prf, sizeof(prf)); 
+  fcharge = new Float_t[fNRF];
+  memcpy(fcharge,prf.fcharge, fNRF);
+  fGRF = new TF1(*(prf.fGRF));
+  //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));
+   //PH Change the name (add 0 to the end)
+  TString s(fGRF->GetName());
+  s+="0";
+  fGRF->SetName(s.Data());
+  return (*this);
+}
+
+
 
 AliTPCRF1D::~AliTPCRF1D()
 {
+  //
   if (fcharge!=0) delete [] fcharge;
   if (fGRF !=0 ) fGRF->Delete();
 }
@@ -150,7 +181,7 @@ 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,2);
+  fGRF = new TF1("funGauss",funGauss,-5,5,1);
   funParam[0]=sigma;
   forigsigma=sigma;
   fGRF->SetParameters(funParam);
@@ -168,7 +199,7 @@ 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;
@@ -186,7 +217,7 @@ 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);
@@ -196,7 +227,7 @@ void AliTPCRF1D::SetGati(Float_t K3, Float_t padDistance, Float_t padWidth,
   sprintf(fType,"Gati");
 }
 
-void AliTPCRF1D::Draw(Float_t x1,Float_t x2,Int_t N)
+void AliTPCRF1D::DrawRF(Float_t x1,Float_t x2,Int_t N)
 { 
   //
   //Draw prf in selected region <x1,x2> with nuber of diviision = n
@@ -284,69 +315,17 @@ void AliTPCRF1D::Update()
 void AliTPCRF1D::Streamer(TBuffer &R__b)
 {
    // Stream an object of class AliTPCRF1D.
-
    if (R__b.IsReading()) {
-      Version_t R__v = R__b.ReadVersion(); if (R__v) { }
-      TObject::Streamer(R__b);     
-      //read pad parameters
-      R__b >> fpadWidth;
-      //read charge parameters
-      R__b >> fType[0];
-      R__b >> fType[1];
-      R__b >> fType[2];
-      R__b >> fType[3];
-      R__b >> fType[4];
-      R__b >> forigsigma;
-      R__b >> fkNorm;
-      R__b >> fK3X;
-      R__b >> fPadDistance; 
-      R__b >> fInteg;
-      R__b >> fOffset;
+      AliTPCRF1D::Class()->ReadBuffer(R__b, this);
       //read functions
-      if (fGRF!=0) { 
-       delete [] fGRF;  
-       fGRF=0;
-      }
-      if (strncmp(fType,"User",3)==0){
-       fGRF= new TF1;
-       R__b>>fGRF;   
-      }
  
-      if (strncmp(fType,"Gauss",3)==0) 
-       fGRF = new TF1("fun",funGauss,-5.,5.,4);
-      if (strncmp(fType,"Cosh",3)==0) 
-       fGRF = new TF1("fun",funCosh,-5.,5.,4);
-      if (strncmp(fType,"Gati",3)==0) 
-       fGRF = new TF1("fun",funGati,-5.,5.,4);   
-      R__b >>fDSTEPM1;  
-      R__b >>fNRF;
-      R__b.ReadFastArray(fcharge,fNRF); 
-      R__b.ReadFastArray(funParam,5); 
-      if (fGRF!=0) fGRF->SetParameters(funParam);     
+      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 {
-      R__b.WriteVersion(AliTPCRF1D::IsA());
-      TObject::Streamer(R__b);   
-      //write pad width
-      R__b << fpadWidth;
-      //write charge parameters
-      R__b << fType[0];
-      R__b << fType[1];
-      R__b << fType[2];
-      R__b << fType[3];
-      R__b << fType[4];
-      R__b << forigsigma;
-      R__b << fkNorm;
-      R__b << fK3X;
-      R__b << fPadDistance;
-      R__b << fInteg;
-      R__b << fOffset;
-      //write interpolation parameters
-      if (strncmp(fType,"User",3)==0) R__b <<fGRF;   
-      R__b <<fDSTEPM1;
-      R__b <<fNRF;    
-      R__b.WriteFastArray(fcharge,fNRF); 
-      R__b.WriteFastArray(funParam,5);              
+      AliTPCRF1D::Class()->WriteBuffer(R__b, this);
    }
 }