]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG3/hfe/AliHFEtofPIDqa.cxx
Updates + addition of EMCal
[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;
3a72645a 147 const Int_t kSteps = 2;
c2690925 148 const Int_t kCentralityBins = 11;
3a72645a 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.;
bf892a6a 153 // Quantities where one can switch between low and high resolution
154 Int_t kPbins = fQAmanager->HasHighResolutionHistos() ? 1000 : 100;
155 Int_t kSigmaBins = fQAmanager->HasHighResolutionHistos() ? 1400 : 240;
156
3a72645a 157 // 1st histogram: TOF sigmas: (species, p nsigma, step)
c2690925 158 Int_t nBinsSigma[5] = {kPIDbins, kPbins, kSigmaBins, kSteps, kCentralityBins};
159 Double_t minSigma[5] = {kMinPID, kMinP, -12., 0, 0};
160 Double_t maxSigma[5] = {kMaxPID, kMaxP, 12., 2., 11.};
161 fHistos->CreateTHnSparse("tofnSigma", "TOF signal; species; p [GeV/c]; TOF signal [a.u.]; Selection Step; Centrality", 5, nBinsSigma, minSigma, maxSigma);
3a72645a 162
163 // 2nd histogram: TOF time - pion hypothesis (TOF Time Resolution Monitor)
164 fHistos->CreateTH2F("tofTimeRes", "Difference between measured and expected time for Pions; p [GeV/c]; #Deltat [ps]", 100, 0.1, 10, 100, -200, 200);
165
166 // 3rd histogram: TPC sigmas to the electron line: (species, p nsigma, step - only filled if apriori PID information available)
c2690925 167 fHistos->CreateTHnSparse("tofMonitorTPC", "TPC signal; species; p [GeV/c]; TPC signal [a.u.]; Selection Step; Centrality", 5, nBinsSigma, minSigma, maxSigma);
3a72645a 168}
169
170//_________________________________________________________
6555e2ad 171void AliHFEtofPIDqa::ProcessTrack(const AliHFEpidObject *track, AliHFEdetPIDqa::EStep_t step){
3a72645a 172 //
173 // Fill TPC histograms
174 //
6555e2ad 175 AliHFEpidObject::AnalysisType_t anatype = track->IsESDanalysis() ? AliHFEpidObject::kESDanalysis : AliHFEpidObject::kAODanalysis;
c2690925 176 Float_t centrality = track->GetCentrality();
3a72645a 177 Int_t species = track->GetAbInitioPID();
178 if(species >= AliPID::kSPECIES) species = -1;
3a72645a 179
3a72645a 180 AliDebug(1, Form("Monitoring particle of type %d for step %d", species, step));
6555e2ad 181 AliHFEpidTOF *tofpid= dynamic_cast<AliHFEpidTOF *>(fQAmanager->GetDetectorPID(AliHFEpid::kTOFpid));
182 AliHFEpidTPC *tpcpid= dynamic_cast<AliHFEpidTPC *>(fQAmanager->GetDetectorPID(AliHFEpid::kTPCpid));
3a72645a 183
c2690925 184 Double_t contentSignal[5];
3a72645a 185 contentSignal[0] = species;
6555e2ad 186 contentSignal[1] = track->GetRecTrack()->P();
bf892a6a 187 contentSignal[2] = tofpid ? tofpid->NumberOfSigmas(track->GetRecTrack(), AliPID::kElectron, anatype): 0.;
3a72645a 188 contentSignal[3] = step;
c2690925 189 contentSignal[4] = centrality;
bf892a6a 190 fHistos->Fill("tofnSigma", contentSignal);
191 if(tofpid){
192 Double_t timeTof = tofpid->GetTOFsignal(track->GetRecTrack(), anatype);
193 Double_t time0 = tofpid->GetTime0(anatype);
194 Double_t tof = timeTof - time0;
195 Double_t times[AliPID::kSPECIES]; tofpid->GetIntegratedTimes(track->GetRecTrack(), times, anatype);
196 fHistos->Fill("tofTimeRes",contentSignal[1], tof - times[AliPID::kPion]);
197 }
3a72645a 198 if(species > -1){
bf892a6a 199 contentSignal[2] = tpcpid ? tpcpid->NumberOfSigmas(track->GetRecTrack(), AliPID::kElectron, anatype) : 0.;
3a72645a 200 fHistos->Fill("tofMonitorTPC", contentSignal);
201 }
202}
203
3a72645a 204//_________________________________________________________
205TH2 *AliHFEtofPIDqa::MakeSpectrumNSigma(AliHFEdetPIDqa::EStep_t istep, Int_t species){
206 //
207 // Plot the Spectrum
208 //
209 THnSparseF *hSignal = dynamic_cast<THnSparseF *>(fHistos->Get("tofnSigma"));
bf892a6a 210 if(!hSignal) return NULL;
3a72645a 211 hSignal->GetAxis(3)->SetRange(istep + 1, istep + 1);
e3ae862b 212 if(species >= 0 && species < AliPID::kSPECIES)
3a72645a 213 hSignal->GetAxis(0)->SetRange(2 + species, 2 + species);
214 TH2 *hTmp = hSignal->Projection(2,1);
bf892a6a 215 TString hname = Form("hTPCsigma%s", istep == AliHFEdetPIDqa::kBeforePID ? "before" : "after"),
216 htitle = Form("TPC dE/dx Spectrum[#sigma] %s selection", istep == AliHFEdetPIDqa::kBeforePID ? "before" : "after");
3a72645a 217 if(species > -1){
bf892a6a 218 hname += AliPID::ParticleName(species);
219 htitle += Form(" for %ss", AliPID::ParticleName(species));
3a72645a 220 }
bf892a6a 221 hTmp->SetName(hname.Data());
222 hTmp->SetTitle(htitle.Data());
3a72645a 223 hTmp->SetStats(kFALSE);
224 hTmp->GetXaxis()->SetTitle("p [GeV/c]");
225 hTmp->GetYaxis()->SetTitle("TOF time|_{el} - expected time|_{el} [#sigma]");
226 hSignal->GetAxis(3)->SetRange(0, hSignal->GetAxis(3)->GetNbins());
227 hSignal->GetAxis(0)->SetRange(0, hSignal->GetAxis(0)->GetNbins());
228 return hTmp;
229}
230
231//_________________________________________________________
232TH1 *AliHFEtofPIDqa::GetHistogram(const char *name){
233 //
234 // Get the histogram
235 //
236 if(!fHistos) return NULL;
237 TObject *histo = fHistos->Get(name);
238 if(!histo->InheritsFrom("TH1")) return NULL;
239 return dynamic_cast<TH1 *>(histo);
240}
241