]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TPC/AliTPCGGVoltError.cxx
Corrections for QA
[u/mrichter/AliRoot.git] / TPC / AliTPCGGVoltError.cxx
CommitLineData
0116859c 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15
16////////////////////////////////////////////////////////////////////////////
17// //
18// AliTPCGGVoltError class //
19// The class calculates the electric field and space point distortions //
20// due a Gating Grid (GG) Error voltage. It uses the exact calculation //
21// technique based on bessel functions. (original code from STAR) //
22// The class allows "effective Omega Tau" corrections. //
23// //
24// date: 27/04/2010 //
25// Authors: Jim Thomas, Stefan Rossegger, Magnus Mager //
26// //
27// Example usage: //
28// AliTPCGGVoltError GGerror; //
29// GGerror.SetOmegaTauT1T2(0.32,1.,1.); // values ideally from OCDB //
30// GGerror.SetDeltaVGGA(50.); // voltage offset A-side //
31// GGerror.SetDeltaVGGC(50.); // voltage offset C-side //
32// GGerror.InitGGVoltErrorDistortion(); // initialization of the look up //
33// // plot dRPhi distortions ... //
34// GGerror.CreateHistoDRPhiinZR(1.,100,100)->Draw("surf2"); //
35////////////////////////////////////////////////////////////////////////////
36
37
38
39#include "AliTPCGGVoltError.h"
40#include <TMath.h>
41
42AliTPCGGVoltError::AliTPCGGVoltError()
43 : AliTPCCorrection("GGVoltError","GatingGrid (GG) Voltage Error"),
44 fC0(0.),fC1(0.),
45 fDeltaVGGA(0.),fDeltaVGGC(0.)
46{
47 //
48 // default constructor
49 //
50}
51
52AliTPCGGVoltError::~AliTPCGGVoltError() {
53 //
54 // default destructor
55 //
56}
57
58void AliTPCGGVoltError::GetCorrection(const Float_t x[],const Short_t roc,Float_t dx[]) {
59
60 //
61 // Gated Grid Voltage Error
62 //
63 // Calculates the effect of having an incorrect voltage on the A or C end plate Gated Grids.
64 //
65 // Electrostatic Equations from StarNote SN0253 by Howard Wieman.
66 //
67
68 Int_t order = 1 ; // FIXME: hardcoded? Linear interpolation = 1, Quadratic = 2
69
70 Double_t intEr, intEphi ;
71 Double_t r, phi, z ;
72 Int_t sign ;
73
74 Double_t deltaVGG;
75
76 r = TMath::Sqrt( x[0]*x[0] + x[1]*x[1] );
77 phi = TMath::ATan2(x[1],x[0]);
78 if ( phi < 0 ) phi += TMath::TwoPi(); // Table uses phi from 0 to 2*Pi
79 z = x[2] ;
80
81 if ( (roc%36) < 18 ) {
82 sign = 1;
83 deltaVGG = fDeltaVGGA; // (TPC End A)
84 } else {
85 sign = -1; // (TPC End C)
86 deltaVGG = fDeltaVGGC;
87 }
88
89 if ( sign==1 && z < fgkZOffSet ) z = fgkZOffSet; // Protect against discontinuity at CE
90 if ( sign==-1 && z > -fgkZOffSet ) z = -fgkZOffSet; // Protect against discontinuity at CE
91
92 Interpolate2DEdistortion( order, r, z, fGGVoltErrorER, intEr );
93 intEphi = 0.0; // Efield is symmetric in phi
94
95 // Calculate distorted position
96 if ( r > 0.0 ) {
97 phi = phi + deltaVGG*( fC0*intEphi - fC1*intEr ) / r;
98 r = r + deltaVGG*( fC0*intEr + fC1*intEphi );
99 }
100
101 // Calculate correction in cartesian coordinates
102 dx[0] = r * TMath::Cos(phi) - x[0];
103 dx[1] = r * TMath::Sin(phi) - x[1];
104 dx[2] = 0.; // z distortion not implemented (1st order distortions)
105
106}
107
108
109Float_t AliTPCGGVoltError::GetIntErOverEz(const Float_t x[],const Short_t roc) {
110 //
111 // This function is purely for calibration purposes
112 // Calculates the integral (int Er/Ez dz) for the setted GG voltage offset
113 //
114
115 Int_t order = 1 ; // FIXME: so far hardcoded? Linear interpolation = 1, Quadratic = 2
116
117 Double_t intEr;
118 Double_t r, phi, z ;
119 Int_t sign ;
120
121 Double_t deltaVGG;
122
123 r = TMath::Sqrt( x[0]*x[0] + x[1]*x[1] );
124 phi = TMath::ATan2(x[1],x[0]);
125 if ( phi < 0 ) phi += TMath::TwoPi(); // Table uses phi from 0 to 2*Pi
126 z = x[2] ;
127
128 if ( (roc%36) < 18 ) {
129 sign = 1;
130 deltaVGG = fDeltaVGGA; // (TPC End A)
131 } else {
132 sign = -1; // (TPC End C)
133 deltaVGG = fDeltaVGGC;
134 }
135
136 if ( sign==1 && z < fgkZOffSet ) z = fgkZOffSet; // Protect against discontinuity at CE
137 if ( sign==-1 && z > -fgkZOffSet ) z = -fgkZOffSet; // Protect against discontinuity at CE
138
139 Interpolate2DEdistortion(order, r, z, fGGVoltErrorER, intEr );
140
141 return (intEr*deltaVGG);
142
143}
144
145void AliTPCGGVoltError::InitGGVoltErrorDistortion() {
146 //
147 // Initialization of the Lookup table which contains the solutions of the GG Error problem
148 //
149
150 Double_t r,z;
151 Int_t nterms = 100 ;
152 for ( Int_t i = 0 ; i < kNZ ; ++i ) {
153 z = fgkZList[i] ;
154 for ( Int_t j = 0 ; j < kNR ; ++j ) {
155 r = fgkRList[j] ;
156 fGGVoltErrorER[i][j] = 0.0 ;
157 Double_t intz = 0.0 ;
158 for ( Int_t n = 1 ; n < nterms ; ++n ) {
159 Double_t k = n * TMath::Pi() / fgkTPC_Z0 ;
160 Double_t ein = 0 ; // Error potential on the IFC
161 Double_t eout = 0 ; // Error potential on the OFC
162 if ( z < 0 ) {
163 ein = -2.0 / ( k * (fgkCathodeV - fgkGG) ) ;
164 eout = -2.0 / ( k * (fgkCathodeV - fgkGG) ) ;
165 }
166 if ( z == 0 ) continue ;
167 if ( z > 0 ) {
168 ein = -2.0 / ( k * (fgkCathodeV - fgkGG) ) ;
169 eout = -2.0 / ( k * (fgkCathodeV - fgkGG) ) ;
170 }
171 Double_t an = ein * TMath::BesselK0( k*fgkOFCRadius ) - eout * TMath::BesselK0( k*fgkIFCRadius ) ;
172 Double_t bn = eout * TMath::BesselI0( k*fgkIFCRadius ) - ein * TMath::BesselI0( k*fgkOFCRadius ) ;
173 Double_t numerator =
174 an * TMath::BesselI1( k*r ) - bn * TMath::BesselK1( k*r ) ;
175 Double_t denominator =
176 TMath::BesselK0( k*fgkOFCRadius ) * TMath::BesselI0( k*fgkIFCRadius ) -
177 TMath::BesselK0( k*fgkIFCRadius ) * TMath::BesselI0( k*fgkOFCRadius ) ;
178 Double_t zterm = TMath::Cos( k*(fgkTPC_Z0-TMath::Abs(z)) ) - 1 ;
179 intz += zterm * numerator / denominator ;
180 // Assume series converges, break if small terms
b9f518ba 181 if ( n>10 && TMath::Abs(intz)*1.e-10 > TMath::Abs(numerator/denominator) ) break;
0116859c 182 }
183 fGGVoltErrorER[i][j] = (Double_t) intz ;
184
185 }
186 }
187}
188
189
190
191void AliTPCGGVoltError::Print(Option_t* option) const {
192 //
193 // Print function to check the settings (e.g. voltage offsets)
194 // option=="a" prints the C0 and C1 coefficents for calibration purposes
195 //
196
197 TString opt = option; opt.ToLower();
198 printf("%s\n",GetTitle());
199 printf(" - GG Voltage offset: A-side: %3.1f V, C-side: %3.1f V \n",fDeltaVGGA,fDeltaVGGC);
200 if (opt.Contains("a")) { // Print all details
201 printf(" - C1: %1.4f, C0: %1.4f \n",fC1,fC0);
202 }
203
204
205
206}