rivet is hosted by Hepforge, IPPP Durham
Jet.hh
Go to the documentation of this file.
00001 // -*- C++ -*-
00002 #ifndef RIVET_Jet_HH
00003 #define RIVET_Jet_HH
00004 
00005 #include "Rivet/Config/RivetCommon.hh"
00006 #include "Rivet/Jet.fhh"
00007 #include "Rivet/Particle.hh"
00008 #include "Rivet/Cuts.hh"
00009 #include "Rivet/Tools/ParticleUtils.hh"
00010 #include "fastjet/PseudoJet.hh"
00011 #include <numeric>
00012 
00013 namespace Rivet {
00014 
00015 
00016   /// @brief Representation of a clustered jet of particles.
00017   class Jet : public ParticleBase {
00018   public:
00019 
00020     /// @name Constructors
00021     //@{
00022 
00023     /// Constructor from a FastJet PseudoJet, with optional full particle constituents information.
00024     Jet(const fastjet::PseudoJet& pj, const Particles& particles=Particles(), const Particles& tags=Particles()) {
00025       setState(pj, particles, tags);
00026     }
00027 
00028     /// Set the jet data, with optional full particle information.
00029     Jet(const FourMomentum& pjet, const Particles& particles=Particles(), const Particles& tags=Particles()) {
00030       setState(pjet, particles, tags);
00031     }
00032 
00033     /// Set all the jet data, with full particle information.
00034     /// @deprecated Prefer the form where the 4-vec comes first and the particles list is optional.
00035     DEPRECATED("Prefer the form where the 4-vec comes first and the particles list is optional.")
00036     Jet(const Particles& particles, const FourMomentum& pjet) {
00037       setState(pjet, particles);
00038     }
00039 
00040     /// Default constructor -- only for STL storability
00041     Jet() { clear(); }
00042 
00043     //@}
00044 
00045 
00046     /// @name Access jet constituents
00047     //@{
00048 
00049     /// Number of particles in this jet.
00050     size_t size() const { return _particles.size(); }
00051 
00052     /// Get the particles in this jet.
00053     vector<Particle>& particles() { return _particles; }
00054     /// Get the particles in this jet (const version)
00055     const vector<Particle>& particles() const { return _particles; }
00056 
00057     /// Get the particles in this jet (FastJet-like alias)
00058     vector<Particle>& constituents() { return particles(); }
00059     /// Get the particles in this jet (FastJet-like alias, const version)
00060     const vector<Particle>& constituents() const { return particles(); }
00061 
00062     /// Check whether this jet contains a particular particle.
00063     bool containsParticle(const Particle& particle) const;
00064     /// Nicer alias for containsParticleId
00065     bool containsPID(const Particle& particle) const { return containsParticle(particle); }
00066 
00067     /// Check whether this jet contains a certain particle type.
00068     bool containsParticleId(PdgId pid) const;
00069     /// Nicer alias for containsParticleId
00070     bool containsPID(PdgId pid) const { return containsParticleId(pid); }
00071 
00072     /// Check whether this jet contains at least one of certain particle types.
00073     bool containsParticleId(const vector<PdgId>& pids) const;
00074     /// Nicer alias for containsParticleId
00075     bool containsPID(const vector<PdgId>& pids) const { return containsParticleId(pids); }
00076 
00077     //@}
00078 
00079 
00080     /// @name Tagging
00081     ///
00082     /// @note General sources of tag particles are planned. The default jet finding
00083     /// adds b-hadron, c-hadron, and tau tags by ghost association.
00084     //@{
00085 
00086     /// @brief Particles which have been tag-matched to this jet
00087     Particles& tags() { return _tags; }
00088     /// @brief Particles which have been tag-matched to this jet (const version)
00089     const Particles& tags() const { return _tags; }
00090     /// @brief Particles which have been tag-matched to this jet _and_ pass a Cut
00091     ///
00092     /// @note Note the less efficient return by value, due to the cut-pass filtering.
00093     Particles tags(const Cut& c) const;
00094 
00095 
00096     /// @brief b particles which have been tag-matched to this jet (and pass an optional Cut)
00097     ///
00098     /// The default jet finding adds b-hadron tags by ghost association.
00099     Particles bTags(const Cut& c=Cuts::open()) const;
00100     /// Does this jet have at least one b-tag (that passes an optional Cut)?
00101     bool bTagged(const Cut& c=Cuts::open()) const { return !bTags(c).empty(); }
00102 
00103 
00104     /// @brief c (and not b) particles which have been tag-matched to this jet (and pass an optional Cut)
00105     ///
00106     /// The default jet finding adds c-hadron tags by ghost association.
00107     Particles cTags(const Cut& c=Cuts::open()) const;
00108     /// Does this jet have at least one c-tag (that passes an optional Cut)?
00109     bool cTagged(const Cut& c=Cuts::open()) const { return !cTags(c).empty(); }
00110 
00111 
00112     /// @brief Tau particles which have been tag-matched to this jet (and pass an optional Cut)
00113     ///
00114     /// The default jet finding adds tau tags by ghost association.
00115     Particles tauTags(const Cut& c=Cuts::open()) const;
00116     /// Does this jet have at least one tau-tag (that passes an optional Cut)?
00117     bool tauTagged(const Cut& c=Cuts::open()) const { return !tauTags(c).empty(); }
00118 
00119 
00120     /// @brief Check whether this jet contains a bottom-flavoured hadron.
00121     ///
00122     /// @deprecated The bTags() or bTagged() function is probably what you want
00123     /// for tagging. This one ignores the tags() list and draws conclusions
00124     /// based directly on the jet constituents; the other gives a much better match
00125     /// to typical experimental methods.
00126     ///
00127     /// @note The decision is made by first trying to find a bottom-flavoured particle
00128     /// in the particles list. Most likely this will fail unless bottom hadrons
00129     /// are set stable. If @a include_decay_products is true (the default), a
00130     /// fallback is attempted, using the post-hadronization ancestor history of
00131     /// all constituents.
00132     //DEPRECATED("Prefer the bTags() or bTagged() function")
00133     bool containsBottom(bool include_decay_products=true) const;
00134 
00135     /// @brief Check whether this jet contains a charm-flavoured hadron.
00136     ///
00137     /// @deprecated The cTags() or cTagged() function is probably what you want
00138     /// for tagging. This one ignores the tags() list and draws conclusions
00139     /// based directly on the jet constituents; the other gives a much better match
00140     /// to typical experimental methods.
00141     ///
00142     /// @note The decision is made by first trying to find a charm-flavoured particle
00143     /// in the particles list. Most likely this will fail unless charmed hadrons
00144     /// are set stable. If @a include_decay_products is true (the default), a
00145     /// fallback is attempted, using the post-hadronization ancestor history of
00146     /// all constituents.
00147     //DEPRECATED("Prefer the cTags() or cTagged() function")
00148     bool containsCharm(bool include_decay_products=true) const;
00149 
00150     //@}
00151 
00152 
00153     /// @name Access additional effective jet 4-vector properties
00154     //@{
00155 
00156     /// Get equivalent single momentum four-vector.
00157     const FourMomentum& momentum() const { return _momentum; }
00158 
00159     /// Get the total energy of this jet.
00160     double totalEnergy() const { return momentum().E(); }
00161 
00162     /// Get the energy carried in this jet by neutral particles.
00163     double neutralEnergy() const;
00164 
00165     /// Get the energy carried in this jet by hadrons.
00166     double hadronicEnergy() const;
00167 
00168     //@}
00169 
00170 
00171     /// @name Interaction with FastJet
00172     //@{
00173 
00174     /// Access the internal FastJet3 PseudoJet (as a const reference)
00175     const fastjet::PseudoJet& pseudojet() const { return _pseudojet; }
00176 
00177     /// Cast operator to FastJet3 PseudoJet (as a const reference)
00178     operator const fastjet::PseudoJet& () const { return pseudojet(); }
00179 
00180     //@}
00181 
00182 
00183     /// @name Set the jet constituents and properties
00184     //@{
00185 
00186     /// @brief Set the jet data from a FastJet PseudoJet, with optional particle constituents and tags lists.
00187     ///
00188     /// @note The particles() list will be extracted from PseudoJet constituents
00189     /// by default, making use of an attached user info if one is found.
00190     Jet& setState(const fastjet::PseudoJet& pj, const Particles& particles=Particles(), const Particles& tags=Particles());
00191 
00192     /// Set all the jet data, with optional full particle constituent and tag information.
00193     Jet& setState(const FourMomentum& mom, const Particles& particles, const Particles& tags=Particles());
00194 
00195     /// @deprecated Prefer the 4-mom first-arg versions
00196     DEPRECATED("Prefer the 4-mom first-arg versions")
00197     Jet& setState(const Particles& particles, const FourMomentum& mom) { return setState(mom, particles); }
00198 
00199     /// @brief Set the particles collection with full particle information.
00200     ///
00201     /// If set, this overrides particle info extracted from the PseudoJet
00202     Jet& setParticles(const Particles& particles);
00203     Jet& setConstituents(const Particles& particles) { return setParticles(particles); }
00204 
00205     /// Reset this jet as empty.
00206     Jet& clear();
00207 
00208     //@}
00209 
00210 
00211   private:
00212 
00213     /// FJ3 PseudoJet member to unify PseudoJet and Jet
00214     fastjet::PseudoJet _pseudojet;
00215 
00216     /// Full constituent particle information. (Filled from PseudoJet if possible.)
00217     /// @todo Make these mutable or similar? Add a flag to force a cache rebuild?
00218     Particles _particles;
00219 
00220     /// Particles used to tag this jet (can be anything, but c and b hadrons are the most common)
00221     Particles _tags;
00222 
00223     /// Effective jet 4-vector (just for caching)
00224     mutable FourMomentum _momentum;
00225 
00226   };
00227 
00228 
00229 }
00230 
00231 #endif