Adding more commnens
[u/mrichter/AliRoot.git] / TPC / AliTPCTransform.cxx
CommitLineData
c1bdda91 1#include "AliTPCTransform.h"
2#include "AliTPCROC.h"
3#include "AliTPCCalROC.h"
4#include "AliTPCcalibDB.h"
5#include "AliTPCParam.h"
6#include "TMath.h"
418bbcaf 7#include "AliTPCExB.h"
c1bdda91 8
9/* To test it:
10 cdb=AliCDBManager::Instance()
11 cdb->SetDefaultStorage("local:///u/mmager/mycalib1")
12 c=AliTPCcalibDB::Instance()
13 c->SetRun(0)
14 Double_t x[]={1.0,2.0,3.0}
15 Int_t i[]={4}
16 AliTPCTransform trafo
17 trafo.Transform(x,i,0,1)
18 */
19
20AliTPCTransform::AliTPCTransform() {
21 // Speed it up a bit!
22 for (Int_t i=0;i<18;++i) {
23 Double_t alpha=TMath::DegToRad()*(10.+20.*(i%18));
24 fSins[i]=TMath::Sin(alpha);
25 fCoss[i]=TMath::Cos(alpha);
26 }
27}
28
29AliTPCTransform::~AliTPCTransform() {
30}
31
32void AliTPCTransform::Transform(Double_t *x,Int_t *i,UInt_t time,
33 Int_t coordinateType) {
34 // input: x[0] - pad
35 // x[1] - pad row
36 // x[2] - time in us
37 // i[0] - sector
38 // output: x[0] - x (all in the rotated global coordinate frame)
39 // x[1] - y
40 // x[2] - z
41 Int_t row=TMath::Nint(x[1]);
42 Int_t pad=TMath::Nint(x[0]);
43 Int_t sector=i[0];
44 AliTPCcalibDB* const calib=AliTPCcalibDB::Instance();
45 Double_t xx[3];
46
47 //ugly: calib->SetRun(time);
48
49 // Time0
50 //TODO: x[2]-=calib->GetPadTime0()->GetCalROC(sector)->GetValue(row,pad);
51
52 // Drift Velocity
53 // (cm/us)
54 // TODO: use a map or parametrisation!
55 x[2]*=2.66;
56
57 Pad2RotatedGlobal(pad,row,x);
58
59 // Alignment
60 //TODO: calib->GetParameters()->GetClusterMatrix(sector)->LocalToMaster(x,xx);
61
62 RotatedGlobal2Global(sector,x);
63
64 // ExB
65 calib->GetExB()->Correct(x,xx);
66
67 Global2RotatedGlobal(sector,xx);
68
69 x[0]=xx[0];x[1]=xx[1];x[2]=xx[2];
70}
71
72inline void AliTPCTransform::Pad2RotatedGlobal(Int_t pad,Int_t row,Double_t *x)
73 const {
74 Float_t tmp[3];
75 AliTPCROC::Instance()->GetPositionLocal(0,row,pad,tmp);
76 x[0]=tmp[0];
77 x[1]=tmp[1];
78}
79
80//TODO rotation in the right direction?
81inline void AliTPCTransform::RotatedGlobal2Global(Int_t sector,Double_t *x)
82 const {
83 Double_t cos,sin;
84 GetCosAndSin(sector,cos,sin);
85 Double_t tmp=x[0];
86 x[0]= cos*tmp+sin*x[1];
87 x[1]=-sin*tmp+cos*x[1];
88}
89
90inline void AliTPCTransform::Global2RotatedGlobal(Int_t sector,Double_t *x)
91 const {
92 Double_t cos,sin;
93 GetCosAndSin(sector,cos,sin);
94 Double_t tmp=x[0];
95 x[0]= cos*tmp-sin*x[1];
96 x[1]= sin*tmp+cos*x[1];
97}
98
99inline void AliTPCTransform::GetCosAndSin(Int_t sector,Double_t &cos,
100 Double_t &sin) const {
101 cos=fCoss[sector%18];
102 sin=fSins[sector%18];
103}
104
105ClassImp(AliTPCTransform)
106