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 AliHFEsignalCuts::ESignalSource_t AliHFEsignalCuts::GetSignalSource(const TObject *const o) const{
143 // Get source type of the electron
145 ESignalSource_t source = kOther;
146 const AliVParticle *v = dynamic_cast<const AliVParticle *>(o);
147 if(!v) return source;
148 Int_t esources = GetElecSource(v);
149 if(esources == AliHFEmcQA::kDirectCharm) source = kEleCharm;
150 else if(esources == AliHFEmcQA::kDirectBeauty || esources == AliHFEmcQA::kBeautyCharm) source = kEleBeauty;
151 else if(esources >= AliHFEmcQA::kGammaPi0 && esources <= AliHFEmcQA::kGammaRho0) source = kEleGamma;
152 else if(esources == AliHFEmcQA:: kPi0 || esources == AliHFEmcQA::kEta || esources == AliHFEmcQA::kOmega || esources == AliHFEmcQA::kPhi || esources == AliHFEmcQA::kEtaPrime || esources == AliHFEmcQA::kRho0) source = kEleNonHFE;
153 else if(esources == AliHFEmcQA::kJpsi) source = kEleJPsi;
154 else if(esources == AliHFEmcQA::kB2Jpsi) source = kEleBtoJPsi;
155 else if(esources == AliHFEmcQA::kKe3) source = kEleKe3;
159 /*****************************************
161 *****************************************/
163 //____________________________________________________________
164 Bool_t AliHFEsignalCuts::IsCharmElectronOld(const TObject * const o) const {
166 // Check if mother is coming from Charm
168 const AliVParticle *v = dynamic_cast<const AliVParticle *>(o);
169 if(!v) return kFALSE;
170 Int_t esources = GetElecSource(v);
171 if(esources == AliHFEmcQA::kDirectCharm) // 1: direct D->e
177 //____________________________________________________________
178 Bool_t AliHFEsignalCuts::IsBeautyElectronOld(const TObject * const o) const {
180 // Check if mother is coming from Beauty
182 const AliVParticle *v = dynamic_cast<const AliVParticle *>(o);
183 if(!v) return kFALSE;
184 Int_t esources = GetElecSource(v);
185 if(esources == AliHFEmcQA::kDirectBeauty || esources == AliHFEmcQA::kBeautyCharm) // 2: B->e 3: B->D->e
191 //____________________________________________________________
192 Bool_t AliHFEsignalCuts::IsGammaElectronOld(const TObject * const o) const {
194 // Check for MC if the electron is coming from Gamma
196 const AliVParticle *v = dynamic_cast<const AliVParticle *>(o);
197 if(!v) return kFALSE;
198 Int_t esources = GetElecSource(v);
199 if(esources >= AliHFEmcQA::kGammaPi0 && esources <= AliHFEmcQA::kGammaRho0 ) // 4: conversion electrons
200 //if(esources == AliHFEmcQA::kGammaPi0 || esources == AliHFEmcQA::kGammaEta || esources == AliHFEmcQA::kGammaOmega || esources == AliHFEmcQA::kGammaPhi || esources == AliHFEmcQA::kGammaEtaPrime || esources == AliHFEmcQA::kGammaRho0 ) // 4: conversion electrons
206 //____________________________________________________________
207 Bool_t AliHFEsignalCuts::IsNonHFElectronOld(const TObject * const o) const {
209 // Check for MC if the electron is coming from NonHFE except for conversion
211 const AliVParticle *v = dynamic_cast<const AliVParticle *>(o);
212 if(!v) return kFALSE;
213 Int_t esources = GetElecSource(v);
214 if(esources == AliHFEmcQA:: kPi0 || esources == AliHFEmcQA::kEta || esources == AliHFEmcQA::kOmega || esources == AliHFEmcQA::kPhi || esources == AliHFEmcQA::kEtaPrime || esources == AliHFEmcQA::kRho0) // 4: conversion electrons
220 //____________________________________________________________
221 Bool_t AliHFEsignalCuts::IsJpsiElectronOld(const TObject * const o) const {
223 // Check if mother is coming from Charm
225 const AliVParticle *v = dynamic_cast<const AliVParticle *>(o);
226 if(!v) return kFALSE;
227 Int_t esources = GetElecSource(v);
228 if(esources == AliHFEmcQA::kJpsi) // 5: J/psi->ee
234 //____________________________________________________________
235 Bool_t AliHFEsignalCuts::IsB2JpsiElectronOld(const TObject * const o) const {
237 // Check if mother is coming from Charm
239 const AliVParticle *v = dynamic_cast<const AliVParticle *>(o);
240 if(!v) return kFALSE;
241 Int_t esources = GetElecSource(v);
242 if(esources == AliHFEmcQA::kB2Jpsi) // 6: B->Jpsi->ee
248 //____________________________________________________________
249 Bool_t AliHFEsignalCuts::IsKe3ElectronOld(const TObject * const o) const {
251 // Check if mother is coming from Charm
253 const AliVParticle *v = dynamic_cast<const AliVParticle *>(o);
254 if(!v) return kFALSE;
255 Int_t esources = GetElecSource(v);
256 if(esources == AliHFEmcQA::kKe3) // 7: K->e
263 //____________________________________________________________
264 Bool_t AliHFEsignalCuts::IsCharmElectron(const TObject * const o) const {
266 // Check if mother is coming from Charm
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));
272 if((motherpdg % 1000) / 100 == 4) return kTRUE; // charmed meson, 3rd position in pdg code == 4
273 if(motherpdg / 1000 == 4) return kTRUE; // charmed baryon, 4th position in pdg code == 4
274 AliDebug(1, "No Charm\n");
278 //____________________________________________________________
279 Bool_t AliHFEsignalCuts::IsBeautyElectron(const TObject * const o) const {
281 // Check if mother is coming from Beauty
283 if(TMath::Abs(GetTrackPDG(dynamic_cast<const AliVParticle *>(o))) != 11) return kFALSE;
284 Int_t motherpdg = TMath::Abs(GetMotherPDG(dynamic_cast<const AliVParticle *>(o)));
285 AliDebug(1, Form("Mother PDG %d\n", motherpdg));
287 if((motherpdg % 1000) / 100 == 5) return kTRUE; // beauty meson, 3rd position in pdg code == 5
288 if(motherpdg / 1000 == 5) return kTRUE; // beauty baryon, 4th position in pdg code == 5
289 AliDebug(1, "No Beauty\n");
293 //____________________________________________________________
294 Bool_t AliHFEsignalCuts::IsGammaElectron(const TObject * const o) const {
296 // Check for MC if the electron is coming from Gamma
298 if(TMath::Abs(GetTrackPDG(dynamic_cast<const AliVParticle *>(o))) != 11) return kFALSE;
299 Int_t motherpdg = TMath::Abs(GetMotherPDG(dynamic_cast<const AliVParticle *>(o)));
300 AliDebug(1, Form("Mother PDG %d\n", motherpdg));
303 AliDebug(1, "No Gamma");
306 AliDebug(1, "Gamma");
312 //____________________________________________________________
313 Int_t AliHFEsignalCuts::GetMotherPDG(const AliVParticle * const track) const {
315 // Get Mother Pdg code for reconstructed respectively MC tracks
317 TClass *type = track->IsA();
318 //if((!fMC && (type == AliESDtrack::Class())) || (!fAODArrayMCInfo && (type == AliAODTrack::Class()))){
319 // AliDebug(1, "No MC Event Available\n");
322 const AliVParticle *motherParticle = NULL, *mctrack = NULL;
323 Int_t label = TMath::Abs(track->GetLabel());
324 if(type == AliESDtrack::Class()){
327 AliDebug(1, "No MC Event Available\n");
330 // Reconstructed track
331 if(label) mctrack = fMC->GetTrack(TMath::Abs(label));
334 else if(type == AliAODTrack::Class()) {
336 if(!fAODArrayMCInfo) {
337 AliDebug(1, "No MC Event Available\n");
341 if(label && label < fAODArrayMCInfo->GetEntriesFast())
342 mctrack = (AliVParticle *) fAODArrayMCInfo->At(label);
348 if(!mctrack) return 0;
351 if(TString(mctrack->IsA()->GetName()).CompareTo("AliMCParticle") == 0){
353 const AliMCParticle *esdmctrack = dynamic_cast<const AliMCParticle *>(mctrack);
356 AliDebug(1, "No MC Event Available\n");
359 motherParticle = fMC->GetTrack(esdmctrack->Particle()->GetFirstMother());
362 const AliMCParticle *esdmcmother = dynamic_cast<const AliMCParticle *>(motherParticle);
363 if(esdmcmother) motherPDG = TMath::Abs(esdmcmother->Particle()->GetPdgCode());
367 // case AODMCParticle
368 const AliAODMCParticle *aodmctrack = dynamic_cast<const AliAODMCParticle *>(mctrack);
370 if(!fAODArrayMCInfo) {
371 AliDebug(1, "No MC Event Available\n");
374 if(aodmctrack->GetMother() && aodmctrack->GetMother() < fAODArrayMCInfo->GetEntriesFast())
375 motherParticle = (AliVParticle *) fAODArrayMCInfo->At(aodmctrack->GetMother());
378 const AliAODMCParticle *aodmcmother = dynamic_cast<const AliAODMCParticle *>(motherParticle);
379 if(aodmcmother) motherPDG = TMath::Abs(aodmcmother->GetPdgCode());
385 //____________________________________________________________
386 Int_t AliHFEsignalCuts::GetTrackPDG(const AliVParticle * const track) const {
388 // Return PDG code of a particle itself
392 TClass *type = track->IsA();
393 //if((!fMC && (type == AliESDtrack::Class())) || (!fAODArrayMCInfo && (type == AliAODTrack::Class()))){
394 // AliDebug(1, "No MC Event Available\n");
397 const AliVParticle *mctrack = NULL;
398 Int_t label = TMath::Abs(track->GetLabel());
399 if(type == AliESDtrack::Class()){
402 AliDebug(1, "No MC Event Available\n");
405 // Reconstructed track
406 if(label) mctrack = fMC->GetTrack(TMath::Abs(label));
409 else if(type == AliAODTrack::Class()) {
411 if(!fAODArrayMCInfo) {
412 AliDebug(1, "No MC Event Available\n");
416 if(label && label < fAODArrayMCInfo->GetEntriesFast())
417 mctrack = (AliVParticle *) fAODArrayMCInfo->At(label);
423 if(!mctrack) return 0;
425 TString mctype = mctrack->IsA()->GetName();
427 if(!mctype.CompareTo("AliMCParticle")){
428 const AliMCParticle *esdmc = dynamic_cast<const AliMCParticle *>(mctrack);
429 if(esdmc) trackPdg = esdmc->Particle()->GetPdgCode();
431 const AliAODMCParticle *aodmc = dynamic_cast< const AliAODMCParticle *>(mctrack);
432 if(aodmc) trackPdg = aodmc->GetPdgCode();
437 //____________________________________________________________
438 Int_t AliHFEsignalCuts::GetElecSource(const AliVParticle * const track) const {
440 // Return PDG code of a particle itself
443 AliDebug(1, "Track not Available\n");
447 TClass *type = track->IsA();
448 //if((!fMC && (type == AliESDtrack::Class())) || (!fAODArrayMCInfo && (type == AliAODTrack::Class()))){
449 // AliDebug(1, "No MC Event Available\n");
453 AliDebug(1, "No MCQA Available\n");
458 const AliVParticle *mctrack = NULL;
459 TParticle *mcpart = NULL;
460 Int_t label = TMath::Abs(track->GetLabel());
461 AliMCParticle *esdmcmother = NULL;
462 if(type == AliESDtrack::Class()){
465 AliDebug(1, "No MC Event Available\n");
468 // Reconstructed track
469 if(label) mctrack = fMC->GetTrack(TMath::Abs(label));
472 else if(type == AliAODTrack::Class()) {
474 if(!fAODArrayMCInfo) {
475 AliDebug(1, "No MC Event Available\n");
479 if(label && label < fAODArrayMCInfo->GetEntriesFast())
480 mctrack = (AliVParticle *) fAODArrayMCInfo->At(label);
485 if(!mctrack) return 0;
488 if(mctrack->IsA() == AliMCParticle::Class()){
489 const AliMCParticle *esdmc = dynamic_cast<const AliMCParticle *>(mctrack);
491 mcpart = esdmc->Particle();
492 eSource=fMCQA->GetElecSource(mcpart,kTRUE);
493 // considering secondary pions
494 if(type == AliESDtrack::Class()){
495 if(eSource>=AliHFEmcQA::kGammaPi0 && eSource<=AliHFEmcQA::kGammaRho0) { // conversion electron, be careful with the enum odering
496 Int_t glabel=TMath::Abs(esdmc->GetMother()); // gamma label
497 if((esdmcmother= dynamic_cast<AliMCParticle *>(fMC->GetTrack(glabel)))){
498 glabel=TMath::Abs(esdmcmother->GetMother()); // gamma's mother's label
499 if((esdmcmother= dynamic_cast<AliMCParticle *>(fMC->GetTrack(glabel)))){
500 if(glabel>fMC->GetNumberOfPrimaries()) eSource=AliHFEmcQA::kScdryM;
504 else if(eSource==AliHFEmcQA::kPi0 || (eSource>=AliHFEmcQA::kEta && eSource<=AliHFEmcQA::kRho0) ){ // nonHFE except for the conversion electron
505 Int_t glabel=TMath::Abs(esdmc->GetMother());
506 if((esdmcmother= dynamic_cast<AliMCParticle *>(fMC->GetTrack(glabel)))){
507 if(glabel>fMC->GetNumberOfPrimaries()) eSource=AliHFEmcQA::kScdryM;
513 eSource=fMCQA->GetElecSource(mctrack,kTRUE);