#include <DataFormats/Candidate/interface/NamedCompositeCandidate.h>
Public Types | |
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 () |
void | clearDaughters () |
clear daughters | |
void | clearRoles () |
virtual NamedCompositeCandidate * | clone () const |
returns a clone of the candidate | |
virtual const Candidate * | daughter (size_type i) const |
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode) | |
virtual Candidate * | daughter (size_type i) |
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 | |
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 | |
std::string | name () const |
get the name of the candidate | |
NamedCompositeCandidate (std::string name, const role_collection &roles, const Candidate &p) | |
constructor from values | |
NamedCompositeCandidate (std::string name, const role_collection &roles, const Particle &p) | |
constructor from values | |
NamedCompositeCandidate (std::string name, const role_collection &roles, Charge q, const LorentzVector &p4, const Point &vtx=Point(0, 0, 0), int pdgId=0, int status=0, bool integerCharge=true) | |
constructor from values | |
NamedCompositeCandidate (std::string name, const role_collection &roles) | |
NamedCompositeCandidate (std::string name="") | |
default constructor | |
const NamedCompositeCandidate::role_collection & | roles () const |
get the roles | |
void | setName (std::string n) |
set the name of the candidate | |
void | setRoles (const NamedCompositeCandidate::role_collection &roles) |
set the roles | |
virtual | ~NamedCompositeCandidate () |
destructor | |
Private Attributes | |
std::string | name_ |
candidate name | |
role_collection | roles_ |
candidate roles |
The daughters are owned by the composite candidate.
Definition at line 23 of file NamedCompositeCandidate.h.
typedef std::vector<std::string> reco::NamedCompositeCandidate::role_collection |
Reimplemented from reco::CompositeCandidate.
Definition at line 25 of file NamedCompositeCandidate.h.
reco::NamedCompositeCandidate::NamedCompositeCandidate | ( | std::string | name = "" |
) | [inline] |
default constructor
Definition at line 28 of file NamedCompositeCandidate.h.
Referenced by clone().
00028 : CompositeCandidate(), name_(name) { }
reco::NamedCompositeCandidate::NamedCompositeCandidate | ( | std::string | name, | |
const role_collection & | roles | |||
) | [inline] |
Definition at line 29 of file NamedCompositeCandidate.h.
00030 : 00031 CompositeCandidate(), name_(name), roles_(roles) { }
reco::NamedCompositeCandidate::NamedCompositeCandidate | ( | std::string | name, | |
const role_collection & | roles, | |||
Charge | q, | |||
const LorentzVector & | p4, | |||
const Point & | vtx = Point( 0, 0, 0 ) , |
|||
int | pdgId = 0 , |
|||
int | status = 0 , |
|||
bool | integerCharge = true | |||
) | [inline] |
constructor from values
Definition at line 33 of file NamedCompositeCandidate.h.
00036 : 00037 CompositeCandidate( q, p4, vtx, pdgId, status, integerCharge ), 00038 name_ (name), roles_(roles) { }
reco::NamedCompositeCandidate::NamedCompositeCandidate | ( | std::string | name, | |
const role_collection & | roles, | |||
const Particle & | p | |||
) | [inline] |
NamedCompositeCandidate::NamedCompositeCandidate | ( | std::string | name, | |
const role_collection & | roles, | |||
const Candidate & | p | |||
) |
constructor from values
Definition at line 9 of file NamedCompositeCandidate.cc.
References Exception, reco::CompositeCandidate::numberOfDaughters(), and roles_.
00011 : 00012 CompositeCandidate(c), 00013 name_(name), 00014 roles_(roles) 00015 { 00016 00017 // Check if there are the same number of daughters and roles 00018 int N1 = roles_.size(); 00019 int N2 = numberOfDaughters(); 00020 00021 if ( N1 != N2 ) { 00022 throw cms::Exception("InvalidReference") 00023 << "NamedCompositeCandidate constructor: Number of roles and daughters differ, this is an error. Name = " << name << "\n"; 00024 } 00025 }
NamedCompositeCandidate::~NamedCompositeCandidate | ( | ) | [virtual] |
destructor
Definition at line 27 of file NamedCompositeCandidate.cc.
References clearDaughters(), and clearRoles().
00027 { clearDaughters(); clearRoles(); }
void NamedCompositeCandidate::addDaughter | ( | std::auto_ptr< Candidate > | cand, | |
const std::string & | s | |||
) |
add a clone of the passed candidate as daughter
Reimplemented from reco::CompositeCandidate.
Definition at line 113 of file NamedCompositeCandidate.cc.
References reco::CompositeCandidate::addDaughter(), reco::CompositeCandidate::begin(), c1, reco::CompositeCandidate::end(), Exception, find(), roles_, and setName().
00114 { 00115 role_collection::iterator begin = roles_.begin(), end = roles_.end(); 00116 bool isFound = ( find( begin, end, s) != end ); 00117 if ( isFound ) { 00118 throw cms::Exception("InvalidReference") 00119 << "NamedCompositeCandidate::addDaughter: Already have role with name " << s 00120 << ", please clearDaughters, or use a new name\n"; 00121 } 00122 00123 roles_.push_back( s ); 00124 NamedCompositeCandidate * c1 = dynamic_cast<NamedCompositeCandidate*>(&*cand); 00125 if ( c1 != 0 ) { 00126 c1->setName( s ); 00127 } 00128 CompositeCandidate::addDaughter( cand ); 00129 }
add a clone of the passed candidate as daughter
Reimplemented from reco::CompositeCandidate.
Definition at line 93 of file NamedCompositeCandidate.cc.
References reco::CompositeCandidate::addDaughter(), reco::CompositeCandidate::begin(), c, c1, reco::Candidate::clone(), reco::CompositeCandidate::end(), Exception, find(), and roles_.
00094 { 00095 00096 role_collection::iterator begin = roles_.begin(), end = roles_.end(); 00097 bool isFound = ( find( begin, end, s) != end ); 00098 if ( isFound ) { 00099 throw cms::Exception("InvalidReference") 00100 << "NamedCompositeCandidate::addDaughter: Already have role with name " << s 00101 << ", please clearDaughters, or use a new name\n"; 00102 } 00103 00104 roles_.push_back( s ); 00105 std::auto_ptr<Candidate> c( cand.clone() ); 00106 NamedCompositeCandidate * c1 = dynamic_cast<NamedCompositeCandidate*>(&*c); 00107 if ( c1 != 0 ) { 00108 c1->setName( s ); 00109 } 00110 CompositeCandidate::addDaughter( c ); 00111 }
void NamedCompositeCandidate::applyRoles | ( | ) |
Reimplemented from reco::CompositeCandidate.
Definition at line 31 of file NamedCompositeCandidate.cc.
References c, c1, reco::CompositeCandidate::daughter(), Exception, i, reco::CompositeCandidate::numberOfDaughters(), roles_, and setName().
00032 { 00033 00034 // Check if there are the same number of daughters and roles 00035 int N1 = roles_.size(); 00036 int N2 = numberOfDaughters(); 00037 if ( N1 != N2 ) { 00038 throw cms::Exception("InvalidReference") 00039 << "NamedCompositeCandidate::applyRoles : Number of roles and daughters differ, this is an error.\n"; 00040 } 00041 // Set up the daughter roles 00042 for ( int i = 0 ; i < N1; ++i ) { 00043 std::string role = roles_[i]; 00044 Candidate * c = CompositeCandidate::daughter( i ); 00045 00046 NamedCompositeCandidate * c1 = dynamic_cast<NamedCompositeCandidate *>(c); 00047 if ( c1 != 0 ) { 00048 c1->setName( role ); 00049 } 00050 } 00051 }
void reco::NamedCompositeCandidate::clearDaughters | ( | ) | [inline] |
clear daughters
Reimplemented from reco::CompositeCandidate.
Definition at line 71 of file NamedCompositeCandidate.h.
References reco::CompositeCandidate::clearDaughters().
Referenced by ~NamedCompositeCandidate().
00071 { CompositeCandidate::clearDaughters(); }
void reco::NamedCompositeCandidate::clearRoles | ( | ) | [inline] |
Reimplemented from reco::CompositeCandidate.
Definition at line 72 of file NamedCompositeCandidate.h.
References roles_.
Referenced by ~NamedCompositeCandidate().
00072 { roles_.clear(); }
NamedCompositeCandidate * NamedCompositeCandidate::clone | ( | void | ) | const [virtual] |
returns a clone of the candidate
Reimplemented from reco::CompositeCandidate.
Definition at line 29 of file NamedCompositeCandidate.cc.
References NamedCompositeCandidate().
00029 { return new NamedCompositeCandidate( * this ); }
virtual const Candidate* reco::NamedCompositeCandidate::daughter | ( | size_type | i | ) | const [inline, virtual] |
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode)
Reimplemented from reco::CompositeCandidate.
Definition at line 66 of file NamedCompositeCandidate.h.
References reco::CompositeCandidate::daughter().
00066 { return CompositeCandidate::daughter(i); }
return daughter at a given position, i = 0, ... numberOfDaughters() - 1
Reimplemented from reco::CompositeCandidate.
Definition at line 65 of file NamedCompositeCandidate.h.
References reco::CompositeCandidate::daughter().
00065 { return CompositeCandidate::daughter(i); }
const Candidate * NamedCompositeCandidate::daughter | ( | const std::string & | s | ) | const [virtual] |
return daughter with a specified role name
Reimplemented from reco::CompositeCandidate.
Definition at line 73 of file NamedCompositeCandidate.cc.
References daughter(), Exception, i, N, and roles_.
00074 { 00075 int ret = -1; 00076 int i = 0, N = roles_.size(); 00077 bool found = false; 00078 for ( ; i < N && !found; ++i ) { 00079 if ( s == roles_[i] ) { 00080 found = true; 00081 ret = i; 00082 } 00083 } 00084 00085 if ( ret < 0 ) { 00086 throw cms::Exception("InvalidReference") 00087 << "NamedCompositeCandidate::daughter: Cannot find role " << s << "\n"; 00088 } 00089 00090 return daughter(ret); 00091 }
Candidate * NamedCompositeCandidate::daughter | ( | const std::string & | s | ) | [virtual] |
return daughter with a specified role name
Reimplemented from reco::CompositeCandidate.
Definition at line 53 of file NamedCompositeCandidate.cc.
References Exception, i, N, and roles_.
Referenced by daughter().
00054 { 00055 int ret = -1; 00056 int i = 0, N = roles_.size(); 00057 bool found = false; 00058 for ( ; i < N && !found; ++i ) { 00059 if ( s == roles_[i] ) { 00060 found = true; 00061 ret = i; 00062 } 00063 } 00064 00065 if ( ret < 0 ) { 00066 throw cms::Exception("InvalidReference") 00067 << "NamedCompositeCandidate::daughter: Cannot find role " << s << "\n"; 00068 } 00069 00070 return daughter(ret); 00071 }
std::string reco::NamedCompositeCandidate::name | ( | ) | const [inline] |
get the name of the candidate
Reimplemented from reco::CompositeCandidate.
Definition at line 54 of file NamedCompositeCandidate.h.
References name_.
00054 { return name_; }
const NamedCompositeCandidate::role_collection& reco::NamedCompositeCandidate::roles | ( | ) | const [inline] |
get the roles
Reimplemented from reco::CompositeCandidate.
Definition at line 58 of file NamedCompositeCandidate.h.
References roles_.
00058 { return roles_;}
void reco::NamedCompositeCandidate::setName | ( | std::string | name | ) | [inline] |
set the name of the candidate
Reimplemented from reco::CompositeCandidate.
Definition at line 56 of file NamedCompositeCandidate.h.
References name_.
Referenced by addDaughter(), and applyRoles().
void reco::NamedCompositeCandidate::setRoles | ( | const NamedCompositeCandidate::role_collection & | roles | ) | [inline] |
set the roles
Reimplemented from reco::CompositeCandidate.
Definition at line 60 of file NamedCompositeCandidate.h.
References roles_.
std::string reco::NamedCompositeCandidate::name_ [private] |
candidate name
Reimplemented from reco::CompositeCandidate.
Definition at line 76 of file NamedCompositeCandidate.h.
candidate roles
Reimplemented from reco::CompositeCandidate.
Definition at line 77 of file NamedCompositeCandidate.h.
Referenced by addDaughter(), applyRoles(), clearRoles(), daughter(), NamedCompositeCandidate(), roles(), and setRoles().