thepeg is hosted by Hepforge, IPPP Durham
ThePEG 2.3.0
MatcherBase.h
1// -*- C++ -*-
2//
3// MatcherBase.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_MatcherBase_H
10#define ThePEG_MatcherBase_H
11// This is the declaration of the MatcherBase class.
12
13
14#include "ParticleData.h"
15#include "ThePEG/EventRecord/Particle.h"
16
17namespace ThePEG {
18
29class MatcherBase: public Interfaced {
30
31public:
32
34 friend class Repository;
35
39 typedef set<tPDPtr> tPDSet;
40
44 typedef set<tPMPtr> tPMSet;
45
46public:
47
54
60
61public:
62
68 virtual bool check(const ParticleData &) const = 0;
69
75 virtual PMPtr pmclone() const = 0;
77
83 bool checkp(const Particle & p) const { return check(p.data()); }
84
91 bool matches(const ParticleData & pd) const {
92 return member(matchingParticles, PDPtr(const_cast<ParticleData *>(&pd)));
93 }
94
95
102 bool matches(const Particle & p) const { return matches(p.data()); }
103
109 bool matches(const MatcherBase & pm) const {
110 return member(matchingMatchers, PMPtr(const_cast<MatcherBase *>(&pm)));
111 }
113
119 const tPDSet & particles() const { return matchingParticles; }
123 const tPMSet & matchers() const { return matchingMatchers; }
125
131 Energy minMass() const { return theMinMass; }
132
136 Energy maxMass() const { return theMaxMass; }
137
142 Energy mass() const { return commonMass; }
143
148 Energy width() const { return commonWidth; }
149
155 Length cTau() const { return commonCTau; }
156
164 PDT::Charge iCharge() const { return commonCharge; }
165
170 bool charged() const { return PDT::charged(commonCharge); }
171
176 bool positive() const { return PDT::positive(commonCharge); }
177
182 bool negative() const { return PDT::negative(commonCharge); }
183
189 PDT::Spin iSpin() const { return commonSpin; }
190
196 PDT::Colour iColour() const { return commonColour; }
197
202 bool coloured() const { return PDT::coloured(commonColour); }
203
208 int stable() const { return commonStable; }
210
215 tPMPtr CC() const { return theAntiPartner; }
216
217public:
218
219
227
233 void persistentInput(PersistentIStream & is, int version);
235
239 static void Init();
240
241protected:
242
248 virtual void doupdate();
250
251protected:
252
258
264
269 template <typename Iterator>
270 void addPIfMatch(Iterator first, Iterator last) {
271 for ( ; first != last; ++first ) addPIfMatch(*first);
272 }
273
278 template <typename Cont>
279 void addPIfMatchFrom(const Cont & c) {
280 addPIfMatch(c.begin(), c.end());
281 }
282
287 template <typename Iterator>
288 void addMIfMatch(Iterator first, Iterator last) {
289 for ( ; first != last; ++first ) addMIfMatch(*first);
290 }
291
296 template <typename Cont>
297 void addMIfMatchFrom(const Cont & c) {
298 addMIfMatch(c.begin(), c.end());
299 }
300
304 void clear();
305
309 static void setCC(tPMPtr pm, tPMPtr apm) {
310 pm->theAntiPartner = apm;
311 apm->theAntiPartner = pm;
312 }
313
314private:
315
320
325
330
335
340
345
350
355
360
365
370
376
377private:
378
384
388 MatcherBase & operator=(const MatcherBase &) = delete;
389
390};
391
396template <>
399 typedef Interfaced NthBase;
400};
401
404template <>
405struct ClassTraits<MatcherBase>:
406 public ClassTraitsBase<MatcherBase> {
408 static string className() { return "ThePEG::MatcherBase"; }
409};
410
413}
414
415#endif /* ThePEG_MatcherBase_H */
A concreate implementation of ClassDescriptionBase describing an abstract class with persistent data.
The Interfaced class is derived from the InterfacedBase class adding a couple of things particular to...
Definition: Interfaced.h:38
MatcherBase is an abstract base class to be used for objects representing groups of ParticleData obje...
Definition: MatcherBase.h:29
bool positive() const
Are the particles positively charged? If all matching particles are positively charged,...
Definition: MatcherBase.h:176
void addPIfMatch(Iterator first, Iterator last)
Add a number of particles to the set of matching particles if they meets the criteria.
Definition: MatcherBase.h:270
bool matches(const Particle &p) const
Check if a given particle belongs to the set of matches.
Definition: MatcherBase.h:102
tPMPtr theAntiPartner
Pointer to a matcher object which matches all anti particles which are matched by this matcher.
Definition: MatcherBase.h:375
bool checkp(const Particle &p) const
Check if a Particle meets the criteria.
Definition: MatcherBase.h:83
tPDSet matchingParticles
The set of particle data objects matched by this matcher.
Definition: MatcherBase.h:319
bool matches(const ParticleData &pd) const
Check if a given particle type belongs to the set of matches.
Definition: MatcherBase.h:91
set< tPMPtr > tPMSet
Convenient typedef.
Definition: MatcherBase.h:44
virtual bool check(const ParticleData &) const =0
Check if a particle type meets the criteria.
void addMIfMatch(tPMPtr)
Add a particle matcher to the set of matching matchers if it meets the criteria.
MatcherBase & operator=(const MatcherBase &)=delete
Private and non-existent assignment operator.
bool coloured() const
Are the particles coloured? If all matching particles are coloured, return true, otherwise false.
Definition: MatcherBase.h:202
PDT::Spin commonSpin
The common spin of all matching particles.
Definition: MatcherBase.h:359
void addMIfMatch(Iterator first, Iterator last)
Add a number of particle matchers to the set of matching matchers if they meets the criteria.
Definition: MatcherBase.h:288
Energy theMaxMass
The maximum mass of all matching particles.
Definition: MatcherBase.h:329
tPMSet matchingMatchers
A set of matchers which matches a subset of this matcher.
Definition: MatcherBase.h:324
Energy minMass() const
Returns the minimum mass of the matching particles.
Definition: MatcherBase.h:131
virtual void doupdate()
Check sanity of the object during the setup phase.
int commonStable
The common stability of all matching particles.
Definition: MatcherBase.h:369
PDT::Spin iSpin() const
Return common spin.
Definition: MatcherBase.h:189
Energy commonWidth
The common width of all matching particles.
Definition: MatcherBase.h:344
void addMIfMatchFrom(const Cont &c)
Add a number of particle matchers to the set of matching matchers if they meets the criteria.
Definition: MatcherBase.h:297
PDT::Colour commonColour
The common colour of all matching particles.
Definition: MatcherBase.h:364
tPMPtr CC() const
Get the matcher object matching the antiparticles of this.
Definition: MatcherBase.h:215
const tPDSet & particles() const
Access to the set of matching particles.
Definition: MatcherBase.h:119
static AbstractClassDescription< MatcherBase > initMatcherBase
The static object used to initialize the description of this class.
Definition: MatcherBase.h:383
void addPIfMatchFrom(const Cont &c)
Add a number of particles to the set of matching particles if they meets the criteria.
Definition: MatcherBase.h:279
bool negative() const
Are the particles negatively charged? If all matching particles are negatively charged,...
Definition: MatcherBase.h:182
const tPMSet & matchers() const
Access to the set of matching matchers.
Definition: MatcherBase.h:123
PDT::Charge commonCharge
The common charge of all matching particles.
Definition: MatcherBase.h:354
Energy maxMass() const
Returns the maximum mass of the matching particles.
Definition: MatcherBase.h:136
Length commonCTau
The common decay length of all matching particles.
Definition: MatcherBase.h:349
bool charged() const
Are the particles charged? If all matching particles are charged, return true, otherwise false.
Definition: MatcherBase.h:170
Energy theMinMass
The minimum mass of all matching particles.
Definition: MatcherBase.h:334
void persistentInput(PersistentIStream &is, int version)
Function used to read in object persistently.
int stable() const
Are the particles stable? Returns (0)1 if all matching particles are (un)stable.
Definition: MatcherBase.h:208
void addPIfMatch(tPDPtr)
Add a particle to the set of matching particles if it meets the criteria.
PDT::Colour iColour() const
If all matching particles have the same colour, the common colour is returned.
Definition: MatcherBase.h:196
static void setCC(tPMPtr pm, tPMPtr apm)
Set antipartner.
Definition: MatcherBase.h:309
bool matches(const MatcherBase &pm) const
Check if a given particle matcher belongs to the set of matches.
Definition: MatcherBase.h:109
Energy mass() const
Returns the common mass of the matching particles.
Definition: MatcherBase.h:142
PDT::Charge iCharge() const
Return common charge.
Definition: MatcherBase.h:164
MatcherBase()
Default constructor.
set< tPDPtr > tPDSet
Convenient typedef.
Definition: MatcherBase.h:39
void persistentOutput(PersistentOStream &os) const
Function used to write out object persistently.
Energy commonMass
The common mass of all matching particles.
Definition: MatcherBase.h:339
virtual PMPtr pmclone() const =0
Specialized clone method for MatcherBase used by the Repository.
static void Init()
Standard Init function used to initialize the interface.
void clear()
Clear information about matching particles and matchers.
Energy width() const
Returns the common width of the matching particles.
Definition: MatcherBase.h:148
Length cTau() const
Returns the common decay length of the matching particles.
Definition: MatcherBase.h:155
MatcherBase(const MatcherBase &)
Copy-constructor.
static bool positive(Charge c)
True if the argument corresponds to a positive charge.
Definition: PDT.h:125
Charge
Definition of enumerated values used for charge information.
Definition: PDT.h:51
Spin
Definition of enumerated values used for spin information.
Definition: PDT.h:32
static bool negative(Charge c)
True if the argument corresponds to a negative charge.
Definition: PDT.h:132
Colour
Definition of enumerated values used for colour information.
Definition: PDT.h:92
static bool charged(Charge c)
True if the argument corresponds to a non-zero charge.
Definition: PDT.h:118
static bool coloured(Colour c)
True if the argument corresponds to a non-zero colour charge.
Definition: PDT.h:139
ParticleData inherits from InterfacedBase and represents the properties of a particle type.
Definition: ParticleData.h:36
The Particle class is used to describe an instance of a particle.
Definition: Particle.h:83
const ParticleDataClass & data() const
Access the ParticleData object of this particle type.
Definition: Particle.h:277
PersistentIStream is used to read persistent objects from a stream where they were previously written...
PersistentOStream is used to write objects persistently to a stream from which they can be read in ag...
RCPtr is a reference counted (smart) pointer.
Definition: RCPtr.h:60
TransientRCPtr is a simple wrapper around a bare pointer which can be assigned to and from an RCPtr a...
Definition: RCPtr.h:519
Repository inherits from the BaseRepository class.
Definition: Repository.h:45
This is the main namespace within which all identifiers in ThePEG are declared.
Definition: FactoryBase.h:28
bool member(const Container &c, const Key &k)
Check if a given object is a part of a container.
Definition: std.h:126
ThePEG::Ptr< MatcherBase >::pointer PMPtr
Alias for a reference counted pointer to MatcherBase .
Definition: Pointers.h:65
ThePEG::Ptr< ParticleData >::pointer PDPtr
Alias for a reference counted pointer to ParticleData .
Definition: Pointers.h:64
BaseClassTraits describes the base classes of the templated class.
Definition: ClassTraits.h:156
int NthBase
The type of the BaseN'th base class (int means there are no further base classes).
Definition: ClassTraits.h:161
static string className()
Return the name of class T.
Definition: ClassTraits.h:66
ClassTraitsType is an empty, non-polymorphic, base class.
Definition: ClassTraits.h:30