1 #include "AliESDtrackCuts.h"
5 //____________________________________________________________________
6 ClassImp(AliESDtrackCuts)
9 const Char_t* AliESDtrackCuts::fCutNames[kNCuts] = {
14 "#Chi^{2}/clusters TPC",
15 "#Chi^{2}/clusters ITS",
34 //____________________________________________________________________
35 AliESDtrackCuts::AliESDtrackCuts()
43 //##############################################################################
44 // setting default cuts
47 SetMaxChi2PerClusterTPC();
48 SetMaxChi2PerClusterITS();
49 SetMaxCovDiagonalElements();
52 SetAcceptKingDaughters();
53 SetMinNsigmaToVertex();
54 SetRequireSigmaToVertex();
66 //_____________________________________________________________________________
67 AliESDtrackCuts::AliESDtrackCuts(const AliESDtrackCuts &c) : TObject(c)
73 ((AliESDtrackCuts &) c).Copy(*this);
76 AliESDtrackCuts::~AliESDtrackCuts()
82 // ## TODO to be implemented
85 void AliESDtrackCuts::Init()
88 // sets everything to zero
91 fCut_MinNClusterTPC = 0;
92 fCut_MinNClusterITS = 0;
94 fCut_MaxChi2PerClusterTPC = 0;
95 fCut_MaxChi2PerClusterITS = 0;
103 fCut_AcceptKinkDaughters = 0;
104 fCut_RequireTPCRefit = 0;
105 fCut_RequireITSRefit = 0;
107 fCut_NsigmaToVertex = 0;
108 fCut_SigmaToVertexRequired = 0;
125 fHistogramsOn = kFALSE;
127 for (Int_t i=0; i<2; ++i)
129 fhNClustersITS[i] = 0;
130 fhNClustersTPC[i] = 0;
132 fhChi2PerClusterITS[i] = 0;
133 fhChi2PerClusterTPC[i] = 0;
145 fhDXYNormalized[i] = 0;
146 fhDZNormalized[i] = 0;
147 fhDXYvsDZNormalized[i] = 0;
151 fhCutCorrelation = 0;
154 //_____________________________________________________________________________
155 AliESDtrackCuts &AliESDtrackCuts::operator=(const AliESDtrackCuts &c)
158 // Assignment operator
161 if (this != &c) ((AliESDtrackCuts &) c).Copy(*this);
165 //_____________________________________________________________________________
166 void AliESDtrackCuts::Copy(TObject &c) const
172 AliESDtrackCuts& target = (AliESDtrackCuts &) c;
176 target.fCut_MinNClusterTPC = fCut_MinNClusterTPC;
177 target.fCut_MinNClusterITS = fCut_MinNClusterITS;
179 target.fCut_MaxChi2PerClusterTPC = fCut_MaxChi2PerClusterTPC;
180 target.fCut_MaxChi2PerClusterITS = fCut_MaxChi2PerClusterITS;
182 target.fCut_MaxC11 = fCut_MaxC11;
183 target.fCut_MaxC22 = fCut_MaxC22;
184 target.fCut_MaxC33 = fCut_MaxC33;
185 target.fCut_MaxC44 = fCut_MaxC44;
186 target.fCut_MaxC55 = fCut_MaxC55;
188 target.fCut_AcceptKinkDaughters = fCut_AcceptKinkDaughters;
189 target.fCut_RequireTPCRefit = fCut_RequireTPCRefit;
190 target.fCut_RequireITSRefit = fCut_RequireITSRefit;
192 target.fCut_NsigmaToVertex = fCut_NsigmaToVertex;
193 target.fCut_SigmaToVertexRequired = fCut_SigmaToVertexRequired;
195 target.fPMin = fPMin;
196 target.fPMax = fPMax;
197 target.fPtMin = fPtMin;
198 target.fPtMax = fPtMax;
199 target.fPxMin = fPxMin;
200 target.fPxMax = fPxMax;
201 target.fPyMin = fPyMin;
202 target.fPyMax = fPyMax;
203 target.fPzMin = fPzMin;
204 target.fPzMax = fPzMax;
205 target.fEtaMin = fEtaMin;
206 target.fEtaMax = fEtaMax;
207 target.fRapMin = fRapMin;
208 target.fRapMax = fRapMax;
210 target.fHistogramsOn = fHistogramsOn;
212 for (Int_t i=0; i<2; ++i)
214 if (fhNClustersITS[i]) target.fhNClustersITS[i] = (TH1F*) fhNClustersITS[i]->Clone();
215 if (fhNClustersTPC[i]) target.fhNClustersTPC[i] = (TH1F*) fhNClustersTPC[i]->Clone();
217 if (fhChi2PerClusterITS[i]) target.fhChi2PerClusterITS[i] = (TH1F*) fhChi2PerClusterITS[i]->Clone();
218 if (fhChi2PerClusterTPC[i]) target.fhChi2PerClusterTPC[i] = (TH1F*) fhChi2PerClusterTPC[i]->Clone();
220 if (fhC11[i]) target.fhC11[i] = (TH1F*) fhC11[i]->Clone();
221 if (fhC22[i]) target.fhC22[i] = (TH1F*) fhC22[i]->Clone();
222 if (fhC33[i]) target.fhC33[i] = (TH1F*) fhC33[i]->Clone();
223 if (fhC44[i]) target.fhC44[i] = (TH1F*) fhC44[i]->Clone();
224 if (fhC55[i]) target.fhC55[i] = (TH1F*) fhC55[i]->Clone();
226 if (fhDXY[i]) target.fhDXY[i] = (TH1F*) fhDXY[i]->Clone();
227 if (fhDZ[i]) target.fhDZ[i] = (TH1F*) fhDZ[i]->Clone();
228 if (fhDXYvsDZ[i]) target.fhDXYvsDZ[i] = (TH2F*) fhDXYvsDZ[i]->Clone();
230 if (fhDXYNormalized[i]) target.fhDXYNormalized[i] = (TH1F*) fhDXYNormalized[i]->Clone();
231 if (fhDZNormalized[i]) target.fhDZNormalized[i] = (TH1F*) fhDZNormalized[i]->Clone();
232 if (fhDXYvsDZNormalized[i]) target.fhDXYvsDZNormalized[i] = (TH2F*) fhDXYvsDZNormalized[i]->Clone();
235 if (fhCutStatistics) target.fhCutStatistics = (TH1F*) fhCutStatistics->Clone();
236 if (fhCutCorrelation) target.fhCutCorrelation = (TH2F*) fhCutCorrelation->Clone();
241 //____________________________________________________________________
243 AliESDtrackCuts::AcceptTrack(AliESDtrack* esdTrack) {
245 // figure out if the tracks survives all the track cuts defined
248 UInt_t status = esdTrack->GetStatus();
253 // getting quality parameters from the ESD track
254 Int_t nClustersITS = esdTrack->GetITSclusters(fIdxInt);
255 Int_t nClustersTPC = esdTrack->GetTPCclusters(fIdxInt);
257 Float_t chi2PerClusterITS = -1;
258 Float_t chi2PerClusterTPC = -1;
260 chi2PerClusterITS = esdTrack->GetITSchi2()/Float_t(nClustersITS);
262 chi2PerClusterTPC = esdTrack->GetTPCchi2()/Float_t(nClustersTPC);
265 esdTrack->GetExternalCovariance(extCov);
267 // getting the track to vertex parameters
271 esdTrack->GetImpactParameters(b,bCov);
272 if (bCov[0]<=0 || bCov[2]<=0) {
273 AliDebug(1, "Estimated b resolution zero!");
274 bCov[0]=0; bCov[1]=0;
276 bRes[0] = TMath::Sqrt(bCov[0]);
277 bRes[1] = TMath::Sqrt(bCov[2]);
279 // FIX !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
281 // this is not correct - it will not give n sigma!!!
283 Float_t nSigmaToVertex = -1;
284 if (bRes[0]!=0 && bRes[1]!=0)
285 nSigmaToVertex = TMath::Sqrt(TMath::Power(b[0]/bRes[0],2) + TMath::Power(b[1]/bRes[1],2));
287 // getting the kinematic variables of the track
288 // (assuming the mass is known)
290 esdTrack->GetPxPyPz(p);
291 Float_t momentum = TMath::Sqrt(TMath::Power(p[0],2) + TMath::Power(p[1],2) + TMath::Power(p[2],2));
292 Float_t pt = TMath::Sqrt(TMath::Power(p[0],2) + TMath::Power(p[1],2));
293 Float_t energy = TMath::Sqrt(TMath::Power(esdTrack->GetMass(),2) + TMath::Power(momentum,2));
295 //y-eta related calculations
298 if((momentum != TMath::Abs(p[2]))&&(momentum != 0))
299 eta = 0.5*TMath::Log((momentum + p[2])/(momentum - p[2]));
300 if((energy != TMath::Abs(p[2]))&&(momentum != 0))
301 y = 0.5*TMath::Log((energy + p[2])/(energy - p[2]));
304 //########################################################################
308 for (Int_t i=0; i<kNCuts; i++) cuts[i]=kFALSE;
310 // track quality cuts
311 if (fCut_RequireTPCRefit && (status&AliESDtrack::kTPCrefit)==0)
313 if (fCut_RequireITSRefit && (status&AliESDtrack::kITSrefit)==0)
315 if (nClustersTPC<fCut_MinNClusterTPC)
317 if (nClustersITS<fCut_MinNClusterITS)
319 if (chi2PerClusterTPC>fCut_MaxChi2PerClusterTPC)
321 if (chi2PerClusterITS>fCut_MaxChi2PerClusterITS)
323 if (extCov[0] > fCut_MaxC11)
325 if (extCov[2] > fCut_MaxC22)
327 if (extCov[5] > fCut_MaxC33)
329 if (extCov[9] > fCut_MaxC44)
331 if (extCov[14] > fCut_MaxC55)
333 if (nSigmaToVertex > fCut_NsigmaToVertex)
335 // if n sigma could not be calculated
336 if (nSigmaToVertex<0 && fCut_SigmaToVertexRequired)
338 if (!fCut_AcceptKinkDaughters && esdTrack->GetKinkIndex(0)>0)
340 // track kinematics cut
341 if((momentum < fPMin) || (momentum > fPMax))
343 if((pt < fPtMin) || (pt > fPtMax))
345 if((p[0] < fPxMin) || (p[0] > fPxMax))
347 if((p[1] < fPyMin) || (p[1] > fPyMax))
349 if((p[2] < fPzMin) || (p[2] > fPzMax))
351 if((eta < fEtaMin) || (eta > fEtaMax))
353 if((y < fRapMin) || (y > fRapMax))
357 for (Int_t i=0; i<kNCuts; i++)
358 if (cuts[i]) cut = kTRUE;
360 //########################################################################
361 // filling histograms
363 fhCutStatistics->Fill(fhCutStatistics->GetBinCenter(fhCutStatistics->GetXaxis()->FindBin("n tracks")));
366 fhCutStatistics->Fill(fhCutStatistics->GetBinCenter(fhCutStatistics->GetXaxis()->FindBin("n cut tracks")));
368 for (Int_t i=0; i<kNCuts; i++) {
370 fhCutStatistics->Fill(fhCutStatistics->GetBinCenter(fhCutStatistics->GetXaxis()->FindBin(fCutNames[i])));
372 for (Int_t j=i; j<kNCuts; j++) {
373 if (cuts[i] && cuts[j]) {
374 Float_t x = fhCutCorrelation->GetXaxis()->GetBinCenter(fhCutCorrelation->GetXaxis()->FindBin(fCutNames[i]));
375 Float_t y = fhCutCorrelation->GetYaxis()->GetBinCenter(fhCutCorrelation->GetYaxis()->FindBin(fCutNames[j]));
376 fhCutCorrelation->Fill(x,y);
382 fhNClustersITS[0]->Fill(nClustersITS);
383 fhNClustersTPC[0]->Fill(nClustersTPC);
384 fhChi2PerClusterITS[0]->Fill(chi2PerClusterITS);
385 fhChi2PerClusterTPC[0]->Fill(chi2PerClusterTPC);
387 fhC11[0]->Fill(extCov[0]);
388 fhC22[0]->Fill(extCov[2]);
389 fhC33[0]->Fill(extCov[5]);
390 fhC44[0]->Fill(extCov[9]);
391 fhC55[0]->Fill(extCov[14]);
394 fhDXY[0]->Fill(b[0]);
395 fhDXYvsDZ[0]->Fill(b[1],b[0]);
397 if (bRes[0]!=0 && bRes[1]!=0) {
398 fhDZNormalized[0]->Fill(b[1]/bRes[1]);
399 fhDXYNormalized[0]->Fill(b[0]/bRes[0]);
400 fhDXYvsDZNormalized[0]->Fill(b[1]/bRes[1], b[0]/bRes[0]);
404 //########################################################################
406 if (cut) return kFALSE;
408 //########################################################################
409 // filling histograms after cut
411 fhNClustersITS[1]->Fill(nClustersITS);
412 fhNClustersTPC[1]->Fill(nClustersTPC);
413 fhChi2PerClusterITS[1]->Fill(chi2PerClusterITS);
414 fhChi2PerClusterTPC[1]->Fill(chi2PerClusterTPC);
416 fhC11[1]->Fill(extCov[0]);
417 fhC22[1]->Fill(extCov[2]);
418 fhC33[1]->Fill(extCov[5]);
419 fhC44[1]->Fill(extCov[9]);
420 fhC55[1]->Fill(extCov[14]);
423 fhDXY[1]->Fill(b[0]);
424 fhDXYvsDZ[1]->Fill(b[1],b[0]);
426 fhDZNormalized[1]->Fill(b[1]/bRes[1]);
427 fhDXYNormalized[1]->Fill(b[0]/bRes[0]);
428 fhDXYvsDZNormalized[1]->Fill(b[1]/bRes[1], b[0]/bRes[0]);
434 //____________________________________________________________________
436 AliESDtrackCuts::GetAcceptedTracks(AliESD* esd)
439 // returns an array of all tracks that pass the cuts
442 TObjArray* acceptedTracks = new TObjArray();
444 // loop over esd tracks
445 for (Int_t iTrack = 0; iTrack < esd->GetNumberOfTracks(); iTrack++) {
446 AliESDtrack* track = esd->GetTrack(iTrack);
448 if (AcceptTrack(track))
449 acceptedTracks->Add(track);
452 return acceptedTracks;
455 //____________________________________________________________________
456 void AliESDtrackCuts::DefineHistograms(Int_t color) {
460 // //###################################################################################
461 // defining histograms
463 fhCutStatistics = new TH1F("cut_statistics","cut statistics",kNCuts+4,-0.5,kNCuts+3.5);
465 fhCutStatistics->GetXaxis()->SetBinLabel(1,"n tracks");
466 fhCutStatistics->GetXaxis()->SetBinLabel(2,"n cut tracks");
468 fhCutCorrelation = new TH2F("cut_correlation","cut correlation",kNCuts,-0.5,kNCuts-0.5,kNCuts,-0.5,kNCuts-0.5);;
470 for (Int_t i=0; i<kNCuts; i++) {
471 fhCutStatistics->GetXaxis()->SetBinLabel(i+4,fCutNames[i]);
472 fhCutCorrelation->GetXaxis()->SetBinLabel(i+1,fCutNames[i]);
473 fhCutCorrelation->GetYaxis()->SetBinLabel(i+1,fCutNames[i]);
476 fhCutStatistics ->SetLineColor(color);
477 fhCutCorrelation ->SetLineColor(color);
478 fhCutStatistics ->SetLineWidth(2);
479 fhCutCorrelation ->SetLineWidth(2);
482 for (Int_t i=0; i<2; i++) {
483 if (i==0) sprintf(str," ");
484 else sprintf(str,"_cut");
486 fhNClustersITS[i] = new TH1F(Form("nClustersITS%s",str),"",8,-0.5,7.5);
487 fhNClustersTPC[i] = new TH1F(Form("nClustersTPC%s",str),"",165,-0.5,164.5);
488 fhChi2PerClusterITS[i] = new TH1F(Form("chi2PerClusterITS%s",str),"",500,0,10);
489 fhChi2PerClusterTPC[i] = new TH1F(Form("chi2PerClusterTPC%s",str),"",500,0,10);
491 fhC11[i] = new TH1F(Form("covMatrixDiagonal11%s",str),"",1000,0,5);
492 fhC22[i] = new TH1F(Form("covMatrixDiagonal22%s",str),"",1000,0,5);
493 fhC33[i] = new TH1F(Form("covMatrixDiagonal33%s",str),"",1000,0,0.5);
494 fhC44[i] = new TH1F(Form("covMatrixDiagonal44%s",str),"",1000,0,5);
495 fhC55[i] = new TH1F(Form("covMatrixDiagonal55%s",str),"",1000,0,5);
497 fhDXY[i] = new TH1F(Form("dXY%s",str),"",500,-10,10);
498 fhDZ[i] = new TH1F(Form("dZ%s",str),"",500,-10,10);
499 fhDXYvsDZ[i] = new TH2F(Form("dXYvsDZ%s",str),"",200,-10,10,200,-10,10);
501 fhDXYNormalized[i] = new TH1F(Form("dXYNormalized%s",str),"",500,-10,10);
502 fhDZNormalized[i] = new TH1F(Form("dZNormalized%s",str),"",500,-10,10);
503 fhDXYvsDZNormalized[i] = new TH2F(Form("dXYvsDZNormalized%s",str),"",200,-10,10,200,-10,10);
506 fhNClustersITS[i]->SetXTitle("n ITS clusters");
507 fhNClustersTPC[i]->SetXTitle("n TPC clusters");
508 fhChi2PerClusterITS[i]->SetXTitle("#Chi^{2} per ITS cluster");
509 fhChi2PerClusterTPC[i]->SetXTitle("#Chi^{2} per TPC cluster");
511 fhC11[i]->SetXTitle("cov 11 : #sigma_{y}^{2} [cm^{2}]");
512 fhC22[i]->SetXTitle("cov 22 : #sigma_{z}^{2} [cm^{2}]");
513 fhC33[i]->SetXTitle("cov 33 : #sigma_{sin(#phi)}^{2}");
514 fhC44[i]->SetXTitle("cov 44 : #sigma_{tan(#theta_{dip})}^{2}");
515 fhC55[i]->SetXTitle("cov 55 : #sigma_{1/p_{T}}^{2} [(c/GeV)^2]");
517 fhDXY[i]->SetXTitle("transverse impact parameter");
518 fhDZ[i]->SetXTitle("longitudinal impact parameter");
519 fhDXYvsDZ[i]->SetXTitle("longitudinal impact parameter");
520 fhDXYvsDZ[i]->SetYTitle("transverse impact parameter");
522 fhDXYNormalized[i]->SetXTitle("normalized trans impact par");
523 fhDZNormalized[i]->SetXTitle("normalized long impact par");
524 fhDXYvsDZNormalized[i]->SetXTitle("normalized long impact par");
525 fhDXYvsDZNormalized[i]->SetYTitle("normalized trans impact par");
527 fhNClustersITS[i]->SetLineColor(color); fhNClustersITS[i]->SetLineWidth(2);
528 fhNClustersTPC[i]->SetLineColor(color); fhNClustersTPC[i]->SetLineWidth(2);
529 fhChi2PerClusterITS[i]->SetLineColor(color); fhChi2PerClusterITS[i]->SetLineWidth(2);
530 fhChi2PerClusterTPC[i]->SetLineColor(color); fhChi2PerClusterTPC[i]->SetLineWidth(2);
532 fhC11[i]->SetLineColor(color); fhC11[i]->SetLineWidth(2);
533 fhC22[i]->SetLineColor(color); fhC22[i]->SetLineWidth(2);
534 fhC33[i]->SetLineColor(color); fhC33[i]->SetLineWidth(2);
535 fhC44[i]->SetLineColor(color); fhC44[i]->SetLineWidth(2);
536 fhC55[i]->SetLineColor(color); fhC55[i]->SetLineWidth(2);
538 fhDXY[i]->SetLineColor(color); fhDXY[i]->SetLineWidth(2);
539 fhDZ[i]->SetLineColor(color); fhDZ[i]->SetLineWidth(2);
541 fhDXYNormalized[i]->SetLineColor(color); fhDXYNormalized[i]->SetLineWidth(2);
542 fhDZNormalized[i]->SetLineColor(color); fhDZNormalized[i]->SetLineWidth(2);
546 //____________________________________________________________________
548 AliESDtrackCuts::Print(const Option_t*) const {
550 AliInfo("AliESDtrackCuts...");
554 //____________________________________________________________________
555 void AliESDtrackCuts::SaveHistograms(Char_t* dir) {
557 if (!fHistogramsOn) {
558 AliDebug(0, "Histograms not on - cannot save histograms!!!");
562 gDirectory->mkdir(dir);
565 gDirectory->mkdir("before_cuts");
566 gDirectory->mkdir("after_cuts");
568 fhCutStatistics->Write();
569 fhCutCorrelation->Write();
571 for (Int_t i=0; i<2; i++) {
573 gDirectory->cd("before_cuts");
575 gDirectory->cd("after_cuts");
577 fhNClustersITS[i] ->Write();
578 fhNClustersTPC[i] ->Write();
579 fhChi2PerClusterITS[i] ->Write();
580 fhChi2PerClusterTPC[i] ->Write();
590 fhDXYvsDZ[i] ->Write();
592 fhDXYNormalized[i] ->Write();
593 fhDZNormalized[i] ->Write();
594 fhDXYvsDZNormalized[i] ->Write();
596 gDirectory->cd("../");
599 gDirectory->cd("../");