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 // Implementation of the TPC transformation class
19 // Origin: Marian Ivanov Marian.Ivanov@cern.ch
22 // Class for tranformation of the coordinate frame
24 // local coordinate frame (sector, padrow, pad, timebine) ==>
25 // rotated global (tracking) cooridnate frame (sector, lx,ly,lz)
27 // Unisochronity - (substract time0 - pad by pad)
28 // Drift velocity - Currently common drift velocity - functionality of AliTPCParam
31 // Time of flight correction -
32 // - Depends on the vertex position
36 // AliTPCclustererMI::AddCluster
37 // AliTPCtrackerMI::Transform
39 //-------------------------------------------------------
42 cdb=AliCDBManager::Instance()
43 cdb->SetDefaultStorage("local:///u/mmager/mycalib1")
44 c=AliTPCcalibDB::Instance()
46 Double_t x[]={1.0,2.0,3.0}
49 trafo.Transform(x,i,0,1)
54 #include "AliTPCROC.h"
55 #include "AliTPCCalPad.h"
56 #include "AliTPCCalROC.h"
57 #include "AliTPCcalibDB.h"
58 #include "AliTPCParam.h"
61 #include "AliTPCExB.h"
62 #include "TGeoMatrix.h"
63 #include "AliTPCRecoParam.h"
64 #include "AliTPCCalibVdrift.h"
65 #include "AliTPCTransform.h"
67 ClassImp(AliTPCTransform)
70 AliTPCTransform::AliTPCTransform():
72 fCurrentRecoParam(0), //! current reconstruction parameters
73 fCurrentRun(0), //! current run
74 fCurrentTimeStamp(0) //! current time stamp
79 for (Int_t i=0;i<18;++i) {
80 Double_t alpha=TMath::DegToRad()*(10.+20.*(i%18));
81 fSins[i]=TMath::Sin(alpha);
82 fCoss[i]=TMath::Cos(alpha);
88 AliTPCTransform::AliTPCTransform(const AliTPCTransform& transform):
89 AliTransform(transform),
90 fCurrentRecoParam(transform.fCurrentRecoParam), //! current reconstruction parameters
91 fCurrentRun(transform.fCurrentRun), //! current run
92 fCurrentTimeStamp(transform.fCurrentTimeStamp) //! current time stamp
97 for (Int_t i=0;i<18;++i) {
98 Double_t alpha=TMath::DegToRad()*(10.+20.*(i%18));
99 fSins[i]=TMath::Sin(alpha);
100 fCoss[i]=TMath::Cos(alpha);
107 AliTPCTransform::~AliTPCTransform() {
113 void AliTPCTransform::SetPrimVertex(Double_t *vtx){
123 void AliTPCTransform::Transform(Double_t *x,Int_t *i,UInt_t /*time*/,
124 Int_t /*coordinateType*/) {
125 // input: x[0] - pad row
129 // output: x[0] - x (all in the rotated global coordinate frame)
133 // primvtx - position of the primary vertex
134 // used for the TOF correction
135 // TOF of particle calculated assuming the speed-of-light and
136 // line approximation
140 Int_t row=TMath::Nint(x[0]);
141 Int_t pad=TMath::Nint(x[1]);
143 AliTPCcalibDB* calib=AliTPCcalibDB::Instance();
145 AliTPCCalPad * time0TPC = calib->GetPadTime0();
146 AliTPCParam * param = calib->GetParameters();
148 AliFatal("Time unisochronity missing");
152 AliFatal("Parameters missing");
156 // Apply Time0 correction - Pad by pad fluctuation
158 x[2]-=time0TPC->GetCalROC(sector)->GetValue(row,pad);
160 // Tranform from pad - time coordinate system to the rotated global (tracking) system
162 Local2RotatedGlobal(sector,x);
167 //TODO: calib->GetParameters()->GetClusterMatrix(sector)->LocalToMaster(x,xx);
168 RotatedGlobal2Global(sector,x);
173 calib->GetExB()->Correct(x,xx);
175 // Time of flight correction
177 if (fCurrentRecoParam&&fCurrentRecoParam->GetUseTOFCorrection()){
178 const Int_t kNIS=param->GetNInnerSector(), kNOS=param->GetNOuterSector();
181 sign = (sector < kNIS/2) ? 1 : -1;
183 sign = ((sector-kNIS) < kNOS/2) ? 1 : -1;
187 dist+=(fPrimVtx[0]-x[0])*(fPrimVtx[0]-x[0]);
188 dist+=(fPrimVtx[1]-x[1])*(fPrimVtx[1]-x[1]);
189 dist+=(fPrimVtx[2]-x[2])*(fPrimVtx[2]-x[2]);
190 dist = TMath::Sqrt(dist);
191 // drift length correction because of TOF
192 // the drift velocity is in cm/s therefore multiplication by 0.01
193 deltaDr = (dist*(0.01*param->GetDriftV()))/TMath::C();
201 Global2RotatedGlobal(sector,xx);
203 x[0]=xx[0];x[1]=xx[1];x[2]=xx[2];
206 void AliTPCTransform::Local2RotatedGlobal(Int_t sector, Double_t *x) const {
209 // Tranform coordinate from
210 // row, pad, time to x,y,z
213 // Current implementation - common drift velocity - for full chamber
214 // TODO: use a map or parametrisation!
218 const Int_t kMax =60; // cache for 60 seconds
219 static Int_t lastStamp=-1; //cached values
220 static Double_t lastCorr = 1;
222 AliTPCcalibDB* calib=AliTPCcalibDB::Instance();
223 AliTPCParam * param = calib->GetParameters();
224 AliTPCCalibVdrift *driftCalib = AliTPCcalibDB::Instance()->GetVdrift(fCurrentRun);
225 Double_t driftCorr = 1.;
228 // caching drift correction - temp. fix
229 // Extremally slow procedure
230 if ( TMath::Abs((lastStamp)-Int_t(fCurrentTimeStamp))<kMax){
231 driftCorr = lastCorr;
233 driftCorr = 1.+(driftCalib->GetPTRelative(fCurrentTimeStamp,0)+ driftCalib->GetPTRelative(fCurrentTimeStamp,1))*0.5;
235 lastStamp=fCurrentTimeStamp;
243 AliFatal("Parameters missing");
245 Int_t row=TMath::Nint(x[0]);
246 // Int_t pad=TMath::Nint(x[1]);
248 const Int_t kNIS=param->GetNInnerSector(), kNOS=param->GetNOuterSector();
250 Double_t zwidth = param->GetZWidth()*driftCorr;
251 Double_t padWidth = 0;
252 Double_t padLength = 0;
256 maxPad = param->GetNPadsLow(row);
257 sign = (sector < kNIS/2) ? 1 : -1;
258 padLength = param->GetPadPitchLength(sector,row);
259 padWidth = param->GetPadPitchWidth(sector);
261 maxPad = param->GetNPadsUp(row);
262 sign = ((sector-kNIS) < kNOS/2) ? 1 : -1;
263 padLength = param->GetPadPitchLength(sector,row);
264 padWidth = param->GetPadPitchWidth(sector);
268 x[0] = param->GetPadRowRadii(sector,row); // padrow X position - ideal
272 x[1]=(x[1]-0.5*maxPad)*padWidth;
273 // pads are mirrorred on C-side
283 x[2]*= zwidth; // tranform time bin to the distance to the ROC
284 x[2]-= 3.*param->GetZSigma() + param->GetNTBinsL1()*zwidth;
285 // subtract the time offsets
286 x[2] = sign*( param->GetZLength(sector) - x[2]);
289 void AliTPCTransform::RotatedGlobal2Global(Int_t sector,Double_t *x) const {
291 // transform possition rotated global to the global
294 GetCosAndSin(sector,cos,sin);
296 x[0]= cos*tmp-sin*x[1];
297 x[1]=+sin*tmp+cos*x[1];
300 void AliTPCTransform::Global2RotatedGlobal(Int_t sector,Double_t *x) const {
302 // tranform possition Global2RotatedGlobal
305 GetCosAndSin(sector,cos,sin);
307 x[0]= cos*tmp+sin*x[1];
308 x[1]= -sin*tmp+cos*x[1];
311 void AliTPCTransform::GetCosAndSin(Int_t sector,Double_t &cos,
312 Double_t &sin) const {
313 cos=fCoss[sector%18];
314 sin=fSins[sector%18];