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 if(!dynamic_cast<const AliVParticle *>(o)) return kFALSE;
130 Int_t esources = GetElecSource(dynamic_cast<const AliVParticle *>(o));
131 if(esources == AliHFEmcQA::kDirectCharm) // 1: direct D->e
137 //____________________________________________________________
138 Bool_t AliHFEsignalCuts::IsBeautyElectron(const TObject * const o) const {
140 // Check if mother is coming from Beauty
142 if(!dynamic_cast<const AliVParticle *>(o)) return kFALSE;
143 Int_t esources = GetElecSource(dynamic_cast<const AliVParticle *>(o));
144 if(esources == AliHFEmcQA::kDirectBeauty || esources == AliHFEmcQA::kBeautyCharm) // 2: B->e 3: B->D->e
150 //____________________________________________________________
151 Bool_t AliHFEsignalCuts::IsGammaElectron(const TObject * const o) const {
153 // Check for MC if the electron is coming from Gamma
155 if(!dynamic_cast<const AliVParticle *>(o)) return kFALSE;
156 Int_t esources = GetElecSource(dynamic_cast<const AliVParticle *>(o));
157 if(esources == AliHFEmcQA::kGamma) // 4: conversion electrons
164 //____________________________________________________________
165 Bool_t AliHFEsignalCuts::IsCharmElectron(const TObject * const o) const {
167 // Check if mother is coming from Charm
169 if(TMath::Abs(GetTrackPDG(dynamic_cast<const AliVParticle *>(o))) != 11) return kFALSE;
170 Int_t motherpdg = TMath::Abs(GetMotherPDG(dynamic_cast<const AliVParticle *>(o)));
171 AliDebug(1, Form("Mother PDG %d\n", motherpdg));
173 if((motherpdg % 1000) / 100 == 4) return kTRUE; // charmed meson, 3rd position in pdg code == 4
174 if(motherpdg / 1000 == 4) return kTRUE; // charmed baryon, 4th position in pdg code == 4
175 AliDebug(1, "No Charm\n");
179 //____________________________________________________________
180 Bool_t AliHFEsignalCuts::IsBeautyElectron(const TObject * const o) const {
182 // Check if mother is coming from Beauty
184 if(TMath::Abs(GetTrackPDG(dynamic_cast<const AliVParticle *>(o))) != 11) return kFALSE;
185 Int_t motherpdg = TMath::Abs(GetMotherPDG(dynamic_cast<const AliVParticle *>(o)));
186 AliDebug(1, Form("Mother PDG %d\n", motherpdg));
188 if((motherpdg % 1000) / 100 == 5) return kTRUE; // beauty meson, 3rd position in pdg code == 5
189 if(motherpdg / 1000 == 5) return kTRUE; // beauty baryon, 4th position in pdg code == 5
190 AliDebug(1, "No Beauty\n");
194 //____________________________________________________________
195 Bool_t AliHFEsignalCuts::IsGammaElectron(const TObject * const o) const {
197 // Check for MC if the electron is coming from Gamma
199 if(TMath::Abs(GetTrackPDG(dynamic_cast<const AliVParticle *>(o))) != 11) return kFALSE;
200 Int_t motherpdg = TMath::Abs(GetMotherPDG(dynamic_cast<const AliVParticle *>(o)));
201 AliDebug(1, Form("Mother PDG %d\n", motherpdg));
204 AliDebug(1, "No Gamma");
207 AliDebug(1, "Gamma");
213 //____________________________________________________________
214 Int_t AliHFEsignalCuts::GetMotherPDG(const AliVParticle * const track) const {
216 // Get Mother Pdg code for reconstructed respectively MC tracks
219 AliDebug(1, "No MC Event Available\n");
222 const AliVParticle *motherParticle = NULL, *mctrack = NULL;
223 TString objectType = track->IsA()->GetName();
224 if(objectType.CompareTo("AliESDtrack") == 0 || objectType.CompareTo("AliAODTrack") == 0){
225 // Reconstructed track
226 if(track->GetLabel())
227 mctrack = fMC->GetTrack(TMath::Abs(track->GetLabel()));
233 if(!mctrack) return 0;
236 if(TString(mctrack->IsA()->GetName()).CompareTo("AliMCParticle") == 0){
238 const AliMCParticle *esdmctrack = dynamic_cast<const AliMCParticle *>(mctrack);
239 if(esdmctrack) motherParticle = fMC->GetTrack(esdmctrack->Particle()->GetFirstMother());
241 const AliMCParticle *esdmcmother = dynamic_cast<const AliMCParticle *>(motherParticle);
242 if(esdmcmother) motherPDG = TMath::Abs(esdmcmother->Particle()->GetPdgCode());
245 // case AODMCParticle
246 const AliAODMCParticle *aodmctrack = dynamic_cast<const AliAODMCParticle *>(mctrack);
247 if(aodmctrack) motherParticle = fMC->GetTrack(aodmctrack->GetMother());
249 const AliAODMCParticle *aodmcmother = dynamic_cast<const AliAODMCParticle *>(motherParticle);
250 if(aodmcmother) motherPDG = TMath::Abs(aodmcmother->GetPdgCode());
256 //____________________________________________________________
257 Int_t AliHFEsignalCuts::GetTrackPDG(const AliVParticle * const track) const {
259 // Return PDG code of a particle itself
262 AliDebug(1, "No MC Event Available\n");
265 TString sourcetype = track->IsA()->GetName();
266 const AliVParticle *mctrack = NULL;
267 if(!sourcetype.CompareTo("AliESDtrack") || !sourcetype.CompareTo("AliAODTrack")){
268 mctrack = fMC->GetTrack(TMath::Abs(track->GetLabel()));
269 } else mctrack = track;
270 if(!mctrack) return 0;
272 TString mctype = mctrack->IsA()->GetName();
274 if(!mctype.CompareTo("AliMCParticle")){
275 const AliMCParticle *esdmc = dynamic_cast<const AliMCParticle *>(mctrack);
276 if(esdmc) trackPdg = esdmc->Particle()->GetPdgCode();
278 const AliAODMCParticle *aodmc = dynamic_cast< const AliAODMCParticle *>(mctrack);
279 if(aodmc) trackPdg = aodmc->GetPdgCode();
284 //____________________________________________________________
285 Int_t AliHFEsignalCuts::GetElecSource(const AliVParticle * const track) const {
287 // Return PDG code of a particle itself
291 AliDebug(1, "No MC Event Available\n");
295 AliDebug(1, "No MCQA Available\n");
299 AliDebug(1, "Track not Available\n");
303 TString sourcetype = track->IsA()->GetName();
304 const AliVParticle *mctrack = NULL;
305 TParticle *mcpart = NULL;
306 if(!sourcetype.CompareTo("AliESDtrack") || !sourcetype.CompareTo("AliAODTrack")){
307 mctrack = fMC->GetTrack(TMath::Abs(track->GetLabel()));
308 } else mctrack = track;
309 if(!mctrack) return 0;
311 TString mctype = mctrack->IsA()->GetName();
313 if(!mctype.CompareTo("AliMCParticle")){
314 const AliMCParticle *esdmc = dynamic_cast<const AliMCParticle *>(mctrack);
315 mcpart = esdmc->Particle();
316 eSource=fMCQA->GetElecSource(mcpart);