]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG3/hfe/AliHFEtofPIDqa.cxx
Fixes for Coverity warnings
[u/mrichter/AliRoot.git] / PWG3 / 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"
6555e2ad 38#include "AliVParticle.h"
3a72645a 39
40#include "AliHFEcollection.h"
6555e2ad 41#include "AliHFEpid.h"
3a72645a 42#include "AliHFEpidBase.h"
6555e2ad 43#include "AliHFEpidQAmanager.h"
44#include "AliHFEpidTPC.h"
45#include "AliHFEpidTOF.h"
3a72645a 46#include "AliHFEtools.h"
47#include "AliHFEtofPIDqa.h"
48
6555e2ad 49ClassImp(AliHFEpidTOF)
50
3a72645a 51//_________________________________________________________
52AliHFEtofPIDqa::AliHFEtofPIDqa():
53 AliHFEdetPIDqa()
54 , fHistos(NULL)
55{
56 //
57 // Dummy constructor
58 //
59}
60
61//_________________________________________________________
62AliHFEtofPIDqa::AliHFEtofPIDqa(const char* name):
6555e2ad 63 AliHFEdetPIDqa(name, "QA for TOF")
3a72645a 64 , fHistos(NULL)
65{
66 //
67 // Default constructor
68 //
69}
70
71//_________________________________________________________
72AliHFEtofPIDqa::AliHFEtofPIDqa(const AliHFEtofPIDqa &o):
73 AliHFEdetPIDqa(o)
74 , fHistos()
75{
76 //
77 // Copy constructor
78 //
79 o.Copy(*this);
80}
81
82//_________________________________________________________
83AliHFEtofPIDqa &AliHFEtofPIDqa::operator=(const AliHFEtofPIDqa &o){
84 //
85 // Do assignment
86 //
87 AliHFEdetPIDqa::operator=(o);
88 if(&o != this) o.Copy(*this);
89 return *this;
90}
91
92//_________________________________________________________
93AliHFEtofPIDqa::~AliHFEtofPIDqa(){
94 //
95 // Destructor
96 //
97 if(fHistos) delete fHistos;
98}
99
100//_________________________________________________________
101void AliHFEtofPIDqa::Copy(TObject &o) const {
102 //
103 // Make copy
104 //
105 AliHFEtofPIDqa &target = dynamic_cast<AliHFEtofPIDqa &>(o);
106 if(target.fHistos){
107 delete target.fHistos;
108 target.fHistos = NULL;
109 }
110 if(fHistos) target.fHistos = new AliHFEcollection(*fHistos);
111}
112
113//_________________________________________________________
114Long64_t AliHFEtofPIDqa::Merge(TCollection *coll){
115 //
116 // Merge with other objects
117 //
118 if(!coll) return 0;
119 if(coll->IsEmpty()) return 1;
120
121 TIter it(coll);
122 AliHFEtofPIDqa *refQA = NULL;
123 TObject *o = NULL;
124 Long64_t count = 0;
125 TList listHistos;
126 while((o = it())){
127 refQA = dynamic_cast<AliHFEtofPIDqa *>(o);
128 if(!refQA) continue;
129
130 listHistos.Add(refQA->fHistos);
131 count++;
132 }
133 fHistos->Merge(&listHistos);
134 return count + 1;
135}
136
137//_________________________________________________________
138void AliHFEtofPIDqa::Initialize(){
139 //
140 // Define Histograms
141 //
142
143 fHistos = new AliHFEcollection("tofqahistos", "Collection of TOF QA histograms");
144
145 // Make common binning
146 const Int_t kPIDbins = AliPID::kSPECIES + 1;
6555e2ad 147 const Int_t kPbins = 100;
3a72645a 148 const Int_t kSteps = 2;
149 const Double_t kMinPID = -1;
150 const Double_t kMinP = 0.;
151 const Double_t kMaxPID = (Double_t)AliPID::kSPECIES;
152 const Double_t kMaxP = 20.;
153
154 // 1st histogram: TOF sigmas: (species, p nsigma, step)
6555e2ad 155 const Int_t kSigmaBins = 240;
3a72645a 156 Int_t nBinsSigma[4] = {kPIDbins, kPbins, kSigmaBins, kSteps};
157 Double_t minSigma[4] = {kMinPID, kMinP, -12., 0};
158 Double_t maxSigma[4] = {kMaxPID, kMaxP, 12., 2.};
159 fHistos->CreateTHnSparse("tofnSigma", "TOF signal; species; p [GeV/c]; TOF signal [a.u.]; Selection Step", 4, nBinsSigma, minSigma, maxSigma);
160
161 // 2nd histogram: TOF time - pion hypothesis (TOF Time Resolution Monitor)
162 fHistos->CreateTH2F("tofTimeRes", "Difference between measured and expected time for Pions; p [GeV/c]; #Deltat [ps]", 100, 0.1, 10, 100, -200, 200);
163
164 // 3rd histogram: TPC sigmas to the electron line: (species, p nsigma, step - only filled if apriori PID information available)
165 fHistos->CreateTHnSparse("tofMonitorTPC", "TPC signal; species; p [GeV/c]; TPC signal [a.u.]; Selection Step", 4, nBinsSigma, minSigma, maxSigma);
166}
167
168//_________________________________________________________
6555e2ad 169void AliHFEtofPIDqa::ProcessTrack(const AliHFEpidObject *track, AliHFEdetPIDqa::EStep_t step){
3a72645a 170 //
171 // Fill TPC histograms
172 //
6555e2ad 173 AliHFEpidObject::AnalysisType_t anatype = track->IsESDanalysis() ? AliHFEpidObject::kESDanalysis : AliHFEpidObject::kAODanalysis;
3a72645a 174 Int_t species = track->GetAbInitioPID();
175 if(species >= AliPID::kSPECIES) species = -1;
3a72645a 176
3a72645a 177 AliDebug(1, Form("Monitoring particle of type %d for step %d", species, step));
6555e2ad 178 AliHFEpidTOF *tofpid= dynamic_cast<AliHFEpidTOF *>(fQAmanager->GetDetectorPID(AliHFEpid::kTOFpid));
179 AliHFEpidTPC *tpcpid= dynamic_cast<AliHFEpidTPC *>(fQAmanager->GetDetectorPID(AliHFEpid::kTPCpid));
3a72645a 180
181 Double_t contentSignal[4];
182 contentSignal[0] = species;
6555e2ad 183 contentSignal[1] = track->GetRecTrack()->P();
184 contentSignal[2] = tofpid->NumberOfSigmas(track->GetRecTrack(), AliPID::kElectron, anatype);
3a72645a 185 contentSignal[3] = step;
186 (dynamic_cast<THnSparseF *>(fHistos->Get("tofnSigma")))->Fill(contentSignal);
6555e2ad 187 Double_t timeTof = tofpid->GetTOFsignal(track->GetRecTrack(), anatype);
188 Double_t time0 = tofpid->GetTime0(anatype);
189 Double_t tof = timeTof - time0;
190 Double_t times[AliPID::kSPECIES]; tofpid->GetIntegratedTimes(track->GetRecTrack(), times, anatype);
3a72645a 191 fHistos->Fill("tofTimeRes",contentSignal[1], tof - times[AliPID::kPion]);
192 if(species > -1){
6555e2ad 193 contentSignal[2] = tpcpid->NumberOfSigmas(track->GetRecTrack(), AliPID::kElectron, anatype);
3a72645a 194 fHistos->Fill("tofMonitorTPC", contentSignal);
195 }
196}
197
3a72645a 198//_________________________________________________________
199TH2 *AliHFEtofPIDqa::MakeSpectrumNSigma(AliHFEdetPIDqa::EStep_t istep, Int_t species){
200 //
201 // Plot the Spectrum
202 //
203 THnSparseF *hSignal = dynamic_cast<THnSparseF *>(fHistos->Get("tofnSigma"));
204 hSignal->GetAxis(3)->SetRange(istep + 1, istep + 1);
205 if(species > 0 && species < AliPID::kSPECIES)
206 hSignal->GetAxis(0)->SetRange(2 + species, 2 + species);
207 TH2 *hTmp = hSignal->Projection(2,1);
208 Char_t hname[256], htitle[256];
209 sprintf(hname, "hTPCsigma%s", istep == AliHFEdetPIDqa::kBeforePID ? "before" : "after");
210 sprintf(htitle, "TPC dE/dx Spectrum[#sigma] %s selection", istep == AliHFEdetPIDqa::kBeforePID ? "before" : "after");
211 if(species > -1){
212 strncat(hname, AliPID::ParticleName(species), strlen(AliPID::ParticleName(species)));
213 Char_t speciesname[256];
214 sprintf(speciesname, " for %ss", AliPID::ParticleName(species));
215 strncat(htitle, speciesname, strlen(speciesname));
216 }
217 hTmp->SetName(hname);
218 hTmp->SetTitle(htitle);
219 hTmp->SetStats(kFALSE);
220 hTmp->GetXaxis()->SetTitle("p [GeV/c]");
221 hTmp->GetYaxis()->SetTitle("TOF time|_{el} - expected time|_{el} [#sigma]");
222 hSignal->GetAxis(3)->SetRange(0, hSignal->GetAxis(3)->GetNbins());
223 hSignal->GetAxis(0)->SetRange(0, hSignal->GetAxis(0)->GetNbins());
224 return hTmp;
225}
226
227//_________________________________________________________
228TH1 *AliHFEtofPIDqa::GetHistogram(const char *name){
229 //
230 // Get the histogram
231 //
232 if(!fHistos) return NULL;
233 TObject *histo = fHistos->Get(name);
234 if(!histo->InheritsFrom("TH1")) return NULL;
235 return dynamic_cast<TH1 *>(histo);
236}
237