]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG3/hfe/AliHFEtpcPIDqa.cxx
Commit modifications done to take care of the problems
[u/mrichter/AliRoot.git] / PWG3 / hfe / AliHFEtpcPIDqa.cxx
CommitLineData
3a72645a 1/**************************************************************************
2* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3* *
4* Author: The ALICE Off-line Project. *
5* Contributors are mentioned in the code where appropriate. *
6* *
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**************************************************************************/
15//
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
25//
26// Author:
27// Markus Fasel <M.Fasel@gsi.de>
28//
bf892a6a 29#include <TBrowser.h>
3a72645a 30#include <TClass.h>
31#include <TH2.h>
32#include <THnSparse.h>
33#include <TString.h>
34
35#include "AliAODTrack.h"
36#include "AliESDtrack.h"
37#include "AliESDpid.h"
38#include "AliLog.h"
39#include "AliPID.h"
40
41#include "AliHFEcollection.h"
42#include "AliHFEpidBase.h"
6555e2ad 43#include "AliHFEpidQAmanager.h"
44#include "AliHFEpidTPC.h"
3a72645a 45#include "AliHFEtools.h"
46#include "AliHFEtpcPIDqa.h"
47
6555e2ad 48ClassImp(AliHFEtpcPIDqa)
49
3a72645a 50//_________________________________________________________
51AliHFEtpcPIDqa::AliHFEtpcPIDqa():
52 AliHFEdetPIDqa()
53 , fHistos(NULL)
54{
55 //
56 // Dummy constructor
57 //
58}
59
60//_________________________________________________________
61AliHFEtpcPIDqa::AliHFEtpcPIDqa(const char* name):
62 AliHFEdetPIDqa(name, "QA for TPC")
63 , fHistos(NULL)
64{
65 //
66 // Default constructor
67 //
68}
69
70//_________________________________________________________
71AliHFEtpcPIDqa::AliHFEtpcPIDqa(const AliHFEtpcPIDqa &o):
72 AliHFEdetPIDqa(o)
71478e06 73 , fHistos(NULL)
3a72645a 74{
75 //
76 // Copy constructor
77 //
78 o.Copy(*this);
79}
80
81//_________________________________________________________
82AliHFEtpcPIDqa &AliHFEtpcPIDqa::operator=(const AliHFEtpcPIDqa &o){
83 //
84 // Do assignment
85 //
86 AliHFEdetPIDqa::operator=(o);
87 if(&o != this) o.Copy(*this);
88 return *this;
89}
90
91//_________________________________________________________
92AliHFEtpcPIDqa::~AliHFEtpcPIDqa(){
93 //
94 // Destructor
95 //
96 if(fHistos) delete fHistos;
97}
98
99//_________________________________________________________
100void AliHFEtpcPIDqa::Copy(TObject &o) const {
101 //
102 // Make copy
103 //
104 AliHFEtpcPIDqa &target = dynamic_cast<AliHFEtpcPIDqa &>(o);
105 if(target.fHistos){
106 delete target.fHistos;
107 target.fHistos = NULL;
108 }
109 if(fHistos) target.fHistos = new AliHFEcollection(*fHistos);
110}
111
112//_________________________________________________________
113Long64_t AliHFEtpcPIDqa::Merge(TCollection *coll){
114 //
115 // Merge with other objects
116 //
117 if(!coll) return 0;
118 if(coll->IsEmpty()) return 1;
119
120 TIter it(coll);
121 AliHFEtpcPIDqa *refQA = NULL;
122 TObject *o = NULL;
123 Long64_t count = 0;
124 TList listHistos;
125 while((o = it())){
126 refQA = dynamic_cast<AliHFEtpcPIDqa *>(o);
127 if(!refQA) continue;
128
129 listHistos.Add(refQA->fHistos);
130 count++;
131 }
132 fHistos->Merge(&listHistos);
133 return count + 1;
134}
135
bf892a6a 136//_________________________________________________________
137void AliHFEtpcPIDqa::Browse(TBrowser *b){
138 //
139 // Browse the PID QA
140 //
141 if(b){
142 if(fHistos){
143 b->Add(fHistos, fHistos->GetName());
144
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();
152
153 TH2 *hptr = NULL;
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"));
158 listdEdx->Add(hptr);
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);
162 }
163 }
164
165 b->Add(listdEdx, "Projections dE/dx");
166 b->Add(listNsigma, "Projections NSigma");
167 }
168 }
169}
170
3a72645a 171//_________________________________________________________
172void AliHFEtpcPIDqa::Initialize(){
173 //
174 // Define Histograms
175 //
176
177 fHistos = new AliHFEcollection("tpcqahistos", "Collection of TPC QA histograms");
178
179 // Make common binning
180 const Int_t kNdim = 5;
181 const Int_t kPIDbins = AliPID::kSPECIES + 1;
3a72645a 182 const Int_t kSteps = 2;
6555e2ad 183 const Int_t kCentralityBins = 11;
3a72645a 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.;
bf892a6a 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;
192
3a72645a 193 // 1st histogram: TPC dEdx: (species, p, dEdx, step)
3a72645a 194 Int_t nBinsdEdx[kNdim] = {kPIDbins, kPbins, kDedxbins, kSteps, kCentralityBins};
195 Double_t mindEdx[kNdim] = {kMinPID, kMinP, 0., 0., 0.};
6555e2ad 196 Double_t maxdEdx[kNdim] = {kMaxPID, kMaxP, 200, 2., 11.};
3a72645a 197 fHistos->CreateTHnSparse("tpcDedx", "TPC signal; species; p [GeV/c]; TPC signal [a.u.]; Centrality; Selection Step", kNdim, nBinsdEdx, mindEdx, maxdEdx);
198 // 2nd histogram: TPC sigmas: (species, p nsigma, step)
3a72645a 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., 100.};
202 fHistos->CreateTHnSparse("tpcnSigma", "TPC signal; species; p [GeV/c]; TPC signal [a.u.]; Centrality; Selection Step", kNdim, nBinsSigma, minSigma, maxSigma);
203
204 // General TPC QA
205}
206
207//_________________________________________________________
6555e2ad 208void AliHFEtpcPIDqa::ProcessTrack(const AliHFEpidObject *track, AliHFEdetPIDqa::EStep_t step){
3a72645a 209 //
210 // Fill TPC histograms
211 //
212 AliDebug(1, Form("QA started for TPC PID for step %d", (Int_t)step));
6555e2ad 213 AliHFEpidObject::AnalysisType_t anatype = track->IsESDanalysis() ? AliHFEpidObject::kESDanalysis : AliHFEpidObject::kAODanalysis;
3a72645a 214 Float_t centrality = track->GetCentrality();
6555e2ad 215 Int_t species = track->GetAbInitioPID();
3a72645a 216 if(species >= AliPID::kSPECIES) species = -1;
3a72645a 217
6555e2ad 218 AliHFEpidTPC *tpcpid = dynamic_cast<AliHFEpidTPC *>(fQAmanager->GetDetectorPID(AliHFEpid::kTPCpid));
3a72645a 219 Double_t contentSignal[5];
220 contentSignal[0] = species;
bf892a6a 221 contentSignal[1] = tpcpid ? tpcpid->GetP(track->GetRecTrack(), anatype) : 0.;
6555e2ad 222 contentSignal[2] = GetTPCsignal(track->GetRecTrack(), anatype);
3a72645a 223 contentSignal[3] = step;
224 contentSignal[4] = centrality;
bf892a6a 225 fHistos->Fill("tpcDedx", contentSignal);
3a72645a 226
bf892a6a 227 contentSignal[2] = tpcpid ? tpcpid->NumberOfSigmas(track->GetRecTrack(), AliPID::kElectron, anatype) : 0.;
228 fHistos->Fill("tpcnSigma", contentSignal);
3a72645a 229}
230
231//_________________________________________________________
6555e2ad 232Double_t AliHFEtpcPIDqa::GetTPCsignal(const AliVParticle *track, AliHFEpidObject::AnalysisType_t anatype){
3a72645a 233 //
6555e2ad 234 // Get TPC signal for ESD and AOD track
3a72645a 235 //
6555e2ad 236 Double_t tpcSignal = 0.;
237 if(anatype == AliHFEpidObject::kESDanalysis){
238 const AliESDtrack *esdtrack = dynamic_cast<const AliESDtrack *>(track);
239 tpcSignal = esdtrack->GetTPCsignal();
240 } else {
241 const AliAODTrack *aodtrack = dynamic_cast<const AliAODTrack *>(track);
242 tpcSignal = aodtrack->GetDetPid() ? aodtrack->GetDetPid()->GetTPCsignal() : 0.;
243 }
244 return tpcSignal;
3a72645a 245}
246
247//_________________________________________________________
248TH2 *AliHFEtpcPIDqa::MakeSpectrumdEdx(AliHFEdetPIDqa::EStep_t istep, Int_t species){
249 //
250 // Plot the Spectrum
251 //
252 THnSparseF *hSignal = dynamic_cast<THnSparseF *>(fHistos->Get("tpcDedx"));
bf892a6a 253 if(!hSignal) return NULL;
3a72645a 254 hSignal->GetAxis(3)->SetRange(istep + 1, istep + 1);
bf892a6a 255 if(species >= 0 && species < AliPID::kSPECIES)
3a72645a 256 hSignal->GetAxis(0)->SetRange(2 + species, 2 + species);
257 TH2 *hTmp = hSignal->Projection(2,1);
bf892a6a 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");
3a72645a 260 if(species > -1){
bf892a6a 261 hname += AliPID::ParticleName(species);
262 htitle += Form(" for %ss", AliPID::ParticleName(species));
3a72645a 263 }
bf892a6a 264 hTmp->SetName(hname.Data());
265 hTmp->SetTitle(htitle.Data());
3a72645a 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());
271 return hTmp;
272}
273
274//_________________________________________________________
275TH2 *AliHFEtpcPIDqa::MakeSpectrumNSigma(AliHFEdetPIDqa::EStep_t istep, Int_t species){
276 //
277 // Plot the Spectrum
278 //
279 THnSparseF *hSignal = dynamic_cast<THnSparseF *>(fHistos->Get("tpcnSigma"));
bf892a6a 280 if(!hSignal) return NULL;
3a72645a 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);
bf892a6a 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");
3a72645a 287 if(species > -1){
bf892a6a 288 hname += AliPID::ParticleName(species);
289 htitle += Form(" for %ss", AliPID::ParticleName(species));
3a72645a 290 }
bf892a6a 291 hTmp->SetName(hname.Data());
292 hTmp->SetTitle(htitle.Data());
3a72645a 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());
298 return hTmp;
299}
300