ParticleFinder.hh
Go to the documentation of this file.
00001 // -*- C++ -*- 00002 #ifndef RIVET_ParticleFinder_HH 00003 #define RIVET_ParticleFinder_HH 00004 00005 #include "Rivet/Projection.hh" 00006 #include "Rivet/Cuts.hh" 00007 00008 namespace Rivet { 00009 00010 00011 /// @brief Base class for projections which return subsets of an event's particles 00012 class ParticleFinder : public Projection { 00013 public: 00014 00015 /// @name Object lifetime management 00016 //@{ 00017 00018 /// Construction using Cuts object 00019 ParticleFinder(Cut c = Cuts::open()) : _cuts(c), _theParticles() {} 00020 00021 /// Virtual destructor for inheritance 00022 virtual ~ParticleFinder() {} 00023 00024 /// Clone on the heap. 00025 virtual const Projection* clone() const = 0; 00026 00027 //@} 00028 00029 00030 /// @name Particle accessors 00031 //@{ 00032 00033 /// Access the projected final-state particles. 00034 virtual size_t size() const { return _theParticles.size(); } 00035 00036 /// Is this final state empty? 00037 virtual bool empty() const { return _theParticles.empty(); } 00038 /// @deprecated Is this final state empty? 00039 virtual bool isEmpty() const { return _theParticles.empty(); } 00040 00041 /// Get the final-state particles in no particular order, with no cuts. 00042 virtual const Particles& particles() const { return _theParticles; } 00043 00044 /// @brief Get the final-state particles, with optional cuts. 00045 /// @note Returns a copy rather than a reference, due to cuts 00046 //virtual Particles particles(Cut c) const { } 00047 00048 /// Get the final-state particles, ordered by supplied sorting function object. 00049 /// @note Returns a copy rather than a reference, due to cuts and sorting 00050 /// @todo Update to use Cuts 00051 template <typename F> 00052 Particles particles(Cut c, F sorter) const { 00053 Particles result; 00054 result.reserve(size()); 00055 if ( c == Cuts::open() ) 00056 result.assign(_theParticles.begin(), _theParticles.end()); 00057 else 00058 foreach (const Particle& p, _theParticles) 00059 if ( c->accept(p) ) result.push_back(p); 00060 std::sort(result.begin(), result.end(), sorter); 00061 return result; 00062 } 00063 00064 /// Get the final-state particles, ordered by decreasing \f$ p_T \f$. 00065 /// @todo Update to use Cuts 00066 Particles particlesByPt(Cut c = Cuts::open()) const { 00067 return particles(c, cmpMomByPt); 00068 } 00069 00070 /// Get the final-state particles, ordered by decreasing \f$ p \f$. 00071 /// @todo Update to use Cuts 00072 /// @todo Remove, since there is the templated method or sortByX methods available for these unusual cases? 00073 Particles particlesByP(Cut c = Cuts::open()) const { 00074 return particles(c, cmpMomByP); 00075 } 00076 00077 /// Get the final-state particles, ordered by decreasing \f$ E \f$. 00078 /// @todo Update to use Cuts 00079 /// @todo Remove, since there is the templated method or sortByX methods available for these unusual cases? 00080 Particles particlesByE(Cut c = Cuts::open()) const { 00081 return particles(c, cmpMomByE); 00082 } 00083 00084 /// Get the final-state particles, ordered by decreasing \f$ E_T \f$. 00085 /// @todo Update to use Cuts 00086 /// @todo Remove, since there is the templated method or sortByX methods available for these unusual cases? 00087 Particles particlesByEt(Cut c = Cuts::open()) const { 00088 return particles(c, cmpMomByEt); 00089 } 00090 00091 /// Get the final-state particles, ordered by increasing \f$ \eta \f$. 00092 /// @todo Update to use Cuts 00093 /// @todo Remove, since there is the templated method or sortByX methods available for these unusual cases? 00094 Particles particlesByEta(Cut c = Cuts::open()) const { 00095 return particles(c, cmpMomByAscPseudorapidity); 00096 } 00097 00098 /// Get the final-state particles, ordered by increasing \f$ |\eta| \f$. 00099 /// @todo Update to use Cuts 00100 /// @todo Remove, since there is the templated method or sortByX methods available for these unusual cases? 00101 Particles particlesByModEta(Cut c = Cuts::open()) const { 00102 return particles(c, cmpMomByAscAbsPseudorapidity); 00103 } 00104 00105 /// Get the final-state particles, ordered by increasing \f$ y \f$. 00106 /// @todo Update to use Cuts 00107 /// @todo Remove, since there is the templated method or sortByX methods available for these unusual cases? 00108 Particles particlesByRapidity(Cut c = Cuts::open()) const { 00109 return particles(c, cmpMomByAscRapidity); 00110 } 00111 00112 /// Get the final-state particles, ordered by increasing \f$ |y| \f$. 00113 /// @todo Update to use Cuts 00114 /// @todo Remove, since there is the templated method or sortByX methods available for these unusual cases? 00115 Particles particlesByModRapidity(Cut c = Cuts::open()) const { 00116 return particles(c, cmpMomByAscAbsRapidity); 00117 } 00118 00119 //@} 00120 00121 00122 /// Minimum-\f$ p_\perp \f$ requirement. 00123 /// @todo Replace with cuts() accessor 00124 ///virtual Cut cuts() const { return _cuts; } 00125 00126 00127 /// @name JetAlg compatibility 00128 //@{ 00129 00130 typedef Particle entity_type; 00131 typedef Particles collection_type; 00132 00133 /// Template-usable interface common to JetAlg. 00134 const collection_type& entities() const { 00135 return particles(); 00136 } 00137 00138 //@} 00139 00140 00141 protected: 00142 00143 /// Apply the projection to the event. 00144 virtual void project(const Event& e) = 0; 00145 00146 /// Compare projections. 00147 virtual int compare(const Projection& p) const; 00148 00149 protected: 00150 /// The applicable cuts 00151 Cut _cuts; 00152 00153 /// The final-state particles. 00154 Particles _theParticles; 00155 00156 }; 00157 00158 00159 } 00160 00161 #endif Generated on Tue Sep 30 2014 19:45:46 for The Rivet MC analysis system by ![]() |