]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGHF/hfe/AliHFEdebugTreeTask.cxx
Updated treatment of D0/D0bar mass assumption (Carlos)
[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)){
143 AliDebug(1, "Event flagged as pileup\n");
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
197 << "\n";
198
fda75e2d 199 // Common variables
200 Double_t charge, eta, phi, momentum, transversemomentum;
201 Int_t source;
202
203 // Monte-Carlo loop
204 if(mcthere){
205 AliMCParticle * mcpart;
206 for(Int_t itrk = 0; itrk < fMCEvent->GetNumberOfTracks(); itrk++){
207 mcpart = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(itrk));
208 if(!mcpart) continue;
209 if(!fTrackCuts->CheckParticleCuts(static_cast<UInt_t>(AliHFEcuts::kStepMCGenerated), mcpart)) continue;
210 // Kinematics
211 charge = mcpart->Charge() > 0. ? 1. : -1.;
212 momentum = mcpart->P() * charge;
213 transversemomentum = mcpart->Pt() * charge;
214 eta = mcpart->Eta();
215 phi = mcpart->Phi();
216 Int_t pdg = mcpart->Particle()->GetPdgCode();
217
218 // Get Production Vertex in radial direction
219 Double_t vx = mcpart->Particle()->Vx(),
220 vy = mcpart->Particle()->Vy();
221 Double_t productionVertex = TMath::Sqrt(vx*vx+vy*vy);
222
223 // Get Mother PDG code of the particle
224 Int_t motherPdg = 0;
225 Int_t motherlabel = mcpart->Particle()->GetFirstMother();
226 if(motherlabel >= 0 && motherlabel < fMCEvent->GetNumberOfTracks()){
227 AliMCParticle *mother = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(motherlabel));
228 if(mother) motherPdg = mother->Particle()->GetPdgCode();
229 }
230
231 // derive source
232 source = 5;
233 if(fSignalCuts->IsCharmElectron(mcpart)) source = 0;
234 else if(fSignalCuts->IsBeautyElectron(mcpart)) source = 1;
235 else if(fSignalCuts->IsGammaElectron(mcpart)) source = 2;
236 else if(fSignalCuts->IsNonHFElectron(mcpart)) source = 3;
237 else if(TMath::Abs(pdg) == 11) source = 4;
238 else source = 5;
239
11ff28c5 240 // Momemntum at the inner wall of the TPC
241 Double_t pTPC = 0., ptTPC = 0.;
242 AliTrackReference *ref = FindTrackReference(mcpart, 80, 270, AliTrackReference::kTPC);
243 if(ref){
244 pTPC = ref->P();
245 ptTPC = ref->Pt();
246 }
247
248
249
250 (*fDebugTree) << "MCDebug"
fda75e2d 251 << "centrality=" << centrality
252 << "MBtrigger=" << isMBTrigger
253 << "CentralTrigger=" << isCentralTrigger
254 << "SemicentralTrigger=" << isSemicentralTrigger
255 << "EMCALtrigger=" << isEMCALTrigger
256 << "run=" << run
257 << "p=" << momentum
258 << "pt=" << transversemomentum
259 << "eta=" << eta
260 << "phi=" << phi
261 << "pdg=" << pdg
262 << "ProductionVertex=" << productionVertex
263 << "motherPdg=" << motherPdg
11ff28c5 264 << "source=" << source
fda75e2d 265 << "\n";
266 }
267 }
268
269 AliESDtrack *track;
11ff28c5 270 Double_t mcp, mcpt, mcptTPC, mcpTPC; // MC Variables added to the debug tree
fda75e2d 271 for(Int_t itrack = 0; itrack < fInputEvent->GetNumberOfTracks(); itrack++){
272 // fill the tree
273 track = dynamic_cast<AliESDtrack *>(fInputEvent->GetTrack(itrack));
274 if(!track) continue;
275 // Cut track (Only basic track cuts)
276 if(!fTrackCuts->CheckParticleCuts(AliHFEcuts::kNcutStepsMCTrack + AliHFEcuts::kStepRecKineITSTPC, track)) continue;
277 // Debug streaming of PID-related quantities
11ff28c5 278 new(&copyTrack) AliESDtrack(*track);
279 if(fTPCpid->HasEtaCorrection()) fTPCpid->ApplyEtaCorrection(&copyTrack, AliHFEpidObject::kESDanalysis); // Apply Eta Correction on copy track
fda75e2d 280 Double_t nSigmaTOF = pid->NumberOfSigmasTOF(track, AliPID::kElectron);
11ff28c5 281 Double_t nSigmaTPC = pid->NumberOfSigmasTPC(&copyTrack, AliPID::kElectron);
282 //if(TMath::Abs(nSigmaTOF) > 5) continue;
fda75e2d 283 // we are not interested in tracks which are more than 5 sigma away from the electron hypothesis in either TOF or TPC
284 Double_t tPCdEdx = track->GetTPCsignal();
285 // Signal, source and MCPID
286 Bool_t signal = kTRUE;
287 source = 5;
11ff28c5 288 mcp = mcpt = mcpTPC = mcptTPC = 0.;
289
290
291
292 Double_t bgcategory = 0.;
293 Int_t mArr = -1;
294 Int_t mesonID = -999;
295 Double_t xr[3]={-999,-999,-999};
296 Double_t eR=-999;
297 Double_t eZ=-999;
298 Double_t unique=-999;
299 Double_t mesonunique=-999;
300 Double_t mesonR=-999;
301 Double_t mesonZ=-999;
302 Double_t mesonMomPdg=-999;
303 Double_t mesonMomPt=-999;
304 Double_t mesonGMomPdg=-999;
305 Double_t mesonGGMomPdg=-999;
306 Double_t mesonPt = -999;
307 Double_t mceta = -999;
308 Double_t mcphi = -999;
309 Int_t mcpdg;
310
311 if(mcthere){
fda75e2d 312 // Signal
313 AliMCParticle *mctrack;
314 if((mctrack = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(TMath::Abs(track->GetLabel()))))){
315 if(!fTrackCuts->CheckParticleCuts(AliHFEcuts::kStepMCGenerated, mctrack)) signal = kFALSE;
316 }
317
318 // Source
319 if(fSignalCuts->IsCharmElectron(track)) source = 0;
320 else if(fSignalCuts->IsBeautyElectron(track)) source = 1;
321 else if(fSignalCuts->IsGammaElectron(track)) source = 2;
322 else if(fSignalCuts->IsNonHFElectron(track)) source = 3;
323 else if(mctrack && (TMath::Abs(mctrack->Particle()->GetPdgCode()) == 11)) source = 4;
324 else source = 5;
11ff28c5 325
3024f297 326 if(!mctrack) continue;
327
11ff28c5 328 // Kinematics
329 mcpt = mctrack->Pt();
330 mcp = mctrack->P();
331 mceta = mctrack->Eta();
332 mcphi = mctrack->Phi();
333 mcpdg = mctrack->Particle()->GetPdgCode();
334
335 AliTrackReference *ref = FindTrackReference(mctrack, 80, 270, AliTrackReference::kTPC);
336 if(ref){
337 mcpTPC = ref->P();
338 mcptTPC = ref->Pt();
339 }
340
341
342 TParticle *mctrack1 = mctrack->Particle();
343 mesonID=GetElecSourceMC(mctrack1);
344 if(mesonID==AliHFEmcQA::kGammaPi0 || mesonID==AliHFEmcQA::kPi0) mArr=0; //pion
345 else if(mesonID==AliHFEmcQA::kGammaEta || mesonID==AliHFEmcQA::kEta) mArr=1; //eta
346 else if(mesonID==AliHFEmcQA::kGammaOmega || mesonID==AliHFEmcQA::kOmega) mArr=2; //omega
347 else if(mesonID==AliHFEmcQA::kGammaPhi || mesonID==AliHFEmcQA::kPhi) mArr=3; //phi
348 else if(mesonID==AliHFEmcQA::kGammaEtaPrime || mesonID==AliHFEmcQA::kEtaPrime) mArr=4; //etaprime
349 else if(mesonID==AliHFEmcQA::kGammaRho0 || mesonID==AliHFEmcQA::kRho0) mArr=5; //rho
350
351 mctrack->XvYvZv(xr);
352
353 eR= TMath::Sqrt(xr[0]*xr[0]+xr[1]*xr[1]);
354 eZ = xr[2];
355 TParticle *mctrackt = mctrack->Particle();
356 unique=mctrackt->GetUniqueID();
357
358 AliMCParticle *mctrackmother = NULL;
359
360 if(!(mArr<0)){
361 if(mesonID>=AliHFEmcQA::kGammaPi0) { // conversion electron, be careful with the enum odering
362 Int_t glabel=TMath::Abs(mctrack->GetMother()); // gamma label
363 if((mctrackmother = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(glabel)))){
364 glabel=TMath::Abs(mctrackmother->GetMother()); // gamma's mother's label
365 if((mctrackmother = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(glabel)))){
366 mesonPt = mctrackmother->Pt(); //meson pt
367 bgcategory = 1.;
368 mctrackmother->XvYvZv(xr);
369 mesonR = TMath::Sqrt(xr[0]*xr[0]+xr[1]*xr[1]);
370 mesonZ = xr[2];
371
372 mctrackt = mctrackmother->Particle();
373 if(mctrackt){
374 mesonunique = mctrackt->GetUniqueID();
375 }
376 if(glabel>fMCEvent->GetNumberOfPrimaries()) {
377 bgcategory = 2.;
378 glabel=TMath::Abs(mctrackmother->GetMother()); // gamma's mother's mother
379 if((mctrackmother = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(glabel)))){
380 mesonMomPdg=mctrackmother->PdgCode();
381 mesonMomPt=mctrackmother->Pt();
382 if(TMath::Abs(mctrackmother->PdgCode())==310){
383 bgcategory = 3.;
384 glabel=TMath::Abs(mctrackmother->GetMother()); // gamma's mother's mother's mother
385 if((mctrackmother = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(glabel)))){
386 mesonGMomPdg=mctrackmother->PdgCode();
387 glabel=TMath::Abs(mctrackmother->GetMother()); // gamma's mother's mother
388 if((mctrackmother = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(glabel)))){
389 mesonGGMomPdg=mctrackmother->PdgCode();
390 }
391 }
392 }
393 }
394 }
395 }
396 }
397 }
398 else{ // nonHFE except for the conversion electron
399 Int_t glabel=TMath::Abs(mctrack->GetMother());
400 if((mctrackmother = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(glabel)))){
401 mesonPt = mctrackmother->Pt(); //meson pt
402 bgcategory = -1.;
403 mctrackmother->XvYvZv(xr);
404 mesonR = TMath::Sqrt(xr[0]*xr[0]+xr[1]*xr[1]);
405 mesonZ = xr[2];
406
407 mctrackt = mctrackmother->Particle();
408 if(mctrackt){
409 mesonunique = mctrackt->GetUniqueID();
410 }
411 if(glabel>fMCEvent->GetNumberOfPrimaries()) {
412 bgcategory = -2.;
413 glabel=TMath::Abs(mctrackmother->GetMother()); // gamma's mother's mother
414 if((mctrackmother = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(glabel)))){
415 mesonMomPdg=mctrackmother->PdgCode();
416 mesonMomPt=mctrackmother->Pt();
417 if(TMath::Abs(mctrackmother->PdgCode())==310){
418 bgcategory = -3.;
419 glabel=TMath::Abs(mctrackmother->GetMother()); // gamma's mother's mother's mother
420 if((mctrackmother = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(glabel)))){
421 mesonGMomPdg=mctrackmother->PdgCode();
422 glabel=TMath::Abs(mctrackmother->GetMother()); // gamma's mother's mother
423 if((mctrackmother = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(glabel)))){
424 mesonGGMomPdg=mctrackmother->PdgCode();
425 }
426 }
427 }
428 }
429 }
430 }
431 }
432 }
433
434
435
fda75e2d 436 }
437 // Get V0 tag (if available)
438 Int_t v0pid = -1;
439 if(track->TestBit(BIT(14))) v0pid = AliPID::kElectron;
440 else if(track->TestBit(BIT(15))) v0pid = AliPID::kPion;
441 else if(track->TestBit(BIT(16))) v0pid = AliPID::kProton;
442 // Kinematics
443 charge = track->Charge() > 0 ? 1. : -1.;
444 eta = track->Eta();
445 phi = track->Phi();
446 momentum = track->P() * charge;
447 transversemomentum = track->Pt() * charge;
11ff28c5 448 Double_t momentumTPC = track->GetTPCInnerParam() ? track->GetTPCInnerParam()->P() : 0.;
449 Double_t transversemomentumTPC = track->GetTPCInnerParam() ? track->GetTPCInnerParam()->Pt() : 0.;
fda75e2d 450 // ITS number of clusters
451 UChar_t nclustersITS = track->GetITSclusters(NULL);
452 Double_t chi2matching = track->GetChi2TPCConstrainedVsGlobal(dynamic_cast<const AliESDVertex *>(vertex));
453 Double_t chi2PerClusterITS = 0.0;
454 if (nclustersITS != 0) chi2PerClusterITS = track->GetITSchi2() / Float_t(nclustersITS);
455 // TPC number of clusters (different definitions)
456 UChar_t nclustersTPC = track->GetTPCncls();
457 UChar_t nclustersTPCPID = track->GetTPCsignalN();
458 UChar_t nfindableTPC = track->GetTPCNclsF();
459 Double_t clusterRatioTPC = 0.0;
460 if((static_cast<Double_t>(nfindableTPC))>0.0) clusterRatioTPC = static_cast<Double_t>(nclustersTPC)/static_cast<Double_t>(nfindableTPC);
461 UChar_t nclustersTPCshared = 0;
462 Float_t ncrossedRowsTPC = track->GetTPCCrossedRows();
463 const TBits &sharedTPC = track->GetTPCSharedMap();
464 for(Int_t ibit = 0; ibit < 160; ibit++) if(sharedTPC.TestBitNumber(ibit)) nclustersTPCshared++;
465 // TRD clusters and tracklets
466 UChar_t nclustersTRD = track->GetTRDncls();
a8ef1999 467 UChar_t ntrackletsTRDPID = track->GetTRDntrackletsPID();
fda75e2d 468 // ITS and TRD acceptance maps
469 UChar_t hasClusterITS[6], hasTrackletTRD[6];
470 UChar_t itsPixel = track->GetITSClusterMap();
471 for(Int_t icl = 0; icl < 6; icl++) hasClusterITS[icl] = TESTBIT(itsPixel, icl) ? 1 : 0;
a8ef1999 472 Double_t trddEdxSum[6];
473 for(Int_t a=0;a<6;a++) { trddEdxSum[a]= 0.;}
fda75e2d 474 for(Int_t itl = 0; itl < 6; itl++){
11ff28c5 475 Int_t nSliceNonZero = 0;
476 trddEdxSum[itl] = track->GetTRDslice(itl, 0); // in new reconstruction slice 0 contains the total charge
fda75e2d 477 for(Int_t islice = 0; islice < 8; islice++){
478 if(track->GetTRDslice(itl, islice) > 0.001) nSliceNonZero++;
479 }
480 hasTrackletTRD[itl] = nSliceNonZero ? 1 : 0;
481 }
482 // TRD PID
483 Double_t pidprobs[5];
484 track->GetTRDpid(pidprobs);
485 Double_t likeEleTRD = pidprobs[0];
486 Double_t likeEleTRDn = likeEleTRD/(likeEleTRD + pidprobs[2]);
a8ef1999 487 Double_t trdtruncmean1 = fTRDpid->GetTRDSignalV1(track, 0.6);
488 Double_t trdtruncmean2 = fTRDpid->GetTRDSignalV2(track, 0.6);
489
fda75e2d 490 // DCA
491 Float_t b[2] = {0.,0.};
492 Float_t bCov[3] = {0.,0.,0.};
493 track->GetImpactParameters(b,bCov);
494 Double_t dca = TMath::Sqrt(b[0]*b[0]+b[1]*b[1]); // impact parameter space
495 Double_t dcaSR=0, dcaSZ=0;
496 if(bCov[0]>0) dcaSR = b[0]/TMath::Sqrt(bCov[0]); // normalised impact parameter xy
497 if(bCov[2]>0) dcaSZ = b[1]/TMath::Sqrt(bCov[2]); // normalised impact parameter z
498 Double_t dcaS = AliESDtrackCuts::GetSigmaToVertex(track); // n_sigma
11ff28c5 499
500 // HFE DCA
501 Double_t hfeb[2] = {-99.,-99.};
502 Double_t hfebCov[3] = {-999.,-999.,-999.};
503 fExtraCuts->GetHFEImpactParameters(track, hfeb, hfebCov);
504
fda75e2d 505 // Fill Tree
506 (*fDebugTree) << "PIDdebug"
507 << "centrality=" << centrality
508 << "MBtrigger=" << isMBTrigger
509 << "CentralTrigger=" << isCentralTrigger
510 << "SemicentralTrigger=" << isSemicentralTrigger
511 << "EMCALtrigger=" << isEMCALTrigger
512 << "signal=" << signal
513 << "source=" << source
514 << "v0pid=" << v0pid
515 << "run=" << run
516 << "p=" << momentum
11ff28c5 517 << "ptpc=" << momentumTPC
fda75e2d 518 << "pt=" << transversemomentum
11ff28c5 519 << "pttpc=" << transversemomentumTPC
520 << "mcp=" << mcp
521 << "mcpt=" << mcpt
522 << "mcpTPC=" << mcpTPC
523 << "mcptTPC=" << mcptTPC
524 << "mceta=" << mceta
525 << "mcphi=" << mcphi
526 << "mcpdg=" << mcpdg
fda75e2d 527 << "eta=" << eta
528 << "phi=" << phi
a8ef1999 529 << "ntracklets=" << ntrackletsTRDPID
fda75e2d 530 << "nclustersTPC=" << nclustersTPC
531 << "nclustersTPCPID=" << nclustersTPCPID
532 << "nclustersTPCshared=" << nclustersTPCshared
533 << "ncrossedRowsTPC=" << ncrossedRowsTPC
534 << "clusterRatioTPC=" << clusterRatioTPC
535 << "nclustersITS=" << nclustersITS
536 << "nclusters=" << nclustersTRD
537 << "chi2matching=" << chi2matching
538 << "chi2PerClusterITS=" << chi2PerClusterITS
539 << "its0=" << hasClusterITS[0]
540 << "its1=" << hasClusterITS[1]
541 << "its2=" << hasClusterITS[2]
542 << "its3=" << hasClusterITS[3]
543 << "its4=" << hasClusterITS[4]
544 << "its5=" << hasClusterITS[5]
545 << "trd0=" << hasTrackletTRD[0]
546 << "trd1=" << hasTrackletTRD[1]
547 << "trd2=" << hasTrackletTRD[2]
548 << "trd3=" << hasTrackletTRD[3]
549 << "trd4=" << hasTrackletTRD[4]
550 << "trd5=" << hasTrackletTRD[5]
a8ef1999 551 << "TRDdEdxl0=" << trddEdxSum[0]
552 << "TRDdEdxl1=" << trddEdxSum[1]
553 << "TRDdEdxl2=" << trddEdxSum[2]
554 << "TRDdEdxl3=" << trddEdxSum[3]
555 << "TRDdEdxl4=" << trddEdxSum[4]
556 << "TRDdEdxl5=" << trddEdxSum[5]
fda75e2d 557 << "TOFsigmaEl=" << nSigmaTOF
558 << "TPCsigmaEl=" << nSigmaTPC
559 << "TPCdEdx=" << tPCdEdx
560 << "TRDlikeEl=" << likeEleTRD
561 << "TRDlikeEln=" << likeEleTRDn
a8ef1999 562 << "trdtruncmean1=" << trdtruncmean1
563 << "trdtruncmean2=" << trdtruncmean2
fda75e2d 564 << "dcaR=" << b[0]
565 << "dcaZ=" << b[1]
566 << "dca=" << dca
567 << "dcaSR=" << dcaSR
568 << "dcaSZ=" << dcaSZ
569 << "dcaS=" << dcaS
11ff28c5 570 << "hfedcaR=" << hfeb[0]
571 << "hfedcaZ=" << hfeb[1]
572 << "hfedcacovR=" << hfebCov[0]
573 << "hfedcacovZ=" << hfebCov[2]
fda75e2d 574 << "vx=" << vtx[0]
575 << "vy=" << vtx[1]
576 << "vz=" << vtx[2]
11ff28c5 577 << "ncontrib=" << ncontrib
578 << "mesonID=" << mesonID
579 << "eR=" << eR
580 << "mesonR=" << mesonR
581 << "eZ=" << eZ
582 << "mesonZ=" << mesonZ
583 << "unique=" << unique
584 << "mesonunique=" << mesonunique
585 << "bgcategory=" << bgcategory
586 << "mesonpt=" << mesonPt
587 << "mesonMomPdg=" << mesonMomPdg
588 << "mesonGMomPdg=" << mesonGMomPdg
589 << "mesonGGMomPdg=" << mesonGGMomPdg
590 << "mesonMomPt=" << mesonMomPt
fda75e2d 591 << "\n";
592 }
593}
594
595
596void AliHFEdebugTreeTask::SetFileName(const char *filename){ fFilename = filename; }
11ff28c5 597//___________________________________________________________
598AliTrackReference *AliHFEdebugTreeTask::FindTrackReference(AliMCParticle *track, Float_t minRadius, Float_t maxRadius, Int_t detectorID)
599{
600 //
601 // Find the track reference
602 //
603 AliTrackReference *ref = NULL, *reftmp;
604 Float_t radius;
605 for(Int_t iref = 0; iref < track->GetNumberOfTrackReferences(); iref++){
606 reftmp = track->GetTrackReference(iref);
607 if(reftmp->DetectorId() != detectorID) continue;
608 radius = reftmp->R();
609 if(radius >= minRadius && radius < maxRadius){
610 ref = reftmp;
611 break;
612 }
613 if(radius > maxRadius) break;
614 }
615 return ref;
616}
617
618//__________________________________________
619Int_t AliHFEdebugTreeTask::GetElecSourceMC(TParticle * const mcpart)
620{
621 // decay particle's origin
622
623 if(!mcpart){
624 AliDebug(1, "no mcparticle, return\n");
625 return -1;
626 }
627
628 if ( abs(mcpart->GetPdgCode()) != AliHFEmcQA::kElectronPDG ) return AliHFEmcQA::kMisID;
629
630 Int_t origin = -1;
631 Bool_t isFinalOpenCharm = kFALSE;
632
633 Int_t iLabel = mcpart->GetFirstMother();
634 if (iLabel<0){
635 AliDebug(1, "Stack label is negative, return\n");
636 return -1;
637 }
638
639 AliMCParticle *mctrack = NULL;
640 Int_t tmpMomLabel=0;
641 if(!(mctrack = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(TMath::Abs(iLabel))))) return -1;
642 TParticle *partMother = mctrack->Particle();
643 TParticle *partMotherCopy = mctrack->Particle();
644 Int_t maPdgcode = partMother->GetPdgCode();
645
646 // if the mother is charmed hadron
647 if ( (int(abs(maPdgcode)/100.)%10) == AliHFEmcQA::kCharm || (int(abs(maPdgcode)/1000.)%10) == AliHFEmcQA::kCharm ) {
648
649 for (Int_t i=0; i<fNparents; i++){
650 if (abs(maPdgcode)==fParentSelect[0][i]){
651 isFinalOpenCharm = kTRUE;
652 }
653 }
654 if (!isFinalOpenCharm) return -1;
655
656 // iterate until you find B hadron as a mother or become top ancester
657 for (Int_t i=1; i<fgkMaxIter; i++){
658
659 Int_t jLabel = partMother->GetFirstMother();
660 if (jLabel == -1){
661 origin = AliHFEmcQA::kDirectCharm;
662 return origin;
663 }
664 if (jLabel < 0){ // safety protection
665 AliDebug(1, "Stack label is negative, return\n");
666 return -1;
667 }
668
669 // if there is an ancester
670 if(!(mctrack = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(TMath::Abs(jLabel))))) return -1;
671 TParticle* grandMa = mctrack->Particle();
672 Int_t grandMaPDG = grandMa->GetPdgCode();
673
674 for (Int_t j=0; j<fNparents; j++){
675 if (abs(grandMaPDG)==fParentSelect[1][j]){
676 origin = AliHFEmcQA::kBeautyCharm;
677 return origin;
678 }
679 }
680
681 partMother = grandMa;
682 } // end of iteration
683 } // end of if
684 else if ( (int(abs(maPdgcode)/100.)%10) == AliHFEmcQA::kBeauty || (int(abs(maPdgcode)/1000.)%10) == AliHFEmcQA::kBeauty ) {
685 for (Int_t i=0; i<fNparents; i++){
686 if (abs(maPdgcode)==fParentSelect[1][i]){
687 origin = AliHFEmcQA::kDirectBeauty;
688 return origin;
689 }
690 }
691 } // end of if
692 else if ( abs(maPdgcode) == 22 ) { //conversion
693
694 tmpMomLabel = partMotherCopy->GetFirstMother();
695 if(!(mctrack = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(TMath::Abs(tmpMomLabel))))) return -1;
696 partMother = mctrack->Particle();
697 maPdgcode = partMother->GetPdgCode();
698 if ( abs(maPdgcode) == 111 ) {
699 origin = AliHFEmcQA::kGammaPi0;
700 return origin;
701 }
702 else if ( abs(maPdgcode) == 221 ) {
703 origin = AliHFEmcQA::kGammaEta;
704 return origin;
705 }
706 else if ( abs(maPdgcode) == 223 ) {
707 origin = AliHFEmcQA::kGammaOmega;
708 return origin;
709 }
710 else if ( abs(maPdgcode) == 333 ) {
711 origin = AliHFEmcQA::kGammaPhi;
712 return origin;
713 }
714 else if ( abs(maPdgcode) == 331 ) {
715 origin = AliHFEmcQA::kGammaEtaPrime;
716 return origin;
717 }
718 else if ( abs(maPdgcode) == 113 ) {
719 origin = AliHFEmcQA::kGammaRho0;
720 return origin;
721 }
722 else origin = AliHFEmcQA::kElse;
723 //origin = kGamma; // finer category above
724 return origin;
725
726 } // end of if
727 else if ( abs(maPdgcode) == 111 ) {
728 origin = AliHFEmcQA::kPi0;
729 return origin;
730 } // end of if
731 else if ( abs(maPdgcode) == 221 ) {
732 origin = AliHFEmcQA::kEta;
733 return origin;
734 } // end of if
735 else if ( abs(maPdgcode) == 223 ) {
736 origin = AliHFEmcQA::kOmega;
737 return origin;
738 } // end of if
739 else if ( abs(maPdgcode) == 333 ) {
740 origin = AliHFEmcQA::kPhi;
741 return origin;
742 } // end of if
743 else if ( abs(maPdgcode) == 331 ) {
744 origin = AliHFEmcQA::kEtaPrime;
745 return origin;
746 } // end of if
747 else if ( abs(maPdgcode) == 113 ) {
748 origin = AliHFEmcQA::kRho0;
749 return origin;
750 } // end of if
751 else{
752 origin = AliHFEmcQA::kElse;
753 }
754 return origin;
755}