ThePEG  1.8.0
MatcherBase.h
1 // -*- C++ -*-
2 //
3 // MatcherBase.h is a part of ThePEG - Toolkit for HEP Event Generation
4 // Copyright (C) 1999-2011 Leif Lonnblad
5 //
6 // ThePEG is licenced under version 2 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 &);
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 */