Conserve the container axis ranges in Projection
[u/mrichter/AliRoot.git] / CORRFW / AliCFTrackQualityCuts.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 AliCFTrackQualityCuts is designed to select reconstructed tracks
17// of high quality and to provide corresponding QA histograms.
18// This class inherits from the Analysis' Framework abstract base class
19// AliAnalysisCuts and is a part of the Correction Framework.
20// This class acts on single, reconstructed tracks, it is applicable on
21// ESD and AOD data.
22// It mainly consists of a IsSelected function that returns a boolean.
23// This function checks whether the considered track passes a set of cuts:
24// - number of clusters in the TPC
25// - number of clusters in the ITS
26// - chi2 / cluster in the TPC
27// - chi2 / cluster in the ITS
28// - successful TPC refit
29// - successful ITS refit
30// - covariance matrix diagonal elements
31//
32// The cut values for these cuts are set with the corresponding set functions.
33// All cut classes provided by the correction framework are supposed to be
34// added in the Analysis Framwork's class AliAnalysisFilter and applied by
35// the filter via a loop.
36//
37// author: I. Kraus (Ingrid.Kraus@cern.ch)
38// idea taken form
39// AliESDtrackCuts writte by Jan Fiete Grosse-Oetringhaus and
40// AliRsnDaughterCut class written by A. Pulvirenti.
41
42
43#include <TCanvas.h>
44#include <TDirectory.h>
563113d0 45#include <TH2.h>
6cb5e116 46#include <TBits.h>
563113d0 47
48#include <AliESDtrack.h>
49#include <AliLog.h>
50#include "AliCFTrackQualityCuts.h"
8edd0c2c 51#include "AliAODTrack.h"
563113d0 52
53ClassImp(AliCFTrackQualityCuts)
54
55//__________________________________________________________________________________
56AliCFTrackQualityCuts::AliCFTrackQualityCuts() :
57 AliCFCutBase(),
58 fMinNClusterTPC(0),
59 fMinNClusterITS(0),
60 fMaxChi2PerClusterTPC(0),
61 fMaxChi2PerClusterITS(0),
563113d0 62 fCovariance11Max(0),
63 fCovariance22Max(0),
64 fCovariance33Max(0),
65 fCovariance44Max(0),
66 fCovariance55Max(0),
8edd0c2c 67 fStatus(0),
563113d0 68 fhCutStatistics(0),
69 fhCutCorrelation(0),
70 fBitmap(0x0),
71 fhNBinsClusterTPC(0),
72 fhNBinsClusterITS(0),
73 fhNBinsChi2TPC(0),
74 fhNBinsChi2ITS(0),
563113d0 75 fhNBinsCovariance11(0),
76 fhNBinsCovariance22(0),
77 fhNBinsCovariance33(0),
78 fhNBinsCovariance44(0),
79 fhNBinsCovariance55(0),
80 fhBinLimClusterTPC(0x0),
81 fhBinLimClusterITS(0x0),
82 fhBinLimChi2TPC(0x0),
83 fhBinLimChi2ITS(0x0),
563113d0 84 fhBinLimCovariance11(0x0),
85 fhBinLimCovariance22(0x0),
86 fhBinLimCovariance33(0x0),
87 fhBinLimCovariance44(0x0),
88 fhBinLimCovariance55(0x0)
6cb5e116 89{
563113d0 90 //
91 // Default constructor
92 //
563113d0 93 Initialise();
94}
95//__________________________________________________________________________________
96AliCFTrackQualityCuts::AliCFTrackQualityCuts(Char_t* name, Char_t* title) :
97 AliCFCutBase(name,title),
98 fMinNClusterTPC(0),
99 fMinNClusterITS(0),
100 fMaxChi2PerClusterTPC(0),
101 fMaxChi2PerClusterITS(0),
563113d0 102 fCovariance11Max(0),
103 fCovariance22Max(0),
104 fCovariance33Max(0),
105 fCovariance44Max(0),
106 fCovariance55Max(0),
8edd0c2c 107 fStatus(0),
563113d0 108 fhCutStatistics(0),
109 fhCutCorrelation(0),
110 fBitmap(0x0),
111 fhNBinsClusterTPC(0),
112 fhNBinsClusterITS(0),
113 fhNBinsChi2TPC(0),
114 fhNBinsChi2ITS(0),
563113d0 115 fhNBinsCovariance11(0),
116 fhNBinsCovariance22(0),
117 fhNBinsCovariance33(0),
118 fhNBinsCovariance44(0),
119 fhNBinsCovariance55(0),
120 fhBinLimClusterTPC(0x0),
121 fhBinLimClusterITS(0x0),
122 fhBinLimChi2TPC(0x0),
123 fhBinLimChi2ITS(0x0),
563113d0 124 fhBinLimCovariance11(0x0),
125 fhBinLimCovariance22(0x0),
126 fhBinLimCovariance33(0x0),
127 fhBinLimCovariance44(0x0),
128 fhBinLimCovariance55(0x0)
563113d0 129{
130 //
131 // Constructor
132 //
563113d0 133 Initialise();
134}
135//__________________________________________________________________________________
136AliCFTrackQualityCuts::AliCFTrackQualityCuts(const AliCFTrackQualityCuts& c) :
137 AliCFCutBase(c),
138 fMinNClusterTPC(c.fMinNClusterTPC),
139 fMinNClusterITS(c.fMinNClusterITS),
140 fMaxChi2PerClusterTPC(c.fMaxChi2PerClusterTPC),
141 fMaxChi2PerClusterITS(c.fMaxChi2PerClusterITS),
563113d0 142 fCovariance11Max(c.fCovariance11Max),
143 fCovariance22Max(c.fCovariance22Max),
144 fCovariance33Max(c.fCovariance33Max),
145 fCovariance44Max(c.fCovariance44Max),
146 fCovariance55Max(c.fCovariance55Max),
8edd0c2c 147 fStatus(c.fStatus),
563113d0 148 fhCutStatistics(c.fhCutStatistics),
149 fhCutCorrelation(c.fhCutCorrelation),
150 fBitmap(c.fBitmap),
151 fhNBinsClusterTPC(c.fhNBinsClusterTPC),
152 fhNBinsClusterITS(c.fhNBinsClusterITS),
153 fhNBinsChi2TPC(c.fhNBinsChi2TPC),
154 fhNBinsChi2ITS(c.fhNBinsChi2ITS),
563113d0 155 fhNBinsCovariance11(c.fhNBinsCovariance11),
156 fhNBinsCovariance22(c.fhNBinsCovariance22),
157 fhNBinsCovariance33(c.fhNBinsCovariance33),
158 fhNBinsCovariance44(c.fhNBinsCovariance44),
159 fhNBinsCovariance55(c.fhNBinsCovariance55),
160 fhBinLimClusterTPC(c.fhBinLimClusterTPC),
161 fhBinLimClusterITS(c.fhBinLimClusterITS),
162 fhBinLimChi2TPC(c.fhBinLimChi2TPC),
163 fhBinLimChi2ITS(c.fhBinLimChi2ITS),
563113d0 164 fhBinLimCovariance11(c.fhBinLimCovariance11),
165 fhBinLimCovariance22(c.fhBinLimCovariance22),
166 fhBinLimCovariance33(c.fhBinLimCovariance33),
167 fhBinLimCovariance44(c.fhBinLimCovariance44),
168 fhBinLimCovariance55(c.fhBinLimCovariance55)
169{
170 //
171 // copy constructor
172 //
173 ((AliCFTrackQualityCuts &) c).Copy(*this);
174}
175//__________________________________________________________________________________
176AliCFTrackQualityCuts& AliCFTrackQualityCuts::operator=(const AliCFTrackQualityCuts& c)
177{
178 //
179 // Assignment operator
180 //
181 if (this != &c) {
182 AliCFCutBase::operator=(c) ;
183 fMinNClusterTPC = c.fMinNClusterTPC ;
184 fMinNClusterITS = c.fMinNClusterITS ;
185 fMaxChi2PerClusterTPC = c.fMaxChi2PerClusterTPC ;
186 fMaxChi2PerClusterITS = c.fMaxChi2PerClusterITS ;
563113d0 187 fCovariance11Max = c.fCovariance11Max ;
188 fCovariance22Max = c.fCovariance22Max ;
189 fCovariance33Max = c.fCovariance33Max ;
190 fCovariance44Max = c.fCovariance44Max ;
191 fCovariance55Max = c.fCovariance55Max ;
8edd0c2c 192 fStatus = c.fStatus ;
563113d0 193 fhCutStatistics = c.fhCutStatistics ;
194 fhCutCorrelation = c.fhCutCorrelation ;
195 fBitmap = c.fBitmap ;
563113d0 196 fhNBinsClusterTPC = c.fhNBinsClusterTPC ;
197 fhNBinsClusterITS = c.fhNBinsClusterITS ;
198 fhNBinsChi2TPC = c.fhNBinsChi2TPC ;
199 fhNBinsChi2ITS = c.fhNBinsChi2ITS ;
563113d0 200 fhNBinsCovariance11 = c.fhNBinsCovariance11 ;
201 fhNBinsCovariance22 = c.fhNBinsCovariance22 ;
202 fhNBinsCovariance33 = c.fhNBinsCovariance33 ;
203 fhNBinsCovariance44 = c.fhNBinsCovariance44 ;
204 fhNBinsCovariance55 = c.fhNBinsCovariance55 ;
205 fhBinLimClusterTPC = c.fhBinLimClusterTPC ;
206 fhBinLimClusterITS = c.fhBinLimClusterITS ;
207 fhBinLimChi2TPC = c.fhBinLimChi2TPC ;
208 fhBinLimChi2ITS = c.fhBinLimChi2ITS ;
563113d0 209 fhBinLimCovariance11 = c.fhBinLimCovariance11 ;
210 fhBinLimCovariance22 = c.fhBinLimCovariance22 ;
211 fhBinLimCovariance33 = c.fhBinLimCovariance33 ;
212 fhBinLimCovariance44 = c.fhBinLimCovariance44 ;
213 fhBinLimCovariance55 = c.fhBinLimCovariance55 ;
6cb5e116 214
563113d0 215 for (Int_t i=0; i<c.kNHist; i++){
216 for (Int_t j=0; j<c.kNStepQA; j++){
217 if(c.fhQA[i][j]) fhQA[i][j] = (TH1F*)c.fhQA[i][j]->Clone();
218 }
219 }
563113d0 220 ((AliCFTrackQualityCuts &) c).Copy(*this);
6cb5e116 221 }
563113d0 222 return *this;
223}
224//__________________________________________________________________________________
225AliCFTrackQualityCuts::~AliCFTrackQualityCuts()
226{
227 //
228 // destructor
229 //
8edd0c2c 230 if (fhCutStatistics) delete fhCutStatistics;
231 if (fhCutCorrelation) delete fhCutCorrelation;
563113d0 232
233 for (Int_t i=0; i<kNHist; i++){
234 for (Int_t j=0; j<kNStepQA; j++){
235 if(fhQA[i][j]) delete fhQA[i][j];
236 }
237 }
6cb5e116 238 if(fBitmap) delete fBitmap;
563113d0 239 if(fhBinLimClusterTPC) delete fhBinLimClusterTPC;
240 if(fhBinLimClusterITS) delete fhBinLimClusterITS;
241 if(fhBinLimChi2TPC) delete fhBinLimChi2TPC;
242 if(fhBinLimChi2ITS) delete fhBinLimChi2ITS;
563113d0 243 if(fhBinLimCovariance11) delete fhBinLimCovariance11;
244 if(fhBinLimCovariance22) delete fhBinLimCovariance22;
245 if(fhBinLimCovariance33) delete fhBinLimCovariance33;
246 if(fhBinLimCovariance44) delete fhBinLimCovariance44;
247 if(fhBinLimCovariance55) delete fhBinLimCovariance55;
563113d0 248}
249//__________________________________________________________________________________
250void AliCFTrackQualityCuts::Initialise()
251{
252 //
253 // sets everything to zero
254 //
255 fMinNClusterTPC = 0;
256 fMinNClusterITS = 0;
257 fMaxChi2PerClusterTPC = 0;
258 fMaxChi2PerClusterITS = 0;
563113d0 259 fCovariance11Max = 0;
260 fCovariance22Max = 0;
261 fCovariance33Max = 0;
262 fCovariance44Max = 0;
263 fCovariance55Max = 0;
8edd0c2c 264 fStatus = 0;
563113d0 265
266 SetMinNClusterTPC();
267 SetMinNClusterITS();
268 SetMaxChi2PerClusterTPC();
269 SetMaxChi2PerClusterITS();
563113d0 270 SetMaxCovDiagonalElements();
8edd0c2c 271 SetStatus();
563113d0 272
273 for (Int_t i=0; i<kNHist; i++){
6cb5e116 274 for (Int_t j=0; j<kNStepQA; j++)
563113d0 275 fhQA[i][j] = 0x0;
563113d0 276 }
277 fhCutStatistics = 0;
278 fhCutCorrelation = 0;
6cb5e116 279 fBitmap=new TBits(0);
563113d0 280
6cb5e116 281 //set default bining for QA histograms
563113d0 282 SetHistogramBins(kCutClusterTPC,165,-0.5,164.5);
283 SetHistogramBins(kCutClusterITS,8,-0.5,7.5);
6cb5e116 284 SetHistogramBins(kCutChi2TPC,500,0.,10.);
285 SetHistogramBins(kCutChi2ITS,500,0.,10.);
6cb5e116 286 SetHistogramBins(kCutCovElement11,200,0.,20.);
287 SetHistogramBins(kCutCovElement22,200,0.,20.);
288 SetHistogramBins(kCutCovElement33,100,0.,1.);
289 SetHistogramBins(kCutCovElement44,100,0.,5.);
290 SetHistogramBins(kCutCovElement55,100,0.,5.);
563113d0 291}
292//__________________________________________________________________________________
293void AliCFTrackQualityCuts::Copy(TObject &c) const
294{
295 //
296 // Copy function
297 //
298 AliCFTrackQualityCuts& target = (AliCFTrackQualityCuts &) c;
299
300 target.Initialise();
301
302 if (fhCutStatistics) target.fhCutStatistics = (TH1F*) fhCutStatistics->Clone();
303 if (fhCutCorrelation) target.fhCutCorrelation = (TH2F*) fhCutCorrelation->Clone();
304
305 for (Int_t i=0; i<kNHist; i++){
306 for (Int_t j=0; j<kNStepQA; j++){
307 if(fhQA[i][j]) target.fhQA[i][j] = (TH1F*)fhQA[i][j]->Clone();
308 }
309 }
563113d0 310 TNamed::Copy(c);
311}
312//__________________________________________________________________________________
107a3100 313void AliCFTrackQualityCuts::SelectionBitMap(TObject* obj)
563113d0 314{
315 //
316 // test if the track passes the single cuts
317 // and store the information in a bitmap
318 //
319
320 // bitmap stores the decision of each single cut
321 for(Int_t i=0; i<kNCuts; i++)fBitmap->SetBitNumber(i,kFALSE);
322
8edd0c2c 323 if (!obj) return;
324 if (!obj->InheritsFrom("AliVParticle")) {
325 AliError("object must derived from AliVParticle !");
326 return;
327 }
563113d0 328
8edd0c2c 329 Bool_t isESDTrack = strcmp(obj->ClassName(),"AliESDtrack") == 0 ? kTRUE : kFALSE ;
330 Bool_t isAODTrack = strcmp(obj->ClassName(),"AliAODTrack") == 0 ? kTRUE : kFALSE ;
563113d0 331
8edd0c2c 332 AliESDtrack * esdTrack = 0x0 ;
333 AliAODTrack * aodTrack = 0x0 ;
334 if (isESDTrack) esdTrack = dynamic_cast<AliESDtrack*>(obj);
335 if (isAODTrack) aodTrack = dynamic_cast<AliAODTrack*>(obj);
563113d0 336
8edd0c2c 337 // get cut quantities
338 Int_t fIdxInt[200];
339 Int_t nClustersTPC = 0;
340 Int_t nClustersITS = 0 ;
341 Float_t chi2PerClusterTPC = 0 ;
342 Float_t chi2PerClusterITS = 0 ;
343 Double_t extCov[15]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
344
345 if (isESDTrack) {
346 nClustersTPC = esdTrack->GetTPCclusters(fIdxInt);
347 nClustersITS = esdTrack->GetITSclusters(fIdxInt);
348 if (nClustersTPC != 0) chi2PerClusterTPC = esdTrack->GetTPCchi2() / Float_t(nClustersTPC);
349 if (nClustersITS != 0) chi2PerClusterITS = esdTrack->GetITSchi2() / Float_t(nClustersITS);
350 esdTrack->GetExternalCovariance(extCov);
351 }
563113d0 352
563113d0 353 // fill the bitmap
354 Int_t iCutBit = 0;
355
107a3100 356 if (nClustersTPC >= fMinNClusterTPC)
8edd0c2c 357 fBitmap->SetBitNumber(iCutBit,kTRUE);
563113d0 358 iCutBit++;
107a3100 359 if (nClustersITS >= fMinNClusterITS)
8edd0c2c 360 fBitmap->SetBitNumber(iCutBit,kTRUE);
563113d0 361 iCutBit++;
107a3100 362 if (chi2PerClusterTPC <= fMaxChi2PerClusterTPC)
8edd0c2c 363 fBitmap->SetBitNumber(iCutBit,kTRUE);
563113d0 364 iCutBit++;
107a3100 365 if (chi2PerClusterITS <= fMaxChi2PerClusterITS)
8edd0c2c 366 fBitmap->SetBitNumber(iCutBit,kTRUE);
563113d0 367 iCutBit++;
107a3100 368 if (extCov[0] <= fCovariance11Max)
8edd0c2c 369 fBitmap->SetBitNumber(iCutBit,kTRUE);
563113d0 370 iCutBit++;
107a3100 371 if (extCov[2] <= fCovariance22Max)
8edd0c2c 372 fBitmap->SetBitNumber(iCutBit,kTRUE);
563113d0 373 iCutBit++;
107a3100 374 if (extCov[5] <= fCovariance33Max)
8edd0c2c 375 fBitmap->SetBitNumber(iCutBit,kTRUE);
563113d0 376 iCutBit++;
107a3100 377 if (extCov[9] <= fCovariance44Max)
8edd0c2c 378 fBitmap->SetBitNumber(iCutBit,kTRUE);
563113d0 379 iCutBit++;
107a3100 380 if (extCov[14] <= fCovariance55Max)
8edd0c2c 381 fBitmap->SetBitNumber(iCutBit,kTRUE);
382 iCutBit++;
383
384 if (isESDTrack) {
385 if ( (esdTrack->GetStatus() & fStatus) == fStatus ) fBitmap->SetBitNumber(iCutBit,kTRUE);
386 }
387 else {
388 if ( (aodTrack->GetStatus() & fStatus) == fStatus ) fBitmap->SetBitNumber(iCutBit,kTRUE);
389 }
563113d0 390
107a3100 391 return;
563113d0 392}
393//__________________________________________________________________________________
394Bool_t AliCFTrackQualityCuts::IsSelected(TObject* obj) {
395 //
396 // loops over decisions of single cuts and returns if the track is accepted
397 //
107a3100 398 SelectionBitMap(obj);
563113d0 399
107a3100 400 if (fIsQAOn) FillHistograms(obj,0);
563113d0 401 Bool_t isSelected = kTRUE;
402
107a3100 403 for (UInt_t icut=0; icut<fBitmap->GetNbits();icut++) {
404 if(!fBitmap->TestBitNumber(icut)) {
405 isSelected = kFALSE;
406 break;
407 }
408 }
409 if (!isSelected) return kFALSE ;
410 if (fIsQAOn) FillHistograms(obj,1);
411 return kTRUE;
563113d0 412}
413//__________________________________________________________________________________
414void AliCFTrackQualityCuts::SetHistogramBins(Int_t index, Int_t nbins, Double_t *bins)
415{
416 //
417 // variable bin size
418 //
419 if(!fIsQAOn) return;
420
8edd0c2c 421 if (index<0 || index>=kNHist) {
422 Error("SetHistogramBins","could not determine histogram from index %d",index);
423 return;
424 }
425
563113d0 426 switch(index){
427 case kCutClusterTPC:
db6722a5 428 fhNBinsClusterTPC=nbins+1;
563113d0 429 fhBinLimClusterTPC=new Double_t[nbins+1];
430 for(Int_t i=0;i<nbins+1;i++)fhBinLimClusterTPC[i]=bins[i];
431 break;
6cb5e116 432
563113d0 433 case kCutClusterITS:
db6722a5 434 fhNBinsClusterITS=nbins+1;
563113d0 435 fhBinLimClusterITS=new Double_t[nbins+1];
436 for(Int_t i=0;i<nbins+1;i++)fhBinLimClusterITS[i]=bins[i];
437 break;
6cb5e116 438
563113d0 439 case kCutChi2TPC:
db6722a5 440 fhNBinsChi2TPC=nbins+1;
563113d0 441 fhBinLimChi2TPC=new Double_t[nbins+1];
442 for(Int_t i=0;i<nbins+1;i++)fhBinLimChi2TPC[i]=bins[i];
443 break;
6cb5e116 444
563113d0 445 case kCutChi2ITS:
db6722a5 446 fhNBinsChi2ITS=nbins+1;
563113d0 447 fhBinLimChi2ITS=new Double_t[nbins+1];
448 for(Int_t i=0;i<nbins+1;i++)fhBinLimChi2ITS[i]=bins[i];
449 break;
6cb5e116 450
563113d0 451 case kCutCovElement11:
db6722a5 452 fhNBinsCovariance11=nbins+1;
563113d0 453 fhBinLimCovariance11=new Double_t[nbins+1];
454 for(Int_t i=0;i<nbins+1;i++)fhBinLimCovariance11[i]=bins[i];
455 break;
6cb5e116 456
563113d0 457 case kCutCovElement22:
db6722a5 458 fhNBinsCovariance22=nbins+1;
563113d0 459 fhBinLimCovariance22=new Double_t[nbins+1];
460 for(Int_t i=0;i<nbins+1;i++)fhBinLimCovariance22[i]=bins[i];
461 break;
6cb5e116 462
563113d0 463 case kCutCovElement33:
db6722a5 464 fhNBinsCovariance33=nbins+1;
563113d0 465 fhBinLimCovariance33=new Double_t[nbins+1];
466 for(Int_t i=0;i<nbins+1;i++)fhBinLimCovariance33[i]=bins[i];
467 break;
6cb5e116 468
563113d0 469 case kCutCovElement44:
db6722a5 470 fhNBinsCovariance44=nbins+1;
563113d0 471 fhBinLimCovariance44=new Double_t[nbins+1];
472 for(Int_t i=0;i<nbins+1;i++)fhBinLimCovariance44[i]=bins[i];
473 break;
6cb5e116 474
563113d0 475 case kCutCovElement55:
db6722a5 476 fhNBinsCovariance55=nbins+1;
563113d0 477 fhBinLimCovariance55=new Double_t[nbins+1];
478 for(Int_t i=0;i<nbins+1;i++)fhBinLimCovariance55[i]=bins[i];
479 break;
480 }
481}
482//__________________________________________________________________________________
483void AliCFTrackQualityCuts::SetHistogramBins(Int_t index, Int_t nbins, Double_t xmin, Double_t xmax)
484{
485 //
486 // fixed bin size
487 //
8edd0c2c 488 if (index<0 || index>=kNHist) {
489 Error("SetHistogramBins","could not determine histogram from index %d",index);
490 return;
491 }
492
563113d0 493 switch(index){
494 case kCutClusterTPC:
db6722a5 495 fhNBinsClusterTPC=nbins+1;
563113d0 496 fhBinLimClusterTPC=new Double_t[nbins+1];
497 for(Int_t i=0;i<nbins+1;i++)fhBinLimClusterTPC[i]=xmin+i*(xmax-xmin)/Double_t(nbins);
498 break;
6cb5e116 499
563113d0 500 case kCutClusterITS:
db6722a5 501 fhNBinsClusterITS=nbins+1;
563113d0 502 fhBinLimClusterITS=new Double_t[nbins+1];
503 for(Int_t i=0;i<nbins+1;i++)fhBinLimClusterITS[i]=xmin+i*(xmax-xmin)/Double_t(nbins);
504 break;
6cb5e116 505
563113d0 506 case kCutChi2TPC:
db6722a5 507 fhNBinsChi2TPC=nbins+1;
563113d0 508 fhBinLimChi2TPC=new Double_t[nbins+1];
509 for(Int_t i=0;i<nbins+1;i++)fhBinLimChi2TPC[i]=xmin+i*(xmax-xmin)/Double_t(nbins);
510 break;
6cb5e116 511
563113d0 512 case kCutChi2ITS:
db6722a5 513 fhNBinsChi2ITS=nbins+1;
563113d0 514 fhBinLimChi2ITS=new Double_t[nbins+1];
515 for(Int_t i=0;i<nbins+1;i++)fhBinLimChi2ITS[i]=xmin+i*(xmax-xmin)/Double_t(nbins);
516 break;
6cb5e116 517
563113d0 518 case kCutCovElement11:
db6722a5 519 fhNBinsCovariance11=nbins+1;
563113d0 520 fhBinLimCovariance11=new Double_t[nbins+1];
521 for(Int_t i=0;i<nbins+1;i++)fhBinLimCovariance11[i]=xmin+i*(xmax-xmin)/Double_t(nbins);
522 break;
6cb5e116 523
563113d0 524 case kCutCovElement22:
db6722a5 525 fhNBinsCovariance22=nbins+1;
563113d0 526 fhBinLimCovariance22=new Double_t[nbins+1];
527 for(Int_t i=0;i<nbins+1;i++)fhBinLimCovariance22[i]=xmin+i*(xmax-xmin)/Double_t(nbins);
528 break;
6cb5e116 529
563113d0 530 case kCutCovElement33:
db6722a5 531 fhNBinsCovariance33=nbins+1;
563113d0 532 fhBinLimCovariance33=new Double_t[nbins+1];
533 for(Int_t i=0;i<nbins+1;i++)fhBinLimCovariance33[i]=xmin+i*(xmax-xmin)/Double_t(nbins);
534 break;
6cb5e116 535
563113d0 536 case kCutCovElement44:
db6722a5 537 fhNBinsCovariance44=nbins+1;
563113d0 538 fhBinLimCovariance44=new Double_t[nbins+1];
539 for(Int_t i=0;i<nbins+1;i++)fhBinLimCovariance44[i]=xmin+i*(xmax-xmin)/Double_t(nbins);
540 break;
6cb5e116 541
563113d0 542 case kCutCovElement55:
db6722a5 543 fhNBinsCovariance55=nbins+1;
563113d0 544 fhBinLimCovariance55=new Double_t[nbins+1];
545 for(Int_t i=0;i<nbins+1;i++)fhBinLimCovariance55[i]=xmin+i*(xmax-xmin)/Double_t(nbins);
546 break;
547 }
548}
549//__________________________________________________________________________________
550 void AliCFTrackQualityCuts::DefineHistograms() {
551 //
552 // histograms for cut variables, cut statistics and cut correlations
553 //
563113d0 554 Int_t color = 2;
555
556 // book cut statistics and cut correlation histograms
557 fhCutStatistics = new TH1F(Form("%s_cut_statistics",GetName()), Form("%s cut statistics",GetName()), kNCuts,0.5,kNCuts+0.5);
558 fhCutStatistics->SetLineWidth(2);
559 fhCutStatistics->GetXaxis()->SetBinLabel(1,"nClustersTPC");
560 fhCutStatistics->GetXaxis()->SetBinLabel(2,"nClustersITS");
561 fhCutStatistics->GetXaxis()->SetBinLabel(3,"chi2PerClusterTPC");
562 fhCutStatistics->GetXaxis()->SetBinLabel(4,"chi2PerClusterITS");
8edd0c2c 563 fhCutStatistics->GetXaxis()->SetBinLabel(5,"covElement11");
564 fhCutStatistics->GetXaxis()->SetBinLabel(6,"covElement22");
565 fhCutStatistics->GetXaxis()->SetBinLabel(7,"covElement33");
566 fhCutStatistics->GetXaxis()->SetBinLabel(8,"covElement44");
567 fhCutStatistics->GetXaxis()->SetBinLabel(9,"covElement55");
563113d0 568
569 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);
570 fhCutCorrelation->SetLineWidth(2);
571 fhCutCorrelation->GetXaxis()->SetBinLabel(1,"nClustersTPC");
572 fhCutCorrelation->GetXaxis()->SetBinLabel(2,"nClustersITS");
573 fhCutCorrelation->GetXaxis()->SetBinLabel(3,"chi2PerClusterTPC");
574 fhCutCorrelation->GetXaxis()->SetBinLabel(4,"chi2PerClusterITS");
8edd0c2c 575 fhCutCorrelation->GetXaxis()->SetBinLabel(5,"covElement11");
576 fhCutCorrelation->GetXaxis()->SetBinLabel(6,"covElement22");
577 fhCutCorrelation->GetXaxis()->SetBinLabel(7,"covElement33");
578 fhCutCorrelation->GetXaxis()->SetBinLabel(8,"covElement44");
579 fhCutCorrelation->GetXaxis()->SetBinLabel(9,"covElement55");
563113d0 580
581 fhCutCorrelation->GetYaxis()->SetBinLabel(1,"nClustersTPC");
582 fhCutCorrelation->GetYaxis()->SetBinLabel(2,"nClustersITS");
583 fhCutCorrelation->GetYaxis()->SetBinLabel(3,"chi2PerClusterTPC");
584 fhCutCorrelation->GetYaxis()->SetBinLabel(4,"chi2PerClusterITS");
8edd0c2c 585 fhCutCorrelation->GetYaxis()->SetBinLabel(5,"covElement11");
586 fhCutCorrelation->GetYaxis()->SetBinLabel(6,"covElement22");
587 fhCutCorrelation->GetYaxis()->SetBinLabel(7,"covElement33");
588 fhCutCorrelation->GetYaxis()->SetBinLabel(8,"covElement44");
589 fhCutCorrelation->GetYaxis()->SetBinLabel(9,"covElement55");
563113d0 590
591
592 // book QA histograms
593 Char_t str[256];
594 for (Int_t i=0; i<kNStepQA; i++) {
595 if (i==0) sprintf(str," ");
596 else sprintf(str,"_cut");
6cb5e116 597
db6722a5 598 fhQA[kCutClusterTPC][i] = new TH1F(Form("%s_nClustersTPC%s",GetName(),str) ,"",fhNBinsClusterTPC-1,fhBinLimClusterTPC);
599 fhQA[kCutClusterITS][i] = new TH1F(Form("%s_nClustersITS%s",GetName(),str) ,"",fhNBinsClusterITS-1,fhBinLimClusterITS);
600 fhQA[kCutChi2TPC][i] = new TH1F(Form("%s_chi2PerClusterTPC%s",GetName(),str),"",fhNBinsChi2TPC-1,fhBinLimChi2TPC);
601 fhQA[kCutChi2ITS][i] = new TH1F(Form("%s_chi2PerClusterITS%s",GetName(),str),"",fhNBinsChi2ITS-1,fhBinLimChi2ITS);
db6722a5 602 fhQA[kCutCovElement11][i] = new TH1F(Form("%s_covMatrixDiagonal11%s",GetName(),str),"",fhNBinsCovariance11-1,fhBinLimCovariance11);
603 fhQA[kCutCovElement22][i] = new TH1F(Form("%s_covMatrixDiagonal22%s",GetName(),str),"",fhNBinsCovariance22-1,fhBinLimCovariance22);
604 fhQA[kCutCovElement33][i] = new TH1F(Form("%s_covMatrixDiagonal33%s",GetName(),str),"",fhNBinsCovariance33-1,fhBinLimCovariance33);
605 fhQA[kCutCovElement44][i] = new TH1F(Form("%s_covMatrixDiagonal44%s",GetName(),str),"",fhNBinsCovariance44-1,fhBinLimCovariance44);
606 fhQA[kCutCovElement55][i] = new TH1F(Form("%s_covMatrixDiagonal55%s",GetName(),str),"",fhNBinsCovariance55-1,fhBinLimCovariance55);
563113d0 607
608 fhQA[kCutClusterTPC][i] ->SetXTitle("n TPC clusters");
609 fhQA[kCutClusterITS][i] ->SetXTitle("n ITS clusters");
610 fhQA[kCutChi2TPC][i] ->SetXTitle("#chi^{2} per TPC cluster");
611 fhQA[kCutChi2ITS][i] ->SetXTitle("#chi^{2} per ITS cluster");
563113d0 612 fhQA[kCutCovElement11][i] ->SetXTitle("cov 11 : #sigma_{y}^{2} (cm^{2})");
613 fhQA[kCutCovElement22][i] ->SetXTitle("cov 22 : #sigma_{z}^{2} (cm^{2})");
614 fhQA[kCutCovElement33][i] ->SetXTitle("cov 33 : #sigma_{sin(#phi)}^{2}");
615 fhQA[kCutCovElement44][i] ->SetXTitle("cov 44 : #sigma_{tan(#theta_{dip})}^{2}");
6cb5e116 616 fhQA[kCutCovElement55][i] ->SetXTitle("cov 55 : #sigma_{1/p_{T}}^{2} ((c/GeV)^{2})");
563113d0 617 }
618
619 for(Int_t i=0; i<kNHist; i++) fhQA[i][1]->SetLineColor(color);
563113d0 620}
621//__________________________________________________________________________________
622void AliCFTrackQualityCuts::FillHistograms(TObject* obj, Bool_t b)
623{
624 //
625 // fill the QA histograms
626 //
563113d0 627
107a3100 628 if (!obj) return;
8edd0c2c 629 if (!obj->InheritsFrom("AliVParticle")) {
630 AliError("object must derived from AliVParticle !");
631 return;
632 }
633
634 Bool_t isESDTrack = strcmp(obj->ClassName(),"AliESDtrack") == 0 ? kTRUE : kFALSE ;
635 Bool_t isAODTrack = strcmp(obj->ClassName(),"AliAODTrack") == 0 ? kTRUE : kFALSE ;
636
637 AliESDtrack * esdTrack = 0x0 ;
638 AliAODTrack * aodTrack = 0x0 ;
639 if (isESDTrack) esdTrack = dynamic_cast<AliESDtrack*>(obj);
640 if (isAODTrack) aodTrack = dynamic_cast<AliAODTrack*>(obj);
563113d0 641
107a3100 642 // b = 0: fill histograms before cuts
643 // b = 1: fill histograms after cuts
563113d0 644
8edd0c2c 645 Int_t fIdxInt[200];
646 Int_t nClustersTPC = 0;
647 Int_t nClustersITS = 0 ;
648 Float_t chi2PerClusterTPC = 0 ;
649 Float_t chi2PerClusterITS = 0 ;
650 Double_t extCov[15]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
651
652 if (isESDTrack) {
653 nClustersTPC = esdTrack->GetTPCclusters(fIdxInt);
654 nClustersITS = esdTrack->GetITSclusters(fIdxInt);
655 if (nClustersTPC != 0) chi2PerClusterTPC = esdTrack->GetTPCchi2() / Float_t(nClustersTPC);
656 if (nClustersITS!=0) chi2PerClusterITS = esdTrack->GetITSchi2() / Float_t(nClustersITS);
657 esdTrack->GetExternalCovariance(extCov);
658 }
107a3100 659 fhQA[kCutClusterTPC][b]->Fill((float)nClustersTPC);
107a3100 660 fhQA[kCutChi2TPC][b]->Fill(chi2PerClusterTPC);
107a3100 661 fhQA[kCutClusterITS][b]->Fill((float)nClustersITS);
107a3100 662 fhQA[kCutChi2ITS][b]->Fill(chi2PerClusterITS);
107a3100 663 fhQA[kCutCovElement11][b]->Fill(extCov[0]);
664 fhQA[kCutCovElement22][b]->Fill(extCov[2]);
665 fhQA[kCutCovElement33][b]->Fill(extCov[5]);
666 fhQA[kCutCovElement44][b]->Fill(extCov[9]);
667 fhQA[kCutCovElement55][b]->Fill(extCov[14]);
6cb5e116 668
563113d0 669 // fill cut statistics and cut correlation histograms with information from the bitmap
670 if (b) return;
671
672 // Get the bitmap of the single cuts
673 if ( !obj ) return;
107a3100 674 SelectionBitMap(obj);
563113d0 675
676 // Number of single cuts in this class
107a3100 677 UInt_t ncuts = fBitmap->GetNbits();
563113d0 678 for(UInt_t bit=0; bit<ncuts;bit++) {
107a3100 679 if (!fBitmap->TestBitNumber(bit)) {
563113d0 680 fhCutStatistics->Fill(bit+1);
681 for (UInt_t bit2=bit; bit2<ncuts;bit2++) {
107a3100 682 if (!fBitmap->TestBitNumber(bit2))
563113d0 683 fhCutCorrelation->Fill(bit+1,bit2+1);
684 }
685 }
686 }
687}
688//__________________________________________________________________________________
689void AliCFTrackQualityCuts::SaveHistograms(const Char_t* dir) {
690 //
691 // saves the histograms in a directory (dir)
692 //
693 if(!fIsQAOn) return;
694
695 if (!dir)
696 dir = GetName();
697
698 gDirectory->mkdir(dir);
699 gDirectory->cd(dir);
700
701 gDirectory->mkdir("before_cuts");
702 gDirectory->mkdir("after_cuts");
703
704 fhCutStatistics->Write();
705 fhCutCorrelation->Write();
706
707 for (Int_t j=0; j<kNStepQA; j++) {
708 if (j==0)
709 gDirectory->cd("before_cuts");
710 else
711 gDirectory->cd("after_cuts");
712
713 for(Int_t i=0; i<kNHist; i++) fhQA[i][j]->Write();
714
715 gDirectory->cd("../");
716 }
717 gDirectory->cd("../");
718}
719//__________________________________________________________________________________
720void AliCFTrackQualityCuts::DrawHistograms(Bool_t drawLogScale)
721{
722 //
723 // draws some histograms
724 //
725 if(!fIsQAOn) return;
726
727 // pad margins
728 Float_t right = 0.03;
729 Float_t left = 0.175;
730 Float_t top = 0.03;
731 Float_t bottom = 0.175;
732
733 TCanvas* canvas1 = new TCanvas("Track_QA_Quality_1", "Track QA Quality 1", 800, 500);
734 canvas1->Divide(2, 1);
735
736 canvas1->cd(1);
737 fhCutStatistics->SetStats(kFALSE);
738 fhCutStatistics->LabelsOption("v");
739 gPad->SetLeftMargin(left);
740 gPad->SetBottomMargin(0.25);
741 gPad->SetRightMargin(right);
742 gPad->SetTopMargin(0.1);
743 fhCutStatistics->Draw();
744
745 canvas1->cd(2);
746 fhCutCorrelation->SetStats(kFALSE);
747 fhCutCorrelation->LabelsOption("v");
748 gPad->SetLeftMargin(0.30);
749 gPad->SetRightMargin(bottom);
750 gPad->SetTopMargin(0.1);
751 gPad->SetBottomMargin(0.25);
752 fhCutCorrelation->Draw("COLZ");
753
754 canvas1->SaveAs(Form("%s.eps", canvas1->GetName()));
755 canvas1->SaveAs(Form("%s.ps", canvas1->GetName()));
756
757 // -----
758
759 TCanvas* canvas2 = new TCanvas("Track_QA_Quality_2", "Track QA Quality 2", 1200, 800);
8edd0c2c 760 canvas2->Divide(2, 2);
563113d0 761
762 canvas2->cd(1);
763 gPad->SetRightMargin(right);
764 gPad->SetLeftMargin(left);
765 gPad->SetTopMargin(top);
766 gPad->SetBottomMargin(bottom);
767 fhQA[kCutClusterTPC][0]->SetStats(kFALSE);
768 fhQA[kCutClusterTPC][0]->Draw();
769 fhQA[kCutClusterTPC][1]->Draw("same");
770
771 canvas2->cd(2);
772 gPad->SetRightMargin(right);
773 gPad->SetLeftMargin(left);
774 gPad->SetTopMargin(top);
775 gPad->SetBottomMargin(bottom);
776 fhQA[kCutChi2TPC][0]->SetStats(kFALSE);
777 fhQA[kCutChi2TPC][0]->Draw();
778 fhQA[kCutChi2TPC][1]->Draw("same");
779
780 canvas2->cd(3);
781 gPad->SetRightMargin(right);
782 gPad->SetLeftMargin(left);
783 gPad->SetTopMargin(top);
784 gPad->SetBottomMargin(bottom);
563113d0 785 fhQA[kCutClusterITS][0]->SetStats(kFALSE);
786 fhQA[kCutClusterITS][0]->Draw();
787 fhQA[kCutClusterITS][1]->Draw("same");
788
8edd0c2c 789 canvas2->cd(4);
563113d0 790 gPad->SetRightMargin(right);
791 gPad->SetLeftMargin(left);
792 gPad->SetTopMargin(top);
793 gPad->SetBottomMargin(bottom);
794 fhQA[kCutChi2ITS][0]->SetStats(kFALSE);
795 fhQA[kCutChi2ITS][0]->Draw();
796 fhQA[kCutChi2ITS][1]->Draw("same");
797
563113d0 798 canvas2->SaveAs(Form("%s.eps", canvas2->GetName()));
799 canvas2->SaveAs(Form("%s.ps", canvas2->GetName()));
800
801 // -----
802
803 TCanvas* canvas3 = new TCanvas("Track_QA_Quality_3", "Track QA Quality 3", 1200, 800);
804 canvas3->Divide(3, 2);
805
806 canvas3->cd(1);
807 if(drawLogScale) gPad->SetLogy();
808 gPad->SetRightMargin(right);
809 gPad->SetLeftMargin(left);
810 gPad->SetTopMargin(top);
811 gPad->SetBottomMargin(bottom);
812 fhQA[kCutCovElement11][0]->SetStats(kFALSE);
813 fhQA[kCutCovElement11][0]->Draw();
814 fhQA[kCutCovElement11][1]->Draw("same");
815
816 canvas3->cd(2);
817 if(drawLogScale) gPad->SetLogy();
818 gPad->SetRightMargin(right);
819 gPad->SetLeftMargin(left);
820 gPad->SetTopMargin(top);
821 gPad->SetBottomMargin(bottom);
822 fhQA[kCutCovElement22][0]->SetStats(kFALSE);
823 fhQA[kCutCovElement22][0]->Draw();
824 fhQA[kCutCovElement22][1]->Draw("same");
825
826 canvas3->cd(3);
827 if(drawLogScale) gPad->SetLogy();
828 gPad->SetRightMargin(right);
829 gPad->SetLeftMargin(left);
830 gPad->SetTopMargin(top);
831 gPad->SetBottomMargin(bottom);
832 fhQA[kCutCovElement33][0]->SetStats(kFALSE);
833 fhQA[kCutCovElement33][0]->Draw();
834 fhQA[kCutCovElement33][1]->Draw("same");
835
836 canvas3->cd(4);
837 if(drawLogScale) gPad->SetLogy();
838 gPad->SetRightMargin(right);
839 gPad->SetLeftMargin(left);
840 gPad->SetTopMargin(top);
841 gPad->SetBottomMargin(bottom);
842 fhQA[kCutCovElement44][0]->SetStats(kFALSE);
843 fhQA[kCutCovElement44][0]->Draw();
844 fhQA[kCutCovElement44][1]->Draw("same");
845
846 canvas3->cd(5);
847 if(drawLogScale) gPad->SetLogy();
848 gPad->SetRightMargin(right);
849 gPad->SetLeftMargin(left);
850 gPad->SetTopMargin(top);
851 gPad->SetBottomMargin(bottom);
852 fhQA[kCutCovElement55][0]->SetStats(kFALSE);
853 fhQA[kCutCovElement55][0]->Draw();
854 fhQA[kCutCovElement55][1]->Draw("same");
855
856 canvas3->SaveAs(Form("%s.eps", canvas3->GetName()));
857 canvas3->SaveAs(Form("%s.ps", canvas3->GetName()));
858}
859//__________________________________________________________________________________
107a3100 860void AliCFTrackQualityCuts::AddQAHistograms(TList *qaList) {
563113d0 861 //
862 // saves the histograms in a TList
863 //
107a3100 864 DefineHistograms();
563113d0 865
866 qaList->Add(fhCutStatistics);
867 qaList->Add(fhCutCorrelation);
868
869 for (Int_t j=0; j<kNStepQA; j++) {
870 for(Int_t i=0; i<kNHist; i++)
871 qaList->Add(fhQA[i][j]);
872 }
873}