1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
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
28 // Markus Fasel <M.Fasel@gsi.de>
34 #include <THnSparse.h>
37 #include "AliESDtrack.h"
40 #include "AliPIDResponse.h"
42 #include "AliHFEcollection.h"
43 #include "AliHFEpidBase.h"
44 #include "AliHFEpidQAmanager.h"
45 #include "AliHFEpidTPC.h"
46 #include "AliHFEpidTRD.h"
47 #include "AliHFEtrdPIDqaV1.h"
49 ClassImp(AliHFEtrdPIDqaV1)
51 //____________________________________________________________
52 AliHFEtrdPIDqaV1::AliHFEtrdPIDqaV1():
61 //____________________________________________________________
62 AliHFEtrdPIDqaV1::AliHFEtrdPIDqaV1(const Char_t *name):
63 AliHFEdetPIDqa(name, "QA for TRD"),
67 // Default constructor
71 //____________________________________________________________
72 AliHFEtrdPIDqaV1::AliHFEtrdPIDqaV1(const AliHFEtrdPIDqaV1 &o):
81 //____________________________________________________________
82 AliHFEtrdPIDqaV1 &AliHFEtrdPIDqaV1::operator=(const AliHFEtrdPIDqaV1 &o){
86 if(this == &o) return *this;
87 AliHFEdetPIDqa::operator=(o);
93 //_________________________________________________________
94 Long64_t AliHFEtrdPIDqaV1::Merge(TCollection *coll){
96 // Merge with other objects
99 if(coll->IsEmpty()) return 1;
102 AliHFEtrdPIDqaV1 *refQA = NULL;
107 refQA = dynamic_cast<AliHFEtrdPIDqaV1 *>(o);
110 listHistos.Add(refQA->fHistos);
113 fHistos->Merge(&listHistos);
117 //_________________________________________________________
118 void AliHFEtrdPIDqaV1::Browse(TBrowser *b){
124 b->Add(fHistos, fHistos->GetName());
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;
131 TList *listLike = new TList;
132 listLike->SetOwner();
133 TList *listCharge = new TList;
134 listCharge->SetOwner();
135 TList *listTPCnsigma = new TList;
136 listTPCnsigma->SetOwner();
139 TList *lctm, *lclike, *lccharge, *lcTPCsig;
140 for(Int_t icent = -1; icent < 11; icent++){
142 lctm->SetName(icent < 0 ? "MinBias" : Form("Centrality%d", icent));
146 lclike->SetName(icent < 0 ? "MinBias" : Form("Centrality%d", icent));
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);
161 hptr->SetName(Form("hTRDtm%s%s", specnames[ispec].Data(), istep == 0 ? "Before" : "After"));
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"));
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"));
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"));
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");
185 //____________________________________________________________
186 void AliHFEtrdPIDqaV1::Initialize(){
188 // Initialize QA histos for TRD PID
191 AliDebug(1, "Initializing PID QA for TRD");
192 // Make common binning
193 const Int_t kPIDbins = AliPID::kSPECIES + 1;
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.;
199 const Int_t kCentralityBins = 11;
201 // Define number of bins
202 Int_t kPbins = fQAmanager->HasHighResolutionHistos() ? 1000 : 100;
203 Int_t tpcSigmaBins = fQAmanager->HasHighResolutionHistos() ? 1400 : 140;
204 Int_t trdLikelihoodBins = fQAmanager->HasHighResolutionHistos() ? 200 : 100;
206 fHistos = new AliHFEcollection("trdqahistos", "Collection of TRD QA histograms");
208 // Create Control Histogram monitoring the TPC sigma between the selection steps
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.};
212 fHistos->CreateTHnSparse("hTPCsigma", "TPC sigma; species p [GeV/c]; TPC dEdx - <dE/dx>|_{el} [#sigma]; selection step", 5, nBinsTPCSigma, minTPCSigma, maxTPCSigma);
213 fHistos->Sumw2("hTPCsigma");
214 // Create Monitoring histogram for the Likelihood distribution
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.};
218 fHistos->CreateTHnSparse("hTRDlikelihood", "TRD Likelihood Distribution; species; p [GeV/c]; TRD electron Likelihood; selection step", 5, nBinsTRDlike, minTRDlike, maxTRDlike);
219 fHistos->Sumw2("hTRDlikelihood");
220 // Create Monitoring histogram for the TRD total charge
221 const Int_t kTRDchargeBins = 1000;
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.};
225 fHistos->CreateTHnSparse("hTRDcharge", "Total TRD charge; species; p [GeV/c]; TRD charge [a.u.]; selection step", 5, nBinsTRDcharge, minTRDcharge, maxTRDcharge);
226 fHistos->Sumw2("hTRDcharge");
227 // Monitoring of the TRD truncated mean according to version 1
228 const Int_t kTRDtmBins = 1000;
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.};
232 fHistos->CreateTHnSparse("hTRDtruncatedMean", "TRD truncated Mean; species; p [GeV/c]; TRD signal [a.u.]; selection step", 5, nBinsTRDtm, minTRDtm, maxTRDtm);
233 fHistos->Sumw2("hTRDtruncatedMean");
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");
242 //____________________________________________________________
243 void AliHFEtrdPIDqaV1::ProcessTrack(const AliHFEpidObject *track, AliHFEdetPIDqa::EStep_t step){
245 // Process the track, fill the containers
247 AliDebug(1, Form("QA started for TRD PID for step %d", (Int_t)step));
248 Int_t species = track->GetAbInitioPID();
249 if(species >= AliPID::kSPECIES) species = -1;
250 AliHFEpidObject::AnalysisType_t anatype = track->IsESDanalysis() ? AliHFEpidObject::kESDanalysis : AliHFEpidObject::kAODanalysis;
252 AliHFEpidTRD *trdpid = dynamic_cast<AliHFEpidTRD *>(fQAmanager->GetDetectorPID(AliHFEpid::kTRDpid));
253 const AliPIDResponse *pidResponse = trdpid ? trdpid->GetPIDResponse() : NULL;
255 Double_t container[5];
256 container[0] = species;
257 container[1] = trdpid ? trdpid->GetP(track->GetRecTrack(), anatype) : 0.;
258 container[2] = pidResponse ? pidResponse->NumberOfSigmasTPC(track->GetRecTrack(), AliPID::kElectron) : 0.;
260 container[4] = track->GetCentrality();
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]));
262 fHistos->Fill("hTPCsigma", container);
263 AliDebug(1, "Filled TPC sigma\n");
267 container[2] = trdpid ? trdpid->GetElectronLikelihood(static_cast<const AliVTrack*>(track->GetRecTrack()), anatype) : 0;
268 fHistos->Fill("hTRDlikelihood", container);
269 AliDebug(1, "Filled likelihood\n");
271 if(track->IsESDanalysis()){
272 const AliESDtrack *esdtrack = dynamic_cast<const AliESDtrack *>(track->GetRecTrack());
274 container[2] = trdpid ? trdpid->GetTRDSignalV1(esdtrack) : 0;
275 fHistos->Fill("hTRDtruncatedMean", container);
278 for(UInt_t ily = 0; ily < 6; ily++){
279 container[2] = trdpid ? trdpid->GetChargeLayer(track->GetRecTrack(), ily, anatype) : 0;
280 if(container[2] < 1e-3) continue; // Filter out 0 entries
281 fHistos->Fill("hTRDcharge", container);
282 AliDebug(1, "Filled TRD charge\n");
285 Int_t ntracklets = track->GetRecTrack()->GetTRDntrackletsPID();
286 if(step == AliHFEdetPIDqa::kBeforePID)
287 fHistos->Fill("hNtrackletsBefore", trdpid ? trdpid->GetP(track->GetRecTrack(), anatype) : 0., ntracklets);
289 fHistos->Fill("hNtrackletsAfter", trdpid ? trdpid->GetP(track->GetRecTrack(), anatype) : 0., ntracklets);
290 AliDebug(1, "Filled tracklet\n");
293 //_________________________________________________________
294 TH2 *AliHFEtrdPIDqaV1::MakeTPCspectrumNsigma(AliHFEdetPIDqa::EStep_t step, Int_t species, Int_t centralityClass){
296 // Get the TPC control histogram for the TRD selection step (either before or after PID)
298 THnSparseF *histo = dynamic_cast<THnSparseF *>(fHistos->Get("hTPCsigma"));
300 AliError("QA histogram monitoring TPC nSigma not available");
303 if(species > -1 && species < AliPID::kSPECIES){
304 // cut on species (if available)
305 histo->GetAxis(0)->SetRange(species + 2, species + 2); // undef + underflow
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;
315 // Project centrality classes
317 histo->GetAxis(4)->SetRange(centralityClass+1, centralityClass+1);
318 centname = Form("Cent%d", centralityClass);
319 centtitle = Form("Centrality %d", centralityClass);
322 histo->GetAxis(4)->SetRange(1, histo->GetAxis(4)->GetNbins()-1);
323 centname = centtitle = "MinBias";
324 hasCentralityInfo = kTRUE;
326 histo->GetAxis(3)->SetRange(step + 1, step + 1);
328 TH2 *hSpec = histo->Projection(2, 1);
329 // construct title and name
330 TString stepname = step == AliHFEdetPIDqa::kBeforePID ? "before" : "after";
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";
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());
335 hSpec->SetName(histname.Data());
336 hSpec->SetTitle(histtitle.Data());
338 // Unset range on the original histogram
339 histo->GetAxis(0)->SetRange(0, histo->GetAxis(0)->GetNbins());
340 histo->GetAxis(3)->SetRange(0, histo->GetAxis(3)->GetNbins());
341 if(hasCentralityInfo)histo->GetAxis(4)->SetRange(0, histo->GetAxis(4)->GetNbins());
345 //_________________________________________________________
346 TH2 *AliHFEtrdPIDqaV1::MakeTRDspectrumTM(AliHFEdetPIDqa::EStep_t step, Int_t species, Int_t centralityClass){
348 // Get the TPC control histogram for the TRD selection step (either before or after PID)
350 THnSparseF *histo = dynamic_cast<THnSparseF *>(fHistos->Get("hTRDtruncatedMean"));
352 AliError("QA histogram monitoring TPC nSigma not available");
355 if(species > -1 && species < AliPID::kSPECIES){
356 // cut on species (if available)
357 histo->GetAxis(0)->SetRange(species + 2, species + 2); // undef + underflow
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;
367 // Project centrality classes
369 histo->GetAxis(4)->SetRange(centralityClass+1, centralityClass+1);
370 centname = Form("Cent%d", centralityClass);
371 centtitle = Form("Centrality %d", centralityClass);
374 histo->GetAxis(4)->SetRange(1, histo->GetAxis(4)->GetNbins()-1);
375 centname = centtitle = "MinBias";
376 hasCentralityInfo= kFALSE;
378 histo->GetAxis(3)->SetRange(step + 1, step + 1);
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";
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());
387 hSpec->SetName(histname.Data());
388 hSpec->SetTitle(histtitle.Data());
390 // Unset range on the original histogram
391 histo->GetAxis(0)->SetRange(0, histo->GetAxis(0)->GetNbins());
392 histo->GetAxis(2)->SetRange(0, histo->GetAxis(2)->GetNbins());
393 if(hasCentralityInfo)histo->GetAxis(4)->SetRange(0, histo->GetAxis(4)->GetNbins());
397 //_________________________________________________________
398 TH2 *AliHFEtrdPIDqaV1::MakeTRDlikelihoodDistribution(AliHFEdetPIDqa::EStep_t step, Int_t species, Int_t centralityClass){
400 // Make Histogram for TRD Likelihood distribution
402 THnSparseF *histo = dynamic_cast<THnSparseF *>(fHistos->Get("hTRDlikelihood"));
404 AliError("QA histogram monitoring TRD Electron Likelihood not available");
407 if(species > -1 && species < AliPID::kSPECIES){
408 // cut on species (if available)
409 histo->GetAxis(0)->SetRange(species + 2, species + 2); // undef + underflow
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;
419 // Project centrality classes
421 histo->GetAxis(4)->SetRange(centralityClass+1, centralityClass+1);
422 centname = Form("Cent%d", centralityClass);
423 centtitle = Form("Centrality %d", centralityClass);
426 histo->GetAxis(4)->SetRange(1, histo->GetAxis(4)->GetNbins()-1);
427 centname = centtitle = "MinBias";
428 hasCentralityInfo= kTRUE;
430 histo->GetAxis(3)->SetRange(step + 1, step + 1);
432 TH2 *hSpec = histo->Projection(2, 1);
433 // construct title and name
434 TString stepname = step == AliHFEdetPIDqa::kBeforePID ? "before" : "after";
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";
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());
439 hSpec->SetName(histname.Data());
440 hSpec->SetTitle(histtitle.Data());
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());
445 if(hasCentralityInfo)histo->GetAxis(4)->SetRange(0, histo->GetAxis(4)->GetNbins());
449 //_________________________________________________________
450 TH2 *AliHFEtrdPIDqaV1::MakeTRDchargeDistribution(AliHFEdetPIDqa::EStep_t step, Int_t species, Int_t centralityClass){
452 // Make Histogram for TRD Likelihood distribution
454 THnSparseF *histo = dynamic_cast<THnSparseF *>(fHistos->Get("hTRDcharge"));
456 AliError("QA histogram monitoring TRD total charge not available");
459 if(species > -1 && species < AliPID::kSPECIES){
460 // cut on species (if available)
461 histo->GetAxis(0)->SetRange(species + 2, species + 2); // undef + underflow
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;
471 // Project centrality classes
473 histo->GetAxis(4)->SetRange(centralityClass+1, centralityClass+1);
474 centname = Form("Cent%d", centralityClass);
475 centtitle = Form("Centrality %d", centralityClass);
478 histo->GetAxis(4)->SetRange(1, histo->GetAxis(4)->GetNbins()-1);
479 centname = centtitle = "MinBias";
480 hasCentralityInfo= kTRUE;
482 histo->GetAxis(3)->SetRange(step + 1, step + 1);
484 TH2 *hSpec = histo->Projection(2, 1);
485 // construct title and name
486 TString stepname = step == AliHFEdetPIDqa::kBeforePID ? "before" : "after";
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";
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());
491 hSpec->SetName(histname.Data());
492 hSpec->SetTitle(histtitle.Data());
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());
497 if(hasCentralityInfo)histo->GetAxis(4)->SetRange(0, histo->GetAxis(4)->GetNbins());