]>
Commit | Line | Data |
---|---|---|
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 | ||
37 | ClassImp(AliHFEsignalCuts) | |
38 | ||
39 | //____________________________________________________________ | |
40 | AliHFEsignalCuts::AliHFEsignalCuts(): | |
41 | AliAnalysisCuts(), | |
42 | fMC(NULL), | |
43 | fMCQA(NULL) | |
44 | { | |
45 | // | |
46 | // Dummy constructor | |
47 | // | |
48 | } | |
49 | ||
50 | //____________________________________________________________ | |
51 | AliHFEsignalCuts::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 | //____________________________________________________________ | |
64 | AliHFEsignalCuts::AliHFEsignalCuts(const AliHFEsignalCuts &ref): | |
65 | AliAnalysisCuts(ref), | |
66 | fMC(ref.fMC), | |
67 | fMCQA(ref.fMCQA) | |
68 | { | |
69 | // | |
70 | // Copy constructor | |
71 | // | |
72 | } | |
73 | ||
74 | //____________________________________________________________ | |
75 | AliHFEsignalCuts &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 | //____________________________________________________________ | |
87 | AliHFEsignalCuts::~AliHFEsignalCuts(){ | |
88 | // | |
89 | // Destructor | |
90 | // | |
91 | if(fMCQA) delete fMCQA; | |
92 | } | |
93 | ||
94 | //____________________________________________________________ | |
95 | void AliHFEsignalCuts::SetMCEvent(AliMCEvent *mc){ | |
96 | // | |
97 | // Set mc event | |
98 | // | |
99 | fMC = mc; | |
100 | if(fMCQA) fMCQA->SetMCEvent(mc); | |
101 | } | |
102 | ||
103 | //____________________________________________________________ | |
104 | Bool_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 | //____________________________________________________________ | |
125 | Bool_t AliHFEsignalCuts::IsCharmElectron(const TObject * const o) const { | |
126 | // | |
127 | // Check if mother is coming from Charm | |
128 | // | |
129 | Int_t esources = GetElecSource(dynamic_cast<const AliVParticle *>(o)); | |
130 | if(esources == AliHFEmcQA::kDirectCharm) // 1: direct D->e | |
131 | return kTRUE; | |
132 | else | |
133 | return kFALSE; | |
134 | } | |
135 | ||
136 | //____________________________________________________________ | |
137 | Bool_t AliHFEsignalCuts::IsBeautyElectron(const TObject * const o) const { | |
138 | // | |
139 | // Check if mother is coming from Beauty | |
140 | // | |
141 | Int_t esources = GetElecSource(dynamic_cast<const AliVParticle *>(o)); | |
142 | if(esources == AliHFEmcQA::kDirectBeauty || esources == AliHFEmcQA::kBeautyCharm) // 2: B->e 3: B->D->e | |
143 | return kTRUE; | |
144 | else | |
145 | return kFALSE; | |
146 | } | |
147 | ||
148 | //____________________________________________________________ | |
149 | Bool_t AliHFEsignalCuts::IsGammaElectron(const TObject * const o) const { | |
150 | // | |
151 | // Check for MC if the electron is coming from Gamma | |
152 | // | |
153 | Int_t esources = GetElecSource(dynamic_cast<const AliVParticle *>(o)); | |
154 | if(esources == AliHFEmcQA::kGamma) // 4: conversion electrons | |
155 | return kTRUE; | |
156 | else | |
157 | return kFALSE; | |
158 | } | |
159 | ||
160 | /* | |
161 | //____________________________________________________________ | |
162 | Bool_t AliHFEsignalCuts::IsCharmElectron(const TObject * const o) const { | |
163 | // | |
164 | // Check if mother is coming from Charm | |
165 | // | |
166 | if(TMath::Abs(GetTrackPDG(dynamic_cast<const AliVParticle *>(o))) != 11) return kFALSE; | |
167 | Int_t motherpdg = TMath::Abs(GetMotherPDG(dynamic_cast<const AliVParticle *>(o))); | |
168 | AliDebug(1, Form("Mother PDG %d\n", motherpdg)); | |
169 | ||
170 | if((motherpdg % 1000) / 100 == 4) return kTRUE; // charmed meson, 3rd position in pdg code == 4 | |
171 | if(motherpdg / 1000 == 4) return kTRUE; // charmed baryon, 4th position in pdg code == 4 | |
172 | AliDebug(1, "No Charm\n"); | |
173 | return kFALSE; | |
174 | } | |
175 | ||
176 | //____________________________________________________________ | |
177 | Bool_t AliHFEsignalCuts::IsBeautyElectron(const TObject * const o) const { | |
178 | // | |
179 | // Check if mother is coming from Beauty | |
180 | // | |
181 | if(TMath::Abs(GetTrackPDG(dynamic_cast<const AliVParticle *>(o))) != 11) return kFALSE; | |
182 | Int_t motherpdg = TMath::Abs(GetMotherPDG(dynamic_cast<const AliVParticle *>(o))); | |
183 | AliDebug(1, Form("Mother PDG %d\n", motherpdg)); | |
184 | ||
185 | if((motherpdg % 1000) / 100 == 5) return kTRUE; // beauty meson, 3rd position in pdg code == 5 | |
186 | if(motherpdg / 1000 == 5) return kTRUE; // beauty baryon, 4th position in pdg code == 5 | |
187 | AliDebug(1, "No Beauty\n"); | |
188 | return kFALSE; | |
189 | } | |
190 | ||
191 | //____________________________________________________________ | |
192 | Bool_t AliHFEsignalCuts::IsGammaElectron(const TObject * const o) const { | |
193 | // | |
194 | // Check for MC if the electron is coming from Gamma | |
195 | // | |
196 | if(TMath::Abs(GetTrackPDG(dynamic_cast<const AliVParticle *>(o))) != 11) return kFALSE; | |
197 | Int_t motherpdg = TMath::Abs(GetMotherPDG(dynamic_cast<const AliVParticle *>(o))); | |
198 | AliDebug(1, Form("Mother PDG %d\n", motherpdg)); | |
199 | ||
200 | if(motherpdg!=22){ | |
201 | AliDebug(1, "No Gamma"); | |
202 | return kFALSE; | |
203 | } else { | |
204 | AliDebug(1, "Gamma"); | |
205 | return kTRUE; | |
206 | } | |
207 | } | |
208 | */ | |
209 | ||
210 | //____________________________________________________________ | |
211 | Int_t AliHFEsignalCuts::GetMotherPDG(const AliVParticle * const track) const { | |
212 | // | |
213 | // Get Mother Pdg code for reconstructed respectively MC tracks | |
214 | // | |
215 | if(!fMC){ | |
216 | AliDebug(1, "No MC Event Available\n"); | |
217 | return 0; | |
218 | } | |
219 | const AliVParticle *motherParticle = NULL, *mctrack = NULL; | |
220 | TString objectType = track->IsA()->GetName(); | |
221 | if(objectType.CompareTo("AliESDtrack") == 0 || objectType.CompareTo("AliAODTrack") == 0){ | |
222 | // Reconstructed track | |
223 | if(track->GetLabel()) | |
224 | mctrack = fMC->GetTrack(TMath::Abs(track->GetLabel())); | |
225 | } else { | |
226 | // MCParticle | |
227 | mctrack = track; | |
228 | } | |
229 | ||
230 | if(!mctrack) return 0; | |
231 | ||
232 | Int_t motherPDG = 0; | |
233 | if(TString(mctrack->IsA()->GetName()).CompareTo("AliMCParticle") == 0){ | |
234 | // case MC Particle | |
235 | motherParticle = fMC->GetTrack((dynamic_cast<const AliMCParticle *>(mctrack)->Particle()->GetFirstMother())); | |
236 | if(motherParticle) | |
237 | motherPDG = TMath::Abs((dynamic_cast<const AliMCParticle *>(motherParticle))->Particle()->GetPdgCode()); | |
238 | } else { | |
239 | // case AODMCParticle | |
240 | motherParticle = fMC->GetTrack((dynamic_cast<const AliAODMCParticle *>(mctrack))->GetMother()); | |
241 | if(motherParticle) | |
242 | motherPDG = TMath::Abs((dynamic_cast<const AliAODMCParticle *>(motherParticle))->GetPdgCode()); | |
243 | } | |
244 | return motherPDG; | |
245 | } | |
246 | ||
247 | //____________________________________________________________ | |
248 | Int_t AliHFEsignalCuts::GetTrackPDG(const AliVParticle * const track) const { | |
249 | // | |
250 | // Return PDG code of a particle itself | |
251 | // | |
252 | if(!fMC){ | |
253 | AliDebug(1, "No MC Event Available\n"); | |
254 | return 0; | |
255 | } | |
256 | TString sourcetype = track->IsA()->GetName(); | |
257 | const AliVParticle *mctrack = NULL; | |
258 | if(!sourcetype.CompareTo("AliESDtrack") || !sourcetype.CompareTo("AliAODTrack")){ | |
259 | mctrack = fMC->GetTrack(TMath::Abs(track->GetLabel())); | |
260 | } else mctrack = track; | |
261 | if(!mctrack) return 0; | |
262 | ||
263 | TString mctype = mctrack->IsA()->GetName(); | |
264 | Int_t trackPdg = 0; | |
265 | if(!mctype.CompareTo("AliMCParticle")){ | |
266 | const AliMCParticle *esdmc = dynamic_cast<const AliMCParticle *>(mctrack); | |
267 | trackPdg = esdmc->Particle()->GetPdgCode(); | |
268 | } else { | |
269 | const AliAODMCParticle *aodmc = dynamic_cast< const AliAODMCParticle *>(mctrack); | |
270 | trackPdg = aodmc->GetPdgCode(); | |
271 | } | |
272 | return trackPdg; | |
273 | } | |
274 | ||
275 | //____________________________________________________________ | |
276 | Int_t AliHFEsignalCuts::GetElecSource(const AliVParticle * const track) const { | |
277 | // | |
278 | // Return PDG code of a particle itself | |
279 | // | |
280 | ||
281 | if(!fMC){ | |
282 | AliDebug(1, "No MC Event Available\n"); | |
283 | return 0; | |
284 | } | |
285 | if(!fMCQA){ | |
286 | AliDebug(1, "No MCQA Available\n"); | |
287 | return 0; | |
288 | } | |
289 | ||
290 | TString sourcetype = track->IsA()->GetName(); | |
291 | const AliVParticle *mctrack = NULL; | |
292 | TParticle *mcpart = NULL; | |
293 | if(!sourcetype.CompareTo("AliESDtrack") || !sourcetype.CompareTo("AliAODTrack")){ | |
294 | mctrack = fMC->GetTrack(TMath::Abs(track->GetLabel())); | |
295 | } else mctrack = track; | |
296 | if(!mctrack) return 0; | |
297 | ||
298 | TString mctype = mctrack->IsA()->GetName(); | |
299 | Int_t eSource = 0; | |
300 | if(!mctype.CompareTo("AliMCParticle")){ | |
301 | const AliMCParticle *esdmc = dynamic_cast<const AliMCParticle *>(mctrack); | |
302 | mcpart = esdmc->Particle(); | |
303 | eSource=fMCQA->GetElecSource(mcpart); | |
304 | } else { | |
305 | return -1; | |
306 | } | |
307 | ||
308 | return eSource; | |
309 | } |