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 "AliAODTrack.h"
36 #include "AliESDtrack.h"
37 #include "AliESDpid.h"
41 #include "AliHFEcollection.h"
42 #include "AliHFEpidBase.h"
43 #include "AliHFEpidQAmanager.h"
44 #include "AliHFEpidTPC.h"
45 #include "AliHFEtools.h"
46 #include "AliHFEtpcPIDqa.h"
48 ClassImp(AliHFEtpcPIDqa)
50 //_________________________________________________________
51 AliHFEtpcPIDqa::AliHFEtpcPIDqa():
60 //_________________________________________________________
61 AliHFEtpcPIDqa::AliHFEtpcPIDqa(const char* name):
62 AliHFEdetPIDqa(name, "QA for TPC")
66 // Default constructor
70 //_________________________________________________________
71 AliHFEtpcPIDqa::AliHFEtpcPIDqa(const AliHFEtpcPIDqa &o):
81 //_________________________________________________________
82 AliHFEtpcPIDqa &AliHFEtpcPIDqa::operator=(const AliHFEtpcPIDqa &o){
86 AliHFEdetPIDqa::operator=(o);
87 if(&o != this) o.Copy(*this);
91 //_________________________________________________________
92 AliHFEtpcPIDqa::~AliHFEtpcPIDqa(){
96 if(fHistos) delete fHistos;
99 //_________________________________________________________
100 void AliHFEtpcPIDqa::Copy(TObject &o) const {
104 AliHFEtpcPIDqa &target = dynamic_cast<AliHFEtpcPIDqa &>(o);
106 delete target.fHistos;
107 target.fHistos = NULL;
109 if(fHistos) target.fHistos = new AliHFEcollection(*fHistos);
112 //_________________________________________________________
113 Long64_t AliHFEtpcPIDqa::Merge(TCollection *coll){
115 // Merge with other objects
118 if(coll->IsEmpty()) return 1;
121 AliHFEtpcPIDqa *refQA = NULL;
126 refQA = dynamic_cast<AliHFEtpcPIDqa *>(o);
129 listHistos.Add(refQA->fHistos);
132 fHistos->Merge(&listHistos);
136 //_________________________________________________________
137 void AliHFEtpcPIDqa::Browse(TBrowser *b){
143 b->Add(fHistos, fHistos->GetName());
145 // Make Projections of the dE/dx Spectra and add them to a new Folder
146 TString specnames[4] = {"All", "Electrons", "Pions", "Protons"};
147 Int_t specind[4] = {-1, AliPID::kElectron, AliPID::kPion, AliPID::kProton};
148 TList *listdEdx = new TList;
149 listdEdx->SetOwner();
150 TList *listNsigma = new TList;
151 listNsigma->SetOwner();
154 for(Int_t ispec = 0; ispec < 4; ispec++){
155 for(Int_t istep = 0; istep < 2; istep++){
156 hptr = MakeSpectrumdEdx(static_cast<AliHFEdetPIDqa::EStep_t>(istep), specind[ispec]);
157 hptr->SetName(Form("hTPCdEdx%s%s", specnames[ispec].Data(), istep == 0 ? "Before" : "After"));
159 hptr = MakeSpectrumNSigma(static_cast<AliHFEdetPIDqa::EStep_t>(istep), specind[ispec]);
160 hptr->SetName(Form("hTPCnsigma%s%s", specnames[ispec].Data(), istep == 0 ? "Before" : "After"));
161 listNsigma->Add(hptr);
165 b->Add(listdEdx, "Projections dE/dx");
166 b->Add(listNsigma, "Projections NSigma");
171 //_________________________________________________________
172 void AliHFEtpcPIDqa::Initialize(){
177 fHistos = new AliHFEcollection("tpcqahistos", "Collection of TPC QA histograms");
179 // Make common binning
180 const Int_t kNdim = 5;
181 const Int_t kPIDbins = AliPID::kSPECIES + 1;
182 const Int_t kSteps = 2;
183 const Int_t kCentralityBins = 11;
184 const Double_t kMinPID = -1;
185 const Double_t kMinP = 0.;
186 const Double_t kMaxPID = (Double_t)AliPID::kSPECIES;
187 const Double_t kMaxP = 20.;
188 // Quantities where one can switch between low and high resolution
189 Int_t kPbins = fQAmanager->HasHighResolutionHistos() ? 1000 : 100;
190 Int_t kDedxbins = fQAmanager->HasHighResolutionHistos() ? 400 : 200;
191 Int_t kSigmaBins = fQAmanager->HasHighResolutionHistos() ? 1400 : 240;
193 // 1st histogram: TPC dEdx: (species, p, dEdx, step)
194 Int_t nBinsdEdx[kNdim] = {kPIDbins, kPbins, kDedxbins, kSteps, kCentralityBins};
195 Double_t mindEdx[kNdim] = {kMinPID, kMinP, 0., 0., 0.};
196 Double_t maxdEdx[kNdim] = {kMaxPID, kMaxP, 200, 2., 11.};
197 fHistos->CreateTHnSparse("tpcDedx", "TPC signal; species; p [GeV/c]; TPC signal [a.u.]; Selection Step; Centrality", kNdim, nBinsdEdx, mindEdx, maxdEdx);
198 // 2nd histogram: TPC sigmas: (species, p nsigma, step)
199 Int_t nBinsSigma[kNdim] = {kPIDbins, kPbins, kSigmaBins, kSteps, kCentralityBins};
200 Double_t minSigma[kNdim] = {kMinPID, kMinP, -12., 0., 0.};
201 Double_t maxSigma[kNdim] = {kMaxPID, kMaxP, 12., 2., 11.};
202 fHistos->CreateTHnSparse("tpcnSigma", "TPC signal; species; p [GeV/c]; TPC signal [a.u.]; Selection Step; Centrality", kNdim, nBinsSigma, minSigma, maxSigma);
207 //_________________________________________________________
208 void AliHFEtpcPIDqa::ProcessTrack(const AliHFEpidObject *track, AliHFEdetPIDqa::EStep_t step){
210 // Fill TPC histograms
212 AliDebug(1, Form("QA started for TPC PID for step %d", (Int_t)step));
213 AliHFEpidObject::AnalysisType_t anatype = track->IsESDanalysis() ? AliHFEpidObject::kESDanalysis : AliHFEpidObject::kAODanalysis;
214 Float_t centrality = track->GetCentrality();
215 Int_t species = track->GetAbInitioPID();
216 if(species >= AliPID::kSPECIES) species = -1;
218 AliHFEpidTPC *tpcpid = dynamic_cast<AliHFEpidTPC *>(fQAmanager->GetDetectorPID(AliHFEpid::kTPCpid));
219 Double_t contentSignal[5];
220 contentSignal[0] = species;
221 contentSignal[1] = tpcpid ? tpcpid->GetP(track->GetRecTrack(), anatype) : 0.;
222 contentSignal[2] = GetTPCsignal(track->GetRecTrack(), anatype);
223 contentSignal[3] = step;
224 contentSignal[4] = centrality;
225 fHistos->Fill("tpcDedx", contentSignal);
227 contentSignal[2] = tpcpid ? tpcpid->NumberOfSigmas(track->GetRecTrack(), AliPID::kElectron, anatype) : 0.;
228 fHistos->Fill("tpcnSigma", contentSignal);
231 //_________________________________________________________
232 Double_t AliHFEtpcPIDqa::GetTPCsignal(const AliVParticle *track, AliHFEpidObject::AnalysisType_t anatype){
234 // Get TPC signal for ESD and AOD track
236 Double_t tpcSignal = 0.;
237 if(anatype == AliHFEpidObject::kESDanalysis){
238 const AliESDtrack *esdtrack = static_cast<const AliESDtrack *>(track);
239 tpcSignal = esdtrack->GetTPCsignal();
241 const AliAODTrack *aodtrack = static_cast<const AliAODTrack *>(track);
242 tpcSignal = aodtrack->GetDetPid() ? aodtrack->GetDetPid()->GetTPCsignal() : 0.;
247 //_________________________________________________________
248 TH2 *AliHFEtpcPIDqa::MakeSpectrumdEdx(AliHFEdetPIDqa::EStep_t istep, Int_t species){
252 THnSparseF *hSignal = dynamic_cast<THnSparseF *>(fHistos->Get("tpcDedx"));
253 if(!hSignal) return NULL;
254 hSignal->GetAxis(3)->SetRange(istep + 1, istep + 1);
255 if(species >= 0 && species < AliPID::kSPECIES)
256 hSignal->GetAxis(0)->SetRange(2 + species, 2 + species);
257 TH2 *hTmp = hSignal->Projection(2,1);
258 TString hname = Form("hTPCsignal%s", istep == AliHFEdetPIDqa::kBeforePID ? "before" : "after"),
259 htitle = Form("TPC dE/dx Spectrum %s selection", istep == AliHFEdetPIDqa::kBeforePID ? "before" : "after");
261 hname += AliPID::ParticleName(species);
262 htitle += Form(" for %ss", AliPID::ParticleName(species));
264 hTmp->SetName(hname.Data());
265 hTmp->SetTitle(htitle.Data());
266 hTmp->SetStats(kFALSE);
267 hTmp->GetXaxis()->SetTitle("p [GeV/c]");
268 hTmp->GetYaxis()->SetTitle("TPC signal [a.u.]");
269 hSignal->GetAxis(3)->SetRange(0, hSignal->GetAxis(3)->GetNbins());
270 hSignal->GetAxis(0)->SetRange(0, hSignal->GetAxis(0)->GetNbins());
274 //_________________________________________________________
275 TH2 *AliHFEtpcPIDqa::MakeSpectrumNSigma(AliHFEdetPIDqa::EStep_t istep, Int_t species){
279 THnSparseF *hSignal = dynamic_cast<THnSparseF *>(fHistos->Get("tpcnSigma"));
280 if(!hSignal) return NULL;
281 hSignal->GetAxis(3)->SetRange(istep + 1, istep + 1);
282 if(species >= 0 && species < AliPID::kSPECIES)
283 hSignal->GetAxis(0)->SetRange(2 + species, 2 + species);
284 TH2 *hTmp = hSignal->Projection(2,1);
285 TString hname = Form("hTPCsigma%s", istep == AliHFEdetPIDqa::kBeforePID ? "before" : "after"),
286 htitle = Form("TPC dE/dx Spectrum[#sigma] %s selection", istep == AliHFEdetPIDqa::kBeforePID ? "before" : "after");
288 hname += AliPID::ParticleName(species);
289 htitle += Form(" for %ss", AliPID::ParticleName(species));
291 hTmp->SetName(hname.Data());
292 hTmp->SetTitle(htitle.Data());
293 hTmp->SetStats(kFALSE);
294 hTmp->GetXaxis()->SetTitle("p [GeV/c]");
295 hTmp->GetYaxis()->SetTitle("TPC dE/dx - <dE/dx>|_{el} [#sigma]");
296 hSignal->GetAxis(3)->SetRange(0, hSignal->GetAxis(3)->GetNbins());
297 hSignal->GetAxis(0)->SetRange(0, hSignal->GetAxis(0)->GetNbins());