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