]>
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 | ||
e156c3bb | 28 | #include "AliAODTrack.h" |
3a72645a | 29 | #include "AliAODMCParticle.h" |
e156c3bb | 30 | #include "AliESDtrack.h" |
3a72645a | 31 | #include "AliLog.h" |
32 | #include "AliMCEvent.h" | |
33 | #include "AliMCParticle.h" | |
34 | #include "AliVParticle.h" | |
35 | ||
36 | #include "AliHFEsignalCuts.h" | |
37 | #include "AliHFEmcQA.h" | |
38 | ||
39 | ClassImp(AliHFEsignalCuts) | |
40 | ||
41 | //____________________________________________________________ | |
42 | AliHFEsignalCuts::AliHFEsignalCuts(): | |
43 | AliAnalysisCuts(), | |
44 | fMC(NULL), | |
45 | fMCQA(NULL) | |
46 | { | |
47 | // | |
48 | // Dummy constructor | |
49 | // | |
50 | } | |
51 | ||
52 | //____________________________________________________________ | |
53 | AliHFEsignalCuts::AliHFEsignalCuts(const Char_t *name, const Char_t *title): | |
54 | AliAnalysisCuts(name, title), | |
55 | fMC(NULL), | |
56 | fMCQA(NULL) | |
57 | { | |
58 | // | |
59 | // Default constructor | |
60 | // | |
61 | fMCQA = new AliHFEmcQA; | |
62 | if(fMCQA) fMCQA->Init(); | |
63 | } | |
64 | ||
65 | //____________________________________________________________ | |
66 | AliHFEsignalCuts::AliHFEsignalCuts(const AliHFEsignalCuts &ref): | |
67 | AliAnalysisCuts(ref), | |
68 | fMC(ref.fMC), | |
69 | fMCQA(ref.fMCQA) | |
70 | { | |
71 | // | |
72 | // Copy constructor | |
73 | // | |
74 | } | |
75 | ||
76 | //____________________________________________________________ | |
77 | AliHFEsignalCuts &AliHFEsignalCuts::operator=(const AliHFEsignalCuts &ref){ | |
78 | // | |
79 | // Assignment operator | |
80 | // | |
81 | if(this != &ref){ | |
82 | fMC = ref.fMC; | |
83 | fMCQA = ref.fMCQA; | |
84 | } | |
85 | return *this; | |
86 | } | |
87 | ||
88 | //____________________________________________________________ | |
89 | AliHFEsignalCuts::~AliHFEsignalCuts(){ | |
90 | // | |
91 | // Destructor | |
92 | // | |
93 | if(fMCQA) delete fMCQA; | |
94 | } | |
95 | ||
96 | //____________________________________________________________ | |
97 | void AliHFEsignalCuts::SetMCEvent(AliMCEvent *mc){ | |
98 | // | |
99 | // Set mc event | |
100 | // | |
101 | fMC = mc; | |
102 | if(fMCQA) fMCQA->SetMCEvent(mc); | |
103 | } | |
104 | ||
105 | //____________________________________________________________ | |
106 | Bool_t AliHFEsignalCuts::IsSelected(TObject *o){ | |
107 | // | |
108 | // Define signal as electron coming from charm or beauty | |
109 | // @TODO: Implement setter so that also either of them can be defined | |
110 | // as signal alone | |
111 | ||
112 | ||
113 | return IsCharmElectron(o) || IsBeautyElectron(o); | |
114 | /* | |
115 | //saving time? | |
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 | |
119 | return kTRUE; | |
120 | else | |
121 | return kFALSE; | |
122 | */ | |
123 | ||
124 | } | |
125 | ||
126 | //____________________________________________________________ | |
127 | Bool_t AliHFEsignalCuts::IsCharmElectron(const TObject * const o) const { | |
128 | // | |
129 | // Check if mother is coming from Charm | |
130 | // | |
bf892a6a | 131 | if(!dynamic_cast<const AliVParticle *>(o)) return kFALSE; |
3a72645a | 132 | Int_t esources = GetElecSource(dynamic_cast<const AliVParticle *>(o)); |
133 | if(esources == AliHFEmcQA::kDirectCharm) // 1: direct D->e | |
134 | return kTRUE; | |
135 | else | |
136 | return kFALSE; | |
137 | } | |
138 | ||
139 | //____________________________________________________________ | |
140 | Bool_t AliHFEsignalCuts::IsBeautyElectron(const TObject * const o) const { | |
141 | // | |
142 | // Check if mother is coming from Beauty | |
143 | // | |
bf892a6a | 144 | if(!dynamic_cast<const AliVParticle *>(o)) return kFALSE; |
3a72645a | 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 | |
147 | return kTRUE; | |
148 | else | |
149 | return kFALSE; | |
150 | } | |
151 | ||
152 | //____________________________________________________________ | |
153 | Bool_t AliHFEsignalCuts::IsGammaElectron(const TObject * const o) const { | |
154 | // | |
c2690925 | 155 | // Check for MC if the electron is coming from Gamma |
3a72645a | 156 | // |
bf892a6a | 157 | if(!dynamic_cast<const AliVParticle *>(o)) return kFALSE; |
3a72645a | 158 | Int_t esources = GetElecSource(dynamic_cast<const AliVParticle *>(o)); |
c2690925 | 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 | |
161 | return kTRUE; | |
162 | else | |
163 | return kFALSE; | |
164 | } | |
165 | ||
166 | //____________________________________________________________ | |
167 | Bool_t AliHFEsignalCuts::IsNonHFElectron(const TObject * const o) const { | |
168 | // | |
169 | // Check for MC if the electron is coming from NonHFE except for conversion | |
170 | // | |
171 | if(!dynamic_cast<const AliVParticle *>(o)) return kFALSE; | |
11ff28c5 | 172 | Int_t esources = GetElecSource(dynamic_cast<const AliVParticle *>(o)); |
c2690925 | 173 | if(esources == AliHFEmcQA:: kPi0 || esources == AliHFEmcQA::kEta || esources == AliHFEmcQA::kOmega || esources == AliHFEmcQA::kPhi || esources == AliHFEmcQA::kEtaPrime || esources == AliHFEmcQA::kRho0) // 4: conversion electrons |
3a72645a | 174 | return kTRUE; |
175 | else | |
176 | return kFALSE; | |
177 | } | |
11ff28c5 | 178 | |
c2690925 | 179 | //____________________________________________________________ |
11ff28c5 | 180 | Bool_t AliHFEsignalCuts::IsJpsiElectron(const TObject * const o) const { |
181 | // | |
182 | // Check if mother is coming from Charm | |
183 | // | |
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 | |
187 | return kTRUE; | |
188 | else | |
189 | return kFALSE; | |
190 | } | |
191 | ||
192 | //____________________________________________________________ | |
193 | Bool_t AliHFEsignalCuts::IsB2JpsiElectron(const TObject * const o) const { | |
194 | // | |
195 | // Check if mother is coming from Charm | |
196 | // | |
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 | |
200 | return kTRUE; | |
201 | else | |
202 | return kFALSE; | |
203 | } | |
204 | ||
205 | //____________________________________________________________ | |
206 | Bool_t AliHFEsignalCuts::IsKe3Electron(const TObject * const o) const { | |
207 | // | |
208 | // Check if mother is coming from Charm | |
209 | // | |
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 | |
213 | return kTRUE; | |
214 | else | |
215 | return kFALSE; | |
216 | } | |
3a72645a | 217 | |
218 | /* | |
219 | //____________________________________________________________ | |
220 | Bool_t AliHFEsignalCuts::IsCharmElectron(const TObject * const o) const { | |
221 | // | |
222 | // Check if mother is coming from Charm | |
223 | // | |
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)); | |
227 | ||
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"); | |
231 | return kFALSE; | |
232 | } | |
233 | ||
234 | //____________________________________________________________ | |
235 | Bool_t AliHFEsignalCuts::IsBeautyElectron(const TObject * const o) const { | |
236 | // | |
237 | // Check if mother is coming from Beauty | |
238 | // | |
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)); | |
242 | ||
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"); | |
246 | return kFALSE; | |
247 | } | |
248 | ||
249 | //____________________________________________________________ | |
250 | Bool_t AliHFEsignalCuts::IsGammaElectron(const TObject * const o) const { | |
251 | // | |
252 | // Check for MC if the electron is coming from Gamma | |
253 | // | |
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)); | |
257 | ||
258 | if(motherpdg!=22){ | |
259 | AliDebug(1, "No Gamma"); | |
260 | return kFALSE; | |
261 | } else { | |
262 | AliDebug(1, "Gamma"); | |
263 | return kTRUE; | |
264 | } | |
265 | } | |
266 | */ | |
267 | ||
268 | //____________________________________________________________ | |
269 | Int_t AliHFEsignalCuts::GetMotherPDG(const AliVParticle * const track) const { | |
270 | // | |
271 | // Get Mother Pdg code for reconstructed respectively MC tracks | |
272 | // | |
273 | if(!fMC){ | |
274 | AliDebug(1, "No MC Event Available\n"); | |
275 | return 0; | |
276 | } | |
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())); | |
283 | } else { | |
284 | // MCParticle | |
285 | mctrack = track; | |
286 | } | |
287 | ||
288 | if(!mctrack) return 0; | |
289 | ||
290 | Int_t motherPDG = 0; | |
291 | if(TString(mctrack->IsA()->GetName()).CompareTo("AliMCParticle") == 0){ | |
292 | // case MC Particle | |
bf892a6a | 293 | const AliMCParticle *esdmctrack = dynamic_cast<const AliMCParticle *>(mctrack); |
294 | if(esdmctrack) motherParticle = fMC->GetTrack(esdmctrack->Particle()->GetFirstMother()); | |
295 | if(motherParticle){ | |
296 | const AliMCParticle *esdmcmother = dynamic_cast<const AliMCParticle *>(motherParticle); | |
297 | if(esdmcmother) motherPDG = TMath::Abs(esdmcmother->Particle()->GetPdgCode()); | |
298 | } | |
3a72645a | 299 | } else { |
300 | // case AODMCParticle | |
bf892a6a | 301 | const AliAODMCParticle *aodmctrack = dynamic_cast<const AliAODMCParticle *>(mctrack); |
302 | if(aodmctrack) motherParticle = fMC->GetTrack(aodmctrack->GetMother()); | |
303 | if(motherParticle){ | |
304 | const AliAODMCParticle *aodmcmother = dynamic_cast<const AliAODMCParticle *>(motherParticle); | |
305 | if(aodmcmother) motherPDG = TMath::Abs(aodmcmother->GetPdgCode()); | |
306 | } | |
3a72645a | 307 | } |
308 | return motherPDG; | |
309 | } | |
310 | ||
311 | //____________________________________________________________ | |
312 | Int_t AliHFEsignalCuts::GetTrackPDG(const AliVParticle * const track) const { | |
313 | // | |
314 | // Return PDG code of a particle itself | |
315 | // | |
316 | if(!fMC){ | |
317 | AliDebug(1, "No MC Event Available\n"); | |
318 | return 0; | |
319 | } | |
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; | |
326 | ||
327 | TString mctype = mctrack->IsA()->GetName(); | |
328 | Int_t trackPdg = 0; | |
329 | if(!mctype.CompareTo("AliMCParticle")){ | |
330 | const AliMCParticle *esdmc = dynamic_cast<const AliMCParticle *>(mctrack); | |
bf892a6a | 331 | if(esdmc) trackPdg = esdmc->Particle()->GetPdgCode(); |
3a72645a | 332 | } else { |
333 | const AliAODMCParticle *aodmc = dynamic_cast< const AliAODMCParticle *>(mctrack); | |
bf892a6a | 334 | if(aodmc) trackPdg = aodmc->GetPdgCode(); |
3a72645a | 335 | } |
336 | return trackPdg; | |
337 | } | |
338 | ||
339 | //____________________________________________________________ | |
340 | Int_t AliHFEsignalCuts::GetElecSource(const AliVParticle * const track) const { | |
341 | // | |
342 | // Return PDG code of a particle itself | |
343 | // | |
344 | ||
e3ae862b | 345 | if(!fMC){ |
346 | AliDebug(1, "No MC Event Available\n"); | |
347 | return 0; | |
348 | } | |
349 | if(!fMCQA){ | |
350 | AliDebug(1, "No MCQA Available\n"); | |
351 | return 0; | |
352 | } | |
353 | if(!track){ | |
354 | AliDebug(1, "Track not Available\n"); | |
355 | return 0; | |
356 | } | |
3a72645a | 357 | |
e156c3bb | 358 | TClass *tracktype; |
e3ae862b | 359 | const AliVParticle *mctrack = NULL; |
360 | TParticle *mcpart = NULL; | |
a8ef1999 | 361 | //AliMCParticle *esdmcmother = NULL; |
e156c3bb | 362 | if((tracktype = track->IsA()) == AliESDtrack::Class() || tracktype == AliAODTrack::Class()){ |
e3ae862b | 363 | mctrack = fMC->GetTrack(TMath::Abs(track->GetLabel())); |
364 | } else mctrack = track; | |
365 | if(!mctrack) return 0; | |
3a72645a | 366 | |
e3ae862b | 367 | Int_t eSource = 0; |
e156c3bb | 368 | if(mctrack->IsA() == AliMCParticle::Class()){ |
e3ae862b | 369 | const AliMCParticle *esdmc = dynamic_cast<const AliMCParticle *>(mctrack); |
370 | if(esdmc){ | |
371 | mcpart = esdmc->Particle(); | |
372 | eSource=fMCQA->GetElecSource(mcpart); | |
a8ef1999 | 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; | |
380 | } | |
381 | } | |
382 | } | |
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; | |
387 | } | |
388 | } | |
389 | */ | |
e3ae862b | 390 | } |
391 | } else { | |
392 | return -1; | |
393 | } | |
394 | return eSource; | |
3a72645a | 395 | } |