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",
37 //____________________________________________________________________
38 AliESDtrackCuts::AliESDtrackCuts()
46 //##############################################################################
47 // setting default cuts
50 SetMaxChi2PerClusterTPC();
51 SetMaxChi2PerClusterITS();
52 SetMaxCovDiagonalElements();
55 SetAcceptKingDaughters();
56 SetMinNsigmaToVertex();
57 SetRequireSigmaToVertex();
69 //_____________________________________________________________________________
70 AliESDtrackCuts::AliESDtrackCuts(const AliESDtrackCuts &c) : TObject(c)
76 ((AliESDtrackCuts &) c).Copy(*this);
79 AliESDtrackCuts::~AliESDtrackCuts()
85 // ## TODO to be implemented
88 void AliESDtrackCuts::Init()
91 // sets everything to zero
94 fCutMinNClusterTPC = 0;
95 fCutMinNClusterITS = 0;
97 fCutMaxChi2PerClusterTPC = 0;
98 fCutMaxChi2PerClusterITS = 0;
106 fCutAcceptKinkDaughters = 0;
107 fCutRequireTPCRefit = 0;
108 fCutRequireITSRefit = 0;
110 fCutNsigmaToVertex = 0;
111 fCutSigmaToVertexRequired = 0;
128 fHistogramsOn = kFALSE;
130 for (Int_t i=0; i<2; ++i)
132 fhNClustersITS[i] = 0;
133 fhNClustersTPC[i] = 0;
135 fhChi2PerClusterITS[i] = 0;
136 fhChi2PerClusterTPC[i] = 0;
148 fhDXYNormalized[i] = 0;
149 fhDZNormalized[i] = 0;
150 fhDXYvsDZNormalized[i] = 0;
154 fhCutCorrelation = 0;
157 //_____________________________________________________________________________
158 AliESDtrackCuts &AliESDtrackCuts::operator=(const AliESDtrackCuts &c)
161 // Assignment operator
164 if (this != &c) ((AliESDtrackCuts &) c).Copy(*this);
168 //_____________________________________________________________________________
169 void AliESDtrackCuts::Copy(TObject &c) const
175 AliESDtrackCuts& target = (AliESDtrackCuts &) c;
179 target.fCutMinNClusterTPC = fCutMinNClusterTPC;
180 target.fCutMinNClusterITS = fCutMinNClusterITS;
182 target.fCutMaxChi2PerClusterTPC = fCutMaxChi2PerClusterTPC;
183 target.fCutMaxChi2PerClusterITS = fCutMaxChi2PerClusterITS;
185 target.fCutMaxC11 = fCutMaxC11;
186 target.fCutMaxC22 = fCutMaxC22;
187 target.fCutMaxC33 = fCutMaxC33;
188 target.fCutMaxC44 = fCutMaxC44;
189 target.fCutMaxC55 = fCutMaxC55;
191 target.fCutAcceptKinkDaughters = fCutAcceptKinkDaughters;
192 target.fCutRequireTPCRefit = fCutRequireTPCRefit;
193 target.fCutRequireITSRefit = fCutRequireITSRefit;
195 target.fCutNsigmaToVertex = fCutNsigmaToVertex;
196 target.fCutSigmaToVertexRequired = fCutSigmaToVertexRequired;
198 target.fPMin = fPMin;
199 target.fPMax = fPMax;
200 target.fPtMin = fPtMin;
201 target.fPtMax = fPtMax;
202 target.fPxMin = fPxMin;
203 target.fPxMax = fPxMax;
204 target.fPyMin = fPyMin;
205 target.fPyMax = fPyMax;
206 target.fPzMin = fPzMin;
207 target.fPzMax = fPzMax;
208 target.fEtaMin = fEtaMin;
209 target.fEtaMax = fEtaMax;
210 target.fRapMin = fRapMin;
211 target.fRapMax = fRapMax;
213 target.fHistogramsOn = fHistogramsOn;
215 for (Int_t i=0; i<2; ++i)
217 if (fhNClustersITS[i]) target.fhNClustersITS[i] = (TH1F*) fhNClustersITS[i]->Clone();
218 if (fhNClustersTPC[i]) target.fhNClustersTPC[i] = (TH1F*) fhNClustersTPC[i]->Clone();
220 if (fhChi2PerClusterITS[i]) target.fhChi2PerClusterITS[i] = (TH1F*) fhChi2PerClusterITS[i]->Clone();
221 if (fhChi2PerClusterTPC[i]) target.fhChi2PerClusterTPC[i] = (TH1F*) fhChi2PerClusterTPC[i]->Clone();
223 if (fhC11[i]) target.fhC11[i] = (TH1F*) fhC11[i]->Clone();
224 if (fhC22[i]) target.fhC22[i] = (TH1F*) fhC22[i]->Clone();
225 if (fhC33[i]) target.fhC33[i] = (TH1F*) fhC33[i]->Clone();
226 if (fhC44[i]) target.fhC44[i] = (TH1F*) fhC44[i]->Clone();
227 if (fhC55[i]) target.fhC55[i] = (TH1F*) fhC55[i]->Clone();
229 if (fhDXY[i]) target.fhDXY[i] = (TH1F*) fhDXY[i]->Clone();
230 if (fhDZ[i]) target.fhDZ[i] = (TH1F*) fhDZ[i]->Clone();
231 if (fhDXYvsDZ[i]) target.fhDXYvsDZ[i] = (TH2F*) fhDXYvsDZ[i]->Clone();
233 if (fhDXYNormalized[i]) target.fhDXYNormalized[i] = (TH1F*) fhDXYNormalized[i]->Clone();
234 if (fhDZNormalized[i]) target.fhDZNormalized[i] = (TH1F*) fhDZNormalized[i]->Clone();
235 if (fhDXYvsDZNormalized[i]) target.fhDXYvsDZNormalized[i] = (TH2F*) fhDXYvsDZNormalized[i]->Clone();
238 if (fhCutStatistics) target.fhCutStatistics = (TH1F*) fhCutStatistics->Clone();
239 if (fhCutCorrelation) target.fhCutCorrelation = (TH2F*) fhCutCorrelation->Clone();
244 //____________________________________________________________________
245 Float_t AliESDtrackCuts::GetSigmaToVertex(AliESDtrack* esdTrack)
252 esdTrack->GetImpactParameters(b,bCov);
253 if (bCov[0]<=0 || bCov[2]<=0) {
254 AliDebug(1, "Estimated b resolution lower or equal zero!");
255 bCov[0]=0; bCov[2]=0;
257 bRes[0] = TMath::Sqrt(bCov[0]);
258 bRes[1] = TMath::Sqrt(bCov[2]);
260 // -----------------------------------
261 // How to get to a n-sigma cut?
263 // The accumulated statistics from 0 to d is
265 // -> Erf(d/Sqrt(2)) for a 1-dim gauss (d = n_sigma)
266 // -> 1 - Exp(-d**2) for a 2-dim gauss (d*d = dx*dx + dy*dy != n_sigma)
268 // It means that for a 2-dim gauss: n_sigma(d) = Sqrt(2)*ErfInv(1 - Exp((-x**2)/2)
269 // Can this be expressed in a different way?
272 // FIX: I don't think this is correct!!! Keeping d as n_sigma for now...
274 if (bRes[0] == 0 || bRes[1] ==0)
277 Float_t d = TMath::Sqrt(TMath::Power(b[0]/bRes[0],2) + TMath::Power(b[1]/bRes[1],2));
279 // stupid rounding problem screws up everything:
280 // if d is too big, TMath::Exp(...) gets 0, and TMath::ErfInverse(1) that should be infinite, gets 0 :(
281 if (TMath::Exp(-d * d / 2) < 1e-10)
284 d = TMath::ErfInverse(1 - TMath::Exp(-d * d / 2)) * TMath::Sqrt(2);
288 //____________________________________________________________________
290 AliESDtrackCuts::AcceptTrack(AliESDtrack* esdTrack) {
292 // figure out if the tracks survives all the track cuts defined
294 // the different quality parameter and kinematic values are first
295 // retrieved from the track. then it is found out what cuts the
296 // track did not survive and finally the cuts are imposed.
300 UInt_t status = esdTrack->GetStatus();
305 // getting quality parameters from the ESD track
306 Int_t nClustersITS = esdTrack->GetITSclusters(fIdxInt);
307 Int_t nClustersTPC = esdTrack->GetTPCclusters(fIdxInt);
311 Float_t chi2PerClusterITS = -1;
312 Float_t chi2PerClusterTPC = -1;
314 chi2PerClusterITS = esdTrack->GetITSchi2()/Float_t(nClustersITS);
316 chi2PerClusterTPC = esdTrack->GetTPCchi2()/Float_t(nClustersTPC);
319 esdTrack->GetExternalCovariance(extCov);
321 // getting the track to vertex parameters
322 Float_t nSigmaToVertex = GetSigmaToVertex(esdTrack);
324 // getting the kinematic variables of the track
325 // (assuming the mass is known)
327 esdTrack->GetPxPyPz(p);
328 Float_t momentum = TMath::Sqrt(TMath::Power(p[0],2) + TMath::Power(p[1],2) + TMath::Power(p[2],2));
329 Float_t pt = TMath::Sqrt(TMath::Power(p[0],2) + TMath::Power(p[1],2));
330 Float_t energy = TMath::Sqrt(TMath::Power(esdTrack->GetMass(),2) + TMath::Power(momentum,2));
333 //y-eta related calculations
336 if((momentum != TMath::Abs(p[2]))&&(momentum != 0))
337 eta = 0.5*TMath::Log((momentum + p[2])/(momentum - p[2]));
338 if((energy != TMath::Abs(p[2]))&&(momentum != 0))
339 y = 0.5*TMath::Log((energy + p[2])/(energy - p[2]));
342 //########################################################################
346 for (Int_t i=0; i<kNCuts; i++) cuts[i]=kFALSE;
348 // track quality cuts
349 if (fCutRequireTPCRefit && (status&AliESDtrack::kTPCrefit)==0)
351 if (fCutRequireITSRefit && (status&AliESDtrack::kITSrefit)==0)
353 if (nClustersTPC<fCutMinNClusterTPC)
355 if (nClustersITS<fCutMinNClusterITS)
357 if (chi2PerClusterTPC>fCutMaxChi2PerClusterTPC)
359 if (chi2PerClusterITS>fCutMaxChi2PerClusterITS)
361 if (extCov[0] > fCutMaxC11)
363 if (extCov[2] > fCutMaxC22)
365 if (extCov[5] > fCutMaxC33)
367 if (extCov[9] > fCutMaxC44)
369 if (extCov[14] > fCutMaxC55)
371 if (nSigmaToVertex > fCutNsigmaToVertex)
373 // if n sigma could not be calculated
374 if (nSigmaToVertex<0 && fCutSigmaToVertexRequired)
376 if (!fCutAcceptKinkDaughters && esdTrack->GetKinkIndex(0)>0)
378 // track kinematics cut
379 if((momentum < fPMin) || (momentum > fPMax))
381 if((pt < fPtMin) || (pt > fPtMax))
383 if((p[0] < fPxMin) || (p[0] > fPxMax))
385 if((p[1] < fPyMin) || (p[1] > fPyMax))
387 if((p[2] < fPzMin) || (p[2] > fPzMax))
389 if((eta < fEtaMin) || (eta > fEtaMax))
391 if((y < fRapMin) || (y > fRapMax))
395 for (Int_t i=0; i<kNCuts; i++)
396 if (cuts[i]) cut = kTRUE;
398 //########################################################################
399 // filling histograms
401 fhCutStatistics->Fill(fhCutStatistics->GetBinCenter(fhCutStatistics->GetXaxis()->FindBin("n tracks")));
404 fhCutStatistics->Fill(fhCutStatistics->GetBinCenter(fhCutStatistics->GetXaxis()->FindBin("n cut tracks")));
406 for (Int_t i=0; i<kNCuts; i++) {
408 fhCutStatistics->Fill(fhCutStatistics->GetBinCenter(fhCutStatistics->GetXaxis()->FindBin(fgkCutNames[i])));
410 for (Int_t j=i; j<kNCuts; j++) {
411 if (cuts[i] && cuts[j]) {
412 Float_t x = fhCutCorrelation->GetXaxis()->GetBinCenter(fhCutCorrelation->GetXaxis()->FindBin(fgkCutNames[i]));
413 Float_t y = fhCutCorrelation->GetYaxis()->GetBinCenter(fhCutCorrelation->GetYaxis()->FindBin(fgkCutNames[j]));
414 fhCutCorrelation->Fill(x,y);
420 fhNClustersITS[0]->Fill(nClustersITS);
421 fhNClustersTPC[0]->Fill(nClustersTPC);
422 fhChi2PerClusterITS[0]->Fill(chi2PerClusterITS);
423 fhChi2PerClusterTPC[0]->Fill(chi2PerClusterTPC);
425 fhC11[0]->Fill(extCov[0]);
426 fhC22[0]->Fill(extCov[2]);
427 fhC33[0]->Fill(extCov[5]);
428 fhC44[0]->Fill(extCov[9]);
429 fhC55[0]->Fill(extCov[14]);
434 esdTrack->GetImpactParameters(b,bCov);
435 if (bCov[0]<=0 || bCov[2]<=0) {
436 AliDebug(1, "Estimated b resolution lower or equal zero!");
437 bCov[0]=0; bCov[2]=0;
439 bRes[0] = TMath::Sqrt(bCov[0]);
440 bRes[1] = TMath::Sqrt(bCov[2]);
443 fhDXY[0]->Fill(b[0]);
444 fhDXYvsDZ[0]->Fill(b[1],b[0]);
446 if (bRes[0]!=0 && bRes[1]!=0) {
447 fhDZNormalized[0]->Fill(b[1]/bRes[1]);
448 fhDXYNormalized[0]->Fill(b[0]/bRes[0]);
449 fhDXYvsDZNormalized[0]->Fill(b[1]/bRes[1], b[0]/bRes[0]);
453 //########################################################################
455 if (cut) return kFALSE;
457 //########################################################################
458 // filling histograms after cut
460 fhNClustersITS[1]->Fill(nClustersITS);
461 fhNClustersTPC[1]->Fill(nClustersTPC);
462 fhChi2PerClusterITS[1]->Fill(chi2PerClusterITS);
463 fhChi2PerClusterTPC[1]->Fill(chi2PerClusterTPC);
465 fhC11[1]->Fill(extCov[0]);
466 fhC22[1]->Fill(extCov[2]);
467 fhC33[1]->Fill(extCov[5]);
468 fhC44[1]->Fill(extCov[9]);
469 fhC55[1]->Fill(extCov[14]);
474 esdTrack->GetImpactParameters(b,bCov);
475 if (bCov[0]<=0 || bCov[2]<=0) {
476 AliDebug(1, "Estimated b resolution lower or equal zero!");
477 bCov[0]=0; bCov[2]=0;
479 bRes[0] = TMath::Sqrt(bCov[0]);
480 bRes[1] = TMath::Sqrt(bCov[2]);
483 fhDXY[1]->Fill(b[0]);
484 fhDXYvsDZ[1]->Fill(b[1],b[0]);
486 if (bRes[0]!=0 && bRes[1]!=0)
488 fhDZNormalized[1]->Fill(b[1]/bRes[1]);
489 fhDXYNormalized[1]->Fill(b[0]/bRes[0]);
490 fhDXYvsDZNormalized[1]->Fill(b[1]/bRes[1], b[0]/bRes[0]);
497 //____________________________________________________________________
499 AliESDtrackCuts::GetAcceptedTracks(AliESD* esd)
502 // returns an array of all tracks that pass the cuts
505 TObjArray* acceptedTracks = new TObjArray();
507 // loop over esd tracks
508 for (Int_t iTrack = 0; iTrack < esd->GetNumberOfTracks(); iTrack++) {
509 AliESDtrack* track = esd->GetTrack(iTrack);
511 if (AcceptTrack(track))
512 acceptedTracks->Add(track);
515 return acceptedTracks;
518 //____________________________________________________________________
520 AliESDtrackCuts::CountAcceptedTracks(AliESD* esd)
523 // returns an the number of tracks that pass the cuts
528 // loop over esd tracks
529 for (Int_t iTrack = 0; iTrack < esd->GetNumberOfTracks(); iTrack++) {
530 AliESDtrack* track = esd->GetTrack(iTrack);
532 if (AcceptTrack(track))
539 //____________________________________________________________________
540 void AliESDtrackCuts::DefineHistograms(Int_t color) {
542 // diagnostics histograms are defined
547 //###################################################################################
548 // defining histograms
550 fhCutStatistics = new TH1F("cut_statistics","cut statistics",kNCuts+4,-0.5,kNCuts+3.5);
552 fhCutStatistics->GetXaxis()->SetBinLabel(1,"n tracks");
553 fhCutStatistics->GetXaxis()->SetBinLabel(2,"n cut tracks");
555 fhCutCorrelation = new TH2F("cut_correlation","cut correlation",kNCuts,-0.5,kNCuts-0.5,kNCuts,-0.5,kNCuts-0.5);;
557 for (Int_t i=0; i<kNCuts; i++) {
558 fhCutStatistics->GetXaxis()->SetBinLabel(i+4,fgkCutNames[i]);
559 fhCutCorrelation->GetXaxis()->SetBinLabel(i+1,fgkCutNames[i]);
560 fhCutCorrelation->GetYaxis()->SetBinLabel(i+1,fgkCutNames[i]);
563 fhCutStatistics ->SetLineColor(color);
564 fhCutCorrelation ->SetLineColor(color);
565 fhCutStatistics ->SetLineWidth(2);
566 fhCutCorrelation ->SetLineWidth(2);
569 for (Int_t i=0; i<2; i++) {
570 if (i==0) sprintf(str," ");
571 else sprintf(str,"_cut");
573 fhNClustersITS[i] = new TH1F(Form("nClustersITS%s",str),"",8,-0.5,7.5);
574 fhNClustersTPC[i] = new TH1F(Form("nClustersTPC%s",str),"",165,-0.5,164.5);
575 fhChi2PerClusterITS[i] = new TH1F(Form("chi2PerClusterITS%s",str),"",500,0,10);
576 fhChi2PerClusterTPC[i] = new TH1F(Form("chi2PerClusterTPC%s",str),"",500,0,10);
578 fhC11[i] = new TH1F(Form("covMatrixDiagonal11%s",str),"",1000,0,5);
579 fhC22[i] = new TH1F(Form("covMatrixDiagonal22%s",str),"",1000,0,5);
580 fhC33[i] = new TH1F(Form("covMatrixDiagonal33%s",str),"",1000,0,0.5);
581 fhC44[i] = new TH1F(Form("covMatrixDiagonal44%s",str),"",1000,0,5);
582 fhC55[i] = new TH1F(Form("covMatrixDiagonal55%s",str),"",1000,0,5);
584 fhDXY[i] = new TH1F(Form("dXY%s",str),"",500,-10,10);
585 fhDZ[i] = new TH1F(Form("dZ%s",str),"",500,-10,10);
586 fhDXYvsDZ[i] = new TH2F(Form("dXYvsDZ%s",str),"",200,-10,10,200,-10,10);
588 fhDXYNormalized[i] = new TH1F(Form("dXYNormalized%s",str),"",500,-10,10);
589 fhDZNormalized[i] = new TH1F(Form("dZNormalized%s",str),"",500,-10,10);
590 fhDXYvsDZNormalized[i] = new TH2F(Form("dXYvsDZNormalized%s",str),"",200,-10,10,200,-10,10);
593 fhNClustersITS[i]->SetXTitle("n ITS clusters");
594 fhNClustersTPC[i]->SetXTitle("n TPC clusters");
595 fhChi2PerClusterITS[i]->SetXTitle("#Chi^{2} per ITS cluster");
596 fhChi2PerClusterTPC[i]->SetXTitle("#Chi^{2} per TPC cluster");
598 fhC11[i]->SetXTitle("cov 11 : #sigma_{y}^{2} [cm^{2}]");
599 fhC22[i]->SetXTitle("cov 22 : #sigma_{z}^{2} [cm^{2}]");
600 fhC33[i]->SetXTitle("cov 33 : #sigma_{sin(#phi)}^{2}");
601 fhC44[i]->SetXTitle("cov 44 : #sigma_{tan(#theta_{dip})}^{2}");
602 fhC55[i]->SetXTitle("cov 55 : #sigma_{1/p_{T}}^{2} [(c/GeV)^2]");
604 fhDXY[i]->SetXTitle("transverse impact parameter");
605 fhDZ[i]->SetXTitle("longitudinal impact parameter");
606 fhDXYvsDZ[i]->SetXTitle("longitudinal impact parameter");
607 fhDXYvsDZ[i]->SetYTitle("transverse impact parameter");
609 fhDXYNormalized[i]->SetXTitle("normalized trans impact par");
610 fhDZNormalized[i]->SetXTitle("normalized long impact par");
611 fhDXYvsDZNormalized[i]->SetXTitle("normalized long impact par");
612 fhDXYvsDZNormalized[i]->SetYTitle("normalized trans impact par");
614 fhNClustersITS[i]->SetLineColor(color); fhNClustersITS[i]->SetLineWidth(2);
615 fhNClustersTPC[i]->SetLineColor(color); fhNClustersTPC[i]->SetLineWidth(2);
616 fhChi2PerClusterITS[i]->SetLineColor(color); fhChi2PerClusterITS[i]->SetLineWidth(2);
617 fhChi2PerClusterTPC[i]->SetLineColor(color); fhChi2PerClusterTPC[i]->SetLineWidth(2);
619 fhC11[i]->SetLineColor(color); fhC11[i]->SetLineWidth(2);
620 fhC22[i]->SetLineColor(color); fhC22[i]->SetLineWidth(2);
621 fhC33[i]->SetLineColor(color); fhC33[i]->SetLineWidth(2);
622 fhC44[i]->SetLineColor(color); fhC44[i]->SetLineWidth(2);
623 fhC55[i]->SetLineColor(color); fhC55[i]->SetLineWidth(2);
625 fhDXY[i]->SetLineColor(color); fhDXY[i]->SetLineWidth(2);
626 fhDZ[i]->SetLineColor(color); fhDZ[i]->SetLineWidth(2);
628 fhDXYNormalized[i]->SetLineColor(color); fhDXYNormalized[i]->SetLineWidth(2);
629 fhDZNormalized[i]->SetLineColor(color); fhDZNormalized[i]->SetLineWidth(2);
633 //____________________________________________________________________
635 AliESDtrackCuts::Print(const Option_t*) const {
637 // print method - still to be implemented
640 AliInfo("AliESDtrackCuts...");
644 //____________________________________________________________________
645 void AliESDtrackCuts::SaveHistograms(Char_t* dir) {
647 // saves the histograms in a directory (dir)
651 if (!fHistogramsOn) {
652 AliDebug(0, "Histograms not on - cannot save histograms!!!");
656 gDirectory->mkdir(dir);
659 gDirectory->mkdir("before_cuts");
660 gDirectory->mkdir("after_cuts");
662 fhCutStatistics->Write();
663 fhCutCorrelation->Write();
665 for (Int_t i=0; i<2; i++) {
667 gDirectory->cd("before_cuts");
669 gDirectory->cd("after_cuts");
671 fhNClustersITS[i] ->Write();
672 fhNClustersTPC[i] ->Write();
673 fhChi2PerClusterITS[i] ->Write();
674 fhChi2PerClusterTPC[i] ->Write();
684 fhDXYvsDZ[i] ->Write();
686 fhDXYNormalized[i] ->Write();
687 fhDZNormalized[i] ->Write();
688 fhDXYvsDZNormalized[i] ->Write();
690 gDirectory->cd("../");
693 gDirectory->cd("../");