1 #include "AliTrackPoints.h"
2 //_________________________________
3 ////////////////////////////////////////////////////////////
5 // class AliTrackPoints //
7 // used by Anti-Merging cut //
8 // contains set of poits the lay on track trajectory //
9 // according to reconstructed track parameters - //
10 // NOT CLUSTERS POSITIONS!!! //
11 // Anti-Merging cut is applied only on tracks coming from //
12 // different events (that are use to fill deniminators) //
14 ////////////////////////////////////////////////////////////
16 #include <TClonesArray.h>
20 #include "AliESDtrack.h"
21 #include "AliTPCtrack.h"
22 #include "AliTrackReference.h"
23 #include "AliITStrackV2.h"
25 ClassImp(AliTrackPoints)
27 Int_t AliTrackPoints::fgDebug = 0;
29 AliTrackPoints::AliTrackPoints():
37 /***************************************************************/
39 AliTrackPoints::AliTrackPoints(AliTrackPoints::ETypes type, AliESDtrack* track, Float_t mf):
46 //tupe - what kind of track points should be calculated
47 //mf - magnetic field in [kG] = [T]*10.0
58 case kITSInnerFromVertexOuterFromTPC:
63 MakeITSPointsInnerFromVertexOuterFromTPC(track,mf);
67 Info("AliTrackPoints","Not recognized type");
71 /***************************************************************/
73 AliTrackPoints::AliTrackPoints(Int_t n, AliESDtrack* track, Float_t mf, Float_t dr, Float_t r0):
80 //mf - magnetic field in kG - needed to calculate curvature out of Pt
81 //r0 - starting radius
82 //dr - calculate points every dr cm, default every 30cm
85 Error("AliTrackPoints","ESD track is null");
94 if ( ((track->GetStatus() & AliESDtrack::kTPCrefit) == kFALSE)&&
95 ((track->GetStatus() & AliESDtrack::kTPCin) == kFALSE) )
97 //could happend: its stand alone tracking
99 Warning("AliTrackPoints","This ESD track does not contain TPC information");
112 track->GetInnerExternalParameters(x,par); //get properties of the track
115 Error("AliTrackPoints","This ESD track seem not to contain TPC information (curv is 0)");
121 Error("AliTrackPoints","Zero Magnetic field passed as parameter.");
125 Double_t alpha = track->GetInnerAlpha();
126 Double_t cc = 1000./0.299792458/mf;//conversion constant
127 Double_t c=par[4]/cc;
129 MakePoints(dr,r0,x,par,c,alpha);
132 /***************************************************************/
134 AliTrackPoints::AliTrackPoints(Int_t n, AliTPCtrack* track, Float_t dr, Float_t r0):
142 //dr - calculate points every dr cm, default every 30cm
145 Error("AliTrackPoints","TPC track is null");
153 track->PropagateTo(r0);
155 //* This formation is now fixed in the following way: *
156 //* external param0: local Y-coordinate of a track (cm) *
157 //* external param1: local Z-coordinate of a track (cm) *
158 //* external param2: local sine of the track momentum azimuth angle *
159 //* external param3: tangent of the track momentum dip angle *
160 //* external param4: 1/pt (1/(GeV/c)) *
164 track->GetExternalParameters(x,par); //get properties of the track
166 Double_t alpha = track->GetAlpha();
167 Double_t c=track->GetC();
168 MakePoints(dr,r0,x,par,c,alpha);
170 /***************************************************************/
172 AliTrackPoints::~AliTrackPoints()
179 /***************************************************************/
181 void AliTrackPoints::MakePoints( Float_t dr, Float_t r0, Double_t x, Double_t* par, Double_t c, Double_t alpha)
183 //Calculates points starting at radius r0
184 //spacing every dr (in radial direction)
185 // according to track parameters
186 // x - position in sector local reference frame. x i parallel to R and sector is symmetric with respect to x
187 // par - track external parameters; array with 5 elements; look at AliTPCtrack.h or AliESDtrack.h for their meaning
188 // c - track curvature
189 // alpha - sector's rotation angle (phi) == angle needed for local to global transformation
192 Double_t z0 = par[1];
194 Double_t phi0local = TMath::ATan2(y,x);
195 Double_t phi0global = phi0local + alpha;
197 if (phi0local<0) phi0local+=2*TMath::Pi();
198 if (phi0local>=2.*TMath::Pi()) phi0local-=2*TMath::Pi();
200 if (phi0global<0) phi0global+=2*TMath::Pi();
201 if (phi0global>=2.*TMath::Pi()) phi0global-=2*TMath::Pi();
203 Double_t r = TMath::Hypot(x,y);
207 Info("AliTrackPoints","Radius0 %f, Real Radius %f",r0,r);
210 Info("AliTrackPoints","Phi Global at first padraw %f, Phi locat %f",phi0global,phi0local);
212 Double_t eta = x*c - par[2] ;//par[2] = fX*C - eta; eta==fP2 ; C==fP4
214 //this calculattions are assuming new (current) model
215 Double_t tmp = par[2];
217 tmp = c*y + TMath::Sqrt(tmp);
218 Double_t dca=(TMath::Hypot(eta,tmp) - 1. )/TMath::Abs(c);
220 //Here is old model Cold=Cnew/2.
221 Double_t dcasq = dca*dca;
223 Double_t cst1 = (1.+c2*dca)*dca;//first constant
224 Double_t cst2 = 1. + 2.*c2*dca;//second constant
226 Double_t factorPhi0 = TMath::ASin((c2*r + cst1/r)/cst2);
227 Double_t factorZ0 = TMath::ASin(c2*TMath::Sqrt((r*r-dcasq)/cst2))*par[3]/c2;
229 for(Int_t i = 0; i<fN; i++)
231 Double_t rc = r0 + i*dr;
232 Double_t ftmp = (c2*rc + cst1/rc)/cst2;
236 Warning("AliTrackPoints","ASin argument > 1 %f:",ftmp);
239 else if (ftmp < -1.0)
242 Warning("AliTrackPoints","ASin argument < -1 %f:",ftmp);
246 Double_t factorPhi = TMath::ASin( ftmp );//factor phi od rc
247 Double_t phi = phi0global + factorPhi - factorPhi0;
249 ftmp = (rc*rc-dcasq)/cst2;
253 Warning("AliTrackPoints","Sqrt argument < 0: %f",ftmp);
257 ftmp = c2*TMath::Sqrt(ftmp);
261 Warning("AliTrackPoints","ASin argument > 1: %f",ftmp);
264 else if (ftmp < -1.0)
267 Warning("AliTrackPoints","ASin argument < -1: %f",ftmp);
270 Double_t factorZ = TMath::ASin(ftmp)*par[3]/c2;
271 fZ[i] = z0 + factorZ - factorZ0;
272 fX[i] = rc*TMath::Cos(phi);
273 fY[i] = rc*TMath::Sin(phi);
275 if ( GetDebug() > 2 )
277 Info("AliTrackPoints","X %f Y %f Z %f R asked %f R obtained %f",
278 fX[i],fY[i],fZ[i],rc,TMath::Hypot(fX[i],fY[i]));
282 /***************************************************************/
284 void AliTrackPoints::MakeITSPoints(AliESDtrack* track)
286 //Calculates points in ITS
288 AliITStrackV2 itstrack(*track,kTRUE);
290 static const Double_t r[6] = {4.0, 7.0, 14.9, 23.8, 39.1, 43.6};
291 for (Int_t i = 0; i < 6; i++)
293 itstrack.GetGlobalXYZat(r[i],x,y,z);
297 // Info("MakeITSPoints","X %f Y %f Z %f R asked %f R obtained %f",
298 // fX[i],fY[i],fZ[i],r[i],TMath::Hypot(fX[i],fY[i]));
303 /***************************************************************/
304 void AliTrackPoints::MakeITSPointsInnerFromVertexOuterFromTPC(AliESDtrack* track, Float_t mf)
306 //makes trackpoints for ITS
307 //for 3 inner layers calculates out of the vector at vertex
308 //for 3 outer ---------------//------------------ at inner TPC
310 static const Double_t r[6] = {4.0, 7.0, 14.9, 23.8, 39.1, 43.6};
311 AliITStrackV2 itstrack(*track,kTRUE);
313 for (Int_t i = 0; i < 3; i++)
315 itstrack.GetGlobalXYZat(r[i],x,y,z);
319 Info("MakeITSPoints","X %f Y %f Z %f R asked %f R obtained %f",
320 fX[i],fY[i],fZ[i],r[i],TMath::Hypot(fX[i],fY[i]));
323 for (Int_t i = 3; i < 6; i++)
326 AliTrackPoints tmptp(1,track,mf,0,r[i]);
327 tmptp.PositionAt(0,ax,ay,az);
331 Info("MakeITSPoints","X %f Y %f Z %f R asked %f R obtained %f",
332 fX[i],fY[i],fZ[i],r[i],TMath::Hypot(fX[i],fY[i]));
338 /***************************************************************/
340 void AliTrackPoints::PositionAt(Int_t n, Float_t &x,Float_t &y,Float_t &z)
342 //returns position at point n
345 Error("PositionAt","Point %d out of range",n);
352 if ( GetDebug() > 1 )
354 Info("AliTrackPoints","n %d; X %f; Y %f; Z %f",n,x,y,z);
357 /***************************************************************/
359 void AliTrackPoints::Move(Float_t x, Float_t y, Float_t z)
361 //Moves all points about vector
362 for (Int_t i = 0; i<fN; i++)
369 /***************************************************************/
371 Double_t AliTrackPoints::AvarageDistance(const AliTrackPoints& tr)
373 //returns the aritmethic avarage distance between two tracks
374 // Info("AvarageDistance","Entered");
375 if ( (fN <= 0) || (tr.fN <=0) )
377 if (GetDebug()) Warning("AvarageDistance","One of tracks is empty");
383 Warning("AvarageDistance","Number of points is not equal");
388 for (Int_t i = 0; i<fN; i++)
392 // Float_t r1sq = fX[i]*fX[i]+fY[i]*fY[i];
393 // Float_t r2sq = tr.fX[i]*tr.fX[i]+tr.fY[i]*tr.fY[i];
394 Float_t r1sq = TMath::Hypot(fX[i],fY[i]);
395 Float_t r2sq = TMath::Hypot(tr.fX[i],tr.fY[i]);
396 Info("AvarageDistance","radii: %f %f",r1sq,r2sq);
400 Double_t dx = fX[i]-tr.fX[i];
401 Double_t dy = fY[i]-tr.fY[i];
402 Double_t dz = fZ[i]-tr.fZ[i];
403 sum+=TMath::Sqrt(dx*dx + dy*dy + dz*dz);
407 Info("AvarageDistance","Diff: x ,y z: %f , %f, %f",dx,dy,dz);
408 Info("AvarageDistance","xxyyzz %f %f %f %f %f %f",
409 fX[i],tr.fX[i],fY[i],tr.fY[i],fZ[i],tr.fZ[i]);
413 Double_t retval = sum/((Double_t)fN);
416 Info("AvarageDistance","Avarage distance is %f.",retval);
420 /***************************************************************/
421 /***************************************************************/
422 /***************************************************************/
423 /***************************************************************/
424 /***************************************************************/
425 /***************************************************************/
429 #include "AliRunLoader.h"
430 #include "AliTPCtrack.h"
440 void AliTrackPoints::Testesd(Int_t entr,const char* fname )
444 AliRunLoader* rl = AliRunLoader::Open();
447 Float_t mf = rl->GetAliRun()->Field()->SolenoidField();
450 TFile* fFile = TFile::Open(fname);
454 printf("testesd: There is no suche a ESD file\n");
457 AliESD* esd = dynamic_cast<AliESD*>(fFile->Get("0"));
458 AliESDtrack *t = esd->GetTrack(entr);
461 ::Error("testesd","Can not get track %d",entr);
467 AliTrackPoints* tp = new AliTrackPoints(N,t,mf,1.);
478 TH2D* hxy = new TH2D("hxy","hxy",1000,xmin,xmax,1000,ymin,ymax);
479 TH2D* hxyt = new TH2D("hxyt","hxyt",1000,xmin,xmax,1000,ymin,ymax);
480 TH2D* hxyTR = new TH2D("hxyTR","hxyTR",1000,xmin,xmax,1000,ymin,ymax);
482 TH2D* hxz = new TH2D("hxz","hxz",1000,xmin,xmax,1000,zmin,zmax);
483 TH2D* hxzt = new TH2D("hxzt","hxzt",1000,xmin,xmax,1000,zmin,zmax);
484 TH2D* hxzTR = new TH2D("hxzTR","hxzTR",1000,xmin,xmax,1000,zmin,zmax);
486 hxyt->SetDirectory(0x0);
487 hxy->SetDirectory(0x0);
488 hxyTR->SetDirectory(0x0);
490 hxzt->SetDirectory(0x0);
491 hxz->SetDirectory(0x0);
492 hxzTR->SetDirectory(0x0);
496 for (Int_t i = 0;i<N;i++)
499 tp->PositionAt(i,x,y,z);
502 printf("Rdemanded %f\n",r);
503 printf("tpx %f tpy %f tpz %f Rt =%f\n", x,y,z,TMath::Hypot(x,y));
508 TTree* treeTR = rl->TreeTR();
509 TBranch* b = treeTR->GetBranch("TPC");
511 TClonesArray* trackrefs = new TClonesArray("AliTrackReference", 100);
512 AliTrackReference* tref;
513 b->SetAddress(&trackrefs);
515 Int_t tlab = TMath::Abs(t->GetLabel());
517 Int_t netr = (Int_t)treeTR->GetEntries();
518 printf("Found %d entries in TR tree\n",netr);
520 for (Int_t e = 0; e < netr; e++)
523 tref = (AliTrackReference*)trackrefs->At(0);
524 if (tref == 0x0) continue;
525 if (tref->GetTrack() != tlab) continue;
527 printf("Found %d entries in TR array\n",trackrefs->GetEntries());
529 for (Int_t i = 0; i < trackrefs->GetEntries(); i++)
531 tref = (AliTrackReference*)trackrefs->At(i);
532 if (tref->GetTrack() != tlab) continue;
536 printf("Track Ref: x %f y %f z %f\n",tref->X(),tref->Y(),tref->Z());
540 for (Int_t j = 1; j < 10; j++)
542 hxyTR->Fill(x, y+j*0.1);
543 hxyTR->Fill(x, y-j*0.1);
544 hxyTR->Fill(x+j*0.1,y);
545 hxyTR->Fill(x-j*0.1,y);
547 hxzTR->Fill(x,z-j*0.1);
548 hxzTR->Fill(x,z+j*0.1);
549 hxzTR->Fill(x-j*0.1,z);
550 hxzTR->Fill(x+j*0.1,z);
556 // hxzt->Draw("same");
562 /***************************************************************/
563 /***************************************************************/
564 /***************************************************************/
566 void AliTrackPoints::Testtpc(Int_t entr)
570 AliRunLoader* rl = AliRunLoader::Open();
571 AliLoader* l = rl->GetLoader("TPCLoader");
573 AliKalmanTrack::SetConvConst(100/0.299792458/0.2/rl->GetAliRun()->Field()->Factor());
575 AliTPCtrack* t = new AliTPCtrack();
576 TBranch* b=l->TreeT()->GetBranch("tracks");
578 l->TreeT()->GetEntry(entr);
580 AliTrackPoints* tp = new AliTrackPoints(N,t,1.);
591 TH2D* hxy = new TH2D("hxy","hxy",1000,xmin,xmax,1000,ymin,ymax);
592 TH2D* hxyt = new TH2D("hxyt","hxyt",1000,xmin,xmax,1000,ymin,ymax);
593 TH2D* hxyTR = new TH2D("hxyTR","hxyTR",1000,xmin,xmax,1000,ymin,ymax);
595 TH2D* hxz = new TH2D("hxz","hxz",1000,xmin,xmax,1000,zmin,zmax);
596 TH2D* hxzt = new TH2D("hxzt","hxzt",1000,xmin,xmax,1000,zmin,zmax);
597 TH2D* hxzTR = new TH2D("hxzTR","hxzTR",1000,xmin,xmax,1000,zmin,zmax);
599 hxyt->SetDirectory(0x0);
600 hxy->SetDirectory(0x0);
601 hxyTR->SetDirectory(0x0);
603 hxzt->SetDirectory(0x0);
604 hxz->SetDirectory(0x0);
605 hxzTR->SetDirectory(0x0);
609 for (Int_t i = 0;i<N;i++)
612 tp->PositionAt(i,x,y,z);
615 printf("Rdemanded %f\n",r);
616 printf("tpx %f tpy %f tpz %f Rt =%f\n", x,y,z,TMath::Hypot(x,y));
618 //BUT they are local!!!!
620 // Double_t phi = t->Phi();
621 Double_t rl = TMath::Hypot(t->GetX(),t->GetY());//real radius
623 Double_t alpha = t->GetAlpha();
624 Double_t salpha = TMath::Sin(alpha);
625 Double_t calpha = TMath::Cos(alpha);
626 x = t->GetX()*calpha - t->GetY()*salpha;
627 y = t->GetX()*salpha + t->GetY()*calpha;
630 printf("tx %f ty %f tz %f Rt = %f R from XY %f\n",x,y,z,TMath::Hypot(x,y),rl);
632 printf("tpz - tz %f\n",z-t->GetZ());
640 TTree* treeTR = rl->TreeTR();
641 b = treeTR->GetBranch("TPC");
643 TClonesArray* trackrefs = new TClonesArray("AliTrackReference", 100);
644 AliTrackReference* tref;
645 b->SetAddress(&trackrefs);
647 Int_t tlab = TMath::Abs(t->GetLabel());
649 Int_t netr = (Int_t)treeTR->GetEntries();
650 printf("Found %d entries in TR tree\n",netr);
652 for (Int_t e = 0; e < netr; e++)
655 tref = (AliTrackReference*)trackrefs->At(0);
656 if (tref == 0x0) continue;
657 if (tref->GetTrack() != tlab) continue;
659 printf("Found %d entries in TR array\n",trackrefs->GetEntries());
661 for (Int_t i = 0; i < trackrefs->GetEntries(); i++)
663 tref = (AliTrackReference*)trackrefs->At(i);
664 if (tref->GetTrack() != tlab) continue;
668 printf("Track Ref: x %f y %f z %f\n",tref->X(),tref->Y(),tref->Z());
672 for (Int_t j = 1; j < 10; j++)
674 hxyTR->Fill(x, y+j*0.1);
675 hxyTR->Fill(x, y-j*0.1);
676 hxyTR->Fill(x+j*0.1,y);
677 hxyTR->Fill(x-j*0.1,y);
679 hxzTR->Fill(x,z-j*0.1);
680 hxzTR->Fill(x,z+j*0.1);
681 hxzTR->Fill(x-j*0.1,z);
682 hxzTR->Fill(x+j*0.1,z);
688 // hxzt->Draw("same");