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-commerciatobjl 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"
59 //____________________________________________________________________
60 AliESDtrackCuts::AliESDtrackCuts(const Char_t* name, const Char_t* title) : AliAnalysisCuts(name,title),
61 fCutMinNClusterTPC(0),
62 fCutMinNClusterITS(0),
63 fCutMaxChi2PerClusterTPC(0),
64 fCutMaxChi2PerClusterITS(0),
70 fCutAcceptKinkDaughters(0),
71 fCutRequireTPCRefit(0),
72 fCutRequireITSRefit(0),
73 fCutNsigmaToVertex(0),
74 fCutSigmaToVertexRequired(0),
102 //##############################################################################
103 // setting default cuts
104 SetMinNClustersTPC();
105 SetMinNClustersITS();
106 SetMaxChi2PerClusterTPC();
107 SetMaxChi2PerClusterITS();
108 SetMaxCovDiagonalElements();
109 SetRequireTPCRefit();
110 SetRequireITSRefit();
111 SetAcceptKingDaughters();
112 SetMinNsigmaToVertex();
113 SetRequireSigmaToVertex();
127 //_____________________________________________________________________________
128 AliESDtrackCuts::AliESDtrackCuts(const AliESDtrackCuts &c) : AliAnalysisCuts(c),
129 fCutMinNClusterTPC(0),
130 fCutMinNClusterITS(0),
131 fCutMaxChi2PerClusterTPC(0),
132 fCutMaxChi2PerClusterITS(0),
138 fCutAcceptKinkDaughters(0),
139 fCutRequireTPCRefit(0),
140 fCutRequireITSRefit(0),
141 fCutNsigmaToVertex(0),
142 fCutSigmaToVertexRequired(0),
144 fCutDCAToVertexXY(0),
168 ((AliESDtrackCuts &) c).Copy(*this);
171 AliESDtrackCuts::~AliESDtrackCuts()
177 for (Int_t i=0; i<2; i++) {
179 if (fhNClustersITS[i])
180 delete fhNClustersITS[i];
181 if (fhNClustersTPC[i])
182 delete fhNClustersTPC[i];
183 if (fhChi2PerClusterITS[i])
184 delete fhChi2PerClusterITS[i];
185 if (fhChi2PerClusterTPC[i])
186 delete fhChi2PerClusterTPC[i];
207 if (fhDXYNormalized[i])
208 delete fhDXYNormalized[i];
209 if (fhDZNormalized[i])
210 delete fhDZNormalized[i];
211 if (fhDXYvsDZNormalized[i])
212 delete fhDXYvsDZNormalized[i];
213 if (fhNSigmaToVertex[i])
214 delete fhNSigmaToVertex[i];
222 delete ffDTheoretical;
225 delete fhCutStatistics;
226 if (fhCutCorrelation)
227 delete fhCutCorrelation;
230 void AliESDtrackCuts::Init()
233 // sets everything to zero
236 fCutMinNClusterTPC = 0;
237 fCutMinNClusterITS = 0;
239 fCutMaxChi2PerClusterTPC = 0;
240 fCutMaxChi2PerClusterITS = 0;
248 fCutAcceptKinkDaughters = 0;
249 fCutRequireTPCRefit = 0;
250 fCutRequireITSRefit = 0;
252 fCutNsigmaToVertex = 0;
253 fCutSigmaToVertexRequired = 0;
255 fCutDCAToVertexXY = 0;
272 fHistogramsOn = kFALSE;
274 for (Int_t i=0; i<2; ++i)
276 fhNClustersITS[i] = 0;
277 fhNClustersTPC[i] = 0;
279 fhChi2PerClusterITS[i] = 0;
280 fhChi2PerClusterTPC[i] = 0;
293 fhDXYNormalized[i] = 0;
294 fhDZNormalized[i] = 0;
295 fhDXYvsDZNormalized[i] = 0;
296 fhNSigmaToVertex[i] = 0;
304 fhCutCorrelation = 0;
307 //_____________________________________________________________________________
308 AliESDtrackCuts &AliESDtrackCuts::operator=(const AliESDtrackCuts &c)
311 // Assignment operator
314 if (this != &c) ((AliESDtrackCuts &) c).Copy(*this);
318 //_____________________________________________________________________________
319 void AliESDtrackCuts::Copy(TObject &c) const
325 AliESDtrackCuts& target = (AliESDtrackCuts &) c;
329 target.fCutMinNClusterTPC = fCutMinNClusterTPC;
330 target.fCutMinNClusterITS = fCutMinNClusterITS;
332 target.fCutMaxChi2PerClusterTPC = fCutMaxChi2PerClusterTPC;
333 target.fCutMaxChi2PerClusterITS = fCutMaxChi2PerClusterITS;
335 target.fCutMaxC11 = fCutMaxC11;
336 target.fCutMaxC22 = fCutMaxC22;
337 target.fCutMaxC33 = fCutMaxC33;
338 target.fCutMaxC44 = fCutMaxC44;
339 target.fCutMaxC55 = fCutMaxC55;
341 target.fCutAcceptKinkDaughters = fCutAcceptKinkDaughters;
342 target.fCutRequireTPCRefit = fCutRequireTPCRefit;
343 target.fCutRequireITSRefit = fCutRequireITSRefit;
345 target.fCutNsigmaToVertex = fCutNsigmaToVertex;
346 target.fCutSigmaToVertexRequired = fCutSigmaToVertexRequired;
347 target.fCutDCAToVertex = fCutDCAToVertex;
348 target.fCutDCAToVertexXY = fCutDCAToVertexXY;
350 target.fPMin = fPMin;
351 target.fPMax = fPMax;
352 target.fPtMin = fPtMin;
353 target.fPtMax = fPtMax;
354 target.fPxMin = fPxMin;
355 target.fPxMax = fPxMax;
356 target.fPyMin = fPyMin;
357 target.fPyMax = fPyMax;
358 target.fPzMin = fPzMin;
359 target.fPzMax = fPzMax;
360 target.fEtaMin = fEtaMin;
361 target.fEtaMax = fEtaMax;
362 target.fRapMin = fRapMin;
363 target.fRapMax = fRapMax;
365 target.fHistogramsOn = fHistogramsOn;
367 for (Int_t i=0; i<2; ++i)
369 if (fhNClustersITS[i]) target.fhNClustersITS[i] = (TH1F*) fhNClustersITS[i]->Clone();
370 if (fhNClustersTPC[i]) target.fhNClustersTPC[i] = (TH1F*) fhNClustersTPC[i]->Clone();
372 if (fhChi2PerClusterITS[i]) target.fhChi2PerClusterITS[i] = (TH1F*) fhChi2PerClusterITS[i]->Clone();
373 if (fhChi2PerClusterTPC[i]) target.fhChi2PerClusterTPC[i] = (TH1F*) fhChi2PerClusterTPC[i]->Clone();
375 if (fhC11[i]) target.fhC11[i] = (TH1F*) fhC11[i]->Clone();
376 if (fhC22[i]) target.fhC22[i] = (TH1F*) fhC22[i]->Clone();
377 if (fhC33[i]) target.fhC33[i] = (TH1F*) fhC33[i]->Clone();
378 if (fhC44[i]) target.fhC44[i] = (TH1F*) fhC44[i]->Clone();
379 if (fhC55[i]) target.fhC55[i] = (TH1F*) fhC55[i]->Clone();
381 if (fhDXY[i]) target.fhDXY[i] = (TH1F*) fhDXY[i]->Clone();
382 if (fhDZ[i]) target.fhDZ[i] = (TH1F*) fhDZ[i]->Clone();
383 if (fhDXYDZ[i]) target.fhDXYDZ[i] = (TH1F*) fhDXYDZ[i]->Clone();
384 if (fhDXYvsDZ[i]) target.fhDXYvsDZ[i] = (TH2F*) fhDXYvsDZ[i]->Clone();
386 if (fhDXYNormalized[i]) target.fhDXYNormalized[i] = (TH1F*) fhDXYNormalized[i]->Clone();
387 if (fhDZNormalized[i]) target.fhDZNormalized[i] = (TH1F*) fhDZNormalized[i]->Clone();
388 if (fhDXYvsDZNormalized[i]) target.fhDXYvsDZNormalized[i] = (TH2F*) fhDXYvsDZNormalized[i]->Clone();
389 if (fhNSigmaToVertex[i]) target.fhNSigmaToVertex[i] = (TH1F*) fhNSigmaToVertex[i]->Clone();
391 if (fhPt[i]) target.fhPt[i] = (TH1F*) fhPt[i]->Clone();
392 if (fhEta[i]) target.fhEta[i] = (TH1F*) fhEta[i]->Clone();
394 if (ffDTheoretical) target.ffDTheoretical = (TF1*) ffDTheoretical->Clone();
396 if (fhCutStatistics) target.fhCutStatistics = (TH1F*) fhCutStatistics->Clone();
397 if (fhCutCorrelation) target.fhCutCorrelation = (TH2F*) fhCutCorrelation->Clone();
402 //_____________________________________________________________________________
403 Long64_t AliESDtrackCuts::Merge(TCollection* list) {
404 // Merge a list of AliESDtrackCuts objects with this (needed for PROOF)
405 // Returns the number of merged objects (including this)
412 TIterator* iter = list->MakeIterator();
415 // collection of measured and generated histograms
417 while ((obj = iter->Next())) {
419 AliESDtrackCuts* entry = dynamic_cast<AliESDtrackCuts*>(obj);
423 if (!entry->fHistogramsOn)
426 for (Int_t i=0; i<2; i++) {
428 fhNClustersITS[i] ->Add(entry->fhNClustersITS[i] );
429 fhNClustersTPC[i] ->Add(entry->fhNClustersTPC[i] );
431 fhChi2PerClusterITS[i] ->Add(entry->fhChi2PerClusterITS[i]);
432 fhChi2PerClusterTPC[i] ->Add(entry->fhChi2PerClusterTPC[i]);
434 fhC11[i] ->Add(entry->fhC11[i] );
435 fhC22[i] ->Add(entry->fhC22[i] );
436 fhC33[i] ->Add(entry->fhC33[i] );
437 fhC44[i] ->Add(entry->fhC44[i] );
438 fhC55[i] ->Add(entry->fhC55[i] );
440 fhDXY[i] ->Add(entry->fhDXY[i] );
441 fhDZ[i] ->Add(entry->fhDZ[i] );
442 fhDXYDZ[i] ->Add(entry->fhDXYDZ[i] );
443 fhDXYvsDZ[i] ->Add(entry->fhDXYvsDZ[i] );
445 fhDXYNormalized[i] ->Add(entry->fhDXYNormalized[i] );
446 fhDZNormalized[i] ->Add(entry->fhDZNormalized[i] );
447 fhDXYvsDZNormalized[i] ->Add(entry->fhDXYvsDZNormalized[i]);
448 fhNSigmaToVertex[i] ->Add(entry->fhNSigmaToVertex[i]);
450 fhPt[i] ->Add(entry->fhPt[i]);
451 fhEta[i] ->Add(entry->fhEta[i]);
454 fhCutStatistics ->Add(entry->fhCutStatistics);
455 fhCutCorrelation ->Add(entry->fhCutCorrelation);
463 //____________________________________________________________________
464 Float_t AliESDtrackCuts::GetSigmaToVertex(AliESDtrack* esdTrack)
466 // Calculates the number of sigma to the vertex.
471 esdTrack->GetImpactParameters(b,bCov);
473 if (bCov[0]<=0 || bCov[2]<=0) {
474 AliDebugClass(1, "Estimated b resolution lower or equal zero!");
475 bCov[0]=0; bCov[2]=0;
477 bRes[0] = TMath::Sqrt(bCov[0]);
478 bRes[1] = TMath::Sqrt(bCov[2]);
480 // -----------------------------------
481 // How to get to a n-sigma cut?
483 // The accumulated statistics from 0 to d is
485 // -> Erf(d/Sqrt(2)) for a 1-dim gauss (d = n_sigma)
486 // -> 1 - Exp(-d**2) for a 2-dim gauss (d*d = dx*dx + dy*dy != n_sigma)
488 // It means that for a 2-dim gauss: n_sigma(d) = Sqrt(2)*ErfInv(1 - Exp((-x**2)/2)
489 // Can this be expressed in a different way?
491 if (bRes[0] == 0 || bRes[1] ==0)
494 Float_t d = TMath::Sqrt(TMath::Power(b[0]/bRes[0],2) + TMath::Power(b[1]/bRes[1],2));
496 // work around precision problem
497 // if d is too big, TMath::Exp(...) gets 0, and TMath::ErfInverse(1) that should be infinite, gets 0 :(
498 // 1e-15 corresponds to nsigma ~ 7.7
499 if (TMath::Exp(-d * d / 2) < 1e-15)
502 Float_t nSigma = TMath::ErfInverse(1 - TMath::Exp(-d * d / 2)) * TMath::Sqrt(2);
506 void AliESDtrackCuts::EnableNeededBranches(TTree* tree)
508 // enables the branches needed by AcceptTrack, for a list see comment of AcceptTrack
510 tree->SetBranchStatus("fTracks.fFlags", 1);
511 tree->SetBranchStatus("fTracks.fITSncls", 1);
512 tree->SetBranchStatus("fTracks.fTPCncls", 1);
513 tree->SetBranchStatus("fTracks.fITSchi2", 1);
514 tree->SetBranchStatus("fTracks.fTPCchi2", 1);
515 tree->SetBranchStatus("fTracks.fC*", 1);
516 tree->SetBranchStatus("fTracks.fD", 1);
517 tree->SetBranchStatus("fTracks.fZ", 1);
518 tree->SetBranchStatus("fTracks.fCdd", 1);
519 tree->SetBranchStatus("fTracks.fCdz", 1);
520 tree->SetBranchStatus("fTracks.fCzz", 1);
521 tree->SetBranchStatus("fTracks.fP*", 1);
522 tree->SetBranchStatus("fTracks.fR*", 1);
523 tree->SetBranchStatus("fTracks.fKinkIndexes*", 1);
526 //____________________________________________________________________
528 AliESDtrackCuts::AcceptTrack(AliESDtrack* esdTrack) {
530 // figure out if the tracks survives all the track cuts defined
532 // the different quality parameter and kinematic values are first
533 // retrieved from the track. then it is found out what cuts the
534 // track did not survive and finally the cuts are imposed.
536 // this function needs the following branches:
542 // fTracks.fC //GetExternalCovariance
543 // fTracks.fD //GetImpactParameters
544 // fTracks.fZ //GetImpactParameters
545 // fTracks.fCdd //GetImpactParameters
546 // fTracks.fCdz //GetImpactParameters
547 // fTracks.fCzz //GetImpactParameters
548 // fTracks.fP //GetPxPyPz
549 // fTracks.fR //GetMass
550 // fTracks.fP //GetMass
551 // fTracks.fKinkIndexes
554 UInt_t status = esdTrack->GetStatus();
556 // getting quality parameters from the ESD track
557 Int_t nClustersITS = esdTrack->GetITSclusters(0);
558 Int_t nClustersTPC = esdTrack->GetTPCclusters(0);
560 Float_t chi2PerClusterITS = -1;
561 Float_t chi2PerClusterTPC = -1;
563 chi2PerClusterITS = esdTrack->GetITSchi2()/Float_t(nClustersITS);
565 chi2PerClusterTPC = esdTrack->GetTPCchi2()/Float_t(nClustersTPC);
567 esdTrack->GetExternalCovariance(extCov);
569 // getting the track to vertex parameters
570 Float_t nSigmaToVertex = GetSigmaToVertex(esdTrack);
574 esdTrack->GetImpactParameters(b,bCov);
575 if (bCov[0]<=0 || bCov[2]<=0) {
576 AliDebug(1, "Estimated b resolution lower or equal zero!");
577 bCov[0]=0; bCov[2]=0;
579 Float_t dcaToVertex = TMath::Sqrt(b[0]*b[0] + b[1]*b[1]);
581 Float_t dcaToVertexXY = b[0];
583 // getting the kinematic variables of the track
584 // (assuming the mass is known)
586 esdTrack->GetPxPyPz(p);
588 Float_t momentum = TMath::Sqrt(TMath::Power(p[0],2) + TMath::Power(p[1],2) + TMath::Power(p[2],2));
589 Float_t pt = TMath::Sqrt(TMath::Power(p[0],2) + TMath::Power(p[1],2));
590 Float_t energy = TMath::Sqrt(TMath::Power(esdTrack->GetMass(),2) + TMath::Power(momentum,2));
593 //y-eta related calculations
596 if((momentum != TMath::Abs(p[2]))&&(momentum != 0))
597 eta = 0.5*TMath::Log((momentum + p[2])/(momentum - p[2]));
598 if((energy != TMath::Abs(p[2]))&&(momentum != 0))
599 y = 0.5*TMath::Log((energy + p[2])/(energy - p[2]));
602 //########################################################################
606 for (Int_t i=0; i<kNCuts; i++) cuts[i]=kFALSE;
608 // track quality cuts
609 if (fCutRequireTPCRefit && (status&AliESDtrack::kTPCrefit)==0)
611 if (fCutRequireITSRefit && (status&AliESDtrack::kITSrefit)==0)
613 if (nClustersTPC<fCutMinNClusterTPC)
615 if (nClustersITS<fCutMinNClusterITS)
617 if (chi2PerClusterTPC>fCutMaxChi2PerClusterTPC)
619 if (chi2PerClusterITS>fCutMaxChi2PerClusterITS)
621 if (extCov[0] > fCutMaxC11)
623 if (extCov[2] > fCutMaxC22)
625 if (extCov[5] > fCutMaxC33)
627 if (extCov[9] > fCutMaxC44)
629 if (extCov[14] > fCutMaxC55)
631 if (nSigmaToVertex > fCutNsigmaToVertex && fCutSigmaToVertexRequired)
633 // if n sigma could not be calculated
634 if (nSigmaToVertex<0 && fCutSigmaToVertexRequired)
636 if (!fCutAcceptKinkDaughters && esdTrack->GetKinkIndex(0)>0)
638 // track kinematics cut
639 if((momentum < fPMin) || (momentum > fPMax))
641 if((pt < fPtMin) || (pt > fPtMax))
643 if((p[0] < fPxMin) || (p[0] > fPxMax))
645 if((p[1] < fPyMin) || (p[1] > fPyMax))
647 if((p[2] < fPzMin) || (p[2] > fPzMax))
649 if((eta < fEtaMin) || (eta > fEtaMax))
651 if((y < fRapMin) || (y > fRapMax))
653 if (dcaToVertex > fCutDCAToVertex)
655 if (dcaToVertexXY > fCutDCAToVertexXY)
659 for (Int_t i=0; i<kNCuts; i++)
660 if (cuts[i]) cut = kTRUE;
664 //########################################################################
665 // filling histograms
667 fhCutStatistics->Fill(fhCutStatistics->GetBinCenter(fhCutStatistics->GetXaxis()->FindBin("n tracks")));
669 fhCutStatistics->Fill(fhCutStatistics->GetBinCenter(fhCutStatistics->GetXaxis()->FindBin("n cut tracks")));
671 for (Int_t i=0; i<kNCuts; i++) {
673 fhCutStatistics->Fill(fhCutStatistics->GetBinCenter(fhCutStatistics->GetXaxis()->FindBin(fgkCutNames[i])));
675 for (Int_t j=i; j<kNCuts; j++) {
676 if (cuts[i] && cuts[j]) {
677 Float_t xC = fhCutCorrelation->GetXaxis()->GetBinCenter(fhCutCorrelation->GetXaxis()->FindBin(fgkCutNames[i]));
678 Float_t yC = fhCutCorrelation->GetYaxis()->GetBinCenter(fhCutCorrelation->GetYaxis()->FindBin(fgkCutNames[j]));
679 fhCutCorrelation->Fill(xC, yC);
685 // now we loop over the filling of the histograms twice: once "before" the cut, once "after"
686 // the code is not in a function due to too many local variables that would need to be passed
688 for (Int_t id = 0; id < 2; id++)
690 // id = 0 --> before cut
691 // id = 1 --> after cut
695 fhNClustersITS[id]->Fill(nClustersITS);
696 fhNClustersTPC[id]->Fill(nClustersTPC);
697 fhChi2PerClusterITS[id]->Fill(chi2PerClusterITS);
698 fhChi2PerClusterTPC[id]->Fill(chi2PerClusterTPC);
700 fhC11[id]->Fill(extCov[0]);
701 fhC22[id]->Fill(extCov[2]);
702 fhC33[id]->Fill(extCov[5]);
703 fhC44[id]->Fill(extCov[9]);
704 fhC55[id]->Fill(extCov[14]);
707 fhEta[id]->Fill(eta);
710 bRes[0] = TMath::Sqrt(bCov[0]);
711 bRes[1] = TMath::Sqrt(bCov[2]);
713 fhDZ[id]->Fill(b[1]);
714 fhDXY[id]->Fill(b[0]);
715 fhDXYDZ[id]->Fill(dcaToVertex);
716 fhDXYvsDZ[id]->Fill(b[1],b[0]);
718 if (bRes[0]!=0 && bRes[1]!=0) {
719 fhDZNormalized[id]->Fill(b[1]/bRes[1]);
720 fhDXYNormalized[id]->Fill(b[0]/bRes[0]);
721 fhDXYvsDZNormalized[id]->Fill(b[1]/bRes[1], b[0]/bRes[0]);
722 fhNSigmaToVertex[id]->Fill(nSigmaToVertex);
734 //____________________________________________________________________
735 AliESDtrack* AliESDtrackCuts::GetTPCOnlyTrack(AliESDEvent* esd, Int_t iTrack)
737 // creates a TPC only track from the given esd track
738 // the track has to be deleted by the user
740 // NB. most of the functionality to get a TPC only track from an ESD track is in AliESDtrack, where it should be
741 // there are only missing propagations here that are needed for old data
742 // this function will therefore become obsolete
744 // adapted from code provided by CKB
746 if (!esd->GetPrimaryVertexTPC())
747 return 0; // No TPC vertex no TPC tracks
749 if(!esd->GetPrimaryVertexTPC()->GetStatus())
750 return 0; // TPC Vertex is created by default in AliESDEvent, do not use in this case
753 AliESDtrack* track = esd->GetTrack(iTrack);
757 AliESDtrack *tpcTrack = new AliESDtrack();
759 // This should have been done during the reconstruction
760 // fixed by Juri in r26675
761 // but recalculate for older data CKB
763 track->GetImpactParametersTPC(p,cov);
765 track->RelateToVertexTPC(esd->GetPrimaryVertexTPC(),esd->GetMagneticField(),kVeryBig);
768 // only true if we have a tpc track
769 if (!track->FillTPCOnlyTrack(*tpcTrack))
775 // propagate to Vertex
776 // not needed for normal reconstructed ESDs...
777 // Double_t pTPC[2],covTPC[3];
778 // tpcTrack->PropagateToDCA(esd->GetPrimaryVertexTPC(), esd->GetMagneticField(), 10000, pTPC, covTPC);
783 //____________________________________________________________________
784 TObjArray* AliESDtrackCuts::GetAcceptedTracks(AliESDEvent* esd,Bool_t bTPC)
787 // returns an array of all tracks that pass the cuts
788 // or an array of TPC only tracks (propagated to the TPC vertex during reco)
789 // tracks that pass the cut
791 TObjArray* acceptedTracks = new TObjArray();
793 // loop over esd tracks
794 for (Int_t iTrack = 0; iTrack < esd->GetNumberOfTracks(); iTrack++) {
796 if(!esd->GetPrimaryVertexTPC())return acceptedTracks; // No TPC vertex no TPC tracks
797 if(!esd->GetPrimaryVertexTPC()->GetStatus())return acceptedTracks; // No proper TPC vertex, only the default
799 AliESDtrack *tpcTrack = GetTPCOnlyTrack(esd, iTrack);
803 if (AcceptTrack(tpcTrack)) {
804 acceptedTracks->Add(tpcTrack);
811 AliESDtrack* track = esd->GetTrack(iTrack);
812 if(AcceptTrack(track))
813 acceptedTracks->Add(track);
816 if(bTPC)acceptedTracks->SetOwner(kTRUE);
817 return acceptedTracks;
820 //____________________________________________________________________
821 Int_t AliESDtrackCuts::CountAcceptedTracks(AliESDEvent* esd)
824 // returns an the number of tracks that pass the cuts
829 // loop over esd tracks
830 for (Int_t iTrack = 0; iTrack < esd->GetNumberOfTracks(); iTrack++) {
831 AliESDtrack* track = esd->GetTrack(iTrack);
832 if (AcceptTrack(track))
839 //____________________________________________________________________
840 void AliESDtrackCuts::DefineHistograms(Int_t color) {
842 // diagnostics histograms are defined
847 Bool_t oldStatus = TH1::AddDirectoryStatus();
848 TH1::AddDirectory(kFALSE);
850 //###################################################################################
851 // defining histograms
853 fhCutStatistics = new TH1F("cut_statistics","cut statistics",kNCuts+4,-0.5,kNCuts+3.5);
855 fhCutStatistics->GetXaxis()->SetBinLabel(1,"n tracks");
856 fhCutStatistics->GetXaxis()->SetBinLabel(2,"n cut tracks");
858 fhCutCorrelation = new TH2F("cut_correlation","cut correlation",kNCuts,-0.5,kNCuts-0.5,kNCuts,-0.5,kNCuts-0.5);;
860 for (Int_t i=0; i<kNCuts; i++) {
861 fhCutStatistics->GetXaxis()->SetBinLabel(i+4,fgkCutNames[i]);
862 fhCutCorrelation->GetXaxis()->SetBinLabel(i+1,fgkCutNames[i]);
863 fhCutCorrelation->GetYaxis()->SetBinLabel(i+1,fgkCutNames[i]);
866 fhCutStatistics ->SetLineColor(color);
867 fhCutCorrelation ->SetLineColor(color);
868 fhCutStatistics ->SetLineWidth(2);
869 fhCutCorrelation ->SetLineWidth(2);
871 for (Int_t i=0; i<2; i++) {
872 fhNClustersITS[i] = new TH1F("nClustersITS" ,"",8,-0.5,7.5);
873 fhNClustersTPC[i] = new TH1F("nClustersTPC" ,"",165,-0.5,164.5);
874 fhChi2PerClusterITS[i] = new TH1F("chi2PerClusterITS","",500,0,10);
875 fhChi2PerClusterTPC[i] = new TH1F("chi2PerClusterTPC","",500,0,10);
877 fhC11[i] = new TH1F("covMatrixDiagonal11","",2000,0,20);
878 fhC22[i] = new TH1F("covMatrixDiagonal22","",2000,0,20);
879 fhC33[i] = new TH1F("covMatrixDiagonal33","",1000,0,0.1);
880 fhC44[i] = new TH1F("covMatrixDiagonal44","",1000,0,0.1);
881 fhC55[i] = new TH1F("covMatrixDiagonal55","",1000,0,5);
883 fhDXY[i] = new TH1F("dXY" ,"",500,-10,10);
884 fhDZ[i] = new TH1F("dZ" ,"",500,-10,10);
885 fhDXYDZ[i] = new TH1F("dXYDZ" ,"",500,0,10);
886 fhDXYvsDZ[i] = new TH2F("dXYvsDZ","",200,-10,10,200,-10,10);
888 fhDXYNormalized[i] = new TH1F("dXYNormalized" ,"",500,-10,10);
889 fhDZNormalized[i] = new TH1F("dZNormalized" ,"",500,-10,10);
890 fhDXYvsDZNormalized[i] = new TH2F("dXYvsDZNormalized","",200,-10,10,200,-10,10);
892 fhNSigmaToVertex[i] = new TH1F("nSigmaToVertex","",500,0,10);
894 fhPt[i] = new TH1F("pt" ,"p_{T} distribution;p_{T} (GeV/c)",500,0.0,100.0);
895 fhEta[i] = new TH1F("eta" ,"#eta distribution;#eta",40,-2.0,2.0);
897 fhNClustersITS[i]->SetTitle("n ITS clusters");
898 fhNClustersTPC[i]->SetTitle("n TPC clusters");
899 fhChi2PerClusterITS[i]->SetTitle("#Chi^{2} per ITS cluster");
900 fhChi2PerClusterTPC[i]->SetTitle("#Chi^{2} per TPC cluster");
902 fhC11[i]->SetTitle("cov 11 : #sigma_{y}^{2} [cm^{2}]");
903 fhC22[i]->SetTitle("cov 22 : #sigma_{z}^{2} [cm^{2}]");
904 fhC33[i]->SetTitle("cov 33 : #sigma_{sin(#phi)}^{2}");
905 fhC44[i]->SetTitle("cov 44 : #sigma_{tan(#theta_{dip})}^{2}");
906 fhC55[i]->SetTitle("cov 55 : #sigma_{1/p_{T}}^{2} [(c/GeV)^2]");
908 fhDXY[i]->SetTitle("transverse impact parameter");
909 fhDZ[i]->SetTitle("longitudinal impact parameter");
910 fhDXYDZ[i]->SetTitle("absolute impact parameter;sqrt(dXY**2 + dZ**2) in cm");
911 fhDXYvsDZ[i]->SetXTitle("longitudinal impact parameter");
912 fhDXYvsDZ[i]->SetYTitle("transverse impact parameter");
914 fhDXYNormalized[i]->SetTitle("normalized trans impact par");
915 fhDZNormalized[i]->SetTitle("normalized long impact par");
916 fhDXYvsDZNormalized[i]->SetTitle("normalized long impact par");
917 fhDXYvsDZNormalized[i]->SetYTitle("normalized trans impact par");
918 fhNSigmaToVertex[i]->SetTitle("n #sigma to vertex");
920 fhNClustersITS[i]->SetLineColor(color); fhNClustersITS[i]->SetLineWidth(2);
921 fhNClustersTPC[i]->SetLineColor(color); fhNClustersTPC[i]->SetLineWidth(2);
922 fhChi2PerClusterITS[i]->SetLineColor(color); fhChi2PerClusterITS[i]->SetLineWidth(2);
923 fhChi2PerClusterTPC[i]->SetLineColor(color); fhChi2PerClusterTPC[i]->SetLineWidth(2);
925 fhC11[i]->SetLineColor(color); fhC11[i]->SetLineWidth(2);
926 fhC22[i]->SetLineColor(color); fhC22[i]->SetLineWidth(2);
927 fhC33[i]->SetLineColor(color); fhC33[i]->SetLineWidth(2);
928 fhC44[i]->SetLineColor(color); fhC44[i]->SetLineWidth(2);
929 fhC55[i]->SetLineColor(color); fhC55[i]->SetLineWidth(2);
931 fhDXY[i]->SetLineColor(color); fhDXY[i]->SetLineWidth(2);
932 fhDZ[i]->SetLineColor(color); fhDZ[i]->SetLineWidth(2);
933 fhDXYDZ[i]->SetLineColor(color); fhDXYDZ[i]->SetLineWidth(2);
935 fhDXYNormalized[i]->SetLineColor(color); fhDXYNormalized[i]->SetLineWidth(2);
936 fhDZNormalized[i]->SetLineColor(color); fhDZNormalized[i]->SetLineWidth(2);
937 fhNSigmaToVertex[i]->SetLineColor(color); fhNSigmaToVertex[i]->SetLineWidth(2);
940 // The number of sigmas to the vertex is per definition gaussian
941 ffDTheoretical = new TF1("nSigmaToVertexTheoretical","([0]/2.506628274)*exp(-(x**2)/2)",0,50);
942 ffDTheoretical->SetParameter(0,1);
944 TH1::AddDirectory(oldStatus);
947 //____________________________________________________________________
948 Bool_t AliESDtrackCuts::LoadHistograms(const Char_t* dir)
951 // loads the histograms from a file
952 // if dir is empty a directory with the name of this object is taken (like in SaveHistogram)
958 if (!gDirectory->cd(dir))
961 ffDTheoretical = dynamic_cast<TF1*> (gDirectory->Get("nSigmaToVertexTheory"));
963 fhCutStatistics = dynamic_cast<TH1F*> (gDirectory->Get("cut_statistics"));
964 fhCutCorrelation = dynamic_cast<TH2F*> (gDirectory->Get("cut_correlation"));
966 for (Int_t i=0; i<2; i++) {
969 gDirectory->cd("before_cuts");
972 gDirectory->cd("after_cuts");
974 fhNClustersITS[i] = dynamic_cast<TH1F*> (gDirectory->Get("nClustersITS" ));
975 fhNClustersTPC[i] = dynamic_cast<TH1F*> (gDirectory->Get("nClustersTPC" ));
976 fhChi2PerClusterITS[i] = dynamic_cast<TH1F*> (gDirectory->Get("chi2PerClusterITS"));
977 fhChi2PerClusterTPC[i] = dynamic_cast<TH1F*> (gDirectory->Get("chi2PerClusterTPC"));
979 fhC11[i] = dynamic_cast<TH1F*> (gDirectory->Get("covMatrixDiagonal11"));
980 fhC22[i] = dynamic_cast<TH1F*> (gDirectory->Get("covMatrixDiagonal22"));
981 fhC33[i] = dynamic_cast<TH1F*> (gDirectory->Get("covMatrixDiagonal33"));
982 fhC44[i] = dynamic_cast<TH1F*> (gDirectory->Get("covMatrixDiagonal44"));
983 fhC55[i] = dynamic_cast<TH1F*> (gDirectory->Get("covMatrixDiagonal55"));
985 fhDXY[i] = dynamic_cast<TH1F*> (gDirectory->Get("dXY" ));
986 fhDZ[i] = dynamic_cast<TH1F*> (gDirectory->Get("dZ" ));
987 fhDXYDZ[i] = dynamic_cast<TH1F*> (gDirectory->Get("dXYDZ"));
988 fhDXYvsDZ[i] = dynamic_cast<TH2F*> (gDirectory->Get("dXYvsDZ"));
990 fhDXYNormalized[i] = dynamic_cast<TH1F*> (gDirectory->Get("dXYNormalized" ));
991 fhDZNormalized[i] = dynamic_cast<TH1F*> (gDirectory->Get("dZNormalized" ));
992 fhDXYvsDZNormalized[i] = dynamic_cast<TH2F*> (gDirectory->Get("dXYvsDZNormalized"));
993 fhNSigmaToVertex[i] = dynamic_cast<TH1F*> (gDirectory->Get("nSigmaToVertex"));
995 fhPt[i] = dynamic_cast<TH1F*> (gDirectory->Get("pt"));
996 fhEta[i] = dynamic_cast<TH1F*> (gDirectory->Get("eta"));
998 gDirectory->cd("../");
1001 gDirectory->cd("..");
1006 //____________________________________________________________________
1007 void AliESDtrackCuts::SaveHistograms(const Char_t* dir) {
1009 // saves the histograms in a directory (dir)
1012 if (!fHistogramsOn) {
1013 AliDebug(0, "Histograms not on - cannot save histograms!!!");
1020 gDirectory->mkdir(dir);
1021 gDirectory->cd(dir);
1023 gDirectory->mkdir("before_cuts");
1024 gDirectory->mkdir("after_cuts");
1026 // a factor of 2 is needed since n sigma is positive
1027 ffDTheoretical->SetParameter(0,2*fhNSigmaToVertex[0]->Integral("width"));
1028 ffDTheoretical->Write("nSigmaToVertexTheory");
1030 fhCutStatistics->Write();
1031 fhCutCorrelation->Write();
1033 for (Int_t i=0; i<2; i++) {
1035 gDirectory->cd("before_cuts");
1037 gDirectory->cd("after_cuts");
1039 fhNClustersITS[i] ->Write();
1040 fhNClustersTPC[i] ->Write();
1041 fhChi2PerClusterITS[i] ->Write();
1042 fhChi2PerClusterTPC[i] ->Write();
1052 fhDXYDZ[i] ->Write();
1053 fhDXYvsDZ[i] ->Write();
1055 fhDXYNormalized[i] ->Write();
1056 fhDZNormalized[i] ->Write();
1057 fhDXYvsDZNormalized[i] ->Write();
1058 fhNSigmaToVertex[i] ->Write();
1063 gDirectory->cd("../");
1066 gDirectory->cd("../");
1069 //____________________________________________________________________
1070 void AliESDtrackCuts::DrawHistograms()
1072 // draws some histograms
1074 TCanvas* canvas1 = new TCanvas(Form("%s_1", GetName()), "Track Quality Results1", 800, 800);
1075 canvas1->Divide(2, 2);
1078 fhNClustersTPC[0]->SetStats(kFALSE);
1079 fhNClustersTPC[0]->Draw();
1082 fhChi2PerClusterTPC[0]->SetStats(kFALSE);
1083 fhChi2PerClusterTPC[0]->Draw();
1086 fhNSigmaToVertex[0]->SetStats(kFALSE);
1087 fhNSigmaToVertex[0]->GetXaxis()->SetRangeUser(0, 10);
1088 fhNSigmaToVertex[0]->Draw();
1090 canvas1->SaveAs(Form("%s_%s.gif", GetName(), canvas1->GetName()));
1092 TCanvas* canvas2 = new TCanvas(Form("%s_2", GetName()), "Track Quality Results2", 1200, 800);
1093 canvas2->Divide(3, 2);
1096 fhC11[0]->SetStats(kFALSE);
1101 fhC22[0]->SetStats(kFALSE);
1106 fhC33[0]->SetStats(kFALSE);
1111 fhC44[0]->SetStats(kFALSE);
1116 fhC55[0]->SetStats(kFALSE);
1120 canvas2->SaveAs(Form("%s_%s.gif", GetName(), canvas2->GetName()));
1122 TCanvas* canvas3 = new TCanvas(Form("%s_3", GetName()), "Track Quality Results3", 1200, 800);
1123 canvas3->Divide(3, 2);
1126 fhDXY[0]->SetStats(kFALSE);
1131 fhDZ[0]->SetStats(kFALSE);
1136 fhDXYvsDZ[0]->SetStats(kFALSE);
1138 gPad->SetRightMargin(0.15);
1139 fhDXYvsDZ[0]->Draw("COLZ");
1142 fhDXYNormalized[0]->SetStats(kFALSE);
1144 fhDXYNormalized[0]->Draw();
1147 fhDZNormalized[0]->SetStats(kFALSE);
1149 fhDZNormalized[0]->Draw();
1152 fhDXYvsDZNormalized[0]->SetStats(kFALSE);
1154 gPad->SetRightMargin(0.15);
1155 fhDXYvsDZNormalized[0]->Draw("COLZ");
1157 canvas3->SaveAs(Form("%s_%s.gif", GetName(), canvas3->GetName()));
1159 TCanvas* canvas4 = new TCanvas(Form("%s_4", GetName()), "Track Quality Results4", 800, 500);
1160 canvas4->Divide(2, 1);
1163 fhCutStatistics->SetStats(kFALSE);
1164 fhCutStatistics->LabelsOption("v");
1165 gPad->SetBottomMargin(0.3);
1166 fhCutStatistics->Draw();
1169 fhCutCorrelation->SetStats(kFALSE);
1170 fhCutCorrelation->LabelsOption("v");
1171 gPad->SetBottomMargin(0.3);
1172 gPad->SetLeftMargin(0.3);
1173 fhCutCorrelation->Draw("COLZ");
1175 canvas4->SaveAs(Form("%s_%s.gif", GetName(), canvas4->GetName()));
1178 fhDXYvsDZNormalized[0]->SetStats(kFALSE);
1179 fhDXYvsDZNormalized[0]->DrawCopy("COLZ");
1182 fhNClustersTPC[0]->SetStats(kFALSE);
1183 fhNClustersTPC[0]->DrawCopy();
1186 fhChi2PerClusterITS[0]->SetStats(kFALSE);
1187 fhChi2PerClusterITS[0]->DrawCopy();
1188 fhChi2PerClusterITS[1]->SetLineColor(2);
1189 fhChi2PerClusterITS[1]->DrawCopy("SAME");
1192 fhChi2PerClusterTPC[0]->SetStats(kFALSE);
1193 fhChi2PerClusterTPC[0]->DrawCopy();
1194 fhChi2PerClusterTPC[1]->SetLineColor(2);
1195 fhChi2PerClusterTPC[1]->DrawCopy("SAME");*/