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 AliHFEtrdPIDqaV1
17 // Monitoring TRD PID in the HFE PID montioring framework. The following
18 // quantities are monitored:
19 // TRD electron likelihood
20 // TRD dE/dx (Absolute values)
21 // TPC dE/dx (Number of sigmas, control histogram)
22 // (Always as function of momentum, particle species and centrality
23 // before and after cut)
24 // More information about the PID monitoring framework can be found in
25 // AliHFEpidQAmanager.cxx and AliHFEdetPIDqa.cxx
28 // Markus Fasel <M.Fasel@gsi.de>
33 #include <THnSparse.h>
39 #include "AliHFEcollection.h"
40 #include "AliHFEpidBase.h"
41 #include "AliHFEpidQAmanager.h"
42 #include "AliHFEpidTPC.h"
43 #include "AliHFEpidTRD.h"
44 #include "AliHFEtrdPIDqaV1.h"
46 ClassImp(AliHFEtrdPIDqaV1)
48 //____________________________________________________________
49 AliHFEtrdPIDqaV1::AliHFEtrdPIDqaV1():
58 //____________________________________________________________
59 AliHFEtrdPIDqaV1::AliHFEtrdPIDqaV1(const Char_t *name):
60 AliHFEdetPIDqa(name, "QA for TRD"),
64 // Default constructor
68 //____________________________________________________________
69 AliHFEtrdPIDqaV1::AliHFEtrdPIDqaV1(const AliHFEtrdPIDqaV1 &o):
78 //____________________________________________________________
79 AliHFEtrdPIDqaV1 &AliHFEtrdPIDqaV1::operator=(const AliHFEtrdPIDqaV1 &o){
83 AliHFEdetPIDqa::operator=(o);
89 //_________________________________________________________
90 Long64_t AliHFEtrdPIDqaV1::Merge(TCollection *coll){
92 // Merge with other objects
95 if(coll->IsEmpty()) return 1;
98 AliHFEtrdPIDqaV1 *refQA = NULL;
103 refQA = dynamic_cast<AliHFEtrdPIDqaV1 *>(o);
106 listHistos.Add(refQA->fHistos);
109 fHistos->Merge(&listHistos);
113 //____________________________________________________________
114 void AliHFEtrdPIDqaV1::Initialize(){
116 // Initialize QA histos for TRD PID
119 AliDebug(1, "Initializing PID QA for TRD");
120 // Make common binning
121 const Int_t kPIDbins = AliPID::kSPECIES + 1;
122 const Int_t kPbins = 100;
123 const Int_t kSteps = 2;
124 const Double_t kMinPID = -1;
125 const Double_t kMinP = 0.;
126 const Double_t kMaxPID = (Double_t)AliPID::kSPECIES;
127 const Double_t kMaxP = 20.;
129 fHistos = new AliHFEcollection("trdqahistos", "Collection of TRD QA histograms");
131 // Create Control Histogram monitoring the TPC sigma between the selection steps
132 const Int_t kTPCSigmaBins = 140;
133 Int_t nBinsTPCSigma[4] = {kPIDbins, kPbins, kTPCSigmaBins, kSteps};
134 Double_t minTPCSigma[4] = {kMinPID, kMinP, -12., 0};
135 Double_t maxTPCSigma[4] = {kMaxPID, kMaxP, 12., 2.};
136 fHistos->CreateTHnSparse("hTPCsigma", "TPC sigma; species p [GeV/c]; TPC dEdx - <dE/dx>|_{el} [#sigma]; selection step", 4, nBinsTPCSigma, minTPCSigma, maxTPCSigma);
137 // Create Monitoring histogram for the Likelihood distribution
138 const Int_t kTRDLikelihoodBins = 100;
139 Int_t nBinsTRDlike[4] = {kPIDbins, kPbins, kTRDLikelihoodBins, kSteps};
140 Double_t minTRDlike[4] = {kMinPID, kMinP, 0., 0.};
141 Double_t maxTRDlike[4] = {kMaxPID, kMaxP, 1., 2.};
142 fHistos->CreateTHnSparse("hTRDlikelihood", "TRD Likelihood Distribution; species; p [GeV/c]; TRD electron Likelihood; selection step", 4, nBinsTRDlike, minTRDlike, maxTRDlike);
143 // Create Monitoring histogram for the TRD total charge
144 const Int_t kTRDchargeBins = 1000;
145 Int_t nBinsTRDcharge[4] = {kPIDbins, kPbins, kTRDchargeBins, kSteps};
146 Double_t minTRDcharge[4] = {kMinPID, kMinP, 0., 0.};
147 Double_t maxTRDcharge[4] = {kMaxPID, kMaxP, 100000., 2.};
148 fHistos->CreateTHnSparse("hTRDcharge", "Total TRD charge; species; p [GeV/c]; TRD charge [a.u.]; selection step", 4, nBinsTRDcharge, minTRDcharge, maxTRDcharge);
151 //____________________________________________________________
152 void AliHFEtrdPIDqaV1::ProcessTrack(const AliHFEpidObject *track, AliHFEdetPIDqa::EStep_t step){
154 // Process the track, fill the containers
156 AliDebug(1, Form("QA started for TRD PID for step %d", (Int_t)step));
157 Int_t species = track->GetAbInitioPID();
158 AliHFEpidObject::AnalysisType_t anatype = track->IsESDanalysis() ? AliHFEpidObject::kESDanalysis : AliHFEpidObject::kAODanalysis;
160 AliHFEpidTRD *trdpid = dynamic_cast<AliHFEpidTRD *>(fQAmanager->GetDetectorPID(AliHFEpid::kTRDpid));
161 AliHFEpidTPC *tpcpid = dynamic_cast<AliHFEpidTPC *>(fQAmanager->GetDetectorPID(AliHFEpid::kTPCpid));
163 Double_t container[4];
164 container[0] = species;
165 container[1] = trdpid->GetP(track->GetRecTrack(), anatype);
166 container[2] = tpcpid->NumberOfSigmas(track->GetRecTrack(), AliPID::kElectron, anatype);
168 fHistos->Fill("hTPCsigma", container);
170 container[2] = trdpid->GetElectronLikelihood(track->GetRecTrack(), anatype);
171 fHistos->Fill("hTRDlikelihood", container);
173 for(UInt_t ily = 0; ily < 6; ily++){
174 container[2] = trdpid->GetChargeLayer(track->GetRecTrack(), ily, anatype);
175 fHistos->Fill("hTRDcharge", container);
177 if(species >= AliPID::kSPECIES) species = -1;
180 //_________________________________________________________
181 TH2 *AliHFEtrdPIDqaV1::MakeTPCspectrumNsigma(AliHFEdetPIDqa::EStep_t step, Int_t species){
183 // Get the TPC control histogram for the TRD selection step (either before or after PID)
185 printf("histos :%p\n", fHistos);
186 THnSparseF *histo = dynamic_cast<THnSparseF *>(fHistos->Get("hTPCsigma"));
188 AliError("QA histogram monitoring TPC nSigma not available");
191 if(species > -1 && species < AliPID::kSPECIES){
192 // cut on species (if available)
193 histo->GetAxis(0)->SetRange(species + 2, species + 2); // undef + underflow
195 histo->GetAxis(3)->SetRange(step + 1, step + 1);
197 TH2 *hSpec = histo->Projection(2, 1);
198 // construct title and name
199 TString stepname = step == AliHFEdetPIDqa::kBeforePID ? "before" : "after";
200 TString speciesname = species > -1 && species < AliPID::kSPECIES ? AliPID::ParticleName(species) : "all Particles";
201 TString specID = species > -1 && species < AliPID::kSPECIES ? AliPID::ParticleName(species) : "unid";
202 TString histname = Form("hSigmaTPC%s%s", specID.Data(), stepname.Data());
203 TString histtitle = Form("TPC Sigma for %s %s PID", speciesname.Data(), stepname.Data());
204 hSpec->SetName(histname.Data());
205 hSpec->SetTitle(histtitle.Data());
207 // Unset range on the original histogram
208 histo->GetAxis(0)->SetRange(0, histo->GetAxis(0)->GetNbins());
209 histo->GetAxis(2)->SetRange(0, histo->GetAxis(2)->GetNbins());
213 //_________________________________________________________
214 TH2 *AliHFEtrdPIDqaV1::MakeTRDlikelihoodDistribution(AliHFEdetPIDqa::EStep_t step, Int_t species){
216 // Make Histogram for TRD Likelihood distribution
218 THnSparseF *histo = dynamic_cast<THnSparseF *>(fHistos->Get("hTRDlikelihood"));
220 AliError("QA histogram monitoring TRD Electron Likelihood not available");
223 if(species > -1 && species < AliPID::kSPECIES){
224 // cut on species (if available)
225 histo->GetAxis(0)->SetRange(species + 2, species + 2); // undef + underflow
227 histo->GetAxis(3)->SetRangeUser(step + 1, step + 1);
229 TH2 *hSpec = histo->Projection(2, 1);
230 // construct title and name
231 TString stepname = step == AliHFEdetPIDqa::kBeforePID ? "before" : "after";
232 TString speciesname = species > -1 && species < AliPID::kSPECIES ? AliPID::ParticleName(species) : "all Particles";
233 TString specID = species > -1 && species < AliPID::kSPECIES ? AliPID::ParticleName(species) : "unid";
234 TString histname = Form("hLikeElTRD%s%s", specID.Data(), stepname.Data());
235 TString histtitle = Form("TRD electron Likelihood for %s %s PID", speciesname.Data(), stepname.Data());
236 hSpec->SetName(histname.Data());
237 hSpec->SetTitle(histtitle.Data());
239 // Unset range on the original histogram
240 histo->GetAxis(0)->SetRange(0, histo->GetAxis(0)->GetNbins());
241 histo->GetAxis(2)->SetRange(0, histo->GetAxis(2)->GetNbins());
245 //_________________________________________________________
246 TH2 *AliHFEtrdPIDqaV1::MakeTRDchargeDistribution(AliHFEdetPIDqa::EStep_t step, Int_t species){
248 // Make Histogram for TRD Likelihood distribution
250 THnSparseF *histo = dynamic_cast<THnSparseF *>(fHistos->Get("hTRDcharge"));
252 AliError("QA histogram monitoring TRD total charge not available");
255 if(species > -1 && species < AliPID::kSPECIES){
256 // cut on species (if available)
257 histo->GetAxis(0)->SetRange(species + 2, species + 2); // undef + underflow
259 histo->GetAxis(3)->SetRange(step + 1, step + 1);
261 TH2 *hSpec = histo->Projection(2, 1);
262 // construct title and name
263 TString stepname = step == AliHFEdetPIDqa::kBeforePID ? "before" : "after";
264 TString speciesname = species > -1 && species < AliPID::kSPECIES ? AliPID::ParticleName(species) : "all Particles";
265 TString specID = species > -1 && species < AliPID::kSPECIES ? AliPID::ParticleName(species) : "unid";
266 TString histname = Form("hChargeTRD%s%s", specID.Data(), stepname.Data());
267 TString histtitle = Form("TRD total charge for %s %s PID", speciesname.Data(), stepname.Data());
268 hSpec->SetName(histname.Data());
269 hSpec->SetTitle(histtitle.Data());
271 // Unset range on the original histogram
272 histo->GetAxis(0)->SetRange(0, histo->GetAxis(0)->GetNbins());
273 histo->GetAxis(2)->SetRange(0, histo->GetAxis(2)->GetNbins());