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>
31 //____________________________________________________________________
32 ClassImp(AliESDtrackCuts)
35 const Char_t* AliESDtrackCuts::fgkCutNames[kNCuts] = {
40 "#Chi^{2}/cluster TPC",
41 "#Chi^{2}/cluster ITS",
57 "trk-to-vtx max dca 2D absolute",
58 "trk-to-vtx max dca xy absolute",
59 "trk-to-vtx max dca z absolute",
60 "trk-to-vtx min dca 2D absolute",
61 "trk-to-vtx min dca xy absolute",
62 "trk-to-vtx min dca z absolute",
63 "SPD cluster requirement",
64 "SDD cluster requirement",
65 "SSD cluster requirement",
66 "require ITS stand-alone",
67 "rel 1/pt uncertainty"
70 //____________________________________________________________________
71 AliESDtrackCuts::AliESDtrackCuts(const Char_t* name, const Char_t* title) : AliAnalysisCuts(name,title),
72 fCutMinNClusterTPC(0),
73 fCutMinNClusterITS(0),
74 fCutMaxChi2PerClusterTPC(0),
75 fCutMaxChi2PerClusterITS(0),
81 fCutMaxRel1PtUncertainty(0),
82 fCutAcceptKinkDaughters(0),
83 fCutRequireTPCRefit(0),
84 fCutRequireITSRefit(0),
85 fCutRequireITSStandAlone(0),
86 fCutNsigmaToVertex(0),
87 fCutSigmaToVertexRequired(0),
88 fCutMaxDCAToVertexXY(0),
89 fCutMaxDCAToVertexZ(0),
90 fCutMinDCAToVertexXY(0),
91 fCutMinDCAToVertexZ(0),
118 //##############################################################################
119 // setting default cuts
120 SetMinNClustersTPC();
121 SetMinNClustersITS();
122 SetMaxChi2PerClusterTPC();
123 SetMaxChi2PerClusterITS();
124 SetMaxCovDiagonalElements();
125 SetMaxRel1PtUncertainty();
126 SetRequireTPCRefit();
127 SetRequireITSRefit();
128 SetRequireITSStandAlone(kFALSE);
129 SetAcceptKinkDaughters();
130 SetMaxNsigmaToVertex();
131 SetMaxDCAToVertexXY();
132 SetMaxDCAToVertexZ();
134 SetMinDCAToVertexXY();
135 SetMinDCAToVertexZ();
143 SetClusterRequirementITS(kSPD);
144 SetClusterRequirementITS(kSDD);
145 SetClusterRequirementITS(kSSD);
150 //_____________________________________________________________________________
151 AliESDtrackCuts::AliESDtrackCuts(const AliESDtrackCuts &c) : AliAnalysisCuts(c),
152 fCutMinNClusterTPC(0),
153 fCutMinNClusterITS(0),
154 fCutMaxChi2PerClusterTPC(0),
155 fCutMaxChi2PerClusterITS(0),
161 fCutMaxRel1PtUncertainty(0),
162 fCutAcceptKinkDaughters(0),
163 fCutRequireTPCRefit(0),
164 fCutRequireITSRefit(0),
165 fCutRequireITSStandAlone(0),
166 fCutNsigmaToVertex(0),
167 fCutSigmaToVertexRequired(0),
168 fCutMaxDCAToVertexXY(0),
169 fCutMaxDCAToVertexZ(0),
170 fCutMinDCAToVertexXY(0),
171 fCutMinDCAToVertexZ(0),
172 fCutDCAToVertex2D(0),
196 ((AliESDtrackCuts &) c).Copy(*this);
199 AliESDtrackCuts::~AliESDtrackCuts()
205 for (Int_t i=0; i<2; i++) {
207 if (fhNClustersITS[i])
208 delete fhNClustersITS[i];
209 if (fhNClustersTPC[i])
210 delete fhNClustersTPC[i];
211 if (fhChi2PerClusterITS[i])
212 delete fhChi2PerClusterITS[i];
213 if (fhChi2PerClusterTPC[i])
214 delete fhChi2PerClusterTPC[i];
226 if (fhRel1PtUncertainty[i])
227 delete fhRel1PtUncertainty[i];
238 if (fhDXYNormalized[i])
239 delete fhDXYNormalized[i];
240 if (fhDZNormalized[i])
241 delete fhDZNormalized[i];
242 if (fhDXYvsDZNormalized[i])
243 delete fhDXYvsDZNormalized[i];
244 if (fhNSigmaToVertex[i])
245 delete fhNSigmaToVertex[i];
253 delete ffDTheoretical;
256 delete fhCutStatistics;
257 if (fhCutCorrelation)
258 delete fhCutCorrelation;
261 void AliESDtrackCuts::Init()
264 // sets everything to zero
267 fCutMinNClusterTPC = 0;
268 fCutMinNClusterITS = 0;
270 fCutMaxChi2PerClusterTPC = 0;
271 fCutMaxChi2PerClusterITS = 0;
273 for (Int_t i = 0; i < 3; i++)
274 fCutClusterRequirementITS[i] = kOff;
282 fCutMaxRel1PtUncertainty = 0;
284 fCutAcceptKinkDaughters = 0;
285 fCutRequireTPCRefit = 0;
286 fCutRequireITSRefit = 0;
287 fCutRequireITSStandAlone = 0;
289 fCutNsigmaToVertex = 0;
290 fCutSigmaToVertexRequired = 0;
291 fCutMaxDCAToVertexXY = 0;
292 fCutMaxDCAToVertexZ = 0;
293 fCutDCAToVertex2D = 0;
294 fCutMinDCAToVertexXY = 0;
295 fCutMinDCAToVertexZ = 0;
313 fHistogramsOn = kFALSE;
315 for (Int_t i=0; i<2; ++i)
317 fhNClustersITS[i] = 0;
318 fhNClustersTPC[i] = 0;
320 fhChi2PerClusterITS[i] = 0;
321 fhChi2PerClusterTPC[i] = 0;
329 fhRel1PtUncertainty[i] = 0;
336 fhDXYNormalized[i] = 0;
337 fhDZNormalized[i] = 0;
338 fhDXYvsDZNormalized[i] = 0;
339 fhNSigmaToVertex[i] = 0;
347 fhCutCorrelation = 0;
350 //_____________________________________________________________________________
351 AliESDtrackCuts &AliESDtrackCuts::operator=(const AliESDtrackCuts &c)
354 // Assignment operator
357 if (this != &c) ((AliESDtrackCuts &) c).Copy(*this);
361 //_____________________________________________________________________________
362 void AliESDtrackCuts::Copy(TObject &c) const
368 AliESDtrackCuts& target = (AliESDtrackCuts &) c;
372 target.fCutMinNClusterTPC = fCutMinNClusterTPC;
373 target.fCutMinNClusterITS = fCutMinNClusterITS;
375 target.fCutMaxChi2PerClusterTPC = fCutMaxChi2PerClusterTPC;
376 target.fCutMaxChi2PerClusterITS = fCutMaxChi2PerClusterITS;
378 for (Int_t i = 0; i < 3; i++)
379 target.fCutClusterRequirementITS[i] = fCutClusterRequirementITS[i];
381 target.fCutMaxC11 = fCutMaxC11;
382 target.fCutMaxC22 = fCutMaxC22;
383 target.fCutMaxC33 = fCutMaxC33;
384 target.fCutMaxC44 = fCutMaxC44;
385 target.fCutMaxC55 = fCutMaxC55;
387 target.fCutMaxRel1PtUncertainty = fCutMaxRel1PtUncertainty;
389 target.fCutAcceptKinkDaughters = fCutAcceptKinkDaughters;
390 target.fCutRequireTPCRefit = fCutRequireTPCRefit;
391 target.fCutRequireITSRefit = fCutRequireITSRefit;
392 target.fCutRequireITSStandAlone = fCutRequireITSStandAlone;
394 target.fCutNsigmaToVertex = fCutNsigmaToVertex;
395 target.fCutSigmaToVertexRequired = fCutSigmaToVertexRequired;
396 target.fCutMaxDCAToVertexXY = fCutMaxDCAToVertexXY;
397 target.fCutMaxDCAToVertexZ = fCutMaxDCAToVertexZ;
398 target.fCutDCAToVertex2D = fCutDCAToVertex2D;
399 target.fCutMinDCAToVertexXY = fCutMinDCAToVertexXY;
400 target.fCutMinDCAToVertexZ = fCutMinDCAToVertexZ;
402 target.fPMin = fPMin;
403 target.fPMax = fPMax;
404 target.fPtMin = fPtMin;
405 target.fPtMax = fPtMax;
406 target.fPxMin = fPxMin;
407 target.fPxMax = fPxMax;
408 target.fPyMin = fPyMin;
409 target.fPyMax = fPyMax;
410 target.fPzMin = fPzMin;
411 target.fPzMax = fPzMax;
412 target.fEtaMin = fEtaMin;
413 target.fEtaMax = fEtaMax;
414 target.fRapMin = fRapMin;
415 target.fRapMax = fRapMax;
417 target.fHistogramsOn = fHistogramsOn;
419 for (Int_t i=0; i<2; ++i)
421 if (fhNClustersITS[i]) target.fhNClustersITS[i] = (TH1F*) fhNClustersITS[i]->Clone();
422 if (fhNClustersTPC[i]) target.fhNClustersTPC[i] = (TH1F*) fhNClustersTPC[i]->Clone();
424 if (fhChi2PerClusterITS[i]) target.fhChi2PerClusterITS[i] = (TH1F*) fhChi2PerClusterITS[i]->Clone();
425 if (fhChi2PerClusterTPC[i]) target.fhChi2PerClusterTPC[i] = (TH1F*) fhChi2PerClusterTPC[i]->Clone();
427 if (fhC11[i]) target.fhC11[i] = (TH1F*) fhC11[i]->Clone();
428 if (fhC22[i]) target.fhC22[i] = (TH1F*) fhC22[i]->Clone();
429 if (fhC33[i]) target.fhC33[i] = (TH1F*) fhC33[i]->Clone();
430 if (fhC44[i]) target.fhC44[i] = (TH1F*) fhC44[i]->Clone();
431 if (fhC55[i]) target.fhC55[i] = (TH1F*) fhC55[i]->Clone();
433 if (fhRel1PtUncertainty[i]) target.fhRel1PtUncertainty[i] = (TH1F*) fhRel1PtUncertainty[i]->Clone();
435 if (fhDXY[i]) target.fhDXY[i] = (TH1F*) fhDXY[i]->Clone();
436 if (fhDZ[i]) target.fhDZ[i] = (TH1F*) fhDZ[i]->Clone();
437 if (fhDXYDZ[i]) target.fhDXYDZ[i] = (TH1F*) fhDXYDZ[i]->Clone();
438 if (fhDXYvsDZ[i]) target.fhDXYvsDZ[i] = (TH2F*) fhDXYvsDZ[i]->Clone();
440 if (fhDXYNormalized[i]) target.fhDXYNormalized[i] = (TH1F*) fhDXYNormalized[i]->Clone();
441 if (fhDZNormalized[i]) target.fhDZNormalized[i] = (TH1F*) fhDZNormalized[i]->Clone();
442 if (fhDXYvsDZNormalized[i]) target.fhDXYvsDZNormalized[i] = (TH2F*) fhDXYvsDZNormalized[i]->Clone();
443 if (fhNSigmaToVertex[i]) target.fhNSigmaToVertex[i] = (TH1F*) fhNSigmaToVertex[i]->Clone();
445 if (fhPt[i]) target.fhPt[i] = (TH1F*) fhPt[i]->Clone();
446 if (fhEta[i]) target.fhEta[i] = (TH1F*) fhEta[i]->Clone();
448 if (ffDTheoretical) target.ffDTheoretical = (TF1*) ffDTheoretical->Clone();
450 if (fhCutStatistics) target.fhCutStatistics = (TH1F*) fhCutStatistics->Clone();
451 if (fhCutCorrelation) target.fhCutCorrelation = (TH2F*) fhCutCorrelation->Clone();
456 //_____________________________________________________________________________
457 Long64_t AliESDtrackCuts::Merge(TCollection* list) {
458 // Merge a list of AliESDtrackCuts objects with this (needed for PROOF)
459 // Returns the number of merged objects (including this)
466 TIterator* iter = list->MakeIterator();
469 // collection of measured and generated histograms
471 while ((obj = iter->Next())) {
473 AliESDtrackCuts* entry = dynamic_cast<AliESDtrackCuts*>(obj);
477 if (!entry->fHistogramsOn)
480 for (Int_t i=0; i<2; i++) {
482 fhNClustersITS[i] ->Add(entry->fhNClustersITS[i] );
483 fhNClustersTPC[i] ->Add(entry->fhNClustersTPC[i] );
485 fhChi2PerClusterITS[i] ->Add(entry->fhChi2PerClusterITS[i]);
486 fhChi2PerClusterTPC[i] ->Add(entry->fhChi2PerClusterTPC[i]);
488 fhC11[i] ->Add(entry->fhC11[i] );
489 fhC22[i] ->Add(entry->fhC22[i] );
490 fhC33[i] ->Add(entry->fhC33[i] );
491 fhC44[i] ->Add(entry->fhC44[i] );
492 fhC55[i] ->Add(entry->fhC55[i] );
494 fhRel1PtUncertainty[i] ->Add(entry->fhRel1PtUncertainty[i]);
496 fhDXY[i] ->Add(entry->fhDXY[i] );
497 fhDZ[i] ->Add(entry->fhDZ[i] );
498 fhDXYDZ[i] ->Add(entry->fhDXYDZ[i] );
499 fhDXYvsDZ[i] ->Add(entry->fhDXYvsDZ[i] );
501 fhDXYNormalized[i] ->Add(entry->fhDXYNormalized[i] );
502 fhDZNormalized[i] ->Add(entry->fhDZNormalized[i] );
503 fhDXYvsDZNormalized[i] ->Add(entry->fhDXYvsDZNormalized[i]);
504 fhNSigmaToVertex[i] ->Add(entry->fhNSigmaToVertex[i]);
506 fhPt[i] ->Add(entry->fhPt[i]);
507 fhEta[i] ->Add(entry->fhEta[i]);
510 fhCutStatistics ->Add(entry->fhCutStatistics);
511 fhCutCorrelation ->Add(entry->fhCutCorrelation);
518 //____________________________________________________________________
519 AliESDtrackCuts* AliESDtrackCuts::GetStandardTPCOnlyTrackCuts()
521 // creates an AliESDtrackCuts object and fills it with standard values for TPC-only cuts
522 // see ALICE note: ...
524 Printf("AliESDtrackCuts::GetStandardTPCOnlyTrackCuts: Creating track cuts for TPC-only.");
526 AliESDtrackCuts* esdTrackCuts = new AliESDtrackCuts;
528 esdTrackCuts->SetMinNClustersTPC(50);
529 esdTrackCuts->SetMaxChi2PerClusterTPC(4);
530 esdTrackCuts->SetAcceptKinkDaughters(kFALSE);
532 esdTrackCuts->SetMaxDCAToVertexZ(3.2);
533 esdTrackCuts->SetMaxDCAToVertexXY(2.4);
534 esdTrackCuts->SetDCAToVertex2D(kTRUE);
539 //____________________________________________________________________
540 Int_t AliESDtrackCuts::GetReferenceMultiplicity(AliESDEvent* esd, Bool_t tpcOnly)
542 // Gets reference multiplicity following the standard cuts and a defined fiducial volume
543 // tpcOnly = kTRUE -> consider TPC-only tracks
544 // = kFALSE -> consider global tracks
548 Printf("AliESDtrackCuts::GetReferenceMultiplicity: Not implemented for global tracks!");
552 AliESDtrackCuts* esdTrackCuts = GetStandardTPCOnlyTrackCuts();
553 esdTrackCuts->SetEtaRange(-0.8, 0.8);
554 esdTrackCuts->SetPtRange(0.15);
556 Int_t nTracks = esdTrackCuts->CountAcceptedTracks(esd);
564 //____________________________________________________________________
565 Float_t AliESDtrackCuts::GetSigmaToVertex(AliESDtrack* esdTrack)
567 // Calculates the number of sigma to the vertex.
572 esdTrack->GetImpactParameters(b,bCov);
574 if (bCov[0]<=0 || bCov[2]<=0) {
575 AliDebugClass(1, "Estimated b resolution lower or equal zero!");
576 bCov[0]=0; bCov[2]=0;
578 bRes[0] = TMath::Sqrt(bCov[0]);
579 bRes[1] = TMath::Sqrt(bCov[2]);
581 // -----------------------------------
582 // How to get to a n-sigma cut?
584 // The accumulated statistics from 0 to d is
586 // -> Erf(d/Sqrt(2)) for a 1-dim gauss (d = n_sigma)
587 // -> 1 - Exp(-d**2) for a 2-dim gauss (d*d = dx*dx + dy*dy != n_sigma)
589 // It means that for a 2-dim gauss: n_sigma(d) = Sqrt(2)*ErfInv(1 - Exp((-d**2)/2)
590 // Can this be expressed in a different way?
592 if (bRes[0] == 0 || bRes[1] ==0)
595 Float_t d = TMath::Sqrt(TMath::Power(b[0]/bRes[0],2) + TMath::Power(b[1]/bRes[1],2));
597 // work around precision problem
598 // if d is too big, TMath::Exp(...) gets 0, and TMath::ErfInverse(1) that should be infinite, gets 0 :(
599 // 1e-15 corresponds to nsigma ~ 7.7
600 if (TMath::Exp(-d * d / 2) < 1e-15)
603 Float_t nSigma = TMath::ErfInverse(1 - TMath::Exp(-d * d / 2)) * TMath::Sqrt(2);
607 void AliESDtrackCuts::EnableNeededBranches(TTree* tree)
609 // enables the branches needed by AcceptTrack, for a list see comment of AcceptTrack
611 tree->SetBranchStatus("fTracks.fFlags", 1);
612 tree->SetBranchStatus("fTracks.fITSncls", 1);
613 tree->SetBranchStatus("fTracks.fTPCncls", 1);
614 tree->SetBranchStatus("fTracks.fITSchi2", 1);
615 tree->SetBranchStatus("fTracks.fTPCchi2", 1);
616 tree->SetBranchStatus("fTracks.fC*", 1);
617 tree->SetBranchStatus("fTracks.fD", 1);
618 tree->SetBranchStatus("fTracks.fZ", 1);
619 tree->SetBranchStatus("fTracks.fCdd", 1);
620 tree->SetBranchStatus("fTracks.fCdz", 1);
621 tree->SetBranchStatus("fTracks.fCzz", 1);
622 tree->SetBranchStatus("fTracks.fP*", 1);
623 tree->SetBranchStatus("fTracks.fR*", 1);
624 tree->SetBranchStatus("fTracks.fKinkIndexes*", 1);
627 //____________________________________________________________________
628 Bool_t AliESDtrackCuts::AcceptTrack(AliESDtrack* esdTrack)
631 // figure out if the tracks survives all the track cuts defined
633 // the different quality parameter and kinematic values are first
634 // retrieved from the track. then it is found out what cuts the
635 // track did not survive and finally the cuts are imposed.
637 // this function needs the following branches:
643 // fTracks.fC //GetExternalCovariance
644 // fTracks.fD //GetImpactParameters
645 // fTracks.fZ //GetImpactParameters
646 // fTracks.fCdd //GetImpactParameters
647 // fTracks.fCdz //GetImpactParameters
648 // fTracks.fCzz //GetImpactParameters
649 // fTracks.fP //GetPxPyPz
650 // fTracks.fR //GetMass
651 // fTracks.fP //GetMass
652 // fTracks.fKinkIndexes
654 UInt_t status = esdTrack->GetStatus();
656 // getting quality parameters from the ESD track
657 Int_t nClustersITS = esdTrack->GetITSclusters(0);
658 Int_t nClustersTPC = esdTrack->GetTPCclusters(0);
660 Float_t chi2PerClusterITS = -1;
661 Float_t chi2PerClusterTPC = -1;
663 chi2PerClusterITS = esdTrack->GetITSchi2()/Float_t(nClustersITS);
665 chi2PerClusterTPC = esdTrack->GetTPCchi2()/Float_t(nClustersTPC);
667 esdTrack->GetExternalCovariance(extCov);
669 // getting the track to vertex parameters
670 Float_t nSigmaToVertex = GetSigmaToVertex(esdTrack);
674 esdTrack->GetImpactParameters(b,bCov);
675 if (bCov[0]<=0 || bCov[2]<=0) {
676 AliDebug(1, "Estimated b resolution lower or equal zero!");
677 bCov[0]=0; bCov[2]=0;
680 Float_t dcaToVertexXY = b[0];
681 Float_t dcaToVertexZ = b[1];
683 Float_t dcaToVertex = -1;
685 if (fCutDCAToVertex2D)
687 dcaToVertex = TMath::Sqrt(dcaToVertexXY*dcaToVertexXY/fCutMaxDCAToVertexXY/fCutMaxDCAToVertexXY + dcaToVertexZ*dcaToVertexZ/fCutMaxDCAToVertexZ/fCutMaxDCAToVertexZ);
690 dcaToVertex = TMath::Sqrt(dcaToVertexXY*dcaToVertexXY + dcaToVertexZ*dcaToVertexZ);
692 // getting the kinematic variables of the track
693 // (assuming the mass is known)
695 esdTrack->GetPxPyPz(p);
697 Float_t momentum = TMath::Sqrt(TMath::Power(p[0],2) + TMath::Power(p[1],2) + TMath::Power(p[2],2));
698 Float_t pt = TMath::Sqrt(TMath::Power(p[0],2) + TMath::Power(p[1],2));
699 Float_t energy = TMath::Sqrt(TMath::Power(esdTrack->GetMass(),2) + TMath::Power(momentum,2));
702 //y-eta related calculations
705 if((momentum != TMath::Abs(p[2]))&&(momentum != 0))
706 eta = 0.5*TMath::Log((momentum + p[2])/(momentum - p[2]));
707 if((energy != TMath::Abs(p[2]))&&(momentum != 0))
708 y = 0.5*TMath::Log((energy + p[2])/(energy - p[2]));
710 Float_t relUncertainty1Pt = TMath::Sqrt(extCov[14])*pt;
712 //########################################################################
716 for (Int_t i=0; i<kNCuts; i++) cuts[i]=kFALSE;
718 // track quality cuts
719 if (fCutRequireTPCRefit && (status&AliESDtrack::kTPCrefit)==0)
721 if (fCutRequireITSRefit && (status&AliESDtrack::kITSrefit)==0)
723 if (nClustersTPC<fCutMinNClusterTPC)
725 if (nClustersITS<fCutMinNClusterITS)
727 if (chi2PerClusterTPC>fCutMaxChi2PerClusterTPC)
729 if (chi2PerClusterITS>fCutMaxChi2PerClusterITS)
731 if (extCov[0] > fCutMaxC11)
733 if (extCov[2] > fCutMaxC22)
735 if (extCov[5] > fCutMaxC33)
737 if (extCov[9] > fCutMaxC44)
739 if (extCov[14] > fCutMaxC55)
741 if (nSigmaToVertex > fCutNsigmaToVertex && fCutSigmaToVertexRequired)
743 // if n sigma could not be calculated
744 if (nSigmaToVertex<0 && fCutSigmaToVertexRequired)
746 if (!fCutAcceptKinkDaughters && esdTrack->GetKinkIndex(0)>0)
748 // track kinematics cut
749 if((momentum < fPMin) || (momentum > fPMax))
751 if((pt < fPtMin) || (pt > fPtMax))
753 if((p[0] < fPxMin) || (p[0] > fPxMax))
755 if((p[1] < fPyMin) || (p[1] > fPyMax))
757 if((p[2] < fPzMin) || (p[2] > fPzMax))
759 if((eta < fEtaMin) || (eta > fEtaMax))
761 if((y < fRapMin) || (y > fRapMax))
763 if (fCutDCAToVertex2D && dcaToVertex > 1)
765 if (!fCutDCAToVertex2D && TMath::Abs(dcaToVertexXY) > fCutMaxDCAToVertexXY)
767 if (!fCutDCAToVertex2D && TMath::Abs(dcaToVertexZ) > fCutMaxDCAToVertexZ)
769 if (fCutDCAToVertex2D && fCutMinDCAToVertexXY > 0 && fCutMinDCAToVertexZ > 0 && dcaToVertexXY*dcaToVertexXY/fCutMinDCAToVertexXY/fCutMinDCAToVertexXY + dcaToVertexZ*dcaToVertexZ/fCutMinDCAToVertexZ/fCutMinDCAToVertexZ < 1)
771 if (!fCutDCAToVertex2D && TMath::Abs(dcaToVertexXY) < fCutMinDCAToVertexXY)
773 if (!fCutDCAToVertex2D && TMath::Abs(dcaToVertexZ) < fCutMinDCAToVertexZ)
776 for (Int_t i = 0; i < 3; i++)
777 cuts[27+i] = !CheckITSClusterRequirement(fCutClusterRequirementITS[i], esdTrack->HasPointOnITSLayer(i*2), esdTrack->HasPointOnITSLayer(i*2+1));
779 if (fCutRequireITSStandAlone && ((status & AliESDtrack::kITSin) == 0 || (status & AliESDtrack::kTPCin)))
782 if (relUncertainty1Pt > fCutMaxRel1PtUncertainty)
786 for (Int_t i=0; i<kNCuts; i++)
787 if (cuts[i]) {cut = kTRUE;}
791 //########################################################################
792 // filling histograms
794 fhCutStatistics->Fill(fhCutStatistics->GetBinCenter(fhCutStatistics->GetXaxis()->FindBin("n tracks")));
796 fhCutStatistics->Fill(fhCutStatistics->GetBinCenter(fhCutStatistics->GetXaxis()->FindBin("n cut tracks")));
798 for (Int_t i=0; i<kNCuts; i++) {
800 fhCutStatistics->Fill(fhCutStatistics->GetBinCenter(fhCutStatistics->GetXaxis()->FindBin(fgkCutNames[i])));
802 for (Int_t j=i; j<kNCuts; j++) {
803 if (cuts[i] && cuts[j]) {
804 Float_t xC = fhCutCorrelation->GetXaxis()->GetBinCenter(fhCutCorrelation->GetXaxis()->FindBin(fgkCutNames[i]));
805 Float_t yC = fhCutCorrelation->GetYaxis()->GetBinCenter(fhCutCorrelation->GetYaxis()->FindBin(fgkCutNames[j]));
806 fhCutCorrelation->Fill(xC, yC);
812 // now we loop over the filling of the histograms twice: once "before" the cut, once "after"
813 // the code is not in a function due to too many local variables that would need to be passed
815 for (Int_t id = 0; id < 2; id++)
817 // id = 0 --> before cut
818 // id = 1 --> after cut
822 fhNClustersITS[id]->Fill(nClustersITS);
823 fhNClustersTPC[id]->Fill(nClustersTPC);
824 fhChi2PerClusterITS[id]->Fill(chi2PerClusterITS);
825 fhChi2PerClusterTPC[id]->Fill(chi2PerClusterTPC);
827 fhC11[id]->Fill(extCov[0]);
828 fhC22[id]->Fill(extCov[2]);
829 fhC33[id]->Fill(extCov[5]);
830 fhC44[id]->Fill(extCov[9]);
831 fhC55[id]->Fill(extCov[14]);
833 fhRel1PtUncertainty[id]->Fill(relUncertainty1Pt);
836 fhEta[id]->Fill(eta);
839 bRes[0] = TMath::Sqrt(bCov[0]);
840 bRes[1] = TMath::Sqrt(bCov[2]);
842 fhDZ[id]->Fill(b[1]);
843 fhDXY[id]->Fill(b[0]);
844 fhDXYDZ[id]->Fill(dcaToVertex);
845 fhDXYvsDZ[id]->Fill(b[1],b[0]);
847 if (bRes[0]!=0 && bRes[1]!=0) {
848 fhDZNormalized[id]->Fill(b[1]/bRes[1]);
849 fhDXYNormalized[id]->Fill(b[0]/bRes[0]);
850 fhDXYvsDZNormalized[id]->Fill(b[1]/bRes[1], b[0]/bRes[0]);
851 fhNSigmaToVertex[id]->Fill(nSigmaToVertex);
863 //____________________________________________________________________
864 Bool_t AliESDtrackCuts::CheckITSClusterRequirement(ITSClusterRequirement req, Bool_t clusterL1, Bool_t clusterL2)
866 // checks if the cluster requirement is fullfilled (in this case: return kTRUE)
870 case kOff: return kTRUE;
871 case kNone: return !clusterL1 && !clusterL2;
872 case kAny: return clusterL1 || clusterL2;
873 case kFirst: return clusterL1;
874 case kOnlyFirst: return clusterL1 && !clusterL2;
875 case kSecond: return clusterL2;
876 case kOnlySecond: return clusterL2 && !clusterL1;
877 case kBoth: return clusterL1 && clusterL2;
883 //____________________________________________________________________
884 AliESDtrack* AliESDtrackCuts::GetTPCOnlyTrack(AliESDEvent* esd, Int_t iTrack)
886 // creates a TPC only track from the given esd track
887 // the track has to be deleted by the user
889 // NB. most of the functionality to get a TPC only track from an ESD track is in AliESDtrack, where it should be
890 // there are only missing propagations here that are needed for old data
891 // this function will therefore become obsolete
893 // adapted from code provided by CKB
895 if (!esd->GetPrimaryVertexTPC())
896 return 0; // No TPC vertex no TPC tracks
898 if(!esd->GetPrimaryVertexTPC()->GetStatus())
899 return 0; // TPC Vertex is created by default in AliESDEvent, do not use in this case
901 AliESDtrack* track = esd->GetTrack(iTrack);
905 AliESDtrack *tpcTrack = new AliESDtrack();
907 // This should have been done during the reconstruction
908 // fixed by Juri in r26675
909 // but recalculate for older data CKB
911 track->GetImpactParametersTPC(p,cov);
913 track->RelateToVertexTPC(esd->GetPrimaryVertexTPC(),esd->GetMagneticField(),kVeryBig);
916 // only true if we have a tpc track
917 if (!track->FillTPCOnlyTrack(*tpcTrack))
923 // propagate to Vertex
924 // not needed for normal reconstructed ESDs...
925 // Double_t pTPC[2],covTPC[3];
926 // tpcTrack->PropagateToDCA(esd->GetPrimaryVertexTPC(), esd->GetMagneticField(), 10000, pTPC, covTPC);
931 //____________________________________________________________________
932 TObjArray* AliESDtrackCuts::GetAcceptedTracks(AliESDEvent* esd,Bool_t bTPC)
935 // returns an array of all tracks that pass the cuts
936 // or an array of TPC only tracks (propagated to the TPC vertex during reco)
937 // tracks that pass the cut
939 TObjArray* acceptedTracks = new TObjArray();
941 // loop over esd tracks
942 for (Int_t iTrack = 0; iTrack < esd->GetNumberOfTracks(); iTrack++) {
944 if(!esd->GetPrimaryVertexTPC())return acceptedTracks; // No TPC vertex no TPC tracks
945 if(!esd->GetPrimaryVertexTPC()->GetStatus())return acceptedTracks; // No proper TPC vertex, only the default
947 AliESDtrack *tpcTrack = GetTPCOnlyTrack(esd, iTrack);
951 if (AcceptTrack(tpcTrack)) {
952 acceptedTracks->Add(tpcTrack);
959 AliESDtrack* track = esd->GetTrack(iTrack);
960 if(AcceptTrack(track))
961 acceptedTracks->Add(track);
964 if(bTPC)acceptedTracks->SetOwner(kTRUE);
965 return acceptedTracks;
968 //____________________________________________________________________
969 Int_t AliESDtrackCuts::CountAcceptedTracks(AliESDEvent* esd)
972 // returns an the number of tracks that pass the cuts
977 // loop over esd tracks
978 for (Int_t iTrack = 0; iTrack < esd->GetNumberOfTracks(); iTrack++) {
979 AliESDtrack* track = esd->GetTrack(iTrack);
980 if (AcceptTrack(track))
987 //____________________________________________________________________
988 void AliESDtrackCuts::DefineHistograms(Int_t color) {
990 // diagnostics histograms are defined
995 Bool_t oldStatus = TH1::AddDirectoryStatus();
996 TH1::AddDirectory(kFALSE);
998 //###################################################################################
999 // defining histograms
1001 fhCutStatistics = new TH1F("cut_statistics","cut statistics",kNCuts+4,-0.5,kNCuts+3.5);
1003 fhCutStatistics->GetXaxis()->SetBinLabel(1,"n tracks");
1004 fhCutStatistics->GetXaxis()->SetBinLabel(2,"n cut tracks");
1006 fhCutCorrelation = new TH2F("cut_correlation","cut correlation",kNCuts,-0.5,kNCuts-0.5,kNCuts,-0.5,kNCuts-0.5);;
1008 for (Int_t i=0; i<kNCuts; i++) {
1009 fhCutStatistics->GetXaxis()->SetBinLabel(i+4,fgkCutNames[i]);
1010 fhCutCorrelation->GetXaxis()->SetBinLabel(i+1,fgkCutNames[i]);
1011 fhCutCorrelation->GetYaxis()->SetBinLabel(i+1,fgkCutNames[i]);
1014 fhCutStatistics ->SetLineColor(color);
1015 fhCutCorrelation ->SetLineColor(color);
1016 fhCutStatistics ->SetLineWidth(2);
1017 fhCutCorrelation ->SetLineWidth(2);
1019 for (Int_t i=0; i<2; i++) {
1020 fhNClustersITS[i] = new TH1F("nClustersITS" ,"",8,-0.5,7.5);
1021 fhNClustersTPC[i] = new TH1F("nClustersTPC" ,"",165,-0.5,164.5);
1022 fhChi2PerClusterITS[i] = new TH1F("chi2PerClusterITS","",500,0,10);
1023 fhChi2PerClusterTPC[i] = new TH1F("chi2PerClusterTPC","",500,0,10);
1025 fhC11[i] = new TH1F("covMatrixDiagonal11","",2000,0,20);
1026 fhC22[i] = new TH1F("covMatrixDiagonal22","",2000,0,20);
1027 fhC33[i] = new TH1F("covMatrixDiagonal33","",1000,0,0.1);
1028 fhC44[i] = new TH1F("covMatrixDiagonal44","",1000,0,0.1);
1029 fhC55[i] = new TH1F("covMatrixDiagonal55","",1000,0,5);
1031 fhRel1PtUncertainty[i] = new TH1F("rel1PtUncertainty","",1000,0,5);
1033 fhDXY[i] = new TH1F("dXY" ,"",500,-10,10);
1034 fhDZ[i] = new TH1F("dZ" ,"",500,-10,10);
1035 fhDXYDZ[i] = new TH1F("dXYDZ" ,"",500,0,10);
1036 fhDXYvsDZ[i] = new TH2F("dXYvsDZ","",200,-10,10,200,-10,10);
1038 fhDXYNormalized[i] = new TH1F("dXYNormalized" ,"",500,-10,10);
1039 fhDZNormalized[i] = new TH1F("dZNormalized" ,"",500,-10,10);
1040 fhDXYvsDZNormalized[i] = new TH2F("dXYvsDZNormalized","",200,-10,10,200,-10,10);
1042 fhNSigmaToVertex[i] = new TH1F("nSigmaToVertex","",500,0,10);
1044 fhPt[i] = new TH1F("pt" ,"p_{T} distribution;p_{T} (GeV/c)", 800, 0.0, 10.0);
1045 fhEta[i] = new TH1F("eta" ,"#eta distribution;#eta",40,-2.0,2.0);
1047 fhNClustersITS[i]->SetTitle("n ITS clusters");
1048 fhNClustersTPC[i]->SetTitle("n TPC clusters");
1049 fhChi2PerClusterITS[i]->SetTitle("#Chi^{2} per ITS cluster");
1050 fhChi2PerClusterTPC[i]->SetTitle("#Chi^{2} per TPC cluster");
1052 fhC11[i]->SetTitle("cov 11 : #sigma_{y}^{2} [cm^{2}]");
1053 fhC22[i]->SetTitle("cov 22 : #sigma_{z}^{2} [cm^{2}]");
1054 fhC33[i]->SetTitle("cov 33 : #sigma_{sin(#phi)}^{2}");
1055 fhC44[i]->SetTitle("cov 44 : #sigma_{tan(#theta_{dip})}^{2}");
1056 fhC55[i]->SetTitle("cov 55 : #sigma_{1/p_{T}}^{2} [(c/GeV)^2]");
1058 fhRel1PtUncertainty[i]->SetTitle("rel. uncertainty of 1/p_{T}");
1060 fhDXY[i]->SetXTitle("transverse impact parameter (cm)");
1061 fhDZ[i]->SetXTitle("longitudinal impact parameter (cm)");
1062 fhDXYDZ[i]->SetTitle("absolute impact parameter;sqrt(dXY**2 + dZ**2) (cm)");
1063 fhDXYvsDZ[i]->SetXTitle("longitudinal impact parameter (cm)");
1064 fhDXYvsDZ[i]->SetYTitle("transverse impact parameter (cm)");
1066 fhDXYNormalized[i]->SetTitle("normalized trans impact par (n#sigma)");
1067 fhDZNormalized[i]->SetTitle("normalized long impact par (n#sigma)");
1068 fhDXYvsDZNormalized[i]->SetTitle("normalized long impact par (n#sigma)");
1069 fhDXYvsDZNormalized[i]->SetYTitle("normalized trans impact par (n#sigma)");
1070 fhNSigmaToVertex[i]->SetTitle("n #sigma to vertex");
1072 fhNClustersITS[i]->SetLineColor(color); fhNClustersITS[i]->SetLineWidth(2);
1073 fhNClustersTPC[i]->SetLineColor(color); fhNClustersTPC[i]->SetLineWidth(2);
1074 fhChi2PerClusterITS[i]->SetLineColor(color); fhChi2PerClusterITS[i]->SetLineWidth(2);
1075 fhChi2PerClusterTPC[i]->SetLineColor(color); fhChi2PerClusterTPC[i]->SetLineWidth(2);
1077 fhC11[i]->SetLineColor(color); fhC11[i]->SetLineWidth(2);
1078 fhC22[i]->SetLineColor(color); fhC22[i]->SetLineWidth(2);
1079 fhC33[i]->SetLineColor(color); fhC33[i]->SetLineWidth(2);
1080 fhC44[i]->SetLineColor(color); fhC44[i]->SetLineWidth(2);
1081 fhC55[i]->SetLineColor(color); fhC55[i]->SetLineWidth(2);
1083 fhRel1PtUncertainty[i]->SetLineColor(color); fhRel1PtUncertainty[i]->SetLineWidth(2);
1085 fhDXY[i]->SetLineColor(color); fhDXY[i]->SetLineWidth(2);
1086 fhDZ[i]->SetLineColor(color); fhDZ[i]->SetLineWidth(2);
1087 fhDXYDZ[i]->SetLineColor(color); fhDXYDZ[i]->SetLineWidth(2);
1089 fhDXYNormalized[i]->SetLineColor(color); fhDXYNormalized[i]->SetLineWidth(2);
1090 fhDZNormalized[i]->SetLineColor(color); fhDZNormalized[i]->SetLineWidth(2);
1091 fhNSigmaToVertex[i]->SetLineColor(color); fhNSigmaToVertex[i]->SetLineWidth(2);
1094 // The number of sigmas to the vertex is per definition gaussian
1095 ffDTheoretical = new TF1("nSigmaToVertexTheoretical","([0]/2.506628274)*exp(-(x**2)/2)",0,50);
1096 ffDTheoretical->SetParameter(0,1);
1098 TH1::AddDirectory(oldStatus);
1101 //____________________________________________________________________
1102 Bool_t AliESDtrackCuts::LoadHistograms(const Char_t* dir)
1105 // loads the histograms from a file
1106 // if dir is empty a directory with the name of this object is taken (like in SaveHistogram)
1112 if (!gDirectory->cd(dir))
1115 ffDTheoretical = dynamic_cast<TF1*> (gDirectory->Get("nSigmaToVertexTheory"));
1117 fhCutStatistics = dynamic_cast<TH1F*> (gDirectory->Get("cut_statistics"));
1118 fhCutCorrelation = dynamic_cast<TH2F*> (gDirectory->Get("cut_correlation"));
1120 for (Int_t i=0; i<2; i++) {
1123 gDirectory->cd("before_cuts");
1126 gDirectory->cd("after_cuts");
1128 fhNClustersITS[i] = dynamic_cast<TH1F*> (gDirectory->Get("nClustersITS" ));
1129 fhNClustersTPC[i] = dynamic_cast<TH1F*> (gDirectory->Get("nClustersTPC" ));
1130 fhChi2PerClusterITS[i] = dynamic_cast<TH1F*> (gDirectory->Get("chi2PerClusterITS"));
1131 fhChi2PerClusterTPC[i] = dynamic_cast<TH1F*> (gDirectory->Get("chi2PerClusterTPC"));
1133 fhC11[i] = dynamic_cast<TH1F*> (gDirectory->Get("covMatrixDiagonal11"));
1134 fhC22[i] = dynamic_cast<TH1F*> (gDirectory->Get("covMatrixDiagonal22"));
1135 fhC33[i] = dynamic_cast<TH1F*> (gDirectory->Get("covMatrixDiagonal33"));
1136 fhC44[i] = dynamic_cast<TH1F*> (gDirectory->Get("covMatrixDiagonal44"));
1137 fhC55[i] = dynamic_cast<TH1F*> (gDirectory->Get("covMatrixDiagonal55"));
1139 fhRel1PtUncertainty[i] = dynamic_cast<TH1F*> (gDirectory->Get("rel1PtUncertainty"));
1141 fhDXY[i] = dynamic_cast<TH1F*> (gDirectory->Get("dXY" ));
1142 fhDZ[i] = dynamic_cast<TH1F*> (gDirectory->Get("dZ" ));
1143 fhDXYDZ[i] = dynamic_cast<TH1F*> (gDirectory->Get("dXYDZ"));
1144 fhDXYvsDZ[i] = dynamic_cast<TH2F*> (gDirectory->Get("dXYvsDZ"));
1146 fhDXYNormalized[i] = dynamic_cast<TH1F*> (gDirectory->Get("dXYNormalized" ));
1147 fhDZNormalized[i] = dynamic_cast<TH1F*> (gDirectory->Get("dZNormalized" ));
1148 fhDXYvsDZNormalized[i] = dynamic_cast<TH2F*> (gDirectory->Get("dXYvsDZNormalized"));
1149 fhNSigmaToVertex[i] = dynamic_cast<TH1F*> (gDirectory->Get("nSigmaToVertex"));
1151 fhPt[i] = dynamic_cast<TH1F*> (gDirectory->Get("pt"));
1152 fhEta[i] = dynamic_cast<TH1F*> (gDirectory->Get("eta"));
1154 gDirectory->cd("../");
1157 gDirectory->cd("..");
1162 //____________________________________________________________________
1163 void AliESDtrackCuts::SaveHistograms(const Char_t* dir) {
1165 // saves the histograms in a directory (dir)
1168 if (!fHistogramsOn) {
1169 AliDebug(0, "Histograms not on - cannot save histograms!!!");
1176 gDirectory->mkdir(dir);
1177 gDirectory->cd(dir);
1179 gDirectory->mkdir("before_cuts");
1180 gDirectory->mkdir("after_cuts");
1182 // a factor of 2 is needed since n sigma is positive
1183 ffDTheoretical->SetParameter(0,2*fhNSigmaToVertex[0]->Integral("width"));
1184 ffDTheoretical->Write("nSigmaToVertexTheory");
1186 fhCutStatistics->Write();
1187 fhCutCorrelation->Write();
1189 for (Int_t i=0; i<2; i++) {
1191 gDirectory->cd("before_cuts");
1193 gDirectory->cd("after_cuts");
1195 fhNClustersITS[i] ->Write();
1196 fhNClustersTPC[i] ->Write();
1197 fhChi2PerClusterITS[i] ->Write();
1198 fhChi2PerClusterTPC[i] ->Write();
1206 fhRel1PtUncertainty[i] ->Write();
1210 fhDXYDZ[i] ->Write();
1211 fhDXYvsDZ[i] ->Write();
1213 fhDXYNormalized[i] ->Write();
1214 fhDZNormalized[i] ->Write();
1215 fhDXYvsDZNormalized[i] ->Write();
1216 fhNSigmaToVertex[i] ->Write();
1221 gDirectory->cd("../");
1224 gDirectory->cd("../");
1227 //____________________________________________________________________
1228 void AliESDtrackCuts::DrawHistograms()
1230 // draws some histograms
1232 TCanvas* canvas1 = new TCanvas(Form("%s_1", GetName()), "Track Quality Results1", 800, 800);
1233 canvas1->Divide(2, 2);
1236 fhNClustersTPC[0]->SetStats(kFALSE);
1237 fhNClustersTPC[0]->Draw();
1240 fhChi2PerClusterTPC[0]->SetStats(kFALSE);
1241 fhChi2PerClusterTPC[0]->Draw();
1244 fhNSigmaToVertex[0]->SetStats(kFALSE);
1245 fhNSigmaToVertex[0]->GetXaxis()->SetRangeUser(0, 10);
1246 fhNSigmaToVertex[0]->Draw();
1248 canvas1->SaveAs(Form("%s_%s.gif", GetName(), canvas1->GetName()));
1250 TCanvas* canvas2 = new TCanvas(Form("%s_2", GetName()), "Track Quality Results2", 1200, 800);
1251 canvas2->Divide(3, 2);
1254 fhC11[0]->SetStats(kFALSE);
1259 fhC22[0]->SetStats(kFALSE);
1264 fhC33[0]->SetStats(kFALSE);
1269 fhC44[0]->SetStats(kFALSE);
1274 fhC55[0]->SetStats(kFALSE);
1279 fhRel1PtUncertainty[0]->SetStats(kFALSE);
1281 fhRel1PtUncertainty[0]->Draw();
1283 canvas2->SaveAs(Form("%s_%s.gif", GetName(), canvas2->GetName()));
1285 TCanvas* canvas3 = new TCanvas(Form("%s_3", GetName()), "Track Quality Results3", 1200, 800);
1286 canvas3->Divide(3, 2);
1289 fhDXY[0]->SetStats(kFALSE);
1294 fhDZ[0]->SetStats(kFALSE);
1299 fhDXYvsDZ[0]->SetStats(kFALSE);
1301 gPad->SetRightMargin(0.15);
1302 fhDXYvsDZ[0]->Draw("COLZ");
1305 fhDXYNormalized[0]->SetStats(kFALSE);
1307 fhDXYNormalized[0]->Draw();
1310 fhDZNormalized[0]->SetStats(kFALSE);
1312 fhDZNormalized[0]->Draw();
1315 fhDXYvsDZNormalized[0]->SetStats(kFALSE);
1317 gPad->SetRightMargin(0.15);
1318 fhDXYvsDZNormalized[0]->Draw("COLZ");
1320 canvas3->SaveAs(Form("%s_%s.gif", GetName(), canvas3->GetName()));
1322 TCanvas* canvas4 = new TCanvas(Form("%s_4", GetName()), "Track Quality Results4", 800, 500);
1323 canvas4->Divide(2, 1);
1326 fhCutStatistics->SetStats(kFALSE);
1327 fhCutStatistics->LabelsOption("v");
1328 gPad->SetBottomMargin(0.3);
1329 fhCutStatistics->Draw();
1332 fhCutCorrelation->SetStats(kFALSE);
1333 fhCutCorrelation->LabelsOption("v");
1334 gPad->SetBottomMargin(0.3);
1335 gPad->SetLeftMargin(0.3);
1336 fhCutCorrelation->Draw("COLZ");
1338 canvas4->SaveAs(Form("%s_%s.gif", GetName(), canvas4->GetName()));
1341 fhDXYvsDZNormalized[0]->SetStats(kFALSE);
1342 fhDXYvsDZNormalized[0]->DrawCopy("COLZ");
1345 fhNClustersTPC[0]->SetStats(kFALSE);
1346 fhNClustersTPC[0]->DrawCopy();
1349 fhChi2PerClusterITS[0]->SetStats(kFALSE);
1350 fhChi2PerClusterITS[0]->DrawCopy();
1351 fhChi2PerClusterITS[1]->SetLineColor(2);
1352 fhChi2PerClusterITS[1]->DrawCopy("SAME");
1355 fhChi2PerClusterTPC[0]->SetStats(kFALSE);
1356 fhChi2PerClusterTPC[0]->DrawCopy();
1357 fhChi2PerClusterTPC[1]->SetLineColor(2);
1358 fhChi2PerClusterTPC[1]->DrawCopy("SAME");*/