|
|
|||
File indexing completed on 2026-08-06 09:38:21
0001 // -*- C++ -*- 0002 // 0003 // SelectorBase.h is a part of ThePEG - Toolkit for HEP Event Generation 0004 // Copyright (C) 1999-2019 Leif Lonnblad 0005 // 0006 // ThePEG is licenced under version 3 of the GPL, see COPYING for details. 0007 // Please respect the MCnet academic guidelines, see GUIDELINES for details. 0008 // 0009 #ifndef ThePEG_SelectorBase_H 0010 #define ThePEG_SelectorBase_H 0011 // This is the declaration of the SelectorBase class. 0012 0013 0014 #include "EventConfig.h" 0015 0016 namespace ThePEG { 0017 0018 /** 0019 * Classes derived from the <code>SelectorBase</code> class are used 0020 * to extract particles from an Event with 0021 * <code>Event::select()</code> method. There are five different kinds 0022 * of checks done by a selector object in the 0023 * <code>Event::select</code> method. If the 0024 * <code>allCollisions()</code> method returns false, only particles 0025 * which belongs to the primary collision in an event will be 0026 * considered for extraction. Furthermore if the 0027 * <code>allSteps()</code> method returns false, only particles 0028 * present in the final step of each collision will be considered. If 0029 * <code>finalState()</code> returns false, final state particles will 0030 * not be considered and if <code>intermediate()</code> returns false, 0031 * intermediate particles will not be considered. Finally among all 0032 * considered particles, only the ones for which the <code>check(const 0033 * Particle &)</code> returns true will be extracted. 0034 * 0035 * 0036 * 0037 * 0038 * @see StandardSelectors 0039 * @see Event 0040 * @see Collision 0041 * @see Step 0042 * @see Particle 0043 * 0044 */ 0045 class SelectorBase { 0046 0047 public: 0048 0049 /** 0050 * Virtual destructor. 0051 */ 0052 virtual ~SelectorBase() {} 0053 0054 /** 0055 * Static method corresponding to the virtual check() method. 0056 */ 0057 static bool Check(const Particle &) { return true; } 0058 0059 /** 0060 * Static method corresponding to the virtual intermediate() method. 0061 */ 0062 static bool Intermediate() { return true; } 0063 0064 /** 0065 * Static method corresponding to the virtual finalState() method. 0066 */ 0067 static bool FinalState() { return true; } 0068 0069 /** 0070 * Static method corresponding to the virtual allSteps() method. 0071 */ 0072 static bool AllSteps() { return true; } 0073 0074 /** 0075 * Static method corresponding to the virtual allCollisions() method. 0076 */ 0077 static bool AllCollisions() { return true; } 0078 0079 /** 0080 * Return true if the particle should be extracted. 0081 */ 0082 virtual bool check(const Particle & p) const { return Check(p); } 0083 0084 /** 0085 * Return true if final state particles are to be considered. 0086 */ 0087 virtual bool finalState() const { return FinalState(); } 0088 0089 /** 0090 * Return true if intermediate particles should be considered. 0091 */ 0092 virtual bool intermediate() const { return Intermediate(); } 0093 0094 /** 0095 * Return true if all steps should be considered. Otherwise only the 0096 * last step in each collision is considered. 0097 */ 0098 virtual bool allSteps() const { return AllSteps(); } 0099 0100 /** 0101 * Return ture if all collisions should be considered. Otherwise 0102 * only the primary collision will be considered. 0103 */ 0104 virtual bool allCollisions() const { return AllCollisions(); } 0105 0106 }; 0107 0108 /** 0109 * The templated <code>ParticleSelector</code> class may be used to 0110 * implement derived classes from the <code>SelectorBase</code> 0111 * class. The requirement on the template class is that it implements 0112 * the static <code>AllCollisions()</code>, <code>AllSteps()</code>, 0113 * <code>FinalState()</code>, <code>Intermediate()</code> and 0114 * <code>Check(const Particle &)</code> (corresponding to the virtual 0115 * ones in <code>ParticleSelector</code>). 0116 */ 0117 template <class T> 0118 struct ParticleSelector: public SelectorBase { 0119 0120 /** 0121 * Static method corresponding to the virtual check() method. 0122 */ 0123 static bool Check(const Particle & p) { return T::Check(p); } 0124 0125 /** 0126 * Static method corresponding to the virtual intermediate() method. 0127 */ 0128 static bool Intermediate() { return T::Intermediate(); } 0129 0130 /** 0131 * Static method corresponding to the virtual finalState() method. 0132 */ 0133 static bool FinalState() { return T::FinalState(); } 0134 0135 /** 0136 * Static method corresponding to the virtual allSteps() method. 0137 */ 0138 static bool AllSteps() { return T::AllSteps(); } 0139 0140 /** 0141 * Static method corresponding to the virtual allCollisions() method. 0142 */ 0143 static bool AllCollisions() { return T::AllCollisions(); } 0144 0145 /** 0146 * Return true if the particle should be extracted. 0147 */ 0148 virtual bool check(const Particle & p) const { return Check(p); } 0149 0150 /** 0151 * Return true if final state particles are to be considered. 0152 */ 0153 virtual bool finalState() const { return FinalState(); } 0154 0155 /** 0156 * Return true if intermediate particles should be considered. 0157 */ 0158 virtual bool intermediate() const { return Intermediate(); } 0159 0160 /** 0161 * Return true if all steps should be considered. Otherwise only the 0162 * last step in each collision is considered. 0163 */ 0164 virtual bool allSteps() const { return AllSteps(); } 0165 0166 /** 0167 * Return ture if all collisions should be considered. Otherwise 0168 * only the primary collision will be considered. 0169 */ 0170 virtual bool allCollisions() const { return AllCollisions(); } 0171 0172 }; 0173 0174 /** 0175 * The SelectIfNot classes can be used to negate the meaning of 0176 * another SelectorBase object. 0177 */ 0178 class SelectIfNot: public SelectorBase { 0179 0180 public: 0181 0182 /** Constructor taking the SelectorBase object to be negated. */ 0183 explicit SelectIfNot(const SelectorBase & S) : s(S) {} 0184 0185 /** 0186 * Return true if the particle should be extracted. 0187 */ 0188 virtual bool check(const Particle & p) const { return !s.check(p); } 0189 0190 /** 0191 * Return true if final state particles are to be considered. 0192 */ 0193 virtual bool finalState() const { return !s.finalState(); } 0194 0195 /** 0196 * Return true if intermediate particles should be considered. 0197 */ 0198 virtual bool intermediate() const { return !s.intermediate(); } 0199 0200 /** 0201 * Return true if all steps should be considered. Otherwise only the 0202 * last step in each collision is considered. 0203 */ 0204 virtual bool allSteps() const { return !s.allSteps(); } 0205 0206 /** 0207 * Return ture if all collisions should be considered. Otherwise 0208 * only the primary collision will be considered. 0209 */ 0210 virtual bool allCollisions() const { return !s.allCollisions(); } 0211 0212 private: 0213 0214 /** 0215 * The selector to be negated. 0216 */ 0217 const SelectorBase & s; 0218 }; 0219 0220 /** 0221 * The SelectIfBoth class can be used to combine other selector 0222 * objects. Particles which would be extracted with either selectors 0223 * will be extractor. 0224 */ 0225 class SelectIfBoth: public SelectorBase { 0226 0227 public: 0228 0229 /** 0230 * Constructor taking two SelectorBase object to be combiden. 0231 */ 0232 SelectIfBoth(const SelectorBase & S1, const SelectorBase & S2) 0233 : s1(S1), s2(S2) {} 0234 0235 /** 0236 * Return true if the particle should be extracted. 0237 */ 0238 virtual bool check(const Particle & p) const { 0239 return s1.check(p) && s2.check(p); 0240 } 0241 0242 /** 0243 * Return true if final state particles are to be considered. 0244 */ 0245 virtual bool finalState() const { 0246 return s1.finalState() && s2.finalState(); 0247 } 0248 0249 /** 0250 * Return true if intermediate particles should be considered. 0251 */ 0252 virtual bool intermediate() const { 0253 return s1.intermediate() && s2.intermediate(); 0254 } 0255 0256 /** 0257 * Return true if all steps should be considered. Otherwise only the 0258 * last step in each collision is considered. 0259 */ 0260 virtual bool allSteps() const { 0261 return s1.allSteps() && s2.allSteps(); 0262 } 0263 0264 /** 0265 * Return ture if all collisions should be considered. Otherwise 0266 * only the primary collision will be considered. 0267 */ 0268 virtual bool allCollisions() const { 0269 return s1.allCollisions() && s2.allCollisions(); 0270 } 0271 0272 private: 0273 0274 /** 0275 * One selector to be combined. 0276 */ 0277 const SelectorBase & s1; 0278 0279 /** 0280 * The other selector to be combined. 0281 */ 0282 const SelectorBase & s2; 0283 0284 }; 0285 0286 /** 0287 * The SelectIfEither class can be used to combine other selector 0288 * objects. Only particles which would be extracted with both selectors 0289 * will be extractor. 0290 */ 0291 class SelectIfEither: public SelectorBase { 0292 0293 public: 0294 0295 /** 0296 * Constructor taking two SelectorBase object to be combiden. 0297 */ 0298 SelectIfEither(const SelectorBase & S1, const SelectorBase & S2) 0299 : s1(S1), s2(S2) {} 0300 0301 /** 0302 * Return true if the particle should be extracted. 0303 */ 0304 virtual bool check(const Particle & p) const { 0305 return s1.check(p) || s2.check(p); 0306 } 0307 0308 /** 0309 * Return true if final state particles are to be considered. 0310 */ 0311 virtual bool finalState() const { 0312 return s1.finalState() || s2.finalState(); 0313 } 0314 0315 /** 0316 * Return true if intermediate particles should be considered. 0317 */ 0318 virtual bool intermediate() const { 0319 return s1.intermediate() || s2.intermediate(); 0320 } 0321 0322 /** 0323 * Return true if all steps should be considered. Otherwise only the 0324 * last step in each collision is considered. 0325 */ 0326 virtual bool allSteps() const { 0327 return s1.allSteps() || s2.allSteps(); 0328 } 0329 0330 /** 0331 * Return ture if all collisions should be considered. Otherwise 0332 * only the primary collision will be considered. 0333 */ 0334 virtual bool allCollisions() const { 0335 return s1.allCollisions() || s2.allCollisions(); 0336 } 0337 0338 private: 0339 0340 /** 0341 * One selector to be combined. 0342 */ 0343 const SelectorBase & s1; 0344 0345 /** 0346 * The other selector to be combined. 0347 */ 0348 const SelectorBase & s2; 0349 0350 }; 0351 0352 /** Helper function to be used together with SelectorBase objects. */ 0353 template <typename OutputIterator, typename Container> 0354 inline void copyIfCheck(OutputIterator r, const Container & c, 0355 const SelectorBase & s) { 0356 for ( typename Container::const_iterator it = c.begin(); 0357 it != c.end(); ++it ) 0358 if ( s.check(**it) ) *r++ = *it; 0359 } 0360 0361 } 0362 0363 #endif /* ThePEG_SelectorBase_H */
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|