rivet is hosted by Hepforge, IPPP Durham
ParticleBase.hh
Go to the documentation of this file.
00001 #ifndef RIVET_ParticleBase_HH
00002 #define RIVET_ParticleBase_HH
00003 
00004 #include "Rivet/Rivet.hh"
00005 #include "Rivet/Math/Vectors.hh"
00006 
00007 namespace Rivet {
00008 
00009 
00010   /// @brief Base class for particle-like things like Particle and Jet
00011   class ParticleBase {
00012   public:
00013 
00014     /// Default constructor
00015     ParticleBase() { }
00016 
00017     /// Virtual destructor
00018     virtual ~ParticleBase() { }
00019 
00020 
00021     /// @name Effective momentum accessors
00022     //@{
00023 
00024     /// Get equivalent single momentum four-vector.
00025     // virtual FourMomentum& momentum() = 0;
00026 
00027     /// Get equivalent single momentum four-vector (const).
00028     virtual const FourMomentum& momentum() const = 0;
00029 
00030     //@}
00031 
00032 
00033     /// @name Convenience access to the effective 4-vector properties
00034     //@{
00035 
00036     /// Get the energy directly.
00037     double energy() const { return momentum().E(); }
00038     /// Get the energy directly.
00039     double E() const { return momentum().E(); }
00040 
00041     /// Get the \f$ p_T \f$ directly.
00042     double pT() const { return momentum().pT(); }
00043 
00044     /// Get the \f$ E_T \f$ directly.
00045     double Et() const { return momentum().Et(); }
00046 
00047     /// Get the mass directly.
00048     double mass() const { return momentum().mass(); }
00049 
00050     /// Get the \f$ \eta \f$ directly.
00051     double pseudorapidity() const { return momentum().eta(); }
00052     /// Get the \f$ \eta \f$ directly.
00053     double eta() const { return momentum().eta(); }
00054 
00055     /// Get the \f$ \eta \f$ directly.
00056     double rapidity() const { return momentum().rapidity(); }
00057 
00058     /// Get the \f$ \phi \f$ directly.
00059     double phi() const { return momentum().phi(); }
00060 
00061     //@}
00062 
00063 
00064 
00065     /// Struct for sorting by increasing transverse momentum in STL set, sort, etc.
00066     struct byPTAscending {
00067       bool operator()(const ParticleBase& left, const ParticleBase& right) const {
00068         double pt2left = left.momentum().pT2();
00069         double pt2right = right.momentum().pT2();
00070         return pt2left < pt2right;
00071       }
00072 
00073       bool operator()(const ParticleBase* left, const ParticleBase* right) const {
00074         return (*this)(*left, *right);
00075       }
00076     };
00077 
00078 
00079     /// Struct for sorting by decreasing transverse momentum in STL set, sort etc.
00080     struct byPTDescending {
00081       bool operator()(const ParticleBase& left, const ParticleBase& right) const {
00082         return byPTAscending()(right, left);
00083       }
00084 
00085       bool operator()(const ParticleBase* left, const ParticleBase* right) const {
00086         return (*this)(*left, *right);
00087       }
00088     };
00089 
00090 
00091     /// Struct for sorting by increasing transverse energy
00092     struct byETAscending {
00093       bool operator()(const ParticleBase& left, const ParticleBase& right) const {
00094         double pt2left = left.momentum().Et2();
00095         double pt2right = right.momentum().Et2();
00096         return pt2left < pt2right;
00097       }
00098 
00099       bool operator()(const ParticleBase* left, const ParticleBase* right) const {
00100         return (*this)(*left, *right);
00101       }
00102     };
00103 
00104 
00105     /// Struct for sorting by decreasing transverse energy
00106     struct byETDescending {
00107       bool operator()(const ParticleBase& left, const ParticleBase& right) const {
00108         return byETAscending()(right, left);
00109       }
00110 
00111       bool operator()(const ParticleBase* left, const ParticleBase* right) const {
00112         return (*this)(*left, *right);
00113       }
00114     };
00115 
00116 
00117     /// Struct for sorting by increasing energy
00118     struct byEAscending {
00119       bool operator()(const ParticleBase& left, const ParticleBase& right) const {
00120         double pt2left = left.momentum().E();
00121         double pt2right = right.momentum().E();
00122         return pt2left < pt2right;
00123       }
00124 
00125       bool operator()(const ParticleBase* left, const ParticleBase* right) const {
00126         return (*this)(*left, *right);
00127       }
00128     };
00129 
00130 
00131     /// Struct for sorting by decreasing energy
00132     struct byEDescending {
00133       bool operator()(const ParticleBase& left, const ParticleBase& right) const {
00134         return byEAscending()(right, left);
00135       }
00136 
00137       bool operator()(const ParticleBase* left, const ParticleBase* right) const {
00138         return (*this)(*left, *right);
00139       }
00140     };
00141 
00142 
00143   };
00144 
00145 
00146 }
00147 
00148 #endif