1 #include "AliESDtrackCuts.h"
4 #include <AliESDtrack.h>
8 //____________________________________________________________________
9 ClassImp(AliESDtrackCuts)
12 const Char_t* AliESDtrackCuts::fgkCutNames[kNCuts] = {
17 "#Chi^{2}/clusters TPC",
18 "#Chi^{2}/clusters ITS",
36 //____________________________________________________________________
37 AliESDtrackCuts::AliESDtrackCuts() : TObject(),
38 fCutMinNClusterTPC(0),
39 fCutMinNClusterITS(0),
40 fCutMaxChi2PerClusterTPC(0),
41 fCutMaxChi2PerClusterITS(0),
47 fCutAcceptKinkDaughters(0),
48 fCutRequireTPCRefit(0),
49 fCutRequireITSRefit(0),
50 fCutNsigmaToVertex(0),
51 fCutSigmaToVertexRequired(0),
76 //##############################################################################
77 // setting default cuts
80 SetMaxChi2PerClusterTPC();
81 SetMaxChi2PerClusterITS();
82 SetMaxCovDiagonalElements();
85 SetAcceptKingDaughters();
86 SetMinNsigmaToVertex();
87 SetRequireSigmaToVertex();
99 //_____________________________________________________________________________
100 AliESDtrackCuts::AliESDtrackCuts(const AliESDtrackCuts &c) : TObject(c),
101 fCutMinNClusterTPC(0),
102 fCutMinNClusterITS(0),
103 fCutMaxChi2PerClusterTPC(0),
104 fCutMaxChi2PerClusterITS(0),
110 fCutAcceptKinkDaughters(0),
111 fCutRequireTPCRefit(0),
112 fCutRequireITSRefit(0),
113 fCutNsigmaToVertex(0),
114 fCutSigmaToVertexRequired(0),
137 ((AliESDtrackCuts &) c).Copy(*this);
140 AliESDtrackCuts::~AliESDtrackCuts()
146 // ## TODO to be implemented
149 void AliESDtrackCuts::Init()
152 // sets everything to zero
155 fCutMinNClusterTPC = 0;
156 fCutMinNClusterITS = 0;
158 fCutMaxChi2PerClusterTPC = 0;
159 fCutMaxChi2PerClusterITS = 0;
167 fCutAcceptKinkDaughters = 0;
168 fCutRequireTPCRefit = 0;
169 fCutRequireITSRefit = 0;
171 fCutNsigmaToVertex = 0;
172 fCutSigmaToVertexRequired = 0;
189 fHistogramsOn = kFALSE;
191 for (Int_t i=0; i<2; ++i)
193 fhNClustersITS[i] = 0;
194 fhNClustersTPC[i] = 0;
196 fhChi2PerClusterITS[i] = 0;
197 fhChi2PerClusterTPC[i] = 0;
209 fhDXYNormalized[i] = 0;
210 fhDZNormalized[i] = 0;
211 fhDXYvsDZNormalized[i] = 0;
215 fhCutCorrelation = 0;
218 //_____________________________________________________________________________
219 AliESDtrackCuts &AliESDtrackCuts::operator=(const AliESDtrackCuts &c)
222 // Assignment operator
225 if (this != &c) ((AliESDtrackCuts &) c).Copy(*this);
229 //_____________________________________________________________________________
230 void AliESDtrackCuts::Copy(TObject &c) const
236 AliESDtrackCuts& target = (AliESDtrackCuts &) c;
240 target.fCutMinNClusterTPC = fCutMinNClusterTPC;
241 target.fCutMinNClusterITS = fCutMinNClusterITS;
243 target.fCutMaxChi2PerClusterTPC = fCutMaxChi2PerClusterTPC;
244 target.fCutMaxChi2PerClusterITS = fCutMaxChi2PerClusterITS;
246 target.fCutMaxC11 = fCutMaxC11;
247 target.fCutMaxC22 = fCutMaxC22;
248 target.fCutMaxC33 = fCutMaxC33;
249 target.fCutMaxC44 = fCutMaxC44;
250 target.fCutMaxC55 = fCutMaxC55;
252 target.fCutAcceptKinkDaughters = fCutAcceptKinkDaughters;
253 target.fCutRequireTPCRefit = fCutRequireTPCRefit;
254 target.fCutRequireITSRefit = fCutRequireITSRefit;
256 target.fCutNsigmaToVertex = fCutNsigmaToVertex;
257 target.fCutSigmaToVertexRequired = fCutSigmaToVertexRequired;
259 target.fPMin = fPMin;
260 target.fPMax = fPMax;
261 target.fPtMin = fPtMin;
262 target.fPtMax = fPtMax;
263 target.fPxMin = fPxMin;
264 target.fPxMax = fPxMax;
265 target.fPyMin = fPyMin;
266 target.fPyMax = fPyMax;
267 target.fPzMin = fPzMin;
268 target.fPzMax = fPzMax;
269 target.fEtaMin = fEtaMin;
270 target.fEtaMax = fEtaMax;
271 target.fRapMin = fRapMin;
272 target.fRapMax = fRapMax;
274 target.fHistogramsOn = fHistogramsOn;
276 for (Int_t i=0; i<2; ++i)
278 if (fhNClustersITS[i]) target.fhNClustersITS[i] = (TH1F*) fhNClustersITS[i]->Clone();
279 if (fhNClustersTPC[i]) target.fhNClustersTPC[i] = (TH1F*) fhNClustersTPC[i]->Clone();
281 if (fhChi2PerClusterITS[i]) target.fhChi2PerClusterITS[i] = (TH1F*) fhChi2PerClusterITS[i]->Clone();
282 if (fhChi2PerClusterTPC[i]) target.fhChi2PerClusterTPC[i] = (TH1F*) fhChi2PerClusterTPC[i]->Clone();
284 if (fhC11[i]) target.fhC11[i] = (TH1F*) fhC11[i]->Clone();
285 if (fhC22[i]) target.fhC22[i] = (TH1F*) fhC22[i]->Clone();
286 if (fhC33[i]) target.fhC33[i] = (TH1F*) fhC33[i]->Clone();
287 if (fhC44[i]) target.fhC44[i] = (TH1F*) fhC44[i]->Clone();
288 if (fhC55[i]) target.fhC55[i] = (TH1F*) fhC55[i]->Clone();
290 if (fhDXY[i]) target.fhDXY[i] = (TH1F*) fhDXY[i]->Clone();
291 if (fhDZ[i]) target.fhDZ[i] = (TH1F*) fhDZ[i]->Clone();
292 if (fhDXYvsDZ[i]) target.fhDXYvsDZ[i] = (TH2F*) fhDXYvsDZ[i]->Clone();
294 if (fhDXYNormalized[i]) target.fhDXYNormalized[i] = (TH1F*) fhDXYNormalized[i]->Clone();
295 if (fhDZNormalized[i]) target.fhDZNormalized[i] = (TH1F*) fhDZNormalized[i]->Clone();
296 if (fhDXYvsDZNormalized[i]) target.fhDXYvsDZNormalized[i] = (TH2F*) fhDXYvsDZNormalized[i]->Clone();
299 if (fhCutStatistics) target.fhCutStatistics = (TH1F*) fhCutStatistics->Clone();
300 if (fhCutCorrelation) target.fhCutCorrelation = (TH2F*) fhCutCorrelation->Clone();
305 //____________________________________________________________________
306 Float_t AliESDtrackCuts::GetSigmaToVertex(AliESDtrack* esdTrack)
313 esdTrack->GetImpactParameters(b,bCov);
314 if (bCov[0]<=0 || bCov[2]<=0) {
315 AliDebug(1, "Estimated b resolution lower or equal zero!");
316 bCov[0]=0; bCov[2]=0;
318 bRes[0] = TMath::Sqrt(bCov[0]);
319 bRes[1] = TMath::Sqrt(bCov[2]);
321 // -----------------------------------
322 // How to get to a n-sigma cut?
324 // The accumulated statistics from 0 to d is
326 // -> Erf(d/Sqrt(2)) for a 1-dim gauss (d = n_sigma)
327 // -> 1 - Exp(-d**2) for a 2-dim gauss (d*d = dx*dx + dy*dy != n_sigma)
329 // It means that for a 2-dim gauss: n_sigma(d) = Sqrt(2)*ErfInv(1 - Exp((-x**2)/2)
330 // Can this be expressed in a different way?
333 // FIX: I don't think this is correct!!! Keeping d as n_sigma for now...
335 if (bRes[0] == 0 || bRes[1] ==0)
338 Float_t d = TMath::Sqrt(TMath::Power(b[0]/bRes[0],2) + TMath::Power(b[1]/bRes[1],2));
340 // stupid rounding problem screws up everything:
341 // if d is too big, TMath::Exp(...) gets 0, and TMath::ErfInverse(1) that should be infinite, gets 0 :(
342 if (TMath::Exp(-d * d / 2) < 1e-10)
345 d = TMath::ErfInverse(1 - TMath::Exp(-d * d / 2)) * TMath::Sqrt(2);
349 //____________________________________________________________________
351 AliESDtrackCuts::AcceptTrack(AliESDtrack* esdTrack) {
353 // figure out if the tracks survives all the track cuts defined
355 // the different quality parameter and kinematic values are first
356 // retrieved from the track. then it is found out what cuts the
357 // track did not survive and finally the cuts are imposed.
361 UInt_t status = esdTrack->GetStatus();
366 // getting quality parameters from the ESD track
367 Int_t nClustersITS = esdTrack->GetITSclusters(fIdxInt);
368 Int_t nClustersTPC = esdTrack->GetTPCclusters(fIdxInt);
372 Float_t chi2PerClusterITS = -1;
373 Float_t chi2PerClusterTPC = -1;
375 chi2PerClusterITS = esdTrack->GetITSchi2()/Float_t(nClustersITS);
377 chi2PerClusterTPC = esdTrack->GetTPCchi2()/Float_t(nClustersTPC);
380 esdTrack->GetExternalCovariance(extCov);
382 // getting the track to vertex parameters
383 Float_t nSigmaToVertex = GetSigmaToVertex(esdTrack);
385 // getting the kinematic variables of the track
386 // (assuming the mass is known)
388 esdTrack->GetPxPyPz(p);
389 Float_t momentum = TMath::Sqrt(TMath::Power(p[0],2) + TMath::Power(p[1],2) + TMath::Power(p[2],2));
390 Float_t pt = TMath::Sqrt(TMath::Power(p[0],2) + TMath::Power(p[1],2));
391 Float_t energy = TMath::Sqrt(TMath::Power(esdTrack->GetMass(),2) + TMath::Power(momentum,2));
394 //y-eta related calculations
397 if((momentum != TMath::Abs(p[2]))&&(momentum != 0))
398 eta = 0.5*TMath::Log((momentum + p[2])/(momentum - p[2]));
399 if((energy != TMath::Abs(p[2]))&&(momentum != 0))
400 y = 0.5*TMath::Log((energy + p[2])/(energy - p[2]));
403 //########################################################################
407 for (Int_t i=0; i<kNCuts; i++) cuts[i]=kFALSE;
409 // track quality cuts
410 if (fCutRequireTPCRefit && (status&AliESDtrack::kTPCrefit)==0)
412 if (fCutRequireITSRefit && (status&AliESDtrack::kITSrefit)==0)
414 if (nClustersTPC<fCutMinNClusterTPC)
416 if (nClustersITS<fCutMinNClusterITS)
418 if (chi2PerClusterTPC>fCutMaxChi2PerClusterTPC)
420 if (chi2PerClusterITS>fCutMaxChi2PerClusterITS)
422 if (extCov[0] > fCutMaxC11)
424 if (extCov[2] > fCutMaxC22)
426 if (extCov[5] > fCutMaxC33)
428 if (extCov[9] > fCutMaxC44)
430 if (extCov[14] > fCutMaxC55)
432 if (nSigmaToVertex > fCutNsigmaToVertex)
434 // if n sigma could not be calculated
435 if (nSigmaToVertex<0 && fCutSigmaToVertexRequired)
437 if (!fCutAcceptKinkDaughters && esdTrack->GetKinkIndex(0)>0)
439 // track kinematics cut
440 if((momentum < fPMin) || (momentum > fPMax))
442 if((pt < fPtMin) || (pt > fPtMax))
444 if((p[0] < fPxMin) || (p[0] > fPxMax))
446 if((p[1] < fPyMin) || (p[1] > fPyMax))
448 if((p[2] < fPzMin) || (p[2] > fPzMax))
450 if((eta < fEtaMin) || (eta > fEtaMax))
452 if((y < fRapMin) || (y > fRapMax))
456 for (Int_t i=0; i<kNCuts; i++)
457 if (cuts[i]) cut = kTRUE;
459 //########################################################################
460 // filling histograms
462 fhCutStatistics->Fill(fhCutStatistics->GetBinCenter(fhCutStatistics->GetXaxis()->FindBin("n tracks")));
465 fhCutStatistics->Fill(fhCutStatistics->GetBinCenter(fhCutStatistics->GetXaxis()->FindBin("n cut tracks")));
467 for (Int_t i=0; i<kNCuts; i++) {
469 fhCutStatistics->Fill(fhCutStatistics->GetBinCenter(fhCutStatistics->GetXaxis()->FindBin(fgkCutNames[i])));
471 for (Int_t j=i; j<kNCuts; j++) {
472 if (cuts[i] && cuts[j]) {
473 Float_t x = fhCutCorrelation->GetXaxis()->GetBinCenter(fhCutCorrelation->GetXaxis()->FindBin(fgkCutNames[i]));
474 Float_t y = fhCutCorrelation->GetYaxis()->GetBinCenter(fhCutCorrelation->GetYaxis()->FindBin(fgkCutNames[j]));
475 fhCutCorrelation->Fill(x,y);
481 fhNClustersITS[0]->Fill(nClustersITS);
482 fhNClustersTPC[0]->Fill(nClustersTPC);
483 fhChi2PerClusterITS[0]->Fill(chi2PerClusterITS);
484 fhChi2PerClusterTPC[0]->Fill(chi2PerClusterTPC);
486 fhC11[0]->Fill(extCov[0]);
487 fhC22[0]->Fill(extCov[2]);
488 fhC33[0]->Fill(extCov[5]);
489 fhC44[0]->Fill(extCov[9]);
490 fhC55[0]->Fill(extCov[14]);
495 esdTrack->GetImpactParameters(b,bCov);
496 if (bCov[0]<=0 || bCov[2]<=0) {
497 AliDebug(1, "Estimated b resolution lower or equal zero!");
498 bCov[0]=0; bCov[2]=0;
500 bRes[0] = TMath::Sqrt(bCov[0]);
501 bRes[1] = TMath::Sqrt(bCov[2]);
504 fhDXY[0]->Fill(b[0]);
505 fhDXYvsDZ[0]->Fill(b[1],b[0]);
507 if (bRes[0]!=0 && bRes[1]!=0) {
508 fhDZNormalized[0]->Fill(b[1]/bRes[1]);
509 fhDXYNormalized[0]->Fill(b[0]/bRes[0]);
510 fhDXYvsDZNormalized[0]->Fill(b[1]/bRes[1], b[0]/bRes[0]);
514 //########################################################################
516 if (cut) return kFALSE;
518 //########################################################################
519 // filling histograms after cut
521 fhNClustersITS[1]->Fill(nClustersITS);
522 fhNClustersTPC[1]->Fill(nClustersTPC);
523 fhChi2PerClusterITS[1]->Fill(chi2PerClusterITS);
524 fhChi2PerClusterTPC[1]->Fill(chi2PerClusterTPC);
526 fhC11[1]->Fill(extCov[0]);
527 fhC22[1]->Fill(extCov[2]);
528 fhC33[1]->Fill(extCov[5]);
529 fhC44[1]->Fill(extCov[9]);
530 fhC55[1]->Fill(extCov[14]);
535 esdTrack->GetImpactParameters(b,bCov);
536 if (bCov[0]<=0 || bCov[2]<=0) {
537 AliDebug(1, "Estimated b resolution lower or equal zero!");
538 bCov[0]=0; bCov[2]=0;
540 bRes[0] = TMath::Sqrt(bCov[0]);
541 bRes[1] = TMath::Sqrt(bCov[2]);
544 fhDXY[1]->Fill(b[0]);
545 fhDXYvsDZ[1]->Fill(b[1],b[0]);
547 if (bRes[0]!=0 && bRes[1]!=0)
549 fhDZNormalized[1]->Fill(b[1]/bRes[1]);
550 fhDXYNormalized[1]->Fill(b[0]/bRes[0]);
551 fhDXYvsDZNormalized[1]->Fill(b[1]/bRes[1], b[0]/bRes[0]);
558 //____________________________________________________________________
560 AliESDtrackCuts::GetAcceptedTracks(AliESD* esd)
563 // returns an array of all tracks that pass the cuts
566 TObjArray* acceptedTracks = new TObjArray();
568 // loop over esd tracks
569 for (Int_t iTrack = 0; iTrack < esd->GetNumberOfTracks(); iTrack++) {
570 AliESDtrack* track = esd->GetTrack(iTrack);
572 if (AcceptTrack(track))
573 acceptedTracks->Add(track);
576 return acceptedTracks;
579 //____________________________________________________________________
581 AliESDtrackCuts::CountAcceptedTracks(AliESD* esd)
584 // returns an the number of tracks that pass the cuts
589 // loop over esd tracks
590 for (Int_t iTrack = 0; iTrack < esd->GetNumberOfTracks(); iTrack++) {
591 AliESDtrack* track = esd->GetTrack(iTrack);
593 if (AcceptTrack(track))
600 //____________________________________________________________________
601 void AliESDtrackCuts::DefineHistograms(Int_t color) {
603 // diagnostics histograms are defined
608 //###################################################################################
609 // defining histograms
611 fhCutStatistics = new TH1F("cut_statistics","cut statistics",kNCuts+4,-0.5,kNCuts+3.5);
613 fhCutStatistics->GetXaxis()->SetBinLabel(1,"n tracks");
614 fhCutStatistics->GetXaxis()->SetBinLabel(2,"n cut tracks");
616 fhCutCorrelation = new TH2F("cut_correlation","cut correlation",kNCuts,-0.5,kNCuts-0.5,kNCuts,-0.5,kNCuts-0.5);;
618 for (Int_t i=0; i<kNCuts; i++) {
619 fhCutStatistics->GetXaxis()->SetBinLabel(i+4,fgkCutNames[i]);
620 fhCutCorrelation->GetXaxis()->SetBinLabel(i+1,fgkCutNames[i]);
621 fhCutCorrelation->GetYaxis()->SetBinLabel(i+1,fgkCutNames[i]);
624 fhCutStatistics ->SetLineColor(color);
625 fhCutCorrelation ->SetLineColor(color);
626 fhCutStatistics ->SetLineWidth(2);
627 fhCutCorrelation ->SetLineWidth(2);
630 for (Int_t i=0; i<2; i++) {
631 if (i==0) sprintf(str," ");
632 else sprintf(str,"_cut");
634 fhNClustersITS[i] = new TH1F(Form("nClustersITS%s",str),"",8,-0.5,7.5);
635 fhNClustersTPC[i] = new TH1F(Form("nClustersTPC%s",str),"",165,-0.5,164.5);
636 fhChi2PerClusterITS[i] = new TH1F(Form("chi2PerClusterITS%s",str),"",500,0,10);
637 fhChi2PerClusterTPC[i] = new TH1F(Form("chi2PerClusterTPC%s",str),"",500,0,10);
639 fhC11[i] = new TH1F(Form("covMatrixDiagonal11%s",str),"",1000,0,5);
640 fhC22[i] = new TH1F(Form("covMatrixDiagonal22%s",str),"",1000,0,5);
641 fhC33[i] = new TH1F(Form("covMatrixDiagonal33%s",str),"",1000,0,0.5);
642 fhC44[i] = new TH1F(Form("covMatrixDiagonal44%s",str),"",1000,0,5);
643 fhC55[i] = new TH1F(Form("covMatrixDiagonal55%s",str),"",1000,0,5);
645 fhDXY[i] = new TH1F(Form("dXY%s",str),"",500,-10,10);
646 fhDZ[i] = new TH1F(Form("dZ%s",str),"",500,-10,10);
647 fhDXYvsDZ[i] = new TH2F(Form("dXYvsDZ%s",str),"",200,-10,10,200,-10,10);
649 fhDXYNormalized[i] = new TH1F(Form("dXYNormalized%s",str),"",500,-10,10);
650 fhDZNormalized[i] = new TH1F(Form("dZNormalized%s",str),"",500,-10,10);
651 fhDXYvsDZNormalized[i] = new TH2F(Form("dXYvsDZNormalized%s",str),"",200,-10,10,200,-10,10);
654 fhNClustersITS[i]->SetXTitle("n ITS clusters");
655 fhNClustersTPC[i]->SetXTitle("n TPC clusters");
656 fhChi2PerClusterITS[i]->SetXTitle("#Chi^{2} per ITS cluster");
657 fhChi2PerClusterTPC[i]->SetXTitle("#Chi^{2} per TPC cluster");
659 fhC11[i]->SetXTitle("cov 11 : #sigma_{y}^{2} [cm^{2}]");
660 fhC22[i]->SetXTitle("cov 22 : #sigma_{z}^{2} [cm^{2}]");
661 fhC33[i]->SetXTitle("cov 33 : #sigma_{sin(#phi)}^{2}");
662 fhC44[i]->SetXTitle("cov 44 : #sigma_{tan(#theta_{dip})}^{2}");
663 fhC55[i]->SetXTitle("cov 55 : #sigma_{1/p_{T}}^{2} [(c/GeV)^2]");
665 fhDXY[i]->SetXTitle("transverse impact parameter");
666 fhDZ[i]->SetXTitle("longitudinal impact parameter");
667 fhDXYvsDZ[i]->SetXTitle("longitudinal impact parameter");
668 fhDXYvsDZ[i]->SetYTitle("transverse impact parameter");
670 fhDXYNormalized[i]->SetXTitle("normalized trans impact par");
671 fhDZNormalized[i]->SetXTitle("normalized long impact par");
672 fhDXYvsDZNormalized[i]->SetXTitle("normalized long impact par");
673 fhDXYvsDZNormalized[i]->SetYTitle("normalized trans impact par");
675 fhNClustersITS[i]->SetLineColor(color); fhNClustersITS[i]->SetLineWidth(2);
676 fhNClustersTPC[i]->SetLineColor(color); fhNClustersTPC[i]->SetLineWidth(2);
677 fhChi2PerClusterITS[i]->SetLineColor(color); fhChi2PerClusterITS[i]->SetLineWidth(2);
678 fhChi2PerClusterTPC[i]->SetLineColor(color); fhChi2PerClusterTPC[i]->SetLineWidth(2);
680 fhC11[i]->SetLineColor(color); fhC11[i]->SetLineWidth(2);
681 fhC22[i]->SetLineColor(color); fhC22[i]->SetLineWidth(2);
682 fhC33[i]->SetLineColor(color); fhC33[i]->SetLineWidth(2);
683 fhC44[i]->SetLineColor(color); fhC44[i]->SetLineWidth(2);
684 fhC55[i]->SetLineColor(color); fhC55[i]->SetLineWidth(2);
686 fhDXY[i]->SetLineColor(color); fhDXY[i]->SetLineWidth(2);
687 fhDZ[i]->SetLineColor(color); fhDZ[i]->SetLineWidth(2);
689 fhDXYNormalized[i]->SetLineColor(color); fhDXYNormalized[i]->SetLineWidth(2);
690 fhDZNormalized[i]->SetLineColor(color); fhDZNormalized[i]->SetLineWidth(2);
694 //____________________________________________________________________
696 AliESDtrackCuts::Print(const Option_t*) const {
698 // print method - still to be implemented
701 AliInfo("AliESDtrackCuts...");
705 //____________________________________________________________________
706 void AliESDtrackCuts::SaveHistograms(Char_t* dir) {
708 // saves the histograms in a directory (dir)
712 if (!fHistogramsOn) {
713 AliDebug(0, "Histograms not on - cannot save histograms!!!");
717 gDirectory->mkdir(dir);
720 gDirectory->mkdir("before_cuts");
721 gDirectory->mkdir("after_cuts");
723 fhCutStatistics->Write();
724 fhCutCorrelation->Write();
726 for (Int_t i=0; i<2; i++) {
728 gDirectory->cd("before_cuts");
730 gDirectory->cd("after_cuts");
732 fhNClustersITS[i] ->Write();
733 fhNClustersTPC[i] ->Write();
734 fhChi2PerClusterITS[i] ->Write();
735 fhChi2PerClusterTPC[i] ->Write();
745 fhDXYvsDZ[i] ->Write();
747 fhDXYNormalized[i] ->Write();
748 fhDZNormalized[i] ->Write();
749 fhDXYvsDZNormalized[i] ->Write();
751 gDirectory->cd("../");
754 gDirectory->cd("../");