]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGHF/hfe/AliHFEtpcPIDqa.cxx
Fix for R_ADDTASK error in AliAnalysisTaskCfg
[u/mrichter/AliRoot.git] / PWGHF / 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
bab17338 35#include "AliAODEvent.h"
3a72645a 36#include "AliAODTrack.h"
37#include "AliESDtrack.h"
3a72645a 38#include "AliLog.h"
39#include "AliPID.h"
8c1c76e9 40#include "AliPIDResponse.h"
3a72645a 41
42#include "AliHFEcollection.h"
43#include "AliHFEpidBase.h"
6555e2ad 44#include "AliHFEpidQAmanager.h"
45#include "AliHFEpidTPC.h"
3a72645a 46#include "AliHFEtools.h"
47#include "AliHFEtpcPIDqa.h"
48
6555e2ad 49ClassImp(AliHFEtpcPIDqa)
50
3a72645a 51//_________________________________________________________
52AliHFEtpcPIDqa::AliHFEtpcPIDqa():
53 AliHFEdetPIDqa()
54 , fHistos(NULL)
e156c3bb 55 , fBrowseCentrality(-1)
3a72645a 56{
57 //
58 // Dummy constructor
59 //
60}
61
62//_________________________________________________________
63AliHFEtpcPIDqa::AliHFEtpcPIDqa(const char* name):
64 AliHFEdetPIDqa(name, "QA for TPC")
65 , fHistos(NULL)
e156c3bb 66 , fBrowseCentrality(-1)
3a72645a 67{
68 //
69 // Default constructor
70 //
71}
72
73//_________________________________________________________
74AliHFEtpcPIDqa::AliHFEtpcPIDqa(const AliHFEtpcPIDqa &o):
75 AliHFEdetPIDqa(o)
71478e06 76 , fHistos(NULL)
e156c3bb 77 , fBrowseCentrality(o.fBrowseCentrality)
3a72645a 78{
79 //
80 // Copy constructor
81 //
82 o.Copy(*this);
83}
84
85//_________________________________________________________
86AliHFEtpcPIDqa &AliHFEtpcPIDqa::operator=(const AliHFEtpcPIDqa &o){
87 //
88 // Do assignment
89 //
90 AliHFEdetPIDqa::operator=(o);
91 if(&o != this) o.Copy(*this);
92 return *this;
93}
94
95//_________________________________________________________
96AliHFEtpcPIDqa::~AliHFEtpcPIDqa(){
97 //
98 // Destructor
99 //
100 if(fHistos) delete fHistos;
101}
102
103//_________________________________________________________
104void AliHFEtpcPIDqa::Copy(TObject &o) const {
105 //
106 // Make copy
107 //
108 AliHFEtpcPIDqa &target = dynamic_cast<AliHFEtpcPIDqa &>(o);
109 if(target.fHistos){
110 delete target.fHistos;
111 target.fHistos = NULL;
112 }
113 if(fHistos) target.fHistos = new AliHFEcollection(*fHistos);
e156c3bb 114 target.fBrowseCentrality = fBrowseCentrality;
3a72645a 115}
116
117//_________________________________________________________
118Long64_t AliHFEtpcPIDqa::Merge(TCollection *coll){
119 //
120 // Merge with other objects
121 //
122 if(!coll) return 0;
123 if(coll->IsEmpty()) return 1;
124
125 TIter it(coll);
126 AliHFEtpcPIDqa *refQA = NULL;
127 TObject *o = NULL;
128 Long64_t count = 0;
129 TList listHistos;
130 while((o = it())){
131 refQA = dynamic_cast<AliHFEtpcPIDqa *>(o);
132 if(!refQA) continue;
133
134 listHistos.Add(refQA->fHistos);
135 count++;
136 }
137 fHistos->Merge(&listHistos);
138 return count + 1;
139}
140
bf892a6a 141//_________________________________________________________
142void AliHFEtpcPIDqa::Browse(TBrowser *b){
143 //
144 // Browse the PID QA
145 //
146 if(b){
147 if(fHistos){
148 b->Add(fHistos, fHistos->GetName());
149
150 // Make Projections of the dE/dx Spectra and add them to a new Folder
c2690925 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};
bf892a6a 153 TList *listdEdx = new TList;
154 listdEdx->SetOwner();
155 TList *listNsigma = new TList;
156 listNsigma->SetOwner();
157
158 TH2 *hptr = NULL;
c2690925 159 for(Int_t ispec = 0; ispec < AliPID::kSPECIES+1; ispec++){
bf892a6a 160 for(Int_t istep = 0; istep < 2; istep++){
e156c3bb 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)));
bf892a6a 163 listdEdx->Add(hptr);
e156c3bb 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)));
bf892a6a 166 listNsigma->Add(hptr);
167 }
168 }
169
170 b->Add(listdEdx, "Projections dE/dx");
171 b->Add(listNsigma, "Projections NSigma");
172 }
173 }
174}
175
3a72645a 176//_________________________________________________________
177void AliHFEtpcPIDqa::Initialize(){
178 //
179 // Define Histograms
180 //
181
182 fHistos = new AliHFEcollection("tpcqahistos", "Collection of TPC QA histograms");
183
184 // Make common binning
bab17338 185 const Int_t kNdim = 7;
3a72645a 186 const Int_t kPIDbins = AliPID::kSPECIES + 1;
3a72645a 187 const Int_t kSteps = 2;
6555e2ad 188 const Int_t kCentralityBins = 11;
3a72645a 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.;
a8d09079 193 const Double_t kMinEta = -0.9;
194 const Double_t kMaxEta = 0.9;
195
bf892a6a 196 // Quantities where one can switch between low and high resolution
197 Int_t kPbins = fQAmanager->HasHighResolutionHistos() ? 1000 : 100;
198 Int_t kDedxbins = fQAmanager->HasHighResolutionHistos() ? 400 : 200;
199 Int_t kSigmaBins = fQAmanager->HasHighResolutionHistos() ? 1400 : 240;
bab17338 200 kSigmaBins = fQAmanager->HasMidResolutionHistos() ? 400 : kSigmaBins;
201 Int_t kEtabins = fQAmanager->HasHighResolutionEtaHistos() ? 27 : 18;
202
3a72645a 203 // 1st histogram: TPC dEdx: (species, p, dEdx, step)
bab17338 204 Int_t nBinsdEdx[kNdim] = {kPIDbins, kPbins, kDedxbins, kSteps, kCentralityBins, kEtabins, 50};
205 Double_t mindEdx[kNdim] = {kMinPID, kMinP, 20., 0., 0., kMinEta, 0};
206 Double_t maxdEdx[kNdim] = {kMaxPID, kMaxP, 160, 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);
208
3a72645a 209 // 2nd histogram: TPC sigmas: (species, p nsigma, step)
bab17338 210 Int_t nBinsSigma[kNdim] = {kPIDbins, kPbins, kSigmaBins, kSteps, kCentralityBins, kEtabins, 50};
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);
3a72645a 214
215 // General TPC QA
216}
217
218//_________________________________________________________
6555e2ad 219void AliHFEtpcPIDqa::ProcessTrack(const AliHFEpidObject *track, AliHFEdetPIDqa::EStep_t step){
3a72645a 220 //
221 // Fill TPC histograms
222 //
223 AliDebug(1, Form("QA started for TPC PID for step %d", (Int_t)step));
6555e2ad 224 AliHFEpidObject::AnalysisType_t anatype = track->IsESDanalysis() ? AliHFEpidObject::kESDanalysis : AliHFEpidObject::kAODanalysis;
3a72645a 225 Float_t centrality = track->GetCentrality();
6555e2ad 226 Int_t species = track->GetAbInitioPID();
3a72645a 227 if(species >= AliPID::kSPECIES) species = -1;
3a72645a 228
6555e2ad 229 AliHFEpidTPC *tpcpid = dynamic_cast<AliHFEpidTPC *>(fQAmanager->GetDetectorPID(AliHFEpid::kTPCpid));
8c1c76e9 230 const AliPIDResponse *pidResponse = tpcpid ? tpcpid->GetPIDResponse() : NULL;
d3a15def 231 Double_t contentSignal[7];
3a72645a 232 contentSignal[0] = species;
bf892a6a 233 contentSignal[1] = tpcpid ? tpcpid->GetP(track->GetRecTrack(), anatype) : 0.;
6555e2ad 234 contentSignal[2] = GetTPCsignal(track->GetRecTrack(), anatype);
3a72645a 235 contentSignal[3] = step;
236 contentSignal[4] = centrality;
a8d09079 237 contentSignal[5] = GetEta(track->GetRecTrack(), anatype);
bab17338 238 contentSignal[6] = fQAmanager->HasFillMultiplicity() ? track->GetMultiplicity() : 0;
bf892a6a 239 fHistos->Fill("tpcDedx", contentSignal);
3a72645a 240
f06b970d 241 contentSignal[2] = pidResponse ? pidResponse->NumberOfSigmasTPC(track->GetRecTrack(), AliPID::kElectron) : -100.;
bf892a6a 242 fHistos->Fill("tpcnSigma", contentSignal);
3a72645a 243}
244
245//_________________________________________________________
6555e2ad 246Double_t AliHFEtpcPIDqa::GetTPCsignal(const AliVParticle *track, AliHFEpidObject::AnalysisType_t anatype){
3a72645a 247 //
6555e2ad 248 // Get TPC signal for ESD and AOD track
3a72645a 249 //
6555e2ad 250 Double_t tpcSignal = 0.;
251 if(anatype == AliHFEpidObject::kESDanalysis){
215ffe88 252 const AliESDtrack *esdtrack = static_cast<const AliESDtrack *>(track);
6555e2ad 253 tpcSignal = esdtrack->GetTPCsignal();
254 } else {
215ffe88 255 const AliAODTrack *aodtrack = static_cast<const AliAODTrack *>(track);
6555e2ad 256 tpcSignal = aodtrack->GetDetPid() ? aodtrack->GetDetPid()->GetTPCsignal() : 0.;
257 }
258 return tpcSignal;
3a72645a 259}
260
a8d09079 261
262//_________________________________________________________
263Double_t AliHFEtpcPIDqa::GetEta(const AliVParticle *track, AliHFEpidObject::AnalysisType_t anatype){
264 //
265 // Get TPC signal for ESD and AOD track
266 //
267 Double_t eta = 0.;
268 if(anatype == AliHFEpidObject::kESDanalysis){
269 const AliESDtrack *esdtrack = static_cast<const AliESDtrack *>(track);
270 eta = esdtrack->Eta();
271 } else {
272 const AliAODTrack *aodtrack = static_cast<const AliAODTrack *>(track);
273 eta = aodtrack->Eta();
274 }
275 return eta;
276}
277
3a72645a 278//_________________________________________________________
e156c3bb 279TH2 *AliHFEtpcPIDqa::MakeSpectrumdEdx(AliHFEdetPIDqa::EStep_t istep, Int_t species, Int_t centralityClass){
3a72645a 280 //
281 // Plot the Spectrum
282 //
283 THnSparseF *hSignal = dynamic_cast<THnSparseF *>(fHistos->Get("tpcDedx"));
bf892a6a 284 if(!hSignal) return NULL;
3a72645a 285 hSignal->GetAxis(3)->SetRange(istep + 1, istep + 1);
bf892a6a 286 if(species >= 0 && species < AliPID::kSPECIES)
3a72645a 287 hSignal->GetAxis(0)->SetRange(2 + species, 2 + species);
bf892a6a 288 TString hname = Form("hTPCsignal%s", istep == AliHFEdetPIDqa::kBeforePID ? "before" : "after"),
289 htitle = Form("TPC dE/dx Spectrum %s selection", istep == AliHFEdetPIDqa::kBeforePID ? "before" : "after");
3a72645a 290 if(species > -1){
bf892a6a 291 hname += AliPID::ParticleName(species);
292 htitle += Form(" for %ss", AliPID::ParticleName(species));
3a72645a 293 }
e156c3bb 294 TString centname, centtitle;
295 Bool_t hasCentralityInfo = kTRUE;
296 if(centralityClass > -1){
297 if(hSignal->GetNdimensions() < 5){
298 AliError("Centrality Information not available");
299 centname = centtitle = "MinBias";
300 hasCentralityInfo= kFALSE;
301 } else {
302 // Project centrality classes
303 // -1 is Min. Bias
304 hSignal->GetAxis(4)->SetRange(centralityClass+1, centralityClass+1);
305 centname = Form("Cent%d", centralityClass);
306 centtitle = Form(" Centrality %d", centralityClass);
307 }
308 } else {
309 centname = centtitle = "MinBias";
310 hasCentralityInfo= kFALSE;
311 }
312 hname += centtitle;
313 htitle += centtitle;
314
315 TH2 *hTmp = hSignal->Projection(2,1);
bf892a6a 316 hTmp->SetName(hname.Data());
317 hTmp->SetTitle(htitle.Data());
3a72645a 318 hTmp->SetStats(kFALSE);
319 hTmp->GetXaxis()->SetTitle("p [GeV/c]");
320 hTmp->GetYaxis()->SetTitle("TPC signal [a.u.]");
321 hSignal->GetAxis(3)->SetRange(0, hSignal->GetAxis(3)->GetNbins());
322 hSignal->GetAxis(0)->SetRange(0, hSignal->GetAxis(0)->GetNbins());
e156c3bb 323 if(hasCentralityInfo) hSignal->GetAxis(4)->SetRange(0, hSignal->GetAxis(4)->GetNbins());
3a72645a 324 return hTmp;
325}
326
327//_________________________________________________________
e156c3bb 328TH2 *AliHFEtpcPIDqa::MakeSpectrumNSigma(AliHFEdetPIDqa::EStep_t istep, Int_t species, Int_t centralityClass){
3a72645a 329 //
330 // Plot the Spectrum
331 //
332 THnSparseF *hSignal = dynamic_cast<THnSparseF *>(fHistos->Get("tpcnSigma"));
bf892a6a 333 if(!hSignal) return NULL;
3a72645a 334 hSignal->GetAxis(3)->SetRange(istep + 1, istep + 1);
335 if(species >= 0 && species < AliPID::kSPECIES)
336 hSignal->GetAxis(0)->SetRange(2 + species, 2 + species);
bf892a6a 337 TString hname = Form("hTPCsigma%s", istep == AliHFEdetPIDqa::kBeforePID ? "before" : "after"),
338 htitle = Form("TPC dE/dx Spectrum[#sigma] %s selection", istep == AliHFEdetPIDqa::kBeforePID ? "before" : "after");
3a72645a 339 if(species > -1){
bf892a6a 340 hname += AliPID::ParticleName(species);
341 htitle += Form(" for %ss", AliPID::ParticleName(species));
3a72645a 342 }
e156c3bb 343 TString centname, centtitle;
344 Bool_t hasCentralityInfo = kTRUE;
345 if(centralityClass > -1){
346 if(hSignal->GetNdimensions() < 5){
347 AliError("Centrality Information not available");
348 centname = centtitle = "MinBias";
349 hasCentralityInfo= kFALSE;
350 } else {
351 // Project centrality classes
352 // -1 is Min. Bias
353 hSignal->GetAxis(4)->SetRange(centralityClass+1, centralityClass+1);
354 centname = Form("Cent%d", centralityClass);
355 centtitle = Form(" Centrality %d", centralityClass);
356 }
357 } else {
358 centname = centtitle = "MinBias";
359 hasCentralityInfo= kFALSE;
360 }
361 hname += centtitle;
362 htitle += centtitle;
363
364 TH2 *hTmp = hSignal->Projection(2,1);
bf892a6a 365 hTmp->SetName(hname.Data());
366 hTmp->SetTitle(htitle.Data());
3a72645a 367 hTmp->SetStats(kFALSE);
368 hTmp->GetXaxis()->SetTitle("p [GeV/c]");
369 hTmp->GetYaxis()->SetTitle("TPC dE/dx - <dE/dx>|_{el} [#sigma]");
370 hSignal->GetAxis(3)->SetRange(0, hSignal->GetAxis(3)->GetNbins());
371 hSignal->GetAxis(0)->SetRange(0, hSignal->GetAxis(0)->GetNbins());
e156c3bb 372 if(hasCentralityInfo) hSignal->GetAxis(4)->SetRange(0, hSignal->GetAxis(4)->GetNbins());
3a72645a 373 return hTmp;
374}
375