]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGHF/hfe/AliHFEtofPIDqa.cxx
Transition PWG3 --> PWGHF
[u/mrichter/AliRoot.git] / PWGHF / hfe / AliHFEtofPIDqa.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 AliHFEtofPIDqa
17//
18// Monitoring TOF PID in the HFE PID montioring framework. The following
19// quantities are monitored:
20// TOF time distance to electron hypothesis (Number of sigmas)
21// TOF time distance to the pion hypothesis (Absolute value)
22// TPC dE/dx (Number of sigmas, as control histogram)
23// (Always as function of momentum, particle species and centrality
24// before and after cut)
25// More information about the PID monitoring framework can be found in
26// AliHFEpidQAmanager.cxx and AliHFEdetPIDqa.cxx
27//
28// Author:
29//
30// Markus Fasel <M.Fasel@gsi.de>
31#include <TClass.h>
32#include <TH2.h>
33#include <THnSparse.h>
34#include <TString.h>
35
3a72645a 36#include "AliLog.h"
37#include "AliPID.h"
8c1c76e9 38#include "AliPIDResponse.h"
6555e2ad 39#include "AliVParticle.h"
3a72645a 40
41#include "AliHFEcollection.h"
6555e2ad 42#include "AliHFEpid.h"
3a72645a 43#include "AliHFEpidBase.h"
6555e2ad 44#include "AliHFEpidQAmanager.h"
45#include "AliHFEpidTPC.h"
46#include "AliHFEpidTOF.h"
3a72645a 47#include "AliHFEtools.h"
48#include "AliHFEtofPIDqa.h"
49
6555e2ad 50ClassImp(AliHFEpidTOF)
51
3a72645a 52//_________________________________________________________
53AliHFEtofPIDqa::AliHFEtofPIDqa():
54 AliHFEdetPIDqa()
55 , fHistos(NULL)
56{
57 //
58 // Dummy constructor
59 //
60}
61
62//_________________________________________________________
63AliHFEtofPIDqa::AliHFEtofPIDqa(const char* name):
6555e2ad 64 AliHFEdetPIDqa(name, "QA for TOF")
3a72645a 65 , fHistos(NULL)
66{
67 //
68 // Default constructor
69 //
70}
71
72//_________________________________________________________
73AliHFEtofPIDqa::AliHFEtofPIDqa(const AliHFEtofPIDqa &o):
74 AliHFEdetPIDqa(o)
75 , fHistos()
76{
77 //
78 // Copy constructor
79 //
80 o.Copy(*this);
81}
82
83//_________________________________________________________
84AliHFEtofPIDqa &AliHFEtofPIDqa::operator=(const AliHFEtofPIDqa &o){
85 //
86 // Do assignment
87 //
88 AliHFEdetPIDqa::operator=(o);
89 if(&o != this) o.Copy(*this);
90 return *this;
91}
92
93//_________________________________________________________
94AliHFEtofPIDqa::~AliHFEtofPIDqa(){
95 //
96 // Destructor
97 //
98 if(fHistos) delete fHistos;
99}
100
101//_________________________________________________________
102void AliHFEtofPIDqa::Copy(TObject &o) const {
103 //
104 // Make copy
105 //
106 AliHFEtofPIDqa &target = dynamic_cast<AliHFEtofPIDqa &>(o);
107 if(target.fHistos){
108 delete target.fHistos;
109 target.fHistos = NULL;
110 }
111 if(fHistos) target.fHistos = new AliHFEcollection(*fHistos);
112}
113
114//_________________________________________________________
115Long64_t AliHFEtofPIDqa::Merge(TCollection *coll){
116 //
117 // Merge with other objects
118 //
119 if(!coll) return 0;
120 if(coll->IsEmpty()) return 1;
121
122 TIter it(coll);
123 AliHFEtofPIDqa *refQA = NULL;
124 TObject *o = NULL;
125 Long64_t count = 0;
126 TList listHistos;
127 while((o = it())){
128 refQA = dynamic_cast<AliHFEtofPIDqa *>(o);
129 if(!refQA) continue;
130
131 listHistos.Add(refQA->fHistos);
132 count++;
133 }
134 fHistos->Merge(&listHistos);
135 return count + 1;
136}
137
138//_________________________________________________________
139void AliHFEtofPIDqa::Initialize(){
140 //
141 // Define Histograms
142 //
143
144 fHistos = new AliHFEcollection("tofqahistos", "Collection of TOF QA histograms");
145
146 // Make common binning
147 const Int_t kPIDbins = AliPID::kSPECIES + 1;
3a72645a 148 const Int_t kSteps = 2;
c2690925 149 const Int_t kCentralityBins = 11;
3a72645a 150 const Double_t kMinPID = -1;
151 const Double_t kMinP = 0.;
152 const Double_t kMaxPID = (Double_t)AliPID::kSPECIES;
153 const Double_t kMaxP = 20.;
bf892a6a 154 // Quantities where one can switch between low and high resolution
155 Int_t kPbins = fQAmanager->HasHighResolutionHistos() ? 1000 : 100;
156 Int_t kSigmaBins = fQAmanager->HasHighResolutionHistos() ? 1400 : 240;
157
3a72645a 158 // 1st histogram: TOF sigmas: (species, p nsigma, step)
c2690925 159 Int_t nBinsSigma[5] = {kPIDbins, kPbins, kSigmaBins, kSteps, kCentralityBins};
160 Double_t minSigma[5] = {kMinPID, kMinP, -12., 0, 0};
161 Double_t maxSigma[5] = {kMaxPID, kMaxP, 12., 2., 11.};
162 fHistos->CreateTHnSparse("tofnSigma", "TOF signal; species; p [GeV/c]; TOF signal [a.u.]; Selection Step; Centrality", 5, nBinsSigma, minSigma, maxSigma);
3a72645a 163
3a72645a 164 // 3rd histogram: TPC sigmas to the electron line: (species, p nsigma, step - only filled if apriori PID information available)
c2690925 165 fHistos->CreateTHnSparse("tofMonitorTPC", "TPC signal; species; p [GeV/c]; TPC signal [a.u.]; Selection Step; Centrality", 5, nBinsSigma, minSigma, maxSigma);
3a72645a 166}
167
168//_________________________________________________________
6555e2ad 169void AliHFEtofPIDqa::ProcessTrack(const AliHFEpidObject *track, AliHFEdetPIDqa::EStep_t step){
3a72645a 170 //
171 // Fill TPC histograms
172 //
8c1c76e9 173 //AliHFEpidObject::AnalysisType_t anatype = track->IsESDanalysis() ? AliHFEpidObject::kESDanalysis : AliHFEpidObject::kAODanalysis;
c2690925 174 Float_t centrality = track->GetCentrality();
3a72645a 175 Int_t species = track->GetAbInitioPID();
176 if(species >= AliPID::kSPECIES) species = -1;
3a72645a 177
3a72645a 178 AliDebug(1, Form("Monitoring particle of type %d for step %d", species, step));
6555e2ad 179 AliHFEpidTOF *tofpid= dynamic_cast<AliHFEpidTOF *>(fQAmanager->GetDetectorPID(AliHFEpid::kTOFpid));
3a72645a 180
8c1c76e9 181 const AliPIDResponse *pidResponse = tofpid ? tofpid->GetPIDResponse() : NULL;
c2690925 182 Double_t contentSignal[5];
3a72645a 183 contentSignal[0] = species;
6555e2ad 184 contentSignal[1] = track->GetRecTrack()->P();
8c1c76e9 185 contentSignal[2] = pidResponse ? pidResponse->NumberOfSigmasTOF(track->GetRecTrack(), AliPID::kElectron): 0.;
3a72645a 186 contentSignal[3] = step;
c2690925 187 contentSignal[4] = centrality;
bf892a6a 188 fHistos->Fill("tofnSigma", contentSignal);
3a72645a 189 if(species > -1){
8c1c76e9 190 contentSignal[2] = pidResponse ? pidResponse->NumberOfSigmasTPC(track->GetRecTrack(), AliPID::kElectron) : 0.;
3a72645a 191 fHistos->Fill("tofMonitorTPC", contentSignal);
192 }
193}
194
3a72645a 195//_________________________________________________________
196TH2 *AliHFEtofPIDqa::MakeSpectrumNSigma(AliHFEdetPIDqa::EStep_t istep, Int_t species){
197 //
198 // Plot the Spectrum
199 //
200 THnSparseF *hSignal = dynamic_cast<THnSparseF *>(fHistos->Get("tofnSigma"));
bf892a6a 201 if(!hSignal) return NULL;
3a72645a 202 hSignal->GetAxis(3)->SetRange(istep + 1, istep + 1);
e3ae862b 203 if(species >= 0 && species < AliPID::kSPECIES)
3a72645a 204 hSignal->GetAxis(0)->SetRange(2 + species, 2 + species);
205 TH2 *hTmp = hSignal->Projection(2,1);
8c1c76e9 206 TString hname = Form("hTOFsigma%s", istep == AliHFEdetPIDqa::kBeforePID ? "before" : "after"),
207 htitle = Form("Time-of-flight spectrum[#sigma] %s selection", istep == AliHFEdetPIDqa::kBeforePID ? "before" : "after");
3a72645a 208 if(species > -1){
bf892a6a 209 hname += AliPID::ParticleName(species);
210 htitle += Form(" for %ss", AliPID::ParticleName(species));
3a72645a 211 }
bf892a6a 212 hTmp->SetName(hname.Data());
213 hTmp->SetTitle(htitle.Data());
3a72645a 214 hTmp->SetStats(kFALSE);
215 hTmp->GetXaxis()->SetTitle("p [GeV/c]");
216 hTmp->GetYaxis()->SetTitle("TOF time|_{el} - expected time|_{el} [#sigma]");
217 hSignal->GetAxis(3)->SetRange(0, hSignal->GetAxis(3)->GetNbins());
218 hSignal->GetAxis(0)->SetRange(0, hSignal->GetAxis(0)->GetNbins());
219 return hTmp;
220}
221
222//_________________________________________________________
223TH1 *AliHFEtofPIDqa::GetHistogram(const char *name){
224 //
225 // Get the histogram
226 //
227 if(!fHistos) return NULL;
228 TObject *histo = fHistos->Get(name);
229 if(!histo->InheritsFrom("TH1")) return NULL;
230 return dynamic_cast<TH1 *>(histo);
231}
232