]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TPC/AliTPCGGVoltError.cxx
Update to speed up the calculation (and the accuracy) to calculate space charge effec...
[u/mrichter/AliRoot.git] / TPC / AliTPCGGVoltError.cxx
index edf22649bc1bb7316169703462f88444ebc72824..dee07bf848ccd532495653777a13e4a198c2e89c 100644 (file)
@@ -47,7 +47,8 @@
 AliTPCGGVoltError::AliTPCGGVoltError()
   : AliTPCCorrection("GGVoltError","GatingGrid (GG) Voltage Error"),
     fC0(0.),fC1(0.),
-    fDeltaVGGA(0.),fDeltaVGGC(0.)
+    fDeltaVGGA(0.),fDeltaVGGC(0.),
+    fInitLookUp(kFALSE)
 {
   //
   // default constructor
@@ -62,7 +63,7 @@ AliTPCGGVoltError::~AliTPCGGVoltError() {
 
 void AliTPCGGVoltError::Init() {
   //
-  //
+  // Init function
   //
   AliMagF* magF= (AliMagF*)TGeoGlobalMagField::Instance()->GetField();
   if (!magF) AliError("Magneticd field - not initialized");
@@ -93,7 +94,7 @@ void AliTPCGGVoltError::Update(const TTimeStamp &/*timeStamp*/) {
   Double_t wt = -10.0 * (bzField*10) * vdrift / ezField ; 
 
   SetOmegaTauT1T2(wt,fT1,fT2);
-  InitGGVoltErrorDistortion();
+  //  InitGGVoltErrorDistortion(); // not necessary in here since the Voltage should not change!
 }
 
 
@@ -108,6 +109,8 @@ void AliTPCGGVoltError::GetCorrection(const Float_t x[],const Short_t roc,Float_
   // Electrostatic Equations from StarNote SN0253 by Howard Wieman.
   //
   
+  if (!fInitLookUp) AliError("Lookup table was not initialized! You should do InitGGVoltErrorDistortion() ...");
+  
   Int_t   order     = 1 ;               // FIXME: hardcoded? Linear interpolation = 1, Quadratic = 2         
  
   Double_t intEr, intEphi ;
@@ -144,7 +147,9 @@ void AliTPCGGVoltError::GetCorrection(const Float_t x[],const Short_t roc,Float_
   // Calculate correction in cartesian coordinates
   dx[0] = r * TMath::Cos(phi) - x[0];
   dx[1] = r * TMath::Sin(phi) - x[1]; 
-  dx[2] = 0.; // z distortion not implemented (1st order distortions)
+  dx[2] = 0.; // z distortion not implemented (1st order distortions) - see e.g. AliTPCBoundaryVoltError-class
+
+
 
 }
 
@@ -154,7 +159,9 @@ Float_t AliTPCGGVoltError::GetIntErOverEz(const Float_t x[],const Short_t roc) {
   // This function is purely for calibration purposes
   // Calculates the integral (int Er/Ez dz) for the setted GG voltage offset 
   // 
-  
+
+  if (!fInitLookUp) AliError("Lookup table was not initialized! You should do InitGGVoltErrorDistortion() ...");
+
   Int_t   order     = 1 ;     // FIXME: so far hardcoded? Linear interpolation = 1, Quadratic = 2         
   
   Double_t intEr;
@@ -199,7 +206,7 @@ void AliTPCGGVoltError::InitGGVoltErrorDistortion() {
       fGGVoltErrorER[i][j] = 0.0 ;         
       Double_t intz = 0.0 ;
       for ( Int_t n = 1 ; n < nterms ; ++n ) {
-       Double_t k    =  n * TMath::Pi() / fgkTPC_Z0 ;
+       Double_t k    =  n * TMath::Pi() / fgkTPCZ0 ;
        Double_t ein  =  0 ;                    // Error potential on the IFC
        Double_t eout =  0 ;                    // Error potential on the OFC
        if ( z < 0 ) {
@@ -218,7 +225,7 @@ void AliTPCGGVoltError::InitGGVoltErrorDistortion() {
        Double_t denominator =
          TMath::BesselK0( k*fgkOFCRadius ) * TMath::BesselI0( k*fgkIFCRadius ) -
          TMath::BesselK0( k*fgkIFCRadius ) * TMath::BesselI0( k*fgkOFCRadius ) ;
-       Double_t zterm = TMath::Cos( k*(fgkTPC_Z0-TMath::Abs(z)) ) - 1 ;
+       Double_t zterm = TMath::Cos( k*(fgkTPCZ0-TMath::Abs(z)) ) - 1 ;
        intz += zterm * numerator / denominator ;
        // Assume series converges, break if small terms
        if ( n>10 && TMath::Abs(intz)*1.e-10 > TMath::Abs(numerator/denominator) ) break;   
@@ -227,11 +234,13 @@ void AliTPCGGVoltError::InitGGVoltErrorDistortion() {
 
     }
   }
+  
+  fInitLookUp = kTRUE;
 }
 
 
 
-void AliTPCGGVoltError::Print(Option_t* option) const {
+void AliTPCGGVoltError::Print(const Option_t* option) const {
   //
   // Print function to check the settings (e.g. voltage offsets)
   // option=="a" prints the C0 and C1 coefficents for calibration purposes
@@ -245,6 +254,7 @@ void AliTPCGGVoltError::Print(Option_t* option) const {
     printf(" - C1: %1.4f, C0: %1.4f \n",fC1,fC0);
   }    
 
+  if (!fInitLookUp) AliError("Lookup table was not initialized! You should do InitGGVoltErrorDistortion() ...");
 
   
 }