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 "AliVParticle.h"
40 #include "AliHFEcollection.h"
41 #include "AliHFEpid.h"
42 #include "AliHFEpidBase.h"
43 #include "AliHFEpidQAmanager.h"
44 #include "AliHFEpidTPC.h"
45 #include "AliHFEpidTOF.h"
46 #include "AliHFEtools.h"
47 #include "AliHFEtofPIDqa.h"
49 ClassImp(AliHFEpidTOF)
51 //_________________________________________________________
52 AliHFEtofPIDqa::AliHFEtofPIDqa():
61 //_________________________________________________________
62 AliHFEtofPIDqa::AliHFEtofPIDqa(const char* name):
63 AliHFEdetPIDqa(name, "QA for TOF")
67 // Default constructor
71 //_________________________________________________________
72 AliHFEtofPIDqa::AliHFEtofPIDqa(const AliHFEtofPIDqa &o):
82 //_________________________________________________________
83 AliHFEtofPIDqa &AliHFEtofPIDqa::operator=(const AliHFEtofPIDqa &o){
87 AliHFEdetPIDqa::operator=(o);
88 if(&o != this) o.Copy(*this);
92 //_________________________________________________________
93 AliHFEtofPIDqa::~AliHFEtofPIDqa(){
97 if(fHistos) delete fHistos;
100 //_________________________________________________________
101 void AliHFEtofPIDqa::Copy(TObject &o) const {
105 AliHFEtofPIDqa &target = dynamic_cast<AliHFEtofPIDqa &>(o);
107 delete target.fHistos;
108 target.fHistos = NULL;
110 if(fHistos) target.fHistos = new AliHFEcollection(*fHistos);
113 //_________________________________________________________
114 Long64_t AliHFEtofPIDqa::Merge(TCollection *coll){
116 // Merge with other objects
119 if(coll->IsEmpty()) return 1;
122 AliHFEtofPIDqa *refQA = NULL;
127 refQA = dynamic_cast<AliHFEtofPIDqa *>(o);
130 listHistos.Add(refQA->fHistos);
133 fHistos->Merge(&listHistos);
137 //_________________________________________________________
138 void AliHFEtofPIDqa::Initialize(){
143 fHistos = new AliHFEcollection("tofqahistos", "Collection of TOF QA histograms");
145 // Make common binning
146 const Int_t kPIDbins = AliPID::kSPECIES + 1;
147 const Int_t kSteps = 2;
148 const Double_t kMinPID = -1;
149 const Double_t kMinP = 0.;
150 const Double_t kMaxPID = (Double_t)AliPID::kSPECIES;
151 const Double_t kMaxP = 20.;
152 // Quantities where one can switch between low and high resolution
153 Int_t kPbins = fQAmanager->HasHighResolutionHistos() ? 1000 : 100;
154 Int_t kSigmaBins = fQAmanager->HasHighResolutionHistos() ? 1400 : 240;
156 // 1st histogram: TOF sigmas: (species, p nsigma, step)
157 Int_t nBinsSigma[4] = {kPIDbins, kPbins, kSigmaBins, kSteps};
158 Double_t minSigma[4] = {kMinPID, kMinP, -12., 0};
159 Double_t maxSigma[4] = {kMaxPID, kMaxP, 12., 2.};
160 fHistos->CreateTHnSparse("tofnSigma", "TOF signal; species; p [GeV/c]; TOF signal [a.u.]; Selection Step", 4, nBinsSigma, minSigma, maxSigma);
162 // 2nd histogram: TOF time - pion hypothesis (TOF Time Resolution Monitor)
163 fHistos->CreateTH2F("tofTimeRes", "Difference between measured and expected time for Pions; p [GeV/c]; #Deltat [ps]", 100, 0.1, 10, 100, -200, 200);
165 // 3rd histogram: TPC sigmas to the electron line: (species, p nsigma, step - only filled if apriori PID information available)
166 fHistos->CreateTHnSparse("tofMonitorTPC", "TPC signal; species; p [GeV/c]; TPC signal [a.u.]; Selection Step", 4, nBinsSigma, minSigma, maxSigma);
169 //_________________________________________________________
170 void AliHFEtofPIDqa::ProcessTrack(const AliHFEpidObject *track, AliHFEdetPIDqa::EStep_t step){
172 // Fill TPC histograms
174 AliHFEpidObject::AnalysisType_t anatype = track->IsESDanalysis() ? AliHFEpidObject::kESDanalysis : AliHFEpidObject::kAODanalysis;
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));
180 AliHFEpidTPC *tpcpid= dynamic_cast<AliHFEpidTPC *>(fQAmanager->GetDetectorPID(AliHFEpid::kTPCpid));
182 Double_t contentSignal[4];
183 contentSignal[0] = species;
184 contentSignal[1] = track->GetRecTrack()->P();
185 contentSignal[2] = tofpid ? tofpid->NumberOfSigmas(track->GetRecTrack(), AliPID::kElectron, anatype): 0.;
186 contentSignal[3] = step;
187 fHistos->Fill("tofnSigma", contentSignal);
189 Double_t timeTof = tofpid->GetTOFsignal(track->GetRecTrack(), anatype);
190 Double_t time0 = tofpid->GetTime0(anatype);
191 Double_t tof = timeTof - time0;
192 Double_t times[AliPID::kSPECIES]; tofpid->GetIntegratedTimes(track->GetRecTrack(), times, anatype);
193 fHistos->Fill("tofTimeRes",contentSignal[1], tof - times[AliPID::kPion]);
196 contentSignal[2] = tpcpid ? tpcpid->NumberOfSigmas(track->GetRecTrack(), AliPID::kElectron, anatype) : 0.;
197 fHistos->Fill("tofMonitorTPC", contentSignal);
201 //_________________________________________________________
202 TH2 *AliHFEtofPIDqa::MakeSpectrumNSigma(AliHFEdetPIDqa::EStep_t istep, Int_t species){
206 THnSparseF *hSignal = dynamic_cast<THnSparseF *>(fHistos->Get("tofnSigma"));
207 if(!hSignal) return NULL;
208 hSignal->GetAxis(3)->SetRange(istep + 1, istep + 1);
209 if(species >= 0 && species < AliPID::kSPECIES)
210 hSignal->GetAxis(0)->SetRange(2 + species, 2 + species);
211 TH2 *hTmp = hSignal->Projection(2,1);
212 TString hname = Form("hTPCsigma%s", istep == AliHFEdetPIDqa::kBeforePID ? "before" : "after"),
213 htitle = Form("TPC dE/dx Spectrum[#sigma] %s selection", istep == AliHFEdetPIDqa::kBeforePID ? "before" : "after");
215 hname += AliPID::ParticleName(species);
216 htitle += Form(" for %ss", AliPID::ParticleName(species));
218 hTmp->SetName(hname.Data());
219 hTmp->SetTitle(htitle.Data());
220 hTmp->SetStats(kFALSE);
221 hTmp->GetXaxis()->SetTitle("p [GeV/c]");
222 hTmp->GetYaxis()->SetTitle("TOF time|_{el} - expected time|_{el} [#sigma]");
223 hSignal->GetAxis(3)->SetRange(0, hSignal->GetAxis(3)->GetNbins());
224 hSignal->GetAxis(0)->SetRange(0, hSignal->GetAxis(0)->GetNbins());
228 //_________________________________________________________
229 TH1 *AliHFEtofPIDqa::GetHistogram(const char *name){
233 if(!fHistos) return NULL;
234 TObject *histo = fHistos->Get(name);
235 if(!histo->InheritsFrom("TH1")) return NULL;
236 return dynamic_cast<TH1 *>(histo);