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"
35 #include "TClonesArray.h"
37 #include "AliHFEsignalCuts.h"
38 #include "AliHFEmcQA.h"
40 ClassImp(AliHFEsignalCuts)
42 //____________________________________________________________
43 AliHFEsignalCuts::AliHFEsignalCuts():
46 fAODArrayMCInfo(NULL),
54 //____________________________________________________________
55 AliHFEsignalCuts::AliHFEsignalCuts(const Char_t *name, const Char_t *title):
56 AliAnalysisCuts(name, title),
58 fAODArrayMCInfo(NULL),
62 // Default constructor
64 fMCQA = new AliHFEmcQA;
65 if(fMCQA) fMCQA->Init();
68 //____________________________________________________________
69 AliHFEsignalCuts::AliHFEsignalCuts(const AliHFEsignalCuts &ref):
72 fAODArrayMCInfo(NULL),
80 //____________________________________________________________
81 AliHFEsignalCuts &AliHFEsignalCuts::operator=(const AliHFEsignalCuts &ref){
83 // Assignment operator
87 //fAODArrayMCInfo = ref.fAODArrayMCInfo;
93 //____________________________________________________________
94 AliHFEsignalCuts::~AliHFEsignalCuts(){
98 if(fMCQA) delete fMCQA;
101 //____________________________________________________________
102 void AliHFEsignalCuts::SetMCEvent(AliMCEvent *mc){
107 if(fMCQA) fMCQA->SetMCEvent(mc);
110 //____________________________________________________________
111 void AliHFEsignalCuts::SetMCAODInfo(TClonesArray *mcarray){
115 fAODArrayMCInfo = mcarray;
116 if(fMCQA) fMCQA->SetMCArray(mcarray);
119 //____________________________________________________________
120 Bool_t AliHFEsignalCuts::IsSelected(TObject *o){
122 // Define signal as electron coming from charm or beauty
123 // @TODO: Implement setter so that also either of them can be defined
127 return IsCharmElectron(o) || IsBeautyElectron(o);
130 Int_t esources = GetElecSource(dynamic_cast<const AliVParticle *>(o));
131 if(esources>0)printf("esources= %d\n",esources);
132 if(esources == AliHFEmcQA::kDirectCharm || esources == AliHFEmcQA::kDirectBeauty || esources == AliHFEmcQA::kBeautyCharm) // 1: direct D->e, 2: B->e 3: B->D->e
140 //____________________________________________________________
141 Bool_t AliHFEsignalCuts::IsCharmElectron(const TObject * const o) const {
143 // Check if mother is coming from Charm
145 if(!dynamic_cast<const AliVParticle *>(o)) return kFALSE;
146 Int_t esources = GetElecSource(dynamic_cast<const AliVParticle *>(o));
147 if(esources == AliHFEmcQA::kDirectCharm) // 1: direct D->e
153 //____________________________________________________________
154 Bool_t AliHFEsignalCuts::IsBeautyElectron(const TObject * const o) const {
156 // Check if mother is coming from Beauty
158 if(!dynamic_cast<const AliVParticle *>(o)) return kFALSE;
159 Int_t esources = GetElecSource(dynamic_cast<const AliVParticle *>(o));
160 if(esources == AliHFEmcQA::kDirectBeauty || esources == AliHFEmcQA::kBeautyCharm) // 2: B->e 3: B->D->e
166 //____________________________________________________________
167 Bool_t AliHFEsignalCuts::IsGammaElectron(const TObject * const o) const {
169 // Check for MC if the electron is coming from Gamma
171 if(!dynamic_cast<const AliVParticle *>(o)) return kFALSE;
172 Int_t esources = GetElecSource(dynamic_cast<const AliVParticle *>(o));
173 if(esources >= AliHFEmcQA::kGammaPi0 && esources <= AliHFEmcQA::kGammaRho0 ) // 4: conversion electrons
174 //if(esources == AliHFEmcQA::kGammaPi0 || esources == AliHFEmcQA::kGammaEta || esources == AliHFEmcQA::kGammaOmega || esources == AliHFEmcQA::kGammaPhi || esources == AliHFEmcQA::kGammaEtaPrime || esources == AliHFEmcQA::kGammaRho0 ) // 4: conversion electrons
180 //____________________________________________________________
181 Bool_t AliHFEsignalCuts::IsNonHFElectron(const TObject * const o) const {
183 // Check for MC if the electron is coming from NonHFE except for conversion
185 if(!dynamic_cast<const AliVParticle *>(o)) return kFALSE;
186 Int_t esources = GetElecSource(dynamic_cast<const AliVParticle *>(o));
187 if(esources == AliHFEmcQA:: kPi0 || esources == AliHFEmcQA::kEta || esources == AliHFEmcQA::kOmega || esources == AliHFEmcQA::kPhi || esources == AliHFEmcQA::kEtaPrime || esources == AliHFEmcQA::kRho0) // 4: conversion electrons
193 //____________________________________________________________
194 Bool_t AliHFEsignalCuts::IsJpsiElectron(const TObject * const o) const {
196 // Check if mother is coming from Charm
198 if(!dynamic_cast<const AliVParticle *>(o)) return kFALSE;
199 Int_t esources = GetElecSource(dynamic_cast<const AliVParticle *>(o));
200 if(esources == AliHFEmcQA::kJpsi) // 5: J/psi->ee
206 //____________________________________________________________
207 Bool_t AliHFEsignalCuts::IsB2JpsiElectron(const TObject * const o) const {
209 // Check if mother is coming from Charm
211 if(!dynamic_cast<const AliVParticle *>(o)) return kFALSE;
212 Int_t esources = GetElecSource(dynamic_cast<const AliVParticle *>(o));
213 if(esources == AliHFEmcQA::kB2Jpsi) // 6: B->Jpsi->ee
219 //____________________________________________________________
220 Bool_t AliHFEsignalCuts::IsKe3Electron(const TObject * const o) const {
222 // Check if mother is coming from Charm
224 if(!dynamic_cast<const AliVParticle *>(o)) return kFALSE;
225 Int_t esources = GetElecSource(dynamic_cast<const AliVParticle *>(o));
226 if(esources == AliHFEmcQA::kKe3) // 7: K->e
233 //____________________________________________________________
234 Bool_t AliHFEsignalCuts::IsCharmElectron(const TObject * const o) const {
236 // Check if mother is coming from Charm
238 if(TMath::Abs(GetTrackPDG(dynamic_cast<const AliVParticle *>(o))) != 11) return kFALSE;
239 Int_t motherpdg = TMath::Abs(GetMotherPDG(dynamic_cast<const AliVParticle *>(o)));
240 AliDebug(1, Form("Mother PDG %d\n", motherpdg));
242 if((motherpdg % 1000) / 100 == 4) return kTRUE; // charmed meson, 3rd position in pdg code == 4
243 if(motherpdg / 1000 == 4) return kTRUE; // charmed baryon, 4th position in pdg code == 4
244 AliDebug(1, "No Charm\n");
248 //____________________________________________________________
249 Bool_t AliHFEsignalCuts::IsBeautyElectron(const TObject * const o) const {
251 // Check if mother is coming from Beauty
253 if(TMath::Abs(GetTrackPDG(dynamic_cast<const AliVParticle *>(o))) != 11) return kFALSE;
254 Int_t motherpdg = TMath::Abs(GetMotherPDG(dynamic_cast<const AliVParticle *>(o)));
255 AliDebug(1, Form("Mother PDG %d\n", motherpdg));
257 if((motherpdg % 1000) / 100 == 5) return kTRUE; // beauty meson, 3rd position in pdg code == 5
258 if(motherpdg / 1000 == 5) return kTRUE; // beauty baryon, 4th position in pdg code == 5
259 AliDebug(1, "No Beauty\n");
263 //____________________________________________________________
264 Bool_t AliHFEsignalCuts::IsGammaElectron(const TObject * const o) const {
266 // Check for MC if the electron is coming from Gamma
268 if(TMath::Abs(GetTrackPDG(dynamic_cast<const AliVParticle *>(o))) != 11) return kFALSE;
269 Int_t motherpdg = TMath::Abs(GetMotherPDG(dynamic_cast<const AliVParticle *>(o)));
270 AliDebug(1, Form("Mother PDG %d\n", motherpdg));
273 AliDebug(1, "No Gamma");
276 AliDebug(1, "Gamma");
282 //____________________________________________________________
283 Int_t AliHFEsignalCuts::GetMotherPDG(const AliVParticle * const track) const {
285 // Get Mother Pdg code for reconstructed respectively MC tracks
287 TClass *type = track->IsA();
288 if((!fMC && (type == AliESDtrack::Class())) || (!fAODArrayMCInfo && (type == AliAODTrack::Class()))){
289 AliDebug(1, "No MC Event Available\n");
292 const AliVParticle *motherParticle = NULL, *mctrack = NULL;
293 Int_t label = TMath::Abs(track->GetLabel());
294 if(type == AliESDtrack::Class()){
295 // Reconstructed track
296 if(label) mctrack = fMC->GetTrack(TMath::Abs(label));
299 else if(type == AliAODTrack::Class()) {
301 if(label && label < fAODArrayMCInfo->GetEntriesFast())
302 mctrack = (AliVParticle *) fAODArrayMCInfo->At(label);
308 if(!mctrack) return 0;
311 if(TString(mctrack->IsA()->GetName()).CompareTo("AliMCParticle") == 0){
313 const AliMCParticle *esdmctrack = dynamic_cast<const AliMCParticle *>(mctrack);
314 if(esdmctrack) motherParticle = fMC->GetTrack(esdmctrack->Particle()->GetFirstMother());
316 const AliMCParticle *esdmcmother = dynamic_cast<const AliMCParticle *>(motherParticle);
317 if(esdmcmother) motherPDG = TMath::Abs(esdmcmother->Particle()->GetPdgCode());
320 // case AODMCParticle
321 const AliAODMCParticle *aodmctrack = dynamic_cast<const AliAODMCParticle *>(mctrack);
323 if(aodmctrack->GetMother() && aodmctrack->GetMother() < fAODArrayMCInfo->GetEntriesFast())
324 motherParticle = (AliVParticle *) fAODArrayMCInfo->At(aodmctrack->GetMother());
327 const AliAODMCParticle *aodmcmother = dynamic_cast<const AliAODMCParticle *>(motherParticle);
328 if(aodmcmother) motherPDG = TMath::Abs(aodmcmother->GetPdgCode());
334 //____________________________________________________________
335 Int_t AliHFEsignalCuts::GetTrackPDG(const AliVParticle * const track) const {
337 // Return PDG code of a particle itself
339 TClass *type = track->IsA();
340 if((!fMC && (type == AliESDtrack::Class())) || (!fAODArrayMCInfo && (type == AliAODTrack::Class()))){
341 AliDebug(1, "No MC Event Available\n");
344 const AliVParticle *mctrack = NULL;
345 Int_t label = TMath::Abs(track->GetLabel());
346 if(type == AliESDtrack::Class()){
347 // Reconstructed track
348 if(label) mctrack = fMC->GetTrack(TMath::Abs(label));
351 else if(type == AliAODTrack::Class()) {
353 if(label && label < fAODArrayMCInfo->GetEntriesFast())
354 mctrack = (AliVParticle *) fAODArrayMCInfo->At(label);
360 if(!mctrack) return 0;
362 TString mctype = mctrack->IsA()->GetName();
364 if(!mctype.CompareTo("AliMCParticle")){
365 const AliMCParticle *esdmc = dynamic_cast<const AliMCParticle *>(mctrack);
366 if(esdmc) trackPdg = esdmc->Particle()->GetPdgCode();
368 const AliAODMCParticle *aodmc = dynamic_cast< const AliAODMCParticle *>(mctrack);
369 if(aodmc) trackPdg = aodmc->GetPdgCode();
374 //____________________________________________________________
375 Int_t AliHFEsignalCuts::GetElecSource(const AliVParticle * const track) const {
377 // Return PDG code of a particle itself
380 TClass *type = track->IsA();
381 if((!fMC && (type == AliESDtrack::Class())) || (!fAODArrayMCInfo && (type == AliAODTrack::Class()))){
382 AliDebug(1, "No MC Event Available\n");
386 AliDebug(1, "No MCQA Available\n");
390 AliDebug(1, "Track not Available\n");
394 const AliVParticle *mctrack = NULL;
395 TParticle *mcpart = NULL;
396 Int_t label = TMath::Abs(track->GetLabel());
397 //AliMCParticle *esdmcmother = NULL;
398 if(type == AliESDtrack::Class()){
399 // Reconstructed track
400 if(label) mctrack = fMC->GetTrack(TMath::Abs(label));
403 else if(type == AliAODTrack::Class()) {
405 if(label && label < fAODArrayMCInfo->GetEntriesFast())
406 mctrack = (AliVParticle *) fAODArrayMCInfo->At(label);
411 if(!mctrack) return 0;
414 if(mctrack->IsA() == AliMCParticle::Class()){
415 const AliMCParticle *esdmc = dynamic_cast<const AliMCParticle *>(mctrack);
417 mcpart = esdmc->Particle();
418 eSource=fMCQA->GetElecSource(mcpart);
419 /* // considering secondary pions
420 if(eSource>=AliHFEmcQA::kGammaPi0) { // conversion electron, be careful with the enum odering
421 Int_t glabel=TMath::Abs(esdmc->GetMother()); // gamma label
422 if((esdmcmother= dynamic_cast<AliMCParticle *>(fMC->GetTrack(glabel)))){
423 glabel=TMath::Abs(esdmcmother->GetMother()); // gamma's mother's label
424 if((esdmcmother= dynamic_cast<AliMCParticle *>(fMC->GetTrack(glabel)))){
425 if(glabel>fMC->GetNumberOfPrimaries()) eSource=AliHFEmcQA::kElse;
429 else if(eSource==AliHFEmcQA::kPi0 || (eSource>=AliHFEmcQA::kEta && eSource<=AliHFEmcQA::kRho0) ){ // nonHFE except for the conversion electron
430 Int_t glabel=TMath::Abs(esdmc->GetMother());
431 if((esdmcmother= dynamic_cast<AliMCParticle *>(fMC->GetTrack(glabel)))){
432 if(glabel>fMC->GetNumberOfPrimaries()) eSource=AliHFEmcQA::kElse;
438 eSource=fMCQA->GetElecSource(mctrack);