2 #include "AliTPCCalPad.h"
3 #include "AliTPCCalROC.h"
4 #include "AliTPCcalibDB.h"
5 #include "AliTPCParam.h"
9 #include "AliTPCTransform.h"
12 cdb=AliCDBManager::Instance()
13 cdb->SetDefaultStorage("local:///u/mmager/mycalib1")
14 c=AliTPCcalibDB::Instance()
16 Double_t x[]={1.0,2.0,3.0}
19 trafo.Transform(x,i,0,1)
22 AliTPCTransform::AliTPCTransform() {
26 for (Int_t i=0;i<18;++i) {
27 Double_t alpha=TMath::DegToRad()*(10.+20.*(i%18));
28 fSins[i]=TMath::Sin(alpha);
29 fCoss[i]=TMath::Cos(alpha);
33 AliTPCTransform::~AliTPCTransform() {
39 void AliTPCTransform::Transform(Double_t *x,Int_t *i,UInt_t /*time*/,
40 Int_t /*coordinateType*/) {
41 // input: x[0] - pad row
45 // output: x[0] - x (all in the rotated global coordinate frame)
48 Int_t row=TMath::Nint(x[0]);
49 Int_t pad=TMath::Nint(x[1]);
51 AliTPCcalibDB* const calib=AliTPCcalibDB::Instance();
53 AliTPCCalPad * time0TPC = calib->GetPadTime0();
54 AliTPCParam * param = calib->GetParameters();
56 AliFatal("Time unisochronity missing");
60 AliFatal("Parameters missing");
64 // Apply Time0 correction - Pad by pad fluctuation
66 x[2]-=time0TPC->GetCalROC(sector)->GetValue(row,pad);
68 // Tranform from pad - time coordinate system to the rotated global (tracking) system
70 Local2RotatedGlobal(sector,x);
75 //TODO: calib->GetParameters()->GetClusterMatrix(sector)->LocalToMaster(x,xx);
76 RotatedGlobal2Global(sector,x);
81 calib->GetExB()->Correct(x,xx);
83 Global2RotatedGlobal(sector,xx);
85 x[0]=xx[0];x[1]=xx[1];x[2]=xx[2];
88 void AliTPCTransform::Local2RotatedGlobal(Int_t sector, Double_t *x) const {
93 // Drift Velocity - time bin to the
94 // Current implementation - common drift velocity
96 // TODO: use a map or parametrisation!
100 AliTPCcalibDB* const calib=AliTPCcalibDB::Instance();
101 AliTPCParam * param = calib->GetParameters();
103 AliFatal("Parameters missing");
105 Int_t row=TMath::Nint(x[0]);
106 Int_t pad=TMath::Nint(x[1]);
108 const Int_t kNIS=param->GetNInnerSector(), kNOS=param->GetNOuterSector();
110 Double_t zwidth = param->GetZWidth();
111 Double_t padWidth = 0;
112 Double_t padLength = 0;
116 maxPad = param->GetNPadsLow(row);
117 sign = (sector < kNIS/2) ? 1 : -1;
118 padLength = param->GetPadPitchLength(sector,row);
119 padWidth = param->GetPadPitchWidth(sector);
121 maxPad = param->GetNPadsUp(row);
122 sign = ((sector-kNIS) < kNOS/2) ? 1 : -1;
123 padLength = param->GetPadPitchLength(sector,row);
124 padWidth = param->GetPadPitchWidth(sector);
128 x[0] = param->GetPadRowRadii(sector,row);
129 // padrow X position - ideal
133 x[1]=(x[1]-0.5*maxPad)*padWidth;
134 // if (!fRecoParam->GetBYMirror()){
135 // if (sector%36>17){
142 x[2]*= zwidth; // tranform time bin to the distance to the ROC
143 x[2]-= 3.*param->GetZSigma() + param->GetNTBinsL1()*zwidth;
144 // subtract the time offsets
145 x[2] = sign*( param->GetZLength(sector) - x[2]);
148 inline void AliTPCTransform::RotatedGlobal2Global(Int_t sector,Double_t *x) const {
150 // transform possition rotated global to the global
153 GetCosAndSin(sector,cos,sin);
155 x[0]= cos*tmp+sin*x[1];
156 x[1]=-sin*tmp+cos*x[1];
159 inline void AliTPCTransform::Global2RotatedGlobal(Int_t sector,Double_t *x) const {
161 // tranform possition Global2RotatedGlobal
164 GetCosAndSin(sector,cos,sin);
166 x[0]= cos*tmp-sin*x[1];
167 x[1]= sin*tmp+cos*x[1];
170 inline void AliTPCTransform::GetCosAndSin(Int_t sector,Double_t &cos,
171 Double_t &sin) const {
172 cos=fCoss[sector%18];
173 sin=fSins[sector%18];
176 ClassImp(AliTPCTransform)