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     /// Cast operator for conversion to FourMomentum
00031     operator const FourMomentum& () const { return momentum(); }
00032 
00033     /// @todo Add a cast operator to FJ3 PseudoJet
00034 
00035     //@}
00036 
00037 
00038     /// @name Convenience access to the effective 4-vector properties
00039     //@{
00040 
00041     /// Get the energy directly.
00042     double E() const { return momentum().E(); }
00043     /// Get the energy directly (alias).
00044     double energy() const { return momentum().E(); }
00045 
00046     /// Get the \f$ p_T \f$ directly.
00047     double pt() const { return momentum().pt(); }
00048     /// Get the \f$ p_T \f$ directly (alias).
00049     double pT() const { return pt(); }
00050     /// Get the \f$ p_T \f$ directly (alias).
00051     double perp() const { return pt(); }
00052 
00053     /// Get the \f$ E_T \f$ directly.
00054     double Et() const { return momentum().Et(); }
00055 
00056     /// Get the mass directly.
00057     double mass() const { return momentum().mass(); }
00058     /// Get the mass**2 directly.
00059     double mass2() const { return momentum().mass2(); }
00060 
00061     /// Get the \f$ \eta \f$ directly.
00062     double pseudorapidity() const { return momentum().eta(); }
00063     /// Get the \f$ \eta \f$ directly (alias).
00064     double eta() const { return momentum().eta(); }
00065     /// Get the \f$ |\eta| \f$ directly.
00066     double abspseudorapidity() const { return momentum().abspseudorapidity(); }
00067     /// Get the \f$ |\eta| \f$ directly (alias).
00068     double abseta() const { return momentum().abseta(); }
00069 
00070     /// Get the \f$ y \f$ directly.
00071     double rapidity() const { return momentum().rapidity(); }
00072     /// Get the \f$ y \f$ directly (alias).
00073     double rap() const { return momentum().rapidity(); }
00074     /// Get the \f$ |y| \f$ directly.
00075     double absrapidity() const { return momentum().absrapidity(); }
00076     /// Get the \f$ |y| \f$ directly (alias).
00077     double absrap() const { return momentum().absrap(); }
00078 
00079     /// Get the \f$ \phi \f$ directly.
00080     double phi() const { return momentum().phi(); }
00081 
00082     //@}
00083 
00084 
00085     /// Struct for sorting by increasing transverse momentum in STL set, sort, etc.
00086     struct byPTAscending {
00087       bool operator()(const ParticleBase& left, const ParticleBase& right) const {
00088         double pt2left = left.momentum().pT2();
00089         double pt2right = right.momentum().pT2();
00090         return pt2left < pt2right;
00091       }
00092 
00093       bool operator()(const ParticleBase* left, const ParticleBase* right) const {
00094         return (*this)(*left, *right);
00095       }
00096     };
00097 
00098 
00099     /// Struct for sorting by decreasing transverse momentum in STL set, sort etc.
00100     struct byPTDescending {
00101       bool operator()(const ParticleBase& left, const ParticleBase& right) const {
00102         return byPTAscending()(right, left);
00103       }
00104 
00105       bool operator()(const ParticleBase* left, const ParticleBase* right) const {
00106         return (*this)(*left, *right);
00107       }
00108     };
00109 
00110 
00111     /// Struct for sorting by increasing transverse energy
00112     struct byETAscending {
00113       bool operator()(const ParticleBase& left, const ParticleBase& right) const {
00114         double pt2left = left.momentum().Et2();
00115         double pt2right = right.momentum().Et2();
00116         return pt2left < pt2right;
00117       }
00118 
00119       bool operator()(const ParticleBase* left, const ParticleBase* right) const {
00120         return (*this)(*left, *right);
00121       }
00122     };
00123 
00124 
00125     /// Struct for sorting by decreasing transverse energy
00126     struct byETDescending {
00127       bool operator()(const ParticleBase& left, const ParticleBase& right) const {
00128         return byETAscending()(right, left);
00129       }
00130 
00131       bool operator()(const ParticleBase* left, const ParticleBase* right) const {
00132         return (*this)(*left, *right);
00133       }
00134     };
00135 
00136 
00137     /// Struct for sorting by increasing energy
00138     struct byEAscending {
00139       bool operator()(const ParticleBase& left, const ParticleBase& right) const {
00140         double pt2left = left.momentum().E();
00141         double pt2right = right.momentum().E();
00142         return pt2left < pt2right;
00143       }
00144 
00145       bool operator()(const ParticleBase* left, const ParticleBase* right) const {
00146         return (*this)(*left, *right);
00147       }
00148     };
00149 
00150 
00151     /// Struct for sorting by decreasing energy
00152     struct byEDescending {
00153       bool operator()(const ParticleBase& left, const ParticleBase& right) const {
00154         return byEAscending()(right, left);
00155       }
00156 
00157       bool operator()(const ParticleBase* left, const ParticleBase* right) const {
00158         return (*this)(*left, *right);
00159       }
00160     };
00161 
00162   };
00163 
00164 
00165 }
00166 
00167 #endif