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 fHistos->Fill("hTPCsigma", container);
263 container[2] = trdpid ? trdpid->GetElectronLikelihood(static_cast<const AliVTrack*>(track->GetRecTrack()), anatype) : 0;
264 fHistos->Fill("hTRDlikelihood", container);
266 if(track->IsESDanalysis()){
267 const AliESDtrack *esdtrack = dynamic_cast<const AliESDtrack *>(track->GetRecTrack());
269 container[2] = trdpid ? trdpid->GetTRDSignalV1(esdtrack) : 0;
270 fHistos->Fill("hTRDtruncatedMean", container);
273 for(UInt_t ily = 0; ily < 6; ily++){
274 container[2] = trdpid ? trdpid->GetChargeLayer(track->GetRecTrack(), ily, anatype) : 0;
275 if(container[2] < 1e-3) continue; // Filter out 0 entries
276 fHistos->Fill("hTRDcharge", container);
279 Int_t ntracklets = track->GetRecTrack()->GetTRDntrackletsPID();
280 if(step == AliHFEdetPIDqa::kBeforePID)
281 fHistos->Fill("hNtrackletsBefore", trdpid ? trdpid->GetP(track->GetRecTrack(), anatype) : 0., ntracklets);
283 fHistos->Fill("hNtrackletsAfter", trdpid ? trdpid->GetP(track->GetRecTrack(), anatype) : 0., ntracklets);
286 //_________________________________________________________
287 TH2 *AliHFEtrdPIDqaV1::MakeTPCspectrumNsigma(AliHFEdetPIDqa::EStep_t step, Int_t species, Int_t centralityClass){
289 // Get the TPC control histogram for the TRD selection step (either before or after PID)
291 THnSparseF *histo = dynamic_cast<THnSparseF *>(fHistos->Get("hTPCsigma"));
293 AliError("QA histogram monitoring TPC nSigma not available");
296 if(species > -1 && species < AliPID::kSPECIES){
297 // cut on species (if available)
298 histo->GetAxis(0)->SetRange(species + 2, species + 2); // undef + underflow
300 TString centname, centtitle;
301 Bool_t hasCentralityInfo = kTRUE;
302 if(centralityClass > -1){
303 if(histo->GetNdimensions() < 5){
304 AliError("Centrality Information not available");
305 centname = centtitle = "MinBias";
306 hasCentralityInfo = kFALSE;
308 // Project centrality classes
310 histo->GetAxis(4)->SetRange(centralityClass+1, centralityClass+1);
311 centname = Form("Cent%d", centralityClass);
312 centtitle = Form("Centrality %d", centralityClass);
315 histo->GetAxis(4)->SetRange(1, histo->GetAxis(4)->GetNbins()-1);
316 centname = centtitle = "MinBias";
317 hasCentralityInfo = kTRUE;
319 histo->GetAxis(3)->SetRange(step + 1, step + 1);
321 TH2 *hSpec = histo->Projection(2, 1);
322 // construct title and name
323 TString stepname = step == AliHFEdetPIDqa::kBeforePID ? "before" : "after";
324 TString speciesname = species > -1 && species < AliPID::kSPECIES ? AliPID::ParticleName(species) : "all Particles";
325 TString specID = species > -1 && species < AliPID::kSPECIES ? AliPID::ParticleName(species) : "unid";
326 TString histname = Form("hSigmaTPC%s%s%s", specID.Data(), stepname.Data(), centname.Data());
327 TString histtitle = Form("TPC Sigma for %s %s PID %s", speciesname.Data(), stepname.Data(), centtitle.Data());
328 hSpec->SetName(histname.Data());
329 hSpec->SetTitle(histtitle.Data());
331 // Unset range on the original histogram
332 histo->GetAxis(0)->SetRange(0, histo->GetAxis(0)->GetNbins());
333 histo->GetAxis(3)->SetRange(0, histo->GetAxis(3)->GetNbins());
334 if(hasCentralityInfo)histo->GetAxis(4)->SetRange(0, histo->GetAxis(4)->GetNbins());
338 //_________________________________________________________
339 TH2 *AliHFEtrdPIDqaV1::MakeTRDspectrumTM(AliHFEdetPIDqa::EStep_t step, Int_t species, Int_t centralityClass){
341 // Get the TPC control histogram for the TRD selection step (either before or after PID)
343 THnSparseF *histo = dynamic_cast<THnSparseF *>(fHistos->Get("hTRDtruncatedMean"));
345 AliError("QA histogram monitoring TPC nSigma not available");
348 if(species > -1 && species < AliPID::kSPECIES){
349 // cut on species (if available)
350 histo->GetAxis(0)->SetRange(species + 2, species + 2); // undef + underflow
352 TString centname, centtitle;
353 Bool_t hasCentralityInfo = kTRUE;
354 if(centralityClass > -1){
355 if(histo->GetNdimensions() < 5){
356 AliError("Centrality Information not available");
357 centname = centtitle = "MinBias";
358 hasCentralityInfo= kFALSE;
360 // Project centrality classes
362 histo->GetAxis(4)->SetRange(centralityClass+1, centralityClass+1);
363 centname = Form("Cent%d", centralityClass);
364 centtitle = Form("Centrality %d", centralityClass);
367 histo->GetAxis(4)->SetRange(1, histo->GetAxis(4)->GetNbins()-1);
368 centname = centtitle = "MinBias";
369 hasCentralityInfo= kFALSE;
371 histo->GetAxis(3)->SetRange(step + 1, step + 1);
373 TH2 *hSpec = histo->Projection(2, 1);
374 // construct title and name
375 TString stepname = step == AliHFEdetPIDqa::kBeforePID ? "before" : "after";
376 TString speciesname = species > -1 && species < AliPID::kSPECIES ? AliPID::ParticleName(species) : "all Particles";
377 TString specID = species > -1 && species < AliPID::kSPECIES ? AliPID::ParticleName(species) : "unid";
378 TString histname = Form("hTMTRD%s%s%s", specID.Data(), stepname.Data(), centname.Data());
379 TString histtitle = Form("TRD Truncated Mean for %s %s PID %s", speciesname.Data(), stepname.Data(), centtitle.Data());
380 hSpec->SetName(histname.Data());
381 hSpec->SetTitle(histtitle.Data());
383 // Unset range on the original histogram
384 histo->GetAxis(0)->SetRange(0, histo->GetAxis(0)->GetNbins());
385 histo->GetAxis(2)->SetRange(0, histo->GetAxis(2)->GetNbins());
386 if(hasCentralityInfo)histo->GetAxis(4)->SetRange(0, histo->GetAxis(4)->GetNbins());
390 //_________________________________________________________
391 TH2 *AliHFEtrdPIDqaV1::MakeTRDlikelihoodDistribution(AliHFEdetPIDqa::EStep_t step, Int_t species, Int_t centralityClass){
393 // Make Histogram for TRD Likelihood distribution
395 THnSparseF *histo = dynamic_cast<THnSparseF *>(fHistos->Get("hTRDlikelihood"));
397 AliError("QA histogram monitoring TRD Electron Likelihood not available");
400 if(species > -1 && species < AliPID::kSPECIES){
401 // cut on species (if available)
402 histo->GetAxis(0)->SetRange(species + 2, species + 2); // undef + underflow
404 TString centname, centtitle;
405 Bool_t hasCentralityInfo = kTRUE;
406 if(centralityClass > -1){
407 if(histo->GetNdimensions() < 5){
408 AliError("Centrality Information not available");
409 centname = centtitle = "MinBias";
410 hasCentralityInfo= kFALSE;
412 // Project centrality classes
414 histo->GetAxis(4)->SetRange(centralityClass+1, centralityClass+1);
415 centname = Form("Cent%d", centralityClass);
416 centtitle = Form("Centrality %d", centralityClass);
419 histo->GetAxis(4)->SetRange(1, histo->GetAxis(4)->GetNbins()-1);
420 centname = centtitle = "MinBias";
421 hasCentralityInfo= kTRUE;
423 histo->GetAxis(3)->SetRange(step + 1, step + 1);
425 TH2 *hSpec = histo->Projection(2, 1);
426 // construct title and name
427 TString stepname = step == AliHFEdetPIDqa::kBeforePID ? "before" : "after";
428 TString speciesname = species > -1 && species < AliPID::kSPECIES ? AliPID::ParticleName(species) : "all Particles";
429 TString specID = species > -1 && species < AliPID::kSPECIES ? AliPID::ParticleName(species) : "unid";
430 TString histname = Form("hLikeElTRD%s%s%s", specID.Data(), stepname.Data(),centname.Data());
431 TString histtitle = Form("TRD electron Likelihood for %s %s PID %s", speciesname.Data(), stepname.Data(),centtitle.Data());
432 hSpec->SetName(histname.Data());
433 hSpec->SetTitle(histtitle.Data());
435 // Unset range on the original histogram
436 histo->GetAxis(0)->SetRange(0, histo->GetAxis(0)->GetNbins());
437 histo->GetAxis(2)->SetRange(0, histo->GetAxis(2)->GetNbins());
438 if(hasCentralityInfo)histo->GetAxis(4)->SetRange(0, histo->GetAxis(4)->GetNbins());
442 //_________________________________________________________
443 TH2 *AliHFEtrdPIDqaV1::MakeTRDchargeDistribution(AliHFEdetPIDqa::EStep_t step, Int_t species, Int_t centralityClass){
445 // Make Histogram for TRD Likelihood distribution
447 THnSparseF *histo = dynamic_cast<THnSparseF *>(fHistos->Get("hTRDcharge"));
449 AliError("QA histogram monitoring TRD total charge not available");
452 if(species > -1 && species < AliPID::kSPECIES){
453 // cut on species (if available)
454 histo->GetAxis(0)->SetRange(species + 2, species + 2); // undef + underflow
456 TString centname, centtitle;
457 Bool_t hasCentralityInfo = kTRUE;
458 if(centralityClass > -1){
459 if(histo->GetNdimensions() < 5){
460 AliError("Centrality Information not available");
461 centname = centtitle = "MinBias";
462 hasCentralityInfo= kFALSE;
464 // Project centrality classes
466 histo->GetAxis(4)->SetRange(centralityClass+1, centralityClass+1);
467 centname = Form("Cent%d", centralityClass);
468 centtitle = Form("Centrality %d", centralityClass);
471 histo->GetAxis(4)->SetRange(1, histo->GetAxis(4)->GetNbins()-1);
472 centname = centtitle = "MinBias";
473 hasCentralityInfo= kTRUE;
475 histo->GetAxis(3)->SetRange(step + 1, step + 1);
477 TH2 *hSpec = histo->Projection(2, 1);
478 // construct title and name
479 TString stepname = step == AliHFEdetPIDqa::kBeforePID ? "before" : "after";
480 TString speciesname = species > -1 && species < AliPID::kSPECIES ? AliPID::ParticleName(species) : "all Particles";
481 TString specID = species > -1 && species < AliPID::kSPECIES ? AliPID::ParticleName(species) : "unid";
482 TString histname = Form("hChargeTRD%s%s%s", specID.Data(), stepname.Data(), centname.Data());
483 TString histtitle = Form("TRD total charge for %s %s PID %s", speciesname.Data(), stepname.Data(), centtitle.Data());
484 hSpec->SetName(histname.Data());
485 hSpec->SetTitle(histtitle.Data());
487 // Unset range on the original histogram
488 histo->GetAxis(0)->SetRange(0, histo->GetAxis(0)->GetNbins());
489 histo->GetAxis(2)->SetRange(0, histo->GetAxis(2)->GetNbins());
490 if(hasCentralityInfo)histo->GetAxis(4)->SetRange(0, histo->GetAxis(4)->GetNbins());