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"
41 #include "AliHFEcollection.h"
42 #include "AliHFEpidBase.h"
43 #include "AliHFEpidQAmanager.h"
44 #include "AliHFEpidTPC.h"
45 #include "AliHFEpidTRD.h"
46 #include "AliHFEtrdPIDqaV1.h"
48 ClassImp(AliHFEtrdPIDqaV1)
50 //____________________________________________________________
51 AliHFEtrdPIDqaV1::AliHFEtrdPIDqaV1():
60 //____________________________________________________________
61 AliHFEtrdPIDqaV1::AliHFEtrdPIDqaV1(const Char_t *name):
62 AliHFEdetPIDqa(name, "QA for TRD"),
66 // Default constructor
70 //____________________________________________________________
71 AliHFEtrdPIDqaV1::AliHFEtrdPIDqaV1(const AliHFEtrdPIDqaV1 &o):
80 //____________________________________________________________
81 AliHFEtrdPIDqaV1 &AliHFEtrdPIDqaV1::operator=(const AliHFEtrdPIDqaV1 &o){
85 AliHFEdetPIDqa::operator=(o);
91 //_________________________________________________________
92 Long64_t AliHFEtrdPIDqaV1::Merge(TCollection *coll){
94 // Merge with other objects
97 if(coll->IsEmpty()) return 1;
100 AliHFEtrdPIDqaV1 *refQA = NULL;
105 refQA = dynamic_cast<AliHFEtrdPIDqaV1 *>(o);
108 listHistos.Add(refQA->fHistos);
111 fHistos->Merge(&listHistos);
115 //_________________________________________________________
116 void AliHFEtrdPIDqaV1::Browse(TBrowser *b){
122 b->Add(fHistos, fHistos->GetName());
124 // Make Projections of the dE/dx Spectra and add them to a new Folder
125 TString specnames[4] = {"All", "Electrons", "Pions", "Protons"};
126 Int_t specind[4] = {-1, AliPID::kElectron, AliPID::kPion, AliPID::kProton};
127 TList *listTM = new TList;
129 TList *listLike = new TList;
130 listLike->SetOwner();
131 TList *listCharge = new TList;
132 listCharge->SetOwner();
133 TList *listTPCnsigma = new TList;
134 listTPCnsigma->SetOwner();
137 for(Int_t ispec = 0; ispec < 4; ispec++){
138 for(Int_t istep = 0; istep < 2; istep++){
139 hptr = MakeTRDspectrumTM(static_cast<AliHFEdetPIDqa::EStep_t>(istep), specind[ispec]);
141 hptr->SetName(Form("hTRDtm%s%s", specnames[ispec].Data(), istep == 0 ? "Before" : "After"));
144 hptr = MakeTRDlikelihoodDistribution(static_cast<AliHFEdetPIDqa::EStep_t>(istep), specind[ispec]);
145 hptr->SetName(Form("hTRDlike%s%s", specnames[ispec].Data(), istep == 0 ? "Before" : "After"));
147 hptr = MakeTRDchargeDistribution(static_cast<AliHFEdetPIDqa::EStep_t>(istep), specind[ispec]);
148 hptr->SetName(Form("hTRDcharge%s%s", specnames[ispec].Data(), istep == 0 ? "Before" : "After"));
149 listCharge->Add(hptr);
150 hptr = MakeTPCspectrumNsigma(static_cast<AliHFEdetPIDqa::EStep_t>(istep), specind[ispec]);
151 hptr->SetName(Form("hTPCspectrum%s%s", specnames[ispec].Data(), istep == 0 ? "Before" : "After"));
152 listTPCnsigma->Add(hptr);
156 b->Add(listTM, "Projections Truncated Mean");
157 b->Add(listLike, "Projections Likelihood distribution");
158 b->Add(listCharge, "Projections Tracklet Charge");
159 b->Add(listTPCnsigma, "Projections TPC spectra");
164 //____________________________________________________________
165 void AliHFEtrdPIDqaV1::Initialize(){
167 // Initialize QA histos for TRD PID
170 AliDebug(1, "Initializing PID QA for TRD");
171 // Make common binning
172 const Int_t kPIDbins = AliPID::kSPECIES + 1;
173 const Int_t kPbins = 100;
174 const Int_t kSteps = 2;
175 const Double_t kMinPID = -1;
176 const Double_t kMinP = 0.;
177 const Double_t kMaxPID = (Double_t)AliPID::kSPECIES;
178 const Double_t kMaxP = 20.;
179 const Int_t kCentralityBins = 11;
181 // Define number of bins
182 Int_t tpcSigmaBins = fQAmanager->HasHighResolutionHistos() ? 1400 : 140;
183 Int_t trdLikelihoodBins = fQAmanager->HasHighResolutionHistos() ? 200 : 100;
185 fHistos = new AliHFEcollection("trdqahistos", "Collection of TRD QA histograms");
187 // Create Control Histogram monitoring the TPC sigma between the selection steps
188 Int_t nBinsTPCSigma[5] = {kPIDbins, kPbins, tpcSigmaBins, kSteps, kCentralityBins};
189 Double_t minTPCSigma[5] = {kMinPID, kMinP, -12., 0., 0.};
190 Double_t maxTPCSigma[5] = {kMaxPID, kMaxP, 12., 2., 11.};
191 fHistos->CreateTHnSparse("hTPCsigma", "TPC sigma; species p [GeV/c]; TPC dEdx - <dE/dx>|_{el} [#sigma]; selection step", 4, nBinsTPCSigma, minTPCSigma, maxTPCSigma);
192 fHistos->Sumw2("hTPCsigma");
193 // Create Monitoring histogram for the Likelihood distribution
194 Int_t nBinsTRDlike[5] = {kPIDbins, kPbins, trdLikelihoodBins, kSteps, kCentralityBins};
195 Double_t minTRDlike[5] = {kMinPID, kMinP, 0., 0., 0.};
196 Double_t maxTRDlike[5] = {kMaxPID, kMaxP, 1., 2., 11.};
197 fHistos->CreateTHnSparse("hTRDlikelihood", "TRD Likelihood Distribution; species; p [GeV/c]; TRD electron Likelihood; selection step", 4, nBinsTRDlike, minTRDlike, maxTRDlike);
198 fHistos->Sumw2("hTRDlikelihood");
199 // Create Monitoring histogram for the TRD total charge
200 const Int_t kTRDchargeBins = 1000;
201 Int_t nBinsTRDcharge[5] = {kPIDbins, kPbins, kTRDchargeBins, kSteps, kCentralityBins};
202 Double_t minTRDcharge[5] = {kMinPID, kMinP, 0., 0., 0.};
203 Double_t maxTRDcharge[5] = {kMaxPID, kMaxP, 100000., 2., 11.};
204 fHistos->CreateTHnSparse("hTRDcharge", "Total TRD charge; species; p [GeV/c]; TRD charge [a.u.]; selection step", 4, nBinsTRDcharge, minTRDcharge, maxTRDcharge);
205 fHistos->Sumw2("hTRDcharge");
206 // Monitoring of the TRD truncated mean according to version 1
207 const Int_t kTRDtmBins = 1000;
208 Int_t nBinsTRDtm[5] = {kPIDbins, kPbins, kTRDtmBins, kSteps, kCentralityBins};
209 Double_t minTRDtm[5] = {kMinPID, kMinP, 0., 0., 0.};
210 Double_t maxTRDtm[5] = {kMaxPID, kMaxP, 20000., 2., 11.};
211 fHistos->CreateTHnSparse("hTRDtruncatedMean", "TRD truncated Mean; species; p [GeV/c]; TRD signal [a.u.]; selection step", 4, nBinsTRDtm, minTRDtm, maxTRDtm);
212 fHistos->Sumw2("hTRDtruncatedMean");
215 //____________________________________________________________
216 void AliHFEtrdPIDqaV1::ProcessTrack(const AliHFEpidObject *track, AliHFEdetPIDqa::EStep_t step){
218 // Process the track, fill the containers
220 AliDebug(1, Form("QA started for TRD PID for step %d", (Int_t)step));
221 Int_t species = track->GetAbInitioPID();
222 if(species >= AliPID::kSPECIES) species = -1;
223 AliHFEpidObject::AnalysisType_t anatype = track->IsESDanalysis() ? AliHFEpidObject::kESDanalysis : AliHFEpidObject::kAODanalysis;
225 AliHFEpidTRD *trdpid = dynamic_cast<AliHFEpidTRD *>(fQAmanager->GetDetectorPID(AliHFEpid::kTRDpid));
226 AliHFEpidTPC *tpcpid = dynamic_cast<AliHFEpidTPC *>(fQAmanager->GetDetectorPID(AliHFEpid::kTPCpid));
228 Double_t container[5];
229 container[0] = species;
230 container[1] = trdpid ? trdpid->GetP(track->GetRecTrack(), anatype) : 0.;
231 container[2] = tpcpid ? tpcpid->NumberOfSigmas(track->GetRecTrack(), AliPID::kElectron, anatype) : 0.;
233 container[4] = track->GetCentrality();
234 fHistos->Fill("hTPCsigma", container);
236 container[2] = trdpid ? trdpid->GetElectronLikelihood(track->GetRecTrack(), anatype) : 0;
237 fHistos->Fill("hTRDlikelihood", container);
239 if(track->IsESDanalysis()){
240 container[2] = trdpid ? trdpid->GetTRDSignalV1(dynamic_cast<const AliESDtrack *>(track->GetRecTrack())) : 0;
241 fHistos->Fill("hTRDtruncatedMean", container);
243 for(UInt_t ily = 0; ily < 6; ily++){
244 container[2] = trdpid ? trdpid->GetChargeLayer(track->GetRecTrack(), ily, anatype) : 0;
245 fHistos->Fill("hTRDcharge", container);
249 //_________________________________________________________
250 TH2 *AliHFEtrdPIDqaV1::MakeTPCspectrumNsigma(AliHFEdetPIDqa::EStep_t step, Int_t species){
252 // Get the TPC control histogram for the TRD selection step (either before or after PID)
254 THnSparseF *histo = dynamic_cast<THnSparseF *>(fHistos->Get("hTPCsigma"));
256 AliError("QA histogram monitoring TPC nSigma not available");
259 if(species > -1 && species < AliPID::kSPECIES){
260 // cut on species (if available)
261 histo->GetAxis(0)->SetRange(species + 2, species + 2); // undef + underflow
263 histo->GetAxis(3)->SetRange(step + 1, step + 1);
265 TH2 *hSpec = histo->Projection(2, 1);
266 // construct title and name
267 TString stepname = step == AliHFEdetPIDqa::kBeforePID ? "before" : "after";
268 TString speciesname = species > -1 && species < AliPID::kSPECIES ? AliPID::ParticleName(species) : "all Particles";
269 TString specID = species > -1 && species < AliPID::kSPECIES ? AliPID::ParticleName(species) : "unid";
270 TString histname = Form("hSigmaTPC%s%s", specID.Data(), stepname.Data());
271 TString histtitle = Form("TPC Sigma for %s %s PID", speciesname.Data(), stepname.Data());
272 hSpec->SetName(histname.Data());
273 hSpec->SetTitle(histtitle.Data());
275 // Unset range on the original histogram
276 histo->GetAxis(0)->SetRange(0, histo->GetAxis(0)->GetNbins());
277 histo->GetAxis(2)->SetRange(0, histo->GetAxis(2)->GetNbins());
281 //_________________________________________________________
282 TH2 *AliHFEtrdPIDqaV1::MakeTRDspectrumTM(AliHFEdetPIDqa::EStep_t step, Int_t species){
284 // Get the TPC control histogram for the TRD selection step (either before or after PID)
286 THnSparseF *histo = dynamic_cast<THnSparseF *>(fHistos->Get("hTRDtruncatedMean"));
288 AliError("QA histogram monitoring TPC nSigma not available");
291 if(species > -1 && species < AliPID::kSPECIES){
292 // cut on species (if available)
293 histo->GetAxis(0)->SetRange(species + 2, species + 2); // undef + underflow
295 histo->GetAxis(3)->SetRange(step + 1, step + 1);
297 TH2 *hSpec = histo->Projection(2, 1);
298 // construct title and name
299 TString stepname = step == AliHFEdetPIDqa::kBeforePID ? "before" : "after";
300 TString speciesname = species > -1 && species < AliPID::kSPECIES ? AliPID::ParticleName(species) : "all Particles";
301 TString specID = species > -1 && species < AliPID::kSPECIES ? AliPID::ParticleName(species) : "unid";
302 TString histname = Form("hTMTRD%s%s", specID.Data(), stepname.Data());
303 TString histtitle = Form("TRD Truncated Mean for %s %s PID", speciesname.Data(), stepname.Data());
304 hSpec->SetName(histname.Data());
305 hSpec->SetTitle(histtitle.Data());
307 // Unset range on the original histogram
308 histo->GetAxis(0)->SetRange(0, histo->GetAxis(0)->GetNbins());
309 histo->GetAxis(2)->SetRange(0, histo->GetAxis(2)->GetNbins());
313 //_________________________________________________________
314 TH2 *AliHFEtrdPIDqaV1::MakeTRDlikelihoodDistribution(AliHFEdetPIDqa::EStep_t step, Int_t species){
316 // Make Histogram for TRD Likelihood distribution
318 THnSparseF *histo = dynamic_cast<THnSparseF *>(fHistos->Get("hTRDlikelihood"));
320 AliError("QA histogram monitoring TRD Electron Likelihood not available");
323 if(species > -1 && species < AliPID::kSPECIES){
324 // cut on species (if available)
325 histo->GetAxis(0)->SetRange(species + 2, species + 2); // undef + underflow
327 histo->GetAxis(3)->SetRange(step + 1, step + 1);
329 TH2 *hSpec = histo->Projection(2, 1);
330 // construct title and name
331 TString stepname = step == AliHFEdetPIDqa::kBeforePID ? "before" : "after";
332 TString speciesname = species > -1 && species < AliPID::kSPECIES ? AliPID::ParticleName(species) : "all Particles";
333 TString specID = species > -1 && species < AliPID::kSPECIES ? AliPID::ParticleName(species) : "unid";
334 TString histname = Form("hLikeElTRD%s%s", specID.Data(), stepname.Data());
335 TString histtitle = Form("TRD electron Likelihood for %s %s PID", speciesname.Data(), stepname.Data());
336 hSpec->SetName(histname.Data());
337 hSpec->SetTitle(histtitle.Data());
339 // Unset range on the original histogram
340 histo->GetAxis(0)->SetRange(0, histo->GetAxis(0)->GetNbins());
341 histo->GetAxis(2)->SetRange(0, histo->GetAxis(2)->GetNbins());
345 //_________________________________________________________
346 TH2 *AliHFEtrdPIDqaV1::MakeTRDchargeDistribution(AliHFEdetPIDqa::EStep_t step, Int_t species){
348 // Make Histogram for TRD Likelihood distribution
350 THnSparseF *histo = dynamic_cast<THnSparseF *>(fHistos->Get("hTRDcharge"));
352 AliError("QA histogram monitoring TRD total charge 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 histo->GetAxis(3)->SetRange(step + 1, step + 1);
361 TH2 *hSpec = histo->Projection(2, 1);
362 // construct title and name
363 TString stepname = step == AliHFEdetPIDqa::kBeforePID ? "before" : "after";
364 TString speciesname = species > -1 && species < AliPID::kSPECIES ? AliPID::ParticleName(species) : "all Particles";
365 TString specID = species > -1 && species < AliPID::kSPECIES ? AliPID::ParticleName(species) : "unid";
366 TString histname = Form("hChargeTRD%s%s", specID.Data(), stepname.Data());
367 TString histtitle = Form("TRD total charge for %s %s PID", speciesname.Data(), stepname.Data());
368 hSpec->SetName(histname.Data());
369 hSpec->SetTitle(histtitle.Data());
371 // Unset range on the original histogram
372 histo->GetAxis(0)->SetRange(0, histo->GetAxis(0)->GetNbins());
373 histo->GetAxis(2)->SetRange(0, histo->GetAxis(2)->GetNbins());