![]() |
![]() |
00001 #include "PhysicsTools/CandUtils/interface/zMCLeptonDaughters.h" 00002 #include "DataFormats/Candidate/interface/Candidate.h" 00003 #include "FWCore/Utilities/interface/EDMException.h" 00004 #include <cassert> 00005 using namespace std; 00006 using namespace reco; 00007 00008 pair<const Candidate*, const Candidate*> zMCLeptonDaughters(const Candidate & z, int leptonPdgId) { 00009 if(z.numberOfDaughters()<2) 00010 throw cms::Exception("RuntimeError") << 00011 "calling helper function reco::zMCLeptonDaughters passing a Z candidate" 00012 "with less than 2 daughters (" << z.numberOfDaughters() << ").\n"; 00013 const Candidate * dau0 = z.daughter(0); 00014 const Candidate * dau1 = z.daughter(1); 00015 for(size_t i0 = 0; i0 < dau0->numberOfDaughters(); ++i0) { 00016 const Candidate * ddau0 = dau0->daughter(i0); 00017 if(abs(ddau0->pdgId())==leptonPdgId && ddau0->status()==1) { 00018 dau0 = ddau0; break; 00019 } 00020 } 00021 for(size_t i1 = 0; i1 < dau1->numberOfDaughters(); ++i1) { 00022 const Candidate * ddau1 = dau1->daughter(i1); 00023 if(abs(ddau1->pdgId())==leptonPdgId && ddau1->status()==1) { 00024 dau1 = ddau1; break; 00025 } 00026 } 00027 assert(abs(dau0->pdgId())==leptonPdgId && dau0->status()==1); 00028 assert(abs(dau1->pdgId())==leptonPdgId && dau1->status()==1); 00029 return make_pair(dau0, dau1); 00030 }