]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG3/hfe/AliHFEpidQA.cxx
Fixes to cure warnings
[u/mrichter/AliRoot.git] / PWG3 / hfe / AliHFEpidQA.cxx
CommitLineData
70da6c5a 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**************************************************************************/
15//
16// Class for PID QA
17// Several studies done on clean samples of electrons, pions and kaons
18// coming from V0 PID
19// Compatible with both ESDs and AODs
20//
21// Autors:
22// Matus Kalisky <matus.kalisky@cern.ch>
23// Markus Heide <mheide@uni-muenster.de>
24// Markus Fasel <M.Fasel@gsi.de>
25//
26#include <TClass.h>
27#include <TIterator.h>
28#include <TList.h>
29#include <TMath.h>
30#include <TObjArray.h>
31#include <TParticle.h>
32#include <TPDGCode.h>
33#include <TString.h>
34
35#include "AliAODMCParticle.h"
36#include "AliAODPid.h"
37#include "AliAODTrack.h"
38#include "AliESDtrack.h"
39#include "AliLog.h"
40#include "AliMCEvent.h"
41#include "AliMCParticle.h"
42#include "AliPID.h"
43#include "AliESDpid.h"
44//#include "AliTRDPIDResponseLQ1D.h"
45#include "AliVEvent.h"
46#include "AliVParticle.h"
47#include "AliExternalTrackParam.h"
48
49
50#include "AliHFEcollection.h"
51#include "AliHFEpidQA.h"
52#include "AliHFEV0pid.h"
53#include "AliHFEV0pidMC.h"
54#include "AliHFEpidTRD.h"
55
56ClassImp(AliHFEpidQA)
57
58//__________________________________________
59AliHFEpidQA::AliHFEpidQA():
60 fMC(NULL)
61 , fV0pid(NULL)
62 , fV0pidMC(NULL)
63 , fOutput(NULL)
64 , fT0(0)
65 , fRun(0)
66 , fESDpid(NULL)
67{
68 //
69 // Default constructor
70 //
71 fESDpid = new AliESDpid;
72}
73
74//__________________________________________
75AliHFEpidQA::~AliHFEpidQA(){
76 //
77 // Destructor
78 //
79 if(fV0pid) delete fV0pid;
80 if(fV0pidMC) delete fV0pidMC;
81 if(fOutput) delete fOutput;
82 if(fESDpid) delete fESDpid;
83// if(fTRDpidResponse) delete fTRDpidResponse;
84}
85
86//__________________________________________
87void AliHFEpidQA::Init(){
88 //
89 // Prepare task output
90 //
91
92 fV0pid = new AliHFEV0pid;
93 if(HasV0pidQA()) fV0pid->InitQA();
94 fV0pidMC = new AliHFEV0pidMC();
95 fV0pidMC->Init();
96
97 fOutput = new AliHFEcollection("pidQA", "PID QA output");
98
99 // 1st: Histos for purity studies
100 fOutput->CreateTH2F("purityElectron", "Electron Putrity", 2, -0.5, 1.5, 20, 0.1, 10);
101 fOutput->BinLogAxis("purityElectron" ,1);
102 fOutput->CreateTH2F("purityPionK0", "K0 Pion Putrity", 2, -0.5, 1.5, 20, 0.1, 10);
103 fOutput->BinLogAxis("purityPionK0" ,1);
104 fOutput->CreateTH2F("purityPionL", "Lambda Pion Putrity", 2, -0.5, 1.5, 20, 0.1, 10);
105 fOutput->BinLogAxis("purityPionL" ,1);
106 fOutput->CreateTH2F("purityProton", "Proton Putrity", 2, -0.5, 1.5, 20, 0.1, 10);
107 fOutput->BinLogAxis("purityProton" ,1);
108
109 // Histograms for TRD Electron Likelihood
110 fOutput->CreateTH2F("hTRDelLikeElectron", "TRD Electron Likelihoods for Electrons; p (GeV/c); likelihood", 20, 0.1, 10, 100, 0., 1.);
111 fOutput->BinLogAxis("hTRDelLikeElectron", 0);
112 fOutput->CreateTH2F("hTRDelLikePionK0", "TRD Electron Likelihoods for K0 Pions; p (GeV/c); likelihood", 20, 0.1, 10, 100, 0., 1.);
113 fOutput->BinLogAxis("hTRDelLikePionK0", 0);
114 fOutput->CreateTH2F("hTRDelLikePionL", "TRD Electron Likelihoods for Lambda Pions; p (GeV/c); likelihood", 20, 0.1, 10, 100, 0., 1.);
115 fOutput->BinLogAxis("hTRDelLikePionL", 0);
116 fOutput->CreateTH2F("hTRDelLikeProton", "TRD Electron Likelihoods for Protons; p (GeV/c); likelihood", 20, 0.1, 10, 100, 0., 1.);
117 fOutput->BinLogAxis("hTRDelLikeProton", 0);
118
119 // TPC pid response
120 fOutput->CreateTH2F("hTPC_dEdx_Electron", "TPC dEdx for conversion electrons; p (GeV/c); dEdx (a.u.)", 20, 0.1, 10, 200, 0, 200);
121 fOutput->BinLogAxis("hTPC_dEdx_Electron", 0);
122 fOutput->CreateTH2F("hTPC_dEdx_PionK0", "TPC dEdx for K0 pions; p (GeV/c); dEdx (a.u.)", 20, 0.1, 10, 200, 0, 200);
123 fOutput->BinLogAxis("hTPC_dEdx_PionK0", 0);
124 fOutput->CreateTH2F("hTPC_dEdx_PionL", "TPC dEdx for Lambda pions; p (GeV/c); dEdx (a.u.)", 20, 0.1, 10, 200, 0, 200);
125 fOutput->BinLogAxis("hTPC_dEdx_PionL", 0);
126 fOutput->CreateTH2F("hTPC_dEdx_Proton", "TPC dEdx for Lambda proton; p (GeV/c); dEdx (a.u.)", 20, 0.1, 10, 200, 0, 200);
127 fOutput->BinLogAxis("hTPC_dEdx_Proton", 0);
128
129 fOutput->CreateTH2F("hTPCnSigmaElectron", "TPC number of sigmas for conversion electrons; p (GeV/c); number of sigmas", 20, 0.1, 10, 100, -7, 7);
130 fOutput->BinLogAxis("hTPCnSigmaElectron", 0);
131 fOutput->CreateTH2F("hTPCnSigmaPionK0", "TPC number of sigmas for K0 pions; p (GeV/c); number of sigmas", 20, 0.1, 10, 100, -7, 7);
132 fOutput->BinLogAxis("hTPCnSigmaPionK0", 0);
133 fOutput->CreateTH2F("hTPCnSigmaPionL", "TPC number of sigmas for Lambda pions; p (GeV/c); number of sigmas", 20, 0.1, 10, 100, -7, 7);
134 fOutput->BinLogAxis("hTPCnSigmaPionL", 0);
135 fOutput->CreateTH2F("hTPCnSigmaProton", "TPC number of sigmas for Lambda protons; p (GeV/c); number of sigmas", 20, 0.1, 10, 100, -7, 7);
136 fOutput->BinLogAxis("hTPCnSigmaProton", 0);
137
138 fOutput->CreateTH2F("hTPC_PID", "TPC pid all tracks; tpc pid probability; species",100, 0, 1, 5, -0.5, 4.5 );
91c7e1ec 139 fOutput->CreateTH2F("hTPC_PID_p_Electron", "TPC PID for conversion electrons; p (GeV/c); TPC PID", 100, 0.1, 10, 5, -0.5, 4.5);
140 fOutput->BinLogAxis("hTPC_PID_p_Electron", 0);
141 fOutput->CreateTH2F("hTPC_PID_p_PionK0", "TPC PID for K0 pions; p (GeV/c); TPC PID", 100, 0.1, 10, 5, -0.5, 4.5);
142 fOutput->BinLogAxis("hTPC_PID_p_PionK0", 0);
143 fOutput->CreateTH2F("hTPC_PID_p_PionL", "TPC PID for Lambda pions; p (GeV/c); TPC PID", 100, 0.1, 10, 5, -0.5, 4.5);
144 fOutput->BinLogAxis("hTPC_PID_p_PionL", 0);
145 fOutput->CreateTH2F("hTPC_PID_p_Proton", "TPC PID for Lambda protons; p (GeV/c); TPC PID", 100, 0.1, 10, 5, -0.5, 4.5);
146 fOutput->BinLogAxis("hTPC_PID_p_Proton", 0);
70da6c5a 147
148
149 // TRD pid response
150 fOutput->CreateTH2F("hTRD_Electron_trk", "all Electron candidate tracklets; p (GeV/c); N TRD tracklets", 100, 0.1, 10, 7, -0.5, 6.5);
151 fOutput->BinLogAxis("hTRD_Electron_trk", 0);
152 fOutput->CreateTH1F("hTRD_Electron_Y_like", "YES - V0 electron eff. for fixed likelihood cut; p (GeV/c); counts", 25, 0.1, 10);
153 fOutput->BinLogAxis("hTRD_Electron_Y_like", 0);
154 fOutput->CreateTH1F("hTRD_Electron_N_like", "NO - V0 electron eff. for fixed likelihood cut; p (GeV/c); counts", 25, 0.1, 10);
155 fOutput->BinLogAxis("hTRD_Electron_N_like", 0);
156 fOutput->CreateTH2F("hTRD_El_like_Electron", "V0 electron likelihoods for electrons; p (GeV/c); likelihood", 25, 0.1, 10, 1000, 0., 1.);
157 fOutput->BinLogAxis("hTRD_El_like_Electron", 0);
158 fOutput->CreateTH2F("hTRD_El_like_Pion", "V0 electron likelihoods for poins; p (GeV/c); likelihood", 25, 0.1, 10, 1000, 0., 1.);
159 fOutput->BinLogAxis("hTRD_El_like_Pion", 0);
160 fOutput->CreateTH2F("hTRD_El_like_Proton", "V0 electron likelihoods for protons; p (GeV/c); likelihood", 25, 0.1, 10, 1000, 0., 1.);
161 fOutput->BinLogAxis("hTRD_El_like_Proton", 0);
162
163
164 // TOF pid response
165
166 fOutput->CreateTH2F("hTOF_PID", "TOF pid all tracks; tof pid probability; species",100, 0, 1,5, -0.5, 4.5 );
167
91c7e1ec 168 fOutput->CreateTH2F("hTOF_PID_p_Electron", "TOF PID for gamma converisons; p_T (GeV/c); counts", 100, 0.1, 10, 5, -0.5, 4.5);
169 fOutput->BinLogAxis("hTOF_PID_p_Electron", 0);
170 fOutput->CreateTH2F("hTOF_PID_p_PionK0", "TOF PID for K0 pions; p_T (GeV/c); counts", 100, 0.1, 10, 5, -0.5, 4.5);
171 fOutput->BinLogAxis("hTOF_PID_p_PionK0", 0);
172 fOutput->CreateTH2F("hTOF_PID_p_PionL", "TOF PID for Lambda pions; p_T (GeV/c); counts", 100, 0.1, 10, 5, -0.5, 4.5);
173 fOutput->BinLogAxis("hTOF_PID_p_PionL", 0);
174 fOutput->CreateTH2F("hTOF_PID_p_Proton", "TOF PID for Lambda protons; p_T (GeV/c); counts", 100, 0.1, 10, 5, -0.5, 4.5);
175 fOutput->BinLogAxis("hTOF_PID_p_Proton", 0);
70da6c5a 176
177 fOutput->CreateTH2F("hTOF_beta_Electron", "TOF beta for gamma conversions; #beta; p (GeV/c)", 120, 0, 1.2, 100, 0.1, 10);
178 fOutput->BinLogAxis("hTOF_beta_Electron", 1);
179 fOutput->CreateTH2F("hTOF_beta_PionK0", "TOF beta for K0 pions; #beta; p (GeV/c)", 120, 0, 1.2, 100, 0.1, 10);
180 fOutput->BinLogAxis("hTOF_beta_PionK0", 1);
181 fOutput->CreateTH2F("hTOF_beta_PionL", "TOF beta Lambda pions; #beta; p (GeV/c)", 120, 0, 1.2, 100, 0.1, 10);
182 fOutput->BinLogAxis("hTOF_beta_PionL", 1);
183 fOutput->CreateTH2F("hTOF_beta_Proton", "TOF beta for Lambda protons; #beta; p (GeV/c)", 120, 0, 1.2, 100, 0.1, 10);
184 fOutput->BinLogAxis("hTOF_beta_Proton", 1);
185
186
187
188 // Prepare TRD PID
189/* if(HasRecalculateTRDpid()){
190 fTRDpidResponse = new AliTRDPIDResponseLQ1D;
191 fTRDpidResponse->LoadReferences();
192 }*/
193}
194
195//__________________________________________
196void AliHFEpidQA::Process(AliVEvent *inputEvent){
197 //
198 // Run PID QA
199 //
200
201 if(fRun >= 104065 && fRun <= 104892){
202 CorrectT0();
203 }
204
205 if(!fV0pid){
206 AliError("V0pid not available! Forgotten to initialize?");
207 return;
208 }
209
210 if(fMC) fV0pidMC->SetMCEvent(fMC);
211
212 fV0pid->Process(inputEvent);
213 TObjArray *electrons = fV0pid->GetListOfElectrons();
214 TObjArray *pionsK0 = fV0pid->GetListOfPionsK0();
215 TObjArray *pionsL = fV0pid->GetListOfPionsL();
216 TObjArray *protons = fV0pid->GetListOfProtons();
217
218 if(fMC){
219 fV0pidMC->Process(electrons, AliHFEV0pid::kRecoElectron);
220 fV0pidMC->Process(pionsK0, AliHFEV0pid::kRecoPionK0);
221 fV0pidMC->Process(pionsL, AliHFEV0pid::kRecoPionL);
222 fV0pidMC->Process(protons, AliHFEV0pid::kRecoProton);
223 }
224
225 AliDebug(2, Form("Number of Electrons : %d", electrons->GetEntries()));
226 AliDebug(2, Form("Number of K0 Pions : %d", pionsK0->GetEntries()));
227 AliDebug(2, Form("Number of Lambda Pions : %d", pionsL->GetEntries()));
228 AliDebug(2, Form("Number of Protons : %d", protons->GetEntries()));
229 if(fMC){
230 AliDebug(2, "MC Information available. Doing Purity checks...");
231 // Calculate the purity of the clean samples using MC
232 MakePurity(electrons, AliHFEV0pid::kRecoElectron);
233 MakePurity(pionsK0, AliHFEV0pid::kRecoPionK0);
234 MakePurity(pionsL, AliHFEV0pid::kRecoPionL);
235 MakePurity(protons, AliHFEV0pid::kRecoProton);
236 }
237 // Now we can do studies on the PID itself
238 // TRD PID: Fill electron Likelihoods for the particle species
239 FillTRDelectronLikelihoods(electrons, AliHFEV0pid::kRecoElectron);
240 FillTRDelectronLikelihoods(pionsK0, AliHFEV0pid::kRecoPionK0);
241 FillTRDelectronLikelihoods(pionsL, AliHFEV0pid::kRecoPionL);
242 FillTRDelectronLikelihoods(protons, AliHFEV0pid::kRecoProton);
243
244 FillPIDresponse(electrons, AliHFEV0pid::kRecoElectron);
245 FillPIDresponse(pionsK0, AliHFEV0pid::kRecoPionK0);
246 FillPIDresponse(pionsL, AliHFEV0pid::kRecoPionL);
247 FillPIDresponse(protons, AliHFEV0pid::kRecoProton);
248
249 // Analysis done, flush the containers
250 fV0pid->Flush();
251}
252
253//__________________________________________
254void AliHFEpidQA::MakePurity(TObjArray *tracks, Int_t species){
255 //
256 // Fill the QA histos for a given species
257 //
258 if(!fMC) return;
259 AliDebug(3, Form("Doing Purity checks for species %d", species));
260 Int_t pdg = 0;
261 Char_t hname[256];
262 switch(species){
263 case AliHFEV0pid::kRecoElectron:
264 pdg = TMath::Abs(kElectron);
265 sprintf(hname, "purityElectron");
266 break;
267 case AliHFEV0pid::kRecoPionK0:
268 pdg = TMath::Abs(kPiPlus);
269 sprintf(hname, "purityPionK0");
270 break;
271 case AliHFEV0pid::kRecoPionL:
272 pdg = TMath::Abs(kPiPlus);
273 sprintf(hname, "purityPionL");
274 break;
275 case AliHFEV0pid::kRecoProton:
276 pdg = TMath::Abs(kProton);
277 sprintf(hname, "purityProton");
278 break;
279 default: // non investigated species
280 AliDebug(3, "Species not investigated");
281 return;
282 }
283 AliDebug(3, Form("Number of tracks: %d", tracks->GetEntries()));
284 TIterator *trackIter = tracks->MakeIterator();
285 AliVParticle *recTrack = NULL, *mcTrack = NULL;
286 while((recTrack = dynamic_cast<AliVParticle *>(trackIter->Next()))){
287 Int_t label = recTrack->GetLabel();
288 AliDebug(4, Form("MC Label %d", label));
289 mcTrack =fMC->GetTrack(TMath::Abs(label));
290 if(!mcTrack){
291 AliDebug(4, "MC track not available");
292 continue; // we don't know
293 }
294
295 // Get the pdg code
296 Int_t trackPdg = 0;
297 if(!TString(mcTrack->IsA()->GetName()).CompareTo("AliMCParticle")){
298 // case ESD
299 AliMCParticle *mcp = dynamic_cast<AliMCParticle *>(mcTrack);
300 trackPdg = TMath::Abs(mcp->Particle()->GetPdgCode());
301 } else {
302 // case AOD
303 AliAODMCParticle *aodmcp = dynamic_cast<AliAODMCParticle *>(mcTrack);
304 trackPdg = TMath::Abs(aodmcp->GetPdgCode());
305 }
306 if(trackPdg == pdg) // Correct identification
307 fOutput->Fill(hname, 0., recTrack->Pt());
308 else // Wrong identification
309 fOutput->Fill(hname, 1., recTrack->Pt());
310 }
311 delete trackIter;
312}
313
314//__________________________________________
315void AliHFEpidQA::FillTRDelectronLikelihoods(TObjArray * const particles, Int_t species){
316 //
317 // Fill electron Likelihoods for the TRD
318 // Required for the calculation of the electron efficiency,
319 // pion and proton efficiency and the thresholds
320 //
321 Char_t hname[256] = "hTRDelLike";
322 switch(species){
323 case AliHFEV0pid::kRecoElectron:
324 sprintf(hname, "%sElectron", hname);
325 break;
326 case AliHFEV0pid::kRecoPionK0:
327 sprintf(hname, "%sPionK0", hname);
328 break;
329 case AliHFEV0pid::kRecoPionL:
330 sprintf(hname, "%sPionL", hname);
331 break;
332 case AliHFEV0pid::kRecoProton:
333 sprintf(hname, "%sProton", hname);
334 break;
335 default:
336 AliDebug(2, Form("Species %d not investigated", species));
337 return;
338 };
339 AliVParticle *recTrack = NULL;
340 TIterator *trackIter = particles->MakeIterator();
341 Double_t quantities[2] = {0., 0.};
342 Double_t trdPidProbs[5];
343 while((recTrack = dynamic_cast<AliVParticle *>(trackIter->Next()))){
344 if(!TString(recTrack->IsA()->GetName()).CompareTo("AliESDtrack")){
345 // case ESD
346 AliESDtrack *esdTrack = dynamic_cast<AliESDtrack *>(recTrack);
347 if(!esdTrack->GetTRDntracklets()) continue; // require at least 1 tracklet
348 // take momentum at the innermost TRD layer
349 Double_t p = 0.;
350 for(Int_t ily = 0; ily < 6; ily++){
351 if((p = esdTrack->GetTRDmomentum(ily)) > 1e-6) break;
352 }
353 quantities[0] = p;
354 if(HasRecalculateTRDpid())
355 RecalculateTRDpid(esdTrack, trdPidProbs);
356 else
357 esdTrack->GetTRDpid(trdPidProbs);
358 quantities[1] = trdPidProbs[ AliPID::kElectron];
359 }
360 else{
361 AliAODTrack *aodTrack = dynamic_cast<AliAODTrack *>(recTrack);
362 if(!aodTrack->GetDetPid()) continue;
363 Float_t *trdMom = aodTrack->GetDetPid()->GetTRDmomentum(), p = 0.;
364 for(Int_t ily = 0; ily < 6; ily++){
365 if((p = trdMom[ily]) > 1e-6) break;
366 }
367 quantities[0] = p;
368 // case AOD (for the moment lacks)
369 if(HasRecalculateTRDpid()){
370 RecalculateTRDpid(aodTrack, trdPidProbs);
371 quantities[1] = trdPidProbs[AliPID::kElectron];
372 }
373 else
374 continue;
375 }
376 fOutput->Fill(hname, quantities[0], quantities[1]);
377 }
378}
379//__________________________________________
380void AliHFEpidQA::FillPIDresponse(TObjArray * const particles, Int_t species){
381 //
382 // Fill the PID response of different detectors to V0 daughter particles
383 //
384 Char_t hname[256] = "";
385 const Char_t *typeName[5] = {"Electron", "PionK0", "PionL", "Kaon", "Proton"};
386 const Int_t typePID[5] = {0, 2, 2, 3, 4};
387
388 AliHFEpidTRD *pidTRD = new AliHFEpidTRD("TRDpid");
389
390 AliVParticle *recTrack = NULL;
391 TIterator *trackIter = particles->MakeIterator();
392 while((recTrack = dynamic_cast<AliVParticle *>(trackIter->Next()))){
393 // ESD
394 if(!TString(recTrack->IsA()->GetName()).CompareTo("AliESDtrack")){
395 // case ESD
396 AliESDtrack *esdTrack = dynamic_cast<AliESDtrack *>(recTrack);
397 const AliExternalTrackParam *tpcIn = esdTrack->GetTPCInnerParam();
398 if(!tpcIn) continue;
399
400 // track kinematics
401 Double_t p = tpcIn->P();
91c7e1ec 402 //Double_t pt = tpcIn->Pt();
70da6c5a 403
404 // TPC dEdx
405 Double_t dEdx = esdTrack->GetTPCsignal();
406 sprintf(hname, "hTPC_dEdx_%s", typeName[species]);
407 fOutput->Fill(hname, p, dEdx);
408
409 //TPC number of sigmas
91c7e1ec 410 Double_t nsigma = fESDpid->NumberOfSigmasTPC(esdTrack,(AliPID::EParticleType)typePID[species]);
70da6c5a 411 sprintf(hname, "hTPCnSigma%s", typeName[species]);
412 fOutput->Fill(hname, p, nsigma);
413
414 // TPC PID response
91c7e1ec 415 sprintf(hname, "hTPC_PID_p_%s", typeName[species]);
70da6c5a 416 Double_t tpcPID[5] = {-1, -1, -1, -1, -1};
417 esdTrack->GetTPCpid(tpcPID);
418 Int_t ix = 0;
419 Double_t tmp = 0.;
420 for(Int_t k=0; k<5; ++k){
421 if(tpcPID[k] > tmp){
422 ix = k;
423 tmp = tpcPID[k];
424 }
425 fOutput->Fill("hTPC_PID", tpcPID[k], k);
426 }
427 if(tpcPID[ix] > 0){
91c7e1ec 428 fOutput->Fill(hname, p, ix);
70da6c5a 429 }
430
431 // TOF PID response
91c7e1ec 432 sprintf(hname, "hTOF_PID_p_%s", typeName[species]);
70da6c5a 433 Double_t tofPID[5] = {-1., -1., -1., -1., -1};
434 esdTrack->GetTOFpid(tofPID);
435 tmp = 0.;
436 for(Int_t k=0; k<5; ++k){
437 if(tofPID[k] > tmp){
438 ix = k;
439 tmp = tofPID[k];
440 }
441 if(tofPID[k] > 0)
442 fOutput->Fill("hTOF_PID", tofPID[k], k);
443 }
444 if(tofPID[ix] > 0){
91c7e1ec 445 fOutput->Fill(hname, p, ix);
70da6c5a 446 }
447
448 //TRD first electron only
449 Int_t nTRK = (int)esdTrack->GetTRDntrackletsPID();
450 if(AliHFEV0pid::kRecoElectron == species){
451 sprintf(hname, "hTRD_%s_trk", typeName[species]);
452 fOutput->Fill(hname, p, nTRK);
453 }
454 Char_t n1[256] = "";
455 Char_t n2[256] = "";
456 Double_t pidProbs[AliPID::kSPECIES];
457 esdTrack->GetTRDpid(pidProbs);
458 Double_t threshold = pidTRD->GetTRDthresholds(0.9, p);
459 if(AliHFEV0pid::kRecoElectron == species && 6 == nTRK){
460 sprintf(n1, "hTRD_%s_Y_like", typeName[species]);
461 sprintf(n2, "hTRD_%s_N_like", typeName[species]);
462 if(pidProbs[typePID[0]] > threshold) fOutput->Fill(n1, p);
463 else fOutput->Fill(n2, p);
464 sprintf(hname, "hTRD_El_like_Electron");
465 fOutput->Fill(hname, p, pidProbs[typePID[species]]);
466 }
467 if( ((AliHFEV0pid::kRecoPionK0 == species) || (AliHFEV0pid::kRecoPionL == species)) && 6 == nTRK ){
468 sprintf(hname, "hTRD_El_like_Pion");
469 fOutput->Fill(hname, p, pidProbs[typePID[0]]);
470 }
471 if(AliHFEV0pid::kRecoProton == species && 6 == nTRK){
472 sprintf(hname,"hTRD_El_like_Proton");
473 fOutput->Fill(hname, p, pidProbs[typePID[0]]);
474 }
475
476
477 //TOF beta
478 sprintf(hname, "hTOF_beta_%s", typeName[species]);
479 Float_t beta = TOFbeta(esdTrack);
480 fOutput->Fill(hname, beta, p);
481 }
482 // AOD - comming soon
483 else{
484 continue;
485 }
486 }// .. tracks in TObjArray
487
488 if(pidTRD) delete pidTRD;
489
490}
491
492//__________________________________________
493TList *AliHFEpidQA::GetOutput(){
494 //
495 // Getter for Output histograms
496 //
497 return fOutput->GetList();
498}
499
500//__________________________________________
501TList *AliHFEpidQA::GetV0pidQA(){
502 //
503 // Getter for V0 PID QA histograms
504 //
505 return fV0pid->GetListOfQAhistograms();
506}
507
508//__________________________________________
509TList *AliHFEpidQA::GetV0pidMC(){
510 //
511 // Getter for V0 PID QA histograms
512 //
513 if(fV0pidMC)
514 return fV0pidMC->GetListOfQAhistograms();
515 return NULL;
516}
517
518//__________________________________________
519void AliHFEpidQA::RecalculateTRDpid(AliESDtrack * /*track*/, Double_t * /*pidProbs*/) const{
520// fTRDpidResponse->MakePID(track);
521// track->GetTRDpid(pidProbs);
522}
523
524//__________________________________________
525void AliHFEpidQA::RecalculateTRDpid(AliAODTrack * /*track*/, Double_t * /*pidProbs*/) const{
526// fTRDpidResponse->MakePID(track, pidProbs);
527}
528//___________________________________________________________________
529void AliHFEpidQA::CorrectT0(){
530 // temporary solutions for correction the T0 for pass4 & pass5
531 // returns corrected T0 for known runs
532 // returns 0 if the correction failed
533 if(! fRun > 0){
534 AliError("Run number not set");
535 fT0 = 0.;
536 return;
537 }
538 Bool_t runFound = kFALSE;
539 const Int_t corr[31][2] = {{104065, 1771614},
540 {104068, 1771603},
541 {104070, 1771594},
542 {104073, 1771610},
543 {104080, 1771305},
544 {104083, 1771613},
545 {104157, 1771665},
546 {104159, 1771679},
547 {104160, 1771633},
548 {104316, 1764344},
549 {104320, 1764342},
550 {104321, 1764371},
551 {104439, 1771750},
552 {104792, 1771755},
553 {104793, 1771762},
554 {104799, 1771828},
555 {104800, 1771788},
556 {104801, 1771796},
557 {104802, 1771775},
558 {104803, 1771795},
559 {104824, 1771751},
560 {104825, 1771763},
561 {104845, 1771792},
562 {104852, 1771817},
563 {104864, 1771825},
564 {104865, 1771827},
565 {104867, 1771841},
566 {104876, 1771856},
567 {104878, 1771847},
568 {104879, 1771830},
569 {104892, 1771837}};
570
571 for(Int_t i=0; i<31; ++i){
572 if(fRun == corr[i][0]){
573 runFound = kTRUE;
574 fT0 = (float)corr[i][1];
575 // for the pass4 & pass5
576 fT0 -= 37*1024*24.4 - 170.;
577 //..
578 break;
579 }
580 }
581
582 if(!runFound){
583 TString error = "Setting T0 correction FAILED, no TOF pid available for run: ";
584 error += fRun;
585 AliError(error);
586 fT0 = 0.;
587 }
588 //cout<<" -D: run: "<<current_run<<" , fT0: "<<fT0<<endl;
589
590}
591//___________________________________________________________________
592Float_t AliHFEpidQA::TOFbeta(AliESDtrack * const track) const {
593 // computes the TOF beta
594 Double_t l = track->GetIntegratedLength(); // cm
595 Double_t t = track->GetTOFsignal();
596 Double_t t0 = fT0; // ps
597 if(l < 360. || l > 800.) return 0.;
598 if(t <= 0.) return 0.;
599 if(t0 <= 0.) return 0.;
600
601 t -= t0; // subtract the T0
602
603 l *= 0.01; // cm ->m
604 t *= 1e-12; //ps -> s
605
606
607 Double_t v = l / t;
608 Float_t beta = v / TMath::C();
609
610 return beta;
611}
612