2#ifndef RIVET_Particle_HH
3#define RIVET_Particle_HH
5#include "Rivet/Particle.fhh"
6#include "Rivet/ParticleBase.hh"
7#include "Rivet/Config/RivetCommon.hh"
8#include "Rivet/Tools/Cuts.hh"
9#include "Rivet/Tools/Utils.hh"
10#include "Rivet/Tools/RivetFastJet.hh"
11#include "Rivet/Math/LorentzTrans.hh"
27 using base = std::vector<Particle>;
30 Particles(
const std::vector<Particle>& vps);
31 FourMomenta moms()
const;
33 operator FourMomenta ()
const {
return moms(); }
34 operator PseudoJets ()
const {
return pseudojets(); }
63 _original(nullptr), _id(PID::ANY), _isDirect(4,
std::make_pair(false,false))
69 _original(gp), _id(
pid),
70 _momentum(
mom), _origin(pos),
71 _isDirect(4,
std::make_pair(false,false))
82 _original(gp), _id(gp->pdg_id()),
84 _isDirect(4,
std::make_pair(false,false))
86 ConstGenVertexPtr vprod = gp->production_vertex();
87 if (vprod !=
nullptr) {
88 setOrigin(vprod->position().t(), vprod->position().x(), vprod->position().y(), vprod->position().z());
94 :
Particle(HepMCUtils::getParticlePtr(gp))
153 const double phi0 = M_PI/2 - this->
phi();
154 const double x0 = rho0 * cos(phi0);
155 const double y0 = rho0 * sin(phi0);
188 explicit operator ConstGenParticlePtr ()
const {
return genParticle(); }
197 PdgId
pid()
const {
return _id; }
199 PdgId
abspid()
const {
return std::abs(_id); }
439 return !
ancestors(f, only_physical).empty();
512 bool fromTau(
bool prompt_taus_only=
false)
const;
537 DEPRECATED(
"Too vague: use fromHadron() || fromPromptTau(), or isDirect()")
550 bool isDirect(
bool allow_from_direct_tau=
false,
bool allow_from_direct_mu=
false)
const;
553 bool isPrompt(
bool allow_from_prompt_tau=
false,
bool allow_from_prompt_mu=
false)
const {
554 return isDirect(allow_from_prompt_tau, allow_from_prompt_mu);
702 if (!f(*
this))
return false;
714 if (!f(*
this))
return false;
734 if (
pid() != other.
pid())
return false;
746 ConstGenParticlePtr _original;
762 mutable std::vector<std::pair<bool,bool> > _isDirect;
782#include "Rivet/Tools/ParticleUtils.hh"
Specialized version of the FourVector with momentum/energy functionality.
Definition Vector4.hh:316
Specialisation of VectorN to a general (non-momentum) Lorentz 4-vector.
Definition Vector4.hh:30
Base class for particle-like things like Particle and Jet.
Definition ParticleBase.hh:13
double py() const
y component of momentum.
Definition ParticleBase.hh:122
const FourMomentum & mom() const
Get equivalent single momentum four-vector (const) (alias).
Definition ParticleBase.hh:39
double phi(const PhiMapping mapping=ZERO_2PI) const
Get the directly.
Definition ParticleBase.hh:105
double p() const
Get the 3-momentum magnitude directly.
Definition ParticleBase.hh:110
double theta() const
Synonym for polarAngle.
Definition ParticleBase.hh:136
double pz() const
z component of momentum.
Definition ParticleBase.hh:124
double px() const
x component of momentum.
Definition ParticleBase.hh:120
double E() const
Get the energy directly.
Definition ParticleBase.hh:51
Particle representation, either from a HepMC::GenEvent or reconstructed.
Definition Particle.hh:53
Particle & setMomentum(double E, double px, double py, double pz)
Set the momentum via components.
Definition Particle.hh:114
bool isHadron() const
Is this a hadron?
Definition Particle.hh:229
Particles allDescendants(const ParticleSelector &f, bool remove_duplicates=true) const
Get a list of all the descendants from the current particle (with selector function)
Definition Particle.hh:612
const Particles constituents(const ParticleSelector &selector, const ParticleSorter &sorter) const
Direct constituents of this particle, filtered and sorted by functors.
Definition Particle.hh:313
const Particles rawConstituents(const ParticleSorter &sorter) const
Fundamental constituents of this particle, sorted by a functor.
Definition Particle.hh:324
bool hasStableDescendantWithout(const ParticleSelector &f) const
Definition Particle.hh:678
virtual fastjet::PseudoJet pseudojet() const
Converter to FastJet3 PseudoJet.
Definition Particle.hh:167
bool hasChildWith(const ParticleSelector &f) const
Definition Particle.hh:582
Vector3 closestApproach() const
Find the point of closest approach to the primary vertex.
Definition Particle.hh:149
bool isDirect(bool allow_from_direct_tau=false, bool allow_from_direct_mu=false) const
Shorthand definition of 'promptness' based on set definition flags.
bool hasDescendantWith(const Cut &c, bool remove_duplicates=true) const
virtual void addConstituent(const Particle &c, bool addmom=false)
Add a single direct constituent to this particle.
bool isPrompt(bool allow_from_prompt_tau=false, bool allow_from_prompt_mu=false) const
Alias for isDirect.
Definition Particle.hh:553
bool hasAncestorWith(const ParticleSelector &f, bool only_physical=true) const
Definition Particle.hh:438
Particles rawConstituents() const
Fundamental constituents of this particle.
bool hasAncestorWith(const Cut &c, bool only_physical=true) const
const Particles constituents(const Cut &c, const ParticleSorter &sorter) const
Direct constituents of this particle, sorted by a functor.
Definition Particle.hh:301
virtual void addConstituents(const Particles &cs, bool addmom=false)
Add direct constituents to this particle.
bool fromBottom() const
Determine whether the particle is from a b-hadron decay.
bool hasParentWithout(const Cut &c) const
bool isNeutrino() const
Is this a neutrino?
Definition Particle.hh:244
bool isSame(const Particle &other) const
Definition Particle.hh:733
const Particles rawConstituents(const ParticleSelector &selector, const ParticleSorter &sorter) const
Fundamental constituents of this particle, filtered and sorted by functors.
Definition Particle.hh:348
Particle & setOrigin(const FourVector &position)
Set the origin position.
Definition Particle.hh:133
Particle()
Definition Particle.hh:61
const Particles & constituents() const
Direct constituents of this particle, returned by reference.
Definition Particle.hh:285
bool hasChildWithout(const Cut &c) const
bool hasParentWith(const ParticleSelector &f) const
Definition Particle.hh:379
bool isLepton() const
Is this a lepton?
Definition Particle.hh:238
bool isChargedLepton() const
Is this a charged lepton?
Definition Particle.hh:241
bool hasParentWith(const Cut &c) const
bool hasBottom() const
Does this (hadron) contain a b quark?
Definition Particle.hh:247
DEPRECATED("Too vague: use fromHadron() || fromPromptTau(), or isDirect()") bool fromDecay() const
Determine whether the particle is from a hadron or tau decay.
Definition Particle.hh:537
bool hasChildWithout(const ParticleSelector &f) const
Definition Particle.hh:597
bool isCharged() const
Is this Particle charged?
Definition Particle.hh:220
bool isMeson() const
Is this a meson?
Definition Particle.hh:232
bool isLastWith(const ParticleSelector &f) const
Determine whether a particle is the last in a decay chain to meet the function requirement.
Definition Particle.hh:713
Particles ancestors(const Cut &c=Cuts::OPEN, bool only_physical=true) const
const Particles constituents(const ParticleSelector &selector) const
Direct constituents of this particle, filtered by a selection functor.
Definition Particle.hh:307
double abscharge() const
The absolute charge of this Particle.
Definition Particle.hh:211
bool isFirstWith(const ParticleSelector &f) const
Determine whether a particle is the first in a decay chain to meet the function requirement.
Definition Particle.hh:701
bool hasDescendantWith(const ParticleSelector &f, bool remove_duplicates=true) const
Definition Particle.hh:621
bool hasStableDescendantWith(const Cut &c) const
bool hasParent(PdgId pid) const
PdgId pid() const
This Particle's PDG ID code.
Definition Particle.hh:197
bool isLastWithout(const ParticleSelector &f) const
Determine whether a particle is the last in a decay chain not to meet the function requirement.
Definition Particle.hh:720
Particles ancestors(const ParticleSelector &f, bool only_physical=true) const
Definition Particle.hh:429
Particle(const RivetHepMC::GenParticle &gp)
Constructor from a HepMC GenParticle reference.
Definition Particle.hh:93
const Particles constituents(const Cut &c) const
Direct constituents of this particle, filtered by a Cut.
Definition Particle.hh:295
double flightLength() const
bool fromHadron() const
Determine whether the particle is from a hadron decay.
bool hasAncestorWithout(const Cut &c, bool only_physical=true) const
bool hasChildWith(const Cut &c) const
const Particles rawConstituents(const ParticleSelector &selector) const
Fundamental constituents of this particle, filtered by a selection functor.
Definition Particle.hh:342
double charge() const
The charge of this Particle.
Definition Particle.hh:208
Particles allDescendants(const Cut &c=Cuts::OPEN, bool remove_duplicates=true) const
Get a list of all the descendants from the current particle (with optional selection Cut)
bool fromTau(bool prompt_taus_only=false) const
Determine whether the particle is from a tau decay.
Particle & setGenParticle(ConstGenParticlePtr gp)
Set a const pointer to the original GenParticle.
Definition Particle.hh:176
bool hasParentWithout(const ParticleSelector &f) const
Definition Particle.hh:394
Particle & transformBy(const LorentzTransform <)
Apply an active Lorentz transform to this particle.
Particles parents(const Cut &c=Cuts::OPEN) const
int abscharge3() const
Three times the absolute charge of this Particle (i.e. integer multiple of smallest quark charge).
Definition Particle.hh:217
Particles stableDescendants(const ParticleSelector &f) const
Get a list of all the stable descendants from the current particle (with selector function)
Definition Particle.hh:654
bool isComposite() const
Determine if this Particle is a composite of other Rivet Particles.
Definition Particle.hh:278
Particle & setOrigin(double t, double x, double y, double z)
Set the origin position via components.
Definition Particle.hh:138
bool fromPromptTau() const
Determine whether the particle is from a prompt tau decay.
Definition Particle.hh:519
bool hasCharm() const
Does this (hadron) contain a c quark?
Definition Particle.hh:250
bool fromHadronicTau(bool prompt_taus_only=false) const
Determine whether the particle is from a tau which decayed hadronically.
bool isFirstWithout(const ParticleSelector &f) const
Determine whether a particle is the first in a decay chain not to meet the function requirement.
Definition Particle.hh:708
bool isStable() const
Whether this particle is stable according to the generator.
const FourMomentum & momentum() const
The momentum.
Definition Particle.hh:103
Particle(ConstGenParticlePtr gp)
Constructor from a HepMC GenParticle pointer.
Definition Particle.hh:80
const Particles rawConstituents(const Cut &c, const ParticleSorter &sorter) const
Fundamental constituents of this particle, sorted by a functor.
Definition Particle.hh:336
bool hasDescendantWithout(const Cut &c, bool remove_duplicates=true) const
Particles children(const ParticleSelector &f) const
Get a list of the direct descendants from the current particle (with selector function)
Definition Particle.hh:573
Particle(PdgId pid, const FourMomentum &mom, ConstGenParticlePtr gp, const FourVector &pos=FourVector())
Constructor from PID, momentum, and a GenParticle for relational links.
Definition Particle.hh:75
PdgId abspid() const
Absolute value of the PDG ID code.
Definition Particle.hh:199
const Particles rawConstituents(const Cut &c) const
Fundamental constituents of this particle, filtered by a Cut.
Definition Particle.hh:330
Particles parents(const ParticleSelector &f) const
Definition Particle.hh:370
Particles children(const Cut &c=Cuts::OPEN) const
Get a list of the direct descendants from the current particle (with optional selection Cut)
bool isVisible() const
Is this particle potentially visible in a detector?
bool hasDescendantWithout(const ParticleSelector &f, bool remove_duplicates=true) const
Definition Particle.hh:636
const Particles constituents(const ParticleSorter &sorter) const
Direct constituents of this particle, sorted by a functor.
Definition Particle.hh:289
bool fromCharm() const
Determine whether the particle is from a c-hadron decay.
bool hasStableDescendantWithout(const Cut &c) const
bool isBaryon() const
Is this a baryon?
Definition Particle.hh:235
Particles stableDescendants(const Cut &c=Cuts::OPEN) const
ConstGenParticlePtr genParticle() const
Get a const pointer to the original GenParticle.
Definition Particle.hh:182
bool hasStableDescendantWith(const ParticleSelector &f) const
Definition Particle.hh:663
bool isParton() const
Is this a parton? (Hopefully not very often... fiducial FTW)
Definition Particle.hh:259
bool hasAncestor(PdgId pid, bool only_physical=true) const
int charge3() const
Three times the charge of this Particle (i.e. integer multiple of smallest quark charge).
Definition Particle.hh:214
bool hasAncestorWithout(const ParticleSelector &f, bool only_physical=true) const
Definition Particle.hh:453
Particle(PdgId pid, const FourMomentum &mom, const FourVector &pos=FourVector(), ConstGenParticlePtr gp=nullptr)
Constructor from PID and momentum.
Definition Particle.hh:67
Particle & setMomentum(const FourMomentum &momentum)
Set the momentum.
Definition Particle.hh:108
virtual void setConstituents(const Particles &cs, bool setmom=false)
Set direct constituents of this particle.
const FourVector & origin() const
The origin position (and time).
Definition Particle.hh:129
Specialised vector of Particle objects.
Definition Particle.hh:25
Three-dimensional specialisation of Vector.
Definition Vector3.hh:40
bool any(const CONTAINER &c)
Return true if x is true for any x in container c, otherwise false.
Definition Utils.hh:325
Jets filter_select(const Jets &jets, const Cut &c)
Filter a jet collection in-place to the subset that passes the supplied Cut.
Definition JetUtils.hh:157
int abscharge3(int pid)
Return the absolute value of 3 times the EM charge.
Definition ParticleIdUtils.hh:960
double charge(int pid)
Return the EM charge (as floating point)
Definition ParticleIdUtils.hh:965
double abscharge(int pid)
Return the EM charge (as floating point)
Definition ParticleIdUtils.hh:970
int charge3(int pid)
Three times the EM charge (as integer)
Definition ParticleIdUtils.hh:883
bool isParton(int pid)
Determine if the PID is that of a parton (quark or gluon)
Definition ParticleIdUtils.hh:180
bool isNeutrino(int pid)
Determine if the PID is that of a neutrino.
Definition ParticleIdUtils.hh:217
bool isChargedLepton(int pid)
Determine if the PID is that of a charged lepton.
Definition ParticleIdUtils.hh:206
bool isLepton(int pid)
Definition ParticleIdUtils.hh:400
bool hasBottom(int pid)
Does this particle contain a bottom quark?
Definition ParticleIdUtils.hh:654
bool hasCharm(int pid)
Does this particle contain a charm quark?
Definition ParticleIdUtils.hh:650
bool isBaryon(int pid)
Check to see if this is a valid baryon.
Definition ParticleIdUtils.hh:318
bool isMeson(int pid)
Check to see if this is a valid meson.
Definition ParticleIdUtils.hh:295
bool isHadron(int pid)
Definition ParticleIdUtils.hh:382
MOMS sortBy(const MOMS &pbs, const CMP &cmp)
Sort a container of momenta by cmp and return by value for const inputs.
Definition Vector4.hh:1451
double perp() const
Synonym for polarRadius.
Definition Vector4.hh:123
double p(const ParticleBase &p)
Unbound function access to p.
Definition ParticleBaseUtils.hh:684
Definition MC_Cent_pPb.hh:10
std::ostream & operator<<(std::ostream &os, const AnalysisInfo &ai)
Stream an AnalysisInfo as a text description.
Definition AnalysisInfo.hh:368
std::pair< Particle, Particle > ParticlePair
Typedef for a pair of Particle objects.
Definition Particle.hh:42
std::vector< PseudoJet > PseudoJets
Definition RivetFastJet.hh:30
std::enable_if< std::is_floating_point< NUM >::value, bool >::type isZero(NUM val, double tolerance=1e-8)
Compare a number to zero.
Definition MathUtils.hh:24