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
179 //____________________________________________________________
180 Bool_t AliHFEsignalCuts::IsJpsiElectron(const TObject * const o) const {
182 // Check if mother is coming from Charm
184 if(!dynamic_cast<const AliVParticle *>(o)) return kFALSE;
185 Int_t esources = GetElecSource(dynamic_cast<const AliVParticle *>(o));
186 if(esources == AliHFEmcQA::kJpsi) // 5: J/psi->ee
192 //____________________________________________________________
193 Bool_t AliHFEsignalCuts::IsB2JpsiElectron(const TObject * const o) const {
195 // Check if mother is coming from Charm
197 if(!dynamic_cast<const AliVParticle *>(o)) return kFALSE;
198 Int_t esources = GetElecSource(dynamic_cast<const AliVParticle *>(o));
199 if(esources == AliHFEmcQA::kB2Jpsi) // 6: B->Jpsi->ee
205 //____________________________________________________________
206 Bool_t AliHFEsignalCuts::IsKe3Electron(const TObject * const o) const {
208 // Check if mother is coming from Charm
210 if(!dynamic_cast<const AliVParticle *>(o)) return kFALSE;
211 Int_t esources = GetElecSource(dynamic_cast<const AliVParticle *>(o));
212 if(esources == AliHFEmcQA::kKe3) // 7: K->e
219 //____________________________________________________________
220 Bool_t AliHFEsignalCuts::IsCharmElectron(const TObject * const o) const {
222 // Check if mother is coming from Charm
224 if(TMath::Abs(GetTrackPDG(dynamic_cast<const AliVParticle *>(o))) != 11) return kFALSE;
225 Int_t motherpdg = TMath::Abs(GetMotherPDG(dynamic_cast<const AliVParticle *>(o)));
226 AliDebug(1, Form("Mother PDG %d\n", motherpdg));
228 if((motherpdg % 1000) / 100 == 4) return kTRUE; // charmed meson, 3rd position in pdg code == 4
229 if(motherpdg / 1000 == 4) return kTRUE; // charmed baryon, 4th position in pdg code == 4
230 AliDebug(1, "No Charm\n");
234 //____________________________________________________________
235 Bool_t AliHFEsignalCuts::IsBeautyElectron(const TObject * const o) const {
237 // Check if mother is coming from Beauty
239 if(TMath::Abs(GetTrackPDG(dynamic_cast<const AliVParticle *>(o))) != 11) return kFALSE;
240 Int_t motherpdg = TMath::Abs(GetMotherPDG(dynamic_cast<const AliVParticle *>(o)));
241 AliDebug(1, Form("Mother PDG %d\n", motherpdg));
243 if((motherpdg % 1000) / 100 == 5) return kTRUE; // beauty meson, 3rd position in pdg code == 5
244 if(motherpdg / 1000 == 5) return kTRUE; // beauty baryon, 4th position in pdg code == 5
245 AliDebug(1, "No Beauty\n");
249 //____________________________________________________________
250 Bool_t AliHFEsignalCuts::IsGammaElectron(const TObject * const o) const {
252 // Check for MC if the electron is coming from Gamma
254 if(TMath::Abs(GetTrackPDG(dynamic_cast<const AliVParticle *>(o))) != 11) return kFALSE;
255 Int_t motherpdg = TMath::Abs(GetMotherPDG(dynamic_cast<const AliVParticle *>(o)));
256 AliDebug(1, Form("Mother PDG %d\n", motherpdg));
259 AliDebug(1, "No Gamma");
262 AliDebug(1, "Gamma");
268 //____________________________________________________________
269 Int_t AliHFEsignalCuts::GetMotherPDG(const AliVParticle * const track) const {
271 // Get Mother Pdg code for reconstructed respectively MC tracks
274 AliDebug(1, "No MC Event Available\n");
277 const AliVParticle *motherParticle = NULL, *mctrack = NULL;
278 TString objectType = track->IsA()->GetName();
279 if(objectType.CompareTo("AliESDtrack") == 0 || objectType.CompareTo("AliAODTrack") == 0){
280 // Reconstructed track
281 if(track->GetLabel())
282 mctrack = fMC->GetTrack(TMath::Abs(track->GetLabel()));
288 if(!mctrack) return 0;
291 if(TString(mctrack->IsA()->GetName()).CompareTo("AliMCParticle") == 0){
293 const AliMCParticle *esdmctrack = dynamic_cast<const AliMCParticle *>(mctrack);
294 if(esdmctrack) motherParticle = fMC->GetTrack(esdmctrack->Particle()->GetFirstMother());
296 const AliMCParticle *esdmcmother = dynamic_cast<const AliMCParticle *>(motherParticle);
297 if(esdmcmother) motherPDG = TMath::Abs(esdmcmother->Particle()->GetPdgCode());
300 // case AODMCParticle
301 const AliAODMCParticle *aodmctrack = dynamic_cast<const AliAODMCParticle *>(mctrack);
302 if(aodmctrack) motherParticle = fMC->GetTrack(aodmctrack->GetMother());
304 const AliAODMCParticle *aodmcmother = dynamic_cast<const AliAODMCParticle *>(motherParticle);
305 if(aodmcmother) motherPDG = TMath::Abs(aodmcmother->GetPdgCode());
311 //____________________________________________________________
312 Int_t AliHFEsignalCuts::GetTrackPDG(const AliVParticle * const track) const {
314 // Return PDG code of a particle itself
317 AliDebug(1, "No MC Event Available\n");
320 TString sourcetype = track->IsA()->GetName();
321 const AliVParticle *mctrack = NULL;
322 if(!sourcetype.CompareTo("AliESDtrack") || !sourcetype.CompareTo("AliAODTrack")){
323 mctrack = fMC->GetTrack(TMath::Abs(track->GetLabel()));
324 } else mctrack = track;
325 if(!mctrack) return 0;
327 TString mctype = mctrack->IsA()->GetName();
329 if(!mctype.CompareTo("AliMCParticle")){
330 const AliMCParticle *esdmc = dynamic_cast<const AliMCParticle *>(mctrack);
331 if(esdmc) trackPdg = esdmc->Particle()->GetPdgCode();
333 const AliAODMCParticle *aodmc = dynamic_cast< const AliAODMCParticle *>(mctrack);
334 if(aodmc) trackPdg = aodmc->GetPdgCode();
339 //____________________________________________________________
340 Int_t AliHFEsignalCuts::GetElecSource(const AliVParticle * const track) const {
342 // Return PDG code of a particle itself
346 AliDebug(1, "No MC Event Available\n");
350 AliDebug(1, "No MCQA Available\n");
354 AliDebug(1, "Track not Available\n");
359 const AliVParticle *mctrack = NULL;
360 TParticle *mcpart = NULL;
361 //AliMCParticle *esdmcmother = NULL;
362 if((tracktype = track->IsA()) == AliESDtrack::Class() || tracktype == AliAODTrack::Class()){
363 mctrack = fMC->GetTrack(TMath::Abs(track->GetLabel()));
364 } else mctrack = track;
365 if(!mctrack) return 0;
368 if(mctrack->IsA() == AliMCParticle::Class()){
369 const AliMCParticle *esdmc = dynamic_cast<const AliMCParticle *>(mctrack);
371 mcpart = esdmc->Particle();
372 eSource=fMCQA->GetElecSource(mcpart);
373 /* // considering secondary pions
374 if(eSource>=AliHFEmcQA::kGammaPi0) { // conversion electron, be careful with the enum odering
375 Int_t glabel=TMath::Abs(esdmc->GetMother()); // gamma label
376 if((esdmcmother= dynamic_cast<AliMCParticle *>(fMC->GetTrack(glabel)))){
377 glabel=TMath::Abs(esdmcmother->GetMother()); // gamma's mother's label
378 if((esdmcmother= dynamic_cast<AliMCParticle *>(fMC->GetTrack(glabel)))){
379 if(glabel>fMC->GetNumberOfPrimaries()) eSource=AliHFEmcQA::kElse;
383 else if(eSource==AliHFEmcQA::kPi0 || (eSource>=AliHFEmcQA::kEta && eSource<=AliHFEmcQA::kRho0) ){ // nonHFE except for the conversion electron
384 Int_t glabel=TMath::Abs(esdmc->GetMother());
385 if((esdmcmother= dynamic_cast<AliMCParticle *>(fMC->GetTrack(glabel)))){
386 if(glabel>fMC->GetNumberOfPrimaries()) eSource=AliHFEmcQA::kElse;