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 **************************************************************************/
16 /* $Id: AliESDtrackCuts.cxx 24534 2008-03-16 22:22:11Z fca $ */
18 #include "AliESDtrackCuts.h"
20 #include <AliESDtrack.h>
21 #include <AliESDVertex.h>
22 #include <AliESDEvent.h>
27 #include <TDirectory.h>
29 //____________________________________________________________________
30 ClassImp(AliESDtrackCuts)
33 const Char_t* AliESDtrackCuts::fgkCutNames[kNCuts] = {
38 "#Chi^{2}/clusters TPC",
39 "#Chi^{2}/clusters ITS",
55 "trk-to-vtx dca absolute",
56 "trk-to-vtx dca xy absolute",
57 "trk-to-vtx dca z absolute"
60 //____________________________________________________________________
61 AliESDtrackCuts::AliESDtrackCuts(const Char_t* name, const Char_t* title) : AliAnalysisCuts(name,title),
62 fCutMinNClusterTPC(0),
63 fCutMinNClusterITS(0),
64 fCutMaxChi2PerClusterTPC(0),
65 fCutMaxChi2PerClusterITS(0),
71 fCutAcceptKinkDaughters(0),
72 fCutRequireTPCRefit(0),
73 fCutRequireITSRefit(0),
74 fCutNsigmaToVertex(0),
75 fCutSigmaToVertexRequired(0),
104 //##############################################################################
105 // setting default cuts
106 SetMinNClustersTPC();
107 SetMinNClustersITS();
108 SetMaxChi2PerClusterTPC();
109 SetMaxChi2PerClusterITS();
110 SetMaxCovDiagonalElements();
111 SetRequireTPCRefit();
112 SetRequireITSRefit();
113 SetAcceptKingDaughters();
114 SetMinNsigmaToVertex();
115 SetRequireSigmaToVertex();
130 //_____________________________________________________________________________
131 AliESDtrackCuts::AliESDtrackCuts(const AliESDtrackCuts &c) : AliAnalysisCuts(c),
132 fCutMinNClusterTPC(0),
133 fCutMinNClusterITS(0),
134 fCutMaxChi2PerClusterTPC(0),
135 fCutMaxChi2PerClusterITS(0),
141 fCutAcceptKinkDaughters(0),
142 fCutRequireTPCRefit(0),
143 fCutRequireITSRefit(0),
144 fCutNsigmaToVertex(0),
145 fCutSigmaToVertexRequired(0),
147 fCutDCAToVertexXY(0),
172 ((AliESDtrackCuts &) c).Copy(*this);
175 AliESDtrackCuts::~AliESDtrackCuts()
181 for (Int_t i=0; i<2; i++) {
183 if (fhNClustersITS[i])
184 delete fhNClustersITS[i];
185 if (fhNClustersTPC[i])
186 delete fhNClustersTPC[i];
187 if (fhChi2PerClusterITS[i])
188 delete fhChi2PerClusterITS[i];
189 if (fhChi2PerClusterTPC[i])
190 delete fhChi2PerClusterTPC[i];
211 if (fhDXYNormalized[i])
212 delete fhDXYNormalized[i];
213 if (fhDZNormalized[i])
214 delete fhDZNormalized[i];
215 if (fhDXYvsDZNormalized[i])
216 delete fhDXYvsDZNormalized[i];
217 if (fhNSigmaToVertex[i])
218 delete fhNSigmaToVertex[i];
226 delete ffDTheoretical;
229 delete fhCutStatistics;
230 if (fhCutCorrelation)
231 delete fhCutCorrelation;
234 void AliESDtrackCuts::Init()
237 // sets everything to zero
240 fCutMinNClusterTPC = 0;
241 fCutMinNClusterITS = 0;
243 fCutMaxChi2PerClusterTPC = 0;
244 fCutMaxChi2PerClusterITS = 0;
252 fCutAcceptKinkDaughters = 0;
253 fCutRequireTPCRefit = 0;
254 fCutRequireITSRefit = 0;
256 fCutNsigmaToVertex = 0;
257 fCutSigmaToVertexRequired = 0;
259 fCutDCAToVertexXY = 0;
260 fCutDCAToVertexZ = 0;
277 fHistogramsOn = kFALSE;
279 for (Int_t i=0; i<2; ++i)
281 fhNClustersITS[i] = 0;
282 fhNClustersTPC[i] = 0;
284 fhChi2PerClusterITS[i] = 0;
285 fhChi2PerClusterTPC[i] = 0;
298 fhDXYNormalized[i] = 0;
299 fhDZNormalized[i] = 0;
300 fhDXYvsDZNormalized[i] = 0;
301 fhNSigmaToVertex[i] = 0;
309 fhCutCorrelation = 0;
312 //_____________________________________________________________________________
313 AliESDtrackCuts &AliESDtrackCuts::operator=(const AliESDtrackCuts &c)
316 // Assignment operator
319 if (this != &c) ((AliESDtrackCuts &) c).Copy(*this);
323 //_____________________________________________________________________________
324 void AliESDtrackCuts::Copy(TObject &c) const
330 AliESDtrackCuts& target = (AliESDtrackCuts &) c;
334 target.fCutMinNClusterTPC = fCutMinNClusterTPC;
335 target.fCutMinNClusterITS = fCutMinNClusterITS;
337 target.fCutMaxChi2PerClusterTPC = fCutMaxChi2PerClusterTPC;
338 target.fCutMaxChi2PerClusterITS = fCutMaxChi2PerClusterITS;
340 target.fCutMaxC11 = fCutMaxC11;
341 target.fCutMaxC22 = fCutMaxC22;
342 target.fCutMaxC33 = fCutMaxC33;
343 target.fCutMaxC44 = fCutMaxC44;
344 target.fCutMaxC55 = fCutMaxC55;
346 target.fCutAcceptKinkDaughters = fCutAcceptKinkDaughters;
347 target.fCutRequireTPCRefit = fCutRequireTPCRefit;
348 target.fCutRequireITSRefit = fCutRequireITSRefit;
350 target.fCutNsigmaToVertex = fCutNsigmaToVertex;
351 target.fCutSigmaToVertexRequired = fCutSigmaToVertexRequired;
352 target.fCutDCAToVertex = fCutDCAToVertex;
353 target.fCutDCAToVertexXY = fCutDCAToVertexXY;
354 target.fCutDCAToVertexZ = fCutDCAToVertexZ;
356 target.fPMin = fPMin;
357 target.fPMax = fPMax;
358 target.fPtMin = fPtMin;
359 target.fPtMax = fPtMax;
360 target.fPxMin = fPxMin;
361 target.fPxMax = fPxMax;
362 target.fPyMin = fPyMin;
363 target.fPyMax = fPyMax;
364 target.fPzMin = fPzMin;
365 target.fPzMax = fPzMax;
366 target.fEtaMin = fEtaMin;
367 target.fEtaMax = fEtaMax;
368 target.fRapMin = fRapMin;
369 target.fRapMax = fRapMax;
371 target.fHistogramsOn = fHistogramsOn;
373 for (Int_t i=0; i<2; ++i)
375 if (fhNClustersITS[i]) target.fhNClustersITS[i] = (TH1F*) fhNClustersITS[i]->Clone();
376 if (fhNClustersTPC[i]) target.fhNClustersTPC[i] = (TH1F*) fhNClustersTPC[i]->Clone();
378 if (fhChi2PerClusterITS[i]) target.fhChi2PerClusterITS[i] = (TH1F*) fhChi2PerClusterITS[i]->Clone();
379 if (fhChi2PerClusterTPC[i]) target.fhChi2PerClusterTPC[i] = (TH1F*) fhChi2PerClusterTPC[i]->Clone();
381 if (fhC11[i]) target.fhC11[i] = (TH1F*) fhC11[i]->Clone();
382 if (fhC22[i]) target.fhC22[i] = (TH1F*) fhC22[i]->Clone();
383 if (fhC33[i]) target.fhC33[i] = (TH1F*) fhC33[i]->Clone();
384 if (fhC44[i]) target.fhC44[i] = (TH1F*) fhC44[i]->Clone();
385 if (fhC55[i]) target.fhC55[i] = (TH1F*) fhC55[i]->Clone();
387 if (fhDXY[i]) target.fhDXY[i] = (TH1F*) fhDXY[i]->Clone();
388 if (fhDZ[i]) target.fhDZ[i] = (TH1F*) fhDZ[i]->Clone();
389 if (fhDXYDZ[i]) target.fhDXYDZ[i] = (TH1F*) fhDXYDZ[i]->Clone();
390 if (fhDXYvsDZ[i]) target.fhDXYvsDZ[i] = (TH2F*) fhDXYvsDZ[i]->Clone();
392 if (fhDXYNormalized[i]) target.fhDXYNormalized[i] = (TH1F*) fhDXYNormalized[i]->Clone();
393 if (fhDZNormalized[i]) target.fhDZNormalized[i] = (TH1F*) fhDZNormalized[i]->Clone();
394 if (fhDXYvsDZNormalized[i]) target.fhDXYvsDZNormalized[i] = (TH2F*) fhDXYvsDZNormalized[i]->Clone();
395 if (fhNSigmaToVertex[i]) target.fhNSigmaToVertex[i] = (TH1F*) fhNSigmaToVertex[i]->Clone();
397 if (fhPt[i]) target.fhPt[i] = (TH1F*) fhPt[i]->Clone();
398 if (fhEta[i]) target.fhEta[i] = (TH1F*) fhEta[i]->Clone();
400 if (ffDTheoretical) target.ffDTheoretical = (TF1*) ffDTheoretical->Clone();
402 if (fhCutStatistics) target.fhCutStatistics = (TH1F*) fhCutStatistics->Clone();
403 if (fhCutCorrelation) target.fhCutCorrelation = (TH2F*) fhCutCorrelation->Clone();
408 //_____________________________________________________________________________
409 Long64_t AliESDtrackCuts::Merge(TCollection* list) {
410 // Merge a list of AliESDtrackCuts objects with this (needed for PROOF)
411 // Returns the number of merged objects (including this)
418 TIterator* iter = list->MakeIterator();
421 // collection of measured and generated histograms
423 while ((obj = iter->Next())) {
425 AliESDtrackCuts* entry = dynamic_cast<AliESDtrackCuts*>(obj);
429 if (!entry->fHistogramsOn)
432 for (Int_t i=0; i<2; i++) {
434 fhNClustersITS[i] ->Add(entry->fhNClustersITS[i] );
435 fhNClustersTPC[i] ->Add(entry->fhNClustersTPC[i] );
437 fhChi2PerClusterITS[i] ->Add(entry->fhChi2PerClusterITS[i]);
438 fhChi2PerClusterTPC[i] ->Add(entry->fhChi2PerClusterTPC[i]);
440 fhC11[i] ->Add(entry->fhC11[i] );
441 fhC22[i] ->Add(entry->fhC22[i] );
442 fhC33[i] ->Add(entry->fhC33[i] );
443 fhC44[i] ->Add(entry->fhC44[i] );
444 fhC55[i] ->Add(entry->fhC55[i] );
446 fhDXY[i] ->Add(entry->fhDXY[i] );
447 fhDZ[i] ->Add(entry->fhDZ[i] );
448 fhDXYDZ[i] ->Add(entry->fhDXYDZ[i] );
449 fhDXYvsDZ[i] ->Add(entry->fhDXYvsDZ[i] );
451 fhDXYNormalized[i] ->Add(entry->fhDXYNormalized[i] );
452 fhDZNormalized[i] ->Add(entry->fhDZNormalized[i] );
453 fhDXYvsDZNormalized[i] ->Add(entry->fhDXYvsDZNormalized[i]);
454 fhNSigmaToVertex[i] ->Add(entry->fhNSigmaToVertex[i]);
456 fhPt[i] ->Add(entry->fhPt[i]);
457 fhEta[i] ->Add(entry->fhEta[i]);
460 fhCutStatistics ->Add(entry->fhCutStatistics);
461 fhCutCorrelation ->Add(entry->fhCutCorrelation);
469 //____________________________________________________________________
470 Float_t AliESDtrackCuts::GetSigmaToVertex(AliESDtrack* esdTrack)
472 // Calculates the number of sigma to the vertex.
477 esdTrack->GetImpactParameters(b,bCov);
479 if (bCov[0]<=0 || bCov[2]<=0) {
480 AliDebugClass(1, "Estimated b resolution lower or equal zero!");
481 bCov[0]=0; bCov[2]=0;
483 bRes[0] = TMath::Sqrt(bCov[0]);
484 bRes[1] = TMath::Sqrt(bCov[2]);
486 // -----------------------------------
487 // How to get to a n-sigma cut?
489 // The accumulated statistics from 0 to d is
491 // -> Erf(d/Sqrt(2)) for a 1-dim gauss (d = n_sigma)
492 // -> 1 - Exp(-d**2) for a 2-dim gauss (d*d = dx*dx + dy*dy != n_sigma)
494 // It means that for a 2-dim gauss: n_sigma(d) = Sqrt(2)*ErfInv(1 - Exp((-x**2)/2)
495 // Can this be expressed in a different way?
497 if (bRes[0] == 0 || bRes[1] ==0)
500 Float_t d = TMath::Sqrt(TMath::Power(b[0]/bRes[0],2) + TMath::Power(b[1]/bRes[1],2));
502 // work around precision problem
503 // if d is too big, TMath::Exp(...) gets 0, and TMath::ErfInverse(1) that should be infinite, gets 0 :(
504 // 1e-15 corresponds to nsigma ~ 7.7
505 if (TMath::Exp(-d * d / 2) < 1e-15)
508 Float_t nSigma = TMath::ErfInverse(1 - TMath::Exp(-d * d / 2)) * TMath::Sqrt(2);
512 void AliESDtrackCuts::EnableNeededBranches(TTree* tree)
514 // enables the branches needed by AcceptTrack, for a list see comment of AcceptTrack
516 tree->SetBranchStatus("fTracks.fFlags", 1);
517 tree->SetBranchStatus("fTracks.fITSncls", 1);
518 tree->SetBranchStatus("fTracks.fTPCncls", 1);
519 tree->SetBranchStatus("fTracks.fITSchi2", 1);
520 tree->SetBranchStatus("fTracks.fTPCchi2", 1);
521 tree->SetBranchStatus("fTracks.fC*", 1);
522 tree->SetBranchStatus("fTracks.fD", 1);
523 tree->SetBranchStatus("fTracks.fZ", 1);
524 tree->SetBranchStatus("fTracks.fCdd", 1);
525 tree->SetBranchStatus("fTracks.fCdz", 1);
526 tree->SetBranchStatus("fTracks.fCzz", 1);
527 tree->SetBranchStatus("fTracks.fP*", 1);
528 tree->SetBranchStatus("fTracks.fR*", 1);
529 tree->SetBranchStatus("fTracks.fKinkIndexes*", 1);
532 //____________________________________________________________________
534 AliESDtrackCuts::AcceptTrack(AliESDtrack* esdTrack) {
536 // figure out if the tracks survives all the track cuts defined
538 // the different quality parameter and kinematic values are first
539 // retrieved from the track. then it is found out what cuts the
540 // track did not survive and finally the cuts are imposed.
542 // this function needs the following branches:
548 // fTracks.fC //GetExternalCovariance
549 // fTracks.fD //GetImpactParameters
550 // fTracks.fZ //GetImpactParameters
551 // fTracks.fCdd //GetImpactParameters
552 // fTracks.fCdz //GetImpactParameters
553 // fTracks.fCzz //GetImpactParameters
554 // fTracks.fP //GetPxPyPz
555 // fTracks.fR //GetMass
556 // fTracks.fP //GetMass
557 // fTracks.fKinkIndexes
560 UInt_t status = esdTrack->GetStatus();
562 // getting quality parameters from the ESD track
563 Int_t nClustersITS = esdTrack->GetITSclusters(0);
564 Int_t nClustersTPC = esdTrack->GetTPCclusters(0);
566 Float_t chi2PerClusterITS = -1;
567 Float_t chi2PerClusterTPC = -1;
569 chi2PerClusterITS = esdTrack->GetITSchi2()/Float_t(nClustersITS);
571 chi2PerClusterTPC = esdTrack->GetTPCchi2()/Float_t(nClustersTPC);
573 esdTrack->GetExternalCovariance(extCov);
575 // getting the track to vertex parameters
576 Float_t nSigmaToVertex = GetSigmaToVertex(esdTrack);
580 esdTrack->GetImpactParameters(b,bCov);
581 if (bCov[0]<=0 || bCov[2]<=0) {
582 AliDebug(1, "Estimated b resolution lower or equal zero!");
583 bCov[0]=0; bCov[2]=0;
586 Float_t dcaToVertexXY = b[0];
587 Float_t dcaToVertexZ = b[1];
589 Float_t dcaToVertex = TMath::Sqrt(dcaToVertexXY*dcaToVertexXY + dcaToVertexZ*dcaToVertexZ);
591 // getting the kinematic variables of the track
592 // (assuming the mass is known)
594 esdTrack->GetPxPyPz(p);
596 Float_t momentum = TMath::Sqrt(TMath::Power(p[0],2) + TMath::Power(p[1],2) + TMath::Power(p[2],2));
597 Float_t pt = TMath::Sqrt(TMath::Power(p[0],2) + TMath::Power(p[1],2));
598 Float_t energy = TMath::Sqrt(TMath::Power(esdTrack->GetMass(),2) + TMath::Power(momentum,2));
601 //y-eta related calculations
604 if((momentum != TMath::Abs(p[2]))&&(momentum != 0))
605 eta = 0.5*TMath::Log((momentum + p[2])/(momentum - p[2]));
606 if((energy != TMath::Abs(p[2]))&&(momentum != 0))
607 y = 0.5*TMath::Log((energy + p[2])/(energy - p[2]));
610 //########################################################################
614 for (Int_t i=0; i<kNCuts; i++) cuts[i]=kFALSE;
616 // track quality cuts
617 if (fCutRequireTPCRefit && (status&AliESDtrack::kTPCrefit)==0)
619 if (fCutRequireITSRefit && (status&AliESDtrack::kITSrefit)==0)
621 if (nClustersTPC<fCutMinNClusterTPC)
623 if (nClustersITS<fCutMinNClusterITS)
625 if (chi2PerClusterTPC>fCutMaxChi2PerClusterTPC)
627 if (chi2PerClusterITS>fCutMaxChi2PerClusterITS)
629 if (extCov[0] > fCutMaxC11)
631 if (extCov[2] > fCutMaxC22)
633 if (extCov[5] > fCutMaxC33)
635 if (extCov[9] > fCutMaxC44)
637 if (extCov[14] > fCutMaxC55)
639 if (nSigmaToVertex > fCutNsigmaToVertex && fCutSigmaToVertexRequired)
641 // if n sigma could not be calculated
642 if (nSigmaToVertex<0 && fCutSigmaToVertexRequired)
644 if (!fCutAcceptKinkDaughters && esdTrack->GetKinkIndex(0)>0)
646 // track kinematics cut
647 if((momentum < fPMin) || (momentum > fPMax))
649 if((pt < fPtMin) || (pt > fPtMax))
651 if((p[0] < fPxMin) || (p[0] > fPxMax))
653 if((p[1] < fPyMin) || (p[1] > fPyMax))
655 if((p[2] < fPzMin) || (p[2] > fPzMax))
657 if((eta < fEtaMin) || (eta > fEtaMax))
659 if((y < fRapMin) || (y > fRapMax))
661 if (dcaToVertex > fCutDCAToVertex)
663 if (dcaToVertexXY > fCutDCAToVertexXY)
665 if (dcaToVertexZ > fCutDCAToVertexZ)
669 for (Int_t i=0; i<kNCuts; i++)
670 if (cuts[i]) cut = kTRUE;
674 //########################################################################
675 // filling histograms
677 fhCutStatistics->Fill(fhCutStatistics->GetBinCenter(fhCutStatistics->GetXaxis()->FindBin("n tracks")));
679 fhCutStatistics->Fill(fhCutStatistics->GetBinCenter(fhCutStatistics->GetXaxis()->FindBin("n cut tracks")));
681 for (Int_t i=0; i<kNCuts; i++) {
683 fhCutStatistics->Fill(fhCutStatistics->GetBinCenter(fhCutStatistics->GetXaxis()->FindBin(fgkCutNames[i])));
685 for (Int_t j=i; j<kNCuts; j++) {
686 if (cuts[i] && cuts[j]) {
687 Float_t xC = fhCutCorrelation->GetXaxis()->GetBinCenter(fhCutCorrelation->GetXaxis()->FindBin(fgkCutNames[i]));
688 Float_t yC = fhCutCorrelation->GetYaxis()->GetBinCenter(fhCutCorrelation->GetYaxis()->FindBin(fgkCutNames[j]));
689 fhCutCorrelation->Fill(xC, yC);
695 // now we loop over the filling of the histograms twice: once "before" the cut, once "after"
696 // the code is not in a function due to too many local variables that would need to be passed
698 for (Int_t id = 0; id < 2; id++)
700 // id = 0 --> before cut
701 // id = 1 --> after cut
705 fhNClustersITS[id]->Fill(nClustersITS);
706 fhNClustersTPC[id]->Fill(nClustersTPC);
707 fhChi2PerClusterITS[id]->Fill(chi2PerClusterITS);
708 fhChi2PerClusterTPC[id]->Fill(chi2PerClusterTPC);
710 fhC11[id]->Fill(extCov[0]);
711 fhC22[id]->Fill(extCov[2]);
712 fhC33[id]->Fill(extCov[5]);
713 fhC44[id]->Fill(extCov[9]);
714 fhC55[id]->Fill(extCov[14]);
717 fhEta[id]->Fill(eta);
720 bRes[0] = TMath::Sqrt(bCov[0]);
721 bRes[1] = TMath::Sqrt(bCov[2]);
723 fhDZ[id]->Fill(b[1]);
724 fhDXY[id]->Fill(b[0]);
725 fhDXYDZ[id]->Fill(dcaToVertex);
726 fhDXYvsDZ[id]->Fill(b[1],b[0]);
728 if (bRes[0]!=0 && bRes[1]!=0) {
729 fhDZNormalized[id]->Fill(b[1]/bRes[1]);
730 fhDXYNormalized[id]->Fill(b[0]/bRes[0]);
731 fhDXYvsDZNormalized[id]->Fill(b[1]/bRes[1], b[0]/bRes[0]);
732 fhNSigmaToVertex[id]->Fill(nSigmaToVertex);
744 //____________________________________________________________________
745 AliESDtrack* AliESDtrackCuts::GetTPCOnlyTrack(AliESDEvent* esd, Int_t iTrack)
747 // creates a TPC only track from the given esd track
748 // the track has to be deleted by the user
750 // NB. most of the functionality to get a TPC only track from an ESD track is in AliESDtrack, where it should be
751 // there are only missing propagations here that are needed for old data
752 // this function will therefore become obsolete
754 // adapted from code provided by CKB
756 if (!esd->GetPrimaryVertexTPC())
757 return 0; // No TPC vertex no TPC tracks
759 if(!esd->GetPrimaryVertexTPC()->GetStatus())
760 return 0; // TPC Vertex is created by default in AliESDEvent, do not use in this case
762 AliESDtrack* track = esd->GetTrack(iTrack);
766 AliESDtrack *tpcTrack = new AliESDtrack();
768 // This should have been done during the reconstruction
769 // fixed by Juri in r26675
770 // but recalculate for older data CKB
772 track->GetImpactParametersTPC(p,cov);
774 track->RelateToVertexTPC(esd->GetPrimaryVertexTPC(),esd->GetMagneticField(),kVeryBig);
777 // only true if we have a tpc track
778 if (!track->FillTPCOnlyTrack(*tpcTrack))
784 // propagate to Vertex
785 // not needed for normal reconstructed ESDs...
786 // Double_t pTPC[2],covTPC[3];
787 // tpcTrack->PropagateToDCA(esd->GetPrimaryVertexTPC(), esd->GetMagneticField(), 10000, pTPC, covTPC);
792 //____________________________________________________________________
793 TObjArray* AliESDtrackCuts::GetAcceptedTracks(AliESDEvent* esd,Bool_t bTPC)
796 // returns an array of all tracks that pass the cuts
797 // or an array of TPC only tracks (propagated to the TPC vertex during reco)
798 // tracks that pass the cut
800 TObjArray* acceptedTracks = new TObjArray();
802 // loop over esd tracks
803 for (Int_t iTrack = 0; iTrack < esd->GetNumberOfTracks(); iTrack++) {
805 if(!esd->GetPrimaryVertexTPC())return acceptedTracks; // No TPC vertex no TPC tracks
806 if(!esd->GetPrimaryVertexTPC()->GetStatus())return acceptedTracks; // No proper TPC vertex, only the default
808 AliESDtrack *tpcTrack = GetTPCOnlyTrack(esd, iTrack);
812 if (AcceptTrack(tpcTrack)) {
813 acceptedTracks->Add(tpcTrack);
820 AliESDtrack* track = esd->GetTrack(iTrack);
821 if(AcceptTrack(track))
822 acceptedTracks->Add(track);
825 if(bTPC)acceptedTracks->SetOwner(kTRUE);
826 return acceptedTracks;
829 //____________________________________________________________________
830 Int_t AliESDtrackCuts::CountAcceptedTracks(AliESDEvent* esd)
833 // returns an the number of tracks that pass the cuts
838 // loop over esd tracks
839 for (Int_t iTrack = 0; iTrack < esd->GetNumberOfTracks(); iTrack++) {
840 AliESDtrack* track = esd->GetTrack(iTrack);
841 if (AcceptTrack(track))
848 //____________________________________________________________________
849 void AliESDtrackCuts::DefineHistograms(Int_t color) {
851 // diagnostics histograms are defined
856 Bool_t oldStatus = TH1::AddDirectoryStatus();
857 TH1::AddDirectory(kFALSE);
859 //###################################################################################
860 // defining histograms
862 fhCutStatistics = new TH1F("cut_statistics","cut statistics",kNCuts+4,-0.5,kNCuts+3.5);
864 fhCutStatistics->GetXaxis()->SetBinLabel(1,"n tracks");
865 fhCutStatistics->GetXaxis()->SetBinLabel(2,"n cut tracks");
867 fhCutCorrelation = new TH2F("cut_correlation","cut correlation",kNCuts,-0.5,kNCuts-0.5,kNCuts,-0.5,kNCuts-0.5);;
869 for (Int_t i=0; i<kNCuts; i++) {
870 fhCutStatistics->GetXaxis()->SetBinLabel(i+4,fgkCutNames[i]);
871 fhCutCorrelation->GetXaxis()->SetBinLabel(i+1,fgkCutNames[i]);
872 fhCutCorrelation->GetYaxis()->SetBinLabel(i+1,fgkCutNames[i]);
875 fhCutStatistics ->SetLineColor(color);
876 fhCutCorrelation ->SetLineColor(color);
877 fhCutStatistics ->SetLineWidth(2);
878 fhCutCorrelation ->SetLineWidth(2);
880 for (Int_t i=0; i<2; i++) {
881 fhNClustersITS[i] = new TH1F("nClustersITS" ,"",8,-0.5,7.5);
882 fhNClustersTPC[i] = new TH1F("nClustersTPC" ,"",165,-0.5,164.5);
883 fhChi2PerClusterITS[i] = new TH1F("chi2PerClusterITS","",500,0,10);
884 fhChi2PerClusterTPC[i] = new TH1F("chi2PerClusterTPC","",500,0,10);
886 fhC11[i] = new TH1F("covMatrixDiagonal11","",2000,0,20);
887 fhC22[i] = new TH1F("covMatrixDiagonal22","",2000,0,20);
888 fhC33[i] = new TH1F("covMatrixDiagonal33","",1000,0,0.1);
889 fhC44[i] = new TH1F("covMatrixDiagonal44","",1000,0,0.1);
890 fhC55[i] = new TH1F("covMatrixDiagonal55","",1000,0,5);
892 fhDXY[i] = new TH1F("dXY" ,"",500,-10,10);
893 fhDZ[i] = new TH1F("dZ" ,"",500,-10,10);
894 fhDXYDZ[i] = new TH1F("dXYDZ" ,"",500,0,10);
895 fhDXYvsDZ[i] = new TH2F("dXYvsDZ","",200,-10,10,200,-10,10);
897 fhDXYNormalized[i] = new TH1F("dXYNormalized" ,"",500,-10,10);
898 fhDZNormalized[i] = new TH1F("dZNormalized" ,"",500,-10,10);
899 fhDXYvsDZNormalized[i] = new TH2F("dXYvsDZNormalized","",200,-10,10,200,-10,10);
901 fhNSigmaToVertex[i] = new TH1F("nSigmaToVertex","",500,0,10);
903 fhPt[i] = new TH1F("pt" ,"p_{T} distribution;p_{T} (GeV/c)",500,0.0,100.0);
904 fhEta[i] = new TH1F("eta" ,"#eta distribution;#eta",40,-2.0,2.0);
906 fhNClustersITS[i]->SetTitle("n ITS clusters");
907 fhNClustersTPC[i]->SetTitle("n TPC clusters");
908 fhChi2PerClusterITS[i]->SetTitle("#Chi^{2} per ITS cluster");
909 fhChi2PerClusterTPC[i]->SetTitle("#Chi^{2} per TPC cluster");
911 fhC11[i]->SetTitle("cov 11 : #sigma_{y}^{2} [cm^{2}]");
912 fhC22[i]->SetTitle("cov 22 : #sigma_{z}^{2} [cm^{2}]");
913 fhC33[i]->SetTitle("cov 33 : #sigma_{sin(#phi)}^{2}");
914 fhC44[i]->SetTitle("cov 44 : #sigma_{tan(#theta_{dip})}^{2}");
915 fhC55[i]->SetTitle("cov 55 : #sigma_{1/p_{T}}^{2} [(c/GeV)^2]");
917 fhDXY[i]->SetTitle("transverse impact parameter");
918 fhDZ[i]->SetTitle("longitudinal impact parameter");
919 fhDXYDZ[i]->SetTitle("absolute impact parameter;sqrt(dXY**2 + dZ**2) in cm");
920 fhDXYvsDZ[i]->SetXTitle("longitudinal impact parameter");
921 fhDXYvsDZ[i]->SetYTitle("transverse impact parameter");
923 fhDXYNormalized[i]->SetTitle("normalized trans impact par");
924 fhDZNormalized[i]->SetTitle("normalized long impact par");
925 fhDXYvsDZNormalized[i]->SetTitle("normalized long impact par");
926 fhDXYvsDZNormalized[i]->SetYTitle("normalized trans impact par");
927 fhNSigmaToVertex[i]->SetTitle("n #sigma to vertex");
929 fhNClustersITS[i]->SetLineColor(color); fhNClustersITS[i]->SetLineWidth(2);
930 fhNClustersTPC[i]->SetLineColor(color); fhNClustersTPC[i]->SetLineWidth(2);
931 fhChi2PerClusterITS[i]->SetLineColor(color); fhChi2PerClusterITS[i]->SetLineWidth(2);
932 fhChi2PerClusterTPC[i]->SetLineColor(color); fhChi2PerClusterTPC[i]->SetLineWidth(2);
934 fhC11[i]->SetLineColor(color); fhC11[i]->SetLineWidth(2);
935 fhC22[i]->SetLineColor(color); fhC22[i]->SetLineWidth(2);
936 fhC33[i]->SetLineColor(color); fhC33[i]->SetLineWidth(2);
937 fhC44[i]->SetLineColor(color); fhC44[i]->SetLineWidth(2);
938 fhC55[i]->SetLineColor(color); fhC55[i]->SetLineWidth(2);
940 fhDXY[i]->SetLineColor(color); fhDXY[i]->SetLineWidth(2);
941 fhDZ[i]->SetLineColor(color); fhDZ[i]->SetLineWidth(2);
942 fhDXYDZ[i]->SetLineColor(color); fhDXYDZ[i]->SetLineWidth(2);
944 fhDXYNormalized[i]->SetLineColor(color); fhDXYNormalized[i]->SetLineWidth(2);
945 fhDZNormalized[i]->SetLineColor(color); fhDZNormalized[i]->SetLineWidth(2);
946 fhNSigmaToVertex[i]->SetLineColor(color); fhNSigmaToVertex[i]->SetLineWidth(2);
949 // The number of sigmas to the vertex is per definition gaussian
950 ffDTheoretical = new TF1("nSigmaToVertexTheoretical","([0]/2.506628274)*exp(-(x**2)/2)",0,50);
951 ffDTheoretical->SetParameter(0,1);
953 TH1::AddDirectory(oldStatus);
956 //____________________________________________________________________
957 Bool_t AliESDtrackCuts::LoadHistograms(const Char_t* dir)
960 // loads the histograms from a file
961 // if dir is empty a directory with the name of this object is taken (like in SaveHistogram)
967 if (!gDirectory->cd(dir))
970 ffDTheoretical = dynamic_cast<TF1*> (gDirectory->Get("nSigmaToVertexTheory"));
972 fhCutStatistics = dynamic_cast<TH1F*> (gDirectory->Get("cut_statistics"));
973 fhCutCorrelation = dynamic_cast<TH2F*> (gDirectory->Get("cut_correlation"));
975 for (Int_t i=0; i<2; i++) {
978 gDirectory->cd("before_cuts");
981 gDirectory->cd("after_cuts");
983 fhNClustersITS[i] = dynamic_cast<TH1F*> (gDirectory->Get("nClustersITS" ));
984 fhNClustersTPC[i] = dynamic_cast<TH1F*> (gDirectory->Get("nClustersTPC" ));
985 fhChi2PerClusterITS[i] = dynamic_cast<TH1F*> (gDirectory->Get("chi2PerClusterITS"));
986 fhChi2PerClusterTPC[i] = dynamic_cast<TH1F*> (gDirectory->Get("chi2PerClusterTPC"));
988 fhC11[i] = dynamic_cast<TH1F*> (gDirectory->Get("covMatrixDiagonal11"));
989 fhC22[i] = dynamic_cast<TH1F*> (gDirectory->Get("covMatrixDiagonal22"));
990 fhC33[i] = dynamic_cast<TH1F*> (gDirectory->Get("covMatrixDiagonal33"));
991 fhC44[i] = dynamic_cast<TH1F*> (gDirectory->Get("covMatrixDiagonal44"));
992 fhC55[i] = dynamic_cast<TH1F*> (gDirectory->Get("covMatrixDiagonal55"));
994 fhDXY[i] = dynamic_cast<TH1F*> (gDirectory->Get("dXY" ));
995 fhDZ[i] = dynamic_cast<TH1F*> (gDirectory->Get("dZ" ));
996 fhDXYDZ[i] = dynamic_cast<TH1F*> (gDirectory->Get("dXYDZ"));
997 fhDXYvsDZ[i] = dynamic_cast<TH2F*> (gDirectory->Get("dXYvsDZ"));
999 fhDXYNormalized[i] = dynamic_cast<TH1F*> (gDirectory->Get("dXYNormalized" ));
1000 fhDZNormalized[i] = dynamic_cast<TH1F*> (gDirectory->Get("dZNormalized" ));
1001 fhDXYvsDZNormalized[i] = dynamic_cast<TH2F*> (gDirectory->Get("dXYvsDZNormalized"));
1002 fhNSigmaToVertex[i] = dynamic_cast<TH1F*> (gDirectory->Get("nSigmaToVertex"));
1004 fhPt[i] = dynamic_cast<TH1F*> (gDirectory->Get("pt"));
1005 fhEta[i] = dynamic_cast<TH1F*> (gDirectory->Get("eta"));
1007 gDirectory->cd("../");
1010 gDirectory->cd("..");
1015 //____________________________________________________________________
1016 void AliESDtrackCuts::SaveHistograms(const Char_t* dir) {
1018 // saves the histograms in a directory (dir)
1021 if (!fHistogramsOn) {
1022 AliDebug(0, "Histograms not on - cannot save histograms!!!");
1029 gDirectory->mkdir(dir);
1030 gDirectory->cd(dir);
1032 gDirectory->mkdir("before_cuts");
1033 gDirectory->mkdir("after_cuts");
1035 // a factor of 2 is needed since n sigma is positive
1036 ffDTheoretical->SetParameter(0,2*fhNSigmaToVertex[0]->Integral("width"));
1037 ffDTheoretical->Write("nSigmaToVertexTheory");
1039 fhCutStatistics->Write();
1040 fhCutCorrelation->Write();
1042 for (Int_t i=0; i<2; i++) {
1044 gDirectory->cd("before_cuts");
1046 gDirectory->cd("after_cuts");
1048 fhNClustersITS[i] ->Write();
1049 fhNClustersTPC[i] ->Write();
1050 fhChi2PerClusterITS[i] ->Write();
1051 fhChi2PerClusterTPC[i] ->Write();
1061 fhDXYDZ[i] ->Write();
1062 fhDXYvsDZ[i] ->Write();
1064 fhDXYNormalized[i] ->Write();
1065 fhDZNormalized[i] ->Write();
1066 fhDXYvsDZNormalized[i] ->Write();
1067 fhNSigmaToVertex[i] ->Write();
1072 gDirectory->cd("../");
1075 gDirectory->cd("../");
1078 //____________________________________________________________________
1079 void AliESDtrackCuts::DrawHistograms()
1081 // draws some histograms
1083 TCanvas* canvas1 = new TCanvas(Form("%s_1", GetName()), "Track Quality Results1", 800, 800);
1084 canvas1->Divide(2, 2);
1087 fhNClustersTPC[0]->SetStats(kFALSE);
1088 fhNClustersTPC[0]->Draw();
1091 fhChi2PerClusterTPC[0]->SetStats(kFALSE);
1092 fhChi2PerClusterTPC[0]->Draw();
1095 fhNSigmaToVertex[0]->SetStats(kFALSE);
1096 fhNSigmaToVertex[0]->GetXaxis()->SetRangeUser(0, 10);
1097 fhNSigmaToVertex[0]->Draw();
1099 canvas1->SaveAs(Form("%s_%s.gif", GetName(), canvas1->GetName()));
1101 TCanvas* canvas2 = new TCanvas(Form("%s_2", GetName()), "Track Quality Results2", 1200, 800);
1102 canvas2->Divide(3, 2);
1105 fhC11[0]->SetStats(kFALSE);
1110 fhC22[0]->SetStats(kFALSE);
1115 fhC33[0]->SetStats(kFALSE);
1120 fhC44[0]->SetStats(kFALSE);
1125 fhC55[0]->SetStats(kFALSE);
1129 canvas2->SaveAs(Form("%s_%s.gif", GetName(), canvas2->GetName()));
1131 TCanvas* canvas3 = new TCanvas(Form("%s_3", GetName()), "Track Quality Results3", 1200, 800);
1132 canvas3->Divide(3, 2);
1135 fhDXY[0]->SetStats(kFALSE);
1140 fhDZ[0]->SetStats(kFALSE);
1145 fhDXYvsDZ[0]->SetStats(kFALSE);
1147 gPad->SetRightMargin(0.15);
1148 fhDXYvsDZ[0]->Draw("COLZ");
1151 fhDXYNormalized[0]->SetStats(kFALSE);
1153 fhDXYNormalized[0]->Draw();
1156 fhDZNormalized[0]->SetStats(kFALSE);
1158 fhDZNormalized[0]->Draw();
1161 fhDXYvsDZNormalized[0]->SetStats(kFALSE);
1163 gPad->SetRightMargin(0.15);
1164 fhDXYvsDZNormalized[0]->Draw("COLZ");
1166 canvas3->SaveAs(Form("%s_%s.gif", GetName(), canvas3->GetName()));
1168 TCanvas* canvas4 = new TCanvas(Form("%s_4", GetName()), "Track Quality Results4", 800, 500);
1169 canvas4->Divide(2, 1);
1172 fhCutStatistics->SetStats(kFALSE);
1173 fhCutStatistics->LabelsOption("v");
1174 gPad->SetBottomMargin(0.3);
1175 fhCutStatistics->Draw();
1178 fhCutCorrelation->SetStats(kFALSE);
1179 fhCutCorrelation->LabelsOption("v");
1180 gPad->SetBottomMargin(0.3);
1181 gPad->SetLeftMargin(0.3);
1182 fhCutCorrelation->Draw("COLZ");
1184 canvas4->SaveAs(Form("%s_%s.gif", GetName(), canvas4->GetName()));
1187 fhDXYvsDZNormalized[0]->SetStats(kFALSE);
1188 fhDXYvsDZNormalized[0]->DrawCopy("COLZ");
1191 fhNClustersTPC[0]->SetStats(kFALSE);
1192 fhNClustersTPC[0]->DrawCopy();
1195 fhChi2PerClusterITS[0]->SetStats(kFALSE);
1196 fhChi2PerClusterITS[0]->DrawCopy();
1197 fhChi2PerClusterITS[1]->SetLineColor(2);
1198 fhChi2PerClusterITS[1]->DrawCopy("SAME");
1201 fhChi2PerClusterTPC[0]->SetStats(kFALSE);
1202 fhChi2PerClusterTPC[0]->DrawCopy();
1203 fhChi2PerClusterTPC[1]->SetLineColor(2);
1204 fhChi2PerClusterTPC[1]->DrawCopy("SAME");*/