]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGHF/hfe/AliHFEdebugTreeTask.cxx
Update of hfe code
[u/mrichter/AliRoot.git] / PWGHF / hfe / AliHFEdebugTreeTask.cxx
CommitLineData
fda75e2d 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// Debug tree task
17//
18// Authors:
19// Markus Fasel <M.Fasel@gsi.de>
20//
21#include <TBits.h>
22#include <TString.h>
23
24#include "AliAnalysisManager.h"
25#include "AliCentrality.h"
26#include "AliESDEvent.h"
27#include "AliESDtrack.h"
28#include "AliESDtrackCuts.h"
29#include "AliESDVertex.h"
30#include "AliHFEcuts.h"
31#include "AliHFEsignalCuts.h"
32#include "AliInputEventHandler.h"
33#include "AliLog.h"
34#include "AliMCEvent.h"
35#include "AliMCEventHandler.h"
36#include "AliMCParticle.h"
37#include "AliPIDResponse.h"
11ff28c5 38#include "AliTrackReference.h"
fda75e2d 39#include "AliVEvent.h"
11ff28c5 40#include "AliHFEpidTPC.h"
a8ef1999 41#include "AliHFEpidTRD.h"
11ff28c5 42#include "AliHFEmcQA.h"
fda75e2d 43#include "TTreeStream.h"
44
45#include "AliHFEdebugTreeTask.h"
46
47ClassImp(AliHFEdebugTreeTask)
48
49AliHFEdebugTreeTask::AliHFEdebugTreeTask():
50 AliAnalysisTaskSE(),
51 fTrackCuts(NULL),
52 fSignalCuts(NULL),
a8ef1999 53 fTRDpid(NULL),
11ff28c5 54 fTPCpid(NULL),
55 fExtraCuts(NULL),
fda75e2d 56 fNclustersTPC(70),
57 fNclustersTPCPID(0),
58 fNclustersITS(2),
59 fFilename("HFEtree.root"),
11ff28c5 60 fDebugTree(NULL),
61 fNparents(-1)
fda75e2d 62{
63
64}
65
66AliHFEdebugTreeTask::AliHFEdebugTreeTask(const char *name):
67 AliAnalysisTaskSE(name),
68 fTrackCuts(NULL),
69 fSignalCuts(NULL),
a8ef1999 70 fTRDpid(NULL),
11ff28c5 71 fTPCpid(NULL),
72 fExtraCuts(NULL),
fda75e2d 73 fNclustersTPC(70),
74 fNclustersTPCPID(0),
75 fNclustersITS(2),
76 fFilename("HFEtree.root"),
11ff28c5 77 fDebugTree(NULL),
78 fNparents(-1)
fda75e2d 79{
11ff28c5 80 fTRDpid = new AliHFEpidTRD("QAtrdPID");
81 fTPCpid = new AliHFEpidTPC("QAtpcPID");
fda75e2d 82}
83
84AliHFEdebugTreeTask::~AliHFEdebugTreeTask(){
a8ef1999 85 if(fDebugTree) delete fDebugTree;
86 if(fTRDpid) delete fTRDpid;
11ff28c5 87 if(fTPCpid) delete fTPCpid;
fda75e2d 88}
89
90void AliHFEdebugTreeTask::UserCreateOutputObjects(){
91 //
92 // Create debug tree, signal cuts and track cuts
93 //
94 fDebugTree = new TTreeSRedirector(fFilename.Data());
95
96 fSignalCuts = new AliHFEsignalCuts("HFEsignalCuts", "HFE MC Signal definition");
97
98 fTrackCuts = new AliHFEcuts("fTrackCuts", "Basic HFE track cuts");
99 fTrackCuts->CreateStandardCuts();
100 // Track cuts
101 fTrackCuts->SetMinNClustersTPC(fNclustersTPC);
102 fTrackCuts->SetMinRatioTPCclusters(0);
103 fTrackCuts->SetTPCmodes(AliHFEextraCuts::kFound, AliHFEextraCuts::kFoundOverFindable);
104 fTrackCuts->SetMinNClustersTPCPID(fNclustersTPCPID);
105 fTrackCuts->SetMinNClustersITS(fNclustersITS);
106 // Event cuts
107 fTrackCuts->SetUseMixedVertex(kTRUE);
108 fTrackCuts->SetVertexRange(10.);
109 fTrackCuts->Initialize();
a8ef1999 110
11ff28c5 111 fExtraCuts = new AliHFEextraCuts("hfeExtraCuts","HFE Extra Cuts");
a8ef1999 112
fda75e2d 113}
114
115void AliHFEdebugTreeTask::UserExec(Option_t *){
116 //
117 // User Exec: Fill debug Tree
118 //
119
120 // Get PID response
121 AliPIDResponse *pid = NULL;
122 AliInputEventHandler *handler = dynamic_cast<AliInputEventHandler *>(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
123 if(handler){
124 pid = handler->GetPIDResponse();
125 } else {
126 AliError("No Handler");
127 }
128 if(!pid){
317ae21b 129 AliError("No PID response");
130 return;
131 }
132 if(!fInputEvent) {
133 AliError("No Input event");
fda75e2d 134 return;
135 }
11ff28c5 136
137 AliESDtrack copyTrack;
fda75e2d 138
139 fTrackCuts->SetRecEvent(fInputEvent);
140
141 // Cut event
142 if(fInputEvent->IsPileupFromSPD(3, 0.8, 3., 2., 5)){
0e30407a 143 AliDebug(1, "Event flagged as pileup\n");
fda75e2d 144 return;
145 }
146 if(!fTrackCuts->CheckEventCuts("fCutsEvRec", fInputEvent)){
147 AliDebug(1, "Event rejected by the event cuts\n");
148 return;
149 }
150
151 // Get run number
152 Int_t run = fInputEvent->GetRunNumber();
153
154 // Derive trigger
155 UInt_t trigger = fInputHandler->IsEventSelected();
156 Bool_t isMBTrigger = trigger & AliVEvent::kMB;
157 Bool_t isCentralTrigger = trigger & AliVEvent::kCentral;
158 Bool_t isSemicentralTrigger = trigger & AliVEvent::kSemiCentral;
159 Bool_t isEMCALTrigger = trigger & AliVEvent::kEMCEJE;
160
161 // Check if MC information is available
162 Bool_t mcthere = dynamic_cast<AliMCEventHandler *>(AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler()) != NULL;
163 if(mcthere){
164 fTrackCuts->SetMCEvent(fMCEvent);
165 fSignalCuts->SetMCEvent(fMCEvent);
166 }
167
168 // Get Primary Vertex
169 const AliVVertex *vertex = fInputEvent->GetPrimaryVertex();
11ff28c5 170 Double_t vtx[3];
171 vertex->GetXYZ(vtx);
172 Double_t ncontrib = fInputEvent->GetPrimaryVertex()->GetNContributors();
fda75e2d 173
174 // Get centrality
175 Float_t centrality = -1.;
317ae21b 176 AliESDEvent *event = (dynamic_cast<AliESDEvent *>(fInputEvent));
177 if(!event) return;
178 TString beamtype = event->GetBeamType();
179 //printf("Beam type %s\n",(const char*)beamtype);
fda75e2d 180 if(!beamtype.CompareTo("Pb-Pb") || !beamtype.CompareTo("A-A")){
181 // Heavy ion run
182 AliDebug(1, "Heavy-Ion event\n");
183 AliCentrality *hicent = fInputEvent->GetCentrality();
184 centrality = hicent->GetCentralityPercentile("V0M");
185 }
186
11ff28c5 187 if(!fExtraCuts){
188 fExtraCuts = new AliHFEextraCuts("hfeExtraCuts","HFE Extra Cuts");
189 }
190 fExtraCuts->SetRecEventInfo(event);
191
192 // Store event selection variables
193 (*fDebugTree) << "EventDebug"
194 << "Centrality=" << centrality
195 << "VertexZ=" << vtx[2]
196 << "NumberOfContributors=" << ncontrib
959ea9d8 197 << "run=" << run
11ff28c5 198 << "\n";
199
fda75e2d 200 // Common variables
201 Double_t charge, eta, phi, momentum, transversemomentum;
202 Int_t source;
203
204 // Monte-Carlo loop
205 if(mcthere){
206 AliMCParticle * mcpart;
207 for(Int_t itrk = 0; itrk < fMCEvent->GetNumberOfTracks(); itrk++){
208 mcpart = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(itrk));
209 if(!mcpart) continue;
210 if(!fTrackCuts->CheckParticleCuts(static_cast<UInt_t>(AliHFEcuts::kStepMCGenerated), mcpart)) continue;
211 // Kinematics
212 charge = mcpart->Charge() > 0. ? 1. : -1.;
213 momentum = mcpart->P() * charge;
214 transversemomentum = mcpart->Pt() * charge;
215 eta = mcpart->Eta();
216 phi = mcpart->Phi();
217 Int_t pdg = mcpart->Particle()->GetPdgCode();
218
219 // Get Production Vertex in radial direction
220 Double_t vx = mcpart->Particle()->Vx(),
0e30407a 221 vy = mcpart->Particle()->Vy();
fda75e2d 222 Double_t productionVertex = TMath::Sqrt(vx*vx+vy*vy);
223
224 // Get Mother PDG code of the particle
225 Int_t motherPdg = 0;
226 Int_t motherlabel = mcpart->Particle()->GetFirstMother();
227 if(motherlabel >= 0 && motherlabel < fMCEvent->GetNumberOfTracks()){
228 AliMCParticle *mother = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(motherlabel));
229 if(mother) motherPdg = mother->Particle()->GetPdgCode();
230 }
231
232 // derive source
233 source = 5;
234 if(fSignalCuts->IsCharmElectron(mcpart)) source = 0;
235 else if(fSignalCuts->IsBeautyElectron(mcpart)) source = 1;
236 else if(fSignalCuts->IsGammaElectron(mcpart)) source = 2;
237 else if(fSignalCuts->IsNonHFElectron(mcpart)) source = 3;
238 else if(TMath::Abs(pdg) == 11) source = 4;
239 else source = 5;
240
11ff28c5 241 // Momemntum at the inner wall of the TPC
242 Double_t pTPC = 0., ptTPC = 0.;
243 AliTrackReference *ref = FindTrackReference(mcpart, 80, 270, AliTrackReference::kTPC);
244 if(ref){
245 pTPC = ref->P();
246 ptTPC = ref->Pt();
247 }
248
249
250
0e30407a 251 (*fDebugTree) << "MCDebug"
fda75e2d 252 << "centrality=" << centrality
253 << "MBtrigger=" << isMBTrigger
254 << "CentralTrigger=" << isCentralTrigger
255 << "SemicentralTrigger=" << isSemicentralTrigger
256 << "EMCALtrigger=" << isEMCALTrigger
257 << "run=" << run
258 << "p=" << momentum
259 << "pt=" << transversemomentum
260 << "eta=" << eta
261 << "phi=" << phi
262 << "pdg=" << pdg
263 << "ProductionVertex=" << productionVertex
264 << "motherPdg=" << motherPdg
cedf0381 265 << "source=" << source
fda75e2d 266 << "\n";
267 }
268 }
269
270 AliESDtrack *track;
11ff28c5 271 Double_t mcp, mcpt, mcptTPC, mcpTPC; // MC Variables added to the debug tree
fda75e2d 272 for(Int_t itrack = 0; itrack < fInputEvent->GetNumberOfTracks(); itrack++){
273 // fill the tree
274 track = dynamic_cast<AliESDtrack *>(fInputEvent->GetTrack(itrack));
275 if(!track) continue;
276 // Cut track (Only basic track cuts)
277 if(!fTrackCuts->CheckParticleCuts(AliHFEcuts::kNcutStepsMCTrack + AliHFEcuts::kStepRecKineITSTPC, track)) continue;
278 // Debug streaming of PID-related quantities
0e30407a 279 copyTrack.~AliESDtrack();
11ff28c5 280 new(&copyTrack) AliESDtrack(*track);
281 if(fTPCpid->HasEtaCorrection()) fTPCpid->ApplyEtaCorrection(&copyTrack, AliHFEpidObject::kESDanalysis); // Apply Eta Correction on copy track
fda75e2d 282 Double_t nSigmaTOF = pid->NumberOfSigmasTOF(track, AliPID::kElectron);
11ff28c5 283 Double_t nSigmaTPC = pid->NumberOfSigmasTPC(&copyTrack, AliPID::kElectron);
284 //if(TMath::Abs(nSigmaTOF) > 5) continue;
fda75e2d 285 // we are not interested in tracks which are more than 5 sigma away from the electron hypothesis in either TOF or TPC
cedf0381 286 Double_t tPCdEdx = copyTrack.GetTPCsignal();
fda75e2d 287 // Signal, source and MCPID
288 Bool_t signal = kTRUE;
289 source = 5;
11ff28c5 290 mcp = mcpt = mcpTPC = mcptTPC = 0.;
291
292
293
294 Double_t bgcategory = 0.;
295 Int_t mArr = -1;
296 Int_t mesonID = -999;
297 Double_t xr[3]={-999,-999,-999};
298 Double_t eR=-999;
299 Double_t eZ=-999;
300 Double_t unique=-999;
301 Double_t mesonunique=-999;
302 Double_t mesonR=-999;
303 Double_t mesonZ=-999;
304 Double_t mesonMomPdg=-999;
305 Double_t mesonMomPt=-999;
306 Double_t mesonGMomPdg=-999;
307 Double_t mesonGGMomPdg=-999;
308 Double_t mesonPt = -999;
309 Double_t mceta = -999;
310 Double_t mcphi = -999;
311 Int_t mcpdg;
312
313 if(mcthere){
fda75e2d 314 // Signal
315 AliMCParticle *mctrack;
316 if((mctrack = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(TMath::Abs(track->GetLabel()))))){
317 if(!fTrackCuts->CheckParticleCuts(AliHFEcuts::kStepMCGenerated, mctrack)) signal = kFALSE;
318 }
319
320 // Source
321 if(fSignalCuts->IsCharmElectron(track)) source = 0;
322 else if(fSignalCuts->IsBeautyElectron(track)) source = 1;
323 else if(fSignalCuts->IsGammaElectron(track)) source = 2;
324 else if(fSignalCuts->IsNonHFElectron(track)) source = 3;
325 else if(mctrack && (TMath::Abs(mctrack->Particle()->GetPdgCode()) == 11)) source = 4;
326 else source = 5;
11ff28c5 327
3024f297 328 if(!mctrack) continue;
329
11ff28c5 330 // Kinematics
331 mcpt = mctrack->Pt();
332 mcp = mctrack->P();
333 mceta = mctrack->Eta();
334 mcphi = mctrack->Phi();
335 mcpdg = mctrack->Particle()->GetPdgCode();
336
337 AliTrackReference *ref = FindTrackReference(mctrack, 80, 270, AliTrackReference::kTPC);
338 if(ref){
339 mcpTPC = ref->P();
340 mcptTPC = ref->Pt();
341 }
342
0e30407a 343
11ff28c5 344 TParticle *mctrack1 = mctrack->Particle();
345 mesonID=GetElecSourceMC(mctrack1);
346 if(mesonID==AliHFEmcQA::kGammaPi0 || mesonID==AliHFEmcQA::kPi0) mArr=0; //pion
347 else if(mesonID==AliHFEmcQA::kGammaEta || mesonID==AliHFEmcQA::kEta) mArr=1; //eta
348 else if(mesonID==AliHFEmcQA::kGammaOmega || mesonID==AliHFEmcQA::kOmega) mArr=2; //omega
349 else if(mesonID==AliHFEmcQA::kGammaPhi || mesonID==AliHFEmcQA::kPhi) mArr=3; //phi
350 else if(mesonID==AliHFEmcQA::kGammaEtaPrime || mesonID==AliHFEmcQA::kEtaPrime) mArr=4; //etaprime
351 else if(mesonID==AliHFEmcQA::kGammaRho0 || mesonID==AliHFEmcQA::kRho0) mArr=5; //rho
352
353 mctrack->XvYvZv(xr);
0e30407a 354
11ff28c5 355 eR= TMath::Sqrt(xr[0]*xr[0]+xr[1]*xr[1]);
356 eZ = xr[2];
357 TParticle *mctrackt = mctrack->Particle();
358 unique=mctrackt->GetUniqueID();
359
360 AliMCParticle *mctrackmother = NULL;
cedf0381 361 AliMCParticle *mctrackmother2 = NULL;
11ff28c5 362
363 if(!(mArr<0)){
0e30407a 364 if(mesonID>=AliHFEmcQA::kGammaPi0) { // conversion electron, be careful with the enum odering
365 Int_t glabel=TMath::Abs(mctrack->GetMother()); // gamma label
366 if((mctrackmother = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(glabel)))){
367 glabel=TMath::Abs(mctrackmother->GetMother()); // gamma's mother's label
368 if((mctrackmother = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(glabel)))){
369 mesonPt = mctrackmother->Pt(); //meson pt
370 bgcategory = 1.;
371 mctrackmother->XvYvZv(xr);
372 mesonR = TMath::Sqrt(xr[0]*xr[0]+xr[1]*xr[1]);
373 mesonZ = xr[2];
374
375 mctrackt = mctrackmother->Particle();
376 if(mctrackt){
cedf0381 377 mesonunique = mctrackt->GetUniqueID();
0e30407a 378 }
cedf0381 379
380 Int_t glabel2=TMath::Abs(mctrackmother->GetMother()); // gamma's mother's mother
381 if((mctrackmother2 = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(glabel2)))){
382 mesonMomPdg=mctrackmother2->PdgCode();
383 mesonMomPt=mctrackmother2->Pt();
384 }
385
0e30407a 386 if(glabel>fMCEvent->GetNumberOfPrimaries()) {
387 bgcategory = 2.;
388 glabel=TMath::Abs(mctrackmother->GetMother()); // gamma's mother's mother
389 if((mctrackmother = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(glabel)))){
390 mesonMomPdg=mctrackmother->PdgCode();
391 mesonMomPt=mctrackmother->Pt();
392 if(TMath::Abs(mctrackmother->PdgCode())==310){
393 bgcategory = 3.;
394 glabel=TMath::Abs(mctrackmother->GetMother()); // gamma's mother's mother's mother
395 if((mctrackmother = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(glabel)))){
396 mesonGMomPdg=mctrackmother->PdgCode();
397 glabel=TMath::Abs(mctrackmother->GetMother()); // gamma's mother's mother
398 if((mctrackmother = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(glabel)))){
399 mesonGGMomPdg=mctrackmother->PdgCode();
400 }
401 }
402 }
403 }
404 }
405 }
406 }
407 }
408 else{ // nonHFE except for the conversion electron
409 Int_t glabel=TMath::Abs(mctrack->GetMother());
410 if((mctrackmother = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(glabel)))){
411 mesonPt = mctrackmother->Pt(); //meson pt
412 bgcategory = -1.;
413 mctrackmother->XvYvZv(xr);
414 mesonR = TMath::Sqrt(xr[0]*xr[0]+xr[1]*xr[1]);
415 mesonZ = xr[2];
416
417 mctrackt = mctrackmother->Particle();
418 if(mctrackt){
419 mesonunique = mctrackt->GetUniqueID();
420 }
421 if(glabel>fMCEvent->GetNumberOfPrimaries()) {
422 bgcategory = -2.;
423 glabel=TMath::Abs(mctrackmother->GetMother()); // gamma's mother's mother
424 if((mctrackmother = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(glabel)))){
425 mesonMomPdg=mctrackmother->PdgCode();
426 mesonMomPt=mctrackmother->Pt();
427 if(TMath::Abs(mctrackmother->PdgCode())==310){
428 bgcategory = -3.;
429 glabel=TMath::Abs(mctrackmother->GetMother()); // gamma's mother's mother's mother
430 if((mctrackmother = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(glabel)))){
11ff28c5 431 mesonGMomPdg=mctrackmother->PdgCode();
0e30407a 432 glabel=TMath::Abs(mctrackmother->GetMother()); // gamma's mother's mother
433 if((mctrackmother = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(glabel)))){
434 mesonGGMomPdg=mctrackmother->PdgCode();
435 }
436 }
437 }
438 }
439 }
440 }
441 }
11ff28c5 442 }
443
444
445
fda75e2d 446 }
447 // Get V0 tag (if available)
448 Int_t v0pid = -1;
449 if(track->TestBit(BIT(14))) v0pid = AliPID::kElectron;
450 else if(track->TestBit(BIT(15))) v0pid = AliPID::kPion;
451 else if(track->TestBit(BIT(16))) v0pid = AliPID::kProton;
452 // Kinematics
453 charge = track->Charge() > 0 ? 1. : -1.;
454 eta = track->Eta();
455 phi = track->Phi();
456 momentum = track->P() * charge;
457 transversemomentum = track->Pt() * charge;
11ff28c5 458 Double_t momentumTPC = track->GetTPCInnerParam() ? track->GetTPCInnerParam()->P() : 0.;
459 Double_t transversemomentumTPC = track->GetTPCInnerParam() ? track->GetTPCInnerParam()->Pt() : 0.;
fda75e2d 460 // ITS number of clusters
461 UChar_t nclustersITS = track->GetITSclusters(NULL);
462 Double_t chi2matching = track->GetChi2TPCConstrainedVsGlobal(dynamic_cast<const AliESDVertex *>(vertex));
463 Double_t chi2PerClusterITS = 0.0;
464 if (nclustersITS != 0) chi2PerClusterITS = track->GetITSchi2() / Float_t(nclustersITS);
465 // TPC number of clusters (different definitions)
76d0b522 466 UChar_t nclustersTPCfit = track->GetTPCNcls();
467 UChar_t nclustersTPCall = 0;
468 const TBits &clusterTPC = track->GetTPCClusterMap();
469 nclustersTPCall = clusterTPC.CountBits();
fda75e2d 470 UChar_t nclustersTPCPID = track->GetTPCsignalN();
471 UChar_t nfindableTPC = track->GetTPCNclsF();
76d0b522 472 Double_t clusterRatioTPCfit = 0.0;
473 if((static_cast<Double_t>(nfindableTPC))>0.0) clusterRatioTPCfit = static_cast<Double_t>(nclustersTPCfit)/static_cast<Double_t>(nfindableTPC);
474 Double_t clusterRatioTPCall = 0.0;
475 if((static_cast<Double_t>(nfindableTPC))>0.0) clusterRatioTPCall = static_cast<Double_t>(nclustersTPCall)/static_cast<Double_t>(nfindableTPC);
fda75e2d 476 UChar_t nclustersTPCshared = 0;
477 Float_t ncrossedRowsTPC = track->GetTPCCrossedRows();
478 const TBits &sharedTPC = track->GetTPCSharedMap();
479 for(Int_t ibit = 0; ibit < 160; ibit++) if(sharedTPC.TestBitNumber(ibit)) nclustersTPCshared++;
480 // TRD clusters and tracklets
481 UChar_t nclustersTRD = track->GetTRDncls();
a8ef1999 482 UChar_t ntrackletsTRDPID = track->GetTRDntrackletsPID();
fda75e2d 483 // ITS and TRD acceptance maps
cedf0381 484 UChar_t hasClusterITS[6], statusITS[5], hasTrackletTRD[6];
fda75e2d 485 UChar_t itsPixel = track->GetITSClusterMap();
cedf0381 486 for(Int_t icl = 0; icl < 6; icl++){
487 hasClusterITS[icl] = TESTBIT(itsPixel, icl) ? 1 : 0;
488 if(CheckITSstatus(track, icl)) statusITS[icl] = 1;
489 else statusITS[icl] = 0;
490 }
a8ef1999 491 Double_t trddEdxSum[6];
492 for(Int_t a=0;a<6;a++) { trddEdxSum[a]= 0.;}
fda75e2d 493 for(Int_t itl = 0; itl < 6; itl++){
0e30407a 494 Int_t nSliceNonZero = 0;
11ff28c5 495 trddEdxSum[itl] = track->GetTRDslice(itl, 0); // in new reconstruction slice 0 contains the total charge
fda75e2d 496 for(Int_t islice = 0; islice < 8; islice++){
497 if(track->GetTRDslice(itl, islice) > 0.001) nSliceNonZero++;
498 }
499 hasTrackletTRD[itl] = nSliceNonZero ? 1 : 0;
500 }
501 // TRD PID
502 Double_t pidprobs[5];
503 track->GetTRDpid(pidprobs);
504 Double_t likeEleTRD = pidprobs[0];
505 Double_t likeEleTRDn = likeEleTRD/(likeEleTRD + pidprobs[2]);
a8ef1999 506 Double_t trdtruncmean1 = fTRDpid->GetTRDSignalV1(track, 0.6);
507 Double_t trdtruncmean2 = fTRDpid->GetTRDSignalV2(track, 0.6);
508
fda75e2d 509 // DCA
510 Float_t b[2] = {0.,0.};
511 Float_t bCov[3] = {0.,0.,0.};
512 track->GetImpactParameters(b,bCov);
513 Double_t dca = TMath::Sqrt(b[0]*b[0]+b[1]*b[1]); // impact parameter space
514 Double_t dcaSR=0, dcaSZ=0;
515 if(bCov[0]>0) dcaSR = b[0]/TMath::Sqrt(bCov[0]); // normalised impact parameter xy
516 if(bCov[2]>0) dcaSZ = b[1]/TMath::Sqrt(bCov[2]); // normalised impact parameter z
517 Double_t dcaS = AliESDtrackCuts::GetSigmaToVertex(track); // n_sigma
11ff28c5 518
519 // HFE DCA
520 Double_t hfeb[2] = {-99.,-99.};
521 Double_t hfebCov[3] = {-999.,-999.,-999.};
522 fExtraCuts->GetHFEImpactParameters(track, hfeb, hfebCov);
523
0e30407a 524 Double_t tofdx= -999.0;
525 Double_t tofdz= -999.0;
526 tofdx=track->GetTOFsignalDx();
527 tofdz=track->GetTOFsignalDz();
528
fda75e2d 529 // Fill Tree
530 (*fDebugTree) << "PIDdebug"
531 << "centrality=" << centrality
532 << "MBtrigger=" << isMBTrigger
533 << "CentralTrigger=" << isCentralTrigger
534 << "SemicentralTrigger=" << isSemicentralTrigger
535 << "EMCALtrigger=" << isEMCALTrigger
536 << "signal=" << signal
537 << "source=" << source
538 << "v0pid=" << v0pid
539 << "run=" << run
540 << "p=" << momentum
11ff28c5 541 << "ptpc=" << momentumTPC
fda75e2d 542 << "pt=" << transversemomentum
11ff28c5 543 << "pttpc=" << transversemomentumTPC
544 << "mcp=" << mcp
545 << "mcpt=" << mcpt
546 << "mcpTPC=" << mcpTPC
547 << "mcptTPC=" << mcptTPC
548 << "mceta=" << mceta
549 << "mcphi=" << mcphi
550 << "mcpdg=" << mcpdg
fda75e2d 551 << "eta=" << eta
552 << "phi=" << phi
a8ef1999 553 << "ntracklets=" << ntrackletsTRDPID
76d0b522 554 << "nclustersTPC=" << nclustersTPCfit
555 << "nclustersTPCall=" << nclustersTPCall
fda75e2d 556 << "nclustersTPCPID=" << nclustersTPCPID
557 << "nclustersTPCshared=" << nclustersTPCshared
558 << "ncrossedRowsTPC=" << ncrossedRowsTPC
76d0b522 559 << "clusterRatioTPC=" << clusterRatioTPCfit
560 << "clusterRatioTPCall=" << clusterRatioTPCall
fda75e2d 561 << "nclustersITS=" << nclustersITS
562 << "nclusters=" << nclustersTRD
563 << "chi2matching=" << chi2matching
cedf0381 564 << "chi2PerClusterITS=" << chi2PerClusterITS
fda75e2d 565 << "its0=" << hasClusterITS[0]
566 << "its1=" << hasClusterITS[1]
567 << "its2=" << hasClusterITS[2]
568 << "its3=" << hasClusterITS[3]
569 << "its4=" << hasClusterITS[4]
570 << "its5=" << hasClusterITS[5]
cedf0381 571 << "statusITS0=" << statusITS[0]
572 << "statusITS1=" << statusITS[1]
573 << "statusITS2=" << statusITS[2]
574 << "statusITS3=" << statusITS[3]
575 << "statusITS4=" << statusITS[4]
576 << "statusITS5=" << statusITS[5]
fda75e2d 577 << "trd0=" << hasTrackletTRD[0]
578 << "trd1=" << hasTrackletTRD[1]
579 << "trd2=" << hasTrackletTRD[2]
580 << "trd3=" << hasTrackletTRD[3]
581 << "trd4=" << hasTrackletTRD[4]
582 << "trd5=" << hasTrackletTRD[5]
cedf0381 583 << "TRDdEdxl0=" << trddEdxSum[0]
584 << "TRDdEdxl1=" << trddEdxSum[1]
585 << "TRDdEdxl2=" << trddEdxSum[2]
586 << "TRDdEdxl3=" << trddEdxSum[3]
587 << "TRDdEdxl4=" << trddEdxSum[4]
588 << "TRDdEdxl5=" << trddEdxSum[5]
fda75e2d 589 << "TOFsigmaEl=" << nSigmaTOF
590 << "TPCsigmaEl=" << nSigmaTPC
591 << "TPCdEdx=" << tPCdEdx
592 << "TRDlikeEl=" << likeEleTRD
593 << "TRDlikeEln=" << likeEleTRDn
cedf0381 594 << "trdtruncmean1=" << trdtruncmean1
a8ef1999 595 << "trdtruncmean2=" << trdtruncmean2
fda75e2d 596 << "dcaR=" << b[0]
597 << "dcaZ=" << b[1]
598 << "dca=" << dca
599 << "dcaSR=" << dcaSR
600 << "dcaSZ=" << dcaSZ
601 << "dcaS=" << dcaS
11ff28c5 602 << "hfedcaR=" << hfeb[0]
603 << "hfedcaZ=" << hfeb[1]
604 << "hfedcacovR=" << hfebCov[0]
605 << "hfedcacovZ=" << hfebCov[2]
fda75e2d 606 << "vx=" << vtx[0]
607 << "vy=" << vtx[1]
0e30407a 608 << "vz=" << vtx[2]
cedf0381 609 << "tofdx=" << tofdx
610 << "tofdz=" << tofdz
611 << "ncontrib=" << ncontrib
612 << "mesonID=" << mesonID
613 << "eR=" << eR
614 << "mesonR=" << mesonR
615 << "eZ=" << eZ
616 << "mesonZ=" << mesonZ
617 << "unique=" << unique
618 << "mesonunique=" << mesonunique
619 << "bgcategory=" << bgcategory
620 << "mesonpt=" << mesonPt
11ff28c5 621 << "mesonMomPdg=" << mesonMomPdg
622 << "mesonGMomPdg=" << mesonGMomPdg
623 << "mesonGGMomPdg=" << mesonGGMomPdg
624 << "mesonMomPt=" << mesonMomPt
fda75e2d 625 << "\n";
626 }
627}
628
629
630void AliHFEdebugTreeTask::SetFileName(const char *filename){ fFilename = filename; }
11ff28c5 631//___________________________________________________________
632AliTrackReference *AliHFEdebugTreeTask::FindTrackReference(AliMCParticle *track, Float_t minRadius, Float_t maxRadius, Int_t detectorID)
633{
634 //
635 // Find the track reference
636 //
637 AliTrackReference *ref = NULL, *reftmp;
638 Float_t radius;
639 for(Int_t iref = 0; iref < track->GetNumberOfTrackReferences(); iref++){
640 reftmp = track->GetTrackReference(iref);
641 if(reftmp->DetectorId() != detectorID) continue;
642 radius = reftmp->R();
643 if(radius >= minRadius && radius < maxRadius){
644 ref = reftmp;
645 break;
646 }
647 if(radius > maxRadius) break;
648 }
649 return ref;
650}
651
652//__________________________________________
653Int_t AliHFEdebugTreeTask::GetElecSourceMC(TParticle * const mcpart)
654{
655 // decay particle's origin
656
657 if(!mcpart){
658 AliDebug(1, "no mcparticle, return\n");
659 return -1;
660 }
661
662 if ( abs(mcpart->GetPdgCode()) != AliHFEmcQA::kElectronPDG ) return AliHFEmcQA::kMisID;
663
664 Int_t origin = -1;
665 Bool_t isFinalOpenCharm = kFALSE;
666
667 Int_t iLabel = mcpart->GetFirstMother();
668 if (iLabel<0){
669 AliDebug(1, "Stack label is negative, return\n");
670 return -1;
671 }
672
673 AliMCParticle *mctrack = NULL;
674 Int_t tmpMomLabel=0;
675 if(!(mctrack = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(TMath::Abs(iLabel))))) return -1;
676 TParticle *partMother = mctrack->Particle();
677 TParticle *partMotherCopy = mctrack->Particle();
678 Int_t maPdgcode = partMother->GetPdgCode();
679
0e30407a 680 // if the mother is charmed hadron
681 if ( (int(abs(maPdgcode)/100.)%10) == AliHFEmcQA::kCharm || (int(abs(maPdgcode)/1000.)%10) == AliHFEmcQA::kCharm ) {
11ff28c5 682
0e30407a 683 for (Int_t i=0; i<fNparents; i++){
11ff28c5 684 if (abs(maPdgcode)==fParentSelect[0][i]){
685 isFinalOpenCharm = kTRUE;
686 }
0e30407a 687 }
688 if (!isFinalOpenCharm) return -1;
11ff28c5 689
0e30407a 690 // iterate until you find B hadron as a mother or become top ancester
691 for (Int_t i=1; i<fgkMaxIter; i++){
11ff28c5 692
693 Int_t jLabel = partMother->GetFirstMother();
694 if (jLabel == -1){
695 origin = AliHFEmcQA::kDirectCharm;
696 return origin;
697 }
698 if (jLabel < 0){ // safety protection
699 AliDebug(1, "Stack label is negative, return\n");
700 return -1;
701 }
702
703 // if there is an ancester
704 if(!(mctrack = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(TMath::Abs(jLabel))))) return -1;
705 TParticle* grandMa = mctrack->Particle();
706 Int_t grandMaPDG = grandMa->GetPdgCode();
707
708 for (Int_t j=0; j<fNparents; j++){
0e30407a 709 if (abs(grandMaPDG)==fParentSelect[1][j]){
710 origin = AliHFEmcQA::kBeautyCharm;
711 return origin;
712 }
11ff28c5 713 }
714
715 partMother = grandMa;
0e30407a 716 } // end of iteration
717 } // end of if
718 else if ( (int(abs(maPdgcode)/100.)%10) == AliHFEmcQA::kBeauty || (int(abs(maPdgcode)/1000.)%10) == AliHFEmcQA::kBeauty ) {
719 for (Int_t i=0; i<fNparents; i++){
11ff28c5 720 if (abs(maPdgcode)==fParentSelect[1][i]){
721 origin = AliHFEmcQA::kDirectBeauty;
722 return origin;
723 }
0e30407a 724 }
725 } // end of if
726 else if ( abs(maPdgcode) == 22 ) { //conversion
727
728 tmpMomLabel = partMotherCopy->GetFirstMother();
729 if(!(mctrack = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(TMath::Abs(tmpMomLabel))))) return -1;
730 partMother = mctrack->Particle();
731 maPdgcode = partMother->GetPdgCode();
732 if ( abs(maPdgcode) == 111 ) {
733 origin = AliHFEmcQA::kGammaPi0;
734 return origin;
735 }
736 else if ( abs(maPdgcode) == 221 ) {
737 origin = AliHFEmcQA::kGammaEta;
738 return origin;
739 }
740 else if ( abs(maPdgcode) == 223 ) {
741 origin = AliHFEmcQA::kGammaOmega;
742 return origin;
743 }
744 else if ( abs(maPdgcode) == 333 ) {
745 origin = AliHFEmcQA::kGammaPhi;
746 return origin;
747 }
748 else if ( abs(maPdgcode) == 331 ) {
749 origin = AliHFEmcQA::kGammaEtaPrime;
750 return origin;
751 }
752 else if ( abs(maPdgcode) == 113 ) {
753 origin = AliHFEmcQA::kGammaRho0;
754 return origin;
755 }
756 else origin = AliHFEmcQA::kElse;
757 //origin = kGamma; // finer category above
758 return origin;
759
760 } // end of if
761 else if ( abs(maPdgcode) == 111 ) {
762 origin = AliHFEmcQA::kPi0;
763 return origin;
764 } // end of if
765 else if ( abs(maPdgcode) == 221 ) {
766 origin = AliHFEmcQA::kEta;
767 return origin;
768 } // end of if
769 else if ( abs(maPdgcode) == 223 ) {
770 origin = AliHFEmcQA::kOmega;
771 return origin;
772 } // end of if
773 else if ( abs(maPdgcode) == 333 ) {
774 origin = AliHFEmcQA::kPhi;
775 return origin;
776 } // end of if
777 else if ( abs(maPdgcode) == 331 ) {
778 origin = AliHFEmcQA::kEtaPrime;
779 return origin;
780 } // end of if
781 else if ( abs(maPdgcode) == 113 ) {
782 origin = AliHFEmcQA::kRho0;
783 return origin;
784 } // end of if
785 else{
11ff28c5 786 origin = AliHFEmcQA::kElse;
0e30407a 787 }
788 return origin;
11ff28c5 789}
cedf0381 790
791//______________________________________________________
792Bool_t AliHFEdebugTreeTask::CheckITSstatus( const AliESDtrack * const esdtrack, Int_t layer) const {
793 //
794 // Check whether ITS area is dead
795 //
796 Int_t itsStatus = 0;
797 Int_t det;
798 Float_t xloc, zloc;
799 esdtrack->GetITSModuleIndexInfo(layer, det, itsStatus, xloc, zloc);
800 Bool_t status;
801 switch(itsStatus){
802 case 2: status = kFALSE; break;
803 case 3: status = kFALSE; break;
804 case 7: status = kFALSE; break;
805 default: status = kTRUE;
806 }
807 return status;
808}
809