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 AliHFEtpcPIDqa
17 // Monitoring TPC PID in the HFE PID montioring framework. The following
18 // quantities are monitored:
19 // TPC dE/dx (Number of sigmas)
20 // TPC dE/dx (Absolute values)
21 // (Always as function of momentum, particle species and centrality
22 // before and after cut)
23 // More information about the PID monitoring framework can be found in
24 // AliHFEpidQAmanager.cxx and AliHFEdetPIDqa.cxx
27 // Markus Fasel <M.Fasel@gsi.de>
32 #include <THnSparse.h>
35 #include "AliAODEvent.h"
36 #include "AliAODTrack.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 "AliHFEtools.h"
47 #include "AliHFEtpcPIDqa.h"
49 ClassImp(AliHFEtpcPIDqa)
51 //_________________________________________________________
52 AliHFEtpcPIDqa::AliHFEtpcPIDqa():
55 , fBrowseCentrality(-1)
62 //_________________________________________________________
63 AliHFEtpcPIDqa::AliHFEtpcPIDqa(const char* name):
64 AliHFEdetPIDqa(name, "QA for TPC")
66 , fBrowseCentrality(-1)
69 // Default constructor
73 //_________________________________________________________
74 AliHFEtpcPIDqa::AliHFEtpcPIDqa(const AliHFEtpcPIDqa &o):
77 , fBrowseCentrality(o.fBrowseCentrality)
85 //_________________________________________________________
86 AliHFEtpcPIDqa &AliHFEtpcPIDqa::operator=(const AliHFEtpcPIDqa &o){
90 AliHFEdetPIDqa::operator=(o);
91 if(&o != this) o.Copy(*this);
95 //_________________________________________________________
96 AliHFEtpcPIDqa::~AliHFEtpcPIDqa(){
100 if(fHistos) delete fHistos;
103 //_________________________________________________________
104 void AliHFEtpcPIDqa::Copy(TObject &o) const {
108 AliHFEtpcPIDqa &target = dynamic_cast<AliHFEtpcPIDqa &>(o);
110 delete target.fHistos;
111 target.fHistos = NULL;
113 if(fHistos) target.fHistos = new AliHFEcollection(*fHistos);
114 target.fBrowseCentrality = fBrowseCentrality;
117 //_________________________________________________________
118 Long64_t AliHFEtpcPIDqa::Merge(TCollection *coll){
120 // Merge with other objects
123 if(coll->IsEmpty()) return 1;
126 AliHFEtpcPIDqa *refQA = NULL;
131 refQA = dynamic_cast<AliHFEtpcPIDqa *>(o);
134 listHistos.Add(refQA->fHistos);
137 fHistos->Merge(&listHistos);
141 //_________________________________________________________
142 void AliHFEtpcPIDqa::Browse(TBrowser *b){
148 b->Add(fHistos, fHistos->GetName());
150 // Make Projections of the dE/dx Spectra and add them to a new Folder
151 TString specnames[AliPID::kSPECIES+1] = {"All", "Electrons", "Muon", "Pions", "Kaon", "Protons"};
152 Int_t specind[AliPID::kSPECIES+1] = {-1, AliPID::kElectron, AliPID::kMuon, AliPID::kPion, AliPID::kKaon, AliPID::kProton};
153 TList *listdEdx = new TList;
154 listdEdx->SetOwner();
155 TList *listNsigma = new TList;
156 listNsigma->SetOwner();
159 for(Int_t ispec = 0; ispec < AliPID::kSPECIES+1; ispec++){
160 for(Int_t istep = 0; istep < 2; istep++){
161 hptr = MakeSpectrumdEdx(static_cast<AliHFEdetPIDqa::EStep_t>(istep), specind[ispec], fBrowseCentrality);
162 hptr->SetName(Form("hTPCdEdx%s%s%s", specnames[ispec].Data(), istep == 0 ? "Before" : "After" , fBrowseCentrality == -1 ? "MinBias" : Form("Cent%d", fBrowseCentrality)));
164 hptr = MakeSpectrumNSigma(static_cast<AliHFEdetPIDqa::EStep_t>(istep), specind[ispec], fBrowseCentrality);
165 hptr->SetName(Form("hTPCnsigma%s%s%s", specnames[ispec].Data(), istep == 0 ? "Before" : "After", fBrowseCentrality == -1 ? "MinBias" : Form("Cent%d", fBrowseCentrality)));
166 listNsigma->Add(hptr);
170 b->Add(listdEdx, "Projections dE/dx");
171 b->Add(listNsigma, "Projections NSigma");
176 //_________________________________________________________
177 void AliHFEtpcPIDqa::Initialize(){
182 fHistos = new AliHFEcollection("tpcqahistos", "Collection of TPC QA histograms");
184 // Make common binning
185 const Int_t kNdim = 7;
186 const Int_t kPIDbins = AliPID::kSPECIES + 1;
187 const Int_t kSteps = 2;
188 const Int_t kCentralityBins = 11;
189 const Double_t kMinPID = -1;
190 const Double_t kMinP = 0.;
191 const Double_t kMaxPID = (Double_t)AliPID::kSPECIES;
192 const Double_t kMaxP = 20.;
193 const Double_t kMinEta = -0.9;
194 const Double_t kMaxEta = 0.9;
196 // Quantities where one can switch between low and high resolution
197 Int_t kPbins = (fQAmanager->HasHighResolutionHistos() || fQAmanager->HasMidResolutionHistos()) ? 1000 : 100;
198 Int_t kDedxbins = fQAmanager->HasHighResolutionHistos() ? 400 : 200;
199 Int_t kSigmaBins = fQAmanager->HasHighResolutionHistos() ? 1400 : 240;
200 kSigmaBins = fQAmanager->HasMidResolutionHistos() ? 400 : kSigmaBins;
201 Int_t kEtabins = fQAmanager->HasHighResolutionEtaHistos() ? 33 : 18;
203 // 1st histogram: TPC dEdx: (species, p, dEdx, step)
204 Int_t nBinsdEdx[kNdim] = {kPIDbins, kPbins, kDedxbins, kSteps, kCentralityBins, kEtabins, 33};
205 Double_t mindEdx[kNdim] = {kMinPID, kMinP, 20., 0., 0., kMinEta, 0};
206 Double_t maxdEdx[kNdim] = {kMaxPID, kMaxP, 130, 2., 11., kMaxEta, 2000};
207 fHistos->CreateTHnSparse("tpcDedx", "TPC signal; species; p [GeV/c]; TPC signal [a.u.]; Selection Step; Centrality; Eta; pVx contrib", kNdim, nBinsdEdx, mindEdx, maxdEdx);
209 // 2nd histogram: TPC sigmas: (species, p nsigma, step)
210 Int_t nBinsSigma[kNdim] = {kPIDbins, kPbins, kSigmaBins, kSteps, kCentralityBins, kEtabins, 33};
211 Double_t minSigma[kNdim] = {kMinPID, kMinP, -12., 0., 0., kMinEta, 0};
212 Double_t maxSigma[kNdim] = {kMaxPID, kMaxP, 12., 2., 11., kMaxEta, 2000};
213 fHistos->CreateTHnSparse("tpcnSigma", "TPC signal; species; p [GeV/c]; TPC signal [a.u.]; Selection Step; Centrality; Eta; pVx contrib", kNdim, nBinsSigma, minSigma, maxSigma);
218 //_________________________________________________________
219 void AliHFEtpcPIDqa::ProcessTrack(const AliHFEpidObject *track, AliHFEdetPIDqa::EStep_t step){
221 // Fill TPC histograms
223 AliDebug(1, Form("QA started for TPC PID for step %d", (Int_t)step));
224 AliHFEpidObject::AnalysisType_t anatype = track->IsESDanalysis() ? AliHFEpidObject::kESDanalysis : AliHFEpidObject::kAODanalysis;
225 Int_t species = track->GetAbInitioPID();
226 if(species >= AliPID::kSPECIES) species = -1;
228 AliHFEpidTPC *tpcpid = dynamic_cast<AliHFEpidTPC *>(fQAmanager->GetDetectorPID(AliHFEpid::kTPCpid));
229 const AliPIDResponse *pidResponse = tpcpid ? tpcpid->GetPIDResponse() : NULL;
230 Double_t contentSignal[7];
231 contentSignal[0] = species;
232 contentSignal[1] = tpcpid ? tpcpid->GetP(track->GetRecTrack(), anatype) : 0.;
233 contentSignal[2] = GetTPCsignal(track->GetRecTrack(), anatype);
234 contentSignal[3] = step;
235 contentSignal[4] = track->GetCentrality();
236 contentSignal[5] = GetEta(track->GetRecTrack(), anatype);
237 contentSignal[6] = fQAmanager->HasFillMultiplicity() ? track->GetMultiplicity() : 0;
238 fHistos->Fill("tpcDedx", contentSignal);
240 if(track->HasCorrectedTPCnSigma())
241 contentSignal[2] = track->GetCorrectedTPCnSigma();
243 contentSignal[2] = pidResponse ? pidResponse->NumberOfSigmasTPC(track->GetRecTrack(), AliPID::kElectron) : -100.;
245 fHistos->Fill("tpcnSigma", contentSignal);
248 //_________________________________________________________
249 Double_t AliHFEtpcPIDqa::GetTPCsignal(const AliVParticle *track, AliHFEpidObject::AnalysisType_t anatype){
251 // Get TPC signal for ESD and AOD track
253 Double_t tpcSignal = 0.;
254 if(anatype == AliHFEpidObject::kESDanalysis){
255 const AliESDtrack *esdtrack = static_cast<const AliESDtrack *>(track);
256 tpcSignal = esdtrack->GetTPCsignal();
258 const AliAODTrack *aodtrack = static_cast<const AliAODTrack *>(track);
259 tpcSignal = aodtrack->GetDetPid() ? aodtrack->GetDetPid()->GetTPCsignal() : 0.;
265 //_________________________________________________________
266 Double_t AliHFEtpcPIDqa::GetEta(const AliVParticle *track, AliHFEpidObject::AnalysisType_t anatype){
268 // Get TPC signal for ESD and AOD track
271 if(anatype == AliHFEpidObject::kESDanalysis){
272 const AliESDtrack *esdtrack = static_cast<const AliESDtrack *>(track);
273 eta = esdtrack->Eta();
275 const AliAODTrack *aodtrack = static_cast<const AliAODTrack *>(track);
276 eta = aodtrack->Eta();
281 //_________________________________________________________
282 TH2 *AliHFEtpcPIDqa::MakeSpectrumdEdx(AliHFEdetPIDqa::EStep_t istep, Int_t species, Int_t centralityClass){
286 THnSparseF *hSignal = dynamic_cast<THnSparseF *>(fHistos->Get("tpcDedx"));
287 if(!hSignal) return NULL;
288 hSignal->GetAxis(3)->SetRange(istep + 1, istep + 1);
289 if(species >= 0 && species < AliPID::kSPECIES)
290 hSignal->GetAxis(0)->SetRange(2 + species, 2 + species);
291 TString hname = Form("hTPCsignal%s", istep == AliHFEdetPIDqa::kBeforePID ? "before" : "after"),
292 htitle = Form("TPC dE/dx Spectrum %s selection", istep == AliHFEdetPIDqa::kBeforePID ? "before" : "after");
294 hname += AliPID::ParticleName(species);
295 htitle += Form(" for %ss", AliPID::ParticleName(species));
297 TString centname, centtitle;
298 Bool_t hasCentralityInfo = kTRUE;
299 if(centralityClass > -1){
300 if(hSignal->GetNdimensions() < 5){
301 AliError("Centrality Information not available");
302 centname = centtitle = "MinBias";
303 hasCentralityInfo= kFALSE;
305 // Project centrality classes
307 hSignal->GetAxis(4)->SetRange(centralityClass+1, centralityClass+1);
308 centname = Form("Cent%d", centralityClass);
309 centtitle = Form(" Centrality %d", centralityClass);
312 centname = centtitle = "MinBias";
313 hasCentralityInfo= kFALSE;
318 TH2 *hTmp = hSignal->Projection(2,1);
319 hTmp->SetName(hname.Data());
320 hTmp->SetTitle(htitle.Data());
321 hTmp->SetStats(kFALSE);
322 hTmp->GetXaxis()->SetTitle("p [GeV/c]");
323 hTmp->GetYaxis()->SetTitle("TPC signal [a.u.]");
324 hSignal->GetAxis(3)->SetRange(0, hSignal->GetAxis(3)->GetNbins());
325 hSignal->GetAxis(0)->SetRange(0, hSignal->GetAxis(0)->GetNbins());
326 if(hasCentralityInfo) hSignal->GetAxis(4)->SetRange(0, hSignal->GetAxis(4)->GetNbins());
330 //_________________________________________________________
331 TH2 *AliHFEtpcPIDqa::MakeSpectrumNSigma(AliHFEdetPIDqa::EStep_t istep, Int_t species, Int_t centralityClass){
335 THnSparseF *hSignal = dynamic_cast<THnSparseF *>(fHistos->Get("tpcnSigma"));
336 if(!hSignal) return NULL;
337 hSignal->GetAxis(3)->SetRange(istep + 1, istep + 1);
338 if(species >= 0 && species < AliPID::kSPECIES)
339 hSignal->GetAxis(0)->SetRange(2 + species, 2 + species);
340 TString hname = Form("hTPCsigma%s", istep == AliHFEdetPIDqa::kBeforePID ? "before" : "after"),
341 htitle = Form("TPC dE/dx Spectrum[#sigma] %s selection", istep == AliHFEdetPIDqa::kBeforePID ? "before" : "after");
343 hname += AliPID::ParticleName(species);
344 htitle += Form(" for %ss", AliPID::ParticleName(species));
346 TString centname, centtitle;
347 Bool_t hasCentralityInfo = kTRUE;
348 if(centralityClass > -1){
349 if(hSignal->GetNdimensions() < 5){
350 AliError("Centrality Information not available");
351 centname = centtitle = "MinBias";
352 hasCentralityInfo= kFALSE;
354 // Project centrality classes
356 hSignal->GetAxis(4)->SetRange(centralityClass+1, centralityClass+1);
357 centname = Form("Cent%d", centralityClass);
358 centtitle = Form(" Centrality %d", centralityClass);
361 centname = centtitle = "MinBias";
362 hasCentralityInfo= kFALSE;
367 TH2 *hTmp = hSignal->Projection(2,1);
368 hTmp->SetName(hname.Data());
369 hTmp->SetTitle(htitle.Data());
370 hTmp->SetStats(kFALSE);
371 hTmp->GetXaxis()->SetTitle("p [GeV/c]");
372 hTmp->GetYaxis()->SetTitle("TPC dE/dx - <dE/dx>|_{el} [#sigma]");
373 hSignal->GetAxis(3)->SetRange(0, hSignal->GetAxis(3)->GetNbins());
374 hSignal->GetAxis(0)->SetRange(0, hSignal->GetAxis(0)->GetNbins());
375 if(hasCentralityInfo) hSignal->GetAxis(4)->SetRange(0, hSignal->GetAxis(4)->GetNbins());