CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Functions
zMCLeptonDaughters.cc File Reference
#include "CommonTools/CandUtils/interface/zMCLeptonDaughters.h"
#include "DataFormats/Candidate/interface/Candidate.h"
#include "FWCore/Utilities/interface/EDMException.h"
#include <cassert>

Go to the source code of this file.

Functions

pair< const Candidate *, const
Candidate * > 
zMCLeptonDaughters (const Candidate &z, int leptonPdgId)
 

Function Documentation

pair<const Candidate*, const Candidate*> zMCLeptonDaughters ( const Candidate z,
int  leptonPdgId 
)

Definition at line 8 of file zMCLeptonDaughters.cc.

References funct::abs(), assert(), reco::Candidate::daughter(), reco::Candidate::numberOfDaughters(), reco::Candidate::pdgId(), and reco::Candidate::status().

8  {
9  if(z.numberOfDaughters()<2)
10  throw cms::Exception("RuntimeError") <<
11  "calling helper function reco::zMCLeptonDaughters passing a Z candidate"
12  "with less than 2 daughters (" << z.numberOfDaughters() << ").\n";
13  const Candidate * dau0 = z.daughter(0);
14  const Candidate * dau1 = z.daughter(1);
15  for(size_t i0 = 0; i0 < dau0->numberOfDaughters(); ++i0) {
16  const Candidate * ddau0 = dau0->daughter(i0);
17  if(abs(ddau0->pdgId())==leptonPdgId && ddau0->status()==1) {
18  dau0 = ddau0; break;
19  }
20  }
21  for(size_t i1 = 0; i1 < dau1->numberOfDaughters(); ++i1) {
22  const Candidate * ddau1 = dau1->daughter(i1);
23  if(abs(ddau1->pdgId())==leptonPdgId && ddau1->status()==1) {
24  dau1 = ddau1; break;
25  }
26  }
27  assert(abs(dau0->pdgId())==leptonPdgId && dau0->status()==1);
28  assert(abs(dau1->pdgId())==leptonPdgId && dau1->status()==1);
29  return make_pair(dau0, dau1);
30 }
virtual const Candidate * daughter(size_type i) const =0
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode) ...
virtual int status() const =0
status word
assert(m_qm.get())
virtual size_type numberOfDaughters() const =0
number of daughters
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
virtual int pdgId() const =0
PDG identifier.