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",
58 "SPD cluster requirement",
59 "SDD cluster requirement",
60 "SSD cluster requirement"
63 //____________________________________________________________________
64 AliESDtrackCuts::AliESDtrackCuts(const Char_t* name, const Char_t* title) : AliAnalysisCuts(name,title),
65 fCutMinNClusterTPC(0),
66 fCutMinNClusterITS(0),
67 fCutMaxChi2PerClusterTPC(0),
68 fCutMaxChi2PerClusterITS(0),
74 fCutAcceptKinkDaughters(0),
75 fCutRequireTPCRefit(0),
76 fCutRequireITSRefit(0),
77 fCutNsigmaToVertex(0),
78 fCutSigmaToVertexRequired(0),
107 //##############################################################################
108 // setting default cuts
109 SetMinNClustersTPC();
110 SetMinNClustersITS();
111 SetMaxChi2PerClusterTPC();
112 SetMaxChi2PerClusterITS();
113 SetMaxCovDiagonalElements();
114 SetRequireTPCRefit();
115 SetRequireITSRefit();
116 SetAcceptKingDaughters();
117 SetMaxNsigmaToVertex();
119 SetMaxDCAToVertexXY();
120 SetMaxDCAToVertexZ();
128 SetClusterRequirementITS(kSPD);
129 SetClusterRequirementITS(kSDD);
130 SetClusterRequirementITS(kSSD);
135 //_____________________________________________________________________________
136 AliESDtrackCuts::AliESDtrackCuts(const AliESDtrackCuts &c) : AliAnalysisCuts(c),
137 fCutMinNClusterTPC(0),
138 fCutMinNClusterITS(0),
139 fCutMaxChi2PerClusterTPC(0),
140 fCutMaxChi2PerClusterITS(0),
146 fCutAcceptKinkDaughters(0),
147 fCutRequireTPCRefit(0),
148 fCutRequireITSRefit(0),
149 fCutNsigmaToVertex(0),
150 fCutSigmaToVertexRequired(0),
152 fCutDCAToVertexXY(0),
177 ((AliESDtrackCuts &) c).Copy(*this);
180 AliESDtrackCuts::~AliESDtrackCuts()
186 for (Int_t i=0; i<2; i++) {
188 if (fhNClustersITS[i])
189 delete fhNClustersITS[i];
190 if (fhNClustersTPC[i])
191 delete fhNClustersTPC[i];
192 if (fhChi2PerClusterITS[i])
193 delete fhChi2PerClusterITS[i];
194 if (fhChi2PerClusterTPC[i])
195 delete fhChi2PerClusterTPC[i];
216 if (fhDXYNormalized[i])
217 delete fhDXYNormalized[i];
218 if (fhDZNormalized[i])
219 delete fhDZNormalized[i];
220 if (fhDXYvsDZNormalized[i])
221 delete fhDXYvsDZNormalized[i];
222 if (fhNSigmaToVertex[i])
223 delete fhNSigmaToVertex[i];
231 delete ffDTheoretical;
234 delete fhCutStatistics;
235 if (fhCutCorrelation)
236 delete fhCutCorrelation;
239 void AliESDtrackCuts::Init()
242 // sets everything to zero
245 fCutMinNClusterTPC = 0;
246 fCutMinNClusterITS = 0;
248 fCutMaxChi2PerClusterTPC = 0;
249 fCutMaxChi2PerClusterITS = 0;
251 for (Int_t i = 0; i < 3; i++)
252 fCutClusterRequirementITS[i] = kOff;
260 fCutAcceptKinkDaughters = 0;
261 fCutRequireTPCRefit = 0;
262 fCutRequireITSRefit = 0;
264 fCutNsigmaToVertex = 0;
265 fCutSigmaToVertexRequired = 0;
267 fCutDCAToVertexXY = 0;
268 fCutDCAToVertexZ = 0;
285 fHistogramsOn = kFALSE;
287 for (Int_t i=0; i<2; ++i)
289 fhNClustersITS[i] = 0;
290 fhNClustersTPC[i] = 0;
292 fhChi2PerClusterITS[i] = 0;
293 fhChi2PerClusterTPC[i] = 0;
306 fhDXYNormalized[i] = 0;
307 fhDZNormalized[i] = 0;
308 fhDXYvsDZNormalized[i] = 0;
309 fhNSigmaToVertex[i] = 0;
317 fhCutCorrelation = 0;
320 //_____________________________________________________________________________
321 AliESDtrackCuts &AliESDtrackCuts::operator=(const AliESDtrackCuts &c)
324 // Assignment operator
327 if (this != &c) ((AliESDtrackCuts &) c).Copy(*this);
331 //_____________________________________________________________________________
332 void AliESDtrackCuts::Copy(TObject &c) const
338 AliESDtrackCuts& target = (AliESDtrackCuts &) c;
342 target.fCutMinNClusterTPC = fCutMinNClusterTPC;
343 target.fCutMinNClusterITS = fCutMinNClusterITS;
345 target.fCutMaxChi2PerClusterTPC = fCutMaxChi2PerClusterTPC;
346 target.fCutMaxChi2PerClusterITS = fCutMaxChi2PerClusterITS;
348 for (Int_t i = 0; i < 3; i++)
349 target.fCutClusterRequirementITS[i] = fCutClusterRequirementITS[i];
351 target.fCutMaxC11 = fCutMaxC11;
352 target.fCutMaxC22 = fCutMaxC22;
353 target.fCutMaxC33 = fCutMaxC33;
354 target.fCutMaxC44 = fCutMaxC44;
355 target.fCutMaxC55 = fCutMaxC55;
357 target.fCutAcceptKinkDaughters = fCutAcceptKinkDaughters;
358 target.fCutRequireTPCRefit = fCutRequireTPCRefit;
359 target.fCutRequireITSRefit = fCutRequireITSRefit;
361 target.fCutNsigmaToVertex = fCutNsigmaToVertex;
362 target.fCutSigmaToVertexRequired = fCutSigmaToVertexRequired;
363 target.fCutDCAToVertex = fCutDCAToVertex;
364 target.fCutDCAToVertexXY = fCutDCAToVertexXY;
365 target.fCutDCAToVertexZ = fCutDCAToVertexZ;
367 target.fPMin = fPMin;
368 target.fPMax = fPMax;
369 target.fPtMin = fPtMin;
370 target.fPtMax = fPtMax;
371 target.fPxMin = fPxMin;
372 target.fPxMax = fPxMax;
373 target.fPyMin = fPyMin;
374 target.fPyMax = fPyMax;
375 target.fPzMin = fPzMin;
376 target.fPzMax = fPzMax;
377 target.fEtaMin = fEtaMin;
378 target.fEtaMax = fEtaMax;
379 target.fRapMin = fRapMin;
380 target.fRapMax = fRapMax;
382 target.fHistogramsOn = fHistogramsOn;
384 for (Int_t i=0; i<2; ++i)
386 if (fhNClustersITS[i]) target.fhNClustersITS[i] = (TH1F*) fhNClustersITS[i]->Clone();
387 if (fhNClustersTPC[i]) target.fhNClustersTPC[i] = (TH1F*) fhNClustersTPC[i]->Clone();
389 if (fhChi2PerClusterITS[i]) target.fhChi2PerClusterITS[i] = (TH1F*) fhChi2PerClusterITS[i]->Clone();
390 if (fhChi2PerClusterTPC[i]) target.fhChi2PerClusterTPC[i] = (TH1F*) fhChi2PerClusterTPC[i]->Clone();
392 if (fhC11[i]) target.fhC11[i] = (TH1F*) fhC11[i]->Clone();
393 if (fhC22[i]) target.fhC22[i] = (TH1F*) fhC22[i]->Clone();
394 if (fhC33[i]) target.fhC33[i] = (TH1F*) fhC33[i]->Clone();
395 if (fhC44[i]) target.fhC44[i] = (TH1F*) fhC44[i]->Clone();
396 if (fhC55[i]) target.fhC55[i] = (TH1F*) fhC55[i]->Clone();
398 if (fhDXY[i]) target.fhDXY[i] = (TH1F*) fhDXY[i]->Clone();
399 if (fhDZ[i]) target.fhDZ[i] = (TH1F*) fhDZ[i]->Clone();
400 if (fhDXYDZ[i]) target.fhDXYDZ[i] = (TH1F*) fhDXYDZ[i]->Clone();
401 if (fhDXYvsDZ[i]) target.fhDXYvsDZ[i] = (TH2F*) fhDXYvsDZ[i]->Clone();
403 if (fhDXYNormalized[i]) target.fhDXYNormalized[i] = (TH1F*) fhDXYNormalized[i]->Clone();
404 if (fhDZNormalized[i]) target.fhDZNormalized[i] = (TH1F*) fhDZNormalized[i]->Clone();
405 if (fhDXYvsDZNormalized[i]) target.fhDXYvsDZNormalized[i] = (TH2F*) fhDXYvsDZNormalized[i]->Clone();
406 if (fhNSigmaToVertex[i]) target.fhNSigmaToVertex[i] = (TH1F*) fhNSigmaToVertex[i]->Clone();
408 if (fhPt[i]) target.fhPt[i] = (TH1F*) fhPt[i]->Clone();
409 if (fhEta[i]) target.fhEta[i] = (TH1F*) fhEta[i]->Clone();
411 if (ffDTheoretical) target.ffDTheoretical = (TF1*) ffDTheoretical->Clone();
413 if (fhCutStatistics) target.fhCutStatistics = (TH1F*) fhCutStatistics->Clone();
414 if (fhCutCorrelation) target.fhCutCorrelation = (TH2F*) fhCutCorrelation->Clone();
419 //_____________________________________________________________________________
420 Long64_t AliESDtrackCuts::Merge(TCollection* list) {
421 // Merge a list of AliESDtrackCuts objects with this (needed for PROOF)
422 // Returns the number of merged objects (including this)
429 TIterator* iter = list->MakeIterator();
432 // collection of measured and generated histograms
434 while ((obj = iter->Next())) {
436 AliESDtrackCuts* entry = dynamic_cast<AliESDtrackCuts*>(obj);
440 if (!entry->fHistogramsOn)
443 for (Int_t i=0; i<2; i++) {
445 fhNClustersITS[i] ->Add(entry->fhNClustersITS[i] );
446 fhNClustersTPC[i] ->Add(entry->fhNClustersTPC[i] );
448 fhChi2PerClusterITS[i] ->Add(entry->fhChi2PerClusterITS[i]);
449 fhChi2PerClusterTPC[i] ->Add(entry->fhChi2PerClusterTPC[i]);
451 fhC11[i] ->Add(entry->fhC11[i] );
452 fhC22[i] ->Add(entry->fhC22[i] );
453 fhC33[i] ->Add(entry->fhC33[i] );
454 fhC44[i] ->Add(entry->fhC44[i] );
455 fhC55[i] ->Add(entry->fhC55[i] );
457 fhDXY[i] ->Add(entry->fhDXY[i] );
458 fhDZ[i] ->Add(entry->fhDZ[i] );
459 fhDXYDZ[i] ->Add(entry->fhDXYDZ[i] );
460 fhDXYvsDZ[i] ->Add(entry->fhDXYvsDZ[i] );
462 fhDXYNormalized[i] ->Add(entry->fhDXYNormalized[i] );
463 fhDZNormalized[i] ->Add(entry->fhDZNormalized[i] );
464 fhDXYvsDZNormalized[i] ->Add(entry->fhDXYvsDZNormalized[i]);
465 fhNSigmaToVertex[i] ->Add(entry->fhNSigmaToVertex[i]);
467 fhPt[i] ->Add(entry->fhPt[i]);
468 fhEta[i] ->Add(entry->fhEta[i]);
471 fhCutStatistics ->Add(entry->fhCutStatistics);
472 fhCutCorrelation ->Add(entry->fhCutCorrelation);
480 //____________________________________________________________________
481 Float_t AliESDtrackCuts::GetSigmaToVertex(AliESDtrack* esdTrack)
483 // Calculates the number of sigma to the vertex.
488 esdTrack->GetImpactParameters(b,bCov);
490 if (bCov[0]<=0 || bCov[2]<=0) {
491 AliDebugClass(1, "Estimated b resolution lower or equal zero!");
492 bCov[0]=0; bCov[2]=0;
494 bRes[0] = TMath::Sqrt(bCov[0]);
495 bRes[1] = TMath::Sqrt(bCov[2]);
497 // -----------------------------------
498 // How to get to a n-sigma cut?
500 // The accumulated statistics from 0 to d is
502 // -> Erf(d/Sqrt(2)) for a 1-dim gauss (d = n_sigma)
503 // -> 1 - Exp(-d**2) for a 2-dim gauss (d*d = dx*dx + dy*dy != n_sigma)
505 // It means that for a 2-dim gauss: n_sigma(d) = Sqrt(2)*ErfInv(1 - Exp((-x**2)/2)
506 // Can this be expressed in a different way?
508 if (bRes[0] == 0 || bRes[1] ==0)
511 Float_t d = TMath::Sqrt(TMath::Power(b[0]/bRes[0],2) + TMath::Power(b[1]/bRes[1],2));
513 // work around precision problem
514 // if d is too big, TMath::Exp(...) gets 0, and TMath::ErfInverse(1) that should be infinite, gets 0 :(
515 // 1e-15 corresponds to nsigma ~ 7.7
516 if (TMath::Exp(-d * d / 2) < 1e-15)
519 Float_t nSigma = TMath::ErfInverse(1 - TMath::Exp(-d * d / 2)) * TMath::Sqrt(2);
523 void AliESDtrackCuts::EnableNeededBranches(TTree* tree)
525 // enables the branches needed by AcceptTrack, for a list see comment of AcceptTrack
527 tree->SetBranchStatus("fTracks.fFlags", 1);
528 tree->SetBranchStatus("fTracks.fITSncls", 1);
529 tree->SetBranchStatus("fTracks.fTPCncls", 1);
530 tree->SetBranchStatus("fTracks.fITSchi2", 1);
531 tree->SetBranchStatus("fTracks.fTPCchi2", 1);
532 tree->SetBranchStatus("fTracks.fC*", 1);
533 tree->SetBranchStatus("fTracks.fD", 1);
534 tree->SetBranchStatus("fTracks.fZ", 1);
535 tree->SetBranchStatus("fTracks.fCdd", 1);
536 tree->SetBranchStatus("fTracks.fCdz", 1);
537 tree->SetBranchStatus("fTracks.fCzz", 1);
538 tree->SetBranchStatus("fTracks.fP*", 1);
539 tree->SetBranchStatus("fTracks.fR*", 1);
540 tree->SetBranchStatus("fTracks.fKinkIndexes*", 1);
543 //____________________________________________________________________
545 AliESDtrackCuts::AcceptTrack(AliESDtrack* esdTrack) {
547 // figure out if the tracks survives all the track cuts defined
549 // the different quality parameter and kinematic values are first
550 // retrieved from the track. then it is found out what cuts the
551 // track did not survive and finally the cuts are imposed.
553 // this function needs the following branches:
559 // fTracks.fC //GetExternalCovariance
560 // fTracks.fD //GetImpactParameters
561 // fTracks.fZ //GetImpactParameters
562 // fTracks.fCdd //GetImpactParameters
563 // fTracks.fCdz //GetImpactParameters
564 // fTracks.fCzz //GetImpactParameters
565 // fTracks.fP //GetPxPyPz
566 // fTracks.fR //GetMass
567 // fTracks.fP //GetMass
568 // fTracks.fKinkIndexes
571 UInt_t status = esdTrack->GetStatus();
573 // getting quality parameters from the ESD track
574 Int_t nClustersITS = esdTrack->GetITSclusters(0);
575 Int_t nClustersTPC = esdTrack->GetTPCclusters(0);
577 Float_t chi2PerClusterITS = -1;
578 Float_t chi2PerClusterTPC = -1;
580 chi2PerClusterITS = esdTrack->GetITSchi2()/Float_t(nClustersITS);
582 chi2PerClusterTPC = esdTrack->GetTPCchi2()/Float_t(nClustersTPC);
584 esdTrack->GetExternalCovariance(extCov);
586 // getting the track to vertex parameters
587 Float_t nSigmaToVertex = GetSigmaToVertex(esdTrack);
591 esdTrack->GetImpactParameters(b,bCov);
592 if (bCov[0]<=0 || bCov[2]<=0) {
593 AliDebug(1, "Estimated b resolution lower or equal zero!");
594 bCov[0]=0; bCov[2]=0;
597 Float_t dcaToVertexXY = b[0];
598 Float_t dcaToVertexZ = b[1];
600 Float_t dcaToVertex = TMath::Sqrt(dcaToVertexXY*dcaToVertexXY + dcaToVertexZ*dcaToVertexZ);
602 // getting the kinematic variables of the track
603 // (assuming the mass is known)
605 esdTrack->GetPxPyPz(p);
607 Float_t momentum = TMath::Sqrt(TMath::Power(p[0],2) + TMath::Power(p[1],2) + TMath::Power(p[2],2));
608 Float_t pt = TMath::Sqrt(TMath::Power(p[0],2) + TMath::Power(p[1],2));
609 Float_t energy = TMath::Sqrt(TMath::Power(esdTrack->GetMass(),2) + TMath::Power(momentum,2));
612 //y-eta related calculations
615 if((momentum != TMath::Abs(p[2]))&&(momentum != 0))
616 eta = 0.5*TMath::Log((momentum + p[2])/(momentum - p[2]));
617 if((energy != TMath::Abs(p[2]))&&(momentum != 0))
618 y = 0.5*TMath::Log((energy + p[2])/(energy - p[2]));
621 //########################################################################
625 for (Int_t i=0; i<kNCuts; i++) cuts[i]=kFALSE;
627 // track quality cuts
628 if (fCutRequireTPCRefit && (status&AliESDtrack::kTPCrefit)==0)
630 if (fCutRequireITSRefit && (status&AliESDtrack::kITSrefit)==0)
632 if (nClustersTPC<fCutMinNClusterTPC)
634 if (nClustersITS<fCutMinNClusterITS)
636 if (chi2PerClusterTPC>fCutMaxChi2PerClusterTPC)
638 if (chi2PerClusterITS>fCutMaxChi2PerClusterITS)
640 if (extCov[0] > fCutMaxC11)
642 if (extCov[2] > fCutMaxC22)
644 if (extCov[5] > fCutMaxC33)
646 if (extCov[9] > fCutMaxC44)
648 if (extCov[14] > fCutMaxC55)
650 if (nSigmaToVertex > fCutNsigmaToVertex && fCutSigmaToVertexRequired)
652 // if n sigma could not be calculated
653 if (nSigmaToVertex<0 && fCutSigmaToVertexRequired)
655 if (!fCutAcceptKinkDaughters && esdTrack->GetKinkIndex(0)>0)
657 // track kinematics cut
658 if((momentum < fPMin) || (momentum > fPMax))
660 if((pt < fPtMin) || (pt > fPtMax))
662 if((p[0] < fPxMin) || (p[0] > fPxMax))
664 if((p[1] < fPyMin) || (p[1] > fPyMax))
666 if((p[2] < fPzMin) || (p[2] > fPzMax))
668 if((eta < fEtaMin) || (eta > fEtaMax))
670 if((y < fRapMin) || (y > fRapMax))
672 if (dcaToVertex > fCutDCAToVertex)
674 if (TMath::Abs(dcaToVertexXY) > fCutDCAToVertexXY)
676 if (TMath::Abs(dcaToVertexZ) > fCutDCAToVertexZ)
679 for (Int_t i = 0; i < 3; i++)
680 cuts[24+i] = !CheckITSClusterRequirement(fCutClusterRequirementITS[i], esdTrack->HasPointOnITSLayer(i*2), esdTrack->HasPointOnITSLayer(i*2+1));
683 for (Int_t i=0; i<kNCuts; i++)
684 if (cuts[i]) cut = kTRUE;
688 //########################################################################
689 // filling histograms
691 fhCutStatistics->Fill(fhCutStatistics->GetBinCenter(fhCutStatistics->GetXaxis()->FindBin("n tracks")));
693 fhCutStatistics->Fill(fhCutStatistics->GetBinCenter(fhCutStatistics->GetXaxis()->FindBin("n cut tracks")));
695 for (Int_t i=0; i<kNCuts; i++) {
697 fhCutStatistics->Fill(fhCutStatistics->GetBinCenter(fhCutStatistics->GetXaxis()->FindBin(fgkCutNames[i])));
699 for (Int_t j=i; j<kNCuts; j++) {
700 if (cuts[i] && cuts[j]) {
701 Float_t xC = fhCutCorrelation->GetXaxis()->GetBinCenter(fhCutCorrelation->GetXaxis()->FindBin(fgkCutNames[i]));
702 Float_t yC = fhCutCorrelation->GetYaxis()->GetBinCenter(fhCutCorrelation->GetYaxis()->FindBin(fgkCutNames[j]));
703 fhCutCorrelation->Fill(xC, yC);
709 // now we loop over the filling of the histograms twice: once "before" the cut, once "after"
710 // the code is not in a function due to too many local variables that would need to be passed
712 for (Int_t id = 0; id < 2; id++)
714 // id = 0 --> before cut
715 // id = 1 --> after cut
719 fhNClustersITS[id]->Fill(nClustersITS);
720 fhNClustersTPC[id]->Fill(nClustersTPC);
721 fhChi2PerClusterITS[id]->Fill(chi2PerClusterITS);
722 fhChi2PerClusterTPC[id]->Fill(chi2PerClusterTPC);
724 fhC11[id]->Fill(extCov[0]);
725 fhC22[id]->Fill(extCov[2]);
726 fhC33[id]->Fill(extCov[5]);
727 fhC44[id]->Fill(extCov[9]);
728 fhC55[id]->Fill(extCov[14]);
731 fhEta[id]->Fill(eta);
734 bRes[0] = TMath::Sqrt(bCov[0]);
735 bRes[1] = TMath::Sqrt(bCov[2]);
737 fhDZ[id]->Fill(b[1]);
738 fhDXY[id]->Fill(b[0]);
739 fhDXYDZ[id]->Fill(dcaToVertex);
740 fhDXYvsDZ[id]->Fill(b[1],b[0]);
742 if (bRes[0]!=0 && bRes[1]!=0) {
743 fhDZNormalized[id]->Fill(b[1]/bRes[1]);
744 fhDXYNormalized[id]->Fill(b[0]/bRes[0]);
745 fhDXYvsDZNormalized[id]->Fill(b[1]/bRes[1], b[0]/bRes[0]);
746 fhNSigmaToVertex[id]->Fill(nSigmaToVertex);
758 //____________________________________________________________________
759 Bool_t AliESDtrackCuts::CheckITSClusterRequirement(ITSClusterRequirement req, Bool_t clusterL1, Bool_t clusterL2)
761 // checks if the cluster requirement is fullfilled (in this case: return kTRUE)
765 case kOff: return kTRUE;
766 case kNone: return !clusterL1 && !clusterL2;
767 case kAny: return clusterL1 || clusterL2;
768 case kFirst: return clusterL1;
769 case kOnlyFirst: return clusterL1 && !clusterL2;
770 case kSecond: return clusterL2;
771 case kOnlySecond: return clusterL2 && !clusterL1;
772 case kBoth: return clusterL1 && clusterL2;
778 //____________________________________________________________________
779 AliESDtrack* AliESDtrackCuts::GetTPCOnlyTrack(AliESDEvent* esd, Int_t iTrack)
781 // creates a TPC only track from the given esd track
782 // the track has to be deleted by the user
784 // NB. most of the functionality to get a TPC only track from an ESD track is in AliESDtrack, where it should be
785 // there are only missing propagations here that are needed for old data
786 // this function will therefore become obsolete
788 // adapted from code provided by CKB
790 if (!esd->GetPrimaryVertexTPC())
791 return 0; // No TPC vertex no TPC tracks
793 if(!esd->GetPrimaryVertexTPC()->GetStatus())
794 return 0; // TPC Vertex is created by default in AliESDEvent, do not use in this case
796 AliESDtrack* track = esd->GetTrack(iTrack);
800 AliESDtrack *tpcTrack = new AliESDtrack();
802 // This should have been done during the reconstruction
803 // fixed by Juri in r26675
804 // but recalculate for older data CKB
806 track->GetImpactParametersTPC(p,cov);
808 track->RelateToVertexTPC(esd->GetPrimaryVertexTPC(),esd->GetMagneticField(),kVeryBig);
811 // only true if we have a tpc track
812 if (!track->FillTPCOnlyTrack(*tpcTrack))
818 // propagate to Vertex
819 // not needed for normal reconstructed ESDs...
820 // Double_t pTPC[2],covTPC[3];
821 // tpcTrack->PropagateToDCA(esd->GetPrimaryVertexTPC(), esd->GetMagneticField(), 10000, pTPC, covTPC);
826 //____________________________________________________________________
827 TObjArray* AliESDtrackCuts::GetAcceptedTracks(AliESDEvent* esd,Bool_t bTPC)
830 // returns an array of all tracks that pass the cuts
831 // or an array of TPC only tracks (propagated to the TPC vertex during reco)
832 // tracks that pass the cut
834 TObjArray* acceptedTracks = new TObjArray();
836 // loop over esd tracks
837 for (Int_t iTrack = 0; iTrack < esd->GetNumberOfTracks(); iTrack++) {
839 if(!esd->GetPrimaryVertexTPC())return acceptedTracks; // No TPC vertex no TPC tracks
840 if(!esd->GetPrimaryVertexTPC()->GetStatus())return acceptedTracks; // No proper TPC vertex, only the default
842 AliESDtrack *tpcTrack = GetTPCOnlyTrack(esd, iTrack);
846 if (AcceptTrack(tpcTrack)) {
847 acceptedTracks->Add(tpcTrack);
854 AliESDtrack* track = esd->GetTrack(iTrack);
855 if(AcceptTrack(track))
856 acceptedTracks->Add(track);
859 if(bTPC)acceptedTracks->SetOwner(kTRUE);
860 return acceptedTracks;
863 //____________________________________________________________________
864 Int_t AliESDtrackCuts::CountAcceptedTracks(AliESDEvent* esd)
867 // returns an the number of tracks that pass the cuts
872 // loop over esd tracks
873 for (Int_t iTrack = 0; iTrack < esd->GetNumberOfTracks(); iTrack++) {
874 AliESDtrack* track = esd->GetTrack(iTrack);
875 if (AcceptTrack(track))
882 //____________________________________________________________________
883 void AliESDtrackCuts::DefineHistograms(Int_t color) {
885 // diagnostics histograms are defined
890 Bool_t oldStatus = TH1::AddDirectoryStatus();
891 TH1::AddDirectory(kFALSE);
893 //###################################################################################
894 // defining histograms
896 fhCutStatistics = new TH1F("cut_statistics","cut statistics",kNCuts+4,-0.5,kNCuts+3.5);
898 fhCutStatistics->GetXaxis()->SetBinLabel(1,"n tracks");
899 fhCutStatistics->GetXaxis()->SetBinLabel(2,"n cut tracks");
901 fhCutCorrelation = new TH2F("cut_correlation","cut correlation",kNCuts,-0.5,kNCuts-0.5,kNCuts,-0.5,kNCuts-0.5);;
903 for (Int_t i=0; i<kNCuts; i++) {
904 fhCutStatistics->GetXaxis()->SetBinLabel(i+4,fgkCutNames[i]);
905 fhCutCorrelation->GetXaxis()->SetBinLabel(i+1,fgkCutNames[i]);
906 fhCutCorrelation->GetYaxis()->SetBinLabel(i+1,fgkCutNames[i]);
909 fhCutStatistics ->SetLineColor(color);
910 fhCutCorrelation ->SetLineColor(color);
911 fhCutStatistics ->SetLineWidth(2);
912 fhCutCorrelation ->SetLineWidth(2);
914 for (Int_t i=0; i<2; i++) {
915 fhNClustersITS[i] = new TH1F("nClustersITS" ,"",8,-0.5,7.5);
916 fhNClustersTPC[i] = new TH1F("nClustersTPC" ,"",165,-0.5,164.5);
917 fhChi2PerClusterITS[i] = new TH1F("chi2PerClusterITS","",500,0,10);
918 fhChi2PerClusterTPC[i] = new TH1F("chi2PerClusterTPC","",500,0,10);
920 fhC11[i] = new TH1F("covMatrixDiagonal11","",2000,0,20);
921 fhC22[i] = new TH1F("covMatrixDiagonal22","",2000,0,20);
922 fhC33[i] = new TH1F("covMatrixDiagonal33","",1000,0,0.1);
923 fhC44[i] = new TH1F("covMatrixDiagonal44","",1000,0,0.1);
924 fhC55[i] = new TH1F("covMatrixDiagonal55","",1000,0,5);
926 fhDXY[i] = new TH1F("dXY" ,"",500,-10,10);
927 fhDZ[i] = new TH1F("dZ" ,"",500,-10,10);
928 fhDXYDZ[i] = new TH1F("dXYDZ" ,"",500,0,10);
929 fhDXYvsDZ[i] = new TH2F("dXYvsDZ","",200,-10,10,200,-10,10);
931 fhDXYNormalized[i] = new TH1F("dXYNormalized" ,"",500,-10,10);
932 fhDZNormalized[i] = new TH1F("dZNormalized" ,"",500,-10,10);
933 fhDXYvsDZNormalized[i] = new TH2F("dXYvsDZNormalized","",200,-10,10,200,-10,10);
935 fhNSigmaToVertex[i] = new TH1F("nSigmaToVertex","",500,0,10);
937 fhPt[i] = new TH1F("pt" ,"p_{T} distribution;p_{T} (GeV/c)",500,0.0,100.0);
938 fhEta[i] = new TH1F("eta" ,"#eta distribution;#eta",40,-2.0,2.0);
940 fhNClustersITS[i]->SetTitle("n ITS clusters");
941 fhNClustersTPC[i]->SetTitle("n TPC clusters");
942 fhChi2PerClusterITS[i]->SetTitle("#Chi^{2} per ITS cluster");
943 fhChi2PerClusterTPC[i]->SetTitle("#Chi^{2} per TPC cluster");
945 fhC11[i]->SetTitle("cov 11 : #sigma_{y}^{2} [cm^{2}]");
946 fhC22[i]->SetTitle("cov 22 : #sigma_{z}^{2} [cm^{2}]");
947 fhC33[i]->SetTitle("cov 33 : #sigma_{sin(#phi)}^{2}");
948 fhC44[i]->SetTitle("cov 44 : #sigma_{tan(#theta_{dip})}^{2}");
949 fhC55[i]->SetTitle("cov 55 : #sigma_{1/p_{T}}^{2} [(c/GeV)^2]");
951 fhDXY[i]->SetTitle("transverse impact parameter");
952 fhDZ[i]->SetTitle("longitudinal impact parameter");
953 fhDXYDZ[i]->SetTitle("absolute impact parameter;sqrt(dXY**2 + dZ**2) in cm");
954 fhDXYvsDZ[i]->SetXTitle("longitudinal impact parameter");
955 fhDXYvsDZ[i]->SetYTitle("transverse impact parameter");
957 fhDXYNormalized[i]->SetTitle("normalized trans impact par");
958 fhDZNormalized[i]->SetTitle("normalized long impact par");
959 fhDXYvsDZNormalized[i]->SetTitle("normalized long impact par");
960 fhDXYvsDZNormalized[i]->SetYTitle("normalized trans impact par");
961 fhNSigmaToVertex[i]->SetTitle("n #sigma to vertex");
963 fhNClustersITS[i]->SetLineColor(color); fhNClustersITS[i]->SetLineWidth(2);
964 fhNClustersTPC[i]->SetLineColor(color); fhNClustersTPC[i]->SetLineWidth(2);
965 fhChi2PerClusterITS[i]->SetLineColor(color); fhChi2PerClusterITS[i]->SetLineWidth(2);
966 fhChi2PerClusterTPC[i]->SetLineColor(color); fhChi2PerClusterTPC[i]->SetLineWidth(2);
968 fhC11[i]->SetLineColor(color); fhC11[i]->SetLineWidth(2);
969 fhC22[i]->SetLineColor(color); fhC22[i]->SetLineWidth(2);
970 fhC33[i]->SetLineColor(color); fhC33[i]->SetLineWidth(2);
971 fhC44[i]->SetLineColor(color); fhC44[i]->SetLineWidth(2);
972 fhC55[i]->SetLineColor(color); fhC55[i]->SetLineWidth(2);
974 fhDXY[i]->SetLineColor(color); fhDXY[i]->SetLineWidth(2);
975 fhDZ[i]->SetLineColor(color); fhDZ[i]->SetLineWidth(2);
976 fhDXYDZ[i]->SetLineColor(color); fhDXYDZ[i]->SetLineWidth(2);
978 fhDXYNormalized[i]->SetLineColor(color); fhDXYNormalized[i]->SetLineWidth(2);
979 fhDZNormalized[i]->SetLineColor(color); fhDZNormalized[i]->SetLineWidth(2);
980 fhNSigmaToVertex[i]->SetLineColor(color); fhNSigmaToVertex[i]->SetLineWidth(2);
983 // The number of sigmas to the vertex is per definition gaussian
984 ffDTheoretical = new TF1("nSigmaToVertexTheoretical","([0]/2.506628274)*exp(-(x**2)/2)",0,50);
985 ffDTheoretical->SetParameter(0,1);
987 TH1::AddDirectory(oldStatus);
990 //____________________________________________________________________
991 Bool_t AliESDtrackCuts::LoadHistograms(const Char_t* dir)
994 // loads the histograms from a file
995 // if dir is empty a directory with the name of this object is taken (like in SaveHistogram)
1001 if (!gDirectory->cd(dir))
1004 ffDTheoretical = dynamic_cast<TF1*> (gDirectory->Get("nSigmaToVertexTheory"));
1006 fhCutStatistics = dynamic_cast<TH1F*> (gDirectory->Get("cut_statistics"));
1007 fhCutCorrelation = dynamic_cast<TH2F*> (gDirectory->Get("cut_correlation"));
1009 for (Int_t i=0; i<2; i++) {
1012 gDirectory->cd("before_cuts");
1015 gDirectory->cd("after_cuts");
1017 fhNClustersITS[i] = dynamic_cast<TH1F*> (gDirectory->Get("nClustersITS" ));
1018 fhNClustersTPC[i] = dynamic_cast<TH1F*> (gDirectory->Get("nClustersTPC" ));
1019 fhChi2PerClusterITS[i] = dynamic_cast<TH1F*> (gDirectory->Get("chi2PerClusterITS"));
1020 fhChi2PerClusterTPC[i] = dynamic_cast<TH1F*> (gDirectory->Get("chi2PerClusterTPC"));
1022 fhC11[i] = dynamic_cast<TH1F*> (gDirectory->Get("covMatrixDiagonal11"));
1023 fhC22[i] = dynamic_cast<TH1F*> (gDirectory->Get("covMatrixDiagonal22"));
1024 fhC33[i] = dynamic_cast<TH1F*> (gDirectory->Get("covMatrixDiagonal33"));
1025 fhC44[i] = dynamic_cast<TH1F*> (gDirectory->Get("covMatrixDiagonal44"));
1026 fhC55[i] = dynamic_cast<TH1F*> (gDirectory->Get("covMatrixDiagonal55"));
1028 fhDXY[i] = dynamic_cast<TH1F*> (gDirectory->Get("dXY" ));
1029 fhDZ[i] = dynamic_cast<TH1F*> (gDirectory->Get("dZ" ));
1030 fhDXYDZ[i] = dynamic_cast<TH1F*> (gDirectory->Get("dXYDZ"));
1031 fhDXYvsDZ[i] = dynamic_cast<TH2F*> (gDirectory->Get("dXYvsDZ"));
1033 fhDXYNormalized[i] = dynamic_cast<TH1F*> (gDirectory->Get("dXYNormalized" ));
1034 fhDZNormalized[i] = dynamic_cast<TH1F*> (gDirectory->Get("dZNormalized" ));
1035 fhDXYvsDZNormalized[i] = dynamic_cast<TH2F*> (gDirectory->Get("dXYvsDZNormalized"));
1036 fhNSigmaToVertex[i] = dynamic_cast<TH1F*> (gDirectory->Get("nSigmaToVertex"));
1038 fhPt[i] = dynamic_cast<TH1F*> (gDirectory->Get("pt"));
1039 fhEta[i] = dynamic_cast<TH1F*> (gDirectory->Get("eta"));
1041 gDirectory->cd("../");
1044 gDirectory->cd("..");
1049 //____________________________________________________________________
1050 void AliESDtrackCuts::SaveHistograms(const Char_t* dir) {
1052 // saves the histograms in a directory (dir)
1055 if (!fHistogramsOn) {
1056 AliDebug(0, "Histograms not on - cannot save histograms!!!");
1063 gDirectory->mkdir(dir);
1064 gDirectory->cd(dir);
1066 gDirectory->mkdir("before_cuts");
1067 gDirectory->mkdir("after_cuts");
1069 // a factor of 2 is needed since n sigma is positive
1070 ffDTheoretical->SetParameter(0,2*fhNSigmaToVertex[0]->Integral("width"));
1071 ffDTheoretical->Write("nSigmaToVertexTheory");
1073 fhCutStatistics->Write();
1074 fhCutCorrelation->Write();
1076 for (Int_t i=0; i<2; i++) {
1078 gDirectory->cd("before_cuts");
1080 gDirectory->cd("after_cuts");
1082 fhNClustersITS[i] ->Write();
1083 fhNClustersTPC[i] ->Write();
1084 fhChi2PerClusterITS[i] ->Write();
1085 fhChi2PerClusterTPC[i] ->Write();
1095 fhDXYDZ[i] ->Write();
1096 fhDXYvsDZ[i] ->Write();
1098 fhDXYNormalized[i] ->Write();
1099 fhDZNormalized[i] ->Write();
1100 fhDXYvsDZNormalized[i] ->Write();
1101 fhNSigmaToVertex[i] ->Write();
1106 gDirectory->cd("../");
1109 gDirectory->cd("../");
1112 //____________________________________________________________________
1113 void AliESDtrackCuts::DrawHistograms()
1115 // draws some histograms
1117 TCanvas* canvas1 = new TCanvas(Form("%s_1", GetName()), "Track Quality Results1", 800, 800);
1118 canvas1->Divide(2, 2);
1121 fhNClustersTPC[0]->SetStats(kFALSE);
1122 fhNClustersTPC[0]->Draw();
1125 fhChi2PerClusterTPC[0]->SetStats(kFALSE);
1126 fhChi2PerClusterTPC[0]->Draw();
1129 fhNSigmaToVertex[0]->SetStats(kFALSE);
1130 fhNSigmaToVertex[0]->GetXaxis()->SetRangeUser(0, 10);
1131 fhNSigmaToVertex[0]->Draw();
1133 canvas1->SaveAs(Form("%s_%s.gif", GetName(), canvas1->GetName()));
1135 TCanvas* canvas2 = new TCanvas(Form("%s_2", GetName()), "Track Quality Results2", 1200, 800);
1136 canvas2->Divide(3, 2);
1139 fhC11[0]->SetStats(kFALSE);
1144 fhC22[0]->SetStats(kFALSE);
1149 fhC33[0]->SetStats(kFALSE);
1154 fhC44[0]->SetStats(kFALSE);
1159 fhC55[0]->SetStats(kFALSE);
1163 canvas2->SaveAs(Form("%s_%s.gif", GetName(), canvas2->GetName()));
1165 TCanvas* canvas3 = new TCanvas(Form("%s_3", GetName()), "Track Quality Results3", 1200, 800);
1166 canvas3->Divide(3, 2);
1169 fhDXY[0]->SetStats(kFALSE);
1174 fhDZ[0]->SetStats(kFALSE);
1179 fhDXYvsDZ[0]->SetStats(kFALSE);
1181 gPad->SetRightMargin(0.15);
1182 fhDXYvsDZ[0]->Draw("COLZ");
1185 fhDXYNormalized[0]->SetStats(kFALSE);
1187 fhDXYNormalized[0]->Draw();
1190 fhDZNormalized[0]->SetStats(kFALSE);
1192 fhDZNormalized[0]->Draw();
1195 fhDXYvsDZNormalized[0]->SetStats(kFALSE);
1197 gPad->SetRightMargin(0.15);
1198 fhDXYvsDZNormalized[0]->Draw("COLZ");
1200 canvas3->SaveAs(Form("%s_%s.gif", GetName(), canvas3->GetName()));
1202 TCanvas* canvas4 = new TCanvas(Form("%s_4", GetName()), "Track Quality Results4", 800, 500);
1203 canvas4->Divide(2, 1);
1206 fhCutStatistics->SetStats(kFALSE);
1207 fhCutStatistics->LabelsOption("v");
1208 gPad->SetBottomMargin(0.3);
1209 fhCutStatistics->Draw();
1212 fhCutCorrelation->SetStats(kFALSE);
1213 fhCutCorrelation->LabelsOption("v");
1214 gPad->SetBottomMargin(0.3);
1215 gPad->SetLeftMargin(0.3);
1216 fhCutCorrelation->Draw("COLZ");
1218 canvas4->SaveAs(Form("%s_%s.gif", GetName(), canvas4->GetName()));
1221 fhDXYvsDZNormalized[0]->SetStats(kFALSE);
1222 fhDXYvsDZNormalized[0]->DrawCopy("COLZ");
1225 fhNClustersTPC[0]->SetStats(kFALSE);
1226 fhNClustersTPC[0]->DrawCopy();
1229 fhChi2PerClusterITS[0]->SetStats(kFALSE);
1230 fhChi2PerClusterITS[0]->DrawCopy();
1231 fhChi2PerClusterITS[1]->SetLineColor(2);
1232 fhChi2PerClusterITS[1]->DrawCopy("SAME");
1235 fhChi2PerClusterTPC[0]->SetStats(kFALSE);
1236 fhChi2PerClusterTPC[0]->DrawCopy();
1237 fhChi2PerClusterTPC[1]->SetLineColor(2);
1238 fhChi2PerClusterTPC[1]->DrawCopy("SAME");*/
1241 Float_t AliESDtrackCuts::GetMinNsigmaToVertex() const
1243 // deprecated, please use GetMaxNsigmaToVertex
1245 Printf("WARNING: AliESDtrackCuts::GetMinNsigmaToVertex is DEPRECATED and will be removed in the next release. Please use GetMaxNsigmaToVertex instead. Renaming was done to improve code readability.");
1247 return GetMaxNsigmaToVertex();
1250 void AliESDtrackCuts::SetMinNsigmaToVertex(Float_t sigma)
1252 // deprecated, will be removed in next release
1254 Printf("WARNING: AliESDtrackCuts::SetMinNsigmaToVertex is DEPRECATED and will be removed in the next release. Please use SetMaxNsigmaToVertex instead. Renaming was done to improve code readability.");
1256 SetMaxNsigmaToVertex(sigma);
1259 void AliESDtrackCuts::SetDCAToVertex(Float_t dist)
1261 // deprecated, will be removed in next release
1263 Printf("WARNING: AliESDtrackCuts::SetDCAToVertex is DEPRECATED and will be removed in the next release. Please use SetMaxDCAToVertex instead. Renaming was done to improve code readability.");
1265 SetMaxDCAToVertex(dist);
1268 void AliESDtrackCuts::SetDCAToVertexXY(Float_t dist)
1270 // deprecated, will be removed in next release
1272 Printf("WARNING: AliESDtrackCuts::SetDCAToVertexXY is DEPRECATED and will be removed in the next release. Please use SetMaxDCAToVertexXY instead. Renaming was done to improve code readability.");
1274 SetMaxDCAToVertexXY(dist);
1277 void AliESDtrackCuts::SetDCAToVertexZ(Float_t dist)
1279 // deprecated, will be removed in next release
1281 Printf("WARNING: AliESDtrackCuts::SetDCAToVertexZ is DEPRECATED and will be removed in the next release. Please use SetMaxDCAToVertexZ instead. Renaming was done to improve code readability.");
1283 SetMaxDCAToVertexZ(dist);