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   inline bool cmpMomByPt(const FourMomentum& a, const FourMomentum& b) {
00015     return a.pT() > b.pT();
00016   }
00017   inline bool cmpMomByAscPt(const FourMomentum& a, const FourMomentum& b) {
00018     return a.pT() < b.pT();
00019   }
00020   inline bool cmpMomByP(const FourMomentum& a, const FourMomentum& b) {
00021     return a.vector3().mod() > b.vector3().mod();
00022   }
00023   inline bool cmpMomByAscP(const FourMomentum& a, const FourMomentum& b) {
00024     return a.vector3().mod() < b.vector3().mod();
00025   }
00026   inline bool cmpMomByEt(const FourMomentum& a, const FourMomentum& b) {
00027     return a.Et() > b.Et();
00028   }
00029   inline bool cmpMomByAscEt(const FourMomentum& a, const FourMomentum& b) {
00030     return a.Et() < b.Et();
00031   }
00032   inline bool cmpMomByE(const FourMomentum& a, const FourMomentum& b) {
00033     return a.E() > b.E();
00034   }
00035   inline bool cmpMomByAscE(const FourMomentum& a, const FourMomentum& b) {
00036     return a.E() < b.E();
00037   }
00038   inline bool cmpMomByDescPseudorapidity(const FourMomentum& a, const FourMomentum& b) {
00039     return a.pseudorapidity() > b.pseudorapidity();
00040   }
00041   inline bool cmpMomByAscPseudorapidity(const FourMomentum& a, const FourMomentum& b) {
00042     return a.pseudorapidity() < b.pseudorapidity();
00043   }
00044   inline bool cmpMomByDescAbsPseudorapidity(const FourMomentum& a, const FourMomentum& b) {
00045     return fabs(a.pseudorapidity()) > fabs(b.pseudorapidity());
00046   }
00047   inline bool cmpMomByAscAbsPseudorapidity(const FourMomentum& a, const FourMomentum& b) {
00048     return fabs(a.pseudorapidity()) < fabs(b.pseudorapidity());
00049   }
00050   inline bool cmpMomByDescRapidity(const FourMomentum& a, const FourMomentum& b) {
00051     return a.rapidity() > b.rapidity();
00052   }
00053   inline bool cmpMomByAscRapidity(const FourMomentum& a, const FourMomentum& b) {
00054     return a.rapidity() < b.rapidity();
00055   }
00056   inline bool cmpMomByDescAbsRapidity(const FourMomentum& a, const FourMomentum& b) {
00057     return fabs(a.rapidity()) > fabs(b.rapidity());
00058   }
00059   inline bool cmpMomByAscAbsRapidity(const FourMomentum& a, const FourMomentum& b) {
00060     return fabs(a.rapidity()) < fabs(b.rapidity());
00061   }
00062 
00063 
00064   /// Abstract base class for projections which can return a set of {@link Jet}s.
00065   class JetAlg : public Projection {
00066   public:
00067 
00068     /// Constructor
00069     JetAlg(const FinalState& fs);
00070 
00071     JetAlg() {};
00072 
00073     /// Clone on the heap.
00074     virtual const Projection* clone() const = 0;
00075 
00076     /// Destructor
00077     virtual ~JetAlg() { }
00078 
00079     /// @brief Include invisible particles in jet construction.
00080     /// The default behaviour is that jets are only constructed from visible
00081     /// (i.e. charged under an SM gauge group) particles. Some jet studies,
00082     /// including those from ATLAS, use a definition in which neutrinos from hadron
00083     /// decays are included (via MC correction) in the experimental jet definition.
00084     /// Setting this flag to true avoids the automatic restriction to a VisibleFinalState.
00085     void useInvisibles(bool useinvis=true) {
00086       _useInvisibles = useinvis;
00087     }
00088 
00089     /// Get jets in no guaranteed order, with optional cuts on \f$ p_\perp \f$ and rapidity.
00090     /// @todo Introduce MomentumFilter objects for pT, ET, eta, y, etc. filtering, to avoid double-arg ambiguities
00091     virtual Jets jets(double ptmin=0.0, double ptmax=MAXDOUBLE,
00092                       double rapmin=-MAXDOUBLE, double rapmax=MAXDOUBLE,
00093                       RapScheme rapscheme=PSEUDORAPIDITY) const {
00094       const Jets rawjets = _jets(ptmin);
00095       Jets rtn;
00096       MSG_DEBUG("Raw jet size (with pTmin cut = " << ptmin/GeV << "GeV) = " << rawjets.size());
00097       foreach (const Jet& j, rawjets) {
00098         const FourMomentum pj = j.momentum();
00099         if (!inRange(pj.pT(), ptmin, ptmax)) continue;
00100         if (rapscheme == PSEUDORAPIDITY && !inRange(pj.eta(), rapmin, rapmax)) continue;
00101         if (rapscheme == RAPIDITY && !inRange(pj.rapidity(), rapmin, rapmax)) continue;
00102         rtn += j;
00103       }
00104       return rtn;
00105     }
00106 
00107     /// Get the jets, ordered by supplied sorting function object, with optional cuts on \f$ p_\perp \f$ and rapidity.
00108     /// @todo Introduce MomentumFilter objects for pT, ET, eta, y, etc. filtering, to avoid double-arg ambiguities
00109     template <typename F>
00110     Jets jets(F sorter, double ptmin, double ptmax,
00111               double rapmin, double rapmax,
00112               RapScheme rapscheme) const {
00113       Jets js = jets(ptmin, ptmax, rapmin, rapmax, rapscheme);
00114       if (sorter != 0) {
00115         std::sort(js.begin(), js.end(), sorter);
00116       }
00117       return js;
00118     }
00119 
00120     /// Get the jets, ordered by \f$ p_T \f$, with optional cuts on \f$ p_\perp \f$ and rapidity.
00121     /// @todo Introduce MomentumFilter objects for pT, ET, eta, y, etc. filtering, to avoid double-arg ambiguities
00122     Jets jetsByPt(double ptmin=0.0, double ptmax=MAXDOUBLE,
00123                   double rapmin=-MAXDOUBLE, double rapmax=MAXDOUBLE,
00124                   RapScheme rapscheme=PSEUDORAPIDITY) const {
00125       return jets(cmpJetsByPt, ptmin, ptmax, rapmin, rapmax, rapscheme);
00126     }
00127 
00128     /// Get the jets, ordered by \f$ |p| \f$, with optional cuts on \f$ p_\perp \f$ and rapidity.
00129     /// @todo Introduce MomentumFilter objects for pT, ET, eta, y, etc. filtering, to avoid double-arg ambiguities
00130     Jets jetsByP(double ptmin=0.0, double ptmax=MAXDOUBLE,
00131                  double rapmin=-MAXDOUBLE, double rapmax=MAXDOUBLE,
00132                  RapScheme rapscheme=PSEUDORAPIDITY) const {
00133       return jets(cmpJetsByP, ptmin, ptmax, rapmin, rapmax, rapscheme);
00134     }
00135 
00136     /// Get the jets, ordered by \f$ E \f$, with optional cuts on \f$ p_\perp \f$ and rapidity.
00137     /// @todo Introduce MomentumFilter objects for pT, ET, eta, y, etc. filtering, to avoid double-arg ambiguities
00138     Jets jetsByE(double ptmin=0.0, double ptmax=MAXDOUBLE,
00139                  double rapmin=-MAXDOUBLE, double rapmax=MAXDOUBLE,
00140                  RapScheme rapscheme=PSEUDORAPIDITY) const {
00141       return jets(cmpJetsByE, ptmin, ptmax, rapmin, rapmax, rapscheme);
00142     }
00143 
00144     /// Get the jets, ordered by \f$ E_T \f$, with optional cuts on \f$ p_\perp \f$ and rapidity.
00145     /// @todo Introduce MomentumFilter objects for pT, ET, eta, y, etc. filtering, to avoid double-arg ambiguities
00146     Jets jetsByEt(double ptmin=0.0, double ptmax=MAXDOUBLE,
00147                   double rapmin=-MAXDOUBLE, double rapmax=MAXDOUBLE,
00148                   RapScheme rapscheme=PSEUDORAPIDITY) const {
00149       return jets(cmpJetsByEt, ptmin, ptmax, rapmin, rapmax, rapscheme);
00150     }
00151 
00152 
00153   protected:
00154 
00155     /// @brief Internal pure virtual method for getting jets in no guaranteed order.
00156     /// An optional cut on min \f$ p_\perp \f$ is applied in this function, since that is
00157     /// directly supported by FastJet and it seems a shame to not make use of that. But
00158     /// all other jet cuts are applied at the @c ::jets() function level.
00159     virtual Jets _jets(double ptmin) const = 0;
00160 
00161 
00162   public:
00163 
00164     /// Number of jets.
00165     virtual size_t size() const = 0;
00166 
00167     /// Clear the projection
00168     virtual void reset() = 0;
00169 
00170     typedef Jet entity_type;
00171     typedef Jets collection_type;
00172 
00173     /// Template-usable interface common to FinalState.
00174     collection_type entities() const { return jets(); }
00175 
00176     /// Do the calculation locally (no caching).
00177     virtual void calc(const ParticleVector& ps) = 0;
00178 
00179 
00180   protected:
00181 
00182     /// Perform the projection on the Event.
00183     virtual void project(const Event& e) = 0;
00184 
00185     /// Compare projections.
00186     virtual int compare(const Projection& p) const = 0;
00187 
00188 
00189   protected:
00190 
00191     /// Flag to determine whether or not the VFS wrapper is to be used.
00192     bool _useInvisibles;
00193 
00194   };
00195 
00196 
00197 }
00198 
00199 #endif