1 /**************************************************************************
2 * Author: Panos Christakoglou. *
3 * Contributors are mentioned in the code where appropriate. *
5 * Permission to use, copy, modify and distribute this software and its *
6 * documentation strictly for non-commercial purposes is hereby granted *
7 * without fee, provided that the above copyright notice appears in all *
8 * copies and that both the copyright notice and this permission notice *
9 * appear in the supporting documentation. The authors make no claims *
10 * about the suitability of this software for any purpose. It is *
11 * provided "as is" without express or implied warranty. *
12 **************************************************************************/
16 //-----------------------------------------------------------------
17 // AliAnalysisTrackCuts class
18 // This is the class to deal with the event and track level cuts
19 // Origin: Panos Christakoglou, UOA-CERN, Panos.Christakoglou@cern.ch
20 //-----------------------------------------------------------------
25 #include <TPaveText.h>
29 #include <TObjArray.h>
30 #include <Riostream.h>
34 #include "AliESDtrack.h"
37 #include "AliAnalysisTrackCuts.h"
39 ClassImp(AliAnalysisTrackCuts)
41 //----------------------------------------//
42 AliAnalysisTrackCuts::AliAnalysisTrackCuts()
44 //Default constructor.
45 //Calls the Reset method.
49 //----------------------------------------//
50 AliAnalysisTrackCuts::~AliAnalysisTrackCuts()
53 delete fAcceptedParticleList;
56 //----------------------------------------//
57 void AliAnalysisTrackCuts::Reset()
59 //Assigns dummy values to every private member.
101 fAcceptedParticleList = new TObjArray();
105 //----------------------------------------//
106 void AliAnalysisTrackCuts::SetPxRange(Float_t r1, Float_t r2)
108 //Sets the range for the momentum x component.
114 //----------------------------------------//
115 void AliAnalysisTrackCuts::SetPyRange(Float_t r1, Float_t r2)
117 //Sets the range for the momentum y component.
123 //----------------------------------------//
124 void AliAnalysisTrackCuts::SetPzRange(Float_t r1, Float_t r2)
126 //Sets the range for the momentum z component.
132 //----------------------------------------//
133 void AliAnalysisTrackCuts::SetPRange(Float_t r1, Float_t r2)
135 //Sets the range for the momentum.
141 //----------------------------------------//
142 void AliAnalysisTrackCuts::SetPtRange(Float_t r1, Float_t r2)
144 //Sets the range for the teransverse momentum.
150 //----------------------------------------//
151 void AliAnalysisTrackCuts::SetBrRange(Float_t r1, Float_t r2)
153 //Sets the range of the closest approach of the track
154 //to the primary vertex in the r-phi plane.
160 //----------------------------------------//
161 void AliAnalysisTrackCuts::SetBzRange(Float_t r1, Float_t r2)
163 //Sets the range of the closest approach of the track
164 //to the primary vertex in the beam axis.
170 //----------------------------------------//
171 void AliAnalysisTrackCuts::SetEtaRange(Float_t r1, Float_t r2)
173 //Sets the range of the pseudo-rapidity.
179 //----------------------------------------//
180 void AliAnalysisTrackCuts::SetRapRange(Float_t r1, Float_t r2)
182 //Sets the range of the rapidity.
188 //----------------------------------------//
189 void AliAnalysisTrackCuts::GetTrackStats()
191 //Gets the statistics.
192 //fTotalTracks is the total number of tracks.
193 //fAcceptedTracks is the number of accepted tracks after the cuts.
194 AliInfo(Form("Total number of tracks: %d",fTotalTracks));
195 AliInfo(Form("Total number of accepted tracks: %d",fAcceptedTracks));
198 //----------------------------------------//
199 void AliAnalysisTrackCuts::GetPStats()
201 //Gets the momentum statistics.
202 //Prints the percentage of tracks rejected due to this cut.
203 AliInfo(Form("P range: [%f,%f]",fPMin,fPMax));
204 if(fTotalTracks != 0)
205 AliInfo(Form("Tracks rejected: %f",100.0*fP/fTotalTracks));
208 //----------------------------------------//
209 void AliAnalysisTrackCuts::GetPtStats()
211 //Gets the transverse momentum statistics.
212 //Prints the percentage of tracks rejected due to this cut.
213 AliInfo(Form("Pt range: [%f,%f]",fPtMin,fPtMax));
214 if(fTotalTracks != 0)
215 AliInfo(Form("Tracks rejected: %f",100.0*fPt/fTotalTracks));
218 //----------------------------------------//
219 void AliAnalysisTrackCuts::GetPxStats()
221 //Gets the x momentum statistics.
222 //Prints the percentage of tracks rejected due to this cut.
223 AliInfo(Form("Px range: [%f,%f]",fPxMin,fPxMax));
224 if(fTotalTracks != 0)
225 AliInfo(Form("Tracks rejected: %f",100.0*fPx/fTotalTracks));
228 //----------------------------------------//
229 void AliAnalysisTrackCuts::GetPyStats()
231 //Gets the y momentum statistics.
232 //Prints the percentage of tracks rejected due to this cut.
233 AliInfo(Form("Py range: [%f,%f]",fPyMin,fPyMax));
234 if(fTotalTracks != 0)
235 AliInfo(Form("Tracks rejected: %f",100.0*fPy/fTotalTracks));
238 //----------------------------------------//
239 void AliAnalysisTrackCuts::GetPzStats()
241 //Gets the z momentum statistics.
242 //Prints the percentage of tracks rejected due to this cut.
243 AliInfo(Form("Pz range: [%f,%f]",fPzMin,fPzMax));
244 if(fTotalTracks != 0)
245 AliInfo(Form("Tracks rejected: %f",100.0*fPz/fTotalTracks));
248 //----------------------------------------//
249 void AliAnalysisTrackCuts::GetEtaStats()
251 //Gets the pseudo-rapidity statistics.
252 //Prints the percentage of tracks rejected due to this cut.
253 AliInfo(Form("eta range: [%f,%f]",fEtaMin,fEtaMax));
254 if(fTotalTracks != 0)
255 AliInfo(Form("Tracks rejected: %f",100.0*fEta/fTotalTracks));
258 //----------------------------------------//
259 void AliAnalysisTrackCuts::GetRapStats()
261 //Gets the rapidity statistics.
262 //Prints the percentage of tracks rejected due to this cut.
263 AliInfo(Form("y range: [%f,%f]",fRapMin,fRapMax));
264 if(fTotalTracks != 0)
265 AliInfo(Form("Tracks rejected: %f",100.0*fRap/fTotalTracks));
268 //----------------------------------------//
269 void AliAnalysisTrackCuts::GetBrStats()
271 //Gets the statistics fro the closest distance of
272 //the track to the primary vertex in the r-phi plane.
273 //Prints the percentage of tracks rejected due to this cut.
274 AliInfo(Form("br range: [%f,%f]",fBrMin,fBrMax));
275 if(fTotalTracks != 0)
276 AliInfo(Form("Tracks rejected: %f",100.0*fbr/fTotalTracks));
279 //----------------------------------------//
280 void AliAnalysisTrackCuts::GetBzStats()
282 //Gets the statistics fro the closest distance of
283 //the track to the primary vertex in the beam axis.
284 //Prints the percentage of tracks rejected due to this cut.
285 AliInfo(Form("bz range: [%f,%f]",fBzMin,fBzMax));
286 if(fTotalTracks != 0)
287 AliInfo(Form("Tracks rejected: %f",100.0*fbz/fTotalTracks));
291 //----------------------------------------//
292 Bool_t AliAnalysisTrackCuts::IsAccepted(AliESD *esd ,AliESDtrack *esdtrack)
294 //Returns true if the tracks is accepted otherwise false.
297 //momentum related calculations
299 esdtrack->GetPxPyPz(p);
300 Float_t momentum = TMath::Sqrt(pow(p[0],2) + pow(p[1],2) + pow(p[2],2));
301 Float_t pt = TMath::Sqrt(pow(p[0],2) + pow(p[1],2));
302 Float_t energy = TMath::Sqrt(pow(esdtrack->GetMass(),2) + pow(momentum,2));
304 //y-eta related calculations
307 if((momentum != TMath::Abs(p[2]))&&(momentum != 0))
308 eta = 0.5*TMath::Log((momentum + p[2])/(momentum - p[2]));
309 if((energy != TMath::Abs(p[2]))&&(momentum != 0))
310 y = 0.5*TMath::Log((energy + p[2])/(energy - p[2]));
312 //impact parameter related calculations
313 Double_t trackPosition[3];
314 esdtrack->GetXYZ(trackPosition);
315 const AliESDVertex * vertexIn = esd->GetVertex();
316 Double_t vertexPosition[3];
317 vertexIn->GetXYZ(vertexPosition);
318 for (Int_t ii=0; ii<3; ii++) trackPosition[ii] -= vertexPosition[ii];
320 Float_t br = Float_t(TMath::Sqrt(pow(trackPosition[0],2) + pow(trackPosition[1],2)));
321 Float_t bz = Float_t(TMath::Abs(trackPosition[2]));
323 if((momentum < fPMin) || (momentum > fPMax)) {
327 if((pt < fPtMin) || (pt > fPtMax)) {
331 if((p[0] < fPxMin) || (p[0] > fPxMax)) {
335 if((p[1] < fPyMin) || (p[1] > fPyMax)) {
339 if((p[2] < fPzMin) || (p[2] > fPzMax)) {
343 if((br < fBrMin) || (br > fBrMax)) {
347 if((bz < fBzMin) || (bz > fBzMax)) {
351 if((eta < fEtaMin) || (eta > fEtaMax)) {
355 if((y < fRapMin) || (y > fRapMax)) {
366 //----------------------------------------//
367 TObjArray *AliAnalysisTrackCuts::GetAcceptedParticles(AliESD *esd)
369 // Returns a list of all tracks that pass the cuts
370 fAcceptedParticleList->Clear();
371 for (Int_t iTrack = 0; iTrack < esd->GetNumberOfTracks(); iTrack++) {
372 AliESDtrack* track = esd->GetTrack(iTrack);
374 if(IsAccepted(esd,track)) fAcceptedParticleList->Add(track);
377 return fAcceptedParticleList;
380 //----------------------------------------//
381 TPaveText *AliAnalysisTrackCuts::GetTrackCuts()
383 //Shows a TPaveText with all the track cuts stats.
384 TCanvas *ccuts2 = new TCanvas("ccuts2","Track cuts",410,10,400,400);
385 ccuts2->SetFillColor(10);
386 ccuts2->SetHighLightColor(10);
388 TPaveText *pave = new TPaveText(0.01,0.01,0.98,0.98);
389 pave->SetFillColor(3);
392 TLine *l1 = pave->AddLine(0,0.89,1,0.89);
394 TLine *l2 = pave->AddLine(0,0.79,1,0.79);
396 TLine *l3 = pave->AddLine(0,0.69,1,0.69);
398 TLine *l4 = pave->AddLine(0,0.59,1,0.59);
400 TLine *l5 = pave->AddLine(0,0.49,1,0.49);
402 TLine *l6 = pave->AddLine(0,0.39,1,0.39);
404 TLine *l7 = pave->AddLine(0,0.29,1,0.29);
406 TLine *l8 = pave->AddLine(0,0.19,1,0.19);
408 TLine *l9 = pave->AddLine(0,0.09,1,0.09);
411 sprintf(cutName,"Total number of tracks: %d",fTotalTracks);
412 TText *t1 = pave->AddText(cutName);
414 t1->SetTextSize(0.04);
415 t1->SetTextAlign(11);
417 sprintf(cutName,"Total number of accepted tracks: %d",fAcceptedTracks);
418 t1 = pave->AddText(cutName);
420 t1->SetTextSize(0.04);
421 t1->SetTextAlign(11);
423 sprintf(cutName,"P range: [%f,%f]",fPMin,fPMax);
424 t1 = pave->AddText(cutName);
426 t1->SetTextSize(0.04);
427 t1->SetTextAlign(11);
428 sprintf(cutName,"Tracks rejected: %f",100.0*fP/fTotalTracks);
429 t1 = pave->AddText(cutName);
431 t1->SetTextSize(0.04);
432 t1->SetTextAlign(11);
434 sprintf(cutName,"Pt range: [%f,%f]",fPtMin,fPtMax);
435 t1 = pave->AddText(cutName);
437 t1->SetTextSize(0.04);
438 t1->SetTextAlign(11);
439 sprintf(cutName,"Tracks rejected: %f",100.0*fPt/fTotalTracks);
440 t1 = pave->AddText(cutName);
442 t1->SetTextSize(0.04);
443 t1->SetTextAlign(11);
445 sprintf(cutName,"Px range: [%f,%f]",fPxMin,fPxMax);
446 t1 = pave->AddText(cutName);
448 t1->SetTextSize(0.04);
449 t1->SetTextAlign(11);
450 sprintf(cutName,"Tracks rejected: %f",100.0*fPx/fTotalTracks);
451 t1 = pave->AddText(cutName);
453 t1->SetTextSize(0.04);
454 t1->SetTextAlign(11);
456 sprintf(cutName,"Py range: [%f,%f]",fPyMin,fPyMax);
457 t1 = pave->AddText(cutName);
459 t1->SetTextSize(0.04);
460 t1->SetTextAlign(11);
461 sprintf(cutName,"Tracks rejected: %f",100.0*fPy/fTotalTracks);
462 t1 = pave->AddText(cutName);
464 t1->SetTextSize(0.04);
465 t1->SetTextAlign(11);
467 sprintf(cutName,"Pz range: [%f,%f]",fPzMin,fPzMax);
468 t1 = pave->AddText(cutName);
470 t1->SetTextSize(0.04);
471 t1->SetTextAlign(11);
472 sprintf(cutName,"Tracks rejected: %f",100.0*fPz/fTotalTracks);
473 t1 = pave->AddText(cutName);
475 t1->SetTextSize(0.04);
476 t1->SetTextAlign(11);
478 sprintf(cutName,"br range: [%f,%f]",fBrMin,fBrMax);
479 t1 = pave->AddText(cutName);
481 t1->SetTextSize(0.04);
482 t1->SetTextAlign(11);
483 sprintf(cutName,"Tracks rejected: %f",100.0*fbr/fTotalTracks);
484 t1 = pave->AddText(cutName);
486 t1->SetTextSize(0.04);
487 t1->SetTextAlign(11);
489 sprintf(cutName,"bz range: [%f,%f]",fBzMin,fBzMax);
490 t1 = pave->AddText(cutName);
492 t1->SetTextSize(0.04);
493 t1->SetTextAlign(11);
494 sprintf(cutName,"Tracks rejected: %f",100.0*fbz/fTotalTracks);
495 t1 = pave->AddText(cutName);
497 t1->SetTextSize(0.04);
498 t1->SetTextAlign(11);
500 sprintf(cutName,"eta range: [%f,%f]",fEtaMin,fEtaMax);
501 t1 = pave->AddText(cutName);
503 t1->SetTextSize(0.04);
504 t1->SetTextAlign(11);
505 sprintf(cutName,"Tracks rejected: %f",100.0*fEta/fTotalTracks);
506 t1 = pave->AddText(cutName);
508 t1->SetTextSize(0.04);
509 t1->SetTextAlign(11);
511 sprintf(cutName,"y range: [%f,%f]",fRapMin,fRapMax);
512 t1 = pave->AddText(cutName);
514 t1->SetTextSize(0.04);
515 t1->SetTextAlign(11);
516 sprintf(cutName,"Tracks rejected: %f",100.0*fRap/fTotalTracks);
517 t1 = pave->AddText(cutName);
519 t1->SetTextSize(0.04);
520 t1->SetTextAlign(11);
525 //----------------------------------------//
526 void AliAnalysisTrackCuts::PrintTrackCuts()
528 //Prints the track cut stats.
529 //GetTrackCuts()->Draw();
531 AliInfo(Form("**************TRACK CUTS**************"));
551 AliInfo(Form("**************************************"));