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