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     ParticleBase() { }
00015 
00016     virtual ~ParticleBase() { }
00017 
00018     // virtual FourMomentum& momentum() = 0;
00019 
00020     virtual const FourMomentum& momentum() const = 0;
00021 
00022 
00023     /// Struct for sorting by increasing transverse momentum in STL set, sort, etc.
00024     struct byPTAscending {
00025       bool operator()(const ParticleBase& left, const ParticleBase& right) const {
00026         double pt2left = left.momentum().pT2();
00027         double pt2right = right.momentum().pT2();
00028         return pt2left < pt2right;
00029       }
00030 
00031       bool operator()(const ParticleBase* left, const ParticleBase* right) const {
00032         return (*this)(*left, *right);
00033       }
00034     };
00035 
00036 
00037     /// Struct for sorting by decreasing transverse momentum in STL set, sort etc.
00038     struct byPTDescending {
00039       bool operator()(const ParticleBase& left, const ParticleBase& right) const {
00040         return byPTAscending()(right, left);
00041       }
00042 
00043       bool operator()(const ParticleBase* left, const ParticleBase* right) const {
00044         return (*this)(*left, *right);
00045       }
00046     };
00047 
00048 
00049     /// Struct for sorting by increasing transverse energy
00050     struct byETAscending {
00051       bool operator()(const ParticleBase& left, const ParticleBase& right) const {
00052         double pt2left = left.momentum().Et2();
00053         double pt2right = right.momentum().Et2();
00054         return pt2left < pt2right;
00055       }
00056 
00057       bool operator()(const ParticleBase* left, const ParticleBase* right) const {
00058         return (*this)(*left, *right);
00059       }
00060     };
00061 
00062 
00063     /// Struct for sorting by decreasing transverse energy
00064     struct byETDescending {
00065       bool operator()(const ParticleBase& left, const ParticleBase& right) const {
00066         return byETAscending()(right, left);
00067       }
00068 
00069       bool operator()(const ParticleBase* left, const ParticleBase* right) const {
00070         return (*this)(*left, *right);
00071       }
00072     };
00073 
00074 
00075     /// Struct for sorting by increasing energy
00076     struct byEAscending {
00077       bool operator()(const ParticleBase& left, const ParticleBase& right) const {
00078         double pt2left = left.momentum().E();
00079         double pt2right = right.momentum().E();
00080         return pt2left < pt2right;
00081       }
00082 
00083       bool operator()(const ParticleBase* left, const ParticleBase* right) const {
00084         return (*this)(*left, *right);
00085       }
00086     };
00087 
00088 
00089     /// Struct for sorting by decreasing energy
00090     struct byEDescending {
00091       bool operator()(const ParticleBase& left, const ParticleBase& right) const {
00092         return byEAscending()(right, left);
00093       }
00094 
00095       bool operator()(const ParticleBase* left, const ParticleBase* right) const {
00096         return (*this)(*left, *right);
00097       }
00098     };
00099 
00100 
00101   };
00102 
00103 
00104 }
00105 
00106 #endif