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 <AliESDEvent.h>
26 #include <TDirectory.h>
28 //____________________________________________________________________
29 ClassImp(AliESDtrackCuts)
32 const Char_t* AliESDtrackCuts::fgkCutNames[kNCuts] = {
37 "#Chi^{2}/clusters TPC",
38 "#Chi^{2}/clusters ITS",
54 "trk-to-vtx dca absolute",
55 "trk-to-vtx dca xy absolute"
58 //____________________________________________________________________
59 AliESDtrackCuts::AliESDtrackCuts(const Char_t* name, const Char_t* title) : AliAnalysisCuts(name,title),
60 fCutMinNClusterTPC(0),
61 fCutMinNClusterITS(0),
62 fCutMaxChi2PerClusterTPC(0),
63 fCutMaxChi2PerClusterITS(0),
69 fCutAcceptKinkDaughters(0),
70 fCutRequireTPCRefit(0),
71 fCutRequireITSRefit(0),
72 fCutNsigmaToVertex(0),
73 fCutSigmaToVertexRequired(0),
101 //##############################################################################
102 // setting default cuts
103 SetMinNClustersTPC();
104 SetMinNClustersITS();
105 SetMaxChi2PerClusterTPC();
106 SetMaxChi2PerClusterITS();
107 SetMaxCovDiagonalElements();
108 SetRequireTPCRefit();
109 SetRequireITSRefit();
110 SetAcceptKingDaughters();
111 SetMinNsigmaToVertex();
112 SetRequireSigmaToVertex();
126 //_____________________________________________________________________________
127 AliESDtrackCuts::AliESDtrackCuts(const AliESDtrackCuts &c) : AliAnalysisCuts(c),
128 fCutMinNClusterTPC(0),
129 fCutMinNClusterITS(0),
130 fCutMaxChi2PerClusterTPC(0),
131 fCutMaxChi2PerClusterITS(0),
137 fCutAcceptKinkDaughters(0),
138 fCutRequireTPCRefit(0),
139 fCutRequireITSRefit(0),
140 fCutNsigmaToVertex(0),
141 fCutSigmaToVertexRequired(0),
143 fCutDCAToVertexXY(0),
167 ((AliESDtrackCuts &) c).Copy(*this);
170 AliESDtrackCuts::~AliESDtrackCuts()
176 for (Int_t i=0; i<2; i++) {
178 if (fhNClustersITS[i])
179 delete fhNClustersITS[i];
180 if (fhNClustersTPC[i])
181 delete fhNClustersTPC[i];
182 if (fhChi2PerClusterITS[i])
183 delete fhChi2PerClusterITS[i];
184 if (fhChi2PerClusterTPC[i])
185 delete fhChi2PerClusterTPC[i];
206 if (fhDXYNormalized[i])
207 delete fhDXYNormalized[i];
208 if (fhDZNormalized[i])
209 delete fhDZNormalized[i];
210 if (fhDXYvsDZNormalized[i])
211 delete fhDXYvsDZNormalized[i];
212 if (fhNSigmaToVertex[i])
213 delete fhNSigmaToVertex[i];
221 delete ffDTheoretical;
224 delete fhCutStatistics;
225 if (fhCutCorrelation)
226 delete fhCutCorrelation;
229 void AliESDtrackCuts::Init()
232 // sets everything to zero
235 fCutMinNClusterTPC = 0;
236 fCutMinNClusterITS = 0;
238 fCutMaxChi2PerClusterTPC = 0;
239 fCutMaxChi2PerClusterITS = 0;
247 fCutAcceptKinkDaughters = 0;
248 fCutRequireTPCRefit = 0;
249 fCutRequireITSRefit = 0;
251 fCutNsigmaToVertex = 0;
252 fCutSigmaToVertexRequired = 0;
254 fCutDCAToVertexXY = 0;
271 fHistogramsOn = kFALSE;
273 for (Int_t i=0; i<2; ++i)
275 fhNClustersITS[i] = 0;
276 fhNClustersTPC[i] = 0;
278 fhChi2PerClusterITS[i] = 0;
279 fhChi2PerClusterTPC[i] = 0;
292 fhDXYNormalized[i] = 0;
293 fhDZNormalized[i] = 0;
294 fhDXYvsDZNormalized[i] = 0;
295 fhNSigmaToVertex[i] = 0;
303 fhCutCorrelation = 0;
306 //_____________________________________________________________________________
307 AliESDtrackCuts &AliESDtrackCuts::operator=(const AliESDtrackCuts &c)
310 // Assignment operator
313 if (this != &c) ((AliESDtrackCuts &) c).Copy(*this);
317 //_____________________________________________________________________________
318 void AliESDtrackCuts::Copy(TObject &c) const
324 AliESDtrackCuts& target = (AliESDtrackCuts &) c;
328 target.fCutMinNClusterTPC = fCutMinNClusterTPC;
329 target.fCutMinNClusterITS = fCutMinNClusterITS;
331 target.fCutMaxChi2PerClusterTPC = fCutMaxChi2PerClusterTPC;
332 target.fCutMaxChi2PerClusterITS = fCutMaxChi2PerClusterITS;
334 target.fCutMaxC11 = fCutMaxC11;
335 target.fCutMaxC22 = fCutMaxC22;
336 target.fCutMaxC33 = fCutMaxC33;
337 target.fCutMaxC44 = fCutMaxC44;
338 target.fCutMaxC55 = fCutMaxC55;
340 target.fCutAcceptKinkDaughters = fCutAcceptKinkDaughters;
341 target.fCutRequireTPCRefit = fCutRequireTPCRefit;
342 target.fCutRequireITSRefit = fCutRequireITSRefit;
344 target.fCutNsigmaToVertex = fCutNsigmaToVertex;
345 target.fCutSigmaToVertexRequired = fCutSigmaToVertexRequired;
346 target.fCutDCAToVertex = fCutDCAToVertex;
347 target.fCutDCAToVertexXY = fCutDCAToVertexXY;
349 target.fPMin = fPMin;
350 target.fPMax = fPMax;
351 target.fPtMin = fPtMin;
352 target.fPtMax = fPtMax;
353 target.fPxMin = fPxMin;
354 target.fPxMax = fPxMax;
355 target.fPyMin = fPyMin;
356 target.fPyMax = fPyMax;
357 target.fPzMin = fPzMin;
358 target.fPzMax = fPzMax;
359 target.fEtaMin = fEtaMin;
360 target.fEtaMax = fEtaMax;
361 target.fRapMin = fRapMin;
362 target.fRapMax = fRapMax;
364 target.fHistogramsOn = fHistogramsOn;
366 for (Int_t i=0; i<2; ++i)
368 if (fhNClustersITS[i]) target.fhNClustersITS[i] = (TH1F*) fhNClustersITS[i]->Clone();
369 if (fhNClustersTPC[i]) target.fhNClustersTPC[i] = (TH1F*) fhNClustersTPC[i]->Clone();
371 if (fhChi2PerClusterITS[i]) target.fhChi2PerClusterITS[i] = (TH1F*) fhChi2PerClusterITS[i]->Clone();
372 if (fhChi2PerClusterTPC[i]) target.fhChi2PerClusterTPC[i] = (TH1F*) fhChi2PerClusterTPC[i]->Clone();
374 if (fhC11[i]) target.fhC11[i] = (TH1F*) fhC11[i]->Clone();
375 if (fhC22[i]) target.fhC22[i] = (TH1F*) fhC22[i]->Clone();
376 if (fhC33[i]) target.fhC33[i] = (TH1F*) fhC33[i]->Clone();
377 if (fhC44[i]) target.fhC44[i] = (TH1F*) fhC44[i]->Clone();
378 if (fhC55[i]) target.fhC55[i] = (TH1F*) fhC55[i]->Clone();
380 if (fhDXY[i]) target.fhDXY[i] = (TH1F*) fhDXY[i]->Clone();
381 if (fhDZ[i]) target.fhDZ[i] = (TH1F*) fhDZ[i]->Clone();
382 if (fhDXYDZ[i]) target.fhDXYDZ[i] = (TH1F*) fhDXYDZ[i]->Clone();
383 if (fhDXYvsDZ[i]) target.fhDXYvsDZ[i] = (TH2F*) fhDXYvsDZ[i]->Clone();
385 if (fhDXYNormalized[i]) target.fhDXYNormalized[i] = (TH1F*) fhDXYNormalized[i]->Clone();
386 if (fhDZNormalized[i]) target.fhDZNormalized[i] = (TH1F*) fhDZNormalized[i]->Clone();
387 if (fhDXYvsDZNormalized[i]) target.fhDXYvsDZNormalized[i] = (TH2F*) fhDXYvsDZNormalized[i]->Clone();
388 if (fhNSigmaToVertex[i]) target.fhNSigmaToVertex[i] = (TH1F*) fhNSigmaToVertex[i]->Clone();
390 if (fhPt[i]) target.fhPt[i] = (TH1F*) fhPt[i]->Clone();
391 if (fhEta[i]) target.fhEta[i] = (TH1F*) fhEta[i]->Clone();
393 if (ffDTheoretical) target.ffDTheoretical = (TF1*) ffDTheoretical->Clone();
395 if (fhCutStatistics) target.fhCutStatistics = (TH1F*) fhCutStatistics->Clone();
396 if (fhCutCorrelation) target.fhCutCorrelation = (TH2F*) fhCutCorrelation->Clone();
401 //_____________________________________________________________________________
402 Long64_t AliESDtrackCuts::Merge(TCollection* list) {
403 // Merge a list of AliESDtrackCuts objects with this (needed for PROOF)
404 // Returns the number of merged objects (including this)
411 TIterator* iter = list->MakeIterator();
414 // collection of measured and generated histograms
416 while ((obj = iter->Next())) {
418 AliESDtrackCuts* entry = dynamic_cast<AliESDtrackCuts*>(obj);
422 if (!entry->fHistogramsOn)
425 for (Int_t i=0; i<2; i++) {
427 fhNClustersITS[i] ->Add(entry->fhNClustersITS[i] );
428 fhNClustersTPC[i] ->Add(entry->fhNClustersTPC[i] );
430 fhChi2PerClusterITS[i] ->Add(entry->fhChi2PerClusterITS[i]);
431 fhChi2PerClusterTPC[i] ->Add(entry->fhChi2PerClusterTPC[i]);
433 fhC11[i] ->Add(entry->fhC11[i] );
434 fhC22[i] ->Add(entry->fhC22[i] );
435 fhC33[i] ->Add(entry->fhC33[i] );
436 fhC44[i] ->Add(entry->fhC44[i] );
437 fhC55[i] ->Add(entry->fhC55[i] );
439 fhDXY[i] ->Add(entry->fhDXY[i] );
440 fhDZ[i] ->Add(entry->fhDZ[i] );
441 fhDXYDZ[i] ->Add(entry->fhDXYDZ[i] );
442 fhDXYvsDZ[i] ->Add(entry->fhDXYvsDZ[i] );
444 fhDXYNormalized[i] ->Add(entry->fhDXYNormalized[i] );
445 fhDZNormalized[i] ->Add(entry->fhDZNormalized[i] );
446 fhDXYvsDZNormalized[i] ->Add(entry->fhDXYvsDZNormalized[i]);
447 fhNSigmaToVertex[i] ->Add(entry->fhNSigmaToVertex[i]);
449 fhPt[i] ->Add(entry->fhPt[i]);
450 fhEta[i] ->Add(entry->fhEta[i]);
453 fhCutStatistics ->Add(entry->fhCutStatistics);
454 fhCutCorrelation ->Add(entry->fhCutCorrelation);
462 //____________________________________________________________________
463 Float_t AliESDtrackCuts::GetSigmaToVertex(AliESDtrack* esdTrack)
465 // Calculates the number of sigma to the vertex.
470 esdTrack->GetImpactParameters(b,bCov);
472 if (bCov[0]<=0 || bCov[2]<=0) {
473 AliDebugClass(1, "Estimated b resolution lower or equal zero!");
474 bCov[0]=0; bCov[2]=0;
476 bRes[0] = TMath::Sqrt(bCov[0]);
477 bRes[1] = TMath::Sqrt(bCov[2]);
479 // -----------------------------------
480 // How to get to a n-sigma cut?
482 // The accumulated statistics from 0 to d is
484 // -> Erf(d/Sqrt(2)) for a 1-dim gauss (d = n_sigma)
485 // -> 1 - Exp(-d**2) for a 2-dim gauss (d*d = dx*dx + dy*dy != n_sigma)
487 // It means that for a 2-dim gauss: n_sigma(d) = Sqrt(2)*ErfInv(1 - Exp((-x**2)/2)
488 // Can this be expressed in a different way?
490 if (bRes[0] == 0 || bRes[1] ==0)
493 Float_t d = TMath::Sqrt(TMath::Power(b[0]/bRes[0],2) + TMath::Power(b[1]/bRes[1],2));
495 // stupid rounding problem screws up everything:
496 // if d is too big, TMath::Exp(...) gets 0, and TMath::ErfInverse(1) that should be infinite, gets 0 :(
497 if (TMath::Exp(-d * d / 2) < 1e-10)
500 d = TMath::ErfInverse(1 - TMath::Exp(-d * d / 2)) * TMath::Sqrt(2);
504 void AliESDtrackCuts::EnableNeededBranches(TTree* tree)
506 // enables the branches needed by AcceptTrack, for a list see comment of AcceptTrack
508 tree->SetBranchStatus("fTracks.fFlags", 1);
509 tree->SetBranchStatus("fTracks.fITSncls", 1);
510 tree->SetBranchStatus("fTracks.fTPCncls", 1);
511 tree->SetBranchStatus("fTracks.fITSchi2", 1);
512 tree->SetBranchStatus("fTracks.fTPCchi2", 1);
513 tree->SetBranchStatus("fTracks.fC*", 1);
514 tree->SetBranchStatus("fTracks.fD", 1);
515 tree->SetBranchStatus("fTracks.fZ", 1);
516 tree->SetBranchStatus("fTracks.fCdd", 1);
517 tree->SetBranchStatus("fTracks.fCdz", 1);
518 tree->SetBranchStatus("fTracks.fCzz", 1);
519 tree->SetBranchStatus("fTracks.fP*", 1);
520 tree->SetBranchStatus("fTracks.fR*", 1);
521 tree->SetBranchStatus("fTracks.fKinkIndexes*", 1);
524 //____________________________________________________________________
526 AliESDtrackCuts::AcceptTrack(AliESDtrack* esdTrack) {
528 // figure out if the tracks survives all the track cuts defined
530 // the different quality parameter and kinematic values are first
531 // retrieved from the track. then it is found out what cuts the
532 // track did not survive and finally the cuts are imposed.
534 // this function needs the following branches:
540 // fTracks.fC //GetExternalCovariance
541 // fTracks.fD //GetImpactParameters
542 // fTracks.fZ //GetImpactParameters
543 // fTracks.fCdd //GetImpactParameters
544 // fTracks.fCdz //GetImpactParameters
545 // fTracks.fCzz //GetImpactParameters
546 // fTracks.fP //GetPxPyPz
547 // fTracks.fR //GetMass
548 // fTracks.fP //GetMass
549 // fTracks.fKinkIndexes
552 UInt_t status = esdTrack->GetStatus();
554 // getting quality parameters from the ESD track
555 Int_t nClustersITS = esdTrack->GetITSclusters(0);
556 Int_t nClustersTPC = esdTrack->GetTPCclusters(0);
558 Float_t chi2PerClusterITS = -1;
559 Float_t chi2PerClusterTPC = -1;
561 chi2PerClusterITS = esdTrack->GetITSchi2()/Float_t(nClustersITS);
563 chi2PerClusterTPC = esdTrack->GetTPCchi2()/Float_t(nClustersTPC);
565 esdTrack->GetExternalCovariance(extCov);
567 // getting the track to vertex parameters
568 Float_t nSigmaToVertex = GetSigmaToVertex(esdTrack);
572 esdTrack->GetImpactParameters(b,bCov);
573 if (bCov[0]<=0 || bCov[2]<=0) {
574 AliDebug(1, "Estimated b resolution lower or equal zero!");
575 bCov[0]=0; bCov[2]=0;
577 Float_t dcaToVertex = TMath::Sqrt(b[0]*b[0] + b[1]*b[1]);
579 Float_t dcaToVertexXY = b[0];
581 // getting the kinematic variables of the track
582 // (assuming the mass is known)
584 esdTrack->GetPxPyPz(p);
586 Float_t momentum = TMath::Sqrt(TMath::Power(p[0],2) + TMath::Power(p[1],2) + TMath::Power(p[2],2));
587 Float_t pt = TMath::Sqrt(TMath::Power(p[0],2) + TMath::Power(p[1],2));
588 Float_t energy = TMath::Sqrt(TMath::Power(esdTrack->GetMass(),2) + TMath::Power(momentum,2));
591 //y-eta related calculations
594 if((momentum != TMath::Abs(p[2]))&&(momentum != 0))
595 eta = 0.5*TMath::Log((momentum + p[2])/(momentum - p[2]));
596 if((energy != TMath::Abs(p[2]))&&(momentum != 0))
597 y = 0.5*TMath::Log((energy + p[2])/(energy - p[2]));
600 //########################################################################
604 for (Int_t i=0; i<kNCuts; i++) cuts[i]=kFALSE;
606 // track quality cuts
607 if (fCutRequireTPCRefit && (status&AliESDtrack::kTPCrefit)==0)
609 if (fCutRequireITSRefit && (status&AliESDtrack::kITSrefit)==0)
611 if (nClustersTPC<fCutMinNClusterTPC)
613 if (nClustersITS<fCutMinNClusterITS)
615 if (chi2PerClusterTPC>fCutMaxChi2PerClusterTPC)
617 if (chi2PerClusterITS>fCutMaxChi2PerClusterITS)
619 if (extCov[0] > fCutMaxC11)
621 if (extCov[2] > fCutMaxC22)
623 if (extCov[5] > fCutMaxC33)
625 if (extCov[9] > fCutMaxC44)
627 if (extCov[14] > fCutMaxC55)
629 if (nSigmaToVertex > fCutNsigmaToVertex && fCutSigmaToVertexRequired)
631 // if n sigma could not be calculated
632 if (nSigmaToVertex<0 && fCutSigmaToVertexRequired)
634 if (!fCutAcceptKinkDaughters && esdTrack->GetKinkIndex(0)>0)
636 // track kinematics cut
637 if((momentum < fPMin) || (momentum > fPMax))
639 if((pt < fPtMin) || (pt > fPtMax))
641 if((p[0] < fPxMin) || (p[0] > fPxMax))
643 if((p[1] < fPyMin) || (p[1] > fPyMax))
645 if((p[2] < fPzMin) || (p[2] > fPzMax))
647 if((eta < fEtaMin) || (eta > fEtaMax))
649 if((y < fRapMin) || (y > fRapMax))
651 if (dcaToVertex > fCutDCAToVertex)
653 if (dcaToVertexXY > fCutDCAToVertexXY)
657 for (Int_t i=0; i<kNCuts; i++)
658 if (cuts[i]) cut = kTRUE;
662 //########################################################################
663 // filling histograms
665 fhCutStatistics->Fill(fhCutStatistics->GetBinCenter(fhCutStatistics->GetXaxis()->FindBin("n tracks")));
667 fhCutStatistics->Fill(fhCutStatistics->GetBinCenter(fhCutStatistics->GetXaxis()->FindBin("n cut tracks")));
669 for (Int_t i=0; i<kNCuts; i++) {
671 fhCutStatistics->Fill(fhCutStatistics->GetBinCenter(fhCutStatistics->GetXaxis()->FindBin(fgkCutNames[i])));
673 for (Int_t j=i; j<kNCuts; j++) {
674 if (cuts[i] && cuts[j]) {
675 Float_t xC = fhCutCorrelation->GetXaxis()->GetBinCenter(fhCutCorrelation->GetXaxis()->FindBin(fgkCutNames[i]));
676 Float_t yC = fhCutCorrelation->GetYaxis()->GetBinCenter(fhCutCorrelation->GetYaxis()->FindBin(fgkCutNames[j]));
677 fhCutCorrelation->Fill(xC, yC);
683 // now we loop over the filling of the histograms twice: once "before" the cut, once "after"
684 // the code is not in a function due to too many local variables that would need to be passed
686 for (Int_t id = 0; id < 2; id++)
688 // id = 0 --> before cut
689 // id = 1 --> after cut
693 fhNClustersITS[id]->Fill(nClustersITS);
694 fhNClustersTPC[id]->Fill(nClustersTPC);
695 fhChi2PerClusterITS[id]->Fill(chi2PerClusterITS);
696 fhChi2PerClusterTPC[id]->Fill(chi2PerClusterTPC);
698 fhC11[id]->Fill(extCov[0]);
699 fhC22[id]->Fill(extCov[2]);
700 fhC33[id]->Fill(extCov[5]);
701 fhC44[id]->Fill(extCov[9]);
702 fhC55[id]->Fill(extCov[14]);
705 fhEta[id]->Fill(eta);
708 bRes[0] = TMath::Sqrt(bCov[0]);
709 bRes[1] = TMath::Sqrt(bCov[2]);
711 fhDZ[id]->Fill(b[1]);
712 fhDXY[id]->Fill(b[0]);
713 fhDXYDZ[id]->Fill(dcaToVertex);
714 fhDXYvsDZ[id]->Fill(b[1],b[0]);
716 if (bRes[0]!=0 && bRes[1]!=0) {
717 fhDZNormalized[id]->Fill(b[1]/bRes[1]);
718 fhDXYNormalized[id]->Fill(b[0]/bRes[0]);
719 fhDXYvsDZNormalized[id]->Fill(b[1]/bRes[1], b[0]/bRes[0]);
720 fhNSigmaToVertex[id]->Fill(nSigmaToVertex);
732 //____________________________________________________________________
733 AliESDtrack* AliESDtrackCuts::GetTPCOnlyTrack(AliESDEvent* esd, Int_t iTrack)
735 // creates a TPC only track from the given esd track
736 // the track has to be deleted by the user
738 // NB. most of the functionality to get a TPC only track from an ESD track is in AliESDtrack, where it should be
739 // there are only missing propagations here that are needed for old data
740 // this function will therefore become obsolete
742 // adapted from code provided by CKB
744 if (!esd->GetPrimaryVertexTPC())
745 return 0; // No TPC vertex no TPC tracks
747 AliESDtrack* track = esd->GetTrack(iTrack);
751 AliESDtrack *tpcTrack = new AliESDtrack();
753 // This should have been done during the reconstruction
754 // fixed by Juri in r26675
755 // but recalculate for older data CKB
757 track->GetImpactParametersTPC(p,cov);
759 track->RelateToVertexTPC(esd->GetPrimaryVertexTPC(),esd->GetMagneticField(),kVeryBig);
762 // only true if we have a tpc track
763 if (!track->FillTPCOnlyTrack(*tpcTrack))
769 // propagate to Vertex
770 // not needed for normal reconstructed ESDs...
771 // Double_t pTPC[2],covTPC[3];
772 // tpcTrack->PropagateToDCA(esd->GetPrimaryVertexTPC(), esd->GetMagneticField(), 10000, pTPC, covTPC);
777 //____________________________________________________________________
778 TObjArray* AliESDtrackCuts::GetAcceptedTracks(AliESDEvent* esd,Bool_t bTPC)
781 // returns an array of all tracks that pass the cuts
782 // or an array of TPC only tracks (propagated to the TPC vertex during reco)
783 // tracks that pass the cut
785 TObjArray* acceptedTracks = new TObjArray();
787 // loop over esd tracks
788 for (Int_t iTrack = 0; iTrack < esd->GetNumberOfTracks(); iTrack++) {
790 if(!esd->GetPrimaryVertexTPC())return acceptedTracks; // No TPC vertex no TPC tracks
792 AliESDtrack *tpcTrack = GetTPCOnlyTrack(esd, iTrack);
796 if (AcceptTrack(tpcTrack)) {
797 acceptedTracks->Add(tpcTrack);
804 AliESDtrack* track = esd->GetTrack(iTrack);
805 if(AcceptTrack(track))
806 acceptedTracks->Add(track);
809 if(bTPC)acceptedTracks->SetOwner(kTRUE);
810 return acceptedTracks;
813 //____________________________________________________________________
814 Int_t AliESDtrackCuts::CountAcceptedTracks(AliESDEvent* esd)
817 // returns an the number of tracks that pass the cuts
822 // loop over esd tracks
823 for (Int_t iTrack = 0; iTrack < esd->GetNumberOfTracks(); iTrack++) {
824 AliESDtrack* track = esd->GetTrack(iTrack);
825 if (AcceptTrack(track))
832 //____________________________________________________________________
833 void AliESDtrackCuts::DefineHistograms(Int_t color) {
835 // diagnostics histograms are defined
840 Bool_t oldStatus = TH1::AddDirectoryStatus();
841 TH1::AddDirectory(kFALSE);
843 //###################################################################################
844 // defining histograms
846 fhCutStatistics = new TH1F("cut_statistics","cut statistics",kNCuts+4,-0.5,kNCuts+3.5);
848 fhCutStatistics->GetXaxis()->SetBinLabel(1,"n tracks");
849 fhCutStatistics->GetXaxis()->SetBinLabel(2,"n cut tracks");
851 fhCutCorrelation = new TH2F("cut_correlation","cut correlation",kNCuts,-0.5,kNCuts-0.5,kNCuts,-0.5,kNCuts-0.5);;
853 for (Int_t i=0; i<kNCuts; i++) {
854 fhCutStatistics->GetXaxis()->SetBinLabel(i+4,fgkCutNames[i]);
855 fhCutCorrelation->GetXaxis()->SetBinLabel(i+1,fgkCutNames[i]);
856 fhCutCorrelation->GetYaxis()->SetBinLabel(i+1,fgkCutNames[i]);
859 fhCutStatistics ->SetLineColor(color);
860 fhCutCorrelation ->SetLineColor(color);
861 fhCutStatistics ->SetLineWidth(2);
862 fhCutCorrelation ->SetLineWidth(2);
864 for (Int_t i=0; i<2; i++) {
865 fhNClustersITS[i] = new TH1F("nClustersITS" ,"",8,-0.5,7.5);
866 fhNClustersTPC[i] = new TH1F("nClustersTPC" ,"",165,-0.5,164.5);
867 fhChi2PerClusterITS[i] = new TH1F("chi2PerClusterITS","",500,0,10);
868 fhChi2PerClusterTPC[i] = new TH1F("chi2PerClusterTPC","",500,0,10);
870 fhC11[i] = new TH1F("covMatrixDiagonal11","",2000,0,20);
871 fhC22[i] = new TH1F("covMatrixDiagonal22","",2000,0,20);
872 fhC33[i] = new TH1F("covMatrixDiagonal33","",1000,0,1);
873 fhC44[i] = new TH1F("covMatrixDiagonal44","",1000,0,5);
874 fhC55[i] = new TH1F("covMatrixDiagonal55","",1000,0,5);
876 fhDXY[i] = new TH1F("dXY" ,"",500,-10,10);
877 fhDZ[i] = new TH1F("dZ" ,"",500,-10,10);
878 fhDXYDZ[i] = new TH1F("dXYDZ" ,"",500,0,10);
879 fhDXYvsDZ[i] = new TH2F("dXYvsDZ","",200,-10,10,200,-10,10);
881 fhDXYNormalized[i] = new TH1F("dXYNormalized" ,"",500,-10,10);
882 fhDZNormalized[i] = new TH1F("dZNormalized" ,"",500,-10,10);
883 fhDXYvsDZNormalized[i] = new TH2F("dXYvsDZNormalized","",200,-10,10,200,-10,10);
885 fhNSigmaToVertex[i] = new TH1F("nSigmaToVertex","",500,0,10);
887 fhPt[i] = new TH1F("pt" ,"p_{T} distribution;p_{T} (GeV/c)",500,0.0,100.0);
888 fhEta[i] = new TH1F("eta" ,"#eta distribution;#eta",40,-2.0,2.0);
890 fhNClustersITS[i]->SetTitle("n ITS clusters");
891 fhNClustersTPC[i]->SetTitle("n TPC clusters");
892 fhChi2PerClusterITS[i]->SetTitle("#Chi^{2} per ITS cluster");
893 fhChi2PerClusterTPC[i]->SetTitle("#Chi^{2} per TPC cluster");
895 fhC11[i]->SetTitle("cov 11 : #sigma_{y}^{2} [cm^{2}]");
896 fhC22[i]->SetTitle("cov 22 : #sigma_{z}^{2} [cm^{2}]");
897 fhC33[i]->SetTitle("cov 33 : #sigma_{sin(#phi)}^{2}");
898 fhC44[i]->SetTitle("cov 44 : #sigma_{tan(#theta_{dip})}^{2}");
899 fhC55[i]->SetTitle("cov 55 : #sigma_{1/p_{T}}^{2} [(c/GeV)^2]");
901 fhDXY[i]->SetTitle("transverse impact parameter");
902 fhDZ[i]->SetTitle("longitudinal impact parameter");
903 fhDXYDZ[i]->SetTitle("absolute impact parameter;sqrt(dXY**2 + dZ**2) in cm");
904 fhDXYvsDZ[i]->SetXTitle("longitudinal impact parameter");
905 fhDXYvsDZ[i]->SetYTitle("transverse impact parameter");
907 fhDXYNormalized[i]->SetTitle("normalized trans impact par");
908 fhDZNormalized[i]->SetTitle("normalized long impact par");
909 fhDXYvsDZNormalized[i]->SetTitle("normalized long impact par");
910 fhDXYvsDZNormalized[i]->SetYTitle("normalized trans impact par");
911 fhNSigmaToVertex[i]->SetTitle("n #sigma to vertex");
913 fhNClustersITS[i]->SetLineColor(color); fhNClustersITS[i]->SetLineWidth(2);
914 fhNClustersTPC[i]->SetLineColor(color); fhNClustersTPC[i]->SetLineWidth(2);
915 fhChi2PerClusterITS[i]->SetLineColor(color); fhChi2PerClusterITS[i]->SetLineWidth(2);
916 fhChi2PerClusterTPC[i]->SetLineColor(color); fhChi2PerClusterTPC[i]->SetLineWidth(2);
918 fhC11[i]->SetLineColor(color); fhC11[i]->SetLineWidth(2);
919 fhC22[i]->SetLineColor(color); fhC22[i]->SetLineWidth(2);
920 fhC33[i]->SetLineColor(color); fhC33[i]->SetLineWidth(2);
921 fhC44[i]->SetLineColor(color); fhC44[i]->SetLineWidth(2);
922 fhC55[i]->SetLineColor(color); fhC55[i]->SetLineWidth(2);
924 fhDXY[i]->SetLineColor(color); fhDXY[i]->SetLineWidth(2);
925 fhDZ[i]->SetLineColor(color); fhDZ[i]->SetLineWidth(2);
926 fhDXYDZ[i]->SetLineColor(color); fhDXYDZ[i]->SetLineWidth(2);
928 fhDXYNormalized[i]->SetLineColor(color); fhDXYNormalized[i]->SetLineWidth(2);
929 fhDZNormalized[i]->SetLineColor(color); fhDZNormalized[i]->SetLineWidth(2);
930 fhNSigmaToVertex[i]->SetLineColor(color); fhNSigmaToVertex[i]->SetLineWidth(2);
933 // The number of sigmas to the vertex is per definition gaussian
934 ffDTheoretical = new TF1("nSigmaToVertexTheoretical","([0]/2.506628274)*exp(-(x**2)/2)",0,50);
935 ffDTheoretical->SetParameter(0,1);
937 TH1::AddDirectory(oldStatus);
940 //____________________________________________________________________
941 Bool_t AliESDtrackCuts::LoadHistograms(const Char_t* dir)
944 // loads the histograms from a file
945 // if dir is empty a directory with the name of this object is taken (like in SaveHistogram)
951 if (!gDirectory->cd(dir))
954 ffDTheoretical = dynamic_cast<TF1*> (gDirectory->Get("nSigmaToVertexTheory"));
956 fhCutStatistics = dynamic_cast<TH1F*> (gDirectory->Get("cut_statistics"));
957 fhCutCorrelation = dynamic_cast<TH2F*> (gDirectory->Get("cut_correlation"));
959 for (Int_t i=0; i<2; i++) {
962 gDirectory->cd("before_cuts");
965 gDirectory->cd("after_cuts");
967 fhNClustersITS[i] = dynamic_cast<TH1F*> (gDirectory->Get("nClustersITS" ));
968 fhNClustersTPC[i] = dynamic_cast<TH1F*> (gDirectory->Get("nClustersTPC" ));
969 fhChi2PerClusterITS[i] = dynamic_cast<TH1F*> (gDirectory->Get("chi2PerClusterITS"));
970 fhChi2PerClusterTPC[i] = dynamic_cast<TH1F*> (gDirectory->Get("chi2PerClusterTPC"));
972 fhC11[i] = dynamic_cast<TH1F*> (gDirectory->Get("covMatrixDiagonal11"));
973 fhC22[i] = dynamic_cast<TH1F*> (gDirectory->Get("covMatrixDiagonal22"));
974 fhC33[i] = dynamic_cast<TH1F*> (gDirectory->Get("covMatrixDiagonal33"));
975 fhC44[i] = dynamic_cast<TH1F*> (gDirectory->Get("covMatrixDiagonal44"));
976 fhC55[i] = dynamic_cast<TH1F*> (gDirectory->Get("covMatrixDiagonal55"));
978 fhDXY[i] = dynamic_cast<TH1F*> (gDirectory->Get("dXY" ));
979 fhDZ[i] = dynamic_cast<TH1F*> (gDirectory->Get("dZ" ));
980 fhDXYDZ[i] = dynamic_cast<TH1F*> (gDirectory->Get("dXYDZ"));
981 fhDXYvsDZ[i] = dynamic_cast<TH2F*> (gDirectory->Get("dXYvsDZ"));
983 fhDXYNormalized[i] = dynamic_cast<TH1F*> (gDirectory->Get("dXYNormalized" ));
984 fhDZNormalized[i] = dynamic_cast<TH1F*> (gDirectory->Get("dZNormalized" ));
985 fhDXYvsDZNormalized[i] = dynamic_cast<TH2F*> (gDirectory->Get("dXYvsDZNormalized"));
986 fhNSigmaToVertex[i] = dynamic_cast<TH1F*> (gDirectory->Get("nSigmaToVertex"));
988 fhPt[i] = dynamic_cast<TH1F*> (gDirectory->Get("pt"));
989 fhEta[i] = dynamic_cast<TH1F*> (gDirectory->Get("eta"));
991 gDirectory->cd("../");
994 gDirectory->cd("..");
999 //____________________________________________________________________
1000 void AliESDtrackCuts::SaveHistograms(const Char_t* dir) {
1002 // saves the histograms in a directory (dir)
1005 if (!fHistogramsOn) {
1006 AliDebug(0, "Histograms not on - cannot save histograms!!!");
1013 gDirectory->mkdir(dir);
1014 gDirectory->cd(dir);
1016 gDirectory->mkdir("before_cuts");
1017 gDirectory->mkdir("after_cuts");
1019 // a factor of 2 is needed since n sigma is positive
1020 ffDTheoretical->SetParameter(0,2*fhNSigmaToVertex[0]->Integral("width"));
1021 ffDTheoretical->Write("nSigmaToVertexTheory");
1023 fhCutStatistics->Write();
1024 fhCutCorrelation->Write();
1026 for (Int_t i=0; i<2; i++) {
1028 gDirectory->cd("before_cuts");
1030 gDirectory->cd("after_cuts");
1032 fhNClustersITS[i] ->Write();
1033 fhNClustersTPC[i] ->Write();
1034 fhChi2PerClusterITS[i] ->Write();
1035 fhChi2PerClusterTPC[i] ->Write();
1045 fhDXYDZ[i] ->Write();
1046 fhDXYvsDZ[i] ->Write();
1048 fhDXYNormalized[i] ->Write();
1049 fhDZNormalized[i] ->Write();
1050 fhDXYvsDZNormalized[i] ->Write();
1051 fhNSigmaToVertex[i] ->Write();
1056 gDirectory->cd("../");
1059 gDirectory->cd("../");
1062 //____________________________________________________________________
1063 void AliESDtrackCuts::DrawHistograms()
1065 // draws some histograms
1067 TCanvas* canvas1 = new TCanvas(Form("%s_1", GetName()), "Track Quality Results1", 800, 800);
1068 canvas1->Divide(2, 2);
1071 fhNClustersTPC[0]->SetStats(kFALSE);
1072 fhNClustersTPC[0]->Draw();
1075 fhChi2PerClusterTPC[0]->SetStats(kFALSE);
1076 fhChi2PerClusterTPC[0]->Draw();
1079 fhNSigmaToVertex[0]->SetStats(kFALSE);
1080 fhNSigmaToVertex[0]->GetXaxis()->SetRangeUser(0, 10);
1081 fhNSigmaToVertex[0]->Draw();
1083 canvas1->SaveAs(Form("%s_%s.gif", GetName(), canvas1->GetName()));
1085 TCanvas* canvas2 = new TCanvas(Form("%s_2", GetName()), "Track Quality Results2", 1200, 800);
1086 canvas2->Divide(3, 2);
1089 fhC11[0]->SetStats(kFALSE);
1094 fhC22[0]->SetStats(kFALSE);
1099 fhC33[0]->SetStats(kFALSE);
1104 fhC44[0]->SetStats(kFALSE);
1109 fhC55[0]->SetStats(kFALSE);
1113 canvas2->SaveAs(Form("%s_%s.gif", GetName(), canvas2->GetName()));
1115 TCanvas* canvas3 = new TCanvas(Form("%s_3", GetName()), "Track Quality Results3", 1200, 800);
1116 canvas3->Divide(3, 2);
1119 fhDXY[0]->SetStats(kFALSE);
1124 fhDZ[0]->SetStats(kFALSE);
1129 fhDXYvsDZ[0]->SetStats(kFALSE);
1131 gPad->SetRightMargin(0.15);
1132 fhDXYvsDZ[0]->Draw("COLZ");
1135 fhDXYNormalized[0]->SetStats(kFALSE);
1137 fhDXYNormalized[0]->Draw();
1140 fhDZNormalized[0]->SetStats(kFALSE);
1142 fhDZNormalized[0]->Draw();
1145 fhDXYvsDZNormalized[0]->SetStats(kFALSE);
1147 gPad->SetRightMargin(0.15);
1148 fhDXYvsDZNormalized[0]->Draw("COLZ");
1150 canvas3->SaveAs(Form("%s_%s.gif", GetName(), canvas3->GetName()));
1152 TCanvas* canvas4 = new TCanvas(Form("%s_4", GetName()), "Track Quality Results4", 800, 500);
1153 canvas4->Divide(2, 1);
1156 fhCutStatistics->SetStats(kFALSE);
1157 fhCutStatistics->LabelsOption("v");
1158 gPad->SetBottomMargin(0.3);
1159 fhCutStatistics->Draw();
1162 fhCutCorrelation->SetStats(kFALSE);
1163 fhCutCorrelation->LabelsOption("v");
1164 gPad->SetBottomMargin(0.3);
1165 gPad->SetLeftMargin(0.3);
1166 fhCutCorrelation->Draw("COLZ");
1168 canvas4->SaveAs(Form("%s_%s.gif", GetName(), canvas4->GetName()));
1171 fhDXYvsDZNormalized[0]->SetStats(kFALSE);
1172 fhDXYvsDZNormalized[0]->DrawCopy("COLZ");
1175 fhNClustersTPC[0]->SetStats(kFALSE);
1176 fhNClustersTPC[0]->DrawCopy();
1179 fhChi2PerClusterITS[0]->SetStats(kFALSE);
1180 fhChi2PerClusterITS[0]->DrawCopy();
1181 fhChi2PerClusterITS[1]->SetLineColor(2);
1182 fhChi2PerClusterITS[1]->DrawCopy("SAME");
1185 fhChi2PerClusterTPC[0]->SetStats(kFALSE);
1186 fhChi2PerClusterTPC[0]->DrawCopy();
1187 fhChi2PerClusterTPC[1]->SetLineColor(2);
1188 fhChi2PerClusterTPC[1]->DrawCopy("SAME");*/