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(const Cut& c=Cuts::open()) 00020 : _cuts(c), _theParticles() 00021 { } 00022 00023 /// Virtual destructor for inheritance 00024 virtual ~ParticleFinder() {} 00025 00026 /// Clone on the heap. 00027 virtual const Projection* clone() const = 0; 00028 00029 //@} 00030 00031 00032 /// @name Particle accessors 00033 //@{ 00034 00035 /// Get the final-state particles in no particular order, with no cuts. 00036 virtual const Particles& particles() const { return _theParticles; } 00037 00038 /// Access the projected final-state particles. 00039 size_t size() const { return particles().size(); } 00040 00041 /// Is this final state empty? 00042 bool empty() const { return particles().empty(); } 00043 /// @deprecated Is this final state empty? 00044 DEPRECATED("Use empty()") 00045 bool isEmpty() const { return particles().empty(); } 00046 00047 00048 /// @brief Get the final-state particles, with optional cuts. 00049 /// @note Returns a copy rather than a reference, due to cuts 00050 /// @todo Can't this be a const Cut& arg? 00051 Particles particles(const Cut& c) const { 00052 // Just return a copy of particles() if the cut is open 00053 if (c == Cuts::open()) return particles(); 00054 // If there is a non-trivial cut... 00055 Particles rtn; 00056 rtn.reserve(size()); 00057 foreach (const Particle& p, particles()) 00058 if (c->accept(p)) rtn.push_back(p); 00059 return rtn; 00060 } 00061 00062 /// Get the final-state particles, ordered by supplied sorting function object. 00063 /// @note Returns a copy rather than a reference, due to cuts and sorting 00064 /// @todo Can't this be a const Cut& arg? 00065 /// @todo Use a std::function instead of typename F? 00066 template <typename F> 00067 Particles particles(F sorter, const Cut & c=Cuts::open()) const { 00068 /// @todo Will the vector be efficiently std::move'd by value through this function chain? 00069 return sortBy(particles(c), sorter); 00070 } 00071 00072 /// Get the final-state particles, ordered by supplied sorting function object. 00073 /// @note Returns a copy rather than a reference, due to cuts and sorting 00074 /// @todo Can't this be a const Cut& arg? 00075 /// @todo Use a std::function instead of typename F? 00076 template <typename F> 00077 Particles particles(const Cut & c, F sorter) const { 00078 /// @todo Will the vector be efficiently std::move'd by value through this function chain? 00079 return sortBy(particles(c), sorter); 00080 } 00081 00082 /// Get the final-state particles, ordered by decreasing \f$ p_T \f$ and with optional cuts. 00083 /// 00084 /// This is a very common use-case, so is available as syntatic sugar for particles(c, cmpMomByPt). 00085 Particles particlesByPt(const Cut & c=Cuts::open()) const { 00086 return particles(c, cmpMomByPt); 00087 } 00088 00089 /// Get the final-state particles, ordered by decreasing \f$ p_T \f$ and with a cut on minimum \f$ p_T \f$. 00090 /// 00091 /// This is a very common use-case, so is available as syntatic sugar for particles(Cuts::pT >= ptmin, cmpMomByPt). 00092 Particles particlesByPt(double ptmin) const { 00093 return particles(Cuts::pT >= ptmin, cmpMomByPt); 00094 } 00095 00096 00097 /// @name Little-used sorted accessors 00098 /// @deprecated Use the versions with a sorter function argument 00099 //@{ 00100 00101 /// Get the final-state particles, ordered by decreasing \f$ p \f$. 00102 /// @todo Remove, since there is the templated method or sortByX methods available for these unusual cases? 00103 /// @deprecated Use the version with a sorter function argument 00104 DEPRECATED("Use the version with a sorter function argument") 00105 Particles particlesByP(const Cut & c=Cuts::open()) const { 00106 return particles(c, cmpMomByP); 00107 } 00108 00109 /// Get the final-state particles, ordered by decreasing \f$ E \f$. 00110 /// @todo Remove, since there is the templated method or sortByX methods available for these unusual cases? 00111 /// @deprecated Use the version with a sorter function argument 00112 DEPRECATED("Use the version with a sorter function argument") 00113 Particles particlesByE(const Cut & c=Cuts::open()) const { 00114 return particles(c, cmpMomByE); 00115 } 00116 00117 /// Get the final-state particles, ordered by decreasing \f$ E_T \f$. 00118 /// @todo Remove, since there is the templated method or sortByX methods available for these unusual cases? 00119 /// @deprecated Use the version with a sorter function argument 00120 DEPRECATED("Use the version with a sorter function argument") 00121 Particles particlesByEt(const Cut & c=Cuts::open()) const { 00122 return particles(c, cmpMomByEt); 00123 } 00124 00125 /// Get the final-state particles, ordered by increasing \f$ \eta \f$. 00126 /// @todo Remove, since there is the templated method or sortByX methods available for these unusual cases? 00127 /// @deprecated Use the version with a sorter function argument 00128 DEPRECATED("Use the version with a sorter function argument") 00129 Particles particlesByEta(const Cut & c=Cuts::open()) const { 00130 return particles(c, cmpMomByEta); 00131 } 00132 00133 /// Get the final-state particles, ordered by increasing \f$ |\eta| \f$. 00134 /// @todo Remove, since there is the templated method or sortByX methods available for these unusual cases? 00135 /// @deprecated Use the version with a sorter function argument 00136 DEPRECATED("Use the version with a sorter function argument") 00137 Particles particlesByModEta(const Cut & c=Cuts::open()) const { 00138 return particles(c, cmpMomByAbsEta); 00139 } 00140 00141 /// Get the final-state particles, ordered by increasing \f$ y \f$. 00142 /// @todo Remove, since there is the templated method or sortByX methods available for these unusual cases? 00143 /// @deprecated Use the version with a sorter function argument 00144 DEPRECATED("Use the version with a sorter function argument") 00145 Particles particlesByRapidity(const Cut & c=Cuts::open()) const { 00146 return particles(c, cmpMomByRap); 00147 } 00148 00149 /// Get the final-state particles, ordered by increasing \f$ |y| \f$. 00150 /// @todo Remove, since there is the templated method or sortByX methods available for these unusual cases? 00151 /// @deprecated Use the version with a sorter function argument 00152 DEPRECATED("Use the version with a sorter function argument") 00153 Particles particlesByModRapidity(const Cut & c=Cuts::open()) const { 00154 return particles(c, cmpMomByAbsRap); 00155 } 00156 00157 //@} 00158 00159 //@} 00160 00161 00162 /// @todo Replace with cuts() accessor 00163 ///virtual Cut cuts() const { return _cuts; } 00164 00165 00166 /// @name For JetAlg compatibility 00167 //@{ 00168 00169 typedef Particle entity_type; 00170 typedef Particles collection_type; 00171 00172 /// Template-usable interface common to JetAlg 00173 const collection_type& entities() const { 00174 return particles(); 00175 } 00176 00177 //@} 00178 00179 00180 protected: 00181 00182 /// Apply the projection to the event 00183 virtual void project(const Event& e) = 0; 00184 00185 /// Compare projections 00186 virtual int compare(const Projection& p) const; 00187 00188 /// The kinematic cuts cuts 00189 Cut _cuts; 00190 00191 /// The found particles returned by the particles() methods 00192 Particles _theParticles; 00193 00194 }; 00195 00196 00197 } 00198 00199 #endif Generated on Thu Mar 10 2016 08:29:52 for The Rivet MC analysis system by ![]() |