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 cmpMomByEt(const FourMomentum& a, const FourMomentum& b) {
00021     return a.Et() > b.Et();
00022   }
00023   inline bool cmpMomByAscEt(const FourMomentum& a, const FourMomentum& b) {
00024     return a.Et() < b.Et();
00025   }
00026   inline bool cmpMomByE(const FourMomentum& a, const FourMomentum& b) {
00027     return a.E() > b.E();
00028   }
00029   inline bool cmpMomByAscE(const FourMomentum& a, const FourMomentum& b) {
00030     return a.E() < b.E();
00031   }
00032   inline bool cmpMomByDescPseudorapidity(const FourMomentum& a, const FourMomentum& b) {
00033     return a.pseudorapidity() > b.pseudorapidity();
00034   }
00035   inline bool cmpMomByAscPseudorapidity(const FourMomentum& a, const FourMomentum& b) {
00036     return a.pseudorapidity() < b.pseudorapidity();
00037   }
00038   inline bool cmpMomByDescAbsPseudorapidity(const FourMomentum& a, const FourMomentum& b) {
00039     return fabs(a.pseudorapidity()) > fabs(b.pseudorapidity());
00040   }
00041   inline bool cmpMomByAscAbsPseudorapidity(const FourMomentum& a, const FourMomentum& b) {
00042     return fabs(a.pseudorapidity()) < fabs(b.pseudorapidity());
00043   }
00044   inline bool cmpMomByDescRapidity(const FourMomentum& a, const FourMomentum& b) {
00045     return a.rapidity() > b.rapidity();
00046   }
00047   inline bool cmpMomByAscRapidity(const FourMomentum& a, const FourMomentum& b) {
00048     return a.rapidity() < b.rapidity();
00049   }
00050   inline bool cmpMomByDescAbsRapidity(const FourMomentum& a, const FourMomentum& b) {
00051     return fabs(a.rapidity()) > fabs(b.rapidity());
00052   }
00053   inline bool cmpMomByAscAbsRapidity(const FourMomentum& a, const FourMomentum& b) {
00054     return fabs(a.rapidity()) < fabs(b.rapidity());
00055   }
00056 
00057 
00058   /// Abstract base class for projections which can return a set of {@link Jet}s.
00059   class JetAlg : public Projection {
00060  
00061   public:
00062 
00063     /// Constructor
00064     JetAlg(const FinalState& fs);
00065 
00066     /// Clone on the heap.
00067     virtual const Projection* clone() const = 0;
00068 
00069     /// Destructor
00070     virtual ~JetAlg() { }
00071 
00072     virtual Jets jets(double ptmin=0.0) const = 0;
00073 
00074     /// Get the jets, ordered by supplied sorting function object.
00075     template <typename F>
00076     Jets jets(F sorter, double ptmin=0.0) const {
00077       Jets js = jets(ptmin);
00078       if (sorter != 0) {
00079         std::sort(js.begin(), js.end(), sorter);
00080       }
00081       return js;
00082     }
00083 
00084     /// Get the jets, ordered by \f$ p_T \f$.
00085     Jets jetsByPt(double ptmin=0.0) const {
00086       return jets(cmpJetsByPt, ptmin);
00087     }
00088 
00089     /// Get the jets, ordered by \f$ E \f$.
00090     Jets jetsByE(double ptmin=0.0) const {
00091       return jets(cmpJetsByE, ptmin);
00092     }
00093 
00094     /// Get the jets, ordered by \f$ E_T \f$.
00095     Jets jetsByEt(double ptmin=0.0) const {
00096       return jets(cmpJetsByEt, ptmin);
00097     }
00098 
00099 
00100   public:
00101 
00102     /// Number of jets.
00103     virtual size_t size() const = 0;
00104 
00105     /// Clear the projection
00106     virtual void reset() = 0;
00107 
00108     typedef Jet entity_type;
00109     typedef Jets collection_type;
00110 
00111     /// Template-usable interface common to FinalState.
00112     collection_type entities() const { return jets(); }
00113 
00114     /// Do the calculation locally (no caching).
00115     void calc(const ParticleVector& ps);
00116 
00117 
00118   protected:
00119 
00120     /// Perform the projection on the Event.
00121     virtual void project(const Event& e) = 0;
00122 
00123     /// Compare projections.
00124     virtual int compare(const Projection& p) const = 0;
00125 
00126   };
00127 
00128 
00129 }
00130 
00131 #endif