thepeg is hosted by Hepforge, IPPP Durham
ThePEG  2.2.1
SelectorBase.h
1 // -*- C++ -*-
2 //
3 // SelectorBase.h is a part of ThePEG - Toolkit for HEP Event Generation
4 // Copyright (C) 1999-2019 Leif Lonnblad
5 //
6 // ThePEG is licenced under version 3 of the GPL, see COPYING for details.
7 // Please respect the MCnet academic guidelines, see GUIDELINES for details.
8 //
9 #ifndef ThePEG_SelectorBase_H
10 #define ThePEG_SelectorBase_H
11 // This is the declaration of the SelectorBase class.
12 
13 
14 #include "EventConfig.h"
15 
16 namespace ThePEG {
17 
45 class SelectorBase {
46 
47 public:
48 
52  virtual ~SelectorBase() {}
53 
57  static bool Check(const Particle &) { return true; }
58 
62  static bool Intermediate() { return true; }
63 
67  static bool FinalState() { return true; }
68 
72  static bool AllSteps() { return true; }
73 
77  static bool AllCollisions() { return true; }
78 
82  virtual bool check(const Particle & p) const { return Check(p); }
83 
87  virtual bool finalState() const { return FinalState(); }
88 
92  virtual bool intermediate() const { return Intermediate(); }
93 
98  virtual bool allSteps() const { return AllSteps(); }
99 
104  virtual bool allCollisions() const { return AllCollisions(); }
105 
106 };
107 
117 template <class T>
119 
123  static bool Check(const Particle & p) { return T::Check(p); }
124 
128  static bool Intermediate() { return T::Intermediate(); }
129 
133  static bool FinalState() { return T::FinalState(); }
134 
138  static bool AllSteps() { return T::AllSteps(); }
139 
143  static bool AllCollisions() { return T::AllCollisions(); }
144 
148  virtual bool check(const Particle & p) const { return Check(p); }
149 
153  virtual bool finalState() const { return FinalState(); }
154 
158  virtual bool intermediate() const { return Intermediate(); }
159 
164  virtual bool allSteps() const { return AllSteps(); }
165 
170  virtual bool allCollisions() const { return AllCollisions(); }
171 
172 };
173 
178 class SelectIfNot: public SelectorBase {
179 
180 public:
181 
183  explicit SelectIfNot(const SelectorBase & S) : s(S) {}
184 
188  virtual bool check(const Particle & p) const { return !s.check(p); }
189 
193  virtual bool finalState() const { return !s.finalState(); }
194 
198  virtual bool intermediate() const { return !s.intermediate(); }
199 
204  virtual bool allSteps() const { return !s.allSteps(); }
205 
210  virtual bool allCollisions() const { return !s.allCollisions(); }
211 
212 private:
213 
217  const SelectorBase & s;
218 };
219 
225 class SelectIfBoth: public SelectorBase {
226 
227 public:
228 
232  SelectIfBoth(const SelectorBase & S1, const SelectorBase & S2)
233  : s1(S1), s2(S2) {}
234 
238  virtual bool check(const Particle & p) const {
239  return s1.check(p) && s2.check(p);
240  }
241 
245  virtual bool finalState() const {
246  return s1.finalState() && s2.finalState();
247  }
248 
252  virtual bool intermediate() const {
253  return s1.intermediate() && s2.intermediate();
254  }
255 
260  virtual bool allSteps() const {
261  return s1.allSteps() && s2.allSteps();
262  }
263 
268  virtual bool allCollisions() const {
269  return s1.allCollisions() && s2.allCollisions();
270  }
271 
272 private:
273 
277  const SelectorBase & s1;
278 
282  const SelectorBase & s2;
283 
284 };
285 
292 
293 public:
294 
298  SelectIfEither(const SelectorBase & S1, const SelectorBase & S2)
299  : s1(S1), s2(S2) {}
300 
304  virtual bool check(const Particle & p) const {
305  return s1.check(p) || s2.check(p);
306  }
307 
311  virtual bool finalState() const {
312  return s1.finalState() || s2.finalState();
313  }
314 
318  virtual bool intermediate() const {
319  return s1.intermediate() || s2.intermediate();
320  }
321 
326  virtual bool allSteps() const {
327  return s1.allSteps() || s2.allSteps();
328  }
329 
334  virtual bool allCollisions() const {
335  return s1.allCollisions() || s2.allCollisions();
336  }
337 
338 private:
339 
343  const SelectorBase & s1;
344 
348  const SelectorBase & s2;
349 
350 };
351 
353 template <typename OutputIterator, typename Container>
354 inline void copyIfCheck(OutputIterator r, const Container & c,
355  const SelectorBase & s) {
356  for ( typename Container::const_iterator it = c.begin();
357  it != c.end(); ++it )
358  if ( s.check(**it) ) *r++ = *it;
359 }
360 
361 }
362 
363 #endif /* ThePEG_SelectorBase_H */
virtual bool intermediate() const
Return true if intermediate particles should be considered.
Definition: SelectorBase.h:252
virtual bool check(const Particle &p) const
Return true if the particle should be extracted.
Definition: SelectorBase.h:238
The Particle class is used to describe an instance of a particle.
Definition: Particle.h:83
static bool AllCollisions()
Static method corresponding to the virtual allCollisions() method.
Definition: SelectorBase.h:143
This is the main config header file for the Event classes.
Classes derived from the SelectorBase class are used to extract particles from an Event with Event::s...
Definition: SelectorBase.h:45
static bool FinalState()
Static method corresponding to the virtual finalState() method.
Definition: SelectorBase.h:133
virtual ~SelectorBase()
Virtual destructor.
Definition: SelectorBase.h:52
virtual bool finalState() const
Return true if final state particles are to be considered.
Definition: SelectorBase.h:193
static bool Intermediate()
Static method corresponding to the virtual intermediate() method.
Definition: SelectorBase.h:62
virtual bool intermediate() const
Return true if intermediate particles should be considered.
Definition: SelectorBase.h:92
virtual bool allSteps() const
Return true if all steps should be considered.
Definition: SelectorBase.h:98
const SelectorBase & s2
The other selector to be combined.
Definition: SelectorBase.h:282
This is the main namespace within which all identifiers in ThePEG are declared.
Definition: FactoryBase.h:28
static bool Check(const Particle &)
Static method corresponding to the virtual check() method.
Definition: SelectorBase.h:57
virtual bool allCollisions() const
Return ture if all collisions should be considered.
Definition: SelectorBase.h:170
The SelectIfEither class can be used to combine other selector objects.
Definition: SelectorBase.h:291
virtual bool check(const Particle &p) const
Return true if the particle should be extracted.
Definition: SelectorBase.h:148
virtual bool finalState() const
Return true if final state particles are to be considered.
Definition: SelectorBase.h:311
static bool Intermediate()
Static method corresponding to the virtual intermediate() method.
Definition: SelectorBase.h:128
virtual bool intermediate() const
Return true if intermediate particles should be considered.
Definition: SelectorBase.h:198
virtual bool allSteps() const
Return true if all steps should be considered.
Definition: SelectorBase.h:204
virtual bool check(const Particle &p) const
Return true if the particle should be extracted.
Definition: SelectorBase.h:188
virtual bool finalState() const
Return true if final state particles are to be considered.
Definition: SelectorBase.h:153
virtual bool allSteps() const
Return true if all steps should be considered.
Definition: SelectorBase.h:164
const SelectorBase & s1
One selector to be combined.
Definition: SelectorBase.h:277
void copyIfCheck(OutputIterator r, const Container &c, const SelectorBase &s)
Helper function to be used together with SelectorBase objects.
Definition: SelectorBase.h:354
virtual bool allCollisions() const
Return ture if all collisions should be considered.
Definition: SelectorBase.h:210
const SelectorBase & s1
One selector to be combined.
Definition: SelectorBase.h:343
The SelectIfBoth class can be used to combine other selector objects.
Definition: SelectorBase.h:225
static bool AllCollisions()
Static method corresponding to the virtual allCollisions() method.
Definition: SelectorBase.h:77
const SelectorBase & s2
The other selector to be combined.
Definition: SelectorBase.h:348
SelectIfEither(const SelectorBase &S1, const SelectorBase &S2)
Constructor taking two SelectorBase object to be combiden.
Definition: SelectorBase.h:298
static bool Check(const Particle &p)
Static method corresponding to the virtual check() method.
Definition: SelectorBase.h:123
virtual bool finalState() const
Return true if final state particles are to be considered.
Definition: SelectorBase.h:245
virtual bool allCollisions() const
Return ture if all collisions should be considered.
Definition: SelectorBase.h:104
const SelectorBase & s
The selector to be negated.
Definition: SelectorBase.h:217
virtual bool allSteps() const
Return true if all steps should be considered.
Definition: SelectorBase.h:260
virtual bool intermediate() const
Return true if intermediate particles should be considered.
Definition: SelectorBase.h:318
virtual bool allCollisions() const
Return ture if all collisions should be considered.
Definition: SelectorBase.h:334
SelectIfNot(const SelectorBase &S)
Constructor taking the SelectorBase object to be negated.
Definition: SelectorBase.h:183
virtual bool check(const Particle &p) const
Return true if the particle should be extracted.
Definition: SelectorBase.h:82
The SelectIfNot classes can be used to negate the meaning of another SelectorBase object...
Definition: SelectorBase.h:178
SelectIfBoth(const SelectorBase &S1, const SelectorBase &S2)
Constructor taking two SelectorBase object to be combiden.
Definition: SelectorBase.h:232
virtual bool allSteps() const
Return true if all steps should be considered.
Definition: SelectorBase.h:326
virtual bool finalState() const
Return true if final state particles are to be considered.
Definition: SelectorBase.h:87
virtual bool intermediate() const
Return true if intermediate particles should be considered.
Definition: SelectorBase.h:158
static bool FinalState()
Static method corresponding to the virtual finalState() method.
Definition: SelectorBase.h:67
virtual bool check(const Particle &p) const
Return true if the particle should be extracted.
Definition: SelectorBase.h:304
static bool AllSteps()
Static method corresponding to the virtual allSteps() method.
Definition: SelectorBase.h:138
virtual bool allCollisions() const
Return ture if all collisions should be considered.
Definition: SelectorBase.h:268
The templated ParticleSelector class may be used to implement derived classes from the SelectorBase c...
Definition: SelectorBase.h:118
static bool AllSteps()
Static method corresponding to the virtual allSteps() method.
Definition: SelectorBase.h:72