simplified efficiency projection
[u/mrichter/AliRoot.git] / CORRFW / AliCFTrackKineCuts.cxx
CommitLineData
563113d0 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16// The class AliCFTrackKineCuts is designed to select both generated
17// and reconstructed tracks of a given range in momentum space,
18// electric charge and azimuthal emission angle phi
19// and to provide corresponding QA histograms.
20// This class inherits from the Analysis' Framework abstract base class
21// AliAnalysisCuts and is a part of the Correction Framework.
22// This class acts on single, generated and reconstructed tracks, it is
23// applicable on ESD and AOD data.
24// It mainly consists of a IsSelected function that returns a boolean.
25// This function checks whether the considered track passes a set of cuts:
26// - total momentum
27// - pt
28// - px
29// - py
30// - pz
31// - eta
32// - rapidity
33// - phi
34// - charge
35// - is charged
36//
37// The cut values for these cuts are set with the corresponding set functions.
38// All cut classes provided by the correction framework are supposed to be
39// added in the Analysis Framwork's class AliAnalysisFilter and applied by
40// the filter via a loop.
41//
42// author: I. Kraus (Ingrid.Kraus@cern.ch)
43// idea taken form
44// AliESDtrackCuts writte by Jan Fiete Grosse-Oetringhaus and
45// AliRsnDaughterCut class written by A. Pulvirenti.
46
47#include <TCanvas.h>
48#include <TDirectory.h>
563113d0 49#include <TH2.h>
7122f2a0 50#include <TBits.h>
563113d0 51
52#include <AliVParticle.h>
53#include <AliLog.h>
54#include "AliCFTrackKineCuts.h"
55
56ClassImp(AliCFTrackKineCuts)
57
58//__________________________________________________________________________________
59AliCFTrackKineCuts::AliCFTrackKineCuts() :
60 AliCFCutBase(),
61 fMomentumMin(0),
62 fMomentumMax(0),
63 fPtMin(0),
64 fPtMax(0),
65 fPxMin(0),
66 fPxMax(0),
67 fPyMin(0),
68 fPyMax(0),
69 fPzMin(0),
70 fPzMax(0),
71 fEtaMin(0),
72 fEtaMax(0),
73 fRapidityMin(0),
74 fRapidityMax(0),
75 fPhiMin(0),
76 fPhiMax(0),
77 fCharge(0),
78 fRequireIsCharged(0),
79 fhCutStatistics(0),
80 fhCutCorrelation(0),
81 fBitmap(0x0),
82 fhNBinsMomentum(0),
83 fhNBinsPt(0),
84 fhNBinsPx(0),
85 fhNBinsPy(0),
86 fhNBinsPz(0),
87 fhNBinsEta(0),
88 fhNBinsRapidity(0),
89 fhNBinsPhi(0),
90 fhNBinsCharge(0),
91 fhBinLimMomentum(0x0),
92 fhBinLimPt(0x0),
93 fhBinLimPx(0x0),
94 fhBinLimPy(0x0),
95 fhBinLimPz(0x0),
96 fhBinLimEta(0x0),
97 fhBinLimRapidity(0x0),
98 fhBinLimPhi(0x0),
99 fhBinLimCharge(0x0)
563113d0 100{
101 //
102 // Default constructor
103 //
563113d0 104 Initialise();
105}
106//__________________________________________________________________________________
107AliCFTrackKineCuts::AliCFTrackKineCuts(Char_t* name, Char_t* title) :
108 AliCFCutBase(name,title),
109 fMomentumMin(0),
110 fMomentumMax(0),
111 fPtMin(0),
112 fPtMax(0),
113 fPxMin(0),
114 fPxMax(0),
115 fPyMin(0),
116 fPyMax(0),
117 fPzMin(0),
118 fPzMax(0),
119 fEtaMin(0),
120 fEtaMax(0),
121 fRapidityMin(0),
122 fRapidityMax(0),
123 fPhiMin(0),
124 fPhiMax(0),
125 fCharge(0),
126 fRequireIsCharged(0),
127 fhCutStatistics(0),
128 fhCutCorrelation(0),
129 fBitmap(0x0),
130 fhNBinsMomentum(0),
131 fhNBinsPt(0),
132 fhNBinsPx(0),
133 fhNBinsPy(0),
134 fhNBinsPz(0),
135 fhNBinsEta(0),
136 fhNBinsRapidity(0),
137 fhNBinsPhi(0),
138 fhNBinsCharge(0),
139 fhBinLimMomentum(0x0),
140 fhBinLimPt(0x0),
141 fhBinLimPx(0x0),
142 fhBinLimPy(0x0),
143 fhBinLimPz(0x0),
144 fhBinLimEta(0x0),
145 fhBinLimRapidity(0x0),
146 fhBinLimPhi(0x0),
147 fhBinLimCharge(0x0)
563113d0 148{
149 //
150 // Constructor
151 //
563113d0 152 Initialise();
153}
154//__________________________________________________________________________________
155AliCFTrackKineCuts::AliCFTrackKineCuts(const AliCFTrackKineCuts& c) :
156 AliCFCutBase(c),
157 fMomentumMin(c.fMomentumMin),
158 fMomentumMax(c.fMomentumMax),
159 fPtMin(c.fPtMin),
160 fPtMax(c.fPtMax),
161 fPxMin(c.fPxMin),
162 fPxMax(c.fPxMax),
163 fPyMin(c.fPyMin),
164 fPyMax(c.fPyMax),
165 fPzMin(c.fPzMin),
166 fPzMax(c.fPzMax),
167 fEtaMin(c.fEtaMin),
168 fEtaMax(c.fEtaMax),
169 fRapidityMin(c.fRapidityMin),
170 fRapidityMax(c.fRapidityMax),
171 fPhiMin(c.fPhiMin),
172 fPhiMax(c.fPhiMax),
173 fCharge(c.fCharge),
174 fRequireIsCharged(c.fRequireIsCharged),
175 fhCutStatistics(c.fhCutStatistics),
176 fhCutCorrelation(c.fhCutCorrelation),
177 fBitmap(c.fBitmap),
178 fhNBinsMomentum(c.fhNBinsMomentum),
179 fhNBinsPt(c.fhNBinsPt),
180 fhNBinsPx(c.fhNBinsPx),
181 fhNBinsPy(c.fhNBinsPy),
182 fhNBinsPz(c.fhNBinsPz),
183 fhNBinsEta(c.fhNBinsEta),
184 fhNBinsRapidity(c.fhNBinsRapidity),
185 fhNBinsPhi(c.fhNBinsPhi),
186 fhNBinsCharge(c.fhNBinsCharge),
187 fhBinLimMomentum(c.fhBinLimMomentum),
188 fhBinLimPt(c.fhBinLimPt),
189 fhBinLimPx(c.fhBinLimPx),
190 fhBinLimPy(c.fhBinLimPy),
191 fhBinLimPz(c.fhBinLimPz),
192 fhBinLimEta(c.fhBinLimEta),
193 fhBinLimRapidity(c.fhBinLimRapidity),
194 fhBinLimPhi(c.fhBinLimPhi),
195 fhBinLimCharge(c.fhBinLimCharge)
563113d0 196{
197 //
198 // copy constructor
199 //
200 ((AliCFTrackKineCuts &) c).Copy(*this);
201}
202//__________________________________________________________________________________
203AliCFTrackKineCuts& AliCFTrackKineCuts::operator=(const AliCFTrackKineCuts& c)
204{
205 //
206 // Assignment operator
207 //
208 if (this != &c) {
209 AliCFCutBase::operator=(c) ;
210 fMomentumMin = c.fMomentumMin ;
211 fMomentumMax = c.fMomentumMax ;
212 fPtMin = c.fPtMin ;
213 fPtMax = c.fPtMax ;
214 fPxMin = c.fPxMin ;
215 fPxMax = c.fPxMax ;
216 fPyMin = c.fPyMin ;
217 fPyMax = c.fPyMax ;
218 fPzMin = c.fPzMin ;
219 fPzMax = c.fPzMax ;
220 fEtaMin = c.fEtaMin ;
221 fEtaMax = c.fEtaMax ;
222 fRapidityMin = c.fRapidityMin ;
223 fRapidityMax = c.fRapidityMax ;
224 fPhiMin = c.fPhiMin ;
225 fPhiMax = c.fPhiMax ;
226 fCharge = c.fCharge ;
227 fRequireIsCharged = c.fRequireIsCharged ;
228 fhCutStatistics = c.fhCutStatistics ;
229 fhCutCorrelation = c.fhCutCorrelation ;
230 fBitmap = c.fBitmap;
231 fhNBinsMomentum = c.fhNBinsMomentum;
232 fhNBinsPt = c.fhNBinsPt;
233 fhNBinsPx = c.fhNBinsPx;
234 fhNBinsPy = c.fhNBinsPy;
235 fhNBinsPz = c.fhNBinsPz;
236 fhNBinsEta = c.fhNBinsEta;
237 fhNBinsRapidity = c.fhNBinsRapidity;
238 fhNBinsPhi = c.fhNBinsPhi;
239 fhNBinsCharge = c.fhNBinsCharge;
240 fhBinLimMomentum = c.fhBinLimMomentum;
241 fhBinLimPt = c.fhBinLimPt;
242 fhBinLimPx = c.fhBinLimPx;
243 fhBinLimPy = c.fhBinLimPy;
244 fhBinLimPz = c.fhBinLimPz;
245 fhBinLimEta = c.fhBinLimEta;
246 fhBinLimRapidity = c.fhBinLimRapidity;
247 fhBinLimPhi = c.fhBinLimPhi;
248 fhBinLimCharge = c.fhBinLimCharge;
7122f2a0 249
563113d0 250 for (Int_t i=0; i<c.kNHist; i++){
251 for (Int_t j=0; j<c.kNStepQA; j++){
252 if(c.fhQA[i][j]) fhQA[i][j] = (TH1F*)c.fhQA[i][j]->Clone();
253 }
254 }
563113d0 255 ((AliCFTrackKineCuts &) c).Copy(*this);
256 }
257 return *this ;
258}
259//__________________________________________________________________________________
260AliCFTrackKineCuts::~AliCFTrackKineCuts()
261{
262 //
263 // destructor
264 //
265 if (fhCutStatistics) delete fhCutStatistics;
266 if (fhCutCorrelation) delete fhCutCorrelation;
267
268 for (Int_t i=0; i<kNHist; i++){
269 for (Int_t j=0; j<kNStepQA; j++){
270 if(fhQA[i][j]) delete fhQA[i][j];
271 }
272 }
7122f2a0 273 if(fBitmap) delete fBitmap;
563113d0 274 if(fhBinLimMomentum) delete fhBinLimMomentum;
275 if(fhBinLimPt) delete fhBinLimPt;
276 if(fhBinLimPx) delete fhBinLimPx;
277 if(fhBinLimPy) delete fhBinLimPy;
278 if(fhBinLimPz) delete fhBinLimPz;
279 if(fhBinLimEta) delete fhBinLimEta;
280 if(fhBinLimRapidity) delete fhBinLimRapidity;
281 if(fhBinLimPhi) delete fhBinLimPhi;
282 if(fhBinLimCharge) delete fhBinLimCharge;
283}
284//__________________________________________________________________________________
285void AliCFTrackKineCuts::Initialise()
286{
287 //
288 // sets everything to zero
289 //
290 fMomentumMin = 0;
291 fMomentumMax = 0;
292 fPtMin = 0;
293 fPtMax = 0;
294 fPxMin = 0;
295 fPxMax = 0;
296 fPyMin = 0;
297 fPyMax = 0;
298 fPzMin = 0;
299 fPzMax = 0;
300 fEtaMin = 0;
301 fEtaMax = 0;
302 fRapidityMin = 0;
303 fRapidityMax = 0;
304 fPhiMin = 0;
305 fPhiMax = 0;
306 fCharge = 0;
307 fRequireIsCharged = 0;
308
309 SetMomentumRange();
310 SetPtRange();
311 SetPxRange();
312 SetPyRange();
313 SetPzRange();
314 SetEtaRange();
315 SetRapidityRange();
316 SetPhiRange();
317 SetChargeRec();
318 SetChargeMC();
319 SetRequireIsCharged();
320
321 for (Int_t i=0; i<kNHist; i++){
322 for (Int_t j=0; j<kNStepQA; j++) {
323 fhQA[i][j] = 0x0;
324 }
325 }
326
327 fhCutStatistics = 0;
328 fhCutCorrelation = 0;
7122f2a0 329 fBitmap=new TBits(0);
330
331 //set default bining for QA histograms
563113d0 332 SetHistogramBins(kCutP,200,0.,20.);
333 SetHistogramBins(kCutPt,200,0.,20.);
334 SetHistogramBins(kCutPx,400,-20.,20.);
335 SetHistogramBins(kCutPy,400,-20.,20.);
336 SetHistogramBins(kCutPz,400,-20.,20.);
337 SetHistogramBins(kCutRapidity,200,-10.,10.);
338 SetHistogramBins(kCutEta,200,-10.,10.);
339 SetHistogramBins(kCutPhi,38,-0.6,7.);
340 SetHistogramBins(kCutCharge,21,-10.5,10.5);
563113d0 341}
342//__________________________________________________________________________________
343void AliCFTrackKineCuts::Copy(TObject &c) const
344{
345 //
346 // Copy function
347 //
348 AliCFTrackKineCuts& target = (AliCFTrackKineCuts &) c;
349
350 target.Initialise();
351
352 if (fhCutStatistics) target.fhCutStatistics = (TH1F*) fhCutStatistics->Clone();
353 if (fhCutCorrelation) target.fhCutCorrelation = (TH2F*) fhCutCorrelation->Clone();
354
355 for (Int_t i=0; i<kNHist; i++){
356 for (Int_t j=0; j<kNStepQA; j++){
357 if(fhQA[i][j]) target.fhQA[i][j] = (TH1F*)fhQA[i][j]->Clone();
358 }
359 }
563113d0 360 TNamed::Copy(c);
361}
362//__________________________________________________________________________________
107a3100 363void AliCFTrackKineCuts::SelectionBitMap(TObject* obj) {
563113d0 364 //
365 // test if the track passes the single cuts
366 // and store the information in a bitmap
367 //
368
369 // bitmap stores the decision of each single cut
370 for(Int_t i=0; i<kNCuts; i++)fBitmap->SetBitNumber(i,kFALSE);
7122f2a0 371
107a3100 372 // check TObject and cast into VParticle
373 if (!obj) return ;
374 if (!obj->InheritsFrom("AliVParticle")) AliError("object must derived from AliVParticle !");
563113d0 375 AliVParticle* particle = dynamic_cast<AliVParticle *>(obj);
107a3100 376 if ( !particle ) return;
563113d0 377
378 Int_t iCutBit = 0;
107a3100 379 if((particle->P() >= fMomentumMin) && (particle->P() <= fMomentumMax))
380 fBitmap->SetBitNumber(iCutBit,kTRUE);
563113d0 381 iCutBit++;
107a3100 382 if ((particle->Pt() >= fPtMin) && (particle->Pt() <= fPtMax))
383 fBitmap->SetBitNumber(iCutBit,kTRUE);
563113d0 384 iCutBit++;
107a3100 385 if ((particle->Px() >= fPxMin) && (particle->Px() <= fPxMax))
386 fBitmap->SetBitNumber(iCutBit,kTRUE);
563113d0 387 iCutBit++;
107a3100 388 if ((particle->Py() >= fPyMin) && (particle->Py() <= fPyMax))
389 fBitmap->SetBitNumber(iCutBit,kTRUE);
563113d0 390 iCutBit++;
107a3100 391 if ((particle->Pz() >= fPzMin) && (particle->Pz() <= fPzMax))
392 fBitmap->SetBitNumber(iCutBit,kTRUE);
563113d0 393 iCutBit++;
107a3100 394 if ((particle->Eta() >= fEtaMin) && (particle->Eta() <= fEtaMax))
395 fBitmap->SetBitNumber(iCutBit,kTRUE);
563113d0 396 iCutBit++;
107a3100 397 if ((particle->Y() >= fRapidityMin) && (particle->Y() <= fRapidityMax))
398 fBitmap->SetBitNumber(iCutBit,kTRUE);
563113d0 399 iCutBit++;
107a3100 400 if ((particle->Phi() >= fPhiMin) && (particle->Phi() <= fPhiMax))
401 fBitmap->SetBitNumber(iCutBit,kTRUE);
563113d0 402 iCutBit++;
76becad4 403 if (fCharge >= 10 || (particle->Charge() == fCharge))
107a3100 404 fBitmap->SetBitNumber(iCutBit,kTRUE);
563113d0 405 iCutBit++;
107a3100 406 if (fRequireIsCharged && particle->Charge()!=0)
407 fBitmap->SetBitNumber(iCutBit,kTRUE);
408 if (!fRequireIsCharged)
409 fBitmap->SetBitNumber(iCutBit,kTRUE);
563113d0 410
107a3100 411 return;
563113d0 412}
413//__________________________________________________________________________________
414Bool_t AliCFTrackKineCuts::IsSelected(TObject* obj) {
415 //
416 // loops over decisions of single cuts and returns if the track is accepted
417 //
107a3100 418 SelectionBitMap(obj);
563113d0 419
107a3100 420 if (fIsQAOn) FillHistograms(obj,0);
563113d0 421 Bool_t isSelected = kTRUE;
422
107a3100 423 for (UInt_t icut=0; icut<fBitmap->GetNbits();icut++) {
424 if(!fBitmap->TestBitNumber(icut)) {
425 isSelected = kFALSE;
426 break;
427 }
428 }
429 if (!isSelected) return kFALSE ;
430 if (fIsQAOn) FillHistograms(obj,1);
431 return kTRUE;
563113d0 432}
433//__________________________________________________________________________________
434void AliCFTrackKineCuts::SetHistogramBins(Int_t index, Int_t nbins, Double_t *bins)
435{
436 //
437 // variable bin size
438 //
439 if(!fIsQAOn) return;
440
441 switch(index){
442 case kCutP:
db6722a5 443 fhNBinsMomentum=nbins+1;
563113d0 444 fhBinLimMomentum=new Double_t[nbins+1];
445 for(Int_t i=0;i<nbins+1;i++)fhBinLimMomentum[i]=bins[i];
446 break;
7122f2a0 447
563113d0 448 case kCutPt:
db6722a5 449 fhNBinsPt=nbins+1;
563113d0 450 fhBinLimPt=new Double_t[nbins+1];
451 for(Int_t i=0;i<nbins+1;i++)fhBinLimPt[i]=bins[i];
452 break;
7122f2a0 453
563113d0 454 case kCutPx:
db6722a5 455 fhNBinsPx=nbins+1;
563113d0 456 fhBinLimPx=new Double_t[nbins+1];
457 for(Int_t i=0;i<nbins+1;i++)fhBinLimPx[i]=bins[i];
458 break;
459
460 case kCutPy:
db6722a5 461 fhNBinsPy=nbins+1;
563113d0 462 fhBinLimPy=new Double_t[nbins+1];
463 for(Int_t i=0;i<nbins+1;i++)fhBinLimPy[i]=bins[i];
464 break;
7122f2a0 465
563113d0 466 case kCutPz:
db6722a5 467 fhNBinsPz=nbins+1;
563113d0 468 fhBinLimPz=new Double_t[nbins+1];
469 for(Int_t i=0;i<nbins+1;i++)fhBinLimPz[i]=bins[i];
470 break;
7122f2a0 471
563113d0 472 case kCutRapidity:
db6722a5 473 fhNBinsRapidity=nbins+1;
563113d0 474 fhBinLimRapidity=new Double_t[nbins+1];
475 for(Int_t i=0;i<nbins+1;i++)fhBinLimRapidity[i]=bins[i];
476 break;
7122f2a0 477
563113d0 478 case kCutEta:
db6722a5 479 fhNBinsEta=nbins+1;
563113d0 480 fhBinLimEta=new Double_t[nbins+1];
481 for(Int_t i=0;i<nbins+1;i++)fhBinLimEta[i]=bins[i];
482 break;
7122f2a0 483
563113d0 484 case kCutPhi:
db6722a5 485 fhNBinsPhi=nbins+1;
563113d0 486 fhBinLimPhi=new Double_t[nbins+1];
487 for(Int_t i=0;i<nbins+1;i++)fhBinLimPhi[i]=bins[i];
488 break;
7122f2a0 489
563113d0 490 case kCutCharge:
db6722a5 491 fhNBinsCharge=nbins+1;
563113d0 492 fhBinLimCharge=new Double_t[nbins+1];
493 for(Int_t i=0;i<nbins+1;i++)fhBinLimCharge[i]=bins[i];
494 break;
495 }
496}
497//__________________________________________________________________________________
498void AliCFTrackKineCuts::SetHistogramBins(Int_t index, Int_t nbins, Double_t xmin, Double_t xmax)
499{
500 //
501 // fixed bin size
502 //
563113d0 503 switch(index){
504 case kCutP:
db6722a5 505 fhNBinsMomentum=nbins+1;
563113d0 506 fhBinLimMomentum=new Double_t[nbins+1];
507 for(Int_t i=0;i<nbins+1;i++)fhBinLimMomentum[i]=xmin+i*(xmax-xmin)/Double_t(nbins);
508 break;
7122f2a0 509
563113d0 510 case kCutPt:
db6722a5 511 fhNBinsPt=nbins+1;
563113d0 512 fhBinLimPt=new Double_t[nbins+1];
513 for(Int_t i=0;i<nbins+1;i++)fhBinLimPt[i]=xmin+i*(xmax-xmin)/Double_t(nbins);
514 break;
7122f2a0 515
563113d0 516 case kCutPx:
db6722a5 517 fhNBinsPx=nbins+1;
563113d0 518 fhBinLimPx=new Double_t[nbins+1];
519 for(Int_t i=0;i<nbins+1;i++)fhBinLimPx[i]=xmin+i*(xmax-xmin)/Double_t(nbins);
520 break;
521
522 case kCutPy:
db6722a5 523 fhNBinsPy=nbins+1;
563113d0 524 fhBinLimPy=new Double_t[nbins+1];
525 for(Int_t i=0;i<nbins+1;i++)fhBinLimPy[i]=xmin+i*(xmax-xmin)/Double_t(nbins);
526 break;
7122f2a0 527
563113d0 528 case kCutPz:
db6722a5 529 fhNBinsPz=nbins+1;
563113d0 530 fhBinLimPz=new Double_t[nbins+1];
531 for(Int_t i=0;i<nbins+1;i++)fhBinLimPz[i]=xmin+i*(xmax-xmin)/Double_t(nbins);
532 break;
7122f2a0 533
563113d0 534 case kCutRapidity:
db6722a5 535 fhNBinsRapidity=nbins+1;
563113d0 536 fhBinLimRapidity=new Double_t[nbins+1];
537 for(Int_t i=0;i<nbins+1;i++)fhBinLimRapidity[i]=xmin+i*(xmax-xmin)/Double_t(nbins);
538 break;
7122f2a0 539
563113d0 540 case kCutEta:
db6722a5 541 fhNBinsEta=nbins+1;
563113d0 542 fhBinLimEta=new Double_t[nbins+1];
543 for(Int_t i=0;i<nbins+1;i++)fhBinLimEta[i]=xmin+i*(xmax-xmin)/Double_t(nbins);
544 break;
7122f2a0 545
563113d0 546 case kCutPhi:
db6722a5 547 fhNBinsPhi=nbins+1;
563113d0 548 fhBinLimPhi=new Double_t[nbins+1];
549 for(Int_t i=0;i<nbins+1;i++)fhBinLimPhi[i]=xmin+i*(xmax-xmin)/Double_t(nbins);
550 break;
7122f2a0 551
563113d0 552 case kCutCharge:
db6722a5 553 fhNBinsCharge=nbins+1;
563113d0 554 fhBinLimCharge=new Double_t[nbins+1];
555 for(Int_t i=0;i<nbins+1;i++)fhBinLimCharge[i]=xmin+i*(xmax-xmin)/Double_t(nbins);
556 break;
557 }
558}
559//__________________________________________________________________________________
560 void AliCFTrackKineCuts::DefineHistograms() {
561 //
562 // histograms for cut variables, cut statistics and cut correlations
563 //
563113d0 564 Int_t color = 2;
565
566 // book cut statistics and cut correlation histograms
567 fhCutStatistics = new TH1F(Form("%s_cut_statistics",GetName()), Form("%s cut statistics",GetName()), kNCuts,0.5,kNCuts+0.5);
568 fhCutStatistics->SetLineWidth(2);
569 fhCutStatistics->GetXaxis()->SetBinLabel(1,"p");
570 fhCutStatistics->GetXaxis()->SetBinLabel(2,"pt");
571 fhCutStatistics->GetXaxis()->SetBinLabel(3,"px");
572 fhCutStatistics->GetXaxis()->SetBinLabel(4,"py");
573 fhCutStatistics->GetXaxis()->SetBinLabel(5,"pz");
574 fhCutStatistics->GetXaxis()->SetBinLabel(6,"eta");
575 fhCutStatistics->GetXaxis()->SetBinLabel(7,"y");
576 fhCutStatistics->GetXaxis()->SetBinLabel(8,"phi");
577 fhCutStatistics->GetXaxis()->SetBinLabel(9,"charge");
578 fhCutStatistics->GetXaxis()->SetBinLabel(10,"is charged");
579
580 fhCutCorrelation = new TH2F(Form("%s_cut_correlation",GetName()), Form("%s cut correlation",GetName()), kNCuts,0.5,kNCuts+0.5,kNCuts,0.5,kNCuts+0.5);
581 fhCutCorrelation->SetLineWidth(2);
582 fhCutCorrelation->GetXaxis()->SetBinLabel(1,"p");
583 fhCutCorrelation->GetXaxis()->SetBinLabel(2,"pt");
584 fhCutCorrelation->GetXaxis()->SetBinLabel(3,"px");
585 fhCutCorrelation->GetXaxis()->SetBinLabel(4,"py");
586 fhCutCorrelation->GetXaxis()->SetBinLabel(5,"pz");
587 fhCutCorrelation->GetXaxis()->SetBinLabel(6,"eta");
588 fhCutCorrelation->GetXaxis()->SetBinLabel(7,"y");
589 fhCutCorrelation->GetXaxis()->SetBinLabel(8,"phi");
590 fhCutCorrelation->GetXaxis()->SetBinLabel(9,"charge");
591 fhCutCorrelation->GetXaxis()->SetBinLabel(10,"is charged");
592
593 fhCutCorrelation->GetYaxis()->SetBinLabel(1,"p");
594 fhCutCorrelation->GetYaxis()->SetBinLabel(2,"pt");
595 fhCutCorrelation->GetYaxis()->SetBinLabel(3,"px");
596 fhCutCorrelation->GetYaxis()->SetBinLabel(4,"py");
597 fhCutCorrelation->GetYaxis()->SetBinLabel(5,"pz");
598 fhCutCorrelation->GetYaxis()->SetBinLabel(6,"eta");
599 fhCutCorrelation->GetYaxis()->SetBinLabel(7,"y");
600 fhCutCorrelation->GetYaxis()->SetBinLabel(8,"phi");
601 fhCutCorrelation->GetYaxis()->SetBinLabel(9,"charge");
602 fhCutCorrelation->GetYaxis()->SetBinLabel(10,"is charged");
603
604
605 // book QA histograms
606 Char_t str[256];
607 for (Int_t i=0; i<kNStepQA; i++) {
608 if (i==0) sprintf(str," ");
609 else sprintf(str,"_cut");
610
db6722a5 611 fhQA[kCutP][i] = new TH1F(Form("%s_momentum%s",GetName(),str), "",fhNBinsMomentum-1,fhBinLimMomentum);
612 fhQA[kCutPt][i] = new TH1F(Form("%s_transverse_momentum%s",GetName(),str),"",fhNBinsPt-1,fhBinLimPt);
613 fhQA[kCutPx][i] = new TH1F(Form("%s_px%s",GetName(),str), "",fhNBinsPx-1,fhBinLimPx);
614 fhQA[kCutPy][i] = new TH1F(Form("%s_py%s",GetName(),str), "",fhNBinsPy-1,fhBinLimPy);
615 fhQA[kCutPz][i] = new TH1F(Form("%s_pz%s",GetName(),str), "",fhNBinsPz-1,fhBinLimPz);
616 fhQA[kCutRapidity][i]=new TH1F(Form("%s_rapidity%s",GetName(),str), "",fhNBinsRapidity-1,fhBinLimRapidity);
617 fhQA[kCutEta][i] = new TH1F(Form("%s_eta%s",GetName(),str), "",fhNBinsEta-1,fhBinLimEta);
618 fhQA[kCutPhi][i] = new TH1F(Form("%s_phi%s",GetName(),str), "",fhNBinsPhi-1,fhBinLimPhi);
619 fhQA[kCutCharge][i] = new TH1F(Form("%s_charge%s",GetName(),str), "",fhNBinsCharge-1,fhBinLimCharge);
563113d0 620
621 fhQA[kCutP][i] ->SetXTitle("momentum p (GeV/c)");
622 fhQA[kCutPt][i] ->SetXTitle("p_{T} (GeV/c)");
623 fhQA[kCutPx][i] ->SetXTitle("p_{x} (GeV/c)");
624 fhQA[kCutPy][i] ->SetXTitle("p_{y} (GeV/c)");
625 fhQA[kCutPz][i] ->SetXTitle("p_{z} (GeV/c)");
626 fhQA[kCutRapidity][i]->SetXTitle("rapidity y");
627 fhQA[kCutEta][i] ->SetXTitle("pseudo rapidity #eta");
628 fhQA[kCutPhi][i] ->SetXTitle("azimuth #phi (rad)");
629 fhQA[kCutCharge][i] ->SetXTitle("charge");
630 }
563113d0 631 for(Int_t i=0; i<kNHist; i++) fhQA[i][1]->SetLineColor(color);
563113d0 632}
633//__________________________________________________________________________________
634void AliCFTrackKineCuts::FillHistograms(TObject* obj, Bool_t b)
635{
636 //
637 // fill the QA histograms
638 //
563113d0 639
640 // cast TObject into VParticle
107a3100 641 if (!obj) return;
563113d0 642 AliVParticle* particle = dynamic_cast<AliVParticle *>(obj);
643 if ( !particle ) return;
644
107a3100 645 // b = 0: fill histograms before cuts
646 // b = 1: fill histograms after cuts
647 fhQA[kCutP][b]->Fill(particle->P());
648 fhQA[kCutPt][b]->Fill(particle->Pt());
649 fhQA[kCutPx][b]->Fill(particle->Px());
650 fhQA[kCutPy][b]->Fill(particle->Py());
651 fhQA[kCutPz][b]->Fill(particle->Pz());
652 fhQA[kCutRapidity][b]->Fill(particle->Y());
653 fhQA[kCutEta][b]->Fill(particle->Eta());
654 fhQA[kCutPhi][b]->Fill(particle->Phi());
655 fhQA[kCutCharge][b]->Fill((float)particle->Charge());
563113d0 656
657 // fill cut statistics and cut correlation histograms with information from the bitmap
658 if (b) return;
659
563113d0 660 // Number of single cuts in this class
107a3100 661 UInt_t ncuts = fBitmap->GetNbits();
563113d0 662 for(UInt_t bit=0; bit<ncuts;bit++) {
107a3100 663 if (!fBitmap->TestBitNumber(bit)) {
664 fhCutStatistics->Fill(bit+1);
665 for (UInt_t bit2=bit; bit2<ncuts;bit2++) {
666 if (!fBitmap->TestBitNumber(bit2))
667 fhCutCorrelation->Fill(bit+1,bit2+1);
668 }
563113d0 669 }
670 }
671}
672//__________________________________________________________________________________
673void AliCFTrackKineCuts::SaveHistograms(const Char_t* dir) {
674 //
675 // saves the histograms in a directory (dir)
676 //
677 if(!fIsQAOn) return;
678
679 if (!dir)
680 dir = GetName();
681
682 gDirectory->mkdir(dir);
683 gDirectory->cd(dir);
684
685 gDirectory->mkdir("before_cuts");
686 gDirectory->mkdir("after_cuts");
687
688 fhCutStatistics->Write();
689 fhCutCorrelation->Write();
690
691 for (Int_t j=0; j<kNStepQA; j++) {
692 if (j==0)
693 gDirectory->cd("before_cuts");
694 else
695 gDirectory->cd("after_cuts");
696
697 for(Int_t i=0; i<kNHist; i++) fhQA[i][j]->Write();
698
699 gDirectory->cd("../");
700 }
563113d0 701 gDirectory->cd("../");
702}
703//__________________________________________________________________________________
704void AliCFTrackKineCuts::DrawHistograms(Bool_t drawLogScale)
705{
706 //
707 // draws some histograms
708 //
709 if(!fIsQAOn) return;
710
711 // pad margins
712 Float_t right = 0.03;
713 Float_t left = 0.175;
714 Float_t top = 0.03;
715 Float_t bottom = 0.175;
716
717 TCanvas* canvas1 = new TCanvas("Track_QA_Kinematics_1", "Track QA Kinematics 1", 800, 500);
718 canvas1->Divide(2, 1);
719
720 canvas1->cd(1);
721 fhCutStatistics->SetStats(kFALSE);
722 fhCutStatistics->LabelsOption("v");
723 gPad->SetLeftMargin(left);
724 gPad->SetBottomMargin(0.25);
725 gPad->SetRightMargin(right);
726 gPad->SetTopMargin(0.1);
727 fhCutStatistics->Draw();
728
729 canvas1->cd(2);
730 fhCutCorrelation->SetStats(kFALSE);
731 fhCutCorrelation->LabelsOption("v");
732 gPad->SetLeftMargin(0.30);
733 gPad->SetRightMargin(bottom);
734 gPad->SetTopMargin(0.1);
735 gPad->SetBottomMargin(0.25);
736 fhCutCorrelation->Draw("COLZ");
737
738 canvas1->SaveAs(Form("%s.eps", canvas1->GetName()));
739 canvas1->SaveAs(Form("%s.ps", canvas1->GetName()));
740
741 // -----
742
743 TCanvas* canvas2 = new TCanvas("Track_QA_Kinematics_2", "Track QA Kinematics 2", 1600, 800);
744 canvas2->Divide(4, 2);
745
746 canvas2->cd(1);
747 fhQA[kCutP][0]->SetStats(kFALSE);
748 if(drawLogScale) gPad->SetLogy();
749 gPad->SetRightMargin(right);
750 gPad->SetLeftMargin(left);
751 gPad->SetTopMargin(top);
752 gPad->SetBottomMargin(bottom);
753 fhQA[kCutP][0]->Draw();
754 fhQA[kCutP][1]->Draw("same");
755
756 canvas2->cd(2);
757 fhQA[kCutPt][0]->SetStats(kFALSE);
758 if(drawLogScale) gPad->SetLogy();
759 gPad->SetRightMargin(right);
760 gPad->SetLeftMargin(left);
761 gPad->SetTopMargin(top);
762 gPad->SetBottomMargin(bottom);
763 fhQA[kCutPt][0]->Draw();
764 fhQA[kCutPt][1]->Draw("same");
765
766 canvas2->cd(3);
767 fhQA[kCutRapidity][0]->SetStats(kFALSE);
768 if(drawLogScale) gPad->SetLogy();
769 gPad->SetRightMargin(right);
770 gPad->SetLeftMargin(left);
771 gPad->SetTopMargin(top);
772 gPad->SetBottomMargin(bottom);
773 fhQA[kCutRapidity][0]->Draw();
774 fhQA[kCutRapidity][1]->Draw("same");
775
776 canvas2->cd(4);
777 fhQA[kCutEta][0]->SetStats(kFALSE);
778 if(drawLogScale) gPad->SetLogy();
779 gPad->SetRightMargin(right);
780 gPad->SetLeftMargin(left);
781 gPad->SetTopMargin(top);
782 gPad->SetBottomMargin(bottom);
783 fhQA[kCutEta][0]->Draw();
784 fhQA[kCutEta][1]->Draw("same");
785
786 canvas2->cd(5);
787 fhQA[kCutPx][0]->SetStats(kFALSE);
788 if(drawLogScale) gPad->SetLogy();
789 gPad->SetRightMargin(right);
790 gPad->SetLeftMargin(left);
791 gPad->SetTopMargin(top);
792 gPad->SetBottomMargin(bottom);
793 fhQA[kCutPx][0]->Draw();
794 fhQA[kCutPx][1]->Draw("same");
795
796 canvas2->cd(6);
797 fhQA[kCutPy][0]->SetStats(kFALSE);
798 if(drawLogScale) gPad->SetLogy();
799 gPad->SetRightMargin(right);
800 gPad->SetLeftMargin(left);
801 gPad->SetTopMargin(top);
802 gPad->SetBottomMargin(bottom);
803 fhQA[kCutPy][0]->Draw();
804 fhQA[kCutPy][1]->Draw("same");
805
806 canvas2->cd(7);
807 fhQA[kCutPz][0]->SetStats(kFALSE);
808 if(drawLogScale) gPad->SetLogy();
809 gPad->SetRightMargin(right);
810 gPad->SetLeftMargin(left);
811 gPad->SetTopMargin(top);
812 gPad->SetBottomMargin(bottom);
813 fhQA[kCutPz][0]->Draw();
814 fhQA[kCutPz][1]->Draw("same");
815
816 canvas2->SaveAs(Form("%s.eps", canvas2->GetName()));
817 canvas2->SaveAs(Form("%s.ps", canvas2->GetName()));
818
819 // -----
820
821 TCanvas* canvas3 = new TCanvas("Track_QA_Kinematics_3", "Track QA Kinematics 3", 800, 400);
822 canvas3->Divide(2, 1);
823
824 canvas3->cd(1);
825 gPad->SetRightMargin(right);
826 gPad->SetLeftMargin(left);
827 gPad->SetTopMargin(top);
828 gPad->SetBottomMargin(bottom);
829 fhQA[kCutPhi][0]->SetStats(kFALSE);
830 fhQA[kCutPhi][0]->Draw();
831 fhQA[kCutPhi][1]->Draw("same");
832
833 canvas3->cd(2);
834 gPad->SetRightMargin(right);
835 gPad->SetLeftMargin(left);
836 gPad->SetTopMargin(top);
837 gPad->SetBottomMargin(bottom);
838 fhQA[kCutCharge][0]->SetStats(kFALSE);
839 fhQA[kCutCharge][0]->Draw();
840 fhQA[kCutCharge][1]->Draw("same");
841
842 canvas3->SaveAs(Form("%s.eps", canvas3->GetName()));
843 canvas3->SaveAs(Form("%s.ps", canvas3->GetName()));
844}
845//__________________________________________________________________________________
107a3100 846void AliCFTrackKineCuts::AddQAHistograms(TList *qaList) {
563113d0 847 //
848 // saves the histograms in a TList
849 //
107a3100 850 DefineHistograms();
563113d0 851
852 qaList->Add(fhCutStatistics);
853 qaList->Add(fhCutCorrelation);
854
855 for (Int_t j=0; j<kNStepQA; j++) {
856 for(Int_t i=0; i<kNHist; i++)
857 qaList->Add(fhQA[i][j]);
858 }
859}