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 "AliAODMCParticle.h"
30 #include "AliMCEvent.h"
31 #include "AliMCParticle.h"
32 #include "AliVParticle.h"
34 #include "AliHFEsignalCuts.h"
35 #include "AliHFEmcQA.h"
37 ClassImp(AliHFEsignalCuts)
39 //____________________________________________________________
40 AliHFEsignalCuts::AliHFEsignalCuts():
50 //____________________________________________________________
51 AliHFEsignalCuts::AliHFEsignalCuts(const Char_t *name, const Char_t *title):
52 AliAnalysisCuts(name, title),
57 // Default constructor
59 fMCQA = new AliHFEmcQA;
60 if(fMCQA) fMCQA->Init();
63 //____________________________________________________________
64 AliHFEsignalCuts::AliHFEsignalCuts(const AliHFEsignalCuts &ref):
74 //____________________________________________________________
75 AliHFEsignalCuts &AliHFEsignalCuts::operator=(const AliHFEsignalCuts &ref){
77 // Assignment operator
86 //____________________________________________________________
87 AliHFEsignalCuts::~AliHFEsignalCuts(){
91 if(fMCQA) delete fMCQA;
94 //____________________________________________________________
95 void AliHFEsignalCuts::SetMCEvent(AliMCEvent *mc){
100 if(fMCQA) fMCQA->SetMCEvent(mc);
103 //____________________________________________________________
104 Bool_t AliHFEsignalCuts::IsSelected(TObject *o){
106 // Define signal as electron coming from charm or beauty
107 // @TODO: Implement setter so that also either of them can be defined
111 return IsCharmElectron(o) || IsBeautyElectron(o);
114 Int_t esources = GetElecSource(dynamic_cast<const AliVParticle *>(o));
115 if(esources>0)printf("esources= %d\n",esources);
116 if(esources == AliHFEmcQA::kDirectCharm || esources == AliHFEmcQA::kDirectBeauty || esources == AliHFEmcQA::kBeautyCharm) // 1: direct D->e, 2: B->e 3: B->D->e
124 //____________________________________________________________
125 Bool_t AliHFEsignalCuts::IsCharmElectron(const TObject * const o) const {
127 // Check if mother is coming from Charm
129 Int_t esources = GetElecSource(dynamic_cast<const AliVParticle *>(o));
130 if(esources == AliHFEmcQA::kDirectCharm) // 1: direct D->e
136 //____________________________________________________________
137 Bool_t AliHFEsignalCuts::IsBeautyElectron(const TObject * const o) const {
139 // Check if mother is coming from Beauty
141 Int_t esources = GetElecSource(dynamic_cast<const AliVParticle *>(o));
142 if(esources == AliHFEmcQA::kDirectBeauty || esources == AliHFEmcQA::kBeautyCharm) // 2: B->e 3: B->D->e
148 //____________________________________________________________
149 Bool_t AliHFEsignalCuts::IsGammaElectron(const TObject * const o) const {
151 // Check for MC if the electron is coming from Gamma
153 Int_t esources = GetElecSource(dynamic_cast<const AliVParticle *>(o));
154 if(esources == AliHFEmcQA::kGamma) // 4: conversion electrons
161 //____________________________________________________________
162 Bool_t AliHFEsignalCuts::IsCharmElectron(const TObject * const o) const {
164 // Check if mother is coming from Charm
166 if(TMath::Abs(GetTrackPDG(dynamic_cast<const AliVParticle *>(o))) != 11) return kFALSE;
167 Int_t motherpdg = TMath::Abs(GetMotherPDG(dynamic_cast<const AliVParticle *>(o)));
168 AliDebug(1, Form("Mother PDG %d\n", motherpdg));
170 if((motherpdg % 1000) / 100 == 4) return kTRUE; // charmed meson, 3rd position in pdg code == 4
171 if(motherpdg / 1000 == 4) return kTRUE; // charmed baryon, 4th position in pdg code == 4
172 AliDebug(1, "No Charm\n");
176 //____________________________________________________________
177 Bool_t AliHFEsignalCuts::IsBeautyElectron(const TObject * const o) const {
179 // Check if mother is coming from Beauty
181 if(TMath::Abs(GetTrackPDG(dynamic_cast<const AliVParticle *>(o))) != 11) return kFALSE;
182 Int_t motherpdg = TMath::Abs(GetMotherPDG(dynamic_cast<const AliVParticle *>(o)));
183 AliDebug(1, Form("Mother PDG %d\n", motherpdg));
185 if((motherpdg % 1000) / 100 == 5) return kTRUE; // beauty meson, 3rd position in pdg code == 5
186 if(motherpdg / 1000 == 5) return kTRUE; // beauty baryon, 4th position in pdg code == 5
187 AliDebug(1, "No Beauty\n");
191 //____________________________________________________________
192 Bool_t AliHFEsignalCuts::IsGammaElectron(const TObject * const o) const {
194 // Check for MC if the electron is coming from Gamma
196 if(TMath::Abs(GetTrackPDG(dynamic_cast<const AliVParticle *>(o))) != 11) return kFALSE;
197 Int_t motherpdg = TMath::Abs(GetMotherPDG(dynamic_cast<const AliVParticle *>(o)));
198 AliDebug(1, Form("Mother PDG %d\n", motherpdg));
201 AliDebug(1, "No Gamma");
204 AliDebug(1, "Gamma");
210 //____________________________________________________________
211 Int_t AliHFEsignalCuts::GetMotherPDG(const AliVParticle * const track) const {
213 // Get Mother Pdg code for reconstructed respectively MC tracks
216 AliDebug(1, "No MC Event Available\n");
219 const AliVParticle *motherParticle = NULL, *mctrack = NULL;
220 TString objectType = track->IsA()->GetName();
221 if(objectType.CompareTo("AliESDtrack") == 0 || objectType.CompareTo("AliAODTrack") == 0){
222 // Reconstructed track
223 if(track->GetLabel())
224 mctrack = fMC->GetTrack(TMath::Abs(track->GetLabel()));
230 if(!mctrack) return 0;
233 if(TString(mctrack->IsA()->GetName()).CompareTo("AliMCParticle") == 0){
235 motherParticle = fMC->GetTrack((dynamic_cast<const AliMCParticle *>(mctrack)->Particle()->GetFirstMother()));
237 motherPDG = TMath::Abs((dynamic_cast<const AliMCParticle *>(motherParticle))->Particle()->GetPdgCode());
239 // case AODMCParticle
240 motherParticle = fMC->GetTrack((dynamic_cast<const AliAODMCParticle *>(mctrack))->GetMother());
242 motherPDG = TMath::Abs((dynamic_cast<const AliAODMCParticle *>(motherParticle))->GetPdgCode());
247 //____________________________________________________________
248 Int_t AliHFEsignalCuts::GetTrackPDG(const AliVParticle * const track) const {
250 // Return PDG code of a particle itself
253 AliDebug(1, "No MC Event Available\n");
256 TString sourcetype = track->IsA()->GetName();
257 const AliVParticle *mctrack = NULL;
258 if(!sourcetype.CompareTo("AliESDtrack") || !sourcetype.CompareTo("AliAODTrack")){
259 mctrack = fMC->GetTrack(TMath::Abs(track->GetLabel()));
260 } else mctrack = track;
261 if(!mctrack) return 0;
263 TString mctype = mctrack->IsA()->GetName();
265 if(!mctype.CompareTo("AliMCParticle")){
266 const AliMCParticle *esdmc = dynamic_cast<const AliMCParticle *>(mctrack);
267 trackPdg = esdmc->Particle()->GetPdgCode();
269 const AliAODMCParticle *aodmc = dynamic_cast< const AliAODMCParticle *>(mctrack);
270 trackPdg = aodmc->GetPdgCode();
275 //____________________________________________________________
276 Int_t AliHFEsignalCuts::GetElecSource(const AliVParticle * const track) const {
278 // Return PDG code of a particle itself
282 AliDebug(1, "No MC Event Available\n");
286 AliDebug(1, "No MCQA Available\n");
290 TString sourcetype = track->IsA()->GetName();
291 const AliVParticle *mctrack = NULL;
292 TParticle *mcpart = NULL;
293 if(!sourcetype.CompareTo("AliESDtrack") || !sourcetype.CompareTo("AliAODTrack")){
294 mctrack = fMC->GetTrack(TMath::Abs(track->GetLabel()));
295 } else mctrack = track;
296 if(!mctrack) return 0;
298 TString mctype = mctrack->IsA()->GetName();
300 if(!mctype.CompareTo("AliMCParticle")){
301 const AliMCParticle *esdmc = dynamic_cast<const AliMCParticle *>(mctrack);
302 mcpart = esdmc->Particle();
303 eSource=fMCQA->GetElecSource(mcpart);