DESY Hbb Analysis Framework
Public Member Functions | Protected Attributes | Private Types | List of all members
analysis::tools::Candidate Class Reference

#include <Candidate.h>

Inheritance diagram for analysis::tools::Candidate:
analysis::tools::Composite< A, B > analysis::tools::GenJet analysis::tools::GenParticle analysis::tools::Jet analysis::tools::JetTag analysis::tools::L1TJet analysis::tools::L1TMuon analysis::tools::MET analysis::tools::Muon analysis::tools::RecoMuon analysis::tools::RecoTrack analysis::tools::TriggerObject

Public Member Functions

 Candidate ()
 default constructor More...
 
 Candidate (const float &pt, const float &eta, const float &phi, const float &e, const float &q)
 constructor from 4-momentum information More...
 
 Candidate (const float &px, const float &py, const float &pz)
 constructor from 3-momentum information More...
 
 Candidate (const float &px, const float &py, const float &pz, const float &q)
 constructor from 3-momentum and charge information More...
 
float deltaPhi (const Candidate &) const
 returns the deltaPhi between this and another candidate More...
 
float deltaR (const Candidate &) const
 returns the deltaR between this and another candidate More...
 
float e () const
 returns the energy More...
 
void e (const float &)
 sets the energy More...
 
float eta () const
 returns the pseudorapidity More...
 
float m () const
 returns the mass More...
 
float mass () const
 returns the mass More...
 
const Candidatematched (const std::string &name)
 returns the pointer to the matched candidate object More...
 
const Candidatematched (const std::string &name) const
 returns the pointer to the matched candidate object More...
 
virtual bool matchTo (const std::vector< Candidate > *cands, const std::string &name, const float &deltaR=0.5)
 function to match this candidate to another object from a list of pointers with a name More...
 
virtual bool matchTo (const std::vector< Candidate > *cands, const std::string &name, const float &delta_pT, const float &deltaR)
 
TVector3 p3 () const
 returns the 4-momentum (TVector3) More...
 
TLorentzVector p4 () const
 returns the 4-momentum (TLorentzVector) More...
 
void p4 (const TLorentzVector &)
 sets the 4-momentum (TLorentzVector) More...
 
float phi () const
 returns the azimuthal angle More...
 
float pt () const
 returns the transverse momentum More...
 
float px () const
 returns the x component of the momentum More...
 
void px (const float &)
 sets the x component of the momentum More...
 
float py () const
 returns the y component of the momentum More...
 
void py (const float &)
 sets the y component of the momentum More...
 
float pz () const
 returns the z component of the momentum More...
 
void pz (const float &)
 sets the z component of the momentum More...
 
int q () const
 returns the charge More...
 
void q (const float &)
 sets the charge More...
 
void unmatch (const std::string &)
 unmatch a matched candidate object, i.e. set it to nullptr, useful to remove possible duplicated matching More...
 
virtual ~Candidate ()
 destructor More...
 

Protected Attributes

std::map< std::string, const Candidate * > matched_
 map of matched candidates More...
 
TLorentzVector p4_
 the 4-momentum More...
 
float q_
 the charge More...
 

Private Types

typedef std::vector< CandidateCandidates
 

Detailed Description

Definition at line 37 of file Candidate.h.

Member Typedef Documentation

typedef std::vector<Candidate> analysis::tools::Candidate::Candidates
private

Definition at line 38 of file Candidate.h.

Constructor & Destructor Documentation

Candidate::Candidate ( )

default constructor

Definition at line 18 of file Candidate.cc.

References p4_, and q_.

19 {
20  q_ = 0;
21  p4_.SetPtEtaPhiE(0.,0.,0.,0.);
22 }
float q_
the charge
Definition: Candidate.h:112
TLorentzVector p4_
the 4-momentum
Definition: Candidate.h:114
Candidate::Candidate ( const float &  pt,
const float &  eta,
const float &  phi,
const float &  e,
const float &  q 
)

constructor from 4-momentum information

Definition at line 24 of file Candidate.cc.

References p4_, q(), and q_.

25 {
26  q_ = q;
27  p4_.SetPtEtaPhiE(pt,eta,phi,e);
28 }
float eta() const
returns the pseudorapidity
Definition: Candidate.cc:134
float e() const
returns the energy
Definition: Candidate.cc:136
float phi() const
returns the azimuthal angle
Definition: Candidate.cc:135
float q_
the charge
Definition: Candidate.h:112
float pt() const
returns the transverse momentum
Definition: Candidate.cc:133
TLorentzVector p4_
the 4-momentum
Definition: Candidate.h:114
int q() const
returns the charge
Definition: Candidate.cc:139
Candidate::Candidate ( const float &  px,
const float &  py,
const float &  pz 
)

constructor from 3-momentum information

Definition at line 30 of file Candidate.cc.

References p4_, and q_.

31 {
32  q_ = 0;
33  p4_.SetXYZM(px,py,pz,0.);
34 }
float py() const
returns the y component of the momentum
Definition: Candidate.cc:131
float px() const
returns the x component of the momentum
Definition: Candidate.cc:130
float pz() const
returns the z component of the momentum
Definition: Candidate.cc:132
float q_
the charge
Definition: Candidate.h:112
TLorentzVector p4_
the 4-momentum
Definition: Candidate.h:114
Candidate::Candidate ( const float &  px,
const float &  py,
const float &  pz,
const float &  q 
)

constructor from 3-momentum and charge information

Definition at line 36 of file Candidate.cc.

References p4_, q(), and q_.

37 {
38  q_ = q;
39  p4_.SetXYZM(px,py,pz,0.);
40 }
float py() const
returns the y component of the momentum
Definition: Candidate.cc:131
float px() const
returns the x component of the momentum
Definition: Candidate.cc:130
float pz() const
returns the z component of the momentum
Definition: Candidate.cc:132
float q_
the charge
Definition: Candidate.h:112
TLorentzVector p4_
the 4-momentum
Definition: Candidate.h:114
int q() const
returns the charge
Definition: Candidate.cc:139
Candidate::~Candidate ( )
virtual

destructor

Definition at line 43 of file Candidate.cc.

44 {
45 }

Member Function Documentation

float Candidate::deltaPhi ( const Candidate cand) const

returns the deltaPhi between this and another candidate

Definition at line 141 of file Candidate.cc.

References p4(), and p4_.

141 { return p4_.DeltaPhi(cand.p4()) ;}
TLorentzVector p4() const
returns the 4-momentum (TLorentzVector)
Definition: Candidate.cc:143
TLorentzVector p4_
the 4-momentum
Definition: Candidate.h:114
float Candidate::deltaR ( const Candidate cand) const

returns the deltaR between this and another candidate

Definition at line 140 of file Candidate.cc.

References p4(), and p4_.

Referenced by analysis::tools::Jet::addMuon(), analysis::tools::Jet::jerMatch(), main(), and matchTo().

140 { return p4_.DeltaR(cand.p4()) ;}
TLorentzVector p4() const
returns the 4-momentum (TLorentzVector)
Definition: Candidate.cc:143
TLorentzVector p4_
the 4-momentum
Definition: Candidate.h:114
float Candidate::e ( ) const

returns the energy

Definition at line 136 of file Candidate.cc.

References p4_.

Referenced by analysis::tools::Jet::applyBjetRegression(), main(), and analysis::tools::BaseAnalyser::triggerEmulation().

136 { return p4_.E() ; }
TLorentzVector p4_
the 4-momentum
Definition: Candidate.h:114
void Candidate::e ( const float &  e)

sets the energy

Definition at line 160 of file Candidate.cc.

References p4_.

160 { p4_.SetE(e); }
float e() const
returns the energy
Definition: Candidate.cc:136
TLorentzVector p4_
the 4-momentum
Definition: Candidate.h:114
float Candidate::eta ( ) const
float Candidate::m ( ) const
float Candidate::mass ( ) const

returns the mass

Definition at line 138 of file Candidate.cc.

References p4_.

138 { return p4_.M() ; }
TLorentzVector p4_
the 4-momentum
Definition: Candidate.h:114
const Candidate * Candidate::matched ( const std::string &  name)

returns the pointer to the matched candidate object

Definition at line 147 of file Candidate.cc.

References matched_, and nano_94X_2017_rereco31Mar18-v1::name.

Referenced by analysis::tools::Jet::jerMatch(), and main().

147 { return matched_[name]; }
std::map< std::string, const Candidate * > matched_
map of matched candidates
Definition: Candidate.h:116
const Candidate * Candidate::matched ( const std::string &  name) const

returns the pointer to the matched candidate object

Definition at line 148 of file Candidate.cc.

References matched_.

148 { return matched_.find(name) != matched_.end() ? matched_.find(name)->second : 0; }
std::map< std::string, const Candidate * > matched_
map of matched candidates
Definition: Candidate.h:116
bool Candidate::matchTo ( const std::vector< Candidate > *  cands,
const std::string &  name,
const float &  deltaR = 0.5 
)
virtual

function to match this candidate to another object from a list of pointers with a name

Definition at line 51 of file Candidate.cc.

References deltaR(), matched_, nano_94X_2017_rereco31Mar18-v1::name, and naf_submit::status().

52 {
53  bool status = false;
54 
55 
56  if ( ! cands )
57  {
58  this -> matched_[name] = nullptr;
59  return status;
60  }
61 
62  const Candidate * cand = nullptr;
63  const Candidate * nearcand = nullptr;
64  float minDeltaR = 100.;
65  for ( size_t i = 0; i < cands->size() ; ++i )
66  {
67  cand = &(cands->at(i));
68  if(this->deltaR(*cand) < minDeltaR)
69  {
70  minDeltaR = this->deltaR(*cand);
71  nearcand = cand;
72  }
73  }
74 
75  if(minDeltaR < deltaR)
76  {
77  this->matched_[name]=nearcand;
78  status = true;
79  }
80 
81  else {
82  this -> matched_[name] = nullptr;
83  }
84 
85  return status;
86 }
def status(submission_dir, failed_only=False)
Definition: naf_submit.py:362
std::map< std::string, const Candidate * > matched_
map of matched candidates
Definition: Candidate.h:116
float deltaR(const Candidate &) const
returns the deltaR between this and another candidate
Definition: Candidate.cc:140
bool Candidate::matchTo ( const std::vector< Candidate > *  cands,
const std::string &  name,
const float &  delta_pT,
const float &  deltaR 
)
virtual

Definition at line 88 of file Candidate.cc.

References deltaR(), matched_, nano_94X_2017_rereco31Mar18-v1::name, pt(), and naf_submit::status().

89 {
90  bool status = false;
91 
92 
93  if ( ! cands )
94  {
95  this -> matched_[name] = nullptr;
96  return status;
97  }
98 
99  const Candidate * cand = nullptr;
100  const Candidate * nearcand = nullptr;
101  float minDeltaR = deltaR + 1; // Assign more real value;
102  float dpT = 0.;
103  float dpTmin = delta_pT + 1;
104  for ( size_t i = 0; i < cands->size() ; ++i )
105  {
106  cand = &(cands->at(i));
107  dpT = std::abs(this->pt() - cand->pt());
108  if(this->deltaR(*cand) < minDeltaR && dpT < dpTmin)
109  {
110  minDeltaR = this->deltaR(*cand);
111  dpTmin = dpT;
112  nearcand = cand;
113  }
114  }
115 
116  if(minDeltaR < deltaR && dpTmin < delta_pT)
117  {
118  this->matched_[name]=nearcand;
119  status = true;
120  }
121 
122  else {
123  this -> matched_[name] = nullptr;
124  }
125 
126  return status;
127 }
def status(submission_dir, failed_only=False)
Definition: naf_submit.py:362
std::map< std::string, const Candidate * > matched_
map of matched candidates
Definition: Candidate.h:116
float pt() const
returns the transverse momentum
Definition: Candidate.cc:133
float deltaR(const Candidate &) const
returns the deltaR between this and another candidate
Definition: Candidate.cc:140
TVector3 Candidate::p3 ( ) const

returns the 4-momentum (TVector3)

Definition at line 144 of file Candidate.cc.

References p4_.

144 { return p4_.Vect(); }
TLorentzVector p4_
the 4-momentum
Definition: Candidate.h:114
TLorentzVector Candidate::p4 ( ) const

returns the 4-momentum (TLorentzVector)

Definition at line 143 of file Candidate.cc.

References p4_.

Referenced by analysis::tools::Jet::addFSR(), analysis::tools::Collection< Object >::associatePartons(), analysis::tools::Jet::associatePartons(), deltaPhi(), deltaR(), and p4().

143 { return p4_; }
TLorentzVector p4_
the 4-momentum
Definition: Candidate.h:114
void Candidate::p4 ( const TLorentzVector &  p4)

sets the 4-momentum (TLorentzVector)

Definition at line 156 of file Candidate.cc.

References p4(), and p4_.

156 { p4_ = p4; }
TLorentzVector p4() const
returns the 4-momentum (TLorentzVector)
Definition: Candidate.cc:143
TLorentzVector p4_
the 4-momentum
Definition: Candidate.h:114
float Candidate::phi ( ) const

returns the azimuthal angle

Definition at line 135 of file Candidate.cc.

References p4_.

Referenced by analysis::tools::Jet::applyBjetRegression(), analysis::tools::JetAnalyser::fillJetHistograms(), main(), and analysis::tools::BaseAnalyser::triggerEmulation().

135 { return p4_.Phi(); }
TLorentzVector p4_
the 4-momentum
Definition: Candidate.h:114
float Candidate::pt ( ) const
float Candidate::px ( ) const

returns the x component of the momentum

Definition at line 130 of file Candidate.cc.

References p4_.

Referenced by analysis::tools::MET::genP().

130 { return p4_.Px() ; }
TLorentzVector p4_
the 4-momentum
Definition: Candidate.h:114
void Candidate::px ( const float &  px)

sets the x component of the momentum

Definition at line 157 of file Candidate.cc.

References p4_.

157 { p4_.SetPx(px); }
float px() const
returns the x component of the momentum
Definition: Candidate.cc:130
TLorentzVector p4_
the 4-momentum
Definition: Candidate.h:114
float Candidate::py ( ) const

returns the y component of the momentum

Definition at line 131 of file Candidate.cc.

References p4_.

Referenced by analysis::tools::MET::genP().

131 { return p4_.Py() ; }
TLorentzVector p4_
the 4-momentum
Definition: Candidate.h:114
void Candidate::py ( const float &  py)

sets the y component of the momentum

Definition at line 158 of file Candidate.cc.

References p4_.

158 { p4_.SetPy(py); }
float py() const
returns the y component of the momentum
Definition: Candidate.cc:131
TLorentzVector p4_
the 4-momentum
Definition: Candidate.h:114
float Candidate::pz ( ) const

returns the z component of the momentum

Definition at line 132 of file Candidate.cc.

References p4_.

Referenced by analysis::tools::MET::genP().

132 { return p4_.Pz() ; }
TLorentzVector p4_
the 4-momentum
Definition: Candidate.h:114
void Candidate::pz ( const float &  pz)

sets the z component of the momentum

Definition at line 159 of file Candidate.cc.

References p4_.

159 { p4_.SetPy(pz); }
float pz() const
returns the z component of the momentum
Definition: Candidate.cc:132
TLorentzVector p4_
the 4-momentum
Definition: Candidate.h:114
int Candidate::q ( ) const

returns the charge

Definition at line 139 of file Candidate.cc.

References q_.

Referenced by Candidate(), main(), and q().

139 { return q_; }
float q_
the charge
Definition: Candidate.h:112
void Candidate::q ( const float &  q)

sets the charge

Definition at line 161 of file Candidate.cc.

References q(), and q_.

161 { q_ = q; }
float q_
the charge
Definition: Candidate.h:112
int q() const
returns the charge
Definition: Candidate.cc:139
void Candidate::unmatch ( const std::string &  name)

unmatch a matched candidate object, i.e. set it to nullptr, useful to remove possible duplicated matching

Definition at line 150 of file Candidate.cc.

References matched_, and nano_94X_2017_rereco31Mar18-v1::name.

151 {
152  matched_[name] = nullptr;
153 }
std::map< std::string, const Candidate * > matched_
map of matched candidates
Definition: Candidate.h:116

Member Data Documentation

std::map<std::string, const Candidate * > analysis::tools::Candidate::matched_
protected

map of matched candidates

Definition at line 116 of file Candidate.h.

Referenced by matched(), matchTo(), and unmatch().

TLorentzVector analysis::tools::Candidate::p4_
protected
float analysis::tools::Candidate::q_
protected

the charge

Definition at line 112 of file Candidate.h.

Referenced by Candidate(), analysis::tools::Composite< A, B >::Composite(), and q().


The documentation for this class was generated from the following files: