#include <DataFormats/Candidate/interface/CompositeCandidate.h>
Public Types | |
typedef CandidateCollection | daughters |
collection of daughters | |
typedef std::vector< std::string > | role_collection |
Public Member Functions | |
void | addDaughter (std::auto_ptr< Candidate >, const std::string &s="") |
add a clone of the passed candidate as daughter | |
void | addDaughter (const Candidate &, const std::string &s="") |
add a clone of the passed candidate as daughter | |
void | applyRoles () |
virtual iterator | begin () |
first daughter iterator | |
virtual const_iterator | begin () const |
first daughter const_iterator | |
void | clearDaughters () |
clear daughters | |
void | clearRoles () |
virtual CompositeCandidate * | clone () const |
returns a clone of the candidate | |
CompositeCandidate (const Candidate &p, const std::string &name, role_collection const &roles) | |
constructor from values | |
CompositeCandidate (const Candidate &p, const std::string &name="") | |
constructor from values | |
CompositeCandidate (const Particle &p, const std::string &name="") | |
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 | |
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 (std::string name="") | |
default constructor | |
virtual const Candidate * | daughter (const std::string &s) const |
return daughter with a specified role name | |
virtual Candidate * | daughter (const std::string &s) |
return daughter with a specified role name | |
virtual Candidate * | daughter (size_type) |
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 | |
virtual const Candidate * | daughter (size_type) const |
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode) | |
virtual iterator | end () |
last daughter const_iterator | |
virtual const_iterator | end () const |
last daughter const_iterator | |
virtual const Candidate * | mother (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 |
The daughters are owned by the composite candidate.
Definition at line 23 of file CompositeCandidate.h.
typedef candidate::const_iterator_imp_specific<daughters> reco::CompositeCandidate::const_iterator_imp_specific [private] |
Definition at line 93 of file CompositeCandidate.h.
typedef candidate::iterator_imp_specific<daughters> reco::CompositeCandidate::iterator_imp_specific [private] |
Definition at line 95 of file CompositeCandidate.h.
typedef std::vector<std::string> reco::CompositeCandidate::role_collection |
reco::CompositeCandidate::CompositeCandidate | ( | std::string | name = "" |
) | [inline] |
reco::CompositeCandidate::CompositeCandidate | ( | const Particle & | p, | |
const std::string & | name = "" | |||
) | [inline, explicit] |
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().
00008 : 00009 Candidate(c), name_(name) { 00010 size_t n = c.numberOfDaughters(); 00011 for(size_t i = 0; i != n; ++i) { 00012 addDaughter(*c.daughter(i)); 00013 } 00014 }
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(), r, and roles_.
00018 : 00019 Candidate(c), name_(name), roles_(roles) { 00020 size_t n = c.numberOfDaughters(); 00021 size_t r = roles_.size(); 00022 bool sameSize = (n == r); 00023 for(size_t i = 0; i != n; ++i) { 00024 if (sameSize && r > 0) 00025 addDaughter(*c.daughter(i), roles_[i]); 00026 else 00027 addDaughter(*c.daughter(i)); 00028 } 00029 }
CompositeCandidate::~CompositeCandidate | ( | ) | [virtual] |
destructor
Reimplemented in pat::CompositeCandidate.
Definition at line 31 of file CompositeCandidate.cc.
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(), c1, dau, end(), Exception, find(), edm::OwnVector< T, P >::push_back(), roles_, and setName().
00145 { 00146 if (s != "") { 00147 role_collection::iterator begin = roles_.begin(), end = roles_.end(); 00148 bool isFound = (find(begin, end, s) != end); 00149 if (isFound) { 00150 throw cms::Exception("InvalidReference") 00151 << "CompositeCandidate::addDaughter: Already have role with name \"" << s 00152 << "\", please clearDaughters, or use a new name\n"; 00153 } 00154 roles_.push_back(s); 00155 CompositeCandidate * c1 = dynamic_cast<CompositeCandidate*>(&*cand); 00156 if (c1 != 0) { 00157 c1->setName(s); 00158 } 00159 } 00160 dau.push_back(cand); 00161 }
add a clone of the passed candidate as daughter
Reimplemented in reco::NamedCompositeCandidate.
Definition at line 126 of file CompositeCandidate.cc.
References begin(), c, c1, reco::Candidate::clone(), dau, end(), Exception, find(), edm::OwnVector< T, P >::push_back(), roles_, and setName().
Referenced by combiner::helpers::ShallowClonePtr::addDaughter(), combiner::helpers::NormalClone::addDaughter(), combiner::helpers::ShallowClone::addDaughter(), reco::NamedCompositeCandidate::addDaughter(), cloneDecayTree(), CompositeCandidate(), TtSemiLepHypothesis::hypo(), PFCandConnector::link(), reco::PFTauDecayMode::PFTauDecayMode(), PFRecoTauDecayModeDeterminator::produce(), and TtSemiEvtSolution::setupHyp().
00126 { 00127 Candidate * c = cand.clone(); 00128 if (s != "") { 00129 role_collection::iterator begin = roles_.begin(), end = roles_.end(); 00130 bool isFound = (find(begin, end, s) != end); 00131 if (isFound) { 00132 throw cms::Exception("InvalidReference") 00133 << "CompositeCandidate::addDaughter: Already have role with name \"" << s 00134 << "\", please clearDaughters, or use a new name\n"; 00135 } 00136 roles_.push_back(s); 00137 CompositeCandidate * c1 = dynamic_cast<CompositeCandidate*>(&*c); 00138 if (c1 != 0) { 00139 c1->setName(s); 00140 } 00141 } 00142 dau.push_back(c); 00143 }
void CompositeCandidate::applyRoles | ( | ) |
Reimplemented in reco::NamedCompositeCandidate.
Definition at line 64 of file CompositeCandidate.cc.
References c, c1, daughter(), Exception, i, numberOfDaughters(), roles_, and setName().
00064 { 00065 00066 if (roles_.size() == 0) 00067 return; 00068 00069 // Check if there are the same number of daughters and roles 00070 int N1 = roles_.size(); 00071 int N2 = numberOfDaughters(); 00072 if (N1 != N2) { 00073 throw cms::Exception("InvalidReference") 00074 << "CompositeCandidate::applyRoles : Number of roles and daughters differ, this is an error.\n"; 00075 } 00076 // Set up the daughter roles 00077 for (int i = 0 ; i < N1; ++i) { 00078 std::string role = roles_[i]; 00079 Candidate * c = CompositeCandidate::daughter(i); 00080 00081 CompositeCandidate * c1 = dynamic_cast<CompositeCandidate *>(c); 00082 if (c1 != 0) { 00083 c1->setName(role); 00084 } 00085 } 00086 }
Candidate::iterator CompositeCandidate::begin | ( | ) | [virtual] |
first daughter iterator
Implements reco::Candidate.
Definition at line 39 of file CompositeCandidate.cc.
References edm::OwnVector< T, P >::begin(), and dau.
00039 { return iterator(new iterator_imp_specific(dau.begin())); }
Candidate::const_iterator CompositeCandidate::begin | ( | ) | const [virtual] |
first daughter const_iterator
Implements reco::Candidate.
Definition at line 35 of file CompositeCandidate.cc.
References edm::OwnVector< T, P >::begin(), and dau.
Referenced by addDaughter(), and reco::NamedCompositeCandidate::addDaughter().
00035 { return const_iterator(new const_iterator_imp_specific(dau.begin())); }
void reco::CompositeCandidate::clearDaughters | ( | ) | [inline] |
clear daughters
Reimplemented in reco::NamedCompositeCandidate.
Definition at line 81 of file CompositeCandidate.h.
References edm::OwnVector< T, P >::clear(), and dau.
Referenced by reco::NamedCompositeCandidate::clearDaughters(), and TtSemiEvtSolution::setupHyp().
void reco::CompositeCandidate::clearRoles | ( | ) | [inline] |
Reimplemented in reco::NamedCompositeCandidate.
Definition at line 83 of file CompositeCandidate.h.
References roles_.
Referenced by TtSemiEvtSolution::setupHyp().
00083 { roles_.clear(); }
CompositeCandidate * CompositeCandidate::clone | ( | void | ) | const [virtual] |
returns a clone of the candidate
Implements reco::Candidate.
Reimplemented in reco::NamedCompositeCandidate, reco::VertexCompositeCandidate, reco::IsolatedPFCandidate, reco::PFCandidate, reco::PileUpPFCandidate, pat::CompositeCandidate, and reco::PFTauDecayMode.
Definition at line 33 of file CompositeCandidate.cc.
References CompositeCandidate().
00033 { return new CompositeCandidate(* this); }
const Candidate * CompositeCandidate::daughter | ( | const std::string & | s | ) | const [virtual] |
return daughter with a specified role name
Reimplemented from reco::Candidate.
Reimplemented in reco::NamedCompositeCandidate.
Definition at line 107 of file CompositeCandidate.cc.
References daughter(), Exception, i, N, and roles_.
00107 { 00108 int ret = -1; 00109 int i = 0, N = roles_.size(); 00110 bool found = false; 00111 for (; i < N && !found; ++i) { 00112 if (s == roles_[i]) { 00113 found = true; 00114 ret = i; 00115 } 00116 } 00117 00118 if (ret < 0) { 00119 throw cms::Exception("InvalidReference") 00120 << "CompositeCandidate::daughter: Cannot find role " << s << "\n"; 00121 } 00122 00123 return daughter(ret); 00124 }
Candidate * CompositeCandidate::daughter | ( | const std::string & | s | ) | [virtual] |
return daughter with a specified role name
Reimplemented from reco::Candidate.
Reimplemented in reco::NamedCompositeCandidate.
Definition at line 88 of file CompositeCandidate.cc.
References daughter(), Exception, i, N, and roles_.
00088 { 00089 int ret = -1; 00090 int i = 0, N = roles_.size(); 00091 bool found = false; 00092 for (; i < N && !found; ++i) { 00093 if (s == roles_[i]) { 00094 found = true; 00095 ret = i; 00096 } 00097 } 00098 00099 if (ret < 0) { 00100 throw cms::Exception("InvalidReference") 00101 << "CompositeCandidate::daughter: Cannot find role " << s << "\n"; 00102 } 00103 00104 return daughter(ret); 00105 }
return daughter at a given position, i = 0, ... numberOfDaughters() - 1
Reimplemented in reco::NamedCompositeCandidate.
Definition at line 47 of file CompositeCandidate.cc.
References d, dau, and numberOfDaughters().
00047 { 00048 Candidate * d = (i >= 0 && i < numberOfDaughters()) ? & dau[ i ] : 0; 00049 return d; 00050 }
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode)
Reimplemented in reco::NamedCompositeCandidate.
Definition at line 43 of file CompositeCandidate.cc.
References dau, and numberOfDaughters().
Referenced by applyRoles(), reco::NamedCompositeCandidate::applyRoles(), reco::PFTauDecayMode::chargedPionCandidates(), daughter(), reco::NamedCompositeCandidate::daughter(), pat::HistoComposite::fill(), reco::PFTauDecayMode::filteredObjectCandidates(), reco::PFTauDecayMode::neutralPionCandidates(), reco::PFTauDecayMode::PFTauDecayMode(), and PFRecoTauDecayModeDeterminator::produce().
00043 { 00044 return (i >= 0 && i < numberOfDaughters()) ? & dau[ i ] : 0; 00045 }
Candidate::iterator CompositeCandidate::end | ( | ) | [virtual] |
last daughter const_iterator
Implements reco::Candidate.
Definition at line 41 of file CompositeCandidate.cc.
References dau, and edm::OwnVector< T, P >::end().
00041 { return iterator(new iterator_imp_specific(dau.end())); }
Candidate::const_iterator CompositeCandidate::end | ( | ) | const [virtual] |
last daughter const_iterator
Implements reco::Candidate.
Definition at line 37 of file CompositeCandidate.cc.
References dau, and edm::OwnVector< T, P >::end().
Referenced by addDaughter(), and reco::NamedCompositeCandidate::addDaughter().
00037 { return const_iterator(new const_iterator_imp_specific(dau.end())); }
std::string reco::CompositeCandidate::name | ( | ) | const [inline] |
get the name of the candidate
Reimplemented in reco::NamedCompositeCandidate.
Definition at line 50 of file CompositeCandidate.h.
References name_.
00050 { return name_;}
size_t CompositeCandidate::numberOfDaughters | ( | ) | const [virtual] |
number of daughters
Implements reco::Candidate.
Definition at line 56 of file CompositeCandidate.cc.
References dau, and edm::OwnVector< T, P >::size().
Referenced by TauMVATrainer::analyze(), applyRoles(), reco::NamedCompositeCandidate::applyRoles(), reco::PFTauDecayMode::chargedPionCandidates(), daughter(), pat::HistoComposite::fill(), reco::PFTauDecayMode::filteredObjectCandidates(), reco::NamedCompositeCandidate::NamedCompositeCandidate(), reco::PFTauDecayMode::neutralPionCandidates(), reco::PFTauDecayMode::pfMasterClones(), reco::PFTauDecayMode::PFTauDecayMode(), and PFRecoTauDecayModeDeterminator::produce().
size_t CompositeCandidate::numberOfMothers | ( | ) | const [virtual] |
number of mothers (zero or one in most of but not all the cases)
Implements reco::Candidate.
Definition at line 58 of file CompositeCandidate.cc.
check overlap with another daughter
Implements reco::Candidate.
Definition at line 60 of file CompositeCandidate.cc.
References Exception.
00060 { 00061 throw cms::Exception("Error") << "can't check overlap internally for CompositeCanddate"; 00062 }
role_collection const& reco::CompositeCandidate::roles | ( | ) | const [inline] |
get the roles
Reimplemented in reco::NamedCompositeCandidate.
Definition at line 54 of file CompositeCandidate.h.
References roles_.
Referenced by pat::HistoComposite::fill(), and TtEvent::isHypoValid().
00054 { return roles_; }
void reco::CompositeCandidate::setName | ( | std::string | name | ) | [inline] |
set the name of the candidate
Reimplemented in reco::NamedCompositeCandidate.
Definition at line 52 of file CompositeCandidate.h.
References name_.
Referenced by addDaughter(), and applyRoles().
void reco::CompositeCandidate::setRoles | ( | const role_collection & | roles | ) | [inline] |
set the roles
Reimplemented in reco::NamedCompositeCandidate.
Definition at line 56 of file CompositeCandidate.h.
References roles_.
daughters reco::CompositeCandidate::dau [private] |
collection of daughters
Definition at line 97 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 101 of file CompositeCandidate.h.
candidate roles
Reimplemented in reco::NamedCompositeCandidate.
Definition at line 103 of file CompositeCandidate.h.
Referenced by addDaughter(), applyRoles(), clearRoles(), CompositeCandidate(), daughter(), roles(), and setRoles().