1 /*************************************************************************
2 * Copyright(c) 1998-2009, 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 **************************************************************************/
16 //#####################################################
18 //# Class AliDielectronMC #
19 //# Cut Class for Jpsi->e+e- analysis #
21 //# by WooJin J. Park, GSI / W.J.Park@gsi.de #
23 //#####################################################
25 #include <AliAnalysisManager.h>
26 #include <AliAODHandler.h>
27 #include <AliESDInputHandler.h>
28 #include <AliAODInputHandler.h>
29 #include <AliMCEventHandler.h>
30 #include <AliMCEvent.h>
31 #include <AliMCParticle.h>
32 #include <AliAODMCParticle.h>
33 #include <AliAODMCHeader.h>
35 #include <AliESDEvent.h>
36 #include <AliAODEvent.h>
37 #include <AliESDtrack.h>
38 #include <AliAODTrack.h>
41 #include <TClonesArray.h>
42 #include <TParticle.h>
44 #include "AliDielectronSignalMC.h"
45 #include "AliDielectronMC.h"
47 AliDielectronMC* AliDielectronMC::fgInstance=0x0;
49 //____________________________________________________________
50 AliDielectronMC* AliDielectronMC::Instance()
53 // return pointer to singleton implementation
55 if (fgInstance) return fgInstance;
57 AnalysisType type=kUNSET;
59 if (AliAnalysisManager::GetAnalysisManager()){
60 if (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()->IsA()==AliESDInputHandler::Class()) type=kESD;
61 else if (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()->IsA()==AliAODInputHandler::Class()) type=kAOD;
63 AliMCEventHandler* mcHandler = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
64 if(type == kESD) hasMC=mcHandler!=0x0;
67 fgInstance=new AliDielectronMC(type);
69 fgInstance->SetHasMC(hasMC);
74 //____________________________________________________________
75 AliDielectronMC::AliDielectronMC(AnalysisType type):
83 // default constructor
88 //____________________________________________________________
89 AliDielectronMC::~AliDielectronMC()
97 //____________________________________________________________
98 void AliDielectronMC::Initialize()
101 // initialize MC class
103 if (!ConnectMCEvent()) AliError("Initialization of MC object failed!");
106 //____________________________________________________________
107 Int_t AliDielectronMC::GetNMCTracks()
110 // return the number of generated tracks from MC event
112 if(fAnaType == kESD){
113 if (!fMCEvent){ AliError("No fMCEvent"); return 0; }
114 return fMCEvent->GetNumberOfTracks();}
115 else if(fAnaType == kAOD){
116 if(!fMcArray) { AliError("No fMcArray"); return 0; }
117 return fMcArray->GetEntriesFast();
122 //____________________________________________________________
123 Int_t AliDielectronMC::GetNMCTracksFromStack()
126 // return the number of generated tracks from stack
128 if (!fStack){ AliError("No fStack"); return -999; }
129 return fStack->GetNtrack();
132 //____________________________________________________________
133 Int_t AliDielectronMC::GetNPrimary() const
136 // return the number of primary track from MC event
138 if (!fMCEvent){ AliError("No fMCEvent"); return 0; }
139 return fMCEvent->GetNumberOfPrimaries();
142 //____________________________________________________________
143 Int_t AliDielectronMC::GetNPrimaryFromStack()
146 // return the number of primary track from stack
148 if (!fStack){ AliError("No fStack"); return -999; }
149 return fStack->GetNprimary();
152 //____________________________________________________________
153 AliVParticle* AliDielectronMC::GetMCTrackFromMCEvent(Int_t itrk) const
156 // return MC track directly from MC event
158 if (itrk<0) return NULL;
159 AliVParticle * track=0x0;
160 if(fAnaType == kESD){
161 if (!fMCEvent){ AliError("No fMCEvent"); return NULL;}
162 track = fMCEvent->GetTrack(itrk); // tracks from MC event (ESD)
163 } else if(fAnaType == kAOD) {
164 if (!fMcArray){ AliError("No fMcArray"); return NULL;}
165 if (itrk>fMcArray->GetEntriesFast()) { AliWarning(Form("track %d out of array size %d",itrk,fMcArray->GetEntriesFast())); return NULL;}
166 track = (AliVParticle*)fMcArray->At(itrk); // tracks from MC event (AOD)
171 //____________________________________________________________
172 Bool_t AliDielectronMC::ConnectMCEvent()
175 // connect stack object from the mc handler
181 if(fAnaType == kESD){
182 AliMCEventHandler* mcHandler = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
183 if (!mcHandler){ /*AliError("Could not retrive MC event handler!");*/ return kFALSE; }
184 if (!mcHandler->InitOk() ) return kFALSE;
185 if (!mcHandler->TreeK() ) return kFALSE;
186 if (!mcHandler->TreeTR() ) return kFALSE;
188 AliMCEvent* mcEvent = mcHandler->MCEvent();
189 if (!mcEvent){ /*AliError("Could not retrieve MC event!");*/ return kFALSE; }
192 if (!UpdateStack()) return kFALSE;
194 else if(fAnaType == kAOD)
196 AliAODInputHandler* aodHandler=(AliAODInputHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
197 if (!aodHandler) return kFALSE;
198 AliAODEvent *aod=aodHandler->GetEvent();
199 if (!aod) return kFALSE;
201 fMcArray = dynamic_cast<TClonesArray*>(aod->FindListObject(AliAODMCParticle::StdBranchName()));
202 if (!fMcArray){ /*AliError("Could not retrieve MC array!");*/ return kFALSE; }
208 //____________________________________________________________
209 Bool_t AliDielectronMC::UpdateStack()
212 // update stack with new event
214 if (!fMCEvent){ AliError("No fMCEvent"); return kFALSE;}
215 AliStack* stack = fMCEvent->Stack();
216 if (!stack){ AliError("Could not retrive stack!"); return kFALSE; }
221 //____________________________________________________________
222 AliMCParticle* AliDielectronMC::GetMCTrack( const AliESDtrack* _track)
227 if (!fMCEvent){ AliError("No fMCEvent"); return NULL;}
229 Int_t nStack = fMCEvent->GetNumberOfTracks();
230 Int_t label = TMath::Abs(_track->GetLabel());
231 if(label>nStack)return NULL;
232 if(label<0) return NULL;
233 AliMCParticle *mctrack = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(label));
238 //____________________________________________________________
239 AliAODMCParticle* AliDielectronMC::GetMCTrack( const AliAODTrack* _track)
244 if(!fMcArray) { AliError("No fMcArray"); return NULL;}
245 Int_t label = _track->GetLabel();
246 if(label < 0 || label > fMcArray->GetEntriesFast()) return NULL;
247 AliAODMCParticle *mctrack = (AliAODMCParticle*)fMcArray->At(label);
251 //____________________________________________________________
252 TParticle* AliDielectronMC::GetMCTrackFromStack(const AliESDtrack* _track)
255 // return MC track from stack
257 Int_t label = TMath::Abs(_track->GetLabel());
258 if (!fStack) AliWarning("fStack is not available. Update stack first.");
259 TParticle* mcpart = fStack->Particle(label);
260 if (!mcpart) return NULL;
264 //____________________________________________________________
265 AliMCParticle* AliDielectronMC::GetMCTrackMother(const AliESDtrack* _track)
268 // return MC track mother
270 AliMCParticle* mcpart = GetMCTrack(_track);
271 if (!mcpart) return NULL;
272 if(mcpart->GetMother()<0) return NULL;
273 AliMCParticle* mcmother = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(mcpart->GetMother()));
274 if (!mcmother) return NULL;
278 //______________________________________________________________
279 AliAODMCParticle* AliDielectronMC::GetMCTrackMother(const AliAODTrack* _track)
282 // return MC track mother
284 AliAODMCParticle* mcpart = GetMCTrack(_track);
285 if (!mcpart) return NULL;
286 if(mcpart->GetMother() < 0) return NULL;
287 AliAODMCParticle* mcmother = dynamic_cast<AliAODMCParticle *>(fMcArray->At(mcpart->GetMother()));
288 if (!mcmother) return NULL;
291 //____________________________________________________________
292 AliMCParticle* AliDielectronMC::GetMCTrackMother(const AliMCParticle* _particle){
294 // return MC track mother
296 if(_particle->GetMother() < 0) return NULL;
297 AliMCParticle* mcmother = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(_particle->GetMother()));
301 //____________________________________________________________
302 AliAODMCParticle* AliDielectronMC::GetMCTrackMother(const AliAODMCParticle* _particle){
304 // return MC track mother
306 if( _particle->GetMother() < 0) return NULL;
307 AliAODMCParticle* mcmother = dynamic_cast<AliAODMCParticle *>(fMcArray->At(_particle->GetMother()));
311 //____________________________________________________________
312 TParticle* AliDielectronMC::GetMCTrackMotherFromStack(const AliESDtrack* _track)
315 // return MC track mother from stack
317 TParticle* mcpart = GetMCTrackFromStack(_track);
318 if ( !mcpart || mcpart->GetFirstMother()<=0 ) return NULL;
319 TParticle* mcmother = fStack->Particle(mcpart->GetFirstMother());
320 if (!mcmother) return NULL;
324 //____________________________________________________________
325 Int_t AliDielectronMC::GetMCPID(const AliESDtrack* _track)
328 // return PDG code of the track from the MC truth info
330 AliMCParticle* mcpart = GetMCTrack(_track);
331 if (!mcpart) return -999;
332 return mcpart->PdgCode();
335 //__________________________________________________________
336 Int_t AliDielectronMC::GetMCPID(const AliAODTrack* _track)
339 // return PDG code of the track from the MC truth info
341 AliAODMCParticle* mcpart = GetMCTrack(_track);
342 if (!mcpart) return -999;
343 return mcpart->PdgCode();
346 //____________________________________________________________
347 Int_t AliDielectronMC::GetMCPIDFromStack(const AliESDtrack* _track)
350 // return MC PDG code from stack
352 TParticle* mcpart = GetMCTrackFromStack(_track);
353 if (!mcpart) return -999;
354 return mcpart->GetPdgCode();
357 //____________________________________________________________
358 Int_t AliDielectronMC::GetMotherPDG( const AliESDtrack* _track)
361 // return PDG code of the mother track from the MC truth info
363 AliMCParticle* mcmother = GetMCTrackMother(_track);
364 if (!mcmother) return -999;
365 return mcmother->PdgCode();
368 //________________________________________________________
369 Int_t AliDielectronMC::GetMotherPDG( const AliAODTrack* _track)
372 // return PDG code of the mother track from the MC truth info
374 AliAODMCParticle* mcmother = GetMCTrackMother(_track);
375 if (!mcmother) return -999;
376 return mcmother->PdgCode();
379 //____________________________________________________________
380 Int_t AliDielectronMC::GetMotherPDGFromStack(const AliESDtrack* _track)
383 // return PDG code of the mother track from stack
385 TParticle* mcmother = GetMCTrackMotherFromStack(_track);
386 if (!mcmother) return -999;
387 return mcmother->GetPdgCode();
390 //____________________________________________________________
391 Int_t AliDielectronMC::GetMCProcess(const AliESDtrack* _track)
394 // return process number of the track
396 AliMCParticle* mcpart = GetMCTrack(_track);
397 if (!mcpart) return -999;
401 //____________________________________________________________
402 Int_t AliDielectronMC::GetMCProcessFromStack(const AliESDtrack* _track)
405 // return process number of the track
407 TParticle* mcpart = GetMCTrackFromStack(_track);
408 if (!mcpart) return -999;
409 return mcpart->GetUniqueID();
412 //____________________________________________________________
413 Int_t AliDielectronMC::NumberOfDaughters(const AliESDtrack* track)
416 // returns the number of daughters
418 AliMCParticle *mcmother=GetMCTrackMother(track);
419 if(!mcmother||!mcmother->Particle()) return -999;
420 // return mcmother->GetFirstDaughter()>0?mcmother->GetLastDaughter()-mcmother->GetFirstDaughter()+1:0;
421 return mcmother->Particle()->GetNDaughters();
424 //_________________________________________________________
425 Int_t AliDielectronMC::NumberOfDaughters(const AliAODTrack* track)
428 // returns the number of daughters
430 AliAODMCParticle *mcmother=GetMCTrackMother(track);
431 if(!mcmother) return -999;
432 return NumberOfDaughters(mcmother);
436 //____________________________________________________________
437 Int_t AliDielectronMC::NumberOfDaughters(const AliMCParticle* particle)
440 // returns the number of daughters
442 AliMCParticle *mcmother=GetMCTrackMother(particle);
443 if(!mcmother||!mcmother->Particle()) return -999;
444 //return mcmother->GetFirstDaughter()>0?mcmother->GetLastDaughter()-mcmother->GetFirstDaughter()+1:0;
445 return mcmother->Particle()->GetNDaughters();
448 //____________________________________________________________
449 Int_t AliDielectronMC::NumberOfDaughters(const AliAODMCParticle* particle)
452 // returns the number of daughters
454 AliAODMCParticle *mcmother=GetMCTrackMother(particle);
455 if(!mcmother) return -999;
456 return mcmother->GetNDaughters();
459 //____________________________________________________________
460 Int_t AliDielectronMC::GetMCProcessMother(const AliESDtrack* _track)
463 // return process number of the mother of the track
465 AliMCParticle* mcmother = GetMCTrackMother(_track);
466 if (!mcmother) return -999;
470 //____________________________________________________________
471 Int_t AliDielectronMC::GetMCProcessMotherFromStack(const AliESDtrack* _track)
474 // return process number of the mother of the track
476 TParticle* mcmother = GetMCTrackMotherFromStack(_track);
477 if (!mcmother) return -999;
478 return mcmother->GetUniqueID();
481 //____________________________________________________________
482 Bool_t AliDielectronMC::IsMCMotherToEE(const AliVParticle *particle, Int_t pdgMother)
485 // Check if the Mother 'particle' is of type pdgMother and decays to e+e-
487 if (fAnaType==kESD && !fMCEvent) return kFALSE;
488 if (fAnaType==kAOD && !fMcArray) return kFALSE;
489 if (!particle) return kFALSE;
491 if (particle->IsA()==AliMCParticle::Class()){
492 return IsMCMotherToEEesd(static_cast<const AliMCParticle*>(particle),pdgMother);
493 } else if (particle->IsA()==AliAODMCParticle::Class()){
494 return IsMCMotherToEEaod(static_cast<const AliAODMCParticle*>(particle),pdgMother);
496 AliError("Unknown particle type");
501 //____________________________________________________________
502 Bool_t AliDielectronMC::IsMCMotherToEEesd(const AliMCParticle *particle, Int_t pdgMother)
505 // Check if the Mother 'particle' is of type pdgMother and decays to e+e-
510 if (particle->PdgCode()!=pdgMother) return kFALSE;
511 Int_t ifirst = particle->GetFirstDaughter();
512 Int_t ilast = particle->GetLastDaughter();
514 //check number of daughters
515 if ((ilast-ifirst)!=1) return kFALSE;
516 AliMCParticle *firstD=static_cast<AliMCParticle*>(GetMCTrackFromMCEvent(ifirst));
517 AliMCParticle *secondD=static_cast<AliMCParticle*>(GetMCTrackFromMCEvent(ilast));
519 //TODO: check how you can get rid of the hardcoded numbers. One should make use of the PdgCodes set in AliDielectron!!!
520 if (firstD->Charge()>0){
521 if (firstD->PdgCode()!=-11) return kFALSE;
522 if (secondD->PdgCode()!=11) return kFALSE;
524 if (firstD->PdgCode()!=11) return kFALSE;
525 if (secondD->PdgCode()!=-11) return kFALSE;
531 //____________________________________________________________
532 Bool_t AliDielectronMC::IsMCMotherToEEaod(const AliAODMCParticle *particle, Int_t pdgMother)
535 // Check if the Mother 'particle' is of type pdgMother and decays to e+e-
539 if (particle->GetPdgCode()!=pdgMother) return kFALSE;
540 if (particle->GetNDaughters()!=2) return kFALSE;
542 Int_t ifirst = particle->GetDaughter(0);
543 Int_t ilast = particle->GetDaughter(1);
545 //check number of daughters
546 if ((ilast-ifirst)!=1) return kFALSE;
548 AliAODMCParticle *firstD=static_cast<AliAODMCParticle*>(GetMCTrackFromMCEvent(ifirst));
549 AliAODMCParticle *secondD=static_cast<AliAODMCParticle*>(GetMCTrackFromMCEvent(ilast));
551 //TODO: check how you can get rid of the hardcoded numbers. One should make use of the PdgCodes set in AliDielectron!!!
553 if (firstD->Charge()>0){
554 if (firstD->GetPdgCode()!=-11) return kFALSE;
555 if (secondD->GetPdgCode()!=11) return kFALSE;
557 if (firstD->GetPdgCode()!=11) return kFALSE;
558 if (secondD->GetPdgCode()!=-11) return kFALSE;
563 //____________________________________________________________
564 Int_t AliDielectronMC::GetLabelMotherWithPdg(const AliVParticle *particle1, const AliVParticle *particle2, Int_t pdgMother)
567 // test if mother of particle 1 and 2 has pdgCode pdgMother and is the same;
570 if (!fMCEvent) return -1;
571 return GetLabelMotherWithPdgESD(particle1, particle2, pdgMother);
573 else if (fAnaType==kAOD)
575 if (!fMcArray) return -1;
576 return GetLabelMotherWithPdgAOD(particle1, particle2, pdgMother);
582 //____________________________________________________________
583 Int_t AliDielectronMC::GetLabelMotherWithPdgESD(const AliVParticle *particle1, const AliVParticle *particle2, Int_t pdgMother)
586 // test if mother of particle 1 and 2 has pdgCode +-11 (electron),
587 // have the same mother and the mother had pdg code pdgMother
589 //TODO: check how you can get rid of the hardcoded numbers. One should make use of the PdgCodes set in AliDielectron!!!
592 AliMCParticle *mcPart1=static_cast<AliMCParticle*>(GetMCTrackFromMCEvent(particle1->GetLabel()));
593 AliMCParticle *mcPart2=static_cast<AliMCParticle*>(GetMCTrackFromMCEvent(particle2->GetLabel()));
595 if (!mcPart1||!mcPart2) return -1;
597 Int_t lblMother1=mcPart1->GetMother();
598 Int_t lblMother2=mcPart2->GetMother();
600 AliMCParticle *mcMother1=static_cast<AliMCParticle*>(GetMCTrackFromMCEvent(lblMother1));
601 if (!mcMother1) return -1;
602 if (lblMother1!=lblMother2) return -1;
603 if (TMath::Abs(mcPart1->PdgCode())!=11) return -1;
604 if (mcPart1->PdgCode()!=-mcPart2->PdgCode()) return -1;
605 if (mcMother1->PdgCode()!=pdgMother) return -1;
610 //____________________________________________________________
611 Int_t AliDielectronMC::GetLabelMotherWithPdgAOD(const AliVParticle *particle1, const AliVParticle *particle2, Int_t pdgMother)
614 // test if mother of particle 1 and 2 has pdgCode +-11 (electron),
615 // have the same mother and the mother had pdg code pdgMother
617 //TODO: check how you can get rid of the hardcoded numbers. One should make use of the PdgCodes set in AliDielectron!!!
619 AliAODMCParticle *mcPart1=static_cast<AliAODMCParticle*>(GetMCTrackFromMCEvent(particle1->GetLabel()));
620 AliAODMCParticle *mcPart2=static_cast<AliAODMCParticle*>(GetMCTrackFromMCEvent(particle2->GetLabel()));
622 if (!mcPart1||!mcPart2) return -1;
624 Int_t lblMother1=mcPart1->GetMother();
625 Int_t lblMother2=mcPart2->GetMother();
627 AliAODMCParticle *mcMother1=static_cast<AliAODMCParticle*>(GetMCTrackFromMCEvent(lblMother1));
629 if (!mcMother1) return -1;
630 if (lblMother1!=lblMother2) return -1;
631 if (TMath::Abs(mcPart1->GetPdgCode())!=11) return -1;
632 if (mcPart1->GetPdgCode()!=-mcPart2->GetPdgCode()) return -1;
633 if (mcMother1->GetPdgCode()!=pdgMother) return -1;
638 //____________________________________________________________
639 void AliDielectronMC::GetDaughters(const TObject *mother, AliVParticle* &d1, AliVParticle* &d2)
642 // Get First two daughters of the mother
649 if(!fMcArray) return;
650 const AliAODMCParticle *aodMother=static_cast<const AliAODMCParticle*>(mother);
651 lblD1=aodMother->GetDaughter(0);
652 lblD2=aodMother->GetDaughter(1);
653 d1 = (AliVParticle*)fMcArray->At(lblD1);
654 d2 = (AliVParticle*)fMcArray->At(lblD2);
655 } else if (fAnaType==kESD){
656 if (!fMCEvent) return;
657 const AliMCParticle *aodMother=static_cast<const AliMCParticle*>(mother);
658 lblD1=aodMother->GetFirstDaughter();
659 lblD2=aodMother->GetLastDaughter();
660 d1=fMCEvent->GetTrack(lblD1);
661 d2=fMCEvent->GetTrack(lblD2);
666 //________________________________________________________________________________
667 Int_t AliDielectronMC::GetMothersLabel(Int_t daughterLabel) const {
669 // Get the label of the mother for particle with label daughterLabel
671 if(daughterLabel<0) return -1;
672 if (fAnaType==kAOD) {
673 if(!fMcArray) return -1;
674 if(GetMCTrackFromMCEvent(daughterLabel))
675 return (static_cast<AliAODMCParticle*>(GetMCTrackFromMCEvent(daughterLabel)))->GetMother();
676 } else if(fAnaType==kESD) {
677 if (!fMCEvent) return -1;
678 if(GetMCTrackFromMCEvent(daughterLabel))
679 return (static_cast<AliMCParticle*>(GetMCTrackFromMCEvent(daughterLabel)))->GetMother();
685 //________________________________________________________________________________
686 Int_t AliDielectronMC::GetPdgFromLabel(Int_t label) const {
688 // Get particle code using the label from stack
690 if(label<0) return 0;
692 if(!fMcArray) return 0;
693 return (static_cast<AliAODMCParticle*>(GetMCTrackFromMCEvent(label)))->PdgCode();
694 } else if(fAnaType==kESD) {
695 if (!fMCEvent) return 0;
696 return (static_cast<AliMCParticle*>(GetMCTrackFromMCEvent(label)))->PdgCode();
702 //________________________________________________________________________________
703 Bool_t AliDielectronMC::ComparePDG(Int_t particlePDG, Int_t requiredPDG, Bool_t pdgExclusion, Bool_t checkBothCharges) const {
705 // Test the PDG codes of particles with the required ones
707 Bool_t result = kTRUE;
708 Int_t absRequiredPDG = TMath::Abs(requiredPDG);
710 switch(absRequiredPDG) {
712 result = kTRUE; // PDG not required (any code will do fine)
714 case 100: // light flavoured mesons
716 result = TMath::Abs(particlePDG)>=100 && TMath::Abs(particlePDG)<=199;
718 if(requiredPDG>0) result = particlePDG>=100 && particlePDG<=199;
719 if(requiredPDG<0) result = particlePDG>=-199 && particlePDG<=-100;
722 case 1000: // light flavoured baryons
724 result = TMath::Abs(particlePDG)>=1000 && TMath::Abs(particlePDG)<=1999;
726 if(requiredPDG>0) result = particlePDG>=1000 && particlePDG<=1999;
727 if(requiredPDG<0) result = particlePDG>=-1999 && particlePDG<=-1000;
730 case 200: // light flavoured mesons
732 result = TMath::Abs(particlePDG)>=200 && TMath::Abs(particlePDG)<=299;
734 if(requiredPDG>0)result = particlePDG>=200 && particlePDG<=299;
735 if(requiredPDG<0)result = particlePDG>=-299 && particlePDG<=-200;
738 case 2000: // light flavoured baryons
740 result = TMath::Abs(particlePDG)>=2000 && TMath::Abs(particlePDG)<=2999;
742 if(requiredPDG>0) result = particlePDG>=2000 && particlePDG<=2999;
743 if(requiredPDG<0) result = particlePDG>=-2999 && particlePDG<=-2000;
746 case 300: // all strange mesons
748 result = TMath::Abs(particlePDG)>=300 && TMath::Abs(particlePDG)<=399;
750 if(requiredPDG>0) result = particlePDG>=300 && particlePDG<=399;
751 if(requiredPDG<0) result = particlePDG>=-399 && particlePDG<=-300;
754 case 3000: // all strange baryons
756 result = TMath::Abs(particlePDG)>=3000 && TMath::Abs(particlePDG)<=3999;
758 if(requiredPDG>0) result = particlePDG>=3000 && particlePDG<=3999;
759 if(requiredPDG<0) result = particlePDG>=-3999 && particlePDG<=-3000;
762 case 400: // all charmed mesons
764 result = TMath::Abs(particlePDG)>=400 && TMath::Abs(particlePDG)<=499;
766 if(requiredPDG>0) result = particlePDG>=400 && particlePDG<=499;
767 if(requiredPDG<0) result = particlePDG>=-499 && particlePDG<=-400;
770 case 401: // open charm mesons
772 result = TMath::Abs(particlePDG)>=400 && TMath::Abs(particlePDG)<=439;
774 if(requiredPDG>0) result = particlePDG>=400 && particlePDG<=439;
775 if(requiredPDG<0) result = particlePDG>=-439 && particlePDG<=-400;
778 case 402: // open charm mesons and baryons together
780 result = (TMath::Abs(particlePDG)>=400 && TMath::Abs(particlePDG)<=439) ||
781 (TMath::Abs(particlePDG)>=4000 && TMath::Abs(particlePDG)<=4399);
783 if(requiredPDG>0) result = (particlePDG>=400 && particlePDG<=439) ||
784 (particlePDG>=4000 && particlePDG<=4399);
785 if(requiredPDG<0) result = (particlePDG>=-439 && particlePDG<=-400) ||
786 (particlePDG>=-4399 && particlePDG<=-4000);
789 case 403: // all charm hadrons
791 result = (TMath::Abs(particlePDG)>=400 && TMath::Abs(particlePDG)<=499) ||
792 (TMath::Abs(particlePDG)>=4000 && TMath::Abs(particlePDG)<=4999);
794 if(requiredPDG>0) result = (particlePDG>=400 && particlePDG<=499) ||
795 (particlePDG>=4000 && particlePDG<=4999);
796 if(requiredPDG<0) result = (particlePDG>=-499 && particlePDG<=-400) ||
797 (particlePDG>=-4999 && particlePDG<=-4000);
800 case 4000: // all charmed baryons
802 result = TMath::Abs(particlePDG)>=4000 && TMath::Abs(particlePDG)<=4999;
804 if(requiredPDG>0) result = particlePDG>=4000 && particlePDG<=4999;
805 if(requiredPDG<0) result = particlePDG>=-4999 && particlePDG<=-4000;
808 case 4001: // open charm baryons
810 result = TMath::Abs(particlePDG)>=4000 && TMath::Abs(particlePDG)<=4399;
812 if(requiredPDG>0) result = particlePDG>=4000 && particlePDG<=4399;
813 if(requiredPDG<0) result = particlePDG>=-4399 && particlePDG<=-4000;
816 case 500: // all beauty mesons
818 result = TMath::Abs(particlePDG)>=500 && TMath::Abs(particlePDG)<=599;
820 if(requiredPDG>0) result = particlePDG>=500 && particlePDG<=599;
821 if(requiredPDG<0) result = particlePDG>=-599 && particlePDG<=-500;
824 case 501: // open beauty mesons
826 result = TMath::Abs(particlePDG)>=500 && TMath::Abs(particlePDG)<=549;
828 if(requiredPDG>0) result = particlePDG>=500 && particlePDG<=549;
829 if(requiredPDG<0) result = particlePDG>=-549 && particlePDG<=-500;
832 case 502: // open beauty mesons and baryons
834 result = (TMath::Abs(particlePDG)>=500 && TMath::Abs(particlePDG)<=549) ||
835 (TMath::Abs(particlePDG)>=5000 && TMath::Abs(particlePDG)<=5499);
837 if(requiredPDG>0) result = (particlePDG>=500 && particlePDG<=549) ||
838 (particlePDG>=5000 && particlePDG<=5499);
839 if(requiredPDG<0) result = (particlePDG>=-549 && particlePDG<=-500) ||
840 (particlePDG>=-5499 && particlePDG<=-5000);
843 case 503: // all beauty hadrons
845 result = (TMath::Abs(particlePDG)>=500 && TMath::Abs(particlePDG)<=599) ||
846 (TMath::Abs(particlePDG)>=5000 && TMath::Abs(particlePDG)<=5999);
848 if(requiredPDG>0) result = (particlePDG>=500 && particlePDG<=599) ||
849 (particlePDG>=5000 && particlePDG<=5999);
850 if(requiredPDG<0) result = (particlePDG>=-599 && particlePDG<=-500) ||
851 (particlePDG>=-5999 && particlePDG<=-5000);
854 case 5000: // all beauty baryons
856 result = TMath::Abs(particlePDG)>=5000 && TMath::Abs(particlePDG)<=5999;
858 if(requiredPDG>0) result = particlePDG>=5000 && particlePDG<=5999;
859 if(requiredPDG<0) result = particlePDG>=-5999 && particlePDG<=-5000;
862 case 5001: // open beauty baryons
864 result = TMath::Abs(particlePDG)>=5000 && TMath::Abs(particlePDG)<=5499;
866 if(requiredPDG>0) result = particlePDG>=5000 && particlePDG<=5499;
867 if(requiredPDG<0) result = particlePDG>=-5499 && particlePDG<=-5000;
870 default: // all specific cases
872 result = (absRequiredPDG==TMath::Abs(particlePDG));
874 result = (requiredPDG==particlePDG);
877 if(absRequiredPDG!=0 && pdgExclusion) result = !result;
882 //________________________________________________________________________________
883 Bool_t AliDielectronMC::IsPhysicalPrimary(Int_t label) const {
885 // Check if the particle with label "label" is a physical primary according to the
886 // definition in AliStack::IsPhysicalPrimary(Int_t label)
887 // Convention for being physical primary:
888 // 1.) particles produced in the collision
889 // 2.) stable particles with respect to strong and electromagnetic interactions
890 // 3.) excludes initial state particles
891 // 4.) includes products of directly produced Sigma0 hyperon decay
892 // 5.) includes products of directly produced pi0 decays
893 // 6.) includes products of directly produced beauty hadron decays
895 if(label<0) return kFALSE;
897 if(!fMcArray) return kFALSE;
898 return (static_cast<AliAODMCParticle*>(GetMCTrackFromMCEvent(label)))->IsPhysicalPrimary();
899 } else if(fAnaType==kESD) {
900 if (!fMCEvent) return kFALSE;
901 return fStack->IsPhysicalPrimary(label);
907 //________________________________________________________________________________
908 Bool_t AliDielectronMC::CheckParticleSource(Int_t label, AliDielectronSignalMC::ESource source) const {
910 // Check the source for the particle
914 case AliDielectronSignalMC::kDontCare :
917 case AliDielectronSignalMC::kPrimary :
918 // true if label is in the list of particles from physics generator
919 // NOTE: This includes all physics event history (initial state particles,
920 // exchange bosons, quarks, di-quarks, strings, un-stable particles, final state particles)
921 // Only the final state particles make it to the detector!!
922 return (label>=0 && label<=GetNPrimary());
924 case AliDielectronSignalMC::kFinalState :
925 // primary particles created in the collision which reach the detectors
927 // 1.) particles produced in the collision
928 // 2.) stable particles with respect to strong and electromagnetic interactions
929 // 3.) excludes initial state particles
930 // 4.) includes products of directly produced Sigma0 hyperon decay
931 // 5.) includes products of directly produced pi0 decays
932 // 6.) includes products of directly produced beauty hadron decays
933 return IsPhysicalPrimary(label);
935 case AliDielectronSignalMC::kDirect :
936 // Primary particles which do not have any mother
937 // This is the case for:
938 // 1.) Initial state particles (the 2 protons in Pythia pp collisions)
939 // 2.) In some codes, with sudden freeze-out, all particles generated from the fireball are direct.
940 // There is no history for these particles.
941 // 3.) Certain particles added via MC generator cocktails (e.g. J/psi added to pythia MB events)
942 return (label>=0 && GetMothersLabel(label)<0);
944 case AliDielectronSignalMC::kNoCocktail :
945 // Particles from the HIJING event and NOT from the AliGenCocktail
946 return (label>=0 && GetMothersLabel(label)>=0);
948 case AliDielectronSignalMC::kSecondary :
949 // particles which are created by the interaction of final state primaries with the detector
950 // or particles from strange weakly decaying particles (e.g. lambda, kaons, etc.)
951 return (label>=GetNPrimary() && !IsPhysicalPrimary(label));
959 //________________________________________________________________________________
960 Bool_t AliDielectronMC::CheckIsRadiative(Int_t label) const
963 // Check if the particle has a three body decay, one being a photon
965 if(label<0) return kFALSE;
969 if(!fMcArray) return kFALSE;
970 AliAODMCParticle *mother=static_cast<AliAODMCParticle*>(GetMCTrackFromMCEvent(label));
971 if (!mother) return kFALSE;
972 const Int_t nd=mother->GetNDaughters();
973 if (nd==2) return kFALSE;
974 for (Int_t i=2; i<nd; ++i)
975 if (GetMCTrackFromMCEvent(mother->GetDaughter(0)+i)->PdgCode()!=22) return kFALSE; //last daughter is photon
976 } else if(fAnaType==kESD) {
977 if (!fMCEvent) return kFALSE;
978 AliMCParticle *mother=static_cast<AliMCParticle*>(GetMCTrackFromMCEvent(label));
979 if (!mother) return kFALSE;
980 const Int_t nd=(mother->GetLastDaughter()-mother->GetFirstDaughter()+1);
981 if (nd==2) return kFALSE;
982 for (Int_t i=2; i<nd; ++i)
983 if (GetMCTrackFromMCEvent(mother->GetFirstDaughter()+i)->PdgCode()!=22) return kFALSE; //last daughters are photons
988 //________________________________________________________________________________
989 Bool_t AliDielectronMC::CheckRadiativeDecision(Int_t mLabel, const AliDielectronSignalMC * const signalMC) const
992 // Check for the decision of the radiative type request
995 if (!signalMC) return kFALSE;
997 if (signalMC->GetJpsiRadiative()==AliDielectronSignalMC::kAll) return kTRUE;
999 Bool_t isRadiative=CheckIsRadiative(mLabel);
1000 if ((signalMC->GetJpsiRadiative()==AliDielectronSignalMC::kIsRadiative) && !isRadiative) return kFALSE;
1001 if ((signalMC->GetJpsiRadiative()==AliDielectronSignalMC::kIsNotRadiative) && isRadiative) return kFALSE;
1006 //________________________________________________________________________________
1007 Bool_t AliDielectronMC::IsMCTruth(Int_t label, AliDielectronSignalMC* signalMC, Int_t branch) const {
1009 // Check if the particle corresponds to the MC truth in signalMC in the branch specified
1012 // NOTE: Some particles have the sign of the label flipped. It is related to the quality of matching
1013 // between the ESD and the MC track. The negative labels indicate a poor matching quality
1014 //if(label<0) return kFALSE;
1015 if(label<0) label *= -1;
1017 AliVParticle* part = GetMCTrackFromMCEvent(label);
1019 AliError(Form("Could not find MC particle with label %d",label));
1024 if(!ComparePDG(part->PdgCode(),signalMC->GetLegPDG(branch),signalMC->GetLegPDGexclude(branch),signalMC->GetCheckBothChargesLegs(branch))) return kFALSE;
1025 if(!CheckParticleSource(label, signalMC->GetLegSource(branch))) return kFALSE;
1028 AliVParticle* mcMother=0x0;
1030 if(signalMC->GetMotherPDG(branch)!=0 || signalMC->GetMotherSource(branch)!=AliDielectronSignalMC::kDontCare) {
1032 mLabel = GetMothersLabel(label);
1033 mcMother = GetMCTrackFromMCEvent(mLabel);
1035 if(!mcMother && !signalMC->GetMotherPDGexclude(branch)) return kFALSE;
1037 if(!ComparePDG((mcMother ? mcMother->PdgCode() : 0),signalMC->GetMotherPDG(branch),signalMC->GetMotherPDGexclude(branch),signalMC->GetCheckBothChargesMothers(branch))) return kFALSE;
1038 if(!CheckParticleSource(mLabel, signalMC->GetMotherSource(branch))) return kFALSE;
1040 //check for radiative deday
1041 if (!CheckRadiativeDecision(mLabel, signalMC)) return kFALSE;
1044 // check the grandmother
1045 AliVParticle* mcGrandMother=0x0;
1046 if(signalMC->GetGrandMotherPDG(branch)!=0 || signalMC->GetGrandMotherSource(branch)!=AliDielectronSignalMC::kDontCare) {
1049 gmLabel = GetMothersLabel(mLabel);
1050 mcGrandMother = static_cast<AliMCParticle*>(GetMCTrackFromMCEvent(gmLabel));
1052 if(!mcGrandMother && !signalMC->GetGrandMotherPDGexclude(branch)) return kFALSE;
1054 if(!ComparePDG((mcGrandMother ? mcGrandMother->PdgCode() : 0),signalMC->GetGrandMotherPDG(branch),signalMC->GetGrandMotherPDGexclude(branch),signalMC->GetCheckBothChargesGrandMothers(branch))) return kFALSE;
1055 if(!CheckParticleSource(gmLabel, signalMC->GetGrandMotherSource(branch))) return kFALSE;
1063 //________________________________________________________________________________
1064 Bool_t AliDielectronMC::IsMCTruth(const AliDielectronPair* pair, const AliDielectronSignalMC* signalMC) const {
1066 // Check if the pair corresponds to the MC truth in signalMC
1070 const AliVParticle * mcD1 = pair->GetFirstDaughter();
1071 const AliVParticle * mcD2 = pair->GetSecondDaughter();
1072 Int_t labelD1 = (mcD1 ? mcD1->GetLabel() : -1);
1073 Int_t labelD2 = (mcD2 ? mcD2->GetLabel() : -1);
1074 if(labelD1<0) labelD1 *= -1;
1075 if(labelD2<0) labelD2 *= -1;
1078 d1Pdg=GetPdgFromLabel(labelD1);
1079 d2Pdg=GetPdgFromLabel(labelD2);
1082 AliVParticle* mcM1=0x0;
1083 AliVParticle* mcM2=0x0;
1086 AliVParticle* mcG1 = 0x0;
1087 AliVParticle* mcG2 = 0x0;
1089 // make direct(1-1 and 2-2) and cross(1-2 and 2-1) comparisons for the whole branch
1090 Bool_t directTerm = kTRUE;
1092 directTerm = directTerm && mcD1 && ComparePDG(d1Pdg,signalMC->GetLegPDG(1),signalMC->GetLegPDGexclude(1),signalMC->GetCheckBothChargesLegs(1))
1093 && CheckParticleSource(labelD1, signalMC->GetLegSource(1));
1095 directTerm = directTerm && mcD2 && ComparePDG(d2Pdg,signalMC->GetLegPDG(2),signalMC->GetLegPDGexclude(2),signalMC->GetCheckBothChargesLegs(2))
1096 && CheckParticleSource(labelD2, signalMC->GetLegSource(2));
1100 if(signalMC->GetMotherPDG(1)!=0 || signalMC->GetMotherSource(1)!=AliDielectronSignalMC::kDontCare) {
1101 labelM1 = GetMothersLabel(labelD1);
1102 if(labelD1>-1 && labelM1>-1) mcM1 = GetMCTrackFromMCEvent(labelM1);
1103 directTerm = directTerm && (mcM1 || signalMC->GetMotherPDGexclude(1))
1104 && ComparePDG((mcM1 ? mcM1->PdgCode() : 0),signalMC->GetMotherPDG(1),signalMC->GetMotherPDGexclude(1),signalMC->GetCheckBothChargesMothers(1))
1105 && CheckParticleSource(labelM1, signalMC->GetMotherSource(1))
1106 && CheckRadiativeDecision(labelM1,signalMC);
1110 if(signalMC->GetMotherPDG(2)!=0 || signalMC->GetMotherSource(2)!=AliDielectronSignalMC::kDontCare) {
1111 labelM2 = GetMothersLabel(labelD2);
1112 if(labelD2>-1 && labelM2>-1) mcM2 = GetMCTrackFromMCEvent(labelM2);
1113 directTerm = directTerm && (mcM2 || signalMC->GetMotherPDGexclude(2))
1114 && ComparePDG((mcM2 ? mcM2->PdgCode() : 0),signalMC->GetMotherPDG(2),signalMC->GetMotherPDGexclude(2),signalMC->GetCheckBothChargesMothers(2))
1115 && CheckParticleSource(labelM2, signalMC->GetMotherSource(2))
1116 && CheckRadiativeDecision(labelM2,signalMC);
1121 if(signalMC->GetGrandMotherPDG(1)!=0 || signalMC->GetGrandMotherSource(1)!=AliDielectronSignalMC::kDontCare) {
1122 labelG1 = GetMothersLabel(labelM1);
1123 if(mcM1 && labelG1>-1) mcG1 = GetMCTrackFromMCEvent(labelG1);
1124 directTerm = directTerm && (mcG1 || signalMC->GetGrandMotherPDGexclude(1))
1125 && ComparePDG((mcG1 ? mcG1->PdgCode() : 0),signalMC->GetGrandMotherPDG(1),signalMC->GetGrandMotherPDGexclude(1),signalMC->GetCheckBothChargesGrandMothers(1))
1126 && CheckParticleSource(labelG1, signalMC->GetGrandMotherSource(1));
1130 if(signalMC->GetGrandMotherPDG(2)!=0 || signalMC->GetGrandMotherSource(2)!=AliDielectronSignalMC::kDontCare) {
1131 labelG2 = GetMothersLabel(labelM2);
1132 if(mcM2 && labelG2>-1) mcG2 = GetMCTrackFromMCEvent(labelG2);
1133 directTerm = directTerm && (mcG2 || signalMC->GetGrandMotherPDGexclude(2))
1134 && ComparePDG((mcG2 ? mcG2->PdgCode() : 0),signalMC->GetGrandMotherPDG(2),signalMC->GetGrandMotherPDGexclude(2),signalMC->GetCheckBothChargesGrandMothers(2))
1135 && CheckParticleSource(labelG2, signalMC->GetGrandMotherSource(2));
1139 Bool_t crossTerm = kTRUE;
1141 crossTerm = crossTerm && mcD2
1142 && ComparePDG(d2Pdg,signalMC->GetLegPDG(1),signalMC->GetLegPDGexclude(1),signalMC->GetCheckBothChargesLegs(1))
1143 && CheckParticleSource(labelD2, signalMC->GetLegSource(1));
1145 crossTerm = crossTerm && mcD1
1146 && ComparePDG(d1Pdg,signalMC->GetLegPDG(2),signalMC->GetLegPDGexclude(2),signalMC->GetCheckBothChargesLegs(2))
1147 && CheckParticleSource(labelD1, signalMC->GetLegSource(2));
1150 if(signalMC->GetMotherPDG(1)!=0 || signalMC->GetMotherSource(1)!=AliDielectronSignalMC::kDontCare) {
1151 if(!mcM2 && labelD2>-1) {
1152 labelM2 = GetMothersLabel(labelD2);
1153 if(labelM2>-1) mcM2 = GetMCTrackFromMCEvent(labelM2);
1155 crossTerm = crossTerm && (mcM2 || signalMC->GetMotherPDGexclude(1))
1156 && ComparePDG((mcM2 ? mcM2->PdgCode() : 0),signalMC->GetMotherPDG(1),signalMC->GetMotherPDGexclude(1),signalMC->GetCheckBothChargesMothers(1))
1157 && CheckParticleSource(labelM2, signalMC->GetMotherSource(1))
1158 && CheckRadiativeDecision(labelM2,signalMC);
1161 if(signalMC->GetMotherPDG(2)!=0 || signalMC->GetMotherSource(2)!=AliDielectronSignalMC::kDontCare) {
1162 if(!mcM1 && labelD1>-1) {
1163 labelM1 = GetMothersLabel(labelD1);
1164 if(labelM1>-1) mcM1 = GetMCTrackFromMCEvent(labelM1);
1166 crossTerm = crossTerm && (mcM1 || signalMC->GetMotherPDGexclude(2))
1167 && ComparePDG((mcM1 ? mcM1->PdgCode() : 0),signalMC->GetMotherPDG(2),signalMC->GetMotherPDGexclude(2),signalMC->GetCheckBothChargesMothers(2))
1168 && CheckParticleSource(labelM1, signalMC->GetMotherSource(2))
1169 && CheckRadiativeDecision(labelM1,signalMC);
1173 if(signalMC->GetGrandMotherPDG(1)!=0 || signalMC->GetGrandMotherSource(1)!=AliDielectronSignalMC::kDontCare) {
1175 labelG2 = GetMothersLabel(labelM2);
1176 if(labelG2>-1) mcG2 = GetMCTrackFromMCEvent(labelG2);
1178 crossTerm = crossTerm && (mcG2 || signalMC->GetGrandMotherPDGexclude(1))
1179 && ComparePDG((mcG2 ? mcG2->PdgCode() : 0),signalMC->GetGrandMotherPDG(1),signalMC->GetGrandMotherPDGexclude(1),signalMC->GetCheckBothChargesGrandMothers(1))
1180 && CheckParticleSource(labelG2, signalMC->GetGrandMotherSource(1));
1183 if(signalMC->GetGrandMotherPDG(2)!=0 || signalMC->GetGrandMotherSource(2)!=AliDielectronSignalMC::kDontCare) {
1185 labelG1 = GetMothersLabel(labelM1);
1186 if(labelG2>-1) mcG1 = GetMCTrackFromMCEvent(labelG1);
1188 crossTerm = crossTerm && (mcG1 || signalMC->GetGrandMotherPDGexclude(2))
1189 && ComparePDG((mcG1 ? mcG1->PdgCode() : 0),signalMC->GetGrandMotherPDG(2),signalMC->GetGrandMotherPDGexclude(2),signalMC->GetCheckBothChargesGrandMothers(2))
1190 && CheckParticleSource(labelG1, signalMC->GetGrandMotherSource(2));
1193 Bool_t motherRelation = kTRUE;
1194 if(signalMC->GetMothersRelation()==AliDielectronSignalMC::kSame) {
1195 motherRelation = motherRelation && HaveSameMother(pair);
1197 if(signalMC->GetMothersRelation()==AliDielectronSignalMC::kDifferent) {
1198 motherRelation = motherRelation && !HaveSameMother(pair);
1201 return ((directTerm || crossTerm) && motherRelation);
1206 //____________________________________________________________
1207 Bool_t AliDielectronMC::HaveSameMother(const AliDielectronPair * pair) const
1210 // Check whether two particles have the same mother
1213 const AliVParticle * daughter1 = pair->GetFirstDaughter();
1214 const AliVParticle * daughter2 = pair->GetSecondDaughter();
1215 if (!daughter1 || !daughter2) return 0;
1217 AliVParticle *mcDaughter1=GetMCTrackFromMCEvent(daughter1->GetLabel());
1218 AliVParticle *mcDaughter2=GetMCTrackFromMCEvent(daughter2->GetLabel());
1219 if (!mcDaughter1 || !mcDaughter2) return 0;
1221 Int_t labelMother1=-1;
1222 Int_t labelMother2=-1;
1224 if (mcDaughter1->IsA()==AliMCParticle::Class()){
1225 labelMother1=(static_cast<AliMCParticle*>(mcDaughter1))->GetMother();
1226 labelMother2=(static_cast<AliMCParticle*>(mcDaughter2))->GetMother();
1227 } else if (mcDaughter1->IsA()==AliAODMCParticle::Class()) {
1228 labelMother1=(static_cast<AliAODMCParticle*>(mcDaughter1))->GetMother();
1229 labelMother2=(static_cast<AliAODMCParticle*>(mcDaughter2))->GetMother();
1232 Bool_t sameMother=(labelMother1>-1)&&(labelMother2>-1)&&(labelMother1==labelMother2);
1237 //________________________________________________________________
1238 Int_t AliDielectronMC::IsJpsiPrimary(const AliDielectronPair * pair)
1240 // return: "0" for primary jpsi
1241 // "1" for secondary jpsi (from beauty)
1242 // "2" for background
1243 if(!HaveSameMother(pair)) return 2;
1244 AliVParticle *mcDaughter1=GetMCTrackFromMCEvent((pair->GetFirstDaughter())->GetLabel());
1245 Int_t labelMother=-1;
1247 if (mcDaughter1->IsA()==AliMCParticle::Class()){
1248 labelMother=(static_cast<AliMCParticle*>(mcDaughter1))->GetMother();
1249 } else if (mcDaughter1->IsA()==AliAODMCParticle::Class()) {
1250 labelMother=(static_cast<AliAODMCParticle*>(mcDaughter1))->GetMother();
1253 AliVParticle* mcMother=GetMCTrackFromMCEvent(labelMother);
1254 if(!IsMCMotherToEE(mcMother,443)) return 2;
1255 return IsJpsiPrimary(mcMother);
1258 //______________________________________________________________
1259 Int_t AliDielectronMC::IsJpsiPrimary(const AliVParticle * particle)
1261 // return: "0" for primary jpsi
1262 // "1" for secondary jpsi (come from B decay)
1266 if (particle->IsA()==AliMCParticle::Class()){
1267 labelMoth = (static_cast<const AliMCParticle*>(particle))->GetMother();
1269 particle = GetMCTrackFromMCEvent(labelMoth);
1270 pdgCode = TMath::Abs((static_cast<const AliMCParticle*>(particle))->PdgCode());
1271 if((pdgCode>500 && pdgCode<600) || (pdgCode>5000 && pdgCode<6000)) return 1;
1272 labelMoth = (static_cast<const AliMCParticle*>(particle))->GetMother();
1275 else if (particle->IsA()==AliAODMCParticle::Class()){
1276 labelMoth = (static_cast<const AliAODMCParticle*>(particle))->GetMother();
1278 particle = GetMCTrackFromMCEvent(labelMoth);
1279 pdgCode = TMath::Abs((static_cast<const AliAODMCParticle*>(particle))->PdgCode());
1280 if((pdgCode>500 && pdgCode<600) || (pdgCode>5000 && pdgCode<6000)) return 1;
1281 labelMoth = (static_cast<const AliAODMCParticle*>(particle))->GetMother();
1288 Bool_t AliDielectronMC::GetPrimaryVertex(Double_t &primVtxX, Double_t &primVtxY, Double_t &primVtxZ){
1290 if(fAnaType == kESD){
1291 const AliVVertex* mcVtx = fMCEvent->GetPrimaryVertex();
1292 if(!mcVtx) return kFALSE;
1293 primVtxX = mcVtx->GetX();
1294 primVtxY = mcVtx->GetY();
1295 primVtxZ = mcVtx->GetZ();
1296 }else if(fAnaType == kAOD){
1297 AliAODEvent *aod=((AliAODInputHandler*)((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler()))->GetEvent();
1298 if(!aod) return kFALSE;
1299 AliAODMCHeader *mcHead = dynamic_cast<AliAODMCHeader*>(aod->FindListObject(AliAODMCHeader::StdBranchName()));
1300 if(!mcHead) return kFALSE;
1301 primVtxX = mcHead->GetVtxX();
1302 primVtxY = mcHead->GetVtxY();
1303 primVtxZ = mcHead->GetVtxZ();