![]() |
|
|||
File indexing completed on 2025-09-15 09:11:07
0001 // -*- C++ -*- 0002 #ifndef RIVET_Jet_HH 0003 #define RIVET_Jet_HH 0004 0005 #include "Rivet/Config/RivetCommon.hh" 0006 #include "Rivet/Jet.fhh" 0007 #include "Rivet/Particle.hh" 0008 #include "Rivet/Tools/Cuts.hh" 0009 #include "Rivet/Tools/Utils.hh" 0010 #include "Rivet/Tools/RivetFastJet.hh" 0011 #include "Rivet/Math/LorentzTrans.hh" 0012 #include <numeric> 0013 0014 namespace Rivet { 0015 0016 0017 /// @brief Specialised vector of Jet objects. 0018 /// 0019 /// A specialised version of vector<Jet> which is able to implicitly and 0020 /// explicitly convert to a vector of FourMomentum or PseudoJet. 0021 class Jets : public std::vector<Jet> { 0022 public: 0023 using base = std::vector<Jet>; //< using-declarations don't like template syntax 0024 using base::base; //< import base-class constructors 0025 Jets(); 0026 Jets(const std::vector<Jet>& vjs); 0027 FourMomenta moms() const; 0028 PseudoJets pseudojets() const; 0029 operator FourMomenta () const { return moms(); } 0030 operator PseudoJets () const { return pseudojets(); } 0031 Jets& operator += (const Jet& j); 0032 Jets& operator += (const Jets& js); 0033 }; 0034 0035 Jets operator + (const Jets& a, const Jets& b); 0036 0037 0038 ////////////////////// 0039 0040 0041 /// @brief Representation of a clustered jet of particles. 0042 class Jet : public ParticleBase { 0043 public: 0044 0045 /// @name Constructors 0046 /// @{ 0047 0048 /// Constructor from a FastJet PseudoJet, with optional full particle constituents information. 0049 Jet(const fastjet::PseudoJet& pj, const Particles& particles=Particles(), const Particles& tags=Particles()) { 0050 setState(pj, particles, tags); 0051 } 0052 0053 /// Set the jet data, with optional full particle information. 0054 Jet(const FourMomentum& pjet, const Particles& particles=Particles(), const Particles& tags=Particles()) { 0055 setState(pjet, particles, tags); 0056 } 0057 0058 /// Default constructor -- only for STL storability 0059 Jet() { clear(); } 0060 0061 /// @} 0062 0063 0064 /// @name Access jet constituents 0065 /// @{ 0066 0067 /// Number of particles in this jet. 0068 size_t size() const { return _particles.size(); } 0069 0070 /// Get the particles in this jet. 0071 Particles& particles() { return _particles; } 0072 /// Get the particles in this jet (const version) 0073 const Particles& particles() const { return _particles; } 0074 /// Get the particles in this jet which pass a cut (const) 0075 const Particles particles(const Cut& c) const { return select(_particles, c); } 0076 /// Get the particles in this jet which pass a filtering functor (const) 0077 const Particles particles(const ParticleSelector& s) const { return select(_particles, s); } 0078 0079 /// Get the particles in this jet (FastJet-like alias) 0080 Particles& constituents() { return particles(); } 0081 /// Get the particles in this jet (FastJet-like alias, const version) 0082 const Particles& constituents() const { return particles(); } 0083 /// Get the particles in this jet which pass a cut (FastJet-like alias, const) 0084 const Particles constituents(const Cut& c) const { return particles(c); } 0085 /// Get the particles in this jet which pass a filtering functor (FastJet-like alias, const) 0086 const Particles constituents(const ParticleSelector& s) const { return particles(s); } 0087 0088 /// Check whether this jet contains a particular particle. 0089 bool containsParticle(const Particle& particle) const; 0090 /// Nicer alias for containsParticleId 0091 bool containsPID(const Particle& particle) const { return containsParticle(particle); } 0092 0093 /// Check whether this jet contains a certain particle type. 0094 bool containsParticleId(PdgId pid) const; 0095 /// Nicer alias for containsParticleId 0096 bool containsPID(PdgId pid) const { return containsParticleId(pid); } 0097 0098 /// Check whether this jet contains at least one of certain particle types. 0099 bool containsParticleId(const vector<PdgId>& pids) const; 0100 /// Nicer alias for containsParticleId 0101 bool containsPID(const vector<PdgId>& pids) const { return containsParticleId(pids); } 0102 0103 /// @} 0104 0105 0106 /// @name Tagging 0107 /// 0108 /// @note General sources of tag particles are planned. The default jet finding 0109 /// adds b-hadron, c-hadron, and tau tags by ghost association. 0110 /// @{ 0111 0112 /// @brief Particles which have been tag-matched to this jet 0113 Particles& tags() { return _tags; } 0114 /// @brief Particles which have been tag-matched to this jet (const version) 0115 const Particles& tags() const { return _tags; } 0116 /// @brief Particles which have been tag-matched to this jet _and_ pass a selector function or dR requirement 0117 /// 0118 /// @note Note the less efficient return by value, due to the filtering. 0119 Particles tags(const ParticleSelector& f, double dRmax=-1) const { 0120 const Particles filttags = select(tags(), f); 0121 // Return, via dR filter if requested 0122 return dRmax < 0 ? filttags : select(filttags, deltaRLess(this->mom(), dRmax)); 0123 } 0124 /// @brief Particles which have been tag-matched to this jet _and_ pass a Cut or dR requirement 0125 /// 0126 /// @note Note the less efficient return by value, due to the cut-pass filtering. 0127 Particles tags(const Cut& c, double dRmax=-1) const; 0128 0129 0130 /// @brief Get the b particles tag-matched to this jet 0131 /// 0132 /// The default jet finding adds b-hadron tags by ghost association. 0133 /// 0134 /// This version has an optional tag-particle Cut requirement 0135 /// and restriction to a tighter dR cone around the jet centroid. 0136 Particles bTags(const Cut& c=Cuts::open(), double dRmax=-1) const; 0137 0138 /// @brief Get the b particles tag-matched to this jet (with optional selector function and dR restriction) 0139 /// 0140 /// The default jet finding adds b-hadron tags by ghost association. 0141 /// 0142 /// This version has an optional tag-particle selector function 0143 /// and restriction to a tighter dR cone around the jet centroid. 0144 Particles bTags(const ParticleSelector& f, double dRmax=-1) const { return select(bTags(), f); } 0145 0146 /// Does this jet have at least one b-tag? (with optional Cut and dR restriction) 0147 bool bTagged(const Cut& c=Cuts::open(), double dRmax=-1) const { return !bTags(c).empty(); } 0148 0149 /// Does this jet have at least one b-tag? (with optional selector function and dR restriction) 0150 bool bTagged(const ParticleSelector& f, double dRmax=-1) const { return !bTags(f).empty(); } 0151 0152 0153 /// @brief Get the c (and not b) particles tag-matched to this jet 0154 /// 0155 /// The default jet finding adds c-hadron tags by ghost association. 0156 /// 0157 /// This version has an optional tag-particle Cut requirement 0158 /// and restriction to a tighter dR cone around the jet centroid. 0159 Particles cTags(const Cut& c=Cuts::open(), double dRmax=-1) const; 0160 0161 /// @brief Get the c (and not b) particles which have been tag-matched to this jet 0162 /// 0163 /// The default jet finding adds c-hadron tags by ghost association. 0164 /// 0165 /// This version has an optional tag-particle selector function 0166 /// and restriction to a tighter dR cone around the jet centroid. 0167 Particles cTags(const ParticleSelector& f, double dRmax=-1) const { return select(cTags(), f); } 0168 0169 /// Does this jet have at least one c-tag? (with optional Cut and dR restriction) 0170 bool cTagged(const Cut& c=Cuts::open(), double dRmax=-1) const { return !cTags(c).empty(); } 0171 0172 /// Does this jet have at least one c-tag? (with optional selector function and dR restriction) 0173 bool cTagged(const ParticleSelector& f, double dRmax=-1) const { return !cTags(f).empty(); } 0174 0175 0176 /// @brief Get the tau particles tag-matched to this jet 0177 /// 0178 /// The default jet finding adds tau tags by ghost association. 0179 /// 0180 /// This version has an optional tag-particle Cut requirement 0181 /// and restriction to a tighter dR cone around the jet centroid. 0182 Particles tauTags(const Cut& c=Cuts::open(), double dRmax=-1) const; 0183 0184 /// @brief Get the tau particles tag-matched to this jet 0185 /// 0186 /// The default jet finding adds tau tags by ghost association. 0187 /// 0188 /// This version has an optional tag-particle selector function 0189 /// and restriction to a tighter dR cone around the jet centroid. 0190 Particles tauTags(const ParticleSelector& f, double dRmax=-1) const { return select(tauTags(), f); } 0191 0192 /// Does this jet have at least one tau-tag (with optional Cut and dR restriction) 0193 bool tauTagged(const Cut& c=Cuts::open(), double dRmax=-1) const { return !tauTags(c).empty(); } 0194 0195 /// Does this jet have at least one tau-tag (with optional selector function and dR restriction) 0196 bool tauTagged(const ParticleSelector& f, double dRmax=-1) const { return !tauTags(f).empty(); } 0197 0198 0199 /// @todo Extend to arbitrary tagging types 0200 0201 /// @} 0202 0203 0204 /// @name Effective jet 4-vector properties 0205 /// @{ 0206 0207 /// Get equivalent single momentum four-vector. 0208 const FourMomentum& momentum() const { return _momentum; } 0209 0210 /// Apply an active Lorentz transform to this jet 0211 /// @note The Rivet jet momentum, constituent particles, and tag particles will be modified. 0212 /// @warning The FastJet cluster sequence and pseudojets will not be modified: don't use them after transformation! 0213 Jet& transformBy(const LorentzTransform& lt); 0214 0215 /// Get the total energy of this jet. 0216 double totalEnergy() const { return momentum().E(); } 0217 0218 /// Get the energy carried in this jet by neutral particles. 0219 double neutralEnergy() const; 0220 0221 /// Get the energy carried in this jet by hadrons. 0222 double hadronicEnergy() const; 0223 0224 /// @} 0225 0226 0227 /// @name Interaction with FastJet 0228 /// @{ 0229 0230 /// Access the internal FastJet3 PseudoJet (as a const reference) 0231 const fastjet::PseudoJet& pseudojet() const { return _pseudojet; } 0232 0233 /// Cast operator to FastJet3 PseudoJet (as a const reference) 0234 operator const fastjet::PseudoJet& () const { return pseudojet(); } 0235 0236 /// @} 0237 0238 0239 /// @name Set the jet constituents and properties 0240 /// @{ 0241 0242 /// @brief Set the jet data from a FastJet PseudoJet, with optional particle constituents and tags lists. 0243 /// 0244 /// @note The particles() list will be extracted from PseudoJet constituents 0245 /// by default, making use of an attached user info if one is found. 0246 Jet& setState(const fastjet::PseudoJet& pj, const Particles& particles=Particles(), const Particles& tags=Particles()); 0247 0248 /// Set all the jet data, with optional full particle constituent and tag information. 0249 Jet& setState(const FourMomentum& mom, const Particles& particles, const Particles& tags=Particles()); 0250 0251 /// @brief Set the particles collection with full particle information. 0252 /// 0253 /// If set, this overrides particle info extracted from the PseudoJet 0254 Jet& setParticles(const Particles& particles); 0255 Jet& setConstituents(const Particles& particles) { return setParticles(particles); } 0256 0257 /// Reset this jet as empty. 0258 Jet& clear(); 0259 0260 /// @} 0261 0262 0263 private: 0264 0265 /// FJ3 PseudoJet member to unify PseudoJet and Jet 0266 fastjet::PseudoJet _pseudojet; 0267 0268 /// Full constituent particle information. (Filled from PseudoJet if possible.) 0269 /// @todo Make these mutable or similar? Add a flag to force a cache rebuild? 0270 Particles _particles; 0271 0272 /// Particles used to tag this jet (can be anything, but c and b hadrons are the most common) 0273 Particles _tags; 0274 0275 /// Effective jet 4-vector (just for caching) 0276 mutable FourMomentum _momentum; 0277 0278 // /// Provide but hide the equality operators, to avoid implicit comparison via fastjet::PseudoJet 0279 // bool operator == (const Jet&) const; 0280 // bool operator != (const Jet&) const; 0281 0282 }; 0283 0284 0285 /// @name String representation and streaming support 0286 /// @{ 0287 0288 /// Allow a Jet to be passed to an ostream. 0289 std::ostream& operator << (std::ostream& os, const Jet& j); 0290 0291 /// @} 0292 0293 0294 } 0295 0296 0297 #include "Rivet/Tools/JetUtils.hh" 0298 0299 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |