thepeg is hosted by Hepforge, IPPP Durham
ThePEG  2.2.1
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 
17 namespace ThePEG {
18 
29 class MatcherBase: public Interfaced {
30 
31 public:
32 
34  friend class Repository;
35 
39  typedef set<tPDPtr> tPDSet;
40 
44  typedef set<tPMPtr> tPMSet;
45 
46 public:
47 
53  MatcherBase();
54 
58  MatcherBase(const MatcherBase &);
59 
63  virtual ~MatcherBase();
65 
66 public:
67 
73  virtual bool check(const ParticleData &) const = 0;
74 
80  virtual PMPtr pmclone() const = 0;
82 
88  bool checkp(const Particle & p) const { return check(p.data()); }
89 
96  bool matches(const ParticleData & pd) const {
97  return member(matchingParticles, PDPtr(const_cast<ParticleData *>(&pd)));
98  }
99 
100 
107  bool matches(const Particle & p) const { return matches(p.data()); }
108 
114  bool matches(const MatcherBase & pm) const {
115  return member(matchingMatchers, PMPtr(const_cast<MatcherBase *>(&pm)));
116  }
118 
124  const tPDSet & particles() const { return matchingParticles; }
128  const tPMSet & matchers() const { return matchingMatchers; }
130 
136  Energy minMass() const { return theMinMass; }
137 
141  Energy maxMass() const { return theMaxMass; }
142 
147  Energy mass() const { return commonMass; }
148 
153  Energy width() const { return commonWidth; }
154 
160  Length cTau() const { return commonCTau; }
161 
169  PDT::Charge iCharge() const { return commonCharge; }
170 
175  bool charged() const { return PDT::charged(commonCharge); }
176 
181  bool positive() const { return PDT::positive(commonCharge); }
182 
187  bool negative() const { return PDT::negative(commonCharge); }
188 
194  PDT::Spin iSpin() const { return commonSpin; }
195 
201  PDT::Colour iColour() const { return commonColour; }
202 
207  bool coloured() const { return PDT::coloured(commonColour); }
208 
213  int stable() const { return commonStable; }
215 
220  tPMPtr CC() const { return theAntiPartner; }
221 
222 public:
223 
224 
231  void persistentOutput(PersistentOStream & os) const;
232 
238  void persistentInput(PersistentIStream & is, int version);
240 
244  static void Init();
245 
246 protected:
247 
253  virtual void doupdate();
255 
256 protected:
257 
262  void addPIfMatch(tPDPtr);
263 
268  void addMIfMatch(tPMPtr);
269 
274  template <typename Iterator>
275  void addPIfMatch(Iterator first, Iterator last) {
276  for ( ; first != last; ++first ) addPIfMatch(*first);
277  }
278 
283  template <typename Cont>
284  void addPIfMatchFrom(const Cont & c) {
285  addPIfMatch(c.begin(), c.end());
286  }
287 
292  template <typename Iterator>
293  void addMIfMatch(Iterator first, Iterator last) {
294  for ( ; first != last; ++first ) addMIfMatch(*first);
295  }
296 
301  template <typename Cont>
302  void addMIfMatchFrom(const Cont & c) {
303  addMIfMatch(c.begin(), c.end());
304  }
305 
309  void clear();
310 
314  static void setCC(tPMPtr pm, tPMPtr apm) {
315  pm->theAntiPartner = apm;
316  apm->theAntiPartner = pm;
317  }
318 
319 private:
320 
325 
330 
335 
340 
345 
350 
355 
360 
365 
370 
375 
381 
382 private:
383 
389 
393  MatcherBase & operator=(const MatcherBase &) = delete;
394 
395 };
396 
401 template <>
402 struct BaseClassTrait<MatcherBase,1>: public ClassTraitsType {
404  typedef Interfaced NthBase;
405 };
406 
409 template <>
410 struct ClassTraits<MatcherBase>:
411  public ClassTraitsBase<MatcherBase> {
413  static string className() { return "ThePEG::MatcherBase"; }
414 };
415 
418 }
419 
420 #endif /* ThePEG_MatcherBase_H */
bool checkp(const Particle &p) const
Check if a Particle meets the criteria.
Definition: MatcherBase.h:88
Energy commonMass
The common mass of all matching particles.
Definition: MatcherBase.h:344
PersistentIStream is used to read persistent objects from a stream where they were previously written...
Energy mass() const
Returns the common mass of the matching particles.
Definition: MatcherBase.h:147
ThePEG::Ptr< MatcherBase >::pointer PMPtr
Alias for a reference counted pointer to MatcherBase .
Definition: Pointers.h:65
PDT::Spin commonSpin
The common spin of all matching particles.
Definition: MatcherBase.h:364
bool positive() const
Are the particles positively charged? If all matching particles are positively charged, return true, otherwise false.
Definition: MatcherBase.h:181
Charge
Definition of enumerated values used for charge information.
Definition: PDT.h:51
Length commonCTau
The common decay length of all matching particles.
Definition: MatcherBase.h:354
The Particle class is used to describe an instance of a particle.
Definition: Particle.h:83
tPDSet matchingParticles
The set of particle data objects matched by this matcher.
Definition: MatcherBase.h:324
ClassTraitsType is an empty, non-polymorphic, base class.
Definition: ClassTraits.h:30
PDT::Charge iCharge() const
Return common charge.
Definition: MatcherBase.h:169
static bool coloured(Colour c)
True if the argument corresponds to a non-zero colour charge.
Definition: PDT.h:129
static bool charged(Charge c)
True if the argument corresponds to a non-zero charge.
Definition: PDT.h:108
int stable() const
Are the particles stable? Returns (0)1 if all matching particles are (un)stable.
Definition: MatcherBase.h:213
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:293
MatcherBase & operator=(const MatcherBase &)=delete
Private and non-existent assignment operator.
const ParticleDataClass & data() const
Access the ParticleData object of this particle type.
Definition: Particle.h:277
bool member(const Container &c, const Key &k)
Check if a given object is a part of a container.
Definition: std.h:125
MatcherBase is an abstract base class to be used for objects representing groups of ParticleData obje...
Definition: MatcherBase.h:29
set< tPMPtr > tPMSet
Convenient typedef.
Definition: MatcherBase.h:44
Colour
Definition of enumerated values used for colour information.
Definition: PDT.h:92
PersistentOStream is used to write objects persistently to a stream from which they can be read in ag...
A concreate implementation of ClassDescriptionBase describing an abstract class with persistent data...
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
PDT::Colour iColour() const
If all matching particles have the same colour, the common colour is returned.
Definition: MatcherBase.h:201
This is the main namespace within which all identifiers in ThePEG are declared.
Definition: FactoryBase.h:28
const tPDSet & particles() const
Access to the set of matching particles.
Definition: MatcherBase.h:124
bool matches(const Particle &p) const
Check if a given particle belongs to the set of matches.
Definition: MatcherBase.h:107
ParticleData inherits from InterfacedBase and represents the properties of a particle type...
Definition: ParticleData.h:36
void addPIfMatch(tPDPtr)
Add a particle to the set of matching particles if it meets the criteria.
bool negative() const
Are the particles negatively charged? If all matching particles are negatively charged, return true, otherwise false.
Definition: MatcherBase.h:187
PDT::Colour commonColour
The common colour of all matching particles.
Definition: MatcherBase.h:369
bool coloured() const
Are the particles coloured? If all matching particles are coloured, return true, otherwise false...
Definition: MatcherBase.h:207
int commonStable
The common stability of all matching particles.
Definition: MatcherBase.h:374
bool charged() const
Are the particles charged? If all matching particles are charged, return true, otherwise false...
Definition: MatcherBase.h:175
tPMPtr CC() const
Get the matcher object matching the antiparticles of this.
Definition: MatcherBase.h:220
Spin
Definition of enumerated values used for spin information.
Definition: PDT.h:32
virtual bool check(const ParticleData &) const =0
Check if a particle type meets the criteria.
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:275
PDT::Spin iSpin() const
Return common spin.
Definition: MatcherBase.h:194
bool matches(const MatcherBase &pm) const
Check if a given particle matcher belongs to the set of matches.
Definition: MatcherBase.h:114
virtual PMPtr pmclone() const =0
Specialized clone method for MatcherBase used by the Repository.
Energy theMinMass
The minimum mass of all matching particles.
Definition: MatcherBase.h:339
tPMPtr theAntiPartner
Pointer to a matcher object which matches all anti particles which are matched by this matcher...
Definition: MatcherBase.h:380
void persistentOutput(PersistentOStream &os) const
Function used to write out object persistently.
Energy theMaxMass
The maximum mass of all matching particles.
Definition: MatcherBase.h:334
Energy minMass() const
Returns the minimum mass of the matching particles.
Definition: MatcherBase.h:136
bool matches(const ParticleData &pd) const
Check if a given particle type belongs to the set of matches.
Definition: MatcherBase.h:96
static bool negative(Charge c)
True if the argument corresponds to a negative charge.
Definition: PDT.h:122
ThePEG::Ptr< ParticleData >::pointer PDPtr
Alias for a reference counted pointer to ParticleData .
Definition: Pointers.h:64
Energy commonWidth
The common width of all matching particles.
Definition: MatcherBase.h:349
void persistentInput(PersistentIStream &is, int version)
Function used to read in object persistently.
RCPtr is a reference counted (smart) pointer.
Definition: RCPtr.h:60
Length cTau() const
Returns the common decay length of the matching particles.
Definition: MatcherBase.h:160
virtual void doupdate()
Check sanity of the object during the setup phase.
The Interfaced class is derived from the InterfacedBase class adding a couple of things particular to...
Definition: Interfaced.h:38
void clear()
Clear information about matching particles and matchers.
void addMIfMatch(tPMPtr)
Add a particle matcher to the set of matching matchers if it meets the criteria.
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:302
static void Init()
Standard Init function used to initialize the interface.
static bool positive(Charge c)
True if the argument corresponds to a positive charge.
Definition: PDT.h:115
static void setCC(tPMPtr pm, tPMPtr apm)
Set antipartner.
Definition: MatcherBase.h:314
const tPMSet & matchers() const
Access to the set of matching matchers.
Definition: MatcherBase.h:128
set< tPDPtr > tPDSet
Convenient typedef.
Definition: MatcherBase.h:39
The default concrete implementation of ClassTraitsBase.
Definition: ClassTraits.h:134
Energy width() const
Returns the common width of the matching particles.
Definition: MatcherBase.h:153
MatcherBase()
Default constructor.
Energy maxMass() const
Returns the maximum mass of the matching particles.
Definition: MatcherBase.h:141
static AbstractClassDescription< MatcherBase > initMatcherBase
The static object used to initialize the description of this class.
Definition: MatcherBase.h:388
void addPIfMatchFrom(const Cont &c)
Add a number of particles to the set of matching particles if they meets the criteria.
Definition: MatcherBase.h:284
BaseClassTraits describes the base classes of the templated class.
Definition: ClassTraits.h:156
PDT::Charge commonCharge
The common charge of all matching particles.
Definition: MatcherBase.h:359
virtual ~MatcherBase()
Destructor.
tPMSet matchingMatchers
A set of matchers which matches a subset of this matcher.
Definition: MatcherBase.h:329
The templated ClassTraitsBase class defines a set of default information about classes used by ThePEG...
Definition: ClassTraits.h:52