1 #include "AliESDtrackCuts.h"
3 //____________________________________________________________________
4 ClassImp(AliESDtrackCuts)
7 const Char_t* AliESDtrackCuts::fgkCutNames[kNCuts] = {
12 "#Chi^{2}/clusters TPC",
13 "#Chi^{2}/clusters ITS",
32 //____________________________________________________________________
33 AliESDtrackCuts::AliESDtrackCuts()
41 //##############################################################################
42 // setting default cuts
45 SetMaxChi2PerClusterTPC();
46 SetMaxChi2PerClusterITS();
47 SetMaxCovDiagonalElements();
50 SetAcceptKingDaughters();
51 SetMinNsigmaToVertex();
52 SetRequireSigmaToVertex();
64 //_____________________________________________________________________________
65 AliESDtrackCuts::AliESDtrackCuts(const AliESDtrackCuts &c) : TObject(c)
71 ((AliESDtrackCuts &) c).Copy(*this);
74 AliESDtrackCuts::~AliESDtrackCuts()
80 // ## TODO to be implemented
83 void AliESDtrackCuts::Init()
86 // sets everything to zero
89 fCutMinNClusterTPC = 0;
90 fCutMinNClusterITS = 0;
92 fCutMaxChi2PerClusterTPC = 0;
93 fCutMaxChi2PerClusterITS = 0;
101 fCutAcceptKinkDaughters = 0;
102 fCutRequireTPCRefit = 0;
103 fCutRequireITSRefit = 0;
105 fCutNsigmaToVertex = 0;
106 fCutSigmaToVertexRequired = 0;
123 fHistogramsOn = kFALSE;
125 for (Int_t i=0; i<2; ++i)
127 fhNClustersITS[i] = 0;
128 fhNClustersTPC[i] = 0;
130 fhChi2PerClusterITS[i] = 0;
131 fhChi2PerClusterTPC[i] = 0;
143 fhDXYNormalized[i] = 0;
144 fhDZNormalized[i] = 0;
145 fhDXYvsDZNormalized[i] = 0;
149 fhCutCorrelation = 0;
152 //_____________________________________________________________________________
153 AliESDtrackCuts &AliESDtrackCuts::operator=(const AliESDtrackCuts &c)
156 // Assignment operator
159 if (this != &c) ((AliESDtrackCuts &) c).Copy(*this);
163 //_____________________________________________________________________________
164 void AliESDtrackCuts::Copy(TObject &c) const
170 AliESDtrackCuts& target = (AliESDtrackCuts &) c;
174 target.fCutMinNClusterTPC = fCutMinNClusterTPC;
175 target.fCutMinNClusterITS = fCutMinNClusterITS;
177 target.fCutMaxChi2PerClusterTPC = fCutMaxChi2PerClusterTPC;
178 target.fCutMaxChi2PerClusterITS = fCutMaxChi2PerClusterITS;
180 target.fCutMaxC11 = fCutMaxC11;
181 target.fCutMaxC22 = fCutMaxC22;
182 target.fCutMaxC33 = fCutMaxC33;
183 target.fCutMaxC44 = fCutMaxC44;
184 target.fCutMaxC55 = fCutMaxC55;
186 target.fCutAcceptKinkDaughters = fCutAcceptKinkDaughters;
187 target.fCutRequireTPCRefit = fCutRequireTPCRefit;
188 target.fCutRequireITSRefit = fCutRequireITSRefit;
190 target.fCutNsigmaToVertex = fCutNsigmaToVertex;
191 target.fCutSigmaToVertexRequired = fCutSigmaToVertexRequired;
193 target.fPMin = fPMin;
194 target.fPMax = fPMax;
195 target.fPtMin = fPtMin;
196 target.fPtMax = fPtMax;
197 target.fPxMin = fPxMin;
198 target.fPxMax = fPxMax;
199 target.fPyMin = fPyMin;
200 target.fPyMax = fPyMax;
201 target.fPzMin = fPzMin;
202 target.fPzMax = fPzMax;
203 target.fEtaMin = fEtaMin;
204 target.fEtaMax = fEtaMax;
205 target.fRapMin = fRapMin;
206 target.fRapMax = fRapMax;
208 target.fHistogramsOn = fHistogramsOn;
210 for (Int_t i=0; i<2; ++i)
212 if (fhNClustersITS[i]) target.fhNClustersITS[i] = (TH1F*) fhNClustersITS[i]->Clone();
213 if (fhNClustersTPC[i]) target.fhNClustersTPC[i] = (TH1F*) fhNClustersTPC[i]->Clone();
215 if (fhChi2PerClusterITS[i]) target.fhChi2PerClusterITS[i] = (TH1F*) fhChi2PerClusterITS[i]->Clone();
216 if (fhChi2PerClusterTPC[i]) target.fhChi2PerClusterTPC[i] = (TH1F*) fhChi2PerClusterTPC[i]->Clone();
218 if (fhC11[i]) target.fhC11[i] = (TH1F*) fhC11[i]->Clone();
219 if (fhC22[i]) target.fhC22[i] = (TH1F*) fhC22[i]->Clone();
220 if (fhC33[i]) target.fhC33[i] = (TH1F*) fhC33[i]->Clone();
221 if (fhC44[i]) target.fhC44[i] = (TH1F*) fhC44[i]->Clone();
222 if (fhC55[i]) target.fhC55[i] = (TH1F*) fhC55[i]->Clone();
224 if (fhDXY[i]) target.fhDXY[i] = (TH1F*) fhDXY[i]->Clone();
225 if (fhDZ[i]) target.fhDZ[i] = (TH1F*) fhDZ[i]->Clone();
226 if (fhDXYvsDZ[i]) target.fhDXYvsDZ[i] = (TH2F*) fhDXYvsDZ[i]->Clone();
228 if (fhDXYNormalized[i]) target.fhDXYNormalized[i] = (TH1F*) fhDXYNormalized[i]->Clone();
229 if (fhDZNormalized[i]) target.fhDZNormalized[i] = (TH1F*) fhDZNormalized[i]->Clone();
230 if (fhDXYvsDZNormalized[i]) target.fhDXYvsDZNormalized[i] = (TH2F*) fhDXYvsDZNormalized[i]->Clone();
233 if (fhCutStatistics) target.fhCutStatistics = (TH1F*) fhCutStatistics->Clone();
234 if (fhCutCorrelation) target.fhCutCorrelation = (TH2F*) fhCutCorrelation->Clone();
239 //____________________________________________________________________
241 AliESDtrackCuts::AcceptTrack(AliESDtrack* esdTrack) {
243 // figure out if the tracks survives all the track cuts defined
245 // the different quality parameter and kinematic values are first
246 // retrieved from the track. then it is found out what cuts the
247 // track did not survive and finally the cuts are imposed.
249 UInt_t status = esdTrack->GetStatus();
254 // getting quality parameters from the ESD track
255 Int_t nClustersITS = esdTrack->GetITSclusters(fIdxInt);
256 Int_t nClustersTPC = esdTrack->GetTPCclusters(fIdxInt);
258 Float_t chi2PerClusterITS = -1;
259 Float_t chi2PerClusterTPC = -1;
261 chi2PerClusterITS = esdTrack->GetITSchi2()/Float_t(nClustersITS);
263 chi2PerClusterTPC = esdTrack->GetTPCchi2()/Float_t(nClustersTPC);
266 esdTrack->GetExternalCovariance(extCov);
268 // getting the track to vertex parameters
272 esdTrack->GetImpactParameters(b,bCov);
273 if (bCov[0]<=0 || bCov[2]<=0) {
274 AliDebug(1, "Estimated b resolution zero!");
275 bCov[0]=0; bCov[1]=0;
277 bRes[0] = TMath::Sqrt(bCov[0]);
278 bRes[1] = TMath::Sqrt(bCov[2]);
280 // FIX !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
282 // this is not correct - it will not give n sigma!!!
284 Float_t nSigmaToVertex = -1;
285 if (bRes[0]!=0 && bRes[1]!=0)
286 nSigmaToVertex = TMath::Sqrt(TMath::Power(b[0]/bRes[0],2) + TMath::Power(b[1]/bRes[1],2));
288 // getting the kinematic variables of the track
289 // (assuming the mass is known)
291 esdTrack->GetPxPyPz(p);
292 Float_t momentum = TMath::Sqrt(TMath::Power(p[0],2) + TMath::Power(p[1],2) + TMath::Power(p[2],2));
293 Float_t pt = TMath::Sqrt(TMath::Power(p[0],2) + TMath::Power(p[1],2));
294 Float_t energy = TMath::Sqrt(TMath::Power(esdTrack->GetMass(),2) + TMath::Power(momentum,2));
296 //y-eta related calculations
299 if((momentum != TMath::Abs(p[2]))&&(momentum != 0))
300 eta = 0.5*TMath::Log((momentum + p[2])/(momentum - p[2]));
301 if((energy != TMath::Abs(p[2]))&&(momentum != 0))
302 y = 0.5*TMath::Log((energy + p[2])/(energy - p[2]));
305 //########################################################################
309 for (Int_t i=0; i<kNCuts; i++) cuts[i]=kFALSE;
311 // track quality cuts
312 if (fCutRequireTPCRefit && (status&AliESDtrack::kTPCrefit)==0)
314 if (fCutRequireITSRefit && (status&AliESDtrack::kITSrefit)==0)
316 if (nClustersTPC<fCutMinNClusterTPC)
318 if (nClustersITS<fCutMinNClusterITS)
320 if (chi2PerClusterTPC>fCutMaxChi2PerClusterTPC)
322 if (chi2PerClusterITS>fCutMaxChi2PerClusterITS)
324 if (extCov[0] > fCutMaxC11)
326 if (extCov[2] > fCutMaxC22)
328 if (extCov[5] > fCutMaxC33)
330 if (extCov[9] > fCutMaxC44)
332 if (extCov[14] > fCutMaxC55)
334 if (nSigmaToVertex > fCutNsigmaToVertex)
336 // if n sigma could not be calculated
337 if (nSigmaToVertex<0 && fCutSigmaToVertexRequired)
339 if (!fCutAcceptKinkDaughters && esdTrack->GetKinkIndex(0)>0)
341 // track kinematics cut
342 if((momentum < fPMin) || (momentum > fPMax))
344 if((pt < fPtMin) || (pt > fPtMax))
346 if((p[0] < fPxMin) || (p[0] > fPxMax))
348 if((p[1] < fPyMin) || (p[1] > fPyMax))
350 if((p[2] < fPzMin) || (p[2] > fPzMax))
352 if((eta < fEtaMin) || (eta > fEtaMax))
354 if((y < fRapMin) || (y > fRapMax))
358 for (Int_t i=0; i<kNCuts; i++)
359 if (cuts[i]) cut = kTRUE;
361 //########################################################################
362 // filling histograms
364 fhCutStatistics->Fill(fhCutStatistics->GetBinCenter(fhCutStatistics->GetXaxis()->FindBin("n tracks")));
367 fhCutStatistics->Fill(fhCutStatistics->GetBinCenter(fhCutStatistics->GetXaxis()->FindBin("n cut tracks")));
369 for (Int_t i=0; i<kNCuts; i++) {
371 fhCutStatistics->Fill(fhCutStatistics->GetBinCenter(fhCutStatistics->GetXaxis()->FindBin(fgkCutNames[i])));
373 for (Int_t j=i; j<kNCuts; j++) {
374 if (cuts[i] && cuts[j]) {
375 Float_t x = fhCutCorrelation->GetXaxis()->GetBinCenter(fhCutCorrelation->GetXaxis()->FindBin(fgkCutNames[i]));
376 Float_t y = fhCutCorrelation->GetYaxis()->GetBinCenter(fhCutCorrelation->GetYaxis()->FindBin(fgkCutNames[j]));
377 fhCutCorrelation->Fill(x,y);
383 fhNClustersITS[0]->Fill(nClustersITS);
384 fhNClustersTPC[0]->Fill(nClustersTPC);
385 fhChi2PerClusterITS[0]->Fill(chi2PerClusterITS);
386 fhChi2PerClusterTPC[0]->Fill(chi2PerClusterTPC);
388 fhC11[0]->Fill(extCov[0]);
389 fhC22[0]->Fill(extCov[2]);
390 fhC33[0]->Fill(extCov[5]);
391 fhC44[0]->Fill(extCov[9]);
392 fhC55[0]->Fill(extCov[14]);
395 fhDXY[0]->Fill(b[0]);
396 fhDXYvsDZ[0]->Fill(b[1],b[0]);
398 if (bRes[0]!=0 && bRes[1]!=0) {
399 fhDZNormalized[0]->Fill(b[1]/bRes[1]);
400 fhDXYNormalized[0]->Fill(b[0]/bRes[0]);
401 fhDXYvsDZNormalized[0]->Fill(b[1]/bRes[1], b[0]/bRes[0]);
405 //########################################################################
407 if (cut) return kFALSE;
409 //########################################################################
410 // filling histograms after cut
412 fhNClustersITS[1]->Fill(nClustersITS);
413 fhNClustersTPC[1]->Fill(nClustersTPC);
414 fhChi2PerClusterITS[1]->Fill(chi2PerClusterITS);
415 fhChi2PerClusterTPC[1]->Fill(chi2PerClusterTPC);
417 fhC11[1]->Fill(extCov[0]);
418 fhC22[1]->Fill(extCov[2]);
419 fhC33[1]->Fill(extCov[5]);
420 fhC44[1]->Fill(extCov[9]);
421 fhC55[1]->Fill(extCov[14]);
424 fhDXY[1]->Fill(b[0]);
425 fhDXYvsDZ[1]->Fill(b[1],b[0]);
427 fhDZNormalized[1]->Fill(b[1]/bRes[1]);
428 fhDXYNormalized[1]->Fill(b[0]/bRes[0]);
429 fhDXYvsDZNormalized[1]->Fill(b[1]/bRes[1], b[0]/bRes[0]);
435 //____________________________________________________________________
437 AliESDtrackCuts::GetAcceptedTracks(AliESD* esd)
440 // returns an array of all tracks that pass the cuts
443 TObjArray* acceptedTracks = new TObjArray();
445 // loop over esd tracks
446 for (Int_t iTrack = 0; iTrack < esd->GetNumberOfTracks(); iTrack++) {
447 AliESDtrack* track = esd->GetTrack(iTrack);
449 if (AcceptTrack(track))
450 acceptedTracks->Add(track);
453 return acceptedTracks;
456 //____________________________________________________________________
457 void AliESDtrackCuts::DefineHistograms(Int_t color) {
459 // diagnostics histograms are defined
464 //###################################################################################
465 // defining histograms
467 fhCutStatistics = new TH1F("cut_statistics","cut statistics",kNCuts+4,-0.5,kNCuts+3.5);
469 fhCutStatistics->GetXaxis()->SetBinLabel(1,"n tracks");
470 fhCutStatistics->GetXaxis()->SetBinLabel(2,"n cut tracks");
472 fhCutCorrelation = new TH2F("cut_correlation","cut correlation",kNCuts,-0.5,kNCuts-0.5,kNCuts,-0.5,kNCuts-0.5);;
474 for (Int_t i=0; i<kNCuts; i++) {
475 fhCutStatistics->GetXaxis()->SetBinLabel(i+4,fgkCutNames[i]);
476 fhCutCorrelation->GetXaxis()->SetBinLabel(i+1,fgkCutNames[i]);
477 fhCutCorrelation->GetYaxis()->SetBinLabel(i+1,fgkCutNames[i]);
480 fhCutStatistics ->SetLineColor(color);
481 fhCutCorrelation ->SetLineColor(color);
482 fhCutStatistics ->SetLineWidth(2);
483 fhCutCorrelation ->SetLineWidth(2);
486 for (Int_t i=0; i<2; i++) {
487 if (i==0) sprintf(str," ");
488 else sprintf(str,"_cut");
490 fhNClustersITS[i] = new TH1F(Form("nClustersITS%s",str),"",8,-0.5,7.5);
491 fhNClustersTPC[i] = new TH1F(Form("nClustersTPC%s",str),"",165,-0.5,164.5);
492 fhChi2PerClusterITS[i] = new TH1F(Form("chi2PerClusterITS%s",str),"",500,0,10);
493 fhChi2PerClusterTPC[i] = new TH1F(Form("chi2PerClusterTPC%s",str),"",500,0,10);
495 fhC11[i] = new TH1F(Form("covMatrixDiagonal11%s",str),"",1000,0,5);
496 fhC22[i] = new TH1F(Form("covMatrixDiagonal22%s",str),"",1000,0,5);
497 fhC33[i] = new TH1F(Form("covMatrixDiagonal33%s",str),"",1000,0,0.5);
498 fhC44[i] = new TH1F(Form("covMatrixDiagonal44%s",str),"",1000,0,5);
499 fhC55[i] = new TH1F(Form("covMatrixDiagonal55%s",str),"",1000,0,5);
501 fhDXY[i] = new TH1F(Form("dXY%s",str),"",500,-10,10);
502 fhDZ[i] = new TH1F(Form("dZ%s",str),"",500,-10,10);
503 fhDXYvsDZ[i] = new TH2F(Form("dXYvsDZ%s",str),"",200,-10,10,200,-10,10);
505 fhDXYNormalized[i] = new TH1F(Form("dXYNormalized%s",str),"",500,-10,10);
506 fhDZNormalized[i] = new TH1F(Form("dZNormalized%s",str),"",500,-10,10);
507 fhDXYvsDZNormalized[i] = new TH2F(Form("dXYvsDZNormalized%s",str),"",200,-10,10,200,-10,10);
510 fhNClustersITS[i]->SetXTitle("n ITS clusters");
511 fhNClustersTPC[i]->SetXTitle("n TPC clusters");
512 fhChi2PerClusterITS[i]->SetXTitle("#Chi^{2} per ITS cluster");
513 fhChi2PerClusterTPC[i]->SetXTitle("#Chi^{2} per TPC cluster");
515 fhC11[i]->SetXTitle("cov 11 : #sigma_{y}^{2} [cm^{2}]");
516 fhC22[i]->SetXTitle("cov 22 : #sigma_{z}^{2} [cm^{2}]");
517 fhC33[i]->SetXTitle("cov 33 : #sigma_{sin(#phi)}^{2}");
518 fhC44[i]->SetXTitle("cov 44 : #sigma_{tan(#theta_{dip})}^{2}");
519 fhC55[i]->SetXTitle("cov 55 : #sigma_{1/p_{T}}^{2} [(c/GeV)^2]");
521 fhDXY[i]->SetXTitle("transverse impact parameter");
522 fhDZ[i]->SetXTitle("longitudinal impact parameter");
523 fhDXYvsDZ[i]->SetXTitle("longitudinal impact parameter");
524 fhDXYvsDZ[i]->SetYTitle("transverse impact parameter");
526 fhDXYNormalized[i]->SetXTitle("normalized trans impact par");
527 fhDZNormalized[i]->SetXTitle("normalized long impact par");
528 fhDXYvsDZNormalized[i]->SetXTitle("normalized long impact par");
529 fhDXYvsDZNormalized[i]->SetYTitle("normalized trans impact par");
531 fhNClustersITS[i]->SetLineColor(color); fhNClustersITS[i]->SetLineWidth(2);
532 fhNClustersTPC[i]->SetLineColor(color); fhNClustersTPC[i]->SetLineWidth(2);
533 fhChi2PerClusterITS[i]->SetLineColor(color); fhChi2PerClusterITS[i]->SetLineWidth(2);
534 fhChi2PerClusterTPC[i]->SetLineColor(color); fhChi2PerClusterTPC[i]->SetLineWidth(2);
536 fhC11[i]->SetLineColor(color); fhC11[i]->SetLineWidth(2);
537 fhC22[i]->SetLineColor(color); fhC22[i]->SetLineWidth(2);
538 fhC33[i]->SetLineColor(color); fhC33[i]->SetLineWidth(2);
539 fhC44[i]->SetLineColor(color); fhC44[i]->SetLineWidth(2);
540 fhC55[i]->SetLineColor(color); fhC55[i]->SetLineWidth(2);
542 fhDXY[i]->SetLineColor(color); fhDXY[i]->SetLineWidth(2);
543 fhDZ[i]->SetLineColor(color); fhDZ[i]->SetLineWidth(2);
545 fhDXYNormalized[i]->SetLineColor(color); fhDXYNormalized[i]->SetLineWidth(2);
546 fhDZNormalized[i]->SetLineColor(color); fhDZNormalized[i]->SetLineWidth(2);
550 //____________________________________________________________________
552 AliESDtrackCuts::Print(const Option_t*) const {
554 // print method - still to be implemented
557 AliInfo("AliESDtrackCuts...");
561 //____________________________________________________________________
562 void AliESDtrackCuts::SaveHistograms(Char_t* dir) {
564 // saves the histograms in a directory (dir)
568 if (!fHistogramsOn) {
569 AliDebug(0, "Histograms not on - cannot save histograms!!!");
573 gDirectory->mkdir(dir);
576 gDirectory->mkdir("before_cuts");
577 gDirectory->mkdir("after_cuts");
579 fhCutStatistics->Write();
580 fhCutCorrelation->Write();
582 for (Int_t i=0; i<2; i++) {
584 gDirectory->cd("before_cuts");
586 gDirectory->cd("after_cuts");
588 fhNClustersITS[i] ->Write();
589 fhNClustersTPC[i] ->Write();
590 fhChi2PerClusterITS[i] ->Write();
591 fhChi2PerClusterTPC[i] ->Write();
601 fhDXYvsDZ[i] ->Write();
603 fhDXYNormalized[i] ->Write();
604 fhDZNormalized[i] ->Write();
605 fhDXYvsDZNormalized[i] ->Write();
607 gDirectory->cd("../");
610 gDirectory->cd("../");