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()
27 AliL3ModelTrack::~AliL3ModelTrack()
41 void AliL3ModelTrack::Init(Int_t slice,Int_t patch)
46 Int_t nrows = NumRows[patch];
47 fClusters = new AliL3ClusterModel[nrows];
48 fPad = new Float_t[nrows];
49 fTime = new Float_t[nrows];
50 fTrackModel = new AliL3TrackModel;
51 fOverlap = new Int_t[nrows];
53 memset(fClusters,0,nrows*sizeof(AliL3ClusterModel));
54 memset(fPad,0,nrows*sizeof(Float_t));
55 memset(fTime,0,nrows*sizeof(Float_t));
56 memset(fTrackModel,0,sizeof(AliL3TrackModel));
57 for(Int_t i=0; i<nrows; i++)
61 AliL3Transform transform;
63 fXYResidualQ = 0.1/transform.GetPadPitchWidth(patch);
64 fZResidualQ = 0.1/transform.GetPadPitchWidth(patch);
72 void AliL3ModelTrack::SetCluster(Int_t row,Float_t fpad,Float_t ftime,Float_t charge,Float_t sigmaY2,Float_t sigmaZ2)
74 Int_t index = row - NRows[fPatch][0];
75 if(index != fNClusters)
76 cout<<"AliL3ModelTrack::SetCluster() : Mismatch ; index: "<<index<<" nclusters "<<fNClusters<<endl;
78 if(index < 0 || index > NumRows[fPatch])
80 cerr<<"AliL3ModelTrack::SetCluster() : Wrong index: "<<index<<" row "<<row<<endl;
83 AliL3ClusterModel *cl = GetClusterModel(row);
85 cl->fPresent = kFALSE;
89 cl->fDTime = (ftime - GetTimeHit(row))/fXYResidualQ;
90 cl->fDPad = (fpad - GetPadHit(row))/fZResidualQ;
91 cl->fDCharge = charge - fClusterCharge;
92 cl->fDSigmaY2 = sigmaY2/fXYWidthQ;
93 cl->fDSigmaZ2 = sigmaZ2/fZWidthQ;
100 void AliL3ModelTrack::FillModel()
102 //Fill the track structure
106 cerr<<"AliL3ModelTrack::FillModel() : No trackmodel "<<endl;
109 fTrackModel->fKappa = GetKappa();
110 fTrackModel->fFirstPointX = GetFirstPointX();
111 fTrackModel->fFirstPointY = GetFirstPointY();
112 fTrackModel->fFirstPointZ = GetFirstPointZ();
113 fTrackModel->fTgl = GetTgl();
114 fTrackModel->fPsi = GetPsi();
115 fTrackModel->fLength = (Short_t)GetLength();
116 fTrackModel->fClusterCharge = fClusterCharge;
117 fTrackModel->fNClusters = fNClusters;
121 void AliL3ModelTrack::FillTrack()
123 //Fill the track parameters from the structure.
127 cerr<<"AliL3ModelTrack::FillTrack() : No data!!"<<endl;
130 SetKappa(fTrackModel->fKappa);
131 SetCharge((-1*(Int_t)copysign(1.,GetKappa())));
132 SetFirstPoint(fTrackModel->fFirstPointX,fTrackModel->fFirstPointY,fTrackModel->fFirstPointZ);
133 SetTgl(fTrackModel->fTgl);
134 SetPsi(fTrackModel->fPsi);
135 SetLength(fTrackModel->fLength);
136 fClusterCharge=fTrackModel->fClusterCharge;
137 fNClusters = fTrackModel->fNClusters;
138 SetPt((BFACT*BField)/fabs(GetKappa()));
142 AliL3Transform transform;
145 for(Int_t i=NRows[fPatch][0]; i<=NRows[fPatch][1]; i++)
147 AliL3ClusterModel *cl = GetClusterModel(i);
149 GetCrossingPoint(i,hit);
150 transform.Slice2Sector(fSlice,i,sector,row);
151 transform.Local2Raw(hit,sector,row);
153 SetTimeHit(i,hit[2]);
157 void AliL3ModelTrack::SetPadHit(Int_t row,Float_t pad)
159 Int_t index = row-NRows[fPatch][0];
160 if(index < 0 || index > NumRows[fPatch])
162 cerr<<"AliL3ModelTrack::SetPadHit() : Wrong index: "<<index<<endl;
169 void AliL3ModelTrack::SetTimeHit(Int_t row,Float_t time)
171 Int_t index = row-NRows[fPatch][0];
172 if(index < 0 || index > NumRows[fPatch])
174 cerr<<"AliL3ModelTrack::SetTimeHit() : Wrong index: "<<index<<endl;
180 void AliL3ModelTrack::SetOverlap(Int_t row,Int_t id)
182 Int_t index = row-NRows[fPatch][0];
183 if(index < 0 || index > NumRows[fPatch])
185 cerr<<"AliL3ModelTrack::SetOverlap() : Wrong index: "<<index<<endl;
191 Bool_t AliL3ModelTrack::GetPad(Int_t row,Float_t &pad)
193 //(ftime - GetTimeHit(fNClusters))/fXYResidualQ;
194 //(fpad - GetPadHit(fNClusters))/fZResidualQ;
196 AliL3ClusterModel *cl = GetClusterModel(row);
197 pad = cl->fDPad*fXYResidualQ + GetPadHit(row);
199 return (Bool_t)cl->fPresent;
202 Bool_t AliL3ModelTrack::GetTime(Int_t row,Float_t &time)
204 AliL3ClusterModel *cl = GetClusterModel(row);
205 time = cl->fDTime*fZResidualQ + GetTimeHit(row);
207 return (Bool_t)cl->fPresent;
210 Bool_t AliL3ModelTrack::GetClusterCharge(Int_t row,Int_t &charge)
212 AliL3ClusterModel *cl = GetClusterModel(row);
213 charge = (Int_t)cl->fDCharge + fClusterCharge;
215 return (Bool_t)cl->fPresent;
218 Bool_t AliL3ModelTrack::GetXYWidth(Int_t row,Float_t &width)
220 AliL3ClusterModel *cl = GetClusterModel(row);
221 width = cl->fDSigmaY2*fXYWidthQ;
223 return (Bool_t)cl->fPresent;
226 Bool_t AliL3ModelTrack::GetZWidth(Int_t row,Float_t &width)
228 AliL3ClusterModel *cl = GetClusterModel(row);
229 width = cl->fDSigmaZ2*fZWidthQ;
231 return (Bool_t)cl->fPresent;
234 Bool_t AliL3ModelTrack::GetPadResidual(Int_t row,Float_t &res)
236 res = fClusters[row].fDPad;
237 return fClusters[row].fPresent;
240 Bool_t AliL3ModelTrack::GetTimeResidual(Int_t row,Float_t &res)
242 res = fClusters[row].fDTime;
243 return fClusters[row].fPresent;
246 Float_t AliL3ModelTrack::GetPadHit(Int_t row)
248 Int_t index = row-NRows[fPatch][0];
249 if(index < 0 || index > NumRows[fPatch])
251 cerr<<"AliL3ModelTrack::GetPadHit() : Wrong index: "<<index<<" row "<<row<<endl;
257 Float_t AliL3ModelTrack::GetTimeHit(Int_t row)
259 Int_t index = row-NRows[fPatch][0];
260 if(index < 0 || index > NumRows[fPatch])
262 cerr<<"AliL3ModelTrack::GetTimeHit() : Wrong index: "<<index<<" row "<<row<<endl;
268 Int_t AliL3ModelTrack::GetOverlap(Int_t row)
270 Int_t index = row-NRows[fPatch][0];
271 if(index < 0 || index > NumRows[fPatch])
273 cerr<<"AliL3ModelTrack::GetOverlap() : Wrong index: "<<index<<endl;
276 return fOverlap[index];
279 AliL3ClusterModel *AliL3ModelTrack::GetClusterModel(Int_t row)
281 if(!fClusters) return 0;
282 Int_t index = row-NRows[fPatch][0];
283 if(index < 0 || index > NumRows[fPatch])
285 cerr<<"AliL3ModelTrack::GetClusterModel() : Wrong index: "<<index<<endl;
288 return &fClusters[index];
291 void AliL3ModelTrack::Print()
295 cout<<"---------------------"<<endl;
296 cout<<"First point "<<GetFirstPointX()<<" "<<GetFirstPointY()<<" "<<GetFirstPointZ()<<endl;
297 cout<<"Last point "<<GetLastPointX()<<" "<<GetLastPointY()<<" "<<GetLastPointZ()<<endl;
298 cout<<"Pt "<<GetPt()<<" kappa "<<GetKappa()<<" tgl "<<GetTgl()<<" psi "<<GetPsi()<<" charge "<<GetCharge()<<endl;
299 cout<<"Center "<<GetCenterX()<<" "<<GetCenterY()<<endl<<endl;
300 cout<<"NHits "<<GetNClusters()<<endl;
301 cout<<"Clusters:"<<endl;
303 for(Int_t i=NRows[fPatch][0]; i<=NRows[fPatch][1]; i++)
305 AliL3ClusterModel *cl = GetClusterModel(i);
308 cout<<i<<" Empty"<<" Padcrossing "<<GetPadHit(i)<<" Timecrossing "<<GetTimeHit(i)<<" ";
311 cout<<i<<" Dpad "<<cl->fDPad<<" Dtime "<<cl->fDTime<<" Dcharge "<<cl->fDCharge;
312 cout<<" Padcrossing "<<GetPadHit(i)<<" Timecrossing "<<GetTimeHit(i)<<" ";
314 cout<<"Overlapping index "<<GetOverlap(i)<<endl;
318 //----------Code below taken from AliTPCTracker.cxx-----------------------
319 //Functions that give the expected cluster errors based on track parameters.
320 Double_t AliL3ModelTrack::GetParSigmaY2(Double_t r)//, Double_t tgl, Double_t pt)
324 // Parametrised error of the cluster reconstruction (pad direction)
328 Double_t tgl = GetTgl();
329 Double_t pt = GetPt();
331 const Float_t kArphi=0.41818e-2;
332 const Float_t kBrphi=0.17460e-4;
333 const Float_t kCrphi=0.30993e-2;
334 const Float_t kDrphi=0.41061e-3;
339 Double_t s=kArphi - kBrphi*r*tgl + kCrphi*x*x + kDrphi*x;
340 if (s<0.4e-3) s=0.4e-3;
341 s*=1.3; //Iouri Belikov
346 Double_t AliL3ModelTrack::GetParSigmaZ2(Double_t r)//, Double_t tgl)
349 // Parametrised error of the cluster reconstruction (drift direction)
353 Double_t tgl = GetTgl();
355 const Float_t kAz=0.39614e-2;
356 const Float_t kBz=0.22443e-4;
357 const Float_t kCz=0.51504e-1;
361 Double_t s=kAz - kBz*r*tgl + kCz*tgl*tgl;
362 if (s<0.4e-3) s=0.4e-3;
363 s*=1.3; //Iouri Belikov