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 if ( GetDebug() > 2 )
321 Info("MakeITSPoints","X %f Y %f Z %f R asked %f R obtained %f",
322 fX[i],fY[i],fZ[i],r[i],TMath::Hypot(fX[i],fY[i]));
326 for (Int_t i = 3; i < 6; i++)
329 AliTrackPoints tmptp(1,track,mf,0,r[i]);
330 tmptp.PositionAt(0,ax,ay,az);
334 if ( GetDebug() > 2 )
336 Info("MakeITSPoints","X %f Y %f Z %f R asked %f R obtained %f",
337 fX[i],fY[i],fZ[i],r[i],TMath::Hypot(fX[i],fY[i]));
344 /***************************************************************/
346 void AliTrackPoints::PositionAt(Int_t n, Float_t &x,Float_t &y,Float_t &z)
348 //returns position at point n
349 if ((n<0) || (n>=fN))
351 Error("PositionAt","Point %d out of range",n);
358 if ( GetDebug() > 1 )
360 Info("AliTrackPoints","n %d; X %f; Y %f; Z %f",n,x,y,z);
363 /***************************************************************/
365 void AliTrackPoints::Move(Float_t x, Float_t y, Float_t z)
367 //Moves all points about vector
368 for (Int_t i = 0; i<fN; i++)
375 /***************************************************************/
377 Double_t AliTrackPoints::AvarageDistance(const AliTrackPoints& tr)
379 //returns the aritmethic avarage distance between two tracks
380 // Info("AvarageDistance","Entered");
381 if ( (fN <= 0) || (tr.fN <=0) )
383 if (GetDebug()) Warning("AvarageDistance","One of tracks is empty");
389 Warning("AvarageDistance","Number of points is not equal");
394 for (Int_t i = 0; i<fN; i++)
398 // Float_t r1sq = fX[i]*fX[i]+fY[i]*fY[i];
399 // Float_t r2sq = tr.fX[i]*tr.fX[i]+tr.fY[i]*tr.fY[i];
400 Float_t r1sq = TMath::Hypot(fX[i],fY[i]);
401 Float_t r2sq = TMath::Hypot(tr.fX[i],tr.fY[i]);
402 Info("AvarageDistance","radii: %f %f",r1sq,r2sq);
406 Double_t dx = fX[i]-tr.fX[i];
407 Double_t dy = fY[i]-tr.fY[i];
408 Double_t dz = fZ[i]-tr.fZ[i];
409 sum+=TMath::Sqrt(dx*dx + dy*dy + dz*dz);
413 Info("AvarageDistance","Diff: x ,y z: %f , %f, %f",dx,dy,dz);
414 Info("AvarageDistance","xxyyzz %f %f %f %f %f %f",
415 fX[i],tr.fX[i],fY[i],tr.fY[i],fZ[i],tr.fZ[i]);
419 Double_t retval = sum/((Double_t)fN);
422 Info("AvarageDistance","Avarage distance is %f.",retval);
426 /***************************************************************/
428 void AliTrackPoints::Print(Option_t* /*option*/) const
431 Info("Print","There is %d points",fN);
432 for(Int_t i = 0; i < fN; i++)
434 Info("Print","%d: %f %f %f",i,fX[i],fY[i],fZ[i]);
439 /***************************************************************/
440 /***************************************************************/
441 /***************************************************************/
442 /***************************************************************/
443 /***************************************************************/
444 /***************************************************************/
448 #include "AliRunLoader.h"
449 #include "AliTPCtrack.h"
459 void AliTrackPoints::Testesd(Int_t entr,const char* fname )
463 AliRunLoader* rl = AliRunLoader::Open();
466 Float_t mf = rl->GetAliRun()->Field()->SolenoidField();
469 TFile* fFile = TFile::Open(fname);
473 printf("testesd: There is no suche a ESD file\n");
476 AliESD* esd = dynamic_cast<AliESD*>(fFile->Get("0"));
477 AliESDtrack *t = esd->GetTrack(entr);
480 ::Error("testesd","Can not get track %d",entr);
486 AliTrackPoints* tp = new AliTrackPoints(N,t,mf,1.);
497 TH2D* hxy = new TH2D("hxy","hxy",1000,xmin,xmax,1000,ymin,ymax);
498 TH2D* hxyt = new TH2D("hxyt","hxyt",1000,xmin,xmax,1000,ymin,ymax);
499 TH2D* hxyTR = new TH2D("hxyTR","hxyTR",1000,xmin,xmax,1000,ymin,ymax);
501 TH2D* hxz = new TH2D("hxz","hxz",1000,xmin,xmax,1000,zmin,zmax);
502 TH2D* hxzt = new TH2D("hxzt","hxzt",1000,xmin,xmax,1000,zmin,zmax);
503 TH2D* hxzTR = new TH2D("hxzTR","hxzTR",1000,xmin,xmax,1000,zmin,zmax);
505 hxyt->SetDirectory(0x0);
506 hxy->SetDirectory(0x0);
507 hxyTR->SetDirectory(0x0);
509 hxzt->SetDirectory(0x0);
510 hxz->SetDirectory(0x0);
511 hxzTR->SetDirectory(0x0);
515 for (Int_t i = 0;i<N;i++)
518 tp->PositionAt(i,x,y,z);
521 printf("Rdemanded %f\n",r);
522 printf("tpx %f tpy %f tpz %f Rt =%f\n", x,y,z,TMath::Hypot(x,y));
527 TTree* treeTR = rl->TreeTR();
528 TBranch* b = treeTR->GetBranch("TPC");
530 TClonesArray* trackrefs = new TClonesArray("AliTrackReference", 100);
531 AliTrackReference* tref;
532 b->SetAddress(&trackrefs);
534 Int_t tlab = TMath::Abs(t->GetLabel());
536 Int_t netr = (Int_t)treeTR->GetEntries();
537 printf("Found %d entries in TR tree\n",netr);
539 for (Int_t e = 0; e < netr; e++)
542 tref = (AliTrackReference*)trackrefs->At(0);
543 if (tref == 0x0) continue;
544 if (tref->GetTrack() != tlab) continue;
546 printf("Found %d entries in TR array\n",trackrefs->GetEntries());
548 for (Int_t i = 0; i < trackrefs->GetEntries(); i++)
550 tref = (AliTrackReference*)trackrefs->At(i);
551 if (tref->GetTrack() != tlab) continue;
555 printf("Track Ref: x %f y %f z %f\n",tref->X(),tref->Y(),tref->Z());
559 for (Int_t j = 1; j < 10; j++)
561 hxyTR->Fill(x, y+j*0.1);
562 hxyTR->Fill(x, y-j*0.1);
563 hxyTR->Fill(x+j*0.1,y);
564 hxyTR->Fill(x-j*0.1,y);
566 hxzTR->Fill(x,z-j*0.1);
567 hxzTR->Fill(x,z+j*0.1);
568 hxzTR->Fill(x-j*0.1,z);
569 hxzTR->Fill(x+j*0.1,z);
575 // hxzt->Draw("same");
581 /***************************************************************/
582 /***************************************************************/
583 /***************************************************************/
585 void AliTrackPoints::Testtpc(Int_t entr)
589 AliRunLoader* rl = AliRunLoader::Open();
590 AliLoader* l = rl->GetLoader("TPCLoader");
592 AliKalmanTrack::SetConvConst(100/0.299792458/0.2/rl->GetAliRun()->Field()->Factor());
594 AliTPCtrack* t = new AliTPCtrack();
595 TBranch* b=l->TreeT()->GetBranch("tracks");
597 l->TreeT()->GetEntry(entr);
599 AliTrackPoints* tp = new AliTrackPoints(N,t,1.);
610 TH2D* hxy = new TH2D("hxy","hxy",1000,xmin,xmax,1000,ymin,ymax);
611 TH2D* hxyt = new TH2D("hxyt","hxyt",1000,xmin,xmax,1000,ymin,ymax);
612 TH2D* hxyTR = new TH2D("hxyTR","hxyTR",1000,xmin,xmax,1000,ymin,ymax);
614 TH2D* hxz = new TH2D("hxz","hxz",1000,xmin,xmax,1000,zmin,zmax);
615 TH2D* hxzt = new TH2D("hxzt","hxzt",1000,xmin,xmax,1000,zmin,zmax);
616 TH2D* hxzTR = new TH2D("hxzTR","hxzTR",1000,xmin,xmax,1000,zmin,zmax);
618 hxyt->SetDirectory(0x0);
619 hxy->SetDirectory(0x0);
620 hxyTR->SetDirectory(0x0);
622 hxzt->SetDirectory(0x0);
623 hxz->SetDirectory(0x0);
624 hxzTR->SetDirectory(0x0);
628 for (Int_t i = 0;i<N;i++)
631 tp->PositionAt(i,x,y,z);
634 printf("Rdemanded %f\n",r);
635 printf("tpx %f tpy %f tpz %f Rt =%f\n", x,y,z,TMath::Hypot(x,y));
637 //BUT they are local!!!!
639 // Double_t phi = t->Phi();
640 Double_t rl = TMath::Hypot(t->GetX(),t->GetY());//real radius
642 Double_t alpha = t->GetAlpha();
643 Double_t salpha = TMath::Sin(alpha);
644 Double_t calpha = TMath::Cos(alpha);
645 x = t->GetX()*calpha - t->GetY()*salpha;
646 y = t->GetX()*salpha + t->GetY()*calpha;
649 printf("tx %f ty %f tz %f Rt = %f R from XY %f\n",x,y,z,TMath::Hypot(x,y),rl);
651 printf("tpz - tz %f\n",z-t->GetZ());
659 TTree* treeTR = rl->TreeTR();
660 b = treeTR->GetBranch("TPC");
662 TClonesArray* trackrefs = new TClonesArray("AliTrackReference", 100);
663 AliTrackReference* tref;
664 b->SetAddress(&trackrefs);
666 Int_t tlab = TMath::Abs(t->GetLabel());
668 Int_t netr = (Int_t)treeTR->GetEntries();
669 printf("Found %d entries in TR tree\n",netr);
671 for (Int_t e = 0; e < netr; e++)
674 tref = (AliTrackReference*)trackrefs->At(0);
675 if (tref == 0x0) continue;
676 if (tref->GetTrack() != tlab) continue;
678 printf("Found %d entries in TR array\n",trackrefs->GetEntries());
680 for (Int_t i = 0; i < trackrefs->GetEntries(); i++)
682 tref = (AliTrackReference*)trackrefs->At(i);
683 if (tref->GetTrack() != tlab) continue;
687 printf("Track Ref: x %f y %f z %f\n",tref->X(),tref->Y(),tref->Z());
691 for (Int_t j = 1; j < 10; j++)
693 hxyTR->Fill(x, y+j*0.1);
694 hxyTR->Fill(x, y-j*0.1);
695 hxyTR->Fill(x+j*0.1,y);
696 hxyTR->Fill(x-j*0.1,y);
698 hxzTR->Fill(x,z-j*0.1);
699 hxzTR->Fill(x,z+j*0.1);
700 hxzTR->Fill(x-j*0.1,z);
701 hxzTR->Fill(x+j*0.1,z);
707 // hxzt->Draw("same");