CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Attributes
reco::NamedCompositeCandidate Class Reference

#include <NamedCompositeCandidate.h>

Inheritance diagram for reco::NamedCompositeCandidate:
reco::CompositeCandidate reco::LeafCandidate reco::Candidate

Public Types

typedef std::vector< std::string > role_collection
 
- Public Types inherited from reco::CompositeCandidate
typedef CandidateCollection daughters
 collection of daughters More...
 
typedef std::vector< std::string > role_collection
 
- Public Types inherited from reco::LeafCandidate
typedef int Charge
 electric charge type More...
 
typedef CandidateCollection daughters
 collection of daughter candidates More...
 
typedef unsigned int index
 
typedef math::XYZTLorentzVector LorentzVector
 Lorentz vector. More...
 
typedef math::XYZPoint Point
 point in the space More...
 
typedef math::PtEtaPhiMLorentzVector PolarLorentzVector
 Lorentz vector. More...
 
typedef math::XYZVector Vector
 point in the space More...
 
- Public Types inherited from reco::Candidate
enum  { dimension = 3 }
 
enum  { size = dimension * (dimension + 1)/2 }
 matix size More...
 
typedef int Charge
 electric charge type More...
 
typedef candidate::const_iterator const_iterator
 
typedef math::Error< dimension >::type CovarianceMatrix
 covariance error matrix (3x3) More...
 
typedef unsigned int index
 index type More...
 
typedef candidate::iterator iterator
 
typedef math::XYZTLorentzVector LorentzVector
 Lorentz vector. More...
 
typedef math::XYZPoint Point
 point in the space More...
 
typedef math::PtEtaPhiMLorentzVector PolarLorentzVector
 Lorentz vector. More...
 
typedef size_t size_type
 
typedef math::XYZVector Vector
 point in the space More...
 

Public Member Functions

void addDaughter (const Candidate &, const std::string &s)
 
void addDaughter (std::unique_ptr< Candidate >, const std::string &s)
 
void applyRoles ()
 
void clearDaughters ()
 
void clearRoles ()
 
NamedCompositeCandidateclone () const override
 returns a clone of the candidate More...
 
Candidatedaughter (const std::string &s) override
 return daughter with a specified role name More...
 
const Candidatedaughter (const std::string &s) const override
 return daughter with a specified role name More...
 
Candidatedaughter (size_type i) override
 return daughter at a given position, i = 0, ... numberOfDaughters() - 1 More...
 
const Candidatedaughter (size_type i) const override
 return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode) More...
 
std::string name () const
 
 NamedCompositeCandidate (std::string name="")
 default constructor More...
 
 NamedCompositeCandidate (std::string name, const role_collection &roles)
 
 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 More...
 
 NamedCompositeCandidate (std::string name, const role_collection &roles, const Candidate &p)
 constructor from values More...
 
const NamedCompositeCandidate::role_collectionroles () const
 
void setName (std::string n)
 
void setRoles (const NamedCompositeCandidate::role_collection &roles)
 
 ~NamedCompositeCandidate () override
 destructor More...
 
- Public Member Functions inherited from reco::CompositeCandidate
void addDaughter (const Candidate &, const std::string &s="")
 add a clone of the passed candidate as daughter More...
 
void addDaughter (std::unique_ptr< Candidate >, const std::string &s="")
 add a clone of the passed candidate as daughter More...
 
void applyRoles ()
 
void clearDaughters ()
 clear daughters More...
 
void clearRoles ()
 
 CompositeCandidate (std::string name="")
 default constructor More...
 
template<typename P4 >
 CompositeCandidate (Charge q, const P4 &p4, const Point &vtx=Point(0, 0, 0), int pdgId=0, int status=0, bool integerCharge=true, std::string name="")
 constructor from values More...
 
 CompositeCandidate (const Candidate &p, const std::string &name="")
 constructor from values More...
 
 CompositeCandidate (const Candidate &p, const std::string &name, role_collection const &roles)
 constructor from values More...
 
const Candidatemother (size_type i=0) const override
 return pointer to mother More...
 
std::string name () const
 get the name of the candidate More...
 
size_type numberOfDaughters () const override
 number of daughters More...
 
size_type numberOfMothers () const override
 number of mothers (zero or one in most of but not all the cases) More...
 
role_collection const & roles () const
 get the roles More...
 
void setName (std::string name)
 set the name of the candidate More...
 
void setRoles (const role_collection &roles)
 set the roles More...
 
 ~CompositeCandidate () override
 destructor More...
 
- Public Member Functions inherited from reco::LeafCandidate
Vector boostToCM () const final
 
int charge () const final
 electric charge More...
 
void construct (int qx3, float pt, float eta, float phi, float mass, const Point &vtx, int pdgId, int status)
 
double energy () const final
 energy More...
 
double et () const final
 transverse energy More...
 
double et2 () const final
 transverse energy squared (use this for cut!) More...
 
double eta () const final
 momentum pseudorapidity More...
 
void fillVertexCovariance (CovarianceMatrix &v) const override
 fill SMatrix More...
 
template<typename T >
T get () const
 get a component More...
 
template<typename T , typename Tag >
T get () const
 get a component More...
 
template<typename T >
T get (size_type i) const
 get a component More...
 
template<typename T , typename Tag >
T get (size_type i) const
 get a component More...
 
bool hasMasterClone () const override
 
bool hasMasterClonePtr () const override
 
bool isCaloMuon () const override
 
bool isConvertedPhoton () const override
 
bool isElectron () const override
 
bool isGlobalMuon () const override
 
bool isJet () const override
 
bool isMuon () const override
 
bool isPhoton () const override
 
bool isStandAloneMuon () const override
 
bool isTrackerMuon () const override
 
 LeafCandidate ()
 
 LeafCandidate (const Candidate &c)
 
template<typename... Args>
 LeafCandidate (Args &&...args)
 
 LeafCandidate (LeafCandidate &rh)
 
 LeafCandidate (LeafCandidate &&)=default
 
 LeafCandidate (LeafCandidate const &)=default
 
bool longLived () const final
 is long lived? More...
 
double mass () const final
 mass More...
 
bool massConstraint () const final
 do mass constraint? More...
 
double massSqr () const final
 mass squared More...
 
const CandidateBaseRefmasterClone () const override
 
const CandidatePtrmasterClonePtr () const override
 
template<typename Ref >
Ref masterRef () const
 cast master clone reference to a concrete type More...
 
Vector momentum () const final
 spatial momentum vector More...
 
const Candidatemother (size_type) const override
 return mother at a given position (throws an exception) More...
 
double mt () const final
 transverse mass More...
 
double mtSqr () const final
 transverse mass squared More...
 
template<typename T >
size_type numberOf () const
 number of components More...
 
template<typename T , typename Tag >
size_type numberOf () const
 number of components More...
 
size_t numberOfDaughters () const override
 number of daughters More...
 
size_t numberOfMothers () const override
 number of mothers More...
 
size_t numberOfSourceCandidatePtrs () const override
 
LeafCandidateoperator= (LeafCandidate &&)=default
 
LeafCandidateoperator= (LeafCandidate const &)=default
 
double p () const final
 magnitude of momentum vector More...
 
const LorentzVectorp4 () const final
 four-momentum Lorentz vector More...
 
int pdgId () const final
 PDG identifier. More...
 
double phi () const final
 momentum azimuthal angle More...
 
const PolarLorentzVectorpolarP4 () const final
 four-momentum Lorentz vector More...
 
double pt () const final
 transverse momentum More...
 
double px () const final
 x coordinate of momentum vector More...
 
double py () const final
 y coordinate of momentum vector More...
 
double pz () const final
 z coordinate of momentum vector More...
 
double rapidity () const final
 rapidity More...
 
void setCharge (Charge q) final
 set electric charge More...
 
void setLongLived () final
 
void setMass (double m) final
 set particle mass More...
 
void setMassConstraint () final
 
void setP4 (const LorentzVector &p4) final
 set 4-momentum More...
 
void setP4 (const PolarLorentzVector &p4) final
 set 4-momentum More...
 
void setPdgId (int pdgId) final
 
void setPz (double pz) final
 
void setStatus (int status) final
 set status word More...
 
void setThreeCharge (Charge qx3) final
 set electric charge More...
 
void setVertex (const Point &vertex) override
 set vertex More...
 
CandidatePtr sourceCandidatePtr (size_type i) const override
 
int status () const final
 status word More...
 
double theta () const final
 momentum polar angle More...
 
int threeCharge () const final
 electric charge More...
 
const Pointvertex () const override
 vertex position (overwritten by PF...) More...
 
double vertexChi2 () const override
 chi-squares More...
 
double vertexCovariance (int i, int j) const override
 (i, j)-th element of error matrix, i, j = 0, ... 2 More...
 
CovarianceMatrix vertexCovariance () const final
 return SMatrix More...
 
double vertexNdof () const override
 
double vertexNormalizedChi2 () const override
 chi-squared divided by n.d.o.f. More...
 
double vx () const override
 x coordinate of vertex position More...
 
double vy () const override
 y coordinate of vertex position More...
 
double vz () const override
 z coordinate of vertex position More...
 
double y () const final
 rapidity More...
 
 ~LeafCandidate () override
 destructor More...
 
- Public Member Functions inherited from reco::Candidate
const_iterator begin () const
 first daughter const_iterator More...
 
iterator begin ()
 first daughter iterator More...
 
virtual const TrackbestTrack () const
 
 Candidate ()
 default constructor More...
 
virtual float dxyError () const
 uncertainty on dxy More...
 
virtual float dzError () const
 uncertainty on dz More...
 
const_iterator end () const
 last daughter const_iterator More...
 
iterator end ()
 last daughter iterator More...
 
template<typename T >
T get () const
 get a component More...
 
template<typename T , typename Tag >
T get () const
 get a component More...
 
template<typename T >
T get (size_type i) const
 get a component More...
 
template<typename T , typename Tag >
T get (size_type i) const
 get a component More...
 
template<typename Ref >
Ref masterRef () const
 cast master clone reference to a concrete type More...
 
template<typename T >
size_type numberOf () const
 number of components More...
 
template<typename T , typename Tag >
size_type numberOf () const
 number of components More...
 
virtual void setSourceCandidatePtr (const CandidatePtr &ptr)
 Set the ptr to the source Candidate. More...
 
virtual ~Candidate ()
 destructor More...
 

Private Attributes

std::string name_
 
role_collection roles_
 

Additional Inherited Members

Detailed Description

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

Author
Luca Lista, INFN

Definition at line 21 of file NamedCompositeCandidate.h.

Member Typedef Documentation

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

Definition at line 23 of file NamedCompositeCandidate.h.

Constructor & Destructor Documentation

reco::NamedCompositeCandidate::NamedCompositeCandidate ( std::string  name = "")
inline

default constructor

Definition at line 26 of file NamedCompositeCandidate.h.

Referenced by clone(), and NamedCompositeCandidate().

CompositeCandidate(std::string name="")
default constructor
reco::NamedCompositeCandidate::NamedCompositeCandidate ( std::string  name,
const role_collection roles 
)
inline

Definition at line 27 of file NamedCompositeCandidate.h.

28  :
const NamedCompositeCandidate::role_collection & roles() const
CompositeCandidate(std::string name="")
default constructor
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 31 of file NamedCompositeCandidate.h.

References clone(), NamedCompositeCandidate(), reco::LeafCandidate::p(), AlCaHLTBitMon_QueryRunRegistry::string, and ~NamedCompositeCandidate().

34  :
35  CompositeCandidate( q, p4, vtx, pdgId, status, integerCharge ),
36  name_ (name), roles_(roles) { }
int pdgId() const final
PDG identifier.
const NamedCompositeCandidate::role_collection & roles() const
CompositeCandidate(std::string name="")
default constructor
const LorentzVector & p4() const final
four-momentum Lorentz vector
Definition: LeafCandidate.h:99
int status() const final
status word
NamedCompositeCandidate::NamedCompositeCandidate ( std::string  name,
const role_collection roles,
const Candidate p 
)

constructor from values

Definition at line 8 of file NamedCompositeCandidate.cc.

References Exception, reco::CompositeCandidate::numberOfDaughters(), and roles_.

10  :
12  name_(name),
13  roles_(roles)
14 {
15 
16  // Check if there are the same number of daughters and roles
17  int N1 = roles_.size();
18  int N2 = numberOfDaughters();
19 
20  if ( N1 != N2 ) {
21  throw cms::Exception("InvalidReference")
22  << "NamedCompositeCandidate constructor: Number of roles and daughters differ, this is an error. Name = " << name << "\n";
23  }
24 }
const NamedCompositeCandidate::role_collection & roles() const
CompositeCandidate(std::string name="")
default constructor
size_type numberOfDaughters() const override
number of daughters
NamedCompositeCandidate::~NamedCompositeCandidate ( )
override

Member Function Documentation

void NamedCompositeCandidate::addDaughter ( const Candidate cand,
const std::string &  s 
)

Definition at line 92 of file NamedCompositeCandidate.cc.

References reco::CompositeCandidate::addDaughter(), reco::Candidate::begin(), EnergyCorrector::c, alignmentValidation::c1, reco::Candidate::clone(), reco::Candidate::end(), Exception, spr::find(), eostools::move(), roles_, and setName().

Referenced by daughter().

93 {
94 
95  role_collection::iterator begin = roles_.begin(), end = roles_.end();
96  bool isFound = ( find( begin, end, s) != end );
97  if ( isFound ) {
98  throw cms::Exception("InvalidReference")
99  << "NamedCompositeCandidate::addDaughter: Already have role with name " << s
100  << ", please clearDaughters, or use a new name\n";
101  }
102 
103  roles_.push_back( s );
104  std::unique_ptr<Candidate> c( cand.clone() );
105  NamedCompositeCandidate * c1 = dynamic_cast<NamedCompositeCandidate*>(&*c);
106  if ( c1 != nullptr ) {
107  c1->setName( s );
108  }
110 }
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
virtual Candidate * clone() const =0
returns a clone of the Candidate object
const_iterator end() const
last daughter const_iterator
Definition: Candidate.h:146
void addDaughter(const Candidate &, const std::string &s="")
add a clone of the passed candidate as daughter
const_iterator begin() const
first daughter const_iterator
Definition: Candidate.h:144
def move(src, dest)
Definition: eostools.py:511
void NamedCompositeCandidate::addDaughter ( std::unique_ptr< Candidate cand,
const std::string &  s 
)

Definition at line 112 of file NamedCompositeCandidate.cc.

References reco::CompositeCandidate::addDaughter(), reco::Candidate::begin(), alignmentValidation::c1, reco::Candidate::end(), Exception, spr::find(), eostools::move(), roles_, and setName().

113 {
114  role_collection::iterator begin = roles_.begin(), end = roles_.end();
115  bool isFound = ( find( begin, end, s) != end );
116  if ( isFound ) {
117  throw cms::Exception("InvalidReference")
118  << "NamedCompositeCandidate::addDaughter: Already have role with name " << s
119  << ", please clearDaughters, or use a new name\n";
120  }
121 
122  roles_.push_back( s );
124  if ( c1 != nullptr ) {
125  c1->setName( s );
126  }
128 }
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
const_iterator end() const
last daughter const_iterator
Definition: Candidate.h:146
void addDaughter(const Candidate &, const std::string &s="")
add a clone of the passed candidate as daughter
const_iterator begin() const
first daughter const_iterator
Definition: Candidate.h:144
def move(src, dest)
Definition: eostools.py:511
void NamedCompositeCandidate::applyRoles ( )

Definition at line 30 of file NamedCompositeCandidate.cc.

References EnergyCorrector::c, alignmentValidation::c1, reco::CompositeCandidate::daughter(), Exception, mps_fire::i, reco::CompositeCandidate::numberOfDaughters(), roles_, setName(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by clearRoles().

31 {
32 
33  // Check if there are the same number of daughters and roles
34  int N1 = roles_.size();
35  int N2 = numberOfDaughters();
36  if ( N1 != N2 ) {
37  throw cms::Exception("InvalidReference")
38  << "NamedCompositeCandidate::applyRoles : Number of roles and daughters differ, this is an error.\n";
39  }
40  // Set up the daughter roles
41  for ( int i = 0 ; i < N1; ++i ) {
42  std::string role = roles_[i];
44 
46  if ( c1 != nullptr ) {
47  c1->setName( role );
48  }
49  }
50 }
const Candidate * daughter(size_type) const override
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode) ...
size_type numberOfDaughters() const override
number of daughters
void reco::NamedCompositeCandidate::clearDaughters ( )
inline
void reco::NamedCompositeCandidate::clearRoles ( )
inline

Definition at line 65 of file NamedCompositeCandidate.h.

References applyRoles(), and roles_.

Referenced by ~NamedCompositeCandidate().

65 { roles_.clear(); }
NamedCompositeCandidate * NamedCompositeCandidate::clone ( void  ) const
overridevirtual

returns a clone of the candidate

Reimplemented from reco::CompositeCandidate.

Definition at line 28 of file NamedCompositeCandidate.cc.

References NamedCompositeCandidate().

Referenced by NamedCompositeCandidate().

28 { return new NamedCompositeCandidate( * this ); }
NamedCompositeCandidate(std::string name="")
default constructor
Candidate * NamedCompositeCandidate::daughter ( const std::string &  s)
overridevirtual

return daughter with a specified role name

Reimplemented from reco::CompositeCandidate.

Definition at line 52 of file NamedCompositeCandidate.cc.

References Exception, runEdmFileComparison::found, mps_fire::i, N, and roles_.

Referenced by daughter(), and setRoles().

53 {
54  int ret = -1;
55  int i = 0, N = roles_.size();
56  bool found = false;
57  for ( ; i < N && !found; ++i ) {
58  if ( s == roles_[i] ) {
59  found = true;
60  ret = i;
61  }
62  }
63 
64  if ( ret < 0 ) {
65  throw cms::Exception("InvalidReference")
66  << "NamedCompositeCandidate::daughter: Cannot find role " << s << "\n";
67  }
68 
69  return daughter(ret);
70 }
Candidate * daughter(const std::string &s) override
return daughter with a specified role name
#define N
Definition: blowfish.cc:9
const Candidate * NamedCompositeCandidate::daughter ( const std::string &  s) const
overridevirtual

return daughter with a specified role name

Reimplemented from reco::CompositeCandidate.

Definition at line 72 of file NamedCompositeCandidate.cc.

References daughter(), Exception, runEdmFileComparison::found, mps_fire::i, N, and roles_.

73 {
74  int ret = -1;
75  int i = 0, N = roles_.size();
76  bool found = false;
77  for ( ; i < N && !found; ++i ) {
78  if ( s == roles_[i] ) {
79  found = true;
80  ret = i;
81  }
82  }
83 
84  if ( ret < 0 ) {
85  throw cms::Exception("InvalidReference")
86  << "NamedCompositeCandidate::daughter: Cannot find role " << s << "\n";
87  }
88 
89  return daughter(ret);
90 }
Candidate * daughter(const std::string &s) override
return daughter with a specified role name
#define N
Definition: blowfish.cc:9
Candidate* reco::NamedCompositeCandidate::daughter ( size_type  i)
inlineoverridevirtual

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

Reimplemented from reco::CompositeCandidate.

Definition at line 58 of file NamedCompositeCandidate.h.

References reco::CompositeCandidate::daughter().

const Candidate * daughter(size_type) const override
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode) ...
const Candidate* reco::NamedCompositeCandidate::daughter ( size_type  i) const
inlineoverridevirtual

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

Reimplemented from reco::CompositeCandidate.

Definition at line 59 of file NamedCompositeCandidate.h.

References addDaughter(), reco::CompositeCandidate::daughter(), and AlCaHLTBitMon_QueryRunRegistry::string.

const Candidate * daughter(size_type) const override
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode) ...
std::string reco::NamedCompositeCandidate::name ( ) const
inline
const NamedCompositeCandidate::role_collection& reco::NamedCompositeCandidate::roles ( ) const
inline

Definition at line 51 of file NamedCompositeCandidate.h.

References roles_.

Referenced by setRoles().

51 { return roles_;}
void reco::NamedCompositeCandidate::setName ( std::string  n)
inline
void reco::NamedCompositeCandidate::setRoles ( const NamedCompositeCandidate::role_collection roles)
inline

Definition at line 53 of file NamedCompositeCandidate.h.

References daughter(), roles(), roles_, alignCSCRings::s, and AlCaHLTBitMon_QueryRunRegistry::string.

53 { roles_.clear(); roles_ = roles; }
const NamedCompositeCandidate::role_collection & roles() const

Member Data Documentation

std::string reco::NamedCompositeCandidate::name_
private

Definition at line 69 of file NamedCompositeCandidate.h.

Referenced by name(), and setName().

role_collection reco::NamedCompositeCandidate::roles_
private