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 **************************************************************************/
17 // Checks whether a particle (reconstructed or MC) is coming from MC Signal
18 // For more information see implementation file
21 // Markus Fasel <M.Fasel@gsi.de>
25 #include <TParticle.h>
28 #include "AliAODTrack.h"
29 #include "AliAODMCParticle.h"
30 #include "AliESDtrack.h"
32 #include "AliMCEvent.h"
33 #include "AliMCParticle.h"
34 #include "AliVParticle.h"
36 #include "AliHFEsignalCuts.h"
37 #include "AliHFEmcQA.h"
39 ClassImp(AliHFEsignalCuts)
41 //____________________________________________________________
42 AliHFEsignalCuts::AliHFEsignalCuts():
52 //____________________________________________________________
53 AliHFEsignalCuts::AliHFEsignalCuts(const Char_t *name, const Char_t *title):
54 AliAnalysisCuts(name, title),
59 // Default constructor
61 fMCQA = new AliHFEmcQA;
62 if(fMCQA) fMCQA->Init();
65 //____________________________________________________________
66 AliHFEsignalCuts::AliHFEsignalCuts(const AliHFEsignalCuts &ref):
76 //____________________________________________________________
77 AliHFEsignalCuts &AliHFEsignalCuts::operator=(const AliHFEsignalCuts &ref){
79 // Assignment operator
88 //____________________________________________________________
89 AliHFEsignalCuts::~AliHFEsignalCuts(){
93 if(fMCQA) delete fMCQA;
96 //____________________________________________________________
97 void AliHFEsignalCuts::SetMCEvent(AliMCEvent *mc){
102 if(fMCQA) fMCQA->SetMCEvent(mc);
105 //____________________________________________________________
106 Bool_t AliHFEsignalCuts::IsSelected(TObject *o){
108 // Define signal as electron coming from charm or beauty
109 // @TODO: Implement setter so that also either of them can be defined
113 return IsCharmElectron(o) || IsBeautyElectron(o);
116 Int_t esources = GetElecSource(dynamic_cast<const AliVParticle *>(o));
117 if(esources>0)printf("esources= %d\n",esources);
118 if(esources == AliHFEmcQA::kDirectCharm || esources == AliHFEmcQA::kDirectBeauty || esources == AliHFEmcQA::kBeautyCharm) // 1: direct D->e, 2: B->e 3: B->D->e
126 //____________________________________________________________
127 Bool_t AliHFEsignalCuts::IsCharmElectron(const TObject * const o) const {
129 // Check if mother is coming from Charm
131 if(!dynamic_cast<const AliVParticle *>(o)) return kFALSE;
132 Int_t esources = GetElecSource(dynamic_cast<const AliVParticle *>(o));
133 if(esources == AliHFEmcQA::kDirectCharm) // 1: direct D->e
139 //____________________________________________________________
140 Bool_t AliHFEsignalCuts::IsBeautyElectron(const TObject * const o) const {
142 // Check if mother is coming from Beauty
144 if(!dynamic_cast<const AliVParticle *>(o)) return kFALSE;
145 Int_t esources = GetElecSource(dynamic_cast<const AliVParticle *>(o));
146 if(esources == AliHFEmcQA::kDirectBeauty || esources == AliHFEmcQA::kBeautyCharm) // 2: B->e 3: B->D->e
152 //____________________________________________________________
153 Bool_t AliHFEsignalCuts::IsGammaElectron(const TObject * const o) const {
155 // Check for MC if the electron is coming from Gamma
157 if(!dynamic_cast<const AliVParticle *>(o)) return kFALSE;
158 Int_t esources = GetElecSource(dynamic_cast<const AliVParticle *>(o));
159 if(esources >= AliHFEmcQA::kGammaPi0 && esources <= AliHFEmcQA::kGammaRho0 ) // 4: conversion electrons
160 //if(esources == AliHFEmcQA::kGammaPi0 || esources == AliHFEmcQA::kGammaEta || esources == AliHFEmcQA::kGammaOmega || esources == AliHFEmcQA::kGammaPhi || esources == AliHFEmcQA::kGammaEtaPrime || esources == AliHFEmcQA::kGammaRho0 ) // 4: conversion electrons
166 //____________________________________________________________
167 Bool_t AliHFEsignalCuts::IsNonHFElectron(const TObject * const o) const {
169 // Check for MC if the electron is coming from NonHFE except for conversion
171 if(!dynamic_cast<const AliVParticle *>(o)) return kFALSE;
172 Int_t esources = GetElecSource(dynamic_cast<const AliVParticle *>(o));
173 if(esources == AliHFEmcQA:: kPi0 || esources == AliHFEmcQA::kEta || esources == AliHFEmcQA::kOmega || esources == AliHFEmcQA::kPhi || esources == AliHFEmcQA::kEtaPrime || esources == AliHFEmcQA::kRho0) // 4: conversion electrons
178 //____________________________________________________________
181 //____________________________________________________________
182 Bool_t AliHFEsignalCuts::IsCharmElectron(const TObject * const o) const {
184 // Check if mother is coming from Charm
186 if(TMath::Abs(GetTrackPDG(dynamic_cast<const AliVParticle *>(o))) != 11) return kFALSE;
187 Int_t motherpdg = TMath::Abs(GetMotherPDG(dynamic_cast<const AliVParticle *>(o)));
188 AliDebug(1, Form("Mother PDG %d\n", motherpdg));
190 if((motherpdg % 1000) / 100 == 4) return kTRUE; // charmed meson, 3rd position in pdg code == 4
191 if(motherpdg / 1000 == 4) return kTRUE; // charmed baryon, 4th position in pdg code == 4
192 AliDebug(1, "No Charm\n");
196 //____________________________________________________________
197 Bool_t AliHFEsignalCuts::IsBeautyElectron(const TObject * const o) const {
199 // Check if mother is coming from Beauty
201 if(TMath::Abs(GetTrackPDG(dynamic_cast<const AliVParticle *>(o))) != 11) return kFALSE;
202 Int_t motherpdg = TMath::Abs(GetMotherPDG(dynamic_cast<const AliVParticle *>(o)));
203 AliDebug(1, Form("Mother PDG %d\n", motherpdg));
205 if((motherpdg % 1000) / 100 == 5) return kTRUE; // beauty meson, 3rd position in pdg code == 5
206 if(motherpdg / 1000 == 5) return kTRUE; // beauty baryon, 4th position in pdg code == 5
207 AliDebug(1, "No Beauty\n");
211 //____________________________________________________________
212 Bool_t AliHFEsignalCuts::IsGammaElectron(const TObject * const o) const {
214 // Check for MC if the electron is coming from Gamma
216 if(TMath::Abs(GetTrackPDG(dynamic_cast<const AliVParticle *>(o))) != 11) return kFALSE;
217 Int_t motherpdg = TMath::Abs(GetMotherPDG(dynamic_cast<const AliVParticle *>(o)));
218 AliDebug(1, Form("Mother PDG %d\n", motherpdg));
221 AliDebug(1, "No Gamma");
224 AliDebug(1, "Gamma");
230 //____________________________________________________________
231 Int_t AliHFEsignalCuts::GetMotherPDG(const AliVParticle * const track) const {
233 // Get Mother Pdg code for reconstructed respectively MC tracks
236 AliDebug(1, "No MC Event Available\n");
239 const AliVParticle *motherParticle = NULL, *mctrack = NULL;
240 TString objectType = track->IsA()->GetName();
241 if(objectType.CompareTo("AliESDtrack") == 0 || objectType.CompareTo("AliAODTrack") == 0){
242 // Reconstructed track
243 if(track->GetLabel())
244 mctrack = fMC->GetTrack(TMath::Abs(track->GetLabel()));
250 if(!mctrack) return 0;
253 if(TString(mctrack->IsA()->GetName()).CompareTo("AliMCParticle") == 0){
255 const AliMCParticle *esdmctrack = dynamic_cast<const AliMCParticle *>(mctrack);
256 if(esdmctrack) motherParticle = fMC->GetTrack(esdmctrack->Particle()->GetFirstMother());
258 const AliMCParticle *esdmcmother = dynamic_cast<const AliMCParticle *>(motherParticle);
259 if(esdmcmother) motherPDG = TMath::Abs(esdmcmother->Particle()->GetPdgCode());
262 // case AODMCParticle
263 const AliAODMCParticle *aodmctrack = dynamic_cast<const AliAODMCParticle *>(mctrack);
264 if(aodmctrack) motherParticle = fMC->GetTrack(aodmctrack->GetMother());
266 const AliAODMCParticle *aodmcmother = dynamic_cast<const AliAODMCParticle *>(motherParticle);
267 if(aodmcmother) motherPDG = TMath::Abs(aodmcmother->GetPdgCode());
273 //____________________________________________________________
274 Int_t AliHFEsignalCuts::GetTrackPDG(const AliVParticle * const track) const {
276 // Return PDG code of a particle itself
279 AliDebug(1, "No MC Event Available\n");
282 TString sourcetype = track->IsA()->GetName();
283 const AliVParticle *mctrack = NULL;
284 if(!sourcetype.CompareTo("AliESDtrack") || !sourcetype.CompareTo("AliAODTrack")){
285 mctrack = fMC->GetTrack(TMath::Abs(track->GetLabel()));
286 } else mctrack = track;
287 if(!mctrack) return 0;
289 TString mctype = mctrack->IsA()->GetName();
291 if(!mctype.CompareTo("AliMCParticle")){
292 const AliMCParticle *esdmc = dynamic_cast<const AliMCParticle *>(mctrack);
293 if(esdmc) trackPdg = esdmc->Particle()->GetPdgCode();
295 const AliAODMCParticle *aodmc = dynamic_cast< const AliAODMCParticle *>(mctrack);
296 if(aodmc) trackPdg = aodmc->GetPdgCode();
301 //____________________________________________________________
302 Int_t AliHFEsignalCuts::GetElecSource(const AliVParticle * const track) const {
304 // Return PDG code of a particle itself
308 AliDebug(1, "No MC Event Available\n");
312 AliDebug(1, "No MCQA Available\n");
316 AliDebug(1, "Track not Available\n");
321 const AliVParticle *mctrack = NULL;
322 TParticle *mcpart = NULL;
323 //AliMCParticle *esdmcmother = NULL;
324 if((tracktype = track->IsA()) == AliESDtrack::Class() || tracktype == AliAODTrack::Class()){
325 mctrack = fMC->GetTrack(TMath::Abs(track->GetLabel()));
326 } else mctrack = track;
327 if(!mctrack) return 0;
330 if(mctrack->IsA() == AliMCParticle::Class()){
331 const AliMCParticle *esdmc = dynamic_cast<const AliMCParticle *>(mctrack);
333 mcpart = esdmc->Particle();
334 eSource=fMCQA->GetElecSource(mcpart);
335 /* // considering secondary pions
336 if(eSource>=AliHFEmcQA::kGammaPi0) { // conversion electron, be careful with the enum odering
337 Int_t glabel=TMath::Abs(esdmc->GetMother()); // gamma label
338 if((esdmcmother= dynamic_cast<AliMCParticle *>(fMC->GetTrack(glabel)))){
339 glabel=TMath::Abs(esdmcmother->GetMother()); // gamma's mother's label
340 if((esdmcmother= dynamic_cast<AliMCParticle *>(fMC->GetTrack(glabel)))){
341 if(glabel>fMC->GetNumberOfPrimaries()) eSource=AliHFEmcQA::kElse;
345 else if(eSource==AliHFEmcQA::kPi0 || (eSource>=AliHFEmcQA::kEta && eSource<=AliHFEmcQA::kRho0) ){ // nonHFE except for the conversion electron
346 Int_t glabel=TMath::Abs(esdmc->GetMother());
347 if((esdmcmother= dynamic_cast<AliMCParticle *>(fMC->GetTrack(glabel)))){
348 if(glabel>fMC->GetNumberOfPrimaries()) eSource=AliHFEmcQA::kElse;