Particle.hh
// -*- C++ -*-
#ifndef RIVET_Particle_HH
#define RIVET_Particle_HH
#include "Rivet/Rivet.hh"
#include "Rivet/Particle.fhh"
#include "Rivet/ParticleBase.hh"
#include "Rivet/ParticleName.hh"
#include "Rivet/Math/Vectors.hh"
#include "Rivet/Tools/Logging.hh"
namespace Rivet {
class Particle : public ParticleBase {
public:
Particle()
: ParticleBase(),
_original(0), _id(0), _momentum()
{ }
Particle(PdgId pid, const FourMomentum& mom)
: ParticleBase(),
_original(0), _id(pid), _momentum(mom)
{ }
Particle(const GenParticle& gp)
: ParticleBase(),
_original(&gp), _id(gp.pdg_id()),
_momentum(gp.momentum())
{ }
public:
const GenParticle& genParticle() const {
assert(_original);
return *_original;
}
bool hasGenParticle() const {
return bool(_original);
}
PdgId pdgId() const {
return _id;
}
Particle& setMomentum(const FourMomentum& momentum) {
_momentum = momentum;
return *this;
}
const FourMomentum& momentum() const {
return _momentum;
}
double energy() const {
return momentum().E();
}
double mass() const {
return momentum().mass();
}
// /// The charge of this Particle.
// double charge() const {
// return PID::charge(*this);
// }
// /// Three times the charge of this Particle (i.e. integer multiple of smallest quark charge).
// int threeCharge() const {
// return PID::threeCharge(*this);
// }
bool hasAncestor(PdgId pdg_id) const;
bool fromDecay() const;
private:
const GenParticle* _original;
PdgId _id;
FourMomentum _momentum;
};
inline std::string toString(const ParticlePair& pair) {
stringstream out;
out << "["
<< toParticleName(pair.first.pdgId()) << " @ "
<< pair.first.momentum().E()/GeV << " GeV, "
<< toParticleName(pair.second.pdgId()) << " @ "
<< pair.second.momentum().E()/GeV << " GeV]";
return out.str();
}
inline std::ostream& operator<<(std::ostream& os, const ParticlePair& pp) {
os << toString(pp);
return os;
}
inline bool cmpParticleByPt(const Particle& a, const Particle& b) {
return a.momentum().pT() > b.momentum().pT();
}
inline bool cmpParticleByAscPt(const Particle& a, const Particle& b) {
return a.momentum().pT() < b.momentum().pT();
}
inline bool cmpParticleByP(const Particle& a, const Particle& b) {
return a.momentum().vector3().mod() > b.momentum().vector3().mod();
}
inline bool cmpParticleByAscP(const Particle& a, const Particle& b) {
return a.momentum().vector3().mod() < b.momentum().vector3().mod();
}
inline bool cmpParticleByEt(const Particle& a, const Particle& b) {
return a.momentum().Et() > b.momentum().Et();
}
inline bool cmpParticleByAscEt(const Particle& a, const Particle& b) {
return a.momentum().Et() < b.momentum().Et();
}
inline bool cmpParticleByE(const Particle& a, const Particle& b) {
return a.momentum().E() > b.momentum().E();
}
inline bool cmpParticleByAscE(const Particle& a, const Particle& b) {
return a.momentum().E() < b.momentum().E();
}
inline bool cmpParticleByDescPseudorapidity(const Particle& a, const Particle& b) {
return a.momentum().pseudorapidity() > b.momentum().pseudorapidity();
}
inline bool cmpParticleByAscPseudorapidity(const Particle& a, const Particle& b) {
return a.momentum().pseudorapidity() < b.momentum().pseudorapidity();
}
inline bool cmpParticleByDescAbsPseudorapidity(const Particle& a, const Particle& b) {
return fabs(a.momentum().pseudorapidity()) > fabs(b.momentum().pseudorapidity());
}
inline bool cmpParticleByAscAbsPseudorapidity(const Particle& a, const Particle& b) {
return fabs(a.momentum().pseudorapidity()) < fabs(b.momentum().pseudorapidity());
}
inline bool cmpParticleByDescRapidity(const Particle& a, const Particle& b) {
return a.momentum().rapidity() > b.momentum().rapidity();
}
inline bool cmpParticleByAscRapidity(const Particle& a, const Particle& b) {
return a.momentum().rapidity() < b.momentum().rapidity();
}
inline bool cmpParticleByDescAbsRapidity(const Particle& a, const Particle& b) {
return fabs(a.momentum().rapidity()) > fabs(b.momentum().rapidity());
}
inline bool cmpParticleByAscAbsRapidity(const Particle& a, const Particle& b) {
return fabs(a.momentum().rapidity()) < fabs(b.momentum().rapidity());
}
inline double deltaR(const Particle& p1, const Particle& p2,
RapScheme scheme = PSEUDORAPIDITY) {
return deltaR(p1.momentum(), p2.momentum(), scheme);
}
inline double deltaR(const Particle& p, const FourMomentum& v,
RapScheme scheme = PSEUDORAPIDITY) {
return deltaR(p.momentum(), v, scheme);
}
inline double deltaR(const Particle& p, const FourVector& v,
RapScheme scheme = PSEUDORAPIDITY) {
return deltaR(p.momentum(), v, scheme);
}
inline double deltaR(const Particle& p, const Vector3& v) {
return deltaR(p.momentum(), v);
}
inline double deltaR(const Particle& p, double eta, double phi) {
return deltaR(p.momentum(), eta, phi);
}
inline double deltaR(const FourMomentum& v, const Particle& p,
RapScheme scheme = PSEUDORAPIDITY) {
return deltaR(v, p.momentum(), scheme);
}
inline double deltaR(const FourVector& v, const Particle& p,
RapScheme scheme = PSEUDORAPIDITY) {
return deltaR(v, p.momentum(), scheme);
}
inline double deltaR(const Vector3& v, const Particle& p) {
return deltaR(v, p.momentum());
}
inline double deltaR(double eta, double phi, const Particle& p) {
return deltaR(eta, phi, p.momentum());
}
inline double deltaPhi(const Particle& p1, const Particle& p2) {
return deltaPhi(p1.momentum(), p2.momentum());
}
inline double deltaPhi(const Particle& p, const FourMomentum& v) {
return deltaPhi(p.momentum(), v);
}
inline double deltaPhi(const Particle& p, const FourVector& v) {
return deltaPhi(p.momentum(), v);
}
inline double deltaPhi(const Particle& p, const Vector3& v) {
return deltaPhi(p.momentum(), v);
}
inline double deltaPhi(const Particle& p, double phi) {
return deltaPhi(p.momentum(), phi);
}
inline double deltaPhi(const FourMomentum& v, const Particle& p) {
return deltaPhi(v, p.momentum());
}
inline double deltaPhi(const FourVector& v, const Particle& p) {
return deltaPhi(v, p.momentum());
}
inline double deltaPhi(const Vector3& v, const Particle& p) {
return deltaPhi(v, p.momentum());
}
inline double deltaPhi(double phi, const Particle& p) {
return deltaPhi(phi, p.momentum());
}
inline double deltaEta(const Particle& p1, const Particle& p2) {
return deltaEta(p1.momentum(), p2.momentum());
}
inline double deltaEta(const Particle& p, const FourMomentum& v) {
return deltaEta(p.momentum(), v);
}
inline double deltaEta(const Particle& p, const FourVector& v) {
return deltaEta(p.momentum(), v);
}
inline double deltaEta(const Particle& p, const Vector3& v) {
return deltaEta(p.momentum(), v);
}
inline double deltaEta(const Particle& p, double eta) {
return deltaEta(p.momentum(), eta);
}
inline double deltaEta(const FourMomentum& v, const Particle& p) {
return deltaEta(v, p.momentum());
}
inline double deltaEta(const FourVector& v, const Particle& p) {
return deltaEta(v, p.momentum());
}
inline double deltaEta(const Vector3& v, const Particle& p) {
return deltaEta(v, p.momentum());
}
inline double deltaEta(double eta, const Particle& p) {
return deltaEta(eta, p.momentum());
}
}
#endif
Rivet
Definition: MC_JetAnalysis.hh:9
Rivet::FourMomentum::pT
double pT() const
Calculate the transverse momentum .
Definition: Vector4.hh:410
Rivet::cmpParticleByAscP
bool cmpParticleByAscP(const Particle &a, const Particle &b)
Sort by ascending momentum, .
Definition: Particle.hh:166
Rivet::Particle::hasAncestor
bool hasAncestor(PdgId pdg_id) const
Definition: Particle.cc:8
Rivet::cmpParticleByEt
bool cmpParticleByEt(const Particle &a, const Particle &b)
Sort by descending transverse energy, .
Definition: Particle.hh:170
Rivet::Particle::pdgId
PdgId pdgId() const
The PDG ID code for this Particle.
Definition: Particle.hh:56
Rivet::cmpParticleByAscAbsRapidity
bool cmpParticleByAscAbsRapidity(const Particle &a, const Particle &b)
Sort by ascending absolute rapidity, .
Definition: Particle.hh:214
Rivet::FourMomentum::Et
double Et() const
Calculate the transverse energy .
Definition: Vector4.hh:420
Rivet::Particle::Particle
Particle(const GenParticle &gp)
Constructor from a HepMC GenParticle.
Definition: Particle.hh:33
Rivet::cmpParticleByAscRapidity
bool cmpParticleByAscRapidity(const Particle &a, const Particle &b)
Sort by ascending rapidity, .
Definition: Particle.hh:206
Rivet::phi
double phi(const Vector3 &v, const PhiMapping mapping=ZERO_2PI)
Synonym for azimuthalAngle.
Definition: Vector3.hh:281
Rivet::FourMomentum::rapidity
double rapidity() const
Calculate the rapidity.
Definition: Vector4.hh:400
Rivet::Particle
Representation of particles from a HepMC::GenEvent.
Definition: Particle.hh:16
Rivet::Particle::mass
double mass() const
The mass of this Particle.
Definition: Particle.hh:78
Rivet::FourVector::pseudorapidity
double pseudorapidity() const
Pseudorapidity (defined purely by the 3-vector components)
Definition: Vector4.hh:129
Rivet::cmpParticleByAscPt
bool cmpParticleByAscPt(const Particle &a, const Particle &b)
Sort by ascending transverse momentum, .
Definition: Particle.hh:158
Rivet::Particle::hasGenParticle
bool hasGenParticle() const
Check if the particle corresponds to a GenParticle.
Definition: Particle.hh:50
Rivet::cmpParticleByAscE
bool cmpParticleByAscE(const Particle &a, const Particle &b)
Sort by ascending energy, .
Definition: Particle.hh:182
Rivet::cmpParticleByDescRapidity
bool cmpParticleByDescRapidity(const Particle &a, const Particle &b)
Sort by descending rapidity, .
Definition: Particle.hh:202
Rivet::FourMomentum::mass
double mass() const
Get the mass (the Lorentz self-invariant).
Definition: Vector4.hh:384
Rivet::cmpParticleByDescAbsRapidity
bool cmpParticleByDescAbsRapidity(const Particle &a, const Particle &b)
Sort by descending absolute rapidity, .
Definition: Particle.hh:210
Rivet::Particle::energy
double energy() const
The energy of this Particle.
Definition: Particle.hh:73
Rivet::FourVector
Specialisation of VectorN to a general (non-momentum) Lorentz 4-vector.
Definition: Vector4.hh:20
Rivet::cmpParticleByAscPseudorapidity
bool cmpParticleByAscPseudorapidity(const Particle &a, const Particle &b)
Sort by ascending pseudorapidity, .
Definition: Particle.hh:190
Rivet::Particle::momentum
const FourMomentum & momentum() const
The momentum of this Particle.
Definition: Particle.hh:68
Rivet::toParticleName
const std::string & toParticleName(PdgId p)
Print a PdgId as a named string.
Definition: ParticleName.hh:142
Rivet::ParticleBase
Base class for particle-like things like Particle and Jet.
Definition: ParticleBase.hh:11
Rivet::FourMomentum::E
double E() const
Get energy (time component of momentum).
Definition: Vector4.hh:355
Rivet::cmpParticleByAscEt
bool cmpParticleByAscEt(const Particle &a, const Particle &b)
Sort by ascending transverse energy, .
Definition: Particle.hh:174
Rivet::Particle::Particle
Particle()
Definition: Particle.hh:21
Rivet::RapScheme
RapScheme
Enum for rapidity variable to be used in calculating , applying rapidity cuts, etc.
Definition: MathHeader.hh:60
Rivet::FourVector::vector3
Vector3 vector3() const
Get the spatial part of the 4-vector as a 3-vector.
Definition: Vector4.hh:139
Rivet::cmpParticleByDescAbsPseudorapidity
bool cmpParticleByDescAbsPseudorapidity(const Particle &a, const Particle &b)
Sort by descending absolute pseudorapidity, .
Definition: Particle.hh:194
Rivet::cmpParticleByE
bool cmpParticleByE(const Particle &a, const Particle &b)
Sort by descending energy, .
Definition: Particle.hh:178
Rivet::Particle::setMomentum
Particle & setMomentum(const FourMomentum &momentum)
Set the momentum of this Particle.
Definition: Particle.hh:62
Rivet::toString
std::string toString(const AnalysisInfo &ai)
String representation.
Definition: AnalysisInfo.cc:234
Rivet::eta
double eta(const Vector3 &v)
Synonym for pseudorapidity.
Definition: Vector3.hh:299
Rivet::cmpParticleByP
bool cmpParticleByP(const Particle &a, const Particle &b)
Sort by descending momentum, .
Definition: Particle.hh:162
Rivet::cmpParticleByPt
bool cmpParticleByPt(const Particle &a, const Particle &b)
Sort by descending transverse momentum, .
Definition: Particle.hh:154
Rivet::Vector3
Three-dimensional specialisation of Vector.
Definition: Vector3.hh:26
Rivet::cmpParticleByDescPseudorapidity
bool cmpParticleByDescPseudorapidity(const Particle &a, const Particle &b)
Sort by descending pseudorapidity, .
Definition: Particle.hh:186
Rivet::operator<<
std::ostream & operator<<(std::ostream &os, const AnalysisInfo &ai)
Stream an AnalysisInfo as a text description.
Definition: AnalysisInfo.hh:239
Rivet::FourMomentum
Specialized version of the FourVector with momentum/energy functionality.
Definition: Vector4.hh:324
Rivet::Particle::Particle
Particle(PdgId pid, const FourMomentum &mom)
Constructor without GenParticle.
Definition: Particle.hh:27
Rivet::Particle::genParticle
const GenParticle & genParticle() const
Get a const reference to the original GenParticle.
Definition: Particle.hh:43
Rivet::Vector::mod
double mod() const
Calculate the modulus of a vector. .
Definition: VectorN.hh:87
Rivet::Particle::fromDecay
bool fromDecay() const
Determine whether the particle is from a hadron or tau decay.
Definition: Particle.cc:19
Rivet::cmpParticleByAscAbsPseudorapidity
bool cmpParticleByAscAbsPseudorapidity(const Particle &a, const Particle &b)
Sort by ascending absolute pseudorapidity, .
Definition: Particle.hh:198