rivet is hosted by Hepforge, IPPP Durham
JetAlg.hh
Go to the documentation of this file.
00001 // -*- C++ -*-
00002 #ifndef RIVET_JetAlg_HH
00003 #define RIVET_JetAlg_HH
00004 
00005 #include "Rivet/Projection.hh"
00006 #include "Rivet/Projections/FinalState.hh"
00007 #include "Rivet/Projections/VisibleFinalState.hh"
00008 #include "Rivet/Particle.hh"
00009 #include "Rivet/Jet.hh"
00010 
00011 namespace Rivet {
00012 
00013 
00014   /// Abstract base class for projections which can return a set of {@link Jet}s.
00015   class JetAlg : public Projection {
00016   public:
00017 
00018     /// Enum for the treatment of muons: whether to include all, some, or none in jet-finding
00019     enum MuonsStrategy { NO_MUONS, DECAY_MUONS, ALL_MUONS };
00020 
00021     /// Enum for the treatment of invisible particles: whether to include all, some, or none in jet-finding
00022     enum InvisiblesStrategy { NO_INVISIBLES, DECAY_INVISIBLES, ALL_INVISIBLES };
00023 
00024 
00025 
00026     /// Constructor
00027     JetAlg(const FinalState& fs, MuonsStrategy usemuons=JetAlg::ALL_MUONS, InvisiblesStrategy useinvis=JetAlg::NO_INVISIBLES);
00028 
00029     /// Default constructor
00030     JetAlg() {};
00031 
00032     /// Clone on the heap.
00033     virtual const Projection* clone() const = 0;
00034 
00035     /// Destructor
00036     virtual ~JetAlg() { }
00037 
00038 
00039     /// @name Control the treatment of muons and invisible particles
00040     ///
00041     /// Since MC-based jet calibration (and/or particle flow) can add back in
00042     /// particles that weren't seen in calorimeters/trackers.
00043     //@{
00044 
00045     /// @brief Include (some) muons in jet construction.
00046     ///
00047     /// The default behaviour is that jets are only constructed from visible
00048     /// particles. Some jet studies, including those from ATLAS, use a definition
00049     /// in which neutrinos from hadron decays are included via MC-based calibrations.
00050     /// Setting this flag to true avoids the automatic restriction to a VisibleFinalState.
00051     void useMuons(MuonsStrategy usemuons=ALL_MUONS) {
00052       _useMuons = usemuons;
00053     }
00054 
00055     /// @brief Include (some) invisible particles in jet construction.
00056     ///
00057     /// The default behaviour is that jets are only constructed from visible
00058     /// particles. Some jet studies, including those from ATLAS, use a definition
00059     /// in which neutrinos from hadron decays are included via MC-based calibrations.
00060     /// Setting this flag to true avoids the automatic restriction to a VisibleFinalState.
00061     void useInvisibles(InvisiblesStrategy useinvis=DECAY_INVISIBLES) {
00062       _useInvisibles = useinvis;
00063     }
00064 
00065     /// @brief Include (some) invisible particles in jet construction.
00066     ///
00067     /// The default behaviour is that jets are only constructed from visible
00068     /// particles. Some jet studies, including those from ATLAS, use a definition
00069     /// in which neutrinos from hadron decays are included via MC-based calibrations.
00070     /// Setting this flag to true avoids the automatic restriction to a VisibleFinalState.
00071     ///
00072     /// @deprecated Use the enum-arg version instead
00073     void useInvisibles(bool useinvis) {
00074       _useInvisibles = useinvis ? DECAY_INVISIBLES : NO_INVISIBLES;
00075     }
00076 
00077     //@}
00078 
00079 
00080     /// @name Access to jet objects
00081     //@{
00082 
00083     /// Get jets in no guaranteed order, with optional cuts on \f$ p_\perp \f$ and rapidity.
00084     /// @note Returns a copy rather than a reference, due to cuts
00085     /// @todo Can't this be a const Cut& arg?
00086     virtual Jets jets(const Cut & c = Cuts::open()) const {
00087       const Jets rawjets = _jets(0.0); // arg means no pT cut
00088       // Just return a copy of rawjets if the cut is open
00089       if (c == Cuts::open()) return rawjets;
00090       // If there is a non-trivial cut...
00091       Jets rtn;
00092       rtn.reserve(size());
00093       foreach (const Jet& j, rawjets)
00094         if (c->accept(j)) rtn.push_back(j);
00095       return rtn;
00096     }
00097 
00098     /// Get the jets, ordered by supplied sorting function object, with optional cuts on \f$ p_\perp \f$ and rapidity.
00099     /// @note Returns a copy rather than a reference, due to cuts and sorting
00100     template <typename F>
00101     Jets jets(F sorter, const Cut & c = Cuts::open()) const {
00102       /// @todo Will the vector be efficiently std::move'd by value through this function chain?
00103       return sortBy(jets(c), sorter);
00104     }
00105 
00106     /// Get the jets, ordered by supplied sorting function object, with optional cuts on \f$ p_\perp \f$ and rapidity.
00107     /// @note Returns a copy rather than a reference, due to cuts and sorting
00108     template <typename F>
00109     Jets jets(const Cut & c ,  F sorter) const {
00110       /// @todo Will the vector be efficiently std::move'd by value through this function chain?
00111       return sortBy(jets(c), sorter);
00112     }
00113 
00114 
00115     /// Get the jets, ordered by \f$ p_T \f$, with optional cuts.
00116     ///
00117     /// @note Returns a copy rather than a reference, due to cuts and sorting
00118     ///
00119     /// This is a very common use-case, so is available as syntatic sugar for jets(c, cmpMomByPt).
00120     /// @todo The other sorted accessors should be removed in a cleanup.
00121     Jets jetsByPt(const Cut & c = Cuts::open()) const {
00122       return jets(c, cmpMomByPt);
00123     }
00124 
00125     //@}
00126 
00127 
00128     /// @name Old sorted jet accessors
00129     /// @deprecated Use the versions with sorter function arguments
00130     //@{
00131 
00132     /// Get the jets, ordered by \f$ |p| \f$, with optional cuts on \f$ p_\perp \f$ and rapidity.
00133     /// @note Returns a copy rather than a reference, due to cuts and sorting
00134     /// @deprecated Use the version with a sorter function argument.
00135     DEPRECATED("Use the version with a sorter function argument.")
00136     Jets jetsByP(const Cut & c = Cuts::open()) const {
00137       return jets(c, cmpMomByP);
00138     }
00139 
00140     /// Get the jets, ordered by \f$ E \f$, with optional cuts on \f$ p_\perp \f$ and rapidity.
00141     /// @note Returns a copy rather than a reference, due to cuts and sorting
00142     /// @deprecated Use the version with a sorter function argument.
00143     DEPRECATED("Use the version with a sorter function argument.")
00144     Jets jetsByE(const Cut & c = Cuts::open()) const {
00145       return jets(c, cmpMomByE);
00146     }
00147 
00148     /// Get the jets, ordered by \f$ E_T \f$, with optional cuts on \f$ p_\perp \f$ and rapidity.
00149     /// @note Returns a copy rather than a reference, due to cuts and sorting
00150     /// @deprecated Use the version with a sorter function argument.
00151     DEPRECATED("Use the version with a sorter function argument.")
00152     Jets jetsByEt(const Cut & c = Cuts::open()) const {
00153       return jets(c, cmpMomByEt);
00154     }
00155 
00156     //@}
00157 
00158 
00159     /// @name Old jet accessors
00160     /// @deprecated Use the versions with Cut arguments
00161     //@{
00162 
00163     /// Get jets in no guaranteed order, with optional cuts on \f$ p_\perp \f$ and rapidity.
00164     ///
00165     /// @deprecated Use the version with a Cut argument
00166     /// @note Returns a copy rather than a reference, due to cuts
00167     DEPRECATED("Use the version with a Cut argument.")
00168     Jets jets(double ptmin, double ptmax=MAXDOUBLE,
00169               double rapmin=-MAXDOUBLE, double rapmax=MAXDOUBLE,
00170               RapScheme rapscheme=PSEUDORAPIDITY) const {
00171       if (rapscheme == PSEUDORAPIDITY) {
00172         return jets((Cuts::pT >= ptmin) & (Cuts::pT < ptmax) & (Cuts::rapIn(rapmin, rapmax)));
00173       } else if (rapscheme == RAPIDITY) {
00174         return jets((Cuts::pT >= ptmin) & (Cuts::pT < ptmax) & (Cuts::etaIn(rapmin, rapmax)));
00175       }
00176       throw LogicError("Unknown rapidity scheme. This shouldn't be possible!");
00177     }
00178 
00179     /// Get the jets, ordered by \f$ p_T \f$, with a cut on \f$ p_\perp \f$.
00180     ///
00181     /// @deprecated Use the version with a Cut argument
00182     /// @note Returns a copy rather than a reference, due to cuts and sorting
00183     ///
00184     /// This is a very common use-case, so is available as syntatic sugar for jets(Cuts::pT >= ptmin, cmpMomByPt).
00185     /// @todo The other sorted accessors should be removed in a cleanup.
00186     Jets jetsByPt(double ptmin) const {
00187       return jets(Cuts::pT >= ptmin, cmpMomByPt);
00188     }
00189 
00190     //@}
00191 
00192 
00193   protected:
00194 
00195     /// @brief Internal pure virtual method for getting jets in no guaranteed order.
00196     /// An optional cut on min \f$ p_\perp \f$ is applied in this function, since that is
00197     /// directly supported by FastJet and it seems a shame to not make use of that. But
00198     /// all other jet cuts are applied at the @c ::jets() function level.
00199     /// @todo Remove the ptmin cut
00200     virtual Jets _jets(double ptmin=0) const = 0;
00201 
00202 
00203   public:
00204 
00205     /// Number of jets.
00206     virtual size_t size() const = 0;
00207     /// Determine if the jet collection is empty.
00208     bool empty() const { return size() != 0; }
00209 
00210     /// Clear the projection.
00211     virtual void reset() = 0;
00212 
00213     typedef Jet entity_type;
00214     typedef Jets collection_type;
00215 
00216     /// Template-usable interface common to FinalState.
00217     collection_type entities() const { return jets(); }
00218 
00219     /// Do the calculation locally (no caching).
00220     virtual void calc(const Particles& constituents, const Particles& tagparticles=Particles()) = 0;
00221 
00222 
00223   protected:
00224 
00225     /// Perform the projection on the Event.
00226     virtual void project(const Event& e) = 0;
00227 
00228     /// Compare projections.
00229     virtual int compare(const Projection& p) const = 0;
00230 
00231 
00232   protected:
00233 
00234     /// Flag to determine whether or not to exclude (some) muons from the would-be constituents.
00235     MuonsStrategy _useMuons;
00236 
00237     /// Flag to determine whether or not to exclude (some) invisible particles from the would-be constituents.
00238     InvisiblesStrategy _useInvisibles;
00239 
00240 
00241   };
00242 
00243 
00244 }
00245 
00246 #endif