]>
Commit | Line | Data |
---|---|---|
022ee144 | 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 | // Implementation of the TPC transformation class | |
18 | // | |
19 | // Origin: Marian Ivanov Marian.Ivanov@cern.ch | |
20 | // Magnus Mager | |
21 | // | |
22 | // Class for tranformation of the coordinate frame | |
66954e3f | 23 | // Transformation |
022ee144 | 24 | // local coordinate frame (sector, padrow, pad, timebine) ==> |
25 | // rotated global (tracking) cooridnate frame (sector, lx,ly,lz) | |
26 | // | |
27 | // Unisochronity - (substract time0 - pad by pad) | |
28 | // Drift velocity - Currently common drift velocity - functionality of AliTPCParam | |
29 | // ExB effect - | |
30 | // | |
31 | // Usage: | |
32 | // AliTPCclustererMI::AddCluster | |
33 | // AliTPCtrackerMI::Transform | |
34 | // | |
35 | //------------------------------------------------------- | |
c1bdda91 | 36 | |
37 | /* To test it: | |
38 | cdb=AliCDBManager::Instance() | |
39 | cdb->SetDefaultStorage("local:///u/mmager/mycalib1") | |
40 | c=AliTPCcalibDB::Instance() | |
41 | c->SetRun(0) | |
42 | Double_t x[]={1.0,2.0,3.0} | |
43 | Int_t i[]={4} | |
44 | AliTPCTransform trafo | |
45 | trafo.Transform(x,i,0,1) | |
46 | */ | |
47 | ||
022ee144 | 48 | /* $Id$ */ |
49 | ||
50 | #include "AliTPCROC.h" | |
51 | #include "AliTPCCalPad.h" | |
52 | #include "AliTPCCalROC.h" | |
53 | #include "AliTPCcalibDB.h" | |
54 | #include "AliTPCParam.h" | |
55 | #include "TMath.h" | |
56 | #include "AliLog.h" | |
57 | #include "AliTPCExB.h" | |
66954e3f | 58 | #include "TGeoMatrix.h" |
022ee144 | 59 | #include "AliTPCTransform.h" |
60 | ||
66954e3f | 61 | ClassImp(AliTPCTransform) |
022ee144 | 62 | |
63 | ||
c1bdda91 | 64 | AliTPCTransform::AliTPCTransform() { |
24db6af7 | 65 | // |
c1bdda91 | 66 | // Speed it up a bit! |
24db6af7 | 67 | // |
c1bdda91 | 68 | for (Int_t i=0;i<18;++i) { |
69 | Double_t alpha=TMath::DegToRad()*(10.+20.*(i%18)); | |
70 | fSins[i]=TMath::Sin(alpha); | |
71 | fCoss[i]=TMath::Cos(alpha); | |
72 | } | |
73 | } | |
74 | ||
75 | AliTPCTransform::~AliTPCTransform() { | |
24db6af7 | 76 | // |
77 | // Destructor | |
78 | // | |
c1bdda91 | 79 | } |
80 | ||
24db6af7 | 81 | void AliTPCTransform::Transform(Double_t *x,Int_t *i,UInt_t /*time*/, |
82 | Int_t /*coordinateType*/) { | |
83 | // input: x[0] - pad row | |
84 | // x[1] - pad | |
c1bdda91 | 85 | // x[2] - time in us |
86 | // i[0] - sector | |
87 | // output: x[0] - x (all in the rotated global coordinate frame) | |
88 | // x[1] - y | |
89 | // x[2] - z | |
24db6af7 | 90 | Int_t row=TMath::Nint(x[0]); |
91 | Int_t pad=TMath::Nint(x[1]); | |
c1bdda91 | 92 | Int_t sector=i[0]; |
66954e3f | 93 | AliTPCcalibDB* calib=AliTPCcalibDB::Instance(); |
24db6af7 | 94 | // |
95 | AliTPCCalPad * time0TPC = calib->GetPadTime0(); | |
96 | AliTPCParam * param = calib->GetParameters(); | |
97 | if (!time0TPC){ | |
98 | AliFatal("Time unisochronity missing"); | |
99 | } | |
c1bdda91 | 100 | |
24db6af7 | 101 | if (!param){ |
102 | AliFatal("Parameters missing"); | |
103 | } | |
c1bdda91 | 104 | |
24db6af7 | 105 | Double_t xx[3]; |
106 | // Apply Time0 correction - Pad by pad fluctuation | |
107 | // | |
108 | x[2]-=time0TPC->GetCalROC(sector)->GetValue(row,pad); | |
109 | // | |
110 | // Tranform from pad - time coordinate system to the rotated global (tracking) system | |
111 | // | |
112 | Local2RotatedGlobal(sector,x); | |
113 | // | |
114 | // | |
115 | // | |
c1bdda91 | 116 | // Alignment |
117 | //TODO: calib->GetParameters()->GetClusterMatrix(sector)->LocalToMaster(x,xx); | |
c1bdda91 | 118 | RotatedGlobal2Global(sector,x); |
24db6af7 | 119 | // |
120 | // | |
121 | // ExB correction | |
122 | // | |
c1bdda91 | 123 | calib->GetExB()->Correct(x,xx); |
124 | ||
125 | Global2RotatedGlobal(sector,xx); | |
126 | ||
127 | x[0]=xx[0];x[1]=xx[1];x[2]=xx[2]; | |
128 | } | |
129 | ||
24db6af7 | 130 | void AliTPCTransform::Local2RotatedGlobal(Int_t sector, Double_t *x) const { |
131 | // | |
132 | // | |
022ee144 | 133 | // Tranform coordinate from |
134 | // row, pad, time to x,y,z | |
24db6af7 | 135 | // |
022ee144 | 136 | // Drift Velocity |
137 | // Current implementation - common drift velocity - for full chamber | |
24db6af7 | 138 | // TODO: use a map or parametrisation! |
139 | // | |
140 | // | |
141 | // | |
66954e3f | 142 | AliTPCcalibDB* calib=AliTPCcalibDB::Instance(); |
24db6af7 | 143 | AliTPCParam * param = calib->GetParameters(); |
144 | if (!param){ | |
145 | AliFatal("Parameters missing"); | |
146 | } | |
147 | Int_t row=TMath::Nint(x[0]); | |
148 | Int_t pad=TMath::Nint(x[1]); | |
149 | // | |
150 | const Int_t kNIS=param->GetNInnerSector(), kNOS=param->GetNOuterSector(); | |
151 | Double_t sign = 1.; | |
152 | Double_t zwidth = param->GetZWidth(); | |
153 | Double_t padWidth = 0; | |
154 | Double_t padLength = 0; | |
155 | Double_t maxPad = 0; | |
156 | // | |
157 | if (sector < kNIS) { | |
158 | maxPad = param->GetNPadsLow(row); | |
159 | sign = (sector < kNIS/2) ? 1 : -1; | |
160 | padLength = param->GetPadPitchLength(sector,row); | |
161 | padWidth = param->GetPadPitchWidth(sector); | |
162 | } else { | |
163 | maxPad = param->GetNPadsUp(row); | |
164 | sign = ((sector-kNIS) < kNOS/2) ? 1 : -1; | |
165 | padLength = param->GetPadPitchLength(sector,row); | |
166 | padWidth = param->GetPadPitchWidth(sector); | |
167 | } | |
168 | // | |
169 | // X coordinate | |
022ee144 | 170 | x[0] = param->GetPadRowRadii(sector,row); // padrow X position - ideal |
24db6af7 | 171 | // |
172 | // Y coordinate | |
173 | // | |
174 | x[1]=(x[1]-0.5*maxPad)*padWidth; | |
24db6af7 | 175 | // |
176 | // Z coordinate | |
177 | // | |
178 | x[2]*= zwidth; // tranform time bin to the distance to the ROC | |
179 | x[2]-= 3.*param->GetZSigma() + param->GetNTBinsL1()*zwidth; | |
180 | // subtract the time offsets | |
181 | x[2] = sign*( param->GetZLength(sector) - x[2]); | |
c1bdda91 | 182 | } |
183 | ||
24db6af7 | 184 | inline void AliTPCTransform::RotatedGlobal2Global(Int_t sector,Double_t *x) const { |
185 | // | |
186 | // transform possition rotated global to the global | |
187 | // | |
c1bdda91 | 188 | Double_t cos,sin; |
189 | GetCosAndSin(sector,cos,sin); | |
190 | Double_t tmp=x[0]; | |
191 | x[0]= cos*tmp+sin*x[1]; | |
192 | x[1]=-sin*tmp+cos*x[1]; | |
193 | } | |
194 | ||
24db6af7 | 195 | inline void AliTPCTransform::Global2RotatedGlobal(Int_t sector,Double_t *x) const { |
196 | // | |
197 | // tranform possition Global2RotatedGlobal | |
198 | // | |
c1bdda91 | 199 | Double_t cos,sin; |
200 | GetCosAndSin(sector,cos,sin); | |
201 | Double_t tmp=x[0]; | |
202 | x[0]= cos*tmp-sin*x[1]; | |
203 | x[1]= sin*tmp+cos*x[1]; | |
204 | } | |
205 | ||
206 | inline void AliTPCTransform::GetCosAndSin(Int_t sector,Double_t &cos, | |
207 | Double_t &sin) const { | |
208 | cos=fCoss[sector%18]; | |
209 | sin=fSins[sector%18]; | |
210 | } | |
211 | ||
c1bdda91 | 212 |