CMS 3D CMS Logo

Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes

reco::CompositeCandidate Class Reference

#include <CompositeCandidate.h>

Inheritance diagram for reco::CompositeCandidate:
reco::LeafCandidate reco::Candidate pat::PATObject< reco::CompositeCandidate > reco::NamedCompositeCandidate reco::PFCandidate reco::PFTauDecayMode reco::V0Candidate reco::VertexCompositeCandidate reco::WMuNuCandidate pat::CompositeCandidate pat::PATObject< reco::PFCandidate > reco::IsolatedPFCandidate reco::PileUpPFCandidate pat::PFParticle

List of all members.

Public Types

typedef CandidateCollection daughters
 collection of daughters
typedef std::vector< std::string > role_collection

Public Member Functions

void addDaughter (const Candidate &, const std::string &s="")
 add a clone of the passed candidate as daughter
void addDaughter (std::auto_ptr< Candidate >, const std::string &s="")
 add a clone of the passed candidate as daughter
void applyRoles ()
virtual const_iterator begin () const
 first daughter const_iterator
virtual iterator begin ()
 first daughter iterator
void clearDaughters ()
 clear daughters
void clearRoles ()
virtual CompositeCandidateclone () const
 returns a clone of the candidate
 CompositeCandidate (std::string name="")
 default constructor
 CompositeCandidate (const Candidate &p, const std::string &name="")
 constructor from values
 CompositeCandidate (Charge q, const LorentzVector &p4, const Point &vtx=Point(0, 0, 0), int pdgId=0, int status=0, bool integerCharge=true, std::string name="")
 constructor from values
 CompositeCandidate (const Candidate &p, const std::string &name, role_collection const &roles)
 constructor from values
 CompositeCandidate (Charge q, const PolarLorentzVector &p4, const Point &vtx=Point(0, 0, 0), int pdgId=0, int status=0, bool integerCharge=true, std::string name="")
 constructor from values
virtual const Candidatedaughter (size_type) const
 return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode)
virtual Candidatedaughter (size_type)
 return daughter at a given position, i = 0, ... numberOfDaughters() - 1
virtual const Candidatedaughter (const std::string &s) const
 return daughter with a specified role name
virtual Candidatedaughter (const std::string &s)
 return daughter with a specified role name
virtual const_iterator end () const
 last daughter const_iterator
virtual iterator end ()
 last daughter const_iterator
virtual const Candidatemother (size_type i=0) const
 return pointer to mother
std::string name () const
 get the name of the candidate
virtual size_type numberOfDaughters () const
 number of daughters
virtual size_type numberOfMothers () const
 number of mothers (zero or one in most of but not all the cases)
role_collection const & roles () const
 get the roles
void setName (std::string name)
 set the name of the candidate
void setRoles (const role_collection &roles)
 set the roles
virtual ~CompositeCandidate ()
 destructor

Private Types

typedef
candidate::const_iterator_imp_specific
< daughters
const_iterator_imp_specific
typedef
candidate::iterator_imp_specific
< daughters
iterator_imp_specific

Private Member Functions

virtual bool overlap (const Candidate &) const
 check overlap with another daughter

Private Attributes

daughters dau
 collection of daughters
std::string name_
 candidate name
role_collection roles_
 candidate roles

Detailed Description

A Candidate composed of daughters. The daughters are owned by the composite candidate.

Author:
Luca Lista, INFN
Version:
Id:
CompositeCandidate.h,v 1.29 2008/12/05 12:15:18 hegner Exp

Definition at line 23 of file CompositeCandidate.h.


Member Typedef Documentation

Reimplemented from reco::LeafCandidate.

Definition at line 90 of file CompositeCandidate.h.

collection of daughters

Reimplemented from reco::LeafCandidate.

Definition at line 26 of file CompositeCandidate.h.

Reimplemented from reco::LeafCandidate.

Definition at line 92 of file CompositeCandidate.h.

typedef std::vector<std::string> reco::CompositeCandidate::role_collection

Reimplemented in reco::NamedCompositeCandidate.

Definition at line 27 of file CompositeCandidate.h.


Constructor & Destructor Documentation

reco::CompositeCandidate::CompositeCandidate ( std::string  name = "") [inline]

default constructor

Definition at line 29 of file CompositeCandidate.h.

Referenced by clone().

reco::CompositeCandidate::CompositeCandidate ( Charge  q,
const LorentzVector p4,
const Point vtx = Point( 0, 0, 0 ),
int  pdgId = 0,
int  status = 0,
bool  integerCharge = true,
std::string  name = "" 
) [inline]

constructor from values

Definition at line 31 of file CompositeCandidate.h.

                                           :
      LeafCandidate( q, p4, vtx, pdgId, status, integerCharge ), name_(name) { }
reco::CompositeCandidate::CompositeCandidate ( Charge  q,
const PolarLorentzVector p4,
const Point vtx = Point( 0, 0, 0 ),
int  pdgId = 0,
int  status = 0,
bool  integerCharge = true,
std::string  name = "" 
) [inline]

constructor from values

Definition at line 36 of file CompositeCandidate.h.

                                            :
      LeafCandidate( q, p4, vtx, pdgId, status, integerCharge ), name_(name) { }
CompositeCandidate::CompositeCandidate ( const Candidate p,
const std::string &  name = "" 
) [explicit]

constructor from values

Definition at line 7 of file CompositeCandidate.cc.

References addDaughter(), reco::Candidate::daughter(), i, n, and reco::Candidate::numberOfDaughters().

                                                              :
  LeafCandidate(c), name_(name) {
  size_t n = c.numberOfDaughters();
  for(size_t i = 0; i != n; ++i) {
      addDaughter(*c.daughter(i));
  }
}
CompositeCandidate::CompositeCandidate ( const Candidate p,
const std::string &  name,
role_collection const &  roles 
) [explicit]

constructor from values

Definition at line 16 of file CompositeCandidate.cc.

References addDaughter(), reco::Candidate::daughter(), i, n, reco::Candidate::numberOfDaughters(), alignCSCRings::r, and roles_.

                                                                      :
  LeafCandidate(c), name_(name), roles_(roles) {
  size_t n = c.numberOfDaughters();
  size_t r = roles_.size();
  bool sameSize = (n == r);
  for(size_t i = 0; i != n; ++i) {
    if (sameSize && r > 0) 
      addDaughter(*c.daughter(i), roles_[i]);
    else
      addDaughter(*c.daughter(i));
  }
}
CompositeCandidate::~CompositeCandidate ( ) [virtual]

destructor

Reimplemented in pat::CompositeCandidate.

Definition at line 31 of file CompositeCandidate.cc.

{ }

Member Function Documentation

void CompositeCandidate::addDaughter ( const Candidate cand,
const std::string &  s = "" 
)
void CompositeCandidate::addDaughter ( std::auto_ptr< Candidate cand,
const std::string &  s = "" 
)

add a clone of the passed candidate as daughter

Reimplemented in reco::NamedCompositeCandidate.

Definition at line 145 of file CompositeCandidate.cc.

References begin(), alignmentValidation::c1, dau, end(), Exception, spr::find(), edm::OwnVector< T, P >::push_back(), roles_, and setName().

                                                                                    {
  if (s != "") {
    role_collection::iterator begin = roles_.begin(), end = roles_.end();
    bool isFound = (find(begin, end, s) != end);
    if (isFound) {
      throw cms::Exception("InvalidReference")
        << "CompositeCandidate::addDaughter: Already have role with name \"" << s 
        << "\", please clearDaughters, or use a new name\n";
    }
    roles_.push_back(s);  
    CompositeCandidate * c1 = dynamic_cast<CompositeCandidate*>(&*cand);
    if (c1 != 0) {
      c1->setName(s);
    }
  }
  dau.push_back(cand);
}
void CompositeCandidate::applyRoles ( )

Reimplemented in reco::NamedCompositeCandidate.

Definition at line 64 of file CompositeCandidate.cc.

References trackerHits::c, alignmentValidation::c1, daughter(), Exception, i, numberOfDaughters(), roles_, and setName().

                                    {

  if (roles_.size() == 0)
    return;

  // Check if there are the same number of daughters and roles
  int N1 = roles_.size();
  int N2 = numberOfDaughters();
  if (N1 != N2) {
    throw cms::Exception("InvalidReference")
      << "CompositeCandidate::applyRoles : Number of roles and daughters differ, this is an error.\n";
  }
  // Set up the daughter roles
  for (int i = 0 ; i < N1; ++i) {
    std::string role = roles_[i];
    Candidate * c = CompositeCandidate::daughter(i);

    CompositeCandidate * c1 = dynamic_cast<CompositeCandidate *>(c);
    if (c1 != 0) {
      c1->setName(role);
    }
  }
}
Candidate::iterator CompositeCandidate::begin ( void  ) [virtual]

first daughter iterator

Reimplemented from reco::LeafCandidate.

Definition at line 39 of file CompositeCandidate.cc.

References edm::OwnVector< T, P >::begin(), and dau.

Candidate::const_iterator CompositeCandidate::begin ( void  ) const [virtual]
void reco::CompositeCandidate::clearDaughters ( ) [inline]

clear daughters

Reimplemented in reco::NamedCompositeCandidate.

Definition at line 78 of file CompositeCandidate.h.

References edm::OwnVector< T, P >::clear(), and dau.

Referenced by TtSemiEvtSolution::setupHyp().

{ dau.clear(); }
void reco::CompositeCandidate::clearRoles ( ) [inline]

Reimplemented in reco::NamedCompositeCandidate.

Definition at line 80 of file CompositeCandidate.h.

References roles_.

Referenced by TtSemiEvtSolution::setupHyp().

{ roles_.clear(); }
CompositeCandidate * CompositeCandidate::clone ( void  ) const [virtual]
const Candidate * CompositeCandidate::daughter ( size_type  i) const [virtual]
Candidate * CompositeCandidate::daughter ( size_type  i) [virtual]

return daughter at a given position, i = 0, ... numberOfDaughters() - 1

Reimplemented from reco::LeafCandidate.

Reimplemented in reco::NamedCompositeCandidate.

Definition at line 47 of file CompositeCandidate.cc.

References dau, and numberOfDaughters().

                                                    { 
  Candidate * d = (i < numberOfDaughters()) ? & dau[ i ] : 0; // i >= 0, since i is unsigned
  return d;
}
Candidate * CompositeCandidate::daughter ( const std::string &  s) [virtual]

return daughter with a specified role name

Reimplemented from reco::LeafCandidate.

Reimplemented in reco::NamedCompositeCandidate.

Definition at line 88 of file CompositeCandidate.cc.

References daughter(), Exception, newFWLiteAna::found, i, N, run_regression::ret, and roles_.

                                                           {
  int ret = -1;
  int i = 0, N = roles_.size();
  bool found = false;
  for (; i < N && !found; ++i) {
    if (s == roles_[i]) {
      found = true;
      ret = i;
    }
  }

  if (ret < 0) {
    throw cms::Exception("InvalidReference")
      << "CompositeCandidate::daughter: Cannot find role " << s << "\n";
  }
  
  return daughter(ret);
}
const Candidate * CompositeCandidate::daughter ( const std::string &  s) const [virtual]

return daughter with a specified role name

Reimplemented from reco::LeafCandidate.

Reimplemented in reco::NamedCompositeCandidate.

Definition at line 107 of file CompositeCandidate.cc.

References daughter(), Exception, newFWLiteAna::found, i, N, run_regression::ret, and roles_.

                                                                        {
  int ret = -1;
  int i = 0, N = roles_.size();
  bool found = false;
  for (; i < N && !found; ++i) {
    if (s == roles_[i]) {
      found = true;
      ret = i;
    }
  }

  if (ret < 0) {
    throw cms::Exception("InvalidReference")
      << "CompositeCandidate::daughter: Cannot find role " << s << "\n";
  }
  
  return daughter(ret);
}
Candidate::iterator CompositeCandidate::end ( void  ) [virtual]

last daughter const_iterator

Reimplemented from reco::LeafCandidate.

Definition at line 41 of file CompositeCandidate.cc.

References dau, and edm::OwnVector< T, P >::end().

{ return iterator(new iterator_imp_specific(dau.end())); }    
Candidate::const_iterator CompositeCandidate::end ( void  ) const [virtual]
const Candidate * CompositeCandidate::mother ( size_type  i = 0) const [virtual]

return pointer to mother

Reimplemented from reco::LeafCandidate.

Definition at line 52 of file CompositeCandidate.cc.

                                                              { 
  return 0;
}
std::string reco::CompositeCandidate::name ( ) const [inline]

get the name of the candidate

Reimplemented in reco::NamedCompositeCandidate.

Definition at line 47 of file CompositeCandidate.h.

References name_.

Referenced by setName().

{ return name_;}
size_t CompositeCandidate::numberOfDaughters ( ) const [virtual]
size_t CompositeCandidate::numberOfMothers ( ) const [virtual]

number of mothers (zero or one in most of but not all the cases)

Reimplemented from reco::LeafCandidate.

Definition at line 58 of file CompositeCandidate.cc.

{ return 0; }
bool CompositeCandidate::overlap ( const Candidate c2) const [private, virtual]

check overlap with another daughter

Reimplemented from reco::LeafCandidate.

Reimplemented in reco::PFCandidate.

Definition at line 60 of file CompositeCandidate.cc.

References Exception.

                                                           {
  throw cms::Exception("Error") << "can't check overlap internally for CompositeCanddate";
}
role_collection const& reco::CompositeCandidate::roles ( ) const [inline]

get the roles

Reimplemented in reco::NamedCompositeCandidate.

Definition at line 51 of file CompositeCandidate.h.

References roles_.

Referenced by TtEvent::isHypoValid(), and setRoles().

{ return roles_; }
void reco::CompositeCandidate::setName ( std::string  name) [inline]

set the name of the candidate

Reimplemented in reco::NamedCompositeCandidate.

Definition at line 49 of file CompositeCandidate.h.

References name(), and name_.

Referenced by addDaughter(), and applyRoles().

{ name_ = name;}
void reco::CompositeCandidate::setRoles ( const role_collection roles) [inline]

set the roles

Reimplemented in reco::NamedCompositeCandidate.

Definition at line 53 of file CompositeCandidate.h.

References roles(), and roles_.

{ roles_.clear(); roles_ = roles; }

Member Data Documentation

collection of daughters

Definition at line 94 of file CompositeCandidate.h.

Referenced by addDaughter(), begin(), clearDaughters(), daughter(), end(), and numberOfDaughters().

std::string reco::CompositeCandidate::name_ [private]

candidate name

Reimplemented in reco::NamedCompositeCandidate.

Definition at line 98 of file CompositeCandidate.h.

Referenced by name(), and setName().

candidate roles

Reimplemented in reco::NamedCompositeCandidate.

Definition at line 100 of file CompositeCandidate.h.

Referenced by addDaughter(), applyRoles(), clearRoles(), CompositeCandidate(), daughter(), roles(), and setRoles().