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>
34 #include <AliESDEvent.h>
35 #include <AliAODEvent.h>
36 #include <AliESDtrack.h>
37 #include <AliAODTrack.h>
40 #include <TClonesArray.h>
41 #include <TParticle.h>
43 #include "AliDielectronSignalMC.h"
44 #include "AliDielectronMC.h"
46 AliDielectronMC* AliDielectronMC::fgInstance=0x0;
48 //____________________________________________________________
49 AliDielectronMC* AliDielectronMC::Instance()
52 // return pointer to singleton implementation
54 if (fgInstance) return fgInstance;
56 AnalysisType type=kUNSET;
58 if (AliAnalysisManager::GetAnalysisManager()){
59 if (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()->IsA()==AliESDInputHandler::Class()) type=kESD;
60 else if (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()->IsA()==AliAODInputHandler::Class()) type=kAOD;
62 AliMCEventHandler* mcHandler = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
63 if(type == kESD) hasMC=mcHandler!=0x0;
66 fgInstance=new AliDielectronMC(type);
68 fgInstance->SetHasMC(hasMC);
73 //____________________________________________________________
74 AliDielectronMC::AliDielectronMC(AnalysisType type):
82 // default constructor
87 //____________________________________________________________
88 AliDielectronMC::~AliDielectronMC()
96 //____________________________________________________________
97 void AliDielectronMC::Initialize()
100 // initialize MC class
102 if (!ConnectMCEvent()) AliError("Initialization of MC object failed!");
105 //____________________________________________________________
106 Int_t AliDielectronMC::GetNMCTracks()
109 // return the number of generated tracks from MC event
111 if(fAnaType == kESD){
112 if (!fMCEvent){ AliError("No fMCEvent"); return 0; }
113 return fMCEvent->GetNumberOfTracks();}
114 else if(fAnaType == kAOD){
115 if(!fMcArray) { AliError("No fMcArray"); return 0; }
116 return fMcArray->GetEntriesFast();
121 //____________________________________________________________
122 Int_t AliDielectronMC::GetNMCTracksFromStack()
125 // return the number of generated tracks from stack
127 if (!fStack){ AliError("No fStack"); return -999; }
128 return fStack->GetNtrack();
131 //____________________________________________________________
132 Int_t AliDielectronMC::GetNPrimary() const
135 // return the number of primary track from MC event
137 if (!fMCEvent){ AliError("No fMCEvent"); return 0; }
138 return fMCEvent->GetNumberOfPrimaries();
141 //____________________________________________________________
142 Int_t AliDielectronMC::GetNPrimaryFromStack()
145 // return the number of primary track from stack
147 if (!fStack){ AliError("No fStack"); return -999; }
148 return fStack->GetNprimary();
151 //____________________________________________________________
152 AliVParticle* AliDielectronMC::GetMCTrackFromMCEvent(Int_t itrk) const
155 // return MC track directly from MC event
157 if (itrk<0) return NULL;
158 AliVParticle * track=0x0;
159 if(fAnaType == kESD){
160 if (!fMCEvent){ AliError("No fMCEvent"); return NULL;}
161 track = fMCEvent->GetTrack(itrk); // tracks from MC event (ESD)
162 } else if(fAnaType == kAOD) {
163 if (!fMcArray){ AliError("No fMcArray"); return NULL;}
164 if (itrk>fMcArray->GetEntriesFast()) { AliWarning(Form("track %d out of array size %d",itrk,fMcArray->GetEntriesFast())); return NULL;}
165 track = (AliVParticle*)fMcArray->At(itrk); // tracks from MC event (AOD)
170 //____________________________________________________________
171 Bool_t AliDielectronMC::ConnectMCEvent()
174 // connect stack object from the mc handler
176 if(fAnaType == kESD){
178 AliMCEventHandler* mcHandler = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
179 if (!mcHandler){ /*AliError("Could not retrive MC event handler!");*/ return kFALSE; }
180 if (!mcHandler->InitOk() ) return kFALSE;
181 if (!mcHandler->TreeK() ) return kFALSE;
182 if (!mcHandler->TreeTR() ) return kFALSE;
184 AliMCEvent* mcEvent = mcHandler->MCEvent();
185 if (!mcEvent){ /*AliError("Could not retrieve MC event!");*/ return kFALSE; }
188 if (!UpdateStack()) return kFALSE;
190 else if(fAnaType == kAOD)
193 AliAODEvent *aod=((AliAODInputHandler*)((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler()))->GetEvent();
194 fMcArray = dynamic_cast<TClonesArray*>(aod->FindListObject(AliAODMCParticle::StdBranchName()));
195 if (!fMcArray){ /*AliError("Could not retrieve MC array!");*/ return kFALSE; }
201 //____________________________________________________________
202 Bool_t AliDielectronMC::UpdateStack()
205 // update stack with new event
207 if (!fMCEvent){ AliError("No fMCEvent"); return kFALSE;}
208 AliStack* stack = fMCEvent->Stack();
209 if (!stack){ AliError("Could not retrive stack!"); return kFALSE; }
214 //____________________________________________________________
215 AliMCParticle* AliDielectronMC::GetMCTrack( const AliESDtrack* _track)
220 if (!fMCEvent){ AliError("No fMCEvent"); return NULL;}
222 Int_t nStack = fMCEvent->GetNumberOfTracks();
223 Int_t label = TMath::Abs(_track->GetLabel());
224 if(label>nStack)return NULL;
225 if(label<0) return NULL;
226 AliMCParticle *mctrack = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(label));
231 //____________________________________________________________
232 AliAODMCParticle* AliDielectronMC::GetMCTrack( const AliAODTrack* _track)
237 if(!fMcArray) { AliError("No fMcArray"); return NULL;}
238 Int_t label = _track->GetLabel();
239 if(label < 0 || label > fMcArray->GetEntriesFast()) return NULL;
240 AliAODMCParticle *mctrack = (AliAODMCParticle*)fMcArray->At(label);
244 //____________________________________________________________
245 TParticle* AliDielectronMC::GetMCTrackFromStack(const AliESDtrack* _track)
248 // return MC track from stack
250 Int_t label = TMath::Abs(_track->GetLabel());
251 if (!fStack) AliWarning("fStack is not available. Update stack first.");
252 TParticle* mcpart = fStack->Particle(label);
253 if (!mcpart) return NULL;
257 //____________________________________________________________
258 AliMCParticle* AliDielectronMC::GetMCTrackMother(const AliESDtrack* _track)
261 // return MC track mother
263 AliMCParticle* mcpart = GetMCTrack(_track);
264 if (!mcpart) return NULL;
265 if(mcpart->GetMother()<0) return NULL;
266 AliMCParticle* mcmother = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(mcpart->GetMother()));
267 if (!mcmother) return NULL;
271 //______________________________________________________________
272 AliAODMCParticle* AliDielectronMC::GetMCTrackMother(const AliAODTrack* _track)
275 // return MC track mother
277 AliAODMCParticle* mcpart = GetMCTrack(_track);
278 if (!mcpart) return NULL;
279 if(mcpart->GetMother() < 0) return NULL;
280 AliAODMCParticle* mcmother = dynamic_cast<AliAODMCParticle *>(fMcArray->At(mcpart->GetMother()));
281 if (!mcmother) return NULL;
284 //____________________________________________________________
285 AliMCParticle* AliDielectronMC::GetMCTrackMother(const AliMCParticle* _particle){
287 // return MC track mother
289 if(_particle->GetMother() < 0) return NULL;
290 AliMCParticle* mcmother = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(_particle->GetMother()));
294 //____________________________________________________________
295 AliAODMCParticle* AliDielectronMC::GetMCTrackMother(const AliAODMCParticle* _particle){
297 // return MC track mother
299 if( _particle->GetMother() < 0) return NULL;
300 AliAODMCParticle* mcmother = dynamic_cast<AliAODMCParticle *>(fMcArray->At(_particle->GetMother()));
304 //____________________________________________________________
305 TParticle* AliDielectronMC::GetMCTrackMotherFromStack(const AliESDtrack* _track)
308 // return MC track mother from stack
310 TParticle* mcpart = GetMCTrackFromStack(_track);
311 if ( !mcpart || mcpart->GetFirstMother()<=0 ) return NULL;
312 TParticle* mcmother = fStack->Particle(mcpart->GetFirstMother());
313 if (!mcmother) return NULL;
317 //____________________________________________________________
318 Int_t AliDielectronMC::GetMCPID(const AliESDtrack* _track)
321 // return PDG code of the track from the MC truth info
323 AliMCParticle* mcpart = GetMCTrack(_track);
324 if (!mcpart) return -999;
325 return mcpart->PdgCode();
328 //__________________________________________________________
329 Int_t AliDielectronMC::GetMCPID(const AliAODTrack* _track)
332 // return PDG code of the track from the MC truth info
334 AliAODMCParticle* mcpart = GetMCTrack(_track);
335 if (!mcpart) return -999;
336 return mcpart->PdgCode();
339 //____________________________________________________________
340 Int_t AliDielectronMC::GetMCPIDFromStack(const AliESDtrack* _track)
343 // return MC PDG code from stack
345 TParticle* mcpart = GetMCTrackFromStack(_track);
346 if (!mcpart) return -999;
347 return mcpart->GetPdgCode();
350 //____________________________________________________________
351 Int_t AliDielectronMC::GetMotherPDG( const AliESDtrack* _track)
354 // return PDG code of the mother track from the MC truth info
356 AliMCParticle* mcmother = GetMCTrackMother(_track);
357 if (!mcmother) return -999;
358 return mcmother->PdgCode();
361 //________________________________________________________
362 Int_t AliDielectronMC::GetMotherPDG( const AliAODTrack* _track)
365 // return PDG code of the mother track from the MC truth info
367 AliAODMCParticle* mcmother = GetMCTrackMother(_track);
368 if (!mcmother) return -999;
369 return mcmother->PdgCode();
372 //____________________________________________________________
373 Int_t AliDielectronMC::GetMotherPDGFromStack(const AliESDtrack* _track)
376 // return PDG code of the mother track from stack
378 TParticle* mcmother = GetMCTrackMotherFromStack(_track);
379 if (!mcmother) return -999;
380 return mcmother->GetPdgCode();
383 //____________________________________________________________
384 Int_t AliDielectronMC::GetMCProcess(const AliESDtrack* _track)
387 // return process number of the track
389 AliMCParticle* mcpart = GetMCTrack(_track);
390 if (!mcpart) return -999;
394 //____________________________________________________________
395 Int_t AliDielectronMC::GetMCProcessFromStack(const AliESDtrack* _track)
398 // return process number of the track
400 TParticle* mcpart = GetMCTrackFromStack(_track);
401 if (!mcpart) return -999;
402 return mcpart->GetUniqueID();
405 //____________________________________________________________
406 Int_t AliDielectronMC::NumberOfDaughters(const AliESDtrack* track)
409 // returns the number of daughters
411 AliMCParticle *mcmother=GetMCTrackMother(track);
412 if(!mcmother||!mcmother->Particle()) return -999;
413 // return mcmother->GetFirstDaughter()>0?mcmother->GetLastDaughter()-mcmother->GetFirstDaughter()+1:0;
414 return mcmother->Particle()->GetNDaughters();
417 //_________________________________________________________
418 Int_t AliDielectronMC::NumberOfDaughters(const AliAODTrack* track)
421 // returns the number of daughters
423 AliAODMCParticle *mcmother=GetMCTrackMother(track);
424 if(!mcmother) return -999;
425 return NumberOfDaughters(mcmother);
429 //____________________________________________________________
430 Int_t AliDielectronMC::NumberOfDaughters(const AliMCParticle* particle)
433 // returns the number of daughters
435 AliMCParticle *mcmother=GetMCTrackMother(particle);
436 if(!mcmother||!mcmother->Particle()) return -999;
437 //return mcmother->GetFirstDaughter()>0?mcmother->GetLastDaughter()-mcmother->GetFirstDaughter()+1:0;
438 return mcmother->Particle()->GetNDaughters();
441 //____________________________________________________________
442 Int_t AliDielectronMC::NumberOfDaughters(const AliAODMCParticle* particle)
445 // returns the number of daughters
447 AliAODMCParticle *mcmother=GetMCTrackMother(particle);
448 if(!mcmother) return -999;
449 return mcmother->GetNDaughters();
452 //____________________________________________________________
453 Int_t AliDielectronMC::GetMCProcessMother(const AliESDtrack* _track)
456 // return process number of the mother of the track
458 AliMCParticle* mcmother = GetMCTrackMother(_track);
459 if (!mcmother) return -999;
463 //____________________________________________________________
464 Int_t AliDielectronMC::GetMCProcessMotherFromStack(const AliESDtrack* _track)
467 // return process number of the mother of the track
469 TParticle* mcmother = GetMCTrackMotherFromStack(_track);
470 if (!mcmother) return -999;
471 return mcmother->GetUniqueID();
474 //____________________________________________________________
475 Bool_t AliDielectronMC::IsMCMotherToEE(const AliVParticle *particle, Int_t pdgMother)
478 // Check if the Mother 'particle' is of type pdgMother and decays to e+e-
480 if (fAnaType==kESD && !fMCEvent) return kFALSE;
481 if (fAnaType==kAOD && !fMcArray) return kFALSE;
482 if (!particle) return kFALSE;
484 if (particle->IsA()==AliMCParticle::Class()){
485 return IsMCMotherToEEesd(static_cast<const AliMCParticle*>(particle),pdgMother);
486 } else if (particle->IsA()==AliAODMCParticle::Class()){
487 return IsMCMotherToEEaod(static_cast<const AliAODMCParticle*>(particle),pdgMother);
489 AliError("Unknown particle type");
494 //____________________________________________________________
495 Bool_t AliDielectronMC::IsMCMotherToEEesd(const AliMCParticle *particle, Int_t pdgMother)
498 // Check if the Mother 'particle' is of type pdgMother and decays to e+e-
503 if (particle->PdgCode()!=pdgMother) return kFALSE;
504 Int_t ifirst = particle->GetFirstDaughter();
505 Int_t ilast = particle->GetLastDaughter();
507 //check number of daughters
508 if ((ilast-ifirst)!=1) return kFALSE;
509 AliMCParticle *firstD=static_cast<AliMCParticle*>(GetMCTrackFromMCEvent(ifirst));
510 AliMCParticle *secondD=static_cast<AliMCParticle*>(GetMCTrackFromMCEvent(ilast));
512 //TODO: check how you can get rid of the hardcoded numbers. One should make use of the PdgCodes set in AliDielectron!!!
513 if (firstD->Charge()>0){
514 if (firstD->PdgCode()!=-11) return kFALSE;
515 if (secondD->PdgCode()!=11) return kFALSE;
517 if (firstD->PdgCode()!=11) return kFALSE;
518 if (secondD->PdgCode()!=-11) return kFALSE;
524 //____________________________________________________________
525 Bool_t AliDielectronMC::IsMCMotherToEEaod(const AliAODMCParticle *particle, Int_t pdgMother)
528 // Check if the Mother 'particle' is of type pdgMother and decays to e+e-
532 if (particle->GetPdgCode()!=pdgMother) return kFALSE;
533 if (particle->GetNDaughters()!=2) return kFALSE;
535 Int_t ifirst = particle->GetDaughter(0);
536 Int_t ilast = particle->GetDaughter(1);
538 //check number of daughters
539 if ((ilast-ifirst)!=1) return kFALSE;
541 AliAODMCParticle *firstD=static_cast<AliAODMCParticle*>(GetMCTrackFromMCEvent(ifirst));
542 AliAODMCParticle *secondD=static_cast<AliAODMCParticle*>(GetMCTrackFromMCEvent(ilast));
544 //TODO: check how you can get rid of the hardcoded numbers. One should make use of the PdgCodes set in AliDielectron!!!
546 if (firstD->Charge()>0){
547 if (firstD->GetPdgCode()!=-11) return kFALSE;
548 if (secondD->GetPdgCode()!=11) return kFALSE;
550 if (firstD->GetPdgCode()!=11) return kFALSE;
551 if (secondD->GetPdgCode()!=-11) return kFALSE;
556 //____________________________________________________________
557 Int_t AliDielectronMC::GetLabelMotherWithPdg(const AliVParticle *particle1, const AliVParticle *particle2, Int_t pdgMother)
560 // test if mother of particle 1 and 2 has pdgCode pdgMother and is the same;
563 if (!fMCEvent) return -1;
564 return GetLabelMotherWithPdgESD(particle1, particle2, pdgMother);
566 else if (fAnaType==kAOD)
568 if (!fMcArray) return -1;
569 return GetLabelMotherWithPdgAOD(particle1, particle2, pdgMother);
575 //____________________________________________________________
576 Int_t AliDielectronMC::GetLabelMotherWithPdgESD(const AliVParticle *particle1, const AliVParticle *particle2, Int_t pdgMother)
579 // test if mother of particle 1 and 2 has pdgCode +-11 (electron),
580 // have the same mother and the mother had pdg code pdgMother
582 //TODO: check how you can get rid of the hardcoded numbers. One should make use of the PdgCodes set in AliDielectron!!!
585 AliMCParticle *mcPart1=static_cast<AliMCParticle*>(GetMCTrackFromMCEvent(particle1->GetLabel()));
586 AliMCParticle *mcPart2=static_cast<AliMCParticle*>(GetMCTrackFromMCEvent(particle2->GetLabel()));
588 if (!mcPart1||!mcPart2) return -1;
590 Int_t lblMother1=mcPart1->GetMother();
591 Int_t lblMother2=mcPart2->GetMother();
593 AliMCParticle *mcMother1=static_cast<AliMCParticle*>(GetMCTrackFromMCEvent(lblMother1));
594 if (!mcMother1) return -1;
595 if (lblMother1!=lblMother2) return -1;
596 if (TMath::Abs(mcPart1->PdgCode())!=11) return -1;
597 if (mcPart1->PdgCode()!=-mcPart2->PdgCode()) return -1;
598 if (mcMother1->PdgCode()!=pdgMother) return -1;
603 //____________________________________________________________
604 Int_t AliDielectronMC::GetLabelMotherWithPdgAOD(const AliVParticle *particle1, const AliVParticle *particle2, Int_t pdgMother)
607 // test if mother of particle 1 and 2 has pdgCode +-11 (electron),
608 // have the same mother and the mother had pdg code pdgMother
610 //TODO: check how you can get rid of the hardcoded numbers. One should make use of the PdgCodes set in AliDielectron!!!
612 AliAODMCParticle *mcPart1=static_cast<AliAODMCParticle*>(GetMCTrackFromMCEvent(particle1->GetLabel()));
613 AliAODMCParticle *mcPart2=static_cast<AliAODMCParticle*>(GetMCTrackFromMCEvent(particle2->GetLabel()));
615 if (!mcPart1||!mcPart2) return -1;
617 Int_t lblMother1=mcPart1->GetMother();
618 Int_t lblMother2=mcPart2->GetMother();
620 AliAODMCParticle *mcMother1=static_cast<AliAODMCParticle*>(GetMCTrackFromMCEvent(lblMother1));
622 if (!mcMother1) return -1;
623 if (lblMother1!=lblMother2) return -1;
624 if (TMath::Abs(mcPart1->GetPdgCode())!=11) return -1;
625 if (mcPart1->GetPdgCode()!=-mcPart2->GetPdgCode()) return -1;
626 if (mcMother1->GetPdgCode()!=pdgMother) return -1;
631 //____________________________________________________________
632 void AliDielectronMC::GetDaughters(const TObject *mother, AliVParticle* &d1, AliVParticle* &d2)
635 // Get First two daughters of the mother
642 if(!fMcArray) return;
643 const AliAODMCParticle *aodMother=static_cast<const AliAODMCParticle*>(mother);
644 lblD1=aodMother->GetDaughter(0);
645 lblD2=aodMother->GetDaughter(1);
646 d1 = (AliVParticle*)fMcArray->At(lblD1);
647 d2 = (AliVParticle*)fMcArray->At(lblD2);
648 } else if (fAnaType==kESD){
649 if (!fMCEvent) return;
650 const AliMCParticle *aodMother=static_cast<const AliMCParticle*>(mother);
651 lblD1=aodMother->GetFirstDaughter();
652 lblD2=aodMother->GetLastDaughter();
653 d1=fMCEvent->GetTrack(lblD1);
654 d2=fMCEvent->GetTrack(lblD2);
659 //________________________________________________________________________________
660 Int_t AliDielectronMC::GetMothersLabel(Int_t daughterLabel) const {
662 // Get the label of the mother for particle with label daughterLabel
664 if(daughterLabel<0) return -1;
665 if (fAnaType==kAOD) {
666 if(!fMcArray) return -1;
667 return (static_cast<AliAODMCParticle*>(GetMCTrackFromMCEvent(daughterLabel)))->GetMother();
668 } else if(fAnaType==kESD) {
669 if (!fMCEvent) return -1;
670 return (static_cast<AliMCParticle*>(GetMCTrackFromMCEvent(daughterLabel)))->GetMother();
676 //________________________________________________________________________________
677 Int_t AliDielectronMC::GetPdgFromLabel(Int_t label) const {
679 // Get particle code using the label from stack
681 if(label<0) return 0;
683 if(!fMcArray) return 0;
684 return (static_cast<AliAODMCParticle*>(GetMCTrackFromMCEvent(label)))->PdgCode();
685 } else if(fAnaType==kESD) {
686 if (!fMCEvent) return 0;
687 return (static_cast<AliMCParticle*>(GetMCTrackFromMCEvent(label)))->PdgCode();
693 //________________________________________________________________________________
694 Bool_t AliDielectronMC::ComparePDG(Int_t particlePDG, Int_t requiredPDG, Bool_t pdgExclusion, Bool_t checkBothCharges) const {
696 // Test the PDG codes of particles with the required ones
698 Bool_t result = kTRUE;
699 Int_t absRequiredPDG = TMath::Abs(requiredPDG);
701 switch(absRequiredPDG) {
703 result = kTRUE; // PDG not required (any code will do fine)
705 case 100: // light flavoured mesons
707 result = TMath::Abs(particlePDG)>=100 && TMath::Abs(particlePDG)<=199;
709 if(requiredPDG>0) result = particlePDG>=100 && particlePDG<=199;
710 if(requiredPDG<0) result = particlePDG>=-199 && particlePDG<=-100;
713 case 1000: // light flavoured baryons
715 result = TMath::Abs(particlePDG)>=1000 && TMath::Abs(particlePDG)<=1999;
717 if(requiredPDG>0) result = particlePDG>=1000 && particlePDG<=1999;
718 if(requiredPDG<0) result = particlePDG>=-1999 && particlePDG<=-1000;
721 case 200: // light flavoured mesons
723 result = TMath::Abs(particlePDG)>=200 && TMath::Abs(particlePDG)<=299;
725 if(requiredPDG>0)result = particlePDG>=200 && particlePDG<=299;
726 if(requiredPDG<0)result = particlePDG>=-299 && particlePDG<=-200;
729 case 2000: // light flavoured baryons
731 result = TMath::Abs(particlePDG)>=2000 && TMath::Abs(particlePDG)<=2999;
733 if(requiredPDG>0) result = particlePDG>=2000 && particlePDG<=2999;
734 if(requiredPDG<0) result = particlePDG>=-2999 && particlePDG<=-2000;
737 case 300: // all strange mesons
739 result = TMath::Abs(particlePDG)>=300 && TMath::Abs(particlePDG)<=399;
741 if(requiredPDG>0) result = particlePDG>=300 && particlePDG<=399;
742 if(requiredPDG<0) result = particlePDG>=-399 && particlePDG<=-300;
745 case 3000: // all strange baryons
747 result = TMath::Abs(particlePDG)>=3000 && TMath::Abs(particlePDG)<=3999;
749 if(requiredPDG>0) result = particlePDG>=3000 && particlePDG<=3999;
750 if(requiredPDG<0) result = particlePDG>=-3999 && particlePDG<=-3000;
753 case 400: // all charmed mesons
755 result = TMath::Abs(particlePDG)>=400 && TMath::Abs(particlePDG)<=499;
757 if(requiredPDG>0) result = particlePDG>=400 && particlePDG<=499;
758 if(requiredPDG<0) result = particlePDG>=-499 && particlePDG<=-400;
761 case 401: // open charm mesons
763 result = TMath::Abs(particlePDG)>=400 && TMath::Abs(particlePDG)<=439;
765 if(requiredPDG>0) result = particlePDG>=400 && particlePDG<=439;
766 if(requiredPDG<0) result = particlePDG>=-439 && particlePDG<=-400;
769 case 402: // open charm mesons and baryons together
771 result = (TMath::Abs(particlePDG)>=400 && TMath::Abs(particlePDG)<=439) ||
772 (TMath::Abs(particlePDG)>=4000 && TMath::Abs(particlePDG)<=4399);
774 if(requiredPDG>0) result = (particlePDG>=400 && particlePDG<=439) ||
775 (particlePDG>=4000 && particlePDG<=4399);
776 if(requiredPDG<0) result = (particlePDG>=-439 && particlePDG<=-400) ||
777 (particlePDG>=-4399 && particlePDG<=-4000);
780 case 403: // all charm hadrons
782 result = (TMath::Abs(particlePDG)>=400 && TMath::Abs(particlePDG)<=499) ||
783 (TMath::Abs(particlePDG)>=4000 && TMath::Abs(particlePDG)<=4999);
785 if(requiredPDG>0) result = (particlePDG>=400 && particlePDG<=499) ||
786 (particlePDG>=4000 && particlePDG<=4999);
787 if(requiredPDG<0) result = (particlePDG>=-499 && particlePDG<=-400) ||
788 (particlePDG>=-4999 && particlePDG<=-4000);
791 case 4000: // all charmed baryons
793 result = TMath::Abs(particlePDG)>=4000 && TMath::Abs(particlePDG)<=4999;
795 if(requiredPDG>0) result = particlePDG>=4000 && particlePDG<=4999;
796 if(requiredPDG<0) result = particlePDG>=-4999 && particlePDG<=-4000;
799 case 4001: // open charm baryons
801 result = TMath::Abs(particlePDG)>=4000 && TMath::Abs(particlePDG)<=4399;
803 if(requiredPDG>0) result = particlePDG>=4000 && particlePDG<=4399;
804 if(requiredPDG<0) result = particlePDG>=-4399 && particlePDG<=-4000;
807 case 500: // all beauty mesons
809 result = TMath::Abs(particlePDG)>=500 && TMath::Abs(particlePDG)<=599;
811 if(requiredPDG>0) result = particlePDG>=500 && particlePDG<=599;
812 if(requiredPDG<0) result = particlePDG>=-599 && particlePDG<=-500;
815 case 501: // open beauty mesons
817 result = TMath::Abs(particlePDG)>=500 && TMath::Abs(particlePDG)<=549;
819 if(requiredPDG>0) result = particlePDG>=500 && particlePDG<=549;
820 if(requiredPDG<0) result = particlePDG>=-549 && particlePDG<=-500;
823 case 502: // open beauty mesons and baryons
825 result = (TMath::Abs(particlePDG)>=500 && TMath::Abs(particlePDG)<=549) ||
826 (TMath::Abs(particlePDG)>=5000 && TMath::Abs(particlePDG)<=5499);
828 if(requiredPDG>0) result = (particlePDG>=500 && particlePDG<=549) ||
829 (particlePDG>=5000 && particlePDG<=5499);
830 if(requiredPDG<0) result = (particlePDG>=-549 && particlePDG<=-500) ||
831 (particlePDG>=-5499 && particlePDG<=-5000);
834 case 503: // all beauty hadrons
836 result = (TMath::Abs(particlePDG)>=500 && TMath::Abs(particlePDG)<=599) ||
837 (TMath::Abs(particlePDG)>=5000 && TMath::Abs(particlePDG)<=5999);
839 if(requiredPDG>0) result = (particlePDG>=500 && particlePDG<=599) ||
840 (particlePDG>=5000 && particlePDG<=5999);
841 if(requiredPDG<0) result = (particlePDG>=-599 && particlePDG<=-500) ||
842 (particlePDG>=-5999 && particlePDG<=-5000);
845 case 5000: // all beauty baryons
847 result = TMath::Abs(particlePDG)>=5000 && TMath::Abs(particlePDG)<=5999;
849 if(requiredPDG>0) result = particlePDG>=5000 && particlePDG<=5999;
850 if(requiredPDG<0) result = particlePDG>=-5999 && particlePDG<=-5000;
853 case 5001: // open beauty baryons
855 result = TMath::Abs(particlePDG)>=5000 && TMath::Abs(particlePDG)<=5499;
857 if(requiredPDG>0) result = particlePDG>=5000 && particlePDG<=5499;
858 if(requiredPDG<0) result = particlePDG>=-5499 && particlePDG<=-5000;
861 default: // all specific cases
863 result = (absRequiredPDG==TMath::Abs(particlePDG));
865 result = (requiredPDG==particlePDG);
868 if(absRequiredPDG!=0 && pdgExclusion) result = !result;
873 //________________________________________________________________________________
874 Bool_t AliDielectronMC::IsPhysicalPrimary(Int_t label) const {
876 // Check if the particle with label "label" is a physical primary according to the
877 // definition in AliStack::IsPhysicalPrimary(Int_t label)
878 // Convention for being physical primary:
879 // 1.) particles produced in the collision
880 // 2.) stable particles with respect to strong and electromagnetic interactions
881 // 3.) excludes initial state particles
882 // 4.) includes products of directly produced Sigma0 hyperon decay
883 // 5.) includes products of directly produced pi0 decays
884 // 6.) includes products of directly produced beauty hadron decays
886 if(label<0) return kFALSE;
888 if(!fMcArray) return kFALSE;
889 return (static_cast<AliAODMCParticle*>(GetMCTrackFromMCEvent(label)))->IsPhysicalPrimary();
890 } else if(fAnaType==kESD) {
891 if (!fMCEvent) return kFALSE;
892 return fStack->IsPhysicalPrimary(label);
898 //________________________________________________________________________________
899 Bool_t AliDielectronMC::CheckParticleSource(Int_t label, AliDielectronSignalMC::ESource source) const {
901 // Check the source for the particle
905 case AliDielectronSignalMC::kDontCare :
908 case AliDielectronSignalMC::kPrimary :
909 // true if label is in the list of particles from physics generator
910 // NOTE: This includes all physics event history (initial state particles,
911 // exchange bosons, quarks, di-quarks, strings, un-stable particles, final state particles)
912 // Only the final state particles make it to the detector!!
913 return (label>=0 && label<=GetNPrimary());
915 case AliDielectronSignalMC::kFinalState :
916 // primary particles created in the collision which reach the detectors
918 // 1.) particles produced in the collision
919 // 2.) stable particles with respect to strong and electromagnetic interactions
920 // 3.) excludes initial state particles
921 // 4.) includes products of directly produced Sigma0 hyperon decay
922 // 5.) includes products of directly produced pi0 decays
923 // 6.) includes products of directly produced beauty hadron decays
924 return IsPhysicalPrimary(label);
926 case AliDielectronSignalMC::kDirect :
927 // Primary particles which do not have any mother
928 // This is the case for:
929 // 1.) Initial state particles (the 2 protons in Pythia pp collisions)
930 // 2.) In some codes, with sudden freeze-out, all particles generated from the fireball are direct.
931 // There is no history for these particles.
932 // 3.) Certain particles added via MC generator cocktails (e.g. J/psi added to pythia MB events)
933 return (label>=0 && GetMothersLabel(label)<0);
935 case AliDielectronSignalMC::kSecondary :
936 // particles which are created by the interaction of final state primaries with the detector
937 // or particles from strange weakly decaying particles (e.g. lambda, kaons, etc.)
938 return (label>=GetNPrimary() && !IsPhysicalPrimary(label));
946 //________________________________________________________________________________
947 Bool_t AliDielectronMC::CheckIsRadiative(Int_t label) const
950 // Check if the particle has a three body decay, one being a photon
952 if(label<0) return kFALSE;
956 if(!fMcArray) return kFALSE;
957 AliAODMCParticle *mother=static_cast<AliAODMCParticle*>(GetMCTrackFromMCEvent(label));
958 if (!mother) return kFALSE;
959 const Int_t nd=mother->GetNDaughters();
960 if (nd==2) return kFALSE;
961 for (Int_t i=2; i<nd; ++i)
962 if (GetMCTrackFromMCEvent(mother->GetDaughter(0)+i)->PdgCode()!=22) return kFALSE; //last daughter is photon
963 } else if(fAnaType==kESD) {
964 if (!fMCEvent) return kFALSE;
965 AliMCParticle *mother=static_cast<AliMCParticle*>(GetMCTrackFromMCEvent(label));
966 const Int_t nd=(mother->GetLastDaughter()-mother->GetFirstDaughter()+1);
967 if (!mother) return kFALSE;
968 if (nd==2) return kFALSE;
969 for (Int_t i=2; i<nd; ++i)
970 if (GetMCTrackFromMCEvent(mother->GetFirstDaughter()+i)->PdgCode()!=22) return kFALSE; //last daughters are photons
975 //________________________________________________________________________________
976 Bool_t AliDielectronMC::CheckRadiativeDecision(Int_t mLabel, const AliDielectronSignalMC * const signalMC) const
979 // Check for the decision of the radiative type request
982 if (!signalMC) return kFALSE;
984 if (signalMC->GetJpsiRadiative()==AliDielectronSignalMC::kAll) return kTRUE;
986 Bool_t isRadiative=CheckIsRadiative(mLabel);
987 if ((signalMC->GetJpsiRadiative()==AliDielectronSignalMC::kIsRadiative) && !isRadiative) return kFALSE;
988 if ((signalMC->GetJpsiRadiative()==AliDielectronSignalMC::kIsNotRadiative) && isRadiative) return kFALSE;
993 //________________________________________________________________________________
994 Bool_t AliDielectronMC::IsMCTruth(Int_t label, AliDielectronSignalMC* signalMC, Int_t branch) const {
996 // Check if the particle corresponds to the MC truth in signalMC in the branch specified
999 // NOTE: Some particles have the sign of the label flipped. It is related to the quality of matching
1000 // between the ESD and the MC track. The negative labels indicate a poor matching quality
1001 //if(label<0) return kFALSE;
1002 if(label<0) label *= -1;
1004 AliVParticle* part = GetMCTrackFromMCEvent(label);
1006 AliError(Form("Could not find MC particle with label %d",label));
1011 if(!ComparePDG(part->PdgCode(),signalMC->GetLegPDG(branch),signalMC->GetLegPDGexclude(branch),signalMC->GetCheckBothChargesLegs(branch))) return kFALSE;
1012 if(!CheckParticleSource(label, signalMC->GetLegSource(branch))) return kFALSE;
1015 AliVParticle* mcMother=0x0;
1017 if(signalMC->GetMotherPDG(branch)!=0 || signalMC->GetMotherSource(branch)!=AliDielectronSignalMC::kDontCare) {
1019 mLabel = GetMothersLabel(label);
1020 mcMother = GetMCTrackFromMCEvent(mLabel);
1022 if(!mcMother && !signalMC->GetMotherPDGexclude(branch)) return kFALSE;
1024 if(!ComparePDG((mcMother ? mcMother->PdgCode() : 0),signalMC->GetMotherPDG(branch),signalMC->GetMotherPDGexclude(branch),signalMC->GetCheckBothChargesMothers(branch))) return kFALSE;
1025 if(!CheckParticleSource(mLabel, signalMC->GetMotherSource(branch))) return kFALSE;
1027 //check for radiative deday
1028 if (!CheckRadiativeDecision(mLabel, signalMC)) return kFALSE;
1031 // check the grandmother
1032 AliVParticle* mcGrandMother=0x0;
1033 if(signalMC->GetGrandMotherPDG(branch)!=0 || signalMC->GetGrandMotherSource(branch)!=AliDielectronSignalMC::kDontCare) {
1036 gmLabel = GetMothersLabel(mLabel);
1037 mcGrandMother = static_cast<AliMCParticle*>(GetMCTrackFromMCEvent(gmLabel));
1039 if(!mcGrandMother && !signalMC->GetGrandMotherPDGexclude(branch)) return kFALSE;
1041 if(!ComparePDG((mcGrandMother ? mcGrandMother->PdgCode() : 0),signalMC->GetGrandMotherPDG(branch),signalMC->GetGrandMotherPDGexclude(branch),signalMC->GetCheckBothChargesGrandMothers(branch))) return kFALSE;
1042 if(!CheckParticleSource(gmLabel, signalMC->GetGrandMotherSource(branch))) return kFALSE;
1050 //________________________________________________________________________________
1051 Bool_t AliDielectronMC::IsMCTruth(const AliDielectronPair* pair, const AliDielectronSignalMC* signalMC) const {
1053 // Check if the pair corresponds to the MC truth in signalMC
1057 const AliVParticle * mcD1 = pair->GetFirstDaughter();
1058 const AliVParticle * mcD2 = pair->GetSecondDaughter();
1059 Int_t labelD1 = (mcD1 ? mcD1->GetLabel() : -1);
1060 Int_t labelD2 = (mcD2 ? mcD2->GetLabel() : -1);
1061 if(labelD1<0) labelD1 *= -1;
1062 if(labelD2<0) labelD2 *= -1;
1065 d1Pdg=GetPdgFromLabel(labelD1);
1066 d2Pdg=GetPdgFromLabel(labelD2);
1069 AliVParticle* mcM1=0x0;
1070 AliVParticle* mcM2=0x0;
1073 AliVParticle* mcG1 = 0x0;
1074 AliVParticle* mcG2 = 0x0;
1076 // make direct(1-1 and 2-2) and cross(1-2 and 2-1) comparisons for the whole branch
1077 Bool_t directTerm = kTRUE;
1079 directTerm = directTerm && mcD1 && ComparePDG(d1Pdg,signalMC->GetLegPDG(1),signalMC->GetLegPDGexclude(1),signalMC->GetCheckBothChargesLegs(1))
1080 && CheckParticleSource(labelD1, signalMC->GetLegSource(1));
1082 directTerm = directTerm && mcD2 && ComparePDG(d2Pdg,signalMC->GetLegPDG(2),signalMC->GetLegPDGexclude(2),signalMC->GetCheckBothChargesLegs(2))
1083 && CheckParticleSource(labelD2, signalMC->GetLegSource(2));
1087 if(signalMC->GetMotherPDG(1)!=0 || signalMC->GetMotherSource(1)!=AliDielectronSignalMC::kDontCare) {
1088 labelM1 = GetMothersLabel(labelD1);
1089 if(labelD1>-1 && labelM1>-1) mcM1 = GetMCTrackFromMCEvent(labelM1);
1090 directTerm = directTerm && (mcM1 || signalMC->GetMotherPDGexclude(1))
1091 && ComparePDG((mcM1 ? mcM1->PdgCode() : 0),signalMC->GetMotherPDG(1),signalMC->GetMotherPDGexclude(1),signalMC->GetCheckBothChargesMothers(1))
1092 && CheckParticleSource(labelM1, signalMC->GetMotherSource(1))
1093 && CheckRadiativeDecision(labelM1,signalMC);
1097 if(signalMC->GetMotherPDG(2)!=0 || signalMC->GetMotherSource(2)!=AliDielectronSignalMC::kDontCare) {
1098 labelM2 = GetMothersLabel(labelD2);
1099 if(labelD2>-1 && labelM2>-1) mcM2 = GetMCTrackFromMCEvent(labelM2);
1100 directTerm = directTerm && (mcM2 || signalMC->GetMotherPDGexclude(2))
1101 && ComparePDG((mcM2 ? mcM2->PdgCode() : 0),signalMC->GetMotherPDG(2),signalMC->GetMotherPDGexclude(2),signalMC->GetCheckBothChargesMothers(2))
1102 && CheckParticleSource(labelM2, signalMC->GetMotherSource(2))
1103 && CheckRadiativeDecision(labelM2,signalMC);
1108 if(signalMC->GetGrandMotherPDG(1)!=0 || signalMC->GetGrandMotherSource(1)!=AliDielectronSignalMC::kDontCare) {
1109 labelG1 = GetMothersLabel(labelM1);
1110 if(mcM1 && labelG1>-1) mcG1 = GetMCTrackFromMCEvent(labelG1);
1111 directTerm = directTerm && (mcG1 || signalMC->GetGrandMotherPDGexclude(1))
1112 && ComparePDG((mcG1 ? mcG1->PdgCode() : 0),signalMC->GetGrandMotherPDG(1),signalMC->GetGrandMotherPDGexclude(1),signalMC->GetCheckBothChargesGrandMothers(1))
1113 && CheckParticleSource(labelG1, signalMC->GetGrandMotherSource(1));
1117 if(signalMC->GetGrandMotherPDG(2)!=0 || signalMC->GetGrandMotherSource(2)!=AliDielectronSignalMC::kDontCare) {
1118 labelG2 = GetMothersLabel(labelM2);
1119 if(mcM2 && labelG2>-1) mcG2 = GetMCTrackFromMCEvent(labelG2);
1120 directTerm = directTerm && (mcG2 || signalMC->GetGrandMotherPDGexclude(2))
1121 && ComparePDG((mcG2 ? mcG2->PdgCode() : 0),signalMC->GetGrandMotherPDG(2),signalMC->GetGrandMotherPDGexclude(2),signalMC->GetCheckBothChargesGrandMothers(2))
1122 && CheckParticleSource(labelG2, signalMC->GetGrandMotherSource(2));
1126 Bool_t crossTerm = kTRUE;
1128 crossTerm = crossTerm && mcD2
1129 && ComparePDG(d2Pdg,signalMC->GetLegPDG(1),signalMC->GetLegPDGexclude(1),signalMC->GetCheckBothChargesLegs(1))
1130 && CheckParticleSource(labelD2, signalMC->GetLegSource(1));
1132 crossTerm = crossTerm && mcD1
1133 && ComparePDG(d1Pdg,signalMC->GetLegPDG(2),signalMC->GetLegPDGexclude(2),signalMC->GetCheckBothChargesLegs(2))
1134 && CheckParticleSource(labelD1, signalMC->GetLegSource(2));
1137 if(signalMC->GetMotherPDG(1)!=0 || signalMC->GetMotherSource(1)!=AliDielectronSignalMC::kDontCare) {
1138 if(!mcM2 && labelD2>-1) {
1139 labelM2 = GetMothersLabel(labelD2);
1140 if(labelM2>-1) mcM2 = GetMCTrackFromMCEvent(labelM2);
1142 crossTerm = crossTerm && (mcM2 || signalMC->GetMotherPDGexclude(1))
1143 && ComparePDG((mcM2 ? mcM2->PdgCode() : 0),signalMC->GetMotherPDG(1),signalMC->GetMotherPDGexclude(1),signalMC->GetCheckBothChargesMothers(1))
1144 && CheckParticleSource(labelM2, signalMC->GetMotherSource(1))
1145 && CheckRadiativeDecision(labelM2,signalMC);
1148 if(signalMC->GetMotherPDG(2)!=0 || signalMC->GetMotherSource(2)!=AliDielectronSignalMC::kDontCare) {
1149 if(!mcM1 && labelD1>-1) {
1150 labelM1 = GetMothersLabel(labelD1);
1151 if(labelM1>-1) mcM1 = GetMCTrackFromMCEvent(labelM1);
1153 crossTerm = crossTerm && (mcM1 || signalMC->GetMotherPDGexclude(2))
1154 && ComparePDG((mcM1 ? mcM1->PdgCode() : 0),signalMC->GetMotherPDG(2),signalMC->GetMotherPDGexclude(2),signalMC->GetCheckBothChargesMothers(2))
1155 && CheckParticleSource(labelM1, signalMC->GetMotherSource(2))
1156 && CheckRadiativeDecision(labelM1,signalMC);
1160 if(signalMC->GetGrandMotherPDG(1)!=0 || signalMC->GetGrandMotherSource(1)!=AliDielectronSignalMC::kDontCare) {
1162 labelG2 = GetMothersLabel(labelM2);
1163 if(labelG2>-1) mcG2 = GetMCTrackFromMCEvent(labelG2);
1165 crossTerm = crossTerm && (mcG2 || signalMC->GetGrandMotherPDGexclude(1))
1166 && ComparePDG((mcG2 ? mcG2->PdgCode() : 0),signalMC->GetGrandMotherPDG(1),signalMC->GetGrandMotherPDGexclude(1),signalMC->GetCheckBothChargesGrandMothers(1))
1167 && CheckParticleSource(labelG2, signalMC->GetGrandMotherSource(1));
1170 if(signalMC->GetGrandMotherPDG(2)!=0 || signalMC->GetGrandMotherSource(2)!=AliDielectronSignalMC::kDontCare) {
1172 labelG1 = GetMothersLabel(labelM1);
1173 if(labelG2>-1) mcG1 = GetMCTrackFromMCEvent(labelG1);
1175 crossTerm = crossTerm && (mcG1 || signalMC->GetGrandMotherPDGexclude(2))
1176 && ComparePDG((mcG1 ? mcG1->PdgCode() : 0),signalMC->GetGrandMotherPDG(2),signalMC->GetGrandMotherPDGexclude(2),signalMC->GetCheckBothChargesGrandMothers(2))
1177 && CheckParticleSource(labelG1, signalMC->GetGrandMotherSource(2));
1180 Bool_t motherRelation = kTRUE;
1181 if(signalMC->GetMothersRelation()==AliDielectronSignalMC::kSame) {
1182 motherRelation = motherRelation && HaveSameMother(pair);
1184 if(signalMC->GetMothersRelation()==AliDielectronSignalMC::kDifferent) {
1185 motherRelation = motherRelation && !HaveSameMother(pair);
1188 return ((directTerm || crossTerm) && motherRelation);
1193 //____________________________________________________________
1194 Bool_t AliDielectronMC::HaveSameMother(const AliDielectronPair * pair) const
1197 // Check whether two particles have the same mother
1200 const AliVParticle * daughter1 = pair->GetFirstDaughter();
1201 const AliVParticle * daughter2 = pair->GetSecondDaughter();
1202 if (!daughter1 || !daughter2) return 0;
1204 AliVParticle *mcDaughter1=GetMCTrackFromMCEvent(daughter1->GetLabel());
1205 AliVParticle *mcDaughter2=GetMCTrackFromMCEvent(daughter2->GetLabel());
1206 if (!mcDaughter1 || !mcDaughter2) return 0;
1208 Int_t labelMother1=-1;
1209 Int_t labelMother2=-1;
1211 if (mcDaughter1->IsA()==AliMCParticle::Class()){
1212 labelMother1=(static_cast<AliMCParticle*>(mcDaughter1))->GetMother();
1213 labelMother2=(static_cast<AliMCParticle*>(mcDaughter2))->GetMother();
1214 } else if (mcDaughter1->IsA()==AliAODMCParticle::Class()) {
1215 labelMother1=(static_cast<AliAODMCParticle*>(mcDaughter1))->GetMother();
1216 labelMother2=(static_cast<AliAODMCParticle*>(mcDaughter2))->GetMother();
1219 Bool_t sameMother=(labelMother1>-1)&&(labelMother2>-1)&&(labelMother1==labelMother2);
1224 //________________________________________________________________
1225 Int_t AliDielectronMC::IsJpsiPrimary(const AliDielectronPair * pair)
1227 // return: "0" for primary jpsi
1228 // "1" for secondary jpsi (from beauty)
1229 // "2" for background
1230 if(!HaveSameMother(pair)) return 2;
1231 AliVParticle *mcDaughter1=GetMCTrackFromMCEvent((pair->GetFirstDaughter())->GetLabel());
1232 Int_t labelMother=-1;
1234 if (mcDaughter1->IsA()==AliMCParticle::Class()){
1235 labelMother=(static_cast<AliMCParticle*>(mcDaughter1))->GetMother();
1236 } else if (mcDaughter1->IsA()==AliAODMCParticle::Class()) {
1237 labelMother=(static_cast<AliAODMCParticle*>(mcDaughter1))->GetMother();
1240 AliVParticle* mcMother=GetMCTrackFromMCEvent(labelMother);
1241 if(!IsMCMotherToEE(mcMother,443)) return 2;
1242 return IsJpsiPrimary(mcMother);
1245 //______________________________________________________________
1246 Int_t AliDielectronMC::IsJpsiPrimary(const AliVParticle * particle)
1248 // return: "0" for primary jpsi
1249 // "1" for secondary jpsi (come from B decay)
1253 if (particle->IsA()==AliMCParticle::Class()){
1254 labelMoth = (static_cast<const AliMCParticle*>(particle))->GetMother();
1256 particle = GetMCTrackFromMCEvent(labelMoth);
1257 pdgCode = TMath::Abs((static_cast<const AliMCParticle*>(particle))->PdgCode());
1258 if((pdgCode>500 && pdgCode<600) || (pdgCode>5000 && pdgCode<6000)) return 1;
1259 labelMoth = (static_cast<const AliMCParticle*>(particle))->GetMother();
1262 else if (particle->IsA()==AliAODMCParticle::Class()){
1263 labelMoth = (static_cast<const AliAODMCParticle*>(particle))->GetMother();
1265 particle = GetMCTrackFromMCEvent(labelMoth);
1266 pdgCode = TMath::Abs((static_cast<const AliAODMCParticle*>(particle))->PdgCode());
1267 if((pdgCode>500 && pdgCode<600) || (pdgCode>5000 && pdgCode<6000)) return 1;
1268 labelMoth = (static_cast<const AliAODMCParticle*>(particle))->GetMother();