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>
36 #include "AliAODTrack.h"
37 #include "AliESDtrack.h"
38 #include "AliESDpid.h"
39 #include "AliExternalTrackParam.h"
42 #include "AliHFEcollection.h"
43 #include "AliHFEpidBase.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(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 const AliVParticle *rectrack = track->GetRecTrack();
159 if(species >= AliPID::kSPECIES) species = -1;
160 if(!TString(rectrack->IsA()->GetName()).CompareTo("AliESDtrack")) ProcessESDtrack(dynamic_cast<const AliESDtrack *>(rectrack), step, species);
161 else if(!TString(rectrack->IsA()->GetName()).CompareTo("AliAODTrack")) ProcessAODtrack(dynamic_cast<const AliAODTrack *>(rectrack), step, species);
162 else AliWarning(Form("Object type %s not supported\n", rectrack->IsA()->GetName()));
165 //____________________________________________________________
166 void AliHFEtrdPIDqaV1::ProcessESDtrack(const AliESDtrack *track, AliHFEdetPIDqa::EStep_t step, Int_t species){
168 // Fill QA histograms
170 Double_t container[4];
171 container[0] = species;
172 container[1] = track->GetOuterParam() ? track->GetOuterParam()->P() : track->P();
173 container[2] = fESDpid->NumberOfSigmasTPC(track, AliPID::kElectron);
175 fHistos->Fill("hTPCsigma", container);
178 track->GetTRDpid(pid);
179 container[2] = pid[AliPID::kElectron];
180 fHistos->Fill("hTRDlikelihood", container);
182 Double_t charge = 0.;
183 for(Int_t ily = 0; ily < 6; ily++){
185 for(Int_t isl = 0; isl < track->GetNumberOfTRDslices(); isl++){
186 charge += track->GetTRDslice(ily, isl);
188 fHistos->Fill("hTRDcharge", container);
192 //_________________________________________________________
193 void AliHFEtrdPIDqaV1::ProcessAODtrack(const AliAODTrack * /*track*/, AliHFEdetPIDqa::EStep_t /*step*/, Int_t /*species*/){
199 //_________________________________________________________
200 TH2 *AliHFEtrdPIDqaV1::MakeTPCspectrumNsigma(AliHFEdetPIDqa::EStep_t step, Int_t species){
202 // Get the TPC control histogram for the TRD selection step (either before or after PID)
204 printf("histos :%p\n", fHistos);
205 THnSparseF *histo = dynamic_cast<THnSparseF *>(fHistos->Get("hTPCsigma"));
207 AliError("QA histogram monitoring TPC nSigma not available");
210 if(species > -1 && species < AliPID::kSPECIES){
211 // cut on species (if available)
212 histo->GetAxis(0)->SetRange(species + 2, species + 2); // undef + underflow
214 histo->GetAxis(3)->SetRangeUser(species + 1, species + 1);
216 TH2 *hSpec = histo->Projection(2, 1);
217 // construct title and name
218 TString stepname = step ? "before" : "after";
219 TString speciesname = species > -1 && species < AliPID::kSPECIES ? AliPID::ParticleName(species) : "all Particles";
220 TString specID = species > -1 && species < AliPID::kSPECIES ? AliPID::ParticleName(species) : "unid";
221 TString histname = Form("hSigmaTPC%s%s", specID.Data(), stepname.Data());
222 TString histtitle = Form("TPC Sigma for %s %s PID", speciesname.Data(), stepname.Data());
223 hSpec->SetName(histname.Data());
224 hSpec->SetTitle(histtitle.Data());
226 // Unset range on the original histogram
227 histo->GetAxis(0)->SetRange(0, histo->GetAxis(0)->GetNbins());
228 histo->GetAxis(2)->SetRange(0, histo->GetAxis(2)->GetNbins());
232 //_________________________________________________________
233 TH2 *AliHFEtrdPIDqaV1::MakeTRDlikelihoodDistribution(AliHFEdetPIDqa::EStep_t step, Int_t species){
235 // Make Histogram for TRD Likelihood distribution
237 THnSparseF *histo = dynamic_cast<THnSparseF *>(fHistos->Get("hTRDlikelihood"));
239 AliError("QA histogram monitoring TRD Electron Likelihood not available");
242 if(species > -1 && species < AliPID::kSPECIES){
243 // cut on species (if available)
244 histo->GetAxis(0)->SetRange(species + 2, species + 2); // undef + underflow
246 histo->GetAxis(3)->SetRangeUser(species + 1, species + 1);
248 TH2 *hSpec = histo->Projection(2, 1);
249 // construct title and name
250 TString stepname = step ? "before" : "after";
251 TString speciesname = species > -1 && species < AliPID::kSPECIES ? AliPID::ParticleName(species) : "all Particles";
252 TString specID = species > -1 && species < AliPID::kSPECIES ? AliPID::ParticleName(species) : "unid";
253 TString histname = Form("hLikeElTRD%s%s", specID.Data(), stepname.Data());
254 TString histtitle = Form("TRD electron Likelihood for %s %s PID", speciesname.Data(), stepname.Data());
255 hSpec->SetName(histname.Data());
256 hSpec->SetTitle(histtitle.Data());
258 // Unset range on the original histogram
259 histo->GetAxis(0)->SetRange(0, histo->GetAxis(0)->GetNbins());
260 histo->GetAxis(2)->SetRange(0, histo->GetAxis(2)->GetNbins());
264 //_________________________________________________________
265 TH2 *AliHFEtrdPIDqaV1::MakeTRDchargeDistribution(AliHFEdetPIDqa::EStep_t step, Int_t species){
267 // Make Histogram for TRD Likelihood distribution
269 THnSparseF *histo = dynamic_cast<THnSparseF *>(fHistos->Get("hTRDcharge"));
271 AliError("QA histogram monitoring TRD total charge not available");
274 if(species > -1 && species < AliPID::kSPECIES){
275 // cut on species (if available)
276 histo->GetAxis(0)->SetRange(species + 2, species + 2); // undef + underflow
278 histo->GetAxis(3)->SetRangeUser(species + 1, species + 1);
280 TH2 *hSpec = histo->Projection(2, 1);
281 // construct title and name
282 TString stepname = step ? "before" : "after";
283 TString speciesname = species > -1 && species < AliPID::kSPECIES ? AliPID::ParticleName(species) : "all Particles";
284 TString specID = species > -1 && species < AliPID::kSPECIES ? AliPID::ParticleName(species) : "unid";
285 TString histname = Form("hChargeTRD%s%s", specID.Data(), stepname.Data());
286 TString histtitle = Form("TRD total charge for %s %s PID", speciesname.Data(), stepname.Data());
287 hSpec->SetName(histname.Data());
288 hSpec->SetTitle(histtitle.Data());
290 // Unset range on the original histogram
291 histo->GetAxis(0)->SetRange(0, histo->GetAxis(0)->GetNbins());
292 histo->GetAxis(2)->SetRange(0, histo->GetAxis(2)->GetNbins());