3 // Author: Anders Vestbo <mailto:vestbo$fi.uib.no>
4 //*-- Copyright © ASV
10 #include "AliL3ModelTrack.h"
11 #include "AliL3Transform.h"
13 ClassImp(AliL3ModelTrack)
15 AliL3ModelTrack::AliL3ModelTrack()
28 AliL3ModelTrack::~AliL3ModelTrack()
44 void AliL3ModelTrack::Init(Int_t slice,Int_t patch)
49 Int_t nrows = NumRows[patch];
50 fClusters = new AliL3ClusterModel[nrows];
51 fPad = new Float_t[nrows];
52 fTime = new Float_t[nrows];
53 fTrackModel = new AliL3TrackModel;
54 fOverlap = new Int_t[nrows];
56 memset(fClusters,0,nrows*sizeof(AliL3ClusterModel));
57 memset(fPad,0,nrows*sizeof(Float_t));
58 memset(fTime,0,nrows*sizeof(Float_t));
59 memset(fTrackModel,0,sizeof(AliL3TrackModel));
60 for(Int_t i=0; i<nrows; i++)
63 fTransform = new AliL3Transform();
67 fXYResidualQ = 0.1/fTransform->GetPadPitchWidth(patch);
68 fZResidualQ = 0.1/fTransform->GetPadPitchWidth(patch);
75 void AliL3ModelTrack::SetCluster(Int_t row,Float_t fpad,Float_t ftime,Float_t charge,Float_t sigmaY2,Float_t sigmaZ2)
77 Int_t index = row - NRows[fPatch][0];
78 if(index != fNClusters)
79 cout<<"AliL3ModelTrack::SetCluster() : Mismatch ; index: "<<index<<" nclusters "<<fNClusters<<endl;
81 if(index < 0 || index > NumRows[fPatch])
83 cerr<<"AliL3ModelTrack::SetCluster() : Wrong index: "<<index<<" row "<<row<<endl;
86 AliL3ClusterModel *cl = GetClusterModel(row);
88 cl->fPresent = kFALSE;
92 cl->fDTime = (ftime - GetTimeHit(row))/fXYResidualQ;
93 cl->fDPad = (fpad - GetPadHit(row))/fZResidualQ;
94 cl->fDCharge = charge - fClusterCharge;
95 cl->fDSigmaY2 = sigmaY2/fXYWidthQ;
96 cl->fDSigmaZ2 = sigmaZ2/fZWidthQ;
103 void AliL3ModelTrack::FillModel()
105 //Fill the track structure
109 cerr<<"AliL3ModelTrack::FillModel() : No trackmodel "<<endl;
112 fTrackModel->fKappa = GetKappa();
113 fTrackModel->fFirstPointX = GetFirstPointX();
114 fTrackModel->fFirstPointY = GetFirstPointY();
115 fTrackModel->fFirstPointZ = GetFirstPointZ();
116 fTrackModel->fTgl = GetTgl();
117 fTrackModel->fPsi = GetPsi();
118 fTrackModel->fLength = (Short_t)GetLength();
119 fTrackModel->fClusterCharge = fClusterCharge;
120 fTrackModel->fNClusters = fNClusters;
124 void AliL3ModelTrack::FillTrack()
126 //Fill the track parameters from the structure.
130 cerr<<"AliL3ModelTrack::FillTrack() : No data!!"<<endl;
133 SetKappa(fTrackModel->fKappa);
134 SetCharge((-1*(Int_t)copysign(1.,GetKappa())));
135 SetFirstPoint(fTrackModel->fFirstPointX,fTrackModel->fFirstPointY,fTrackModel->fFirstPointZ);
136 SetTgl(fTrackModel->fTgl);
137 SetPsi(fTrackModel->fPsi);
138 SetLength(fTrackModel->fLength);
139 fClusterCharge=fTrackModel->fClusterCharge;
140 fNClusters = fTrackModel->fNClusters;
141 SetPt((BFACT*BField)/fabs(GetKappa()));
147 for(Int_t i=NRows[fPatch][0]; i<=NRows[fPatch][1]; i++)
149 AliL3ClusterModel *cl = GetClusterModel(i);
151 GetCrossingPoint(i,hit);
152 fTransform->Slice2Sector(fSlice,i,sector,row);
153 fTransform->Local2Raw(hit,sector,row);
155 SetTimeHit(i,hit[2]);
159 void AliL3ModelTrack::SetPadHit(Int_t row,Float_t pad)
161 Int_t index = row-NRows[fPatch][0];
162 if(index < 0 || index > NumRows[fPatch])
164 cerr<<"AliL3ModelTrack::SetPadHit() : Wrong index: "<<index<<endl;
171 void AliL3ModelTrack::SetTimeHit(Int_t row,Float_t time)
173 Int_t index = row-NRows[fPatch][0];
174 if(index < 0 || index > NumRows[fPatch])
176 cerr<<"AliL3ModelTrack::SetTimeHit() : Wrong index: "<<index<<endl;
182 void AliL3ModelTrack::SetOverlap(Int_t row,Int_t id)
184 Int_t index = row-NRows[fPatch][0];
185 if(index < 0 || index > NumRows[fPatch])
187 cerr<<"AliL3ModelTrack::SetOverlap() : Wrong index: "<<index<<endl;
193 Bool_t AliL3ModelTrack::GetPad(Int_t row,Float_t &pad)
195 //(ftime - GetTimeHit(fNClusters))/fXYResidualQ;
196 //(fpad - GetPadHit(fNClusters))/fZResidualQ;
198 AliL3ClusterModel *cl = GetClusterModel(row);
199 pad = cl->fDPad*fXYResidualQ + GetPadHit(row);
201 return (Bool_t)cl->fPresent;
204 Bool_t AliL3ModelTrack::GetTime(Int_t row,Float_t &time)
206 AliL3ClusterModel *cl = GetClusterModel(row);
207 time = cl->fDTime*fZResidualQ + GetTimeHit(row);
209 return (Bool_t)cl->fPresent;
212 Bool_t AliL3ModelTrack::GetClusterCharge(Int_t row,Int_t &charge)
214 AliL3ClusterModel *cl = GetClusterModel(row);
215 charge = (Int_t)cl->fDCharge + fClusterCharge;
217 return (Bool_t)cl->fPresent;
220 Bool_t AliL3ModelTrack::GetXYWidth(Int_t row,Float_t &width)
222 AliL3ClusterModel *cl = GetClusterModel(row);
223 width = cl->fDSigmaY2*fXYWidthQ;
225 return (Bool_t)cl->fPresent;
228 Bool_t AliL3ModelTrack::GetZWidth(Int_t row,Float_t &width)
230 AliL3ClusterModel *cl = GetClusterModel(row);
231 width = cl->fDSigmaZ2*fZWidthQ;
233 return (Bool_t)cl->fPresent;
236 Bool_t AliL3ModelTrack::GetPadResidual(Int_t row,Float_t &res)
238 res = fClusters[row].fDPad;
239 return fClusters[row].fPresent;
242 Bool_t AliL3ModelTrack::GetTimeResidual(Int_t row,Float_t &res)
244 res = fClusters[row].fDTime;
245 return fClusters[row].fPresent;
248 Float_t AliL3ModelTrack::GetPadHit(Int_t row)
250 Int_t index = row-NRows[fPatch][0];
251 if(index < 0 || index > NumRows[fPatch])
253 cerr<<"AliL3ModelTrack::GetPadHit() : Wrong index: "<<index<<" row "<<row<<endl;
259 Float_t AliL3ModelTrack::GetTimeHit(Int_t row)
261 Int_t index = row-NRows[fPatch][0];
262 if(index < 0 || index > NumRows[fPatch])
264 cerr<<"AliL3ModelTrack::GetTimeHit() : Wrong index: "<<index<<" row "<<row<<endl;
270 Int_t AliL3ModelTrack::GetOverlap(Int_t row)
272 Int_t index = row-NRows[fPatch][0];
273 if(index < 0 || index > NumRows[fPatch])
275 cerr<<"AliL3ModelTrack::GetOverlap() : Wrong index: "<<index<<endl;
278 return fOverlap[index];
281 AliL3ClusterModel *AliL3ModelTrack::GetClusterModel(Int_t row)
283 if(!fClusters) return 0;
284 Int_t index = row-NRows[fPatch][0];
285 if(index < 0 || index > NumRows[fPatch])
287 cerr<<"AliL3ModelTrack::GetClusterModel() : Wrong index: "<<index<<endl;
290 return &fClusters[index];
293 void AliL3ModelTrack::Print()
297 cout<<"---------------------"<<endl;
298 cout<<"First point "<<GetFirstPointX()<<" "<<GetFirstPointY()<<" "<<GetFirstPointZ()<<endl;
299 cout<<"Last point "<<GetLastPointX()<<" "<<GetLastPointY()<<" "<<GetLastPointZ()<<endl;
300 cout<<"Pt "<<GetPt()<<" kappa "<<GetKappa()<<" tgl "<<GetTgl()<<" psi "<<GetPsi()<<" charge "<<GetCharge()<<endl;
301 cout<<"Center "<<GetCenterX()<<" "<<GetCenterY()<<endl<<endl;
302 cout<<"NHits "<<GetNClusters()<<endl;
303 cout<<"Clusters:"<<endl;
305 for(Int_t i=NRows[fPatch][0]; i<=NRows[fPatch][1]; i++)
307 AliL3ClusterModel *cl = GetClusterModel(i);
310 cout<<i<<" Empty"<<" Padcrossing "<<GetPadHit(i)<<" Timecrossing "<<GetTimeHit(i)<<" ";
313 cout<<i<<" Dpad "<<cl->fDPad<<" Dtime "<<cl->fDTime<<" Dcharge "<<cl->fDCharge;
314 cout<<" Padcrossing "<<GetPadHit(i)<<" Timecrossing "<<GetTimeHit(i)<<" ";
316 cout<<"Overlapping index "<<GetOverlap(i)<<endl;
320 //----------Code below taken from AliTPCTracker.cxx-----------------------
321 //Functions that give the expected cluster errors based on track parameters.
322 Double_t AliL3ModelTrack::GetParSigmaY2(Int_t row)//Double_t r)//, Double_t tgl, Double_t pt)
326 // Parametrised error of the cluster reconstruction (pad direction)
331 if(!GetTime(row,time) || !GetPad(row,pad))
336 fTransform->Slice2Sector(fSlice,row,sector,padrow);
337 fTransform->Raw2Local(xyz,sector,padrow,pad,time);
338 Double_t r = sqrt(xyz[0]*xyz[0] + xyz[1]*xyz[1]);
340 Double_t tgl = GetTgl();
341 Double_t pt = GetPt();
343 const Float_t kArphi=0.41818e-2;
344 const Float_t kBrphi=0.17460e-4;
345 const Float_t kCrphi=0.30993e-2;
346 const Float_t kDrphi=0.41061e-3;
351 Double_t s=kArphi - kBrphi*r*tgl + kCrphi*x*x + kDrphi*x;
352 if (s<0.4e-3) s=0.4e-3;
353 s*=1.3; //Iouri Belikov
358 Double_t AliL3ModelTrack::GetParSigmaZ2(Int_t row)//Double_t r)//, Double_t tgl)
361 // Parametrised error of the cluster reconstruction (drift direction)
366 if(!GetTime(row,time) || !GetPad(row,pad))
371 fTransform->Slice2Sector(fSlice,row,sector,padrow);
372 fTransform->Raw2Local(xyz,sector,padrow,pad,time);
373 Double_t r = sqrt(xyz[0]*xyz[0] + xyz[1]*xyz[1]);
375 Double_t tgl = GetTgl();
377 const Float_t kAz=0.39614e-2;
378 const Float_t kBz=0.22443e-4;
379 const Float_t kCz=0.51504e-1;
383 Double_t s=kAz - kBz*r*tgl + kCz*tgl*tgl;
384 if (s<0.4e-3) s=0.4e-3;
385 s*=1.3; //Iouri Belikov