コード例 #1
0
//=============================================================================
// Return all descendants of level i for a Particle
//=============================================================================
const LHCb::Particle::ConstVector ParticleDescendants::descendants(const LHCb::Particle* P, int maxlevel){
  
  LHCb::Particle::ConstVector Parts ;

  int level = 0 ;
  bool found = false ;
  
  LHCb::Particle::ConstVector mothers ;

  do {
    ++level ;
    LHCb::Particle::ConstVector leveldaughters ;
    if ( level == 1 ) found = addDaughters( P, leveldaughters) ;
    else found = addDaughters( mothers, leveldaughters) ;
    if ( level==maxlevel || maxlevel == 0 ) {
      Parts.insert(Parts.end(),leveldaughters.begin(),leveldaughters.end()) ;
      verbose() << "Level: " << level << " - inserted " << leveldaughters.size() 
                << " daughters to get " << Parts.size() << endmsg ;
    }
    verbose() << "Level " << level << " of " << maxlevel << " : " 
              << leveldaughters.size() << " daughters " << found << endmsg ;
    mothers = leveldaughters ;
  } while ( (maxlevel<=0 || level<=maxlevel) && found ) ;
  
  debug() << "Reached " << level << ". Returning " << Parts.size() 
          << " daughters" << endmsg ;
  
  return Parts ;
}  
コード例 #2
0
//=============================================================================
// Return all daughters of particles in a vector
//=============================================================================
bool ParticleDescendants::addDaughters(const LHCb::Particle* M, 
                                       LHCb::Particle::ConstVector& Parts){
  if ( 0==M ) return false;
  if ( M->isBasicParticle() ) return false;  
  const LHCb::Particle::ConstVector dauts = M->daughtersVector();
  Parts.insert(Parts.end(),dauts.begin(),dauts.end());
  verbose() << "Added " << dauts.size() << " daughters" << endmsg ;
  return (!dauts.empty());
  
}