1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
16 // Class AliHFEtofPIDqa
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
30 // Markus Fasel <M.Fasel@gsi.de>
33 #include <THnSparse.h>
38 #include "AliPIDResponse.h"
39 #include "AliVParticle.h"
41 #include "AliHFEcollection.h"
42 #include "AliHFEpid.h"
43 #include "AliHFEpidBase.h"
44 #include "AliHFEpidQAmanager.h"
45 #include "AliHFEpidTPC.h"
46 #include "AliHFEpidTOF.h"
47 #include "AliHFEtools.h"
48 #include "AliHFEtofPIDqa.h"
50 ClassImp(AliHFEpidTOF)
52 //_________________________________________________________
53 AliHFEtofPIDqa::AliHFEtofPIDqa():
62 //_________________________________________________________
63 AliHFEtofPIDqa::AliHFEtofPIDqa(const char* name):
64 AliHFEdetPIDqa(name, "QA for TOF")
68 // Default constructor
72 //_________________________________________________________
73 AliHFEtofPIDqa::AliHFEtofPIDqa(const AliHFEtofPIDqa &o):
83 //_________________________________________________________
84 AliHFEtofPIDqa &AliHFEtofPIDqa::operator=(const AliHFEtofPIDqa &o){
88 AliHFEdetPIDqa::operator=(o);
89 if(&o != this) o.Copy(*this);
93 //_________________________________________________________
94 AliHFEtofPIDqa::~AliHFEtofPIDqa(){
98 if(fHistos) delete fHistos;
101 //_________________________________________________________
102 void AliHFEtofPIDqa::Copy(TObject &o) const {
106 AliHFEtofPIDqa &target = dynamic_cast<AliHFEtofPIDqa &>(o);
108 delete target.fHistos;
109 target.fHistos = NULL;
111 if(fHistos) target.fHistos = new AliHFEcollection(*fHistos);
114 //_________________________________________________________
115 Long64_t AliHFEtofPIDqa::Merge(TCollection *coll){
117 // Merge with other objects
120 if(coll->IsEmpty()) return 1;
123 AliHFEtofPIDqa *refQA = NULL;
128 refQA = dynamic_cast<AliHFEtofPIDqa *>(o);
131 listHistos.Add(refQA->fHistos);
134 fHistos->Merge(&listHistos);
138 //_________________________________________________________
139 void AliHFEtofPIDqa::Initialize(){
144 fHistos = new AliHFEcollection("tofqahistos", "Collection of TOF QA histograms");
146 // Make common binning
147 const Int_t kPIDbins = AliPID::kSPECIES + 1;
148 const Int_t kSteps = 2;
149 const Int_t kCentralityBins = 11;
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.;
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;
158 // 1st histogram: TOF sigmas: (species, p nsigma, step)
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);
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; Centrality", 5, nBinsSigma, minSigma, maxSigma);
168 //_________________________________________________________
169 void AliHFEtofPIDqa::ProcessTrack(const AliHFEpidObject *track, AliHFEdetPIDqa::EStep_t step){
171 // Fill TPC histograms
173 //AliHFEpidObject::AnalysisType_t anatype = track->IsESDanalysis() ? AliHFEpidObject::kESDanalysis : AliHFEpidObject::kAODanalysis;
174 Float_t centrality = track->GetCentrality();
175 Int_t species = track->GetAbInitioPID();
176 if(species >= AliPID::kSPECIES) species = -1;
178 AliDebug(1, Form("Monitoring particle of type %d for step %d", species, step));
179 AliHFEpidTOF *tofpid= dynamic_cast<AliHFEpidTOF *>(fQAmanager->GetDetectorPID(AliHFEpid::kTOFpid));
181 const AliPIDResponse *pidResponse = tofpid ? tofpid->GetPIDResponse() : NULL;
182 Double_t contentSignal[5];
183 contentSignal[0] = species;
184 contentSignal[1] = track->GetRecTrack()->P();
185 contentSignal[2] = pidResponse ? pidResponse->NumberOfSigmasTOF(track->GetRecTrack(), AliPID::kElectron): 0.;
186 contentSignal[3] = step;
187 contentSignal[4] = centrality;
188 fHistos->Fill("tofnSigma", contentSignal);
190 contentSignal[2] = pidResponse ? pidResponse->NumberOfSigmasTPC(track->GetRecTrack(), AliPID::kElectron) : 0.;
191 fHistos->Fill("tofMonitorTPC", contentSignal);
195 //_________________________________________________________
196 TH2 *AliHFEtofPIDqa::MakeSpectrumNSigma(AliHFEdetPIDqa::EStep_t istep, Int_t species){
200 THnSparseF *hSignal = dynamic_cast<THnSparseF *>(fHistos->Get("tofnSigma"));
201 if(!hSignal) return NULL;
202 hSignal->GetAxis(3)->SetRange(istep + 1, istep + 1);
203 if(species >= 0 && species < AliPID::kSPECIES)
204 hSignal->GetAxis(0)->SetRange(2 + species, 2 + species);
205 TH2 *hTmp = hSignal->Projection(2,1);
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");
209 hname += AliPID::ParticleName(species);
210 htitle += Form(" for %ss", AliPID::ParticleName(species));
212 hTmp->SetName(hname.Data());
213 hTmp->SetTitle(htitle.Data());
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());
222 //_________________________________________________________
223 TH1 *AliHFEtofPIDqa::GetHistogram(const char *name){
227 if(!fHistos) return NULL;
228 TObject *histo = fHistos->Get(name);
229 if(!histo->InheritsFrom("TH1")) return NULL;
230 return dynamic_cast<TH1 *>(histo);