CMS 3D CMS Logo

Typedefs | Functions
GenParticlesHelper Namespace Reference

Typedefs

typedef reco::GenParticleCollection::const_iterator IG
 
typedef reco::GenParticleRefVector::const_iterator IGR
 

Functions

void findDescendents (const reco::GenParticleRef &base, reco::GenParticleRefVector &descendents, int status, int pdgId=0)
 find all descendents of a given status and pdgId (recursive) More...
 
void findParticles (const reco::GenParticleCollection &sourceParticles, reco::GenParticleRefVector &particleRefs, int pdgId, int status)
 find all particles of a given pdgId and status More...
 
void findSisters (const reco::GenParticleRef &baseSister, reco::GenParticleRefVector &sisterRefs)
 find the particles having the same daughter as baseSister More...
 
bool hasAncestor (const reco::GenParticle *particle, int pdgId, int status)
 does the particle have an ancestor with this pdgId and this status? More...
 
bool isDirect (const reco::GenParticleRef &particle)
 check if particle is direct (has status 3 or is a daughter of particle with status 3) More...
 

Typedef Documentation

◆ IG

typedef reco::GenParticleCollection::const_iterator GenParticlesHelper::IG

Definition at line 10 of file GenParticlesHelper.h.

◆ IGR

Definition at line 11 of file GenParticlesHelper.h.

Function Documentation

◆ findDescendents()

void GenParticlesHelper::findDescendents ( const reco::GenParticleRef base,
reco::GenParticleRefVector descendents,
int  status,
int  pdgId = 0 
)

find all descendents of a given status and pdgId (recursive)

Definition at line 28 of file GenParticlesHelper.cc.

References funct::abs(), newFWLiteAna::base, edm::RefVector< C, T, F >::begin(), edm::RefVector< C, T, F >::end(), EgammaValidation_cff::pdgId, edm::RefVector< C, T, F >::push_back(), and mps_update::status.

Referenced by TauGenJetProducer::produce().

31  {
32  const GenParticleRefVector& daughterRefs = base->daughterRefVector();
33 
34  for (IGR idr = daughterRefs.begin(); idr != daughterRefs.end(); ++idr) {
35  if ((*idr)->status() == status && (!pdgId || std::abs((*idr)->pdgId()) == pdgId)) {
36  // cout<<"adding "<<(*idr)<<endl;
37  descendents.push_back(*idr);
38  } else
39  findDescendents(*idr, descendents, status, pdgId);
40  }
41  }
reco::GenParticleRefVector::const_iterator IGR
base
Main Program
Definition: newFWLiteAna.py:92
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const_iterator end() const
Termination of iteration.
Definition: RefVector.h:228
void push_back(value_type const &ref)
Add a Ref<C, T> to the RefVector.
Definition: RefVector.h:67
const_iterator begin() const
Initialize an iterator over the RefVector.
Definition: RefVector.h:223
void findDescendents(const reco::GenParticleRef &base, reco::GenParticleRefVector &descendents, int status, int pdgId=0)
find all descendents of a given status and pdgId (recursive)

◆ findParticles()

void GenParticlesHelper::findParticles ( const reco::GenParticleCollection sourceParticles,
reco::GenParticleRefVector particleRefs,
int  pdgId,
int  status 
)

find all particles of a given pdgId and status

Definition at line 8 of file GenParticlesHelper.cc.

References funct::abs(), EgammaValidation_cff::pdgId, edm::RefVector< C, T, F >::push_back(), and mps_update::status.

Referenced by TauGenJetProducer::produce().

11  {
12  unsigned index = 0;
13  for (IG ig = sourceParticles.begin(); ig != sourceParticles.end(); ++ig, ++index) {
14  const GenParticle& gen = *ig;
15 
16  // status has been specified, and this one does not have the correct
17  // status
18  if (status && gen.status() != status)
19  continue;
20 
21  if (std::abs(gen.pdgId()) == pdgId) {
22  GenParticleRef genref(&sourceParticles, index);
23  particleRefs.push_back(genref);
24  }
25  }
26  }
reco::GenParticleCollection::const_iterator IG
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
void push_back(value_type const &ref)
Add a Ref<C, T> to the RefVector.
Definition: RefVector.h:67

◆ findSisters()

void GenParticlesHelper::findSisters ( const reco::GenParticleRef baseSister,
reco::GenParticleRefVector sisterRefs 
)

find the particles having the same daughter as baseSister

Definition at line 43 of file GenParticlesHelper.cc.

References cms::cuda::assert(), edm::RefVector< C, T, F >::begin(), edm::RefVector< C, T, F >::end(), l1ctLayer2EG_cff::id, and edm::RefVector< C, T, F >::push_back().

43  {
44  assert(baseSister->numberOfMothers() > 0);
45 
46  // get first mother
47  const GenParticleRefVector& mothers = baseSister->motherRefVector();
48 
49  // get sisters
50  const GenParticleRefVector allRefs = mothers[0]->daughterRefVector();
51 
53  for (IT id = allRefs.begin(); id != allRefs.end(); ++id) {
54  if (*id == baseSister) {
55  continue; // this is myself
56  } else
57  sisterRefs.push_back(*id);
58  }
59  }
assert(be >=bs)
std::vector< LinkConnSpec >::const_iterator IT
const_iterator end() const
Termination of iteration.
Definition: RefVector.h:228
void push_back(value_type const &ref)
Add a Ref<C, T> to the RefVector.
Definition: RefVector.h:67
const_iterator begin() const
Initialize an iterator over the RefVector.
Definition: RefVector.h:223

◆ hasAncestor()

bool GenParticlesHelper::hasAncestor ( const reco::GenParticle particle,
int  pdgId,
int  status 
)

does the particle have an ancestor with this pdgId and this status?

Definition at line 77 of file GenParticlesHelper.cc.

References edm::RefVector< C, T, F >::begin(), edm::RefVector< C, T, F >::end(), reco::CompositeRefCandidateT< D >::motherRefVector(), EgammaValidation_cff::pdgId, reco::LeafCandidate::pdgId(), mps_update::status, and reco::LeafCandidate::status().

77  {
78  if (particle->pdgId() == pdgId && particle->status() == status)
79  return true;
80 
81  const GenParticleRefVector& mothers = particle->motherRefVector();
82 
83  for (IGR im = mothers.begin(); im != mothers.end(); ++im) {
84  const GenParticle& part = **im;
85  if (hasAncestor(&part, pdgId, status))
86  return true;
87  }
88 
89  return false;
90  }
reco::GenParticleRefVector::const_iterator IGR
int status() const final
status word
int pdgId() const final
PDG identifier.
const mothers & motherRefVector() const
references to mothers
part
Definition: HCALResponse.h:20
const_iterator end() const
Termination of iteration.
Definition: RefVector.h:228
bool hasAncestor(const reco::GenParticle *particle, int pdgId, int status)
does the particle have an ancestor with this pdgId and this status?
const_iterator begin() const
Initialize an iterator over the RefVector.
Definition: RefVector.h:223

◆ isDirect()

bool GenParticlesHelper::isDirect ( const reco::GenParticleRef particle)

check if particle is direct (has status 3 or is a daughter of particle with status 3)

Definition at line 61 of file GenParticlesHelper.cc.

References cms::cuda::assert(), and mps_update::status.

61  {
62  assert((particle->status() != 0) && (particle->status() < 4));
63  if (particle->status() == 3)
64  return true;
65  else {
66  assert(particle->numberOfMothers() > 0);
67 
68  // get first mother
69  const GenParticleRefVector& mothers = particle->motherRefVector();
70  if (mothers[0]->status() == 3)
71  return true;
72  else
73  return false;
74  }
75  }
assert(be >=bs)