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 **************************************************************************/
20 // Checks whether a particle (reconstructed or MC) is coming from MC Signal
21 // For more information see implementation file
24 // Markus Fasel <M.Fasel@gsi.de>
28 #include <TParticle.h>
31 #include "AliAODMCParticle.h"
33 #include "AliMCEvent.h"
34 #include "AliMCParticle.h"
35 #include "AliVParticle.h"
37 #include "AliHFEsignalCuts.h"
38 #include "AliHFEmcQA.h"
40 ClassImp(AliHFEsignalCuts)
42 //____________________________________________________________
43 AliHFEsignalCuts::AliHFEsignalCuts():
53 //____________________________________________________________
54 AliHFEsignalCuts::AliHFEsignalCuts(const Char_t *name, const Char_t *title):
55 AliAnalysisCuts(name, title),
60 // Default constructor
62 fMCQA = new AliHFEmcQA;
63 if(fMCQA) fMCQA->Init();
66 //____________________________________________________________
67 AliHFEsignalCuts::AliHFEsignalCuts(const AliHFEsignalCuts &ref):
77 //____________________________________________________________
78 AliHFEsignalCuts &AliHFEsignalCuts::operator=(const AliHFEsignalCuts &ref){
80 // Assignment operator
89 //____________________________________________________________
90 AliHFEsignalCuts::~AliHFEsignalCuts(){
94 if(fMCQA) delete fMCQA;
97 //____________________________________________________________
98 void AliHFEsignalCuts::SetMCEvent(AliMCEvent *mc){
103 if(fMCQA) fMCQA->SetMCEvent(mc);
106 //____________________________________________________________
107 Bool_t AliHFEsignalCuts::IsSelected(TObject *o){
109 // Define signal as electron coming from charm or beauty
110 // @TODO: Implement setter so that also either of them can be defined
114 return IsCharmElectron(o) || IsBeautyElectron(o);
117 Int_t esources = GetElecSource(dynamic_cast<const AliVParticle *>(o));
118 if(esources>0)printf("esources= %d\n",esources);
119 if(esources == AliHFEmcQA::kDirectCharm || esources == AliHFEmcQA::kDirectBeauty || esources == AliHFEmcQA::kBeautyCharm) // 1: direct D->e, 2: B->e 3: B->D->e
127 //____________________________________________________________
128 Bool_t AliHFEsignalCuts::IsCharmElectron(const TObject * const o) const {
130 // Check if mother is coming from Charm
132 if(!dynamic_cast<const AliVParticle *>(o)) return kFALSE;
133 Int_t esources = GetElecSource(dynamic_cast<const AliVParticle *>(o));
134 if(esources == AliHFEmcQA::kDirectCharm) // 1: direct D->e
140 //____________________________________________________________
141 Bool_t AliHFEsignalCuts::IsBeautyElectron(const TObject * const o) const {
143 // Check if mother is coming from Beauty
145 if(!dynamic_cast<const AliVParticle *>(o)) return kFALSE;
146 Int_t esources = GetElecSource(dynamic_cast<const AliVParticle *>(o));
147 if(esources == AliHFEmcQA::kDirectBeauty || esources == AliHFEmcQA::kBeautyCharm) // 2: B->e 3: B->D->e
153 //____________________________________________________________
154 Bool_t AliHFEsignalCuts::IsGammaElectron(const TObject * const o) const {
156 // Check for MC if the electron is coming from Gamma
158 if(!dynamic_cast<const AliVParticle *>(o)) return kFALSE;
159 Int_t esources = GetElecSource(dynamic_cast<const AliVParticle *>(o));
160 if(esources == AliHFEmcQA::kGamma) // 4: conversion electrons
167 //____________________________________________________________
168 Bool_t AliHFEsignalCuts::IsCharmElectron(const TObject * const o) const {
170 // Check if mother is coming from Charm
172 if(TMath::Abs(GetTrackPDG(dynamic_cast<const AliVParticle *>(o))) != 11) return kFALSE;
173 Int_t motherpdg = TMath::Abs(GetMotherPDG(dynamic_cast<const AliVParticle *>(o)));
174 AliDebug(1, Form("Mother PDG %d\n", motherpdg));
176 if((motherpdg % 1000) / 100 == 4) return kTRUE; // charmed meson, 3rd position in pdg code == 4
177 if(motherpdg / 1000 == 4) return kTRUE; // charmed baryon, 4th position in pdg code == 4
178 AliDebug(1, "No Charm\n");
182 //____________________________________________________________
183 Bool_t AliHFEsignalCuts::IsBeautyElectron(const TObject * const o) const {
185 // Check if mother is coming from Beauty
187 if(TMath::Abs(GetTrackPDG(dynamic_cast<const AliVParticle *>(o))) != 11) return kFALSE;
188 Int_t motherpdg = TMath::Abs(GetMotherPDG(dynamic_cast<const AliVParticle *>(o)));
189 AliDebug(1, Form("Mother PDG %d\n", motherpdg));
191 if((motherpdg % 1000) / 100 == 5) return kTRUE; // beauty meson, 3rd position in pdg code == 5
192 if(motherpdg / 1000 == 5) return kTRUE; // beauty baryon, 4th position in pdg code == 5
193 AliDebug(1, "No Beauty\n");
197 //____________________________________________________________
198 Bool_t AliHFEsignalCuts::IsGammaElectron(const TObject * const o) const {
200 // Check for MC if the electron is coming from Gamma
202 if(TMath::Abs(GetTrackPDG(dynamic_cast<const AliVParticle *>(o))) != 11) return kFALSE;
203 Int_t motherpdg = TMath::Abs(GetMotherPDG(dynamic_cast<const AliVParticle *>(o)));
204 AliDebug(1, Form("Mother PDG %d\n", motherpdg));
207 AliDebug(1, "No Gamma");
210 AliDebug(1, "Gamma");
216 //____________________________________________________________
217 Int_t AliHFEsignalCuts::GetMotherPDG(const AliVParticle * const track) const {
219 // Get Mother Pdg code for reconstructed respectively MC tracks
222 AliDebug(1, "No MC Event Available\n");
225 const AliVParticle *motherParticle = NULL, *mctrack = NULL;
226 TString objectType = track->IsA()->GetName();
227 if(objectType.CompareTo("AliESDtrack") == 0 || objectType.CompareTo("AliAODTrack") == 0){
228 // Reconstructed track
229 if(track->GetLabel())
230 mctrack = fMC->GetTrack(TMath::Abs(track->GetLabel()));
236 if(!mctrack) return 0;
239 if(TString(mctrack->IsA()->GetName()).CompareTo("AliMCParticle") == 0){
241 const AliMCParticle *esdmctrack = dynamic_cast<const AliMCParticle *>(mctrack);
242 if(esdmctrack) motherParticle = fMC->GetTrack(esdmctrack->Particle()->GetFirstMother());
244 const AliMCParticle *esdmcmother = dynamic_cast<const AliMCParticle *>(motherParticle);
245 if(esdmcmother) motherPDG = TMath::Abs(esdmcmother->Particle()->GetPdgCode());
248 // case AODMCParticle
249 const AliAODMCParticle *aodmctrack = dynamic_cast<const AliAODMCParticle *>(mctrack);
250 if(aodmctrack) motherParticle = fMC->GetTrack(aodmctrack->GetMother());
252 const AliAODMCParticle *aodmcmother = dynamic_cast<const AliAODMCParticle *>(motherParticle);
253 if(aodmcmother) motherPDG = TMath::Abs(aodmcmother->GetPdgCode());
259 //____________________________________________________________
260 Int_t AliHFEsignalCuts::GetTrackPDG(const AliVParticle * const track) const {
262 // Return PDG code of a particle itself
265 AliDebug(1, "No MC Event Available\n");
268 TString sourcetype = track->IsA()->GetName();
269 const AliVParticle *mctrack = NULL;
270 if(!sourcetype.CompareTo("AliESDtrack") || !sourcetype.CompareTo("AliAODTrack")){
271 mctrack = fMC->GetTrack(TMath::Abs(track->GetLabel()));
272 } else mctrack = track;
273 if(!mctrack) return 0;
275 TString mctype = mctrack->IsA()->GetName();
277 if(!mctype.CompareTo("AliMCParticle")){
278 const AliMCParticle *esdmc = dynamic_cast<const AliMCParticle *>(mctrack);
279 if(esdmc) trackPdg = esdmc->Particle()->GetPdgCode();
281 const AliAODMCParticle *aodmc = dynamic_cast< const AliAODMCParticle *>(mctrack);
282 if(aodmc) trackPdg = aodmc->GetPdgCode();
287 //____________________________________________________________
288 Int_t AliHFEsignalCuts::GetElecSource(const AliVParticle * const track) const {
290 // Return PDG code of a particle itself
294 AliDebug(1, "No MC Event Available\n");
298 AliDebug(1, "No MCQA Available\n");
302 AliDebug(1, "Track not Available\n");
306 TString sourcetype = track->IsA()->GetName();
307 const AliVParticle *mctrack = NULL;
308 TParticle *mcpart = NULL;
309 if(!sourcetype.CompareTo("AliESDtrack") || !sourcetype.CompareTo("AliAODTrack")){
310 mctrack = fMC->GetTrack(TMath::Abs(track->GetLabel()));
311 } else mctrack = track;
312 if(!mctrack) return 0;
314 TString mctype = mctrack->IsA()->GetName();
316 if(!mctype.CompareTo("AliMCParticle")){
317 const AliMCParticle *esdmc = dynamic_cast<const AliMCParticle *>(mctrack);
319 mcpart = esdmc->Particle();
320 eSource=fMCQA->GetElecSource(mcpart);