]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG3/hfe/AliHFEtofPIDqa.cxx
Added default pass=2 value to AddTaskCentrality.C. Fatal error if the pass is not...
[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**************************************************************************/
27de2dfb 15
16/* $Id$ */
17
3a72645a 18//
19// Class AliHFEtofPIDqa
20//
21// Monitoring TOF PID in the HFE PID montioring framework. The following
22// quantities are monitored:
23// TOF time distance to electron hypothesis (Number of sigmas)
24// TOF time distance to the pion hypothesis (Absolute value)
25// TPC dE/dx (Number of sigmas, as control histogram)
26// (Always as function of momentum, particle species and centrality
27// before and after cut)
28// More information about the PID monitoring framework can be found in
29// AliHFEpidQAmanager.cxx and AliHFEdetPIDqa.cxx
30//
31// Author:
32//
33// Markus Fasel <M.Fasel@gsi.de>
34#include <TClass.h>
35#include <TH2.h>
36#include <THnSparse.h>
37#include <TString.h>
38
3a72645a 39#include "AliLog.h"
40#include "AliPID.h"
6555e2ad 41#include "AliVParticle.h"
3a72645a 42
43#include "AliHFEcollection.h"
6555e2ad 44#include "AliHFEpid.h"
3a72645a 45#include "AliHFEpidBase.h"
6555e2ad 46#include "AliHFEpidQAmanager.h"
47#include "AliHFEpidTPC.h"
48#include "AliHFEpidTOF.h"
3a72645a 49#include "AliHFEtools.h"
50#include "AliHFEtofPIDqa.h"
51
6555e2ad 52ClassImp(AliHFEpidTOF)
53
3a72645a 54//_________________________________________________________
55AliHFEtofPIDqa::AliHFEtofPIDqa():
56 AliHFEdetPIDqa()
57 , fHistos(NULL)
58{
59 //
60 // Dummy constructor
61 //
62}
63
64//_________________________________________________________
65AliHFEtofPIDqa::AliHFEtofPIDqa(const char* name):
6555e2ad 66 AliHFEdetPIDqa(name, "QA for TOF")
3a72645a 67 , fHistos(NULL)
68{
69 //
70 // Default constructor
71 //
72}
73
74//_________________________________________________________
75AliHFEtofPIDqa::AliHFEtofPIDqa(const AliHFEtofPIDqa &o):
76 AliHFEdetPIDqa(o)
77 , fHistos()
78{
79 //
80 // Copy constructor
81 //
82 o.Copy(*this);
83}
84
85//_________________________________________________________
86AliHFEtofPIDqa &AliHFEtofPIDqa::operator=(const AliHFEtofPIDqa &o){
87 //
88 // Do assignment
89 //
90 AliHFEdetPIDqa::operator=(o);
91 if(&o != this) o.Copy(*this);
92 return *this;
93}
94
95//_________________________________________________________
96AliHFEtofPIDqa::~AliHFEtofPIDqa(){
97 //
98 // Destructor
99 //
100 if(fHistos) delete fHistos;
101}
102
103//_________________________________________________________
104void AliHFEtofPIDqa::Copy(TObject &o) const {
105 //
106 // Make copy
107 //
108 AliHFEtofPIDqa &target = dynamic_cast<AliHFEtofPIDqa &>(o);
109 if(target.fHistos){
110 delete target.fHistos;
111 target.fHistos = NULL;
112 }
113 if(fHistos) target.fHistos = new AliHFEcollection(*fHistos);
114}
115
116//_________________________________________________________
117Long64_t AliHFEtofPIDqa::Merge(TCollection *coll){
118 //
119 // Merge with other objects
120 //
121 if(!coll) return 0;
122 if(coll->IsEmpty()) return 1;
123
124 TIter it(coll);
125 AliHFEtofPIDqa *refQA = NULL;
126 TObject *o = NULL;
127 Long64_t count = 0;
128 TList listHistos;
129 while((o = it())){
130 refQA = dynamic_cast<AliHFEtofPIDqa *>(o);
131 if(!refQA) continue;
132
133 listHistos.Add(refQA->fHistos);
134 count++;
135 }
136 fHistos->Merge(&listHistos);
137 return count + 1;
138}
139
140//_________________________________________________________
141void AliHFEtofPIDqa::Initialize(){
142 //
143 // Define Histograms
144 //
145
146 fHistos = new AliHFEcollection("tofqahistos", "Collection of TOF QA histograms");
147
148 // Make common binning
149 const Int_t kPIDbins = AliPID::kSPECIES + 1;
3a72645a 150 const Int_t kSteps = 2;
151 const Double_t kMinPID = -1;
152 const Double_t kMinP = 0.;
153 const Double_t kMaxPID = (Double_t)AliPID::kSPECIES;
154 const Double_t kMaxP = 20.;
bf892a6a 155 // Quantities where one can switch between low and high resolution
156 Int_t kPbins = fQAmanager->HasHighResolutionHistos() ? 1000 : 100;
157 Int_t kSigmaBins = fQAmanager->HasHighResolutionHistos() ? 1400 : 240;
158
3a72645a 159 // 1st histogram: TOF sigmas: (species, p nsigma, step)
3a72645a 160 Int_t nBinsSigma[4] = {kPIDbins, kPbins, kSigmaBins, kSteps};
161 Double_t minSigma[4] = {kMinPID, kMinP, -12., 0};
162 Double_t maxSigma[4] = {kMaxPID, kMaxP, 12., 2.};
163 fHistos->CreateTHnSparse("tofnSigma", "TOF signal; species; p [GeV/c]; TOF signal [a.u.]; Selection Step", 4, nBinsSigma, minSigma, maxSigma);
164
165 // 2nd histogram: TOF time - pion hypothesis (TOF Time Resolution Monitor)
166 fHistos->CreateTH2F("tofTimeRes", "Difference between measured and expected time for Pions; p [GeV/c]; #Deltat [ps]", 100, 0.1, 10, 100, -200, 200);
167
168 // 3rd histogram: TPC sigmas to the electron line: (species, p nsigma, step - only filled if apriori PID information available)
169 fHistos->CreateTHnSparse("tofMonitorTPC", "TPC signal; species; p [GeV/c]; TPC signal [a.u.]; Selection Step", 4, nBinsSigma, minSigma, maxSigma);
170}
171
172//_________________________________________________________
6555e2ad 173void AliHFEtofPIDqa::ProcessTrack(const AliHFEpidObject *track, AliHFEdetPIDqa::EStep_t step){
3a72645a 174 //
175 // Fill TPC histograms
176 //
6555e2ad 177 AliHFEpidObject::AnalysisType_t anatype = track->IsESDanalysis() ? AliHFEpidObject::kESDanalysis : AliHFEpidObject::kAODanalysis;
3a72645a 178 Int_t species = track->GetAbInitioPID();
179 if(species >= AliPID::kSPECIES) species = -1;
3a72645a 180
3a72645a 181 AliDebug(1, Form("Monitoring particle of type %d for step %d", species, step));
6555e2ad 182 AliHFEpidTOF *tofpid= dynamic_cast<AliHFEpidTOF *>(fQAmanager->GetDetectorPID(AliHFEpid::kTOFpid));
183 AliHFEpidTPC *tpcpid= dynamic_cast<AliHFEpidTPC *>(fQAmanager->GetDetectorPID(AliHFEpid::kTPCpid));
3a72645a 184
185 Double_t contentSignal[4];
186 contentSignal[0] = species;
6555e2ad 187 contentSignal[1] = track->GetRecTrack()->P();
bf892a6a 188 contentSignal[2] = tofpid ? tofpid->NumberOfSigmas(track->GetRecTrack(), AliPID::kElectron, anatype): 0.;
3a72645a 189 contentSignal[3] = step;
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