]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG3/hfe/AliHFEsignalCuts.cxx
Fixes to run w/o OCDB infotrmation (in that case the class only provides statistics...
[u/mrichter/AliRoot.git] / PWG3 / hfe / AliHFEsignalCuts.cxx
CommitLineData
3a72645a 1/**************************************************************************
2* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3* *
4* Author: The ALICE Off-line Project. *
5* Contributors are mentioned in the code where appropriate. *
6* *
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**************************************************************************/
15//
16// Signal cuts
17// Checks whether a particle (reconstructed or MC) is coming from MC Signal
18// For more information see implementation file
19//
20// Autor:
21// Markus Fasel <M.Fasel@gsi.de>
22//
23#include <TClass.h>
24#include <TMath.h>
25#include <TParticle.h>
26#include <TString.h>
27
28#include "AliAODMCParticle.h"
29#include "AliLog.h"
30#include "AliMCEvent.h"
31#include "AliMCParticle.h"
32#include "AliVParticle.h"
33
34#include "AliHFEsignalCuts.h"
35#include "AliHFEmcQA.h"
36
37ClassImp(AliHFEsignalCuts)
38
39//____________________________________________________________
40AliHFEsignalCuts::AliHFEsignalCuts():
41 AliAnalysisCuts(),
42 fMC(NULL),
43 fMCQA(NULL)
44{
45 //
46 // Dummy constructor
47 //
48}
49
50//____________________________________________________________
51AliHFEsignalCuts::AliHFEsignalCuts(const Char_t *name, const Char_t *title):
52 AliAnalysisCuts(name, title),
53 fMC(NULL),
54 fMCQA(NULL)
55{
56 //
57 // Default constructor
58 //
59 fMCQA = new AliHFEmcQA;
60 if(fMCQA) fMCQA->Init();
61}
62
63//____________________________________________________________
64AliHFEsignalCuts::AliHFEsignalCuts(const AliHFEsignalCuts &ref):
65 AliAnalysisCuts(ref),
66 fMC(ref.fMC),
67 fMCQA(ref.fMCQA)
68{
69 //
70 // Copy constructor
71 //
72}
73
74//____________________________________________________________
75AliHFEsignalCuts &AliHFEsignalCuts::operator=(const AliHFEsignalCuts &ref){
76 //
77 // Assignment operator
78 //
79 if(this != &ref){
80 fMC = ref.fMC;
81 fMCQA = ref.fMCQA;
82 }
83 return *this;
84}
85
86//____________________________________________________________
87AliHFEsignalCuts::~AliHFEsignalCuts(){
88 //
89 // Destructor
90 //
91 if(fMCQA) delete fMCQA;
92}
93
94//____________________________________________________________
95void AliHFEsignalCuts::SetMCEvent(AliMCEvent *mc){
96 //
97 // Set mc event
98 //
99 fMC = mc;
100 if(fMCQA) fMCQA->SetMCEvent(mc);
101}
102
103//____________________________________________________________
104Bool_t AliHFEsignalCuts::IsSelected(TObject *o){
105 //
106 // Define signal as electron coming from charm or beauty
107 // @TODO: Implement setter so that also either of them can be defined
108 // as signal alone
109
110
111 return IsCharmElectron(o) || IsBeautyElectron(o);
112/*
113 //saving time?
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
117 return kTRUE;
118 else
119 return kFALSE;
120*/
121
122}
123
124//____________________________________________________________
125Bool_t AliHFEsignalCuts::IsCharmElectron(const TObject * const o) const {
126 //
127 // Check if mother is coming from Charm
128 //
bf892a6a 129 if(!dynamic_cast<const AliVParticle *>(o)) return kFALSE;
3a72645a 130 Int_t esources = GetElecSource(dynamic_cast<const AliVParticle *>(o));
131 if(esources == AliHFEmcQA::kDirectCharm) // 1: direct D->e
132 return kTRUE;
133 else
134 return kFALSE;
135}
136
137//____________________________________________________________
138Bool_t AliHFEsignalCuts::IsBeautyElectron(const TObject * const o) const {
139 //
140 // Check if mother is coming from Beauty
141 //
bf892a6a 142 if(!dynamic_cast<const AliVParticle *>(o)) return kFALSE;
3a72645a 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
145 return kTRUE;
146 else
147 return kFALSE;
148}
149
150//____________________________________________________________
151Bool_t AliHFEsignalCuts::IsGammaElectron(const TObject * const o) const {
152 //
153 // Check for MC if the electron is coming from Gamma
154 //
bf892a6a 155 if(!dynamic_cast<const AliVParticle *>(o)) return kFALSE;
3a72645a 156 Int_t esources = GetElecSource(dynamic_cast<const AliVParticle *>(o));
157 if(esources == AliHFEmcQA::kGamma) // 4: conversion electrons
158 return kTRUE;
159 else
160 return kFALSE;
161}
162
163/*
164//____________________________________________________________
165Bool_t AliHFEsignalCuts::IsCharmElectron(const TObject * const o) const {
166 //
167 // Check if mother is coming from Charm
168 //
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));
172
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");
176 return kFALSE;
177}
178
179//____________________________________________________________
180Bool_t AliHFEsignalCuts::IsBeautyElectron(const TObject * const o) const {
181 //
182 // Check if mother is coming from Beauty
183 //
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));
187
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");
191 return kFALSE;
192}
193
194//____________________________________________________________
195Bool_t AliHFEsignalCuts::IsGammaElectron(const TObject * const o) const {
196 //
197 // Check for MC if the electron is coming from Gamma
198 //
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));
202
203 if(motherpdg!=22){
204 AliDebug(1, "No Gamma");
205 return kFALSE;
206 } else {
207 AliDebug(1, "Gamma");
208 return kTRUE;
209 }
210}
211*/
212
213//____________________________________________________________
214Int_t AliHFEsignalCuts::GetMotherPDG(const AliVParticle * const track) const {
215 //
216 // Get Mother Pdg code for reconstructed respectively MC tracks
217 //
218 if(!fMC){
219 AliDebug(1, "No MC Event Available\n");
220 return 0;
221 }
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()));
228 } else {
229 // MCParticle
230 mctrack = track;
231 }
232
233 if(!mctrack) return 0;
234
235 Int_t motherPDG = 0;
236 if(TString(mctrack->IsA()->GetName()).CompareTo("AliMCParticle") == 0){
237 // case MC Particle
bf892a6a 238 const AliMCParticle *esdmctrack = dynamic_cast<const AliMCParticle *>(mctrack);
239 if(esdmctrack) motherParticle = fMC->GetTrack(esdmctrack->Particle()->GetFirstMother());
240 if(motherParticle){
241 const AliMCParticle *esdmcmother = dynamic_cast<const AliMCParticle *>(motherParticle);
242 if(esdmcmother) motherPDG = TMath::Abs(esdmcmother->Particle()->GetPdgCode());
243 }
3a72645a 244 } else {
245 // case AODMCParticle
bf892a6a 246 const AliAODMCParticle *aodmctrack = dynamic_cast<const AliAODMCParticle *>(mctrack);
247 if(aodmctrack) motherParticle = fMC->GetTrack(aodmctrack->GetMother());
248 if(motherParticle){
249 const AliAODMCParticle *aodmcmother = dynamic_cast<const AliAODMCParticle *>(motherParticle);
250 if(aodmcmother) motherPDG = TMath::Abs(aodmcmother->GetPdgCode());
251 }
3a72645a 252 }
253 return motherPDG;
254}
255
256//____________________________________________________________
257Int_t AliHFEsignalCuts::GetTrackPDG(const AliVParticle * const track) const {
258 //
259 // Return PDG code of a particle itself
260 //
261 if(!fMC){
262 AliDebug(1, "No MC Event Available\n");
263 return 0;
264 }
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;
271
272 TString mctype = mctrack->IsA()->GetName();
273 Int_t trackPdg = 0;
274 if(!mctype.CompareTo("AliMCParticle")){
275 const AliMCParticle *esdmc = dynamic_cast<const AliMCParticle *>(mctrack);
bf892a6a 276 if(esdmc) trackPdg = esdmc->Particle()->GetPdgCode();
3a72645a 277 } else {
278 const AliAODMCParticle *aodmc = dynamic_cast< const AliAODMCParticle *>(mctrack);
bf892a6a 279 if(aodmc) trackPdg = aodmc->GetPdgCode();
3a72645a 280 }
281 return trackPdg;
282}
283
284//____________________________________________________________
285Int_t AliHFEsignalCuts::GetElecSource(const AliVParticle * const track) const {
286 //
287 // Return PDG code of a particle itself
288 //
289
290 if(!fMC){
291 AliDebug(1, "No MC Event Available\n");
292 return 0;
293 }
294 if(!fMCQA){
295 AliDebug(1, "No MCQA Available\n");
296 return 0;
297 }
bf892a6a 298 if(!track){
299 AliDebug(1, "Track not Available\n");
300 return 0;
301 }
3a72645a 302
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;
310
311 TString mctype = mctrack->IsA()->GetName();
312 Int_t eSource = 0;
313 if(!mctype.CompareTo("AliMCParticle")){
314 const AliMCParticle *esdmc = dynamic_cast<const AliMCParticle *>(mctrack);
315 mcpart = esdmc->Particle();
316 eSource=fMCQA->GetElecSource(mcpart);
317 } else {
318 return -1;
319 }
320
321 return eSource;
322}