1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
16 ////////////////////////////////////////////////////////////////////////////
17 // AliTPCGGVoltError class //
18 ////////////////////////////////////////////////////////////////////////////
22 #include "TGeoGlobalMagField.h"
23 #include "AliTPCcalibDB.h"
24 #include "AliTPCParam.h"
27 #include "AliTPCGGVoltError.h"
30 AliTPCGGVoltError::AliTPCGGVoltError()
31 : AliTPCCorrection("GGVoltError","GatingGrid (GG) Voltage Error"),
33 fDeltaVGGA(0.),fDeltaVGGC(0.),
37 // default constructor
41 AliTPCGGVoltError::~AliTPCGGVoltError() {
47 void AliTPCGGVoltError::Init() {
51 AliMagF* magF= (AliMagF*)TGeoGlobalMagField::Instance()->GetField();
52 if (!magF) AliError("Magneticd field - not initialized");
53 Double_t bzField = magF->SolenoidField()/10.; //field in T
54 AliTPCParam *param= AliTPCcalibDB::Instance()->GetParameters();
55 if (!param) AliError("Parameters - not initialized");
56 Double_t vdrift = param->GetDriftV()/1000000.; // [cm/us] // From dataBase: to be updated: per second (ideally)
57 Double_t ezField = 400; // [V/cm] // to be updated: never (hopefully)
58 Double_t wt = -10.0 * (bzField*10) * vdrift / ezField ;
60 SetOmegaTauT1T2(wt,fT1,fT2);
61 InitGGVoltErrorDistortion();
62 //SetDeltaVGGA(0.0);// ideally from the database
63 //SetDeltaVGGC(0.0);// ideally from the database
66 void AliTPCGGVoltError::Update(const TTimeStamp &/*timeStamp*/) {
70 AliMagF* magF= (AliMagF*)TGeoGlobalMagField::Instance()->GetField();
71 if (!magF) AliError("Magneticd field - not initialized");
72 Double_t bzField = magF->SolenoidField()/10.; //field in T
73 AliTPCParam *param= AliTPCcalibDB::Instance()->GetParameters();
74 if (!param) AliError("Parameters - not initialized");
75 Double_t vdrift = param->GetDriftV()/1000000.; // [cm/us] // From dataBase: to be updated: per second (ideally)
76 Double_t ezField = 400; // [V/cm] // to be updated: never (hopefully)
77 Double_t wt = -10.0 * (bzField*10) * vdrift / ezField ;
79 SetOmegaTauT1T2(wt,fT1,fT2);
80 // InitGGVoltErrorDistortion(); // not necessary in here since the Voltage should not change!
85 void AliTPCGGVoltError::GetCorrection(const Float_t x[],const Short_t roc,Float_t dx[]) {
88 // Gated Grid Voltage Error
90 // Calculates the effect of having an incorrect voltage on the A or C end plate Gated Grids.
92 // Electrostatic Equations from StarNote SN0253 by Howard Wieman.
95 if (!fInitLookUp) AliError("Lookup table was not initialized! You should do InitGGVoltErrorDistortion() ...");
97 Int_t order = 1 ; // FIXME: hardcoded? Linear interpolation = 1, Quadratic = 2
99 Double_t intEr, intEphi ;
105 r = TMath::Sqrt( x[0]*x[0] + x[1]*x[1] );
106 phi = TMath::ATan2(x[1],x[0]);
107 if ( phi < 0 ) phi += TMath::TwoPi(); // Table uses phi from 0 to 2*Pi
110 if ( (roc%36) < 18 ) {
112 deltaVGG = fDeltaVGGA; // (TPC End A)
114 sign = -1; // (TPC End C)
115 deltaVGG = fDeltaVGGC;
118 if ( sign==1 && z < fgkZOffSet ) z = fgkZOffSet; // Protect against discontinuity at CE
119 if ( sign==-1 && z > -fgkZOffSet ) z = -fgkZOffSet; // Protect against discontinuity at CE
121 Interpolate2DEdistortion( order, r, z, fGGVoltErrorER, intEr );
122 intEphi = 0.0; // Efield is symmetric in phi
124 // Calculate distorted position
126 phi = phi + deltaVGG*( fC0*intEphi - fC1*intEr ) / r;
127 r = r + deltaVGG*( fC0*intEr + fC1*intEphi );
130 // Calculate correction in cartesian coordinates
131 dx[0] = r * TMath::Cos(phi) - x[0];
132 dx[1] = r * TMath::Sin(phi) - x[1];
133 dx[2] = 0.; // z distortion not implemented (1st order distortions) - see e.g. AliTPCBoundaryVoltError-class
140 Float_t AliTPCGGVoltError::GetIntErOverEz(const Float_t x[],const Short_t roc) {
142 // This function is purely for calibration purposes
143 // Calculates the integral (int Er/Ez dz) for the setted GG voltage offset
146 if (!fInitLookUp) AliError("Lookup table was not initialized! You should do InitGGVoltErrorDistortion() ...");
148 Int_t order = 1 ; // FIXME: so far hardcoded? Linear interpolation = 1, Quadratic = 2
156 r = TMath::Sqrt( x[0]*x[0] + x[1]*x[1] );
157 phi = TMath::ATan2(x[1],x[0]);
158 if ( phi < 0 ) phi += TMath::TwoPi(); // Table uses phi from 0 to 2*Pi
161 if ( (roc%36) < 18 ) {
163 deltaVGG = fDeltaVGGA; // (TPC End A)
165 sign = -1; // (TPC End C)
166 deltaVGG = fDeltaVGGC;
169 if ( sign==1 && z < fgkZOffSet ) z = fgkZOffSet; // Protect against discontinuity at CE
170 if ( sign==-1 && z > -fgkZOffSet ) z = -fgkZOffSet; // Protect against discontinuity at CE
172 Interpolate2DEdistortion(order, r, z, fGGVoltErrorER, intEr );
174 return (intEr*deltaVGG);
178 void AliTPCGGVoltError::InitGGVoltErrorDistortion() {
180 // Initialization of the Lookup table which contains the solutions of the GG Error problem
185 for ( Int_t i = 0 ; i < kNZ ; ++i ) {
187 for ( Int_t j = 0 ; j < kNR ; ++j ) {
189 fGGVoltErrorER[i][j] = 0.0 ;
190 Double_t intz = 0.0 ;
191 for ( Int_t n = 1 ; n < nterms ; ++n ) {
192 Double_t k = n * TMath::Pi() / fgkTPCZ0 ;
193 Double_t ein = 0 ; // Error potential on the IFC
194 Double_t eout = 0 ; // Error potential on the OFC
196 ein = -2.0 / ( k * (fgkCathodeV - fgkGG) ) ;
197 eout = -2.0 / ( k * (fgkCathodeV - fgkGG) ) ;
199 if ( z == 0 ) continue ;
201 ein = -2.0 / ( k * (fgkCathodeV - fgkGG) ) ;
202 eout = -2.0 / ( k * (fgkCathodeV - fgkGG) ) ;
204 Double_t an = ein * TMath::BesselK0( k*fgkOFCRadius ) - eout * TMath::BesselK0( k*fgkIFCRadius ) ;
205 Double_t bn = eout * TMath::BesselI0( k*fgkIFCRadius ) - ein * TMath::BesselI0( k*fgkOFCRadius ) ;
207 an * TMath::BesselI1( k*r ) - bn * TMath::BesselK1( k*r ) ;
208 Double_t denominator =
209 TMath::BesselK0( k*fgkOFCRadius ) * TMath::BesselI0( k*fgkIFCRadius ) -
210 TMath::BesselK0( k*fgkIFCRadius ) * TMath::BesselI0( k*fgkOFCRadius ) ;
211 Double_t zterm = TMath::Cos( k*(fgkTPCZ0-TMath::Abs(z)) ) - 1 ;
212 intz += zterm * numerator / denominator ;
213 // Assume series converges, break if small terms
214 if ( n>10 && TMath::Abs(intz)*1.e-10 > TMath::Abs(numerator/denominator) ) break;
216 fGGVoltErrorER[i][j] = (Double_t) intz ;
226 void AliTPCGGVoltError::Print(const Option_t* option) const {
228 // Print function to check the settings (e.g. voltage offsets)
229 // option=="a" prints the C0 and C1 coefficents for calibration purposes
232 TString opt = option; opt.ToLower();
233 printf("%s\n",GetTitle());
234 printf(" - GG Voltage offset: A-side: %3.1f V, C-side: %3.1f V \n",fDeltaVGGA,fDeltaVGGC);
235 if (opt.Contains("a")) { // Print all details
236 printf(" - T1: %1.4f, T2: %1.4f \n",fT1,fT2);
237 printf(" - C1: %1.4f, C0: %1.4f \n",fC1,fC0);
240 if (!fInitLookUp) AliError("Lookup table was not initialized! You should do InitGGVoltErrorDistortion() ...");