thepeg is hosted by Hepforge, IPPP Durham
ThePEG 2.3.0
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
16namespace ThePEG {
17
46
47public:
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
117template <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
179
180public:
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
212private:
213
218};
219
226
227public:
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
272private:
273
278
283
284};
285
292
293public:
294
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
338private:
339
344
349
350};
351
353template <typename OutputIterator, typename Container>
354inline 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 */
This is the main config header file for the Event classes.
The Particle class is used to describe an instance of a particle.
Definition: Particle.h:83
The SelectIfBoth class can be used to combine other selector objects.
Definition: SelectorBase.h:225
const SelectorBase & s2
The other selector to be combined.
Definition: SelectorBase.h:282
virtual bool allCollisions() const
Return ture if all collisions should be considered.
Definition: SelectorBase.h:268
virtual bool allSteps() const
Return true if all steps should be considered.
Definition: SelectorBase.h:260
const SelectorBase & s1
One selector to be combined.
Definition: SelectorBase.h:277
virtual bool check(const Particle &p) const
Return true if the particle should be extracted.
Definition: SelectorBase.h:238
SelectIfBoth(const SelectorBase &S1, const SelectorBase &S2)
Constructor taking two SelectorBase object to be combiden.
Definition: SelectorBase.h:232
virtual bool finalState() const
Return true if final state particles are to be considered.
Definition: SelectorBase.h:245
virtual bool intermediate() const
Return true if intermediate particles should be considered.
Definition: SelectorBase.h:252
The SelectIfEither class can be used to combine other selector objects.
Definition: SelectorBase.h:291
SelectIfEither(const SelectorBase &S1, const SelectorBase &S2)
Constructor taking two SelectorBase object to be combiden.
Definition: SelectorBase.h:298
virtual bool intermediate() const
Return true if intermediate particles should be considered.
Definition: SelectorBase.h:318
virtual bool check(const Particle &p) const
Return true if the particle should be extracted.
Definition: SelectorBase.h:304
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:311
const SelectorBase & s1
One selector to be combined.
Definition: SelectorBase.h:343
const SelectorBase & s2
The other selector to be combined.
Definition: SelectorBase.h:348
virtual bool allCollisions() const
Return ture if all collisions should be considered.
Definition: SelectorBase.h:334
The SelectIfNot classes can be used to negate the meaning of another SelectorBase object.
Definition: SelectorBase.h:178
virtual bool allCollisions() const
Return ture if all collisions should be considered.
Definition: SelectorBase.h:210
virtual bool finalState() const
Return true if final state particles are to be considered.
Definition: SelectorBase.h:193
virtual bool allSteps() const
Return true if all steps should be considered.
Definition: SelectorBase.h:204
virtual bool intermediate() const
Return true if intermediate particles should be considered.
Definition: SelectorBase.h:198
SelectIfNot(const SelectorBase &S)
Constructor taking the SelectorBase object to be negated.
Definition: SelectorBase.h:183
const SelectorBase & s
The selector to be negated.
Definition: SelectorBase.h:217
virtual bool check(const Particle &p) const
Return true if the particle should be extracted.
Definition: SelectorBase.h:188
Classes derived from the SelectorBase class are used to extract particles from an Event with Event::s...
Definition: SelectorBase.h:45
virtual ~SelectorBase()
Virtual destructor.
Definition: SelectorBase.h:52
virtual bool check(const Particle &p) const
Return true if the particle should be extracted.
Definition: SelectorBase.h:82
static bool Check(const Particle &)
Static method corresponding to the virtual check() method.
Definition: SelectorBase.h:57
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:92
static bool AllCollisions()
Static method corresponding to the virtual allCollisions() method.
Definition: SelectorBase.h:77
static bool AllSteps()
Static method corresponding to the virtual allSteps() method.
Definition: SelectorBase.h:72
virtual bool allSteps() const
Return true if all steps should be considered.
Definition: SelectorBase.h:98
static bool Intermediate()
Static method corresponding to the virtual intermediate() method.
Definition: SelectorBase.h:62
static bool FinalState()
Static method corresponding to the virtual finalState() method.
Definition: SelectorBase.h:67
virtual bool allCollisions() const
Return ture if all collisions should be considered.
Definition: SelectorBase.h:104
This is the main namespace within which all identifiers in ThePEG are declared.
Definition: FactoryBase.h:28
void copyIfCheck(OutputIterator r, const Container &c, const SelectorBase &s)
Helper function to be used together with SelectorBase objects.
Definition: SelectorBase.h:354
The templated ParticleSelector class may be used to implement derived classes from the SelectorBase c...
Definition: SelectorBase.h:118
static bool Check(const Particle &p)
Static method corresponding to the virtual check() method.
Definition: SelectorBase.h:123
virtual bool allSteps() const
Return true if all steps should be considered.
Definition: SelectorBase.h:164
static bool FinalState()
Static method corresponding to the virtual finalState() method.
Definition: SelectorBase.h:133
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:170
static bool Intermediate()
Static method corresponding to the virtual intermediate() method.
Definition: SelectorBase.h:128
static bool AllCollisions()
Static method corresponding to the virtual allCollisions() method.
Definition: SelectorBase.h:143
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:153
virtual bool intermediate() const
Return true if intermediate particles should be considered.
Definition: SelectorBase.h:158