1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
18 #include "AliTrackPoints.h"
21 //_________________________________
22 ////////////////////////////////////////////////////////////
24 // class AliTrackPoints //
26 // used by Anti-Merging cut //
27 // contains set of poits the lay on track trajectory //
28 // according to reconstructed track parameters - //
29 // NOT CLUSTERS POSITIONS!!! //
30 // Anti-Merging cut is applied only on tracks coming from //
31 // different events (that are use to fill deniminators) //
33 ////////////////////////////////////////////////////////////
35 #include <TClonesArray.h>
39 #include "AliESDtrack.h"
40 #include "AliTPCtrack.h"
41 #include "AliTrackReference.h"
42 #include "AliITStrackV2.h"
44 ClassImp(AliTrackPoints)
46 Int_t AliTrackPoints::fgDebug = 0;
48 AliTrackPoints::AliTrackPoints():
56 /***************************************************************/
58 AliTrackPoints::AliTrackPoints(AliTrackPoints::ETypes type, AliESDtrack* track, Float_t mf):
65 //tupe - what kind of track points should be calculated
66 //mf - magnetic field in [kG] = [T]*10.0
77 case kITSInnerFromVertexOuterFromTPC:
82 MakeITSPointsInnerFromVertexOuterFromTPC(track,mf);
86 Info("AliTrackPoints","Not recognized type");
90 /***************************************************************/
92 AliTrackPoints::AliTrackPoints(Int_t n, AliESDtrack* track, Float_t mf, Float_t dr, Float_t r0):
99 //mf - magnetic field in kG - needed to calculate curvature out of Pt
100 //r0 - starting radius
101 //dr - calculate points every dr cm, default every 30cm
104 Error("AliTrackPoints","ESD track is null");
113 if ( ((track->GetStatus() & AliESDtrack::kTPCrefit) == kFALSE)&&
114 ((track->GetStatus() & AliESDtrack::kTPCin) == kFALSE) )
116 //could happend: its stand alone tracking
117 AliDebug(3,"This ESD track does not contain TPC information");
130 track->GetInnerExternalParameters(x,par); //get properties of the track
133 Error("AliTrackPoints","This ESD track seem not to contain TPC information (curv is 0)");
139 Error("AliTrackPoints","Zero Magnetic field passed as parameter.");
143 Double_t alpha = track->GetInnerAlpha();
144 Double_t cc = 1000./0.299792458/mf;//conversion constant
145 Double_t c=par[4]/cc;
147 MakePoints(dr,r0,x,par,c,alpha);
150 /***************************************************************/
152 AliTrackPoints::AliTrackPoints(Int_t n, AliTPCtrack* track, Float_t dr, Float_t r0):
160 //dr - calculate points every dr cm, default every 30cm
163 Error("AliTrackPoints","TPC track is null");
171 track->PropagateTo(r0);
173 //* This formation is now fixed in the following way: *
174 //* external param0: local Y-coordinate of a track (cm) *
175 //* external param1: local Z-coordinate of a track (cm) *
176 //* external param2: local sine of the track momentum azimuth angle *
177 //* external param3: tangent of the track momentum dip angle *
178 //* external param4: 1/pt (1/(GeV/c)) *
182 track->GetExternalParameters(x,par); //get properties of the track
184 Double_t alpha = track->GetAlpha();
185 Double_t c=track->GetC();
186 MakePoints(dr,r0,x,par,c,alpha);
188 /***************************************************************/
190 AliTrackPoints::~AliTrackPoints()
197 /***************************************************************/
199 void AliTrackPoints::MakePoints( Float_t dr, Float_t r0, Double_t x, Double_t* par, Double_t c, Double_t alpha)
201 //Calculates points starting at radius r0
202 //spacing every dr (in radial direction)
203 // according to track parameters
204 // x - position in sector local reference frame. x i parallel to R and sector is symmetric with respect to x
205 // par - track external parameters; array with 5 elements; look at AliTPCtrack.h or AliESDtrack.h for their meaning
206 // c - track curvature
207 // alpha - sector's rotation angle (phi) == angle needed for local to global transformation
210 Double_t z0 = par[1];
212 Double_t phi0local = TMath::ATan2(y,x);
213 Double_t phi0global = phi0local + alpha;
215 if (phi0local<0) phi0local+=2*TMath::Pi();
216 if (phi0local>=2.*TMath::Pi()) phi0local-=2*TMath::Pi();
218 if (phi0global<0) phi0global+=2*TMath::Pi();
219 if (phi0global>=2.*TMath::Pi()) phi0global-=2*TMath::Pi();
221 Double_t r = TMath::Hypot(x,y);
224 AliDebug(9,Form("Radius0 %f, Real Radius %f",r0,r));
226 AliDebug(5,Form("Phi Global at first padraw %f, Phi locat %f",phi0global,phi0local));
228 Double_t eta = x*c - par[2] ;//par[2] = fX*C - eta; eta==fP2 ; C==fP4
230 //this calculattions are assuming new (current) model
231 Double_t tmp = par[2];
233 tmp = c*y + TMath::Sqrt(tmp);
234 Double_t dca=(TMath::Hypot(eta,tmp) - 1. )/TMath::Abs(c);
236 //Here is old model Cold=Cnew/2.
237 Double_t dcasq = dca*dca;
239 Double_t cst1 = (1.+c2*dca)*dca;//first constant
240 Double_t cst2 = 1. + 2.*c2*dca;//second constant
242 Double_t factorPhi0 = TMath::ASin((c2*r + cst1/r)/cst2);
243 Double_t factorZ0 = TMath::ASin(c2*TMath::Sqrt((r*r-dcasq)/cst2))*par[3]/c2;
245 for(Int_t i = 0; i<fN; i++)
247 Double_t rc = r0 + i*dr;
248 Double_t ftmp = (c2*rc + cst1/rc)/cst2;
251 AliDebug(1,Form("ASin argument > 1 %f:",ftmp));
254 else if (ftmp < -1.0)
256 AliDebug(1,Form("ASin argument < -1 %f:",ftmp));
260 Double_t factorPhi = TMath::ASin( ftmp );//factor phi od rc
261 Double_t phi = phi0global + factorPhi - factorPhi0;
263 ftmp = (rc*rc-dcasq)/cst2;
266 AliDebug(1,Form("Sqrt argument < 0: %f",ftmp));
270 ftmp = c2*TMath::Sqrt(ftmp);
273 AliDebug(1,Form("ASin argument > 1: %f",ftmp));
276 else if (ftmp < -1.0)
278 AliDebug(2,Form("ASin argument < -1: %f",ftmp));
281 Double_t factorZ = TMath::ASin(ftmp)*par[3]/c2;
282 fZ[i] = z0 + factorZ - factorZ0;
283 fX[i] = rc*TMath::Cos(phi);
284 fY[i] = rc*TMath::Sin(phi);
286 AliDebug(3,Form("AliTrackPoints","X %f Y %f Z %f R asked %f R obtained %f",
287 fX[i],fY[i],fZ[i],rc,TMath::Hypot(fX[i],fY[i])));
290 /***************************************************************/
292 void AliTrackPoints::MakeITSPoints(AliESDtrack* track)
294 //Calculates points in ITS
296 AliITStrackV2 itstrack(*track,kTRUE);
298 static const Double_t r[6] = {4.0, 7.0, 14.9, 23.8, 39.1, 43.6};
299 for (Int_t i = 0; i < 6; i++)
301 itstrack.GetGlobalXYZat(r[i],x,y,z);
305 // Info("MakeITSPoints","X %f Y %f Z %f R asked %f R obtained %f",
306 // fX[i],fY[i],fZ[i],r[i],TMath::Hypot(fX[i],fY[i]));
311 /***************************************************************/
312 void AliTrackPoints::MakeITSPointsInnerFromVertexOuterFromTPC(AliESDtrack* track, Float_t mf)
314 //makes trackpoints for ITS
315 //for 3 inner layers calculates out of the vector at vertex
316 //for 3 outer ---------------//------------------ at inner TPC
318 static const Double_t r[6] = {4.0, 7.0, 14.9, 23.8, 39.1, 43.6};
319 AliITStrackV2 itstrack(*track,kTRUE);
321 for (Int_t i = 0; i < 3; i++)
323 itstrack.GetGlobalXYZat(r[i],x,y,z);
327 AliDebug(3,Form("X %f Y %f Z %f R asked %f R obtained %f",
328 fX[i],fY[i],fZ[i],r[i],TMath::Hypot(fX[i],fY[i])));
331 for (Int_t i = 3; i < 6; i++)
334 AliTrackPoints tmptp(1,track,mf,0,r[i]);
335 tmptp.PositionAt(0,ax,ay,az);
339 AliDebug(3,Form("X %f Y %f Z %f R asked %f R obtained %f",
340 fX[i],fY[i],fZ[i],r[i],TMath::Hypot(fX[i],fY[i])));
346 /***************************************************************/
348 void AliTrackPoints::PositionAt(Int_t n, Float_t &x,Float_t &y,Float_t &z)
350 //returns position at point n
351 if ((n<0) || (n>=fN))
353 Error("PositionAt","Point %d out of range",n);
360 AliDebug(2,Form("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 AliDebug(1,"One of tracks is empty");
389 Warning("AvarageDistance","Number of points is not equal");
394 for (Int_t i = 0; i<fN; i++)
396 AliDebug(10,Form("radii: %f %f",TMath::Hypot(fX[i],fY[i]),TMath::Hypot(tr.fX[i],tr.fY[i])));
397 // Float_t r1sq = fX[i]*fX[i]+fY[i]*fY[i];
398 // Float_t r2sq = tr.fX[i]*tr.fX[i]+tr.fY[i]*tr.fY[i];
401 Double_t dx = fX[i]-tr.fX[i];
402 Double_t dy = fY[i]-tr.fY[i];
403 Double_t dz = fZ[i]-tr.fZ[i];
404 sum+=TMath::Sqrt(dx*dx + dy*dy + dz*dz);
406 AliDebug(2,Form("Diff: x ,y z: %f , %f, %f",dx,dy,dz));
407 AliDebug(2,Form("xxyyzz %f %f %f %f %f %f",
408 fX[i],tr.fX[i],fY[i],tr.fY[i],fZ[i],tr.fZ[i]));
411 Double_t retval = sum/((Double_t)fN);
412 AliDebug(1,Form("Avarage distance is %f.",retval));
416 /***************************************************************/
418 void AliTrackPoints::Print(Option_t* /*option*/) const
421 Info("Print","There is %d points",fN);
422 for(Int_t i = 0; i < fN; i++)
424 Info("Print","%d: %f %f %f",i,fX[i],fY[i],fZ[i]);
429 /***************************************************************/
430 /***************************************************************/
431 /***************************************************************/
432 /***************************************************************/
433 /***************************************************************/
434 /***************************************************************/
438 #include "AliRunLoader.h"
439 #include "AliTPCtrack.h"
449 void AliTrackPoints::Testesd(Int_t entr,const char* fname )
453 AliRunLoader* rl = AliRunLoader::Open();
456 Float_t mf = rl->GetAliRun()->Field()->SolenoidField();
459 TFile* fFile = TFile::Open(fname);
463 printf("testesd: There is no suche a ESD file\n");
466 AliESD* esd = dynamic_cast<AliESD*>(fFile->Get("0"));
467 AliESDtrack *t = esd->GetTrack(entr);
470 ::Error("testesd","Can not get track %d",entr);
476 AliTrackPoints* tp = new AliTrackPoints(N,t,mf,1.);
487 TH2D* hxy = new TH2D("hxy","hxy",1000,xmin,xmax,1000,ymin,ymax);
488 TH2D* hxyt = new TH2D("hxyt","hxyt",1000,xmin,xmax,1000,ymin,ymax);
489 TH2D* hxyTR = new TH2D("hxyTR","hxyTR",1000,xmin,xmax,1000,ymin,ymax);
491 TH2D* hxz = new TH2D("hxz","hxz",1000,xmin,xmax,1000,zmin,zmax);
492 TH2D* hxzt = new TH2D("hxzt","hxzt",1000,xmin,xmax,1000,zmin,zmax);
493 TH2D* hxzTR = new TH2D("hxzTR","hxzTR",1000,xmin,xmax,1000,zmin,zmax);
495 hxyt->SetDirectory(0x0);
496 hxy->SetDirectory(0x0);
497 hxyTR->SetDirectory(0x0);
499 hxzt->SetDirectory(0x0);
500 hxz->SetDirectory(0x0);
501 hxzTR->SetDirectory(0x0);
505 for (Int_t i = 0;i<N;i++)
508 tp->PositionAt(i,x,y,z);
511 printf("Rdemanded %f\n",r);
512 printf("tpx %f tpy %f tpz %f Rt =%f\n", x,y,z,TMath::Hypot(x,y));
517 TTree* treeTR = rl->TreeTR();
518 TBranch* b = treeTR->GetBranch("TPC");
520 TClonesArray* trackrefs = new TClonesArray("AliTrackReference", 100);
521 AliTrackReference* tref;
522 b->SetAddress(&trackrefs);
524 Int_t tlab = TMath::Abs(t->GetLabel());
526 Int_t netr = (Int_t)treeTR->GetEntries();
527 printf("Found %d entries in TR tree\n",netr);
529 for (Int_t e = 0; e < netr; e++)
532 tref = (AliTrackReference*)trackrefs->At(0);
533 if (tref == 0x0) continue;
534 if (tref->GetTrack() != tlab) continue;
536 printf("Found %d entries in TR array\n",trackrefs->GetEntries());
538 for (Int_t i = 0; i < trackrefs->GetEntries(); i++)
540 tref = (AliTrackReference*)trackrefs->At(i);
541 if (tref->GetTrack() != tlab) continue;
545 printf("Track Ref: x %f y %f z %f\n",tref->X(),tref->Y(),tref->Z());
549 for (Int_t j = 1; j < 10; j++)
551 hxyTR->Fill(x, y+j*0.1);
552 hxyTR->Fill(x, y-j*0.1);
553 hxyTR->Fill(x+j*0.1,y);
554 hxyTR->Fill(x-j*0.1,y);
556 hxzTR->Fill(x,z-j*0.1);
557 hxzTR->Fill(x,z+j*0.1);
558 hxzTR->Fill(x-j*0.1,z);
559 hxzTR->Fill(x+j*0.1,z);
565 // hxzt->Draw("same");
571 /***************************************************************/
572 /***************************************************************/
573 /***************************************************************/
575 void AliTrackPoints::Testtpc(Int_t entr)
579 AliRunLoader* rl = AliRunLoader::Open();
580 AliLoader* l = rl->GetLoader("TPCLoader");
582 AliKalmanTrack::SetConvConst(100/0.299792458/0.2/rl->GetAliRun()->Field()->Factor());
584 AliTPCtrack* t = new AliTPCtrack();
585 TBranch* b=l->TreeT()->GetBranch("tracks");
587 l->TreeT()->GetEntry(entr);
589 AliTrackPoints* tp = new AliTrackPoints(N,t,1.);
600 TH2D* hxy = new TH2D("hxy","hxy",1000,xmin,xmax,1000,ymin,ymax);
601 TH2D* hxyt = new TH2D("hxyt","hxyt",1000,xmin,xmax,1000,ymin,ymax);
602 TH2D* hxyTR = new TH2D("hxyTR","hxyTR",1000,xmin,xmax,1000,ymin,ymax);
604 TH2D* hxz = new TH2D("hxz","hxz",1000,xmin,xmax,1000,zmin,zmax);
605 TH2D* hxzt = new TH2D("hxzt","hxzt",1000,xmin,xmax,1000,zmin,zmax);
606 TH2D* hxzTR = new TH2D("hxzTR","hxzTR",1000,xmin,xmax,1000,zmin,zmax);
608 hxyt->SetDirectory(0x0);
609 hxy->SetDirectory(0x0);
610 hxyTR->SetDirectory(0x0);
612 hxzt->SetDirectory(0x0);
613 hxz->SetDirectory(0x0);
614 hxzTR->SetDirectory(0x0);
618 for (Int_t i = 0;i<N;i++)
621 tp->PositionAt(i,x,y,z);
624 printf("Rdemanded %f\n",r);
625 printf("tpx %f tpy %f tpz %f Rt =%f\n", x,y,z,TMath::Hypot(x,y));
627 //BUT they are local!!!!
629 // Double_t phi = t->Phi();
630 Double_t rl = TMath::Hypot(t->GetX(),t->GetY());//real radius
632 Double_t alpha = t->GetAlpha();
633 Double_t salpha = TMath::Sin(alpha);
634 Double_t calpha = TMath::Cos(alpha);
635 x = t->GetX()*calpha - t->GetY()*salpha;
636 y = t->GetX()*salpha + t->GetY()*calpha;
639 printf("tx %f ty %f tz %f Rt = %f R from XY %f\n",x,y,z,TMath::Hypot(x,y),rl);
641 printf("tpz - tz %f\n",z-t->GetZ());
649 TTree* treeTR = rl->TreeTR();
650 b = treeTR->GetBranch("TPC");
652 TClonesArray* trackrefs = new TClonesArray("AliTrackReference", 100);
653 AliTrackReference* tref;
654 b->SetAddress(&trackrefs);
656 Int_t tlab = TMath::Abs(t->GetLabel());
658 Int_t netr = (Int_t)treeTR->GetEntries();
659 printf("Found %d entries in TR tree\n",netr);
661 for (Int_t e = 0; e < netr; e++)
664 tref = (AliTrackReference*)trackrefs->At(0);
665 if (tref == 0x0) continue;
666 if (tref->GetTrack() != tlab) continue;
668 printf("Found %d entries in TR array\n",trackrefs->GetEntries());
670 for (Int_t i = 0; i < trackrefs->GetEntries(); i++)
672 tref = (AliTrackReference*)trackrefs->At(i);
673 if (tref->GetTrack() != tlab) continue;
677 printf("Track Ref: x %f y %f z %f\n",tref->X(),tref->Y(),tref->Z());
681 for (Int_t j = 1; j < 10; j++)
683 hxyTR->Fill(x, y+j*0.1);
684 hxyTR->Fill(x, y-j*0.1);
685 hxyTR->Fill(x+j*0.1,y);
686 hxyTR->Fill(x-j*0.1,y);
688 hxzTR->Fill(x,z-j*0.1);
689 hxzTR->Fill(x,z+j*0.1);
690 hxzTR->Fill(x-j*0.1,z);
691 hxzTR->Fill(x+j*0.1,z);
697 // hxzt->Draw("same");