/usr/include/Rivet/Particle.hh is in librivet-dev 1.8.3-1.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 | // -*- 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 {
/// Representation of particles from a HepMC::GenEvent.
class Particle : public ParticleBase {
public:
/// Default constructor.
/// @deprecated A particle without info is useless. This only exists to keep STL containers happy.
Particle()
: ParticleBase(),
_original(0), _id(0), _momentum()
{ }
/// Constructor without GenParticle.
Particle(PdgId pid, const FourMomentum& mom)
: ParticleBase(),
_original(0), _id(pid), _momentum(mom)
{ }
/// Constructor from a HepMC GenParticle.
Particle(const GenParticle& gp)
: ParticleBase(),
_original(&gp), _id(gp.pdg_id()),
_momentum(gp.momentum())
{ }
public:
/// Get a const reference to the original GenParticle.
const GenParticle& genParticle() const {
assert(_original);
return *_original;
}
/// Check if the particle corresponds to a GenParticle.
bool hasGenParticle() const {
return bool(_original);
}
/// The PDG ID code for this Particle.
PdgId pdgId() const {
return _id;
}
/// Set the momentum of this Particle.
Particle& setMomentum(const FourMomentum& momentum) {
_momentum = momentum;
return *this;
}
/// The momentum of this Particle.
const FourMomentum& momentum() const {
return _momentum;
}
/// The energy of this Particle.
double energy() const {
return momentum().E();
}
/// The mass of this Particle.
double mass() const {
return momentum().mass();
}
/// @todo Re-enable
// /// The charge of this Particle.
// double charge() const {
// return PID::charge(*this);
// }
/// @todo Re-enable
// /// Three times the charge of this Particle (i.e. integer multiple of smallest quark charge).
// int threeCharge() const {
// return PID::threeCharge(*this);
// }
/// Check whether a given PID is found in the GenParticle's ancestor list
///
/// @note This question is valid in MC, but may not be answerable
/// experimentally -- use this function with care when replicating
/// experimental analyses!
bool hasAncestor(PdgId pdg_id) const;
/// @brief Determine whether the particle is from a hadron or tau decay
///
/// Specifically, walk up the ancestor chain until a status 2 hadron or
/// tau is found, if at all.
///
/// @note This question is valid in MC, but may not be answerable
/// experimentally -- use this function with care when replicating
/// experimental analyses!
bool fromDecay() const;
/// @todo Add methods like fromS/C/BHadron(), fromTau()?
private:
/// A pointer to the original GenParticle from which this Particle is projected.
const GenParticle* _original;
/// The PDG ID code for this Particle.
PdgId _id;
/// The momentum of this projection of the Particle.
FourMomentum _momentum;
};
/// @name String representation
//@{
/// Print a ParticlePair as a string.
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();
}
/// Allow ParticlePair to be passed to an ostream.
inline std::ostream& operator<<(std::ostream& os, const ParticlePair& pp) {
os << toString(pp);
return os;
}
//@}
/// @name Comparison functors
//@{
/// Sort by descending transverse momentum, \f$ p_\perp \f$
inline bool cmpParticleByPt(const Particle& a, const Particle& b) {
return a.momentum().pT() > b.momentum().pT();
}
/// Sort by ascending transverse momentum, \f$ p_\perp \f$
inline bool cmpParticleByAscPt(const Particle& a, const Particle& b) {
return a.momentum().pT() < b.momentum().pT();
}
/// Sort by descending momentum, \f$ p \f$
inline bool cmpParticleByP(const Particle& a, const Particle& b) {
return a.momentum().vector3().mod() > b.momentum().vector3().mod();
}
/// Sort by ascending momentum, \f$ p \f$
inline bool cmpParticleByAscP(const Particle& a, const Particle& b) {
return a.momentum().vector3().mod() < b.momentum().vector3().mod();
}
/// Sort by descending transverse energy, \f$ E_\perp \f$
inline bool cmpParticleByEt(const Particle& a, const Particle& b) {
return a.momentum().Et() > b.momentum().Et();
}
/// Sort by ascending transverse energy, \f$ E_\perp \f$
inline bool cmpParticleByAscEt(const Particle& a, const Particle& b) {
return a.momentum().Et() < b.momentum().Et();
}
/// Sort by descending energy, \f$ E \f$
inline bool cmpParticleByE(const Particle& a, const Particle& b) {
return a.momentum().E() > b.momentum().E();
}
/// Sort by ascending energy, \f$ E \f$
inline bool cmpParticleByAscE(const Particle& a, const Particle& b) {
return a.momentum().E() < b.momentum().E();
}
/// Sort by descending pseudorapidity, \f$ \eta \f$
inline bool cmpParticleByDescPseudorapidity(const Particle& a, const Particle& b) {
return a.momentum().pseudorapidity() > b.momentum().pseudorapidity();
}
/// Sort by ascending pseudorapidity, \f$ \eta \f$
inline bool cmpParticleByAscPseudorapidity(const Particle& a, const Particle& b) {
return a.momentum().pseudorapidity() < b.momentum().pseudorapidity();
}
/// Sort by descending absolute pseudorapidity, \f$ |\eta| \f$
inline bool cmpParticleByDescAbsPseudorapidity(const Particle& a, const Particle& b) {
return fabs(a.momentum().pseudorapidity()) > fabs(b.momentum().pseudorapidity());
}
/// Sort by ascending absolute pseudorapidity, \f$ |\eta| \f$
inline bool cmpParticleByAscAbsPseudorapidity(const Particle& a, const Particle& b) {
return fabs(a.momentum().pseudorapidity()) < fabs(b.momentum().pseudorapidity());
}
/// Sort by descending rapidity, \f$ y \f$
inline bool cmpParticleByDescRapidity(const Particle& a, const Particle& b) {
return a.momentum().rapidity() > b.momentum().rapidity();
}
/// Sort by ascending rapidity, \f$ y \f$
inline bool cmpParticleByAscRapidity(const Particle& a, const Particle& b) {
return a.momentum().rapidity() < b.momentum().rapidity();
}
/// Sort by descending absolute rapidity, \f$ |y| \f$
inline bool cmpParticleByDescAbsRapidity(const Particle& a, const Particle& b) {
return fabs(a.momentum().rapidity()) > fabs(b.momentum().rapidity());
}
/// Sort by ascending absolute rapidity, \f$ |y| \f$
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
|