]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGHF/hfe/AliHFEtrdPIDqaV1.cxx
:x
[u/mrichter/AliRoot.git] / PWGHF / hfe / AliHFEtrdPIDqaV1.cxx
CommitLineData
3a72645a 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// Class AliHFEtrdPIDqaV1
17// Monitoring TRD PID in the HFE PID montioring framework. The following
18// quantities are monitored:
19// TRD electron likelihood
20// TRD dE/dx (Absolute values)
21// TPC dE/dx (Number of sigmas, control histogram)
22// (Always as function of momentum, particle species and centrality
23// before and after cut)
24// More information about the PID monitoring framework can be found in
25// AliHFEpidQAmanager.cxx and AliHFEdetPIDqa.cxx
26//
27// Author:
28// Markus Fasel <M.Fasel@gsi.de>
29//
30
31#include <TAxis.h>
e3ae862b 32#include <TBrowser.h>
3a72645a 33#include <TH2.h>
34#include <THnSparse.h>
35#include <TString.h>
36
e3ae862b 37#include "AliESDtrack.h"
6555e2ad 38#include "AliLog.h"
3a72645a 39#include "AliPID.h"
8c1c76e9 40#include "AliPIDResponse.h"
3a72645a 41
42#include "AliHFEcollection.h"
43#include "AliHFEpidBase.h"
6555e2ad 44#include "AliHFEpidQAmanager.h"
45#include "AliHFEpidTPC.h"
46#include "AliHFEpidTRD.h"
3a72645a 47#include "AliHFEtrdPIDqaV1.h"
48
49ClassImp(AliHFEtrdPIDqaV1)
50
51//____________________________________________________________
52AliHFEtrdPIDqaV1::AliHFEtrdPIDqaV1():
53 AliHFEdetPIDqa(),
54 fHistos(NULL)
55{
56 //
57 // Dummy constructor
58 //
59}
60
61//____________________________________________________________
62AliHFEtrdPIDqaV1::AliHFEtrdPIDqaV1(const Char_t *name):
63 AliHFEdetPIDqa(name, "QA for TRD"),
64 fHistos(NULL)
65{
66 //
67 // Default constructor
68 //
69}
70
71//____________________________________________________________
72AliHFEtrdPIDqaV1::AliHFEtrdPIDqaV1(const AliHFEtrdPIDqaV1 &o):
73 AliHFEdetPIDqa(o),
74 fHistos(NULL)
75{
76 //
77 // Copy constructor
78 //
79}
80
81//____________________________________________________________
82AliHFEtrdPIDqaV1 &AliHFEtrdPIDqaV1::operator=(const AliHFEtrdPIDqaV1 &o){
83 //
84 // Make assignment
85 //
aa1417ee 86 if(this == &o) return *this;
3a72645a 87 AliHFEdetPIDqa::operator=(o);
88 fHistos = o.fHistos;
89
90 return *this;
91}
92
93//_________________________________________________________
94Long64_t AliHFEtrdPIDqaV1::Merge(TCollection *coll){
95 //
96 // Merge with other objects
97 //
98 if(!coll) return 0;
99 if(coll->IsEmpty()) return 1;
100
101 TIter it(coll);
102 AliHFEtrdPIDqaV1 *refQA = NULL;
103 TObject *o = NULL;
104 Long64_t count = 0;
105 TList listHistos;
106 while((o = it())){
107 refQA = dynamic_cast<AliHFEtrdPIDqaV1 *>(o);
108 if(!refQA) continue;
109
110 listHistos.Add(refQA->fHistos);
111 count++;
112 }
113 fHistos->Merge(&listHistos);
114 return count + 1;
115}
116
e3ae862b 117//_________________________________________________________
118void AliHFEtrdPIDqaV1::Browse(TBrowser *b){
119 //
120 // Browse the PID QA
121 //
122 if(b){
123 if(fHistos){
124 b->Add(fHistos, fHistos->GetName());
125
126 // Make Projections of the dE/dx Spectra and add them to a new Folder
127 TString specnames[4] = {"All", "Electrons", "Pions", "Protons"};
128 Int_t specind[4] = {-1, AliPID::kElectron, AliPID::kPion, AliPID::kProton};
129 TList *listTM = new TList;
130 listTM->SetOwner();
131 TList *listLike = new TList;
132 listLike->SetOwner();
133 TList *listCharge = new TList;
134 listCharge->SetOwner();
135 TList *listTPCnsigma = new TList;
136 listTPCnsigma->SetOwner();
137
138 TH2 *hptr = NULL;
e156c3bb 139 TList *lctm, *lclike, *lccharge, *lcTPCsig;
140 for(Int_t icent = -1; icent < 11; icent++){
141 lctm = new TList;
142 lctm->SetName(icent < 0 ? "MinBias" : Form("Centrality%d", icent));
143 lctm->SetOwner();
144 listTM->Add(lctm);
145 lclike = new TList;
146 lclike->SetName(icent < 0 ? "MinBias" : Form("Centrality%d", icent));
147 lclike->SetOwner();
148 listLike->Add(lclike);
149 lccharge = new TList;
150 lccharge->SetName(icent < 0 ? "MinBias" : Form("Centrality%d", icent));
151 lccharge->SetOwner();
152 listCharge->Add(lccharge);
153 lcTPCsig = new TList;
154 lcTPCsig->SetName(icent < 0 ? "MinBias" : Form("Centrality%d", icent));
155 lcTPCsig->SetOwner();
156 listTPCnsigma->Add(lcTPCsig);
157 for(Int_t ispec = 0; ispec < 4; ispec++){
158 for(Int_t istep = 0; istep < 2; istep++){
159 hptr = MakeTRDspectrumTM(static_cast<AliHFEdetPIDqa::EStep_t>(istep), specind[ispec], icent);
160 if(hptr){
161 hptr->SetName(Form("hTRDtm%s%s", specnames[ispec].Data(), istep == 0 ? "Before" : "After"));
162 lctm->Add(hptr);
163 }
164 hptr = MakeTRDlikelihoodDistribution(static_cast<AliHFEdetPIDqa::EStep_t>(istep), specind[ispec], icent);
165 hptr->SetName(Form("hTRDlike%s%s", specnames[ispec].Data(), istep == 0 ? "Before" : "After"));
166 lclike->Add(hptr);
167 hptr = MakeTRDchargeDistribution(static_cast<AliHFEdetPIDqa::EStep_t>(istep), specind[ispec], icent);
168 hptr->SetName(Form("hTRDcharge%s%s", specnames[ispec].Data(), istep == 0 ? "Before" : "After"));
169 lccharge->Add(hptr);
170 hptr = MakeTPCspectrumNsigma(static_cast<AliHFEdetPIDqa::EStep_t>(istep), specind[ispec], icent);
171 hptr->SetName(Form("hTPCspectrum%s%s", specnames[ispec].Data(), istep == 0 ? "Before" : "After"));
172 lcTPCsig->Add(hptr);
ccc37cdc 173 }
e3ae862b 174 }
175 }
e156c3bb 176
e3ae862b 177 b->Add(listTM, "Projections Truncated Mean");
178 b->Add(listLike, "Projections Likelihood distribution");
179 b->Add(listCharge, "Projections Tracklet Charge");
180 b->Add(listTPCnsigma, "Projections TPC spectra");
181 }
182 }
183}
184
3a72645a 185//____________________________________________________________
186void AliHFEtrdPIDqaV1::Initialize(){
187 //
188 // Initialize QA histos for TRD PID
189 //
190
191 AliDebug(1, "Initializing PID QA for TRD");
192 // Make common binning
193 const Int_t kPIDbins = AliPID::kSPECIES + 1;
3a72645a 194 const Int_t kSteps = 2;
195 const Double_t kMinPID = -1;
196 const Double_t kMinP = 0.;
197 const Double_t kMaxPID = (Double_t)AliPID::kSPECIES;
198 const Double_t kMaxP = 20.;
f9f097c0 199 const Int_t kCentralityBins = 11;
3a72645a 200
8c1c76e9 201 // Define number of bins
202 Int_t kPbins = fQAmanager->HasHighResolutionHistos() ? 1000 : 100;
3e03bd67 203 Int_t tpcSigmaBins = fQAmanager->HasHighResolutionHistos() ? 1400 : 140;
204 Int_t trdLikelihoodBins = fQAmanager->HasHighResolutionHistos() ? 200 : 100;
205
3a72645a 206 fHistos = new AliHFEcollection("trdqahistos", "Collection of TRD QA histograms");
207
208 // Create Control Histogram monitoring the TPC sigma between the selection steps
f9f097c0 209 Int_t nBinsTPCSigma[5] = {kPIDbins, kPbins, tpcSigmaBins, kSteps, kCentralityBins};
210 Double_t minTPCSigma[5] = {kMinPID, kMinP, -12., 0., 0.};
211 Double_t maxTPCSigma[5] = {kMaxPID, kMaxP, 12., 2., 11.};
e156c3bb 212 fHistos->CreateTHnSparse("hTPCsigma", "TPC sigma; species p [GeV/c]; TPC dEdx - <dE/dx>|_{el} [#sigma]; selection step", 5, nBinsTPCSigma, minTPCSigma, maxTPCSigma);
bf892a6a 213 fHistos->Sumw2("hTPCsigma");
3a72645a 214 // Create Monitoring histogram for the Likelihood distribution
f9f097c0 215 Int_t nBinsTRDlike[5] = {kPIDbins, kPbins, trdLikelihoodBins, kSteps, kCentralityBins};
216 Double_t minTRDlike[5] = {kMinPID, kMinP, 0., 0., 0.};
217 Double_t maxTRDlike[5] = {kMaxPID, kMaxP, 1., 2., 11.};
e156c3bb 218 fHistos->CreateTHnSparse("hTRDlikelihood", "TRD Likelihood Distribution; species; p [GeV/c]; TRD electron Likelihood; selection step", 5, nBinsTRDlike, minTRDlike, maxTRDlike);
bf892a6a 219 fHistos->Sumw2("hTRDlikelihood");
3a72645a 220 // Create Monitoring histogram for the TRD total charge
221 const Int_t kTRDchargeBins = 1000;
f9f097c0 222 Int_t nBinsTRDcharge[5] = {kPIDbins, kPbins, kTRDchargeBins, kSteps, kCentralityBins};
223 Double_t minTRDcharge[5] = {kMinPID, kMinP, 0., 0., 0.};
224 Double_t maxTRDcharge[5] = {kMaxPID, kMaxP, 100000., 2., 11.};
e156c3bb 225 fHistos->CreateTHnSparse("hTRDcharge", "Total TRD charge; species; p [GeV/c]; TRD charge [a.u.]; selection step", 5, nBinsTRDcharge, minTRDcharge, maxTRDcharge);
bf892a6a 226 fHistos->Sumw2("hTRDcharge");
e3ae862b 227 // Monitoring of the TRD truncated mean according to version 1
228 const Int_t kTRDtmBins = 1000;
f9f097c0 229 Int_t nBinsTRDtm[5] = {kPIDbins, kPbins, kTRDtmBins, kSteps, kCentralityBins};
230 Double_t minTRDtm[5] = {kMinPID, kMinP, 0., 0., 0.};
231 Double_t maxTRDtm[5] = {kMaxPID, kMaxP, 20000., 2., 11.};
e156c3bb 232 fHistos->CreateTHnSparse("hTRDtruncatedMean", "TRD truncated Mean; species; p [GeV/c]; TRD signal [a.u.]; selection step", 5, nBinsTRDtm, minTRDtm, maxTRDtm);
ccc37cdc 233 fHistos->Sumw2("hTRDtruncatedMean");
e17c1f86 234
235 // Monitoring of the number of tracklets
236 fHistos->CreateTH2F("hNtrackletsBefore", "Number of tracklets before PID; species; p (GeV/c), Number of Tracklets", kPbins, kMinP, kMaxP, 7, 0., 7.);
237 fHistos->Sumw2("hNtrackletsBefore");
238 fHistos->CreateTH2F("hNtrackletsAfter", "Number of tracklets after PID; species; p (GeV/c), Number of Tracklets", kPbins, kMinP, kMaxP, 7, 0., 7.);
239 fHistos->Sumw2("hNtrackletsAfter");
3a72645a 240}
241
242//____________________________________________________________
6555e2ad 243void AliHFEtrdPIDqaV1::ProcessTrack(const AliHFEpidObject *track, AliHFEdetPIDqa::EStep_t step){
3a72645a 244 //
245 // Process the track, fill the containers
246 //
247 AliDebug(1, Form("QA started for TRD PID for step %d", (Int_t)step));
248 Int_t species = track->GetAbInitioPID();
e3ae862b 249 if(species >= AliPID::kSPECIES) species = -1;
6555e2ad 250 AliHFEpidObject::AnalysisType_t anatype = track->IsESDanalysis() ? AliHFEpidObject::kESDanalysis : AliHFEpidObject::kAODanalysis;
3a72645a 251
6555e2ad 252 AliHFEpidTRD *trdpid = dynamic_cast<AliHFEpidTRD *>(fQAmanager->GetDetectorPID(AliHFEpid::kTRDpid));
8c1c76e9 253 const AliPIDResponse *pidResponse = trdpid ? trdpid->GetPIDResponse() : NULL;
6555e2ad 254
f9f097c0 255 Double_t container[5];
3a72645a 256 container[0] = species;
bf892a6a 257 container[1] = trdpid ? trdpid->GetP(track->GetRecTrack(), anatype) : 0.;
8c1c76e9 258 container[2] = pidResponse ? pidResponse->NumberOfSigmasTPC(track->GetRecTrack(), AliPID::kElectron) : 0.;
3a72645a 259 container[3] = step;
f9f097c0 260 container[4] = track->GetCentrality();
85358761 261 AliDebug(1, Form("Species %d, p %f, number of sigma TPC %f, step %f, centrality %f", (Int_t)species,(Float_t) container[1],(Float_t) container[2],(Float_t) container[3],(Float_t) container[4]));
3a72645a 262 fHistos->Fill("hTPCsigma", container);
85358761 263 AliDebug(1, "Filled TPC sigma\n");
264
265
3a72645a 266
8c1c76e9 267 container[2] = trdpid ? trdpid->GetElectronLikelihood(static_cast<const AliVTrack*>(track->GetRecTrack()), anatype) : 0;
3a72645a 268 fHistos->Fill("hTRDlikelihood", container);
85358761 269 AliDebug(1, "Filled likelihood\n");
3a72645a 270
e3ae862b 271 if(track->IsESDanalysis()){
63bffcf1 272 const AliESDtrack *esdtrack = dynamic_cast<const AliESDtrack *>(track->GetRecTrack());
273 if(esdtrack){
274 container[2] = trdpid ? trdpid->GetTRDSignalV1(esdtrack) : 0;
275 fHistos->Fill("hTRDtruncatedMean", container);
276 }
e3ae862b 277 }
6555e2ad 278 for(UInt_t ily = 0; ily < 6; ily++){
f9f097c0 279 container[2] = trdpid ? trdpid->GetChargeLayer(track->GetRecTrack(), ily, anatype) : 0;
e156c3bb 280 if(container[2] < 1e-3) continue; // Filter out 0 entries
3a72645a 281 fHistos->Fill("hTRDcharge", container);
85358761 282 AliDebug(1, "Filled TRD charge\n");
3a72645a 283 }
e17c1f86 284
285 Int_t ntracklets = track->GetRecTrack()->GetTRDntrackletsPID();
286 if(step == AliHFEdetPIDqa::kBeforePID)
287 fHistos->Fill("hNtrackletsBefore", trdpid ? trdpid->GetP(track->GetRecTrack(), anatype) : 0., ntracklets);
288 else
289 fHistos->Fill("hNtrackletsAfter", trdpid ? trdpid->GetP(track->GetRecTrack(), anatype) : 0., ntracklets);
85358761 290 AliDebug(1, "Filled tracklet\n");
3a72645a 291}
292
293//_________________________________________________________
e156c3bb 294TH2 *AliHFEtrdPIDqaV1::MakeTPCspectrumNsigma(AliHFEdetPIDqa::EStep_t step, Int_t species, Int_t centralityClass){
3a72645a 295 //
296 // Get the TPC control histogram for the TRD selection step (either before or after PID)
297 //
3a72645a 298 THnSparseF *histo = dynamic_cast<THnSparseF *>(fHistos->Get("hTPCsigma"));
299 if(!histo){
300 AliError("QA histogram monitoring TPC nSigma not available");
301 return NULL;
302 }
303 if(species > -1 && species < AliPID::kSPECIES){
304 // cut on species (if available)
305 histo->GetAxis(0)->SetRange(species + 2, species + 2); // undef + underflow
306 }
e156c3bb 307 TString centname, centtitle;
308 Bool_t hasCentralityInfo = kTRUE;
309 if(centralityClass > -1){
310 if(histo->GetNdimensions() < 5){
311 AliError("Centrality Information not available");
312 centname = centtitle = "MinBias";
313 hasCentralityInfo = kFALSE;
314 } else {
315 // Project centrality classes
316 // -1 is Min. Bias
317 histo->GetAxis(4)->SetRange(centralityClass+1, centralityClass+1);
318 centname = Form("Cent%d", centralityClass);
319 centtitle = Form("Centrality %d", centralityClass);
320 }
321 } else {
322 histo->GetAxis(4)->SetRange(1, histo->GetAxis(4)->GetNbins()-1);
323 centname = centtitle = "MinBias";
324 hasCentralityInfo = kTRUE;
325 }
6555e2ad 326 histo->GetAxis(3)->SetRange(step + 1, step + 1);
3a72645a 327
328 TH2 *hSpec = histo->Projection(2, 1);
329 // construct title and name
6555e2ad 330 TString stepname = step == AliHFEdetPIDqa::kBeforePID ? "before" : "after";
3a72645a 331 TString speciesname = species > -1 && species < AliPID::kSPECIES ? AliPID::ParticleName(species) : "all Particles";
332 TString specID = species > -1 && species < AliPID::kSPECIES ? AliPID::ParticleName(species) : "unid";
e156c3bb 333 TString histname = Form("hSigmaTPC%s%s%s", specID.Data(), stepname.Data(), centname.Data());
334 TString histtitle = Form("TPC Sigma for %s %s PID %s", speciesname.Data(), stepname.Data(), centtitle.Data());
3a72645a 335 hSpec->SetName(histname.Data());
336 hSpec->SetTitle(histtitle.Data());
337
338 // Unset range on the original histogram
e3ae862b 339 histo->GetAxis(0)->SetRange(0, histo->GetAxis(0)->GetNbins());
e156c3bb 340 histo->GetAxis(3)->SetRange(0, histo->GetAxis(3)->GetNbins());
341 if(hasCentralityInfo)histo->GetAxis(4)->SetRange(0, histo->GetAxis(4)->GetNbins());
e3ae862b 342 return hSpec;
343}
344
345//_________________________________________________________
e156c3bb 346TH2 *AliHFEtrdPIDqaV1::MakeTRDspectrumTM(AliHFEdetPIDqa::EStep_t step, Int_t species, Int_t centralityClass){
e3ae862b 347 //
348 // Get the TPC control histogram for the TRD selection step (either before or after PID)
349 //
350 THnSparseF *histo = dynamic_cast<THnSparseF *>(fHistos->Get("hTRDtruncatedMean"));
351 if(!histo){
352 AliError("QA histogram monitoring TPC nSigma not available");
353 return NULL;
354 }
355 if(species > -1 && species < AliPID::kSPECIES){
356 // cut on species (if available)
357 histo->GetAxis(0)->SetRange(species + 2, species + 2); // undef + underflow
358 }
e156c3bb 359 TString centname, centtitle;
360 Bool_t hasCentralityInfo = kTRUE;
361 if(centralityClass > -1){
362 if(histo->GetNdimensions() < 5){
363 AliError("Centrality Information not available");
364 centname = centtitle = "MinBias";
365 hasCentralityInfo= kFALSE;
366 } else {
367 // Project centrality classes
368 // -1 is Min. Bias
369 histo->GetAxis(4)->SetRange(centralityClass+1, centralityClass+1);
370 centname = Form("Cent%d", centralityClass);
371 centtitle = Form("Centrality %d", centralityClass);
372 }
373 } else {
374 histo->GetAxis(4)->SetRange(1, histo->GetAxis(4)->GetNbins()-1);
375 centname = centtitle = "MinBias";
376 hasCentralityInfo= kFALSE;
377 }
e3ae862b 378 histo->GetAxis(3)->SetRange(step + 1, step + 1);
379
380 TH2 *hSpec = histo->Projection(2, 1);
381 // construct title and name
382 TString stepname = step == AliHFEdetPIDqa::kBeforePID ? "before" : "after";
383 TString speciesname = species > -1 && species < AliPID::kSPECIES ? AliPID::ParticleName(species) : "all Particles";
384 TString specID = species > -1 && species < AliPID::kSPECIES ? AliPID::ParticleName(species) : "unid";
e156c3bb 385 TString histname = Form("hTMTRD%s%s%s", specID.Data(), stepname.Data(), centname.Data());
386 TString histtitle = Form("TRD Truncated Mean for %s %s PID %s", speciesname.Data(), stepname.Data(), centtitle.Data());
e3ae862b 387 hSpec->SetName(histname.Data());
388 hSpec->SetTitle(histtitle.Data());
389
390 // Unset range on the original histogram
3a72645a 391 histo->GetAxis(0)->SetRange(0, histo->GetAxis(0)->GetNbins());
392 histo->GetAxis(2)->SetRange(0, histo->GetAxis(2)->GetNbins());
e156c3bb 393 if(hasCentralityInfo)histo->GetAxis(4)->SetRange(0, histo->GetAxis(4)->GetNbins());
3a72645a 394 return hSpec;
395}
396
397//_________________________________________________________
e156c3bb 398TH2 *AliHFEtrdPIDqaV1::MakeTRDlikelihoodDistribution(AliHFEdetPIDqa::EStep_t step, Int_t species, Int_t centralityClass){
3a72645a 399 //
400 // Make Histogram for TRD Likelihood distribution
401 //
402 THnSparseF *histo = dynamic_cast<THnSparseF *>(fHistos->Get("hTRDlikelihood"));
403 if(!histo){
404 AliError("QA histogram monitoring TRD Electron Likelihood not available");
405 return NULL;
406 }
407 if(species > -1 && species < AliPID::kSPECIES){
408 // cut on species (if available)
409 histo->GetAxis(0)->SetRange(species + 2, species + 2); // undef + underflow
410 }
e156c3bb 411 TString centname, centtitle;
412 Bool_t hasCentralityInfo = kTRUE;
413 if(centralityClass > -1){
414 if(histo->GetNdimensions() < 5){
415 AliError("Centrality Information not available");
416 centname = centtitle = "MinBias";
417 hasCentralityInfo= kFALSE;
418 } else {
419 // Project centrality classes
420 // -1 is Min. Bias
421 histo->GetAxis(4)->SetRange(centralityClass+1, centralityClass+1);
422 centname = Form("Cent%d", centralityClass);
423 centtitle = Form("Centrality %d", centralityClass);
424 }
425 } else {
426 histo->GetAxis(4)->SetRange(1, histo->GetAxis(4)->GetNbins()-1);
427 centname = centtitle = "MinBias";
428 hasCentralityInfo= kTRUE;
429 }
c2690925 430 histo->GetAxis(3)->SetRange(step + 1, step + 1);
3a72645a 431
432 TH2 *hSpec = histo->Projection(2, 1);
433 // construct title and name
6555e2ad 434 TString stepname = step == AliHFEdetPIDqa::kBeforePID ? "before" : "after";
3a72645a 435 TString speciesname = species > -1 && species < AliPID::kSPECIES ? AliPID::ParticleName(species) : "all Particles";
436 TString specID = species > -1 && species < AliPID::kSPECIES ? AliPID::ParticleName(species) : "unid";
e156c3bb 437 TString histname = Form("hLikeElTRD%s%s%s", specID.Data(), stepname.Data(),centname.Data());
438 TString histtitle = Form("TRD electron Likelihood for %s %s PID %s", speciesname.Data(), stepname.Data(),centtitle.Data());
3a72645a 439 hSpec->SetName(histname.Data());
440 hSpec->SetTitle(histtitle.Data());
441
442 // Unset range on the original histogram
443 histo->GetAxis(0)->SetRange(0, histo->GetAxis(0)->GetNbins());
444 histo->GetAxis(2)->SetRange(0, histo->GetAxis(2)->GetNbins());
e156c3bb 445 if(hasCentralityInfo)histo->GetAxis(4)->SetRange(0, histo->GetAxis(4)->GetNbins());
3a72645a 446 return hSpec;
447}
448
449//_________________________________________________________
e156c3bb 450TH2 *AliHFEtrdPIDqaV1::MakeTRDchargeDistribution(AliHFEdetPIDqa::EStep_t step, Int_t species, Int_t centralityClass){
3a72645a 451 //
452 // Make Histogram for TRD Likelihood distribution
453 //
454 THnSparseF *histo = dynamic_cast<THnSparseF *>(fHistos->Get("hTRDcharge"));
455 if(!histo){
456 AliError("QA histogram monitoring TRD total charge not available");
457 return NULL;
458 }
459 if(species > -1 && species < AliPID::kSPECIES){
460 // cut on species (if available)
461 histo->GetAxis(0)->SetRange(species + 2, species + 2); // undef + underflow
462 }
e156c3bb 463 TString centname, centtitle;
464 Bool_t hasCentralityInfo = kTRUE;
465 if(centralityClass > -1){
466 if(histo->GetNdimensions() < 5){
467 AliError("Centrality Information not available");
468 centname = centtitle = "MinBias";
469 hasCentralityInfo= kFALSE;
470 } else {
471 // Project centrality classes
472 // -1 is Min. Bias
473 histo->GetAxis(4)->SetRange(centralityClass+1, centralityClass+1);
474 centname = Form("Cent%d", centralityClass);
475 centtitle = Form("Centrality %d", centralityClass);
476 }
477 } else {
478 histo->GetAxis(4)->SetRange(1, histo->GetAxis(4)->GetNbins()-1);
479 centname = centtitle = "MinBias";
480 hasCentralityInfo= kTRUE;
481 }
6555e2ad 482 histo->GetAxis(3)->SetRange(step + 1, step + 1);
3a72645a 483
484 TH2 *hSpec = histo->Projection(2, 1);
485 // construct title and name
6555e2ad 486 TString stepname = step == AliHFEdetPIDqa::kBeforePID ? "before" : "after";
3a72645a 487 TString speciesname = species > -1 && species < AliPID::kSPECIES ? AliPID::ParticleName(species) : "all Particles";
488 TString specID = species > -1 && species < AliPID::kSPECIES ? AliPID::ParticleName(species) : "unid";
e156c3bb 489 TString histname = Form("hChargeTRD%s%s%s", specID.Data(), stepname.Data(), centname.Data());
490 TString histtitle = Form("TRD total charge for %s %s PID %s", speciesname.Data(), stepname.Data(), centtitle.Data());
3a72645a 491 hSpec->SetName(histname.Data());
492 hSpec->SetTitle(histtitle.Data());
493
494 // Unset range on the original histogram
495 histo->GetAxis(0)->SetRange(0, histo->GetAxis(0)->GetNbins());
496 histo->GetAxis(2)->SetRange(0, histo->GetAxis(2)->GetNbins());
e156c3bb 497 if(hasCentralityInfo)histo->GetAxis(4)->SetRange(0, histo->GetAxis(4)->GetNbins());
3a72645a 498 return hSpec;
499}
500