00001 // -*- C++ -*- 00002 // 00003 // MatcherBase.h is a part of ThePEG - Toolkit for HEP Event Generation 00004 // Copyright (C) 1999-2007 Leif Lonnblad 00005 // 00006 // ThePEG is licenced under version 2 of the GPL, see COPYING for details. 00007 // Please respect the MCnet academic guidelines, see GUIDELINES for details. 00008 // 00009 #ifndef ThePEG_MatcherBase_H 00010 #define ThePEG_MatcherBase_H 00011 // This is the declaration of the MatcherBase class. 00012 00013 00014 #include "ParticleData.h" 00015 #include "ThePEG/EventRecord/Particle.h" 00016 00017 namespace ThePEG { 00018 00029 class MatcherBase: public Interfaced { 00030 00031 public: 00032 00034 friend class Repository; 00035 00039 typedef set<tPDPtr> tPDSet; 00040 00044 typedef set<tPMPtr> tPMSet; 00045 00046 public: 00047 00053 MatcherBase(); 00054 00058 MatcherBase(const MatcherBase &); 00059 00063 virtual ~MatcherBase(); 00065 00066 public: 00067 00073 virtual bool check(const ParticleData &) const = 0; 00074 00080 virtual PMPtr pmclone() const = 0; 00082 00088 bool checkp(const Particle & p) const { return check(p.data()); } 00089 00096 bool matches(const ParticleData & pd) const { 00097 return member(matchingParticles, PDPtr(const_cast<ParticleData *>(&pd))); 00098 } 00099 00100 00107 bool matches(const Particle & p) const { return matches(p.data()); } 00108 00114 bool matches(const MatcherBase & pm) const { 00115 return member(matchingMatchers, PMPtr(const_cast<MatcherBase *>(&pm))); 00116 } 00118 00124 const tPDSet & particles() const { return matchingParticles; } 00128 const tPMSet & matchers() const { return matchingMatchers; } 00130 00136 Energy minMass() const { return theMinMass; } 00137 00141 Energy maxMass() const { return theMaxMass; } 00142 00147 Energy mass() const { return commonMass; } 00148 00153 Energy width() const { return commonWidth; } 00154 00160 Length cTau() const { return commonCTau; } 00161 00169 PDT::Charge iCharge() const { return commonCharge; } 00170 00175 bool charged() const { return PDT::charged(commonCharge); } 00176 00181 bool positive() const { return PDT::positive(commonCharge); } 00182 00187 bool negative() const { return PDT::negative(commonCharge); } 00188 00194 PDT::Spin iSpin() const { return commonSpin; } 00195 00201 PDT::Colour iColour() const { return commonColour; } 00202 00207 bool coloured() const { return PDT::coloured(commonColour); } 00208 00213 int stable() const { return commonStable; } 00215 00220 tPMPtr CC() const { return theAntiPartner; } 00221 00222 public: 00223 00224 00231 void persistentOutput(PersistentOStream & os) const; 00232 00238 void persistentInput(PersistentIStream & is, int version); 00240 00244 static void Init(); 00245 00246 protected: 00247 00253 virtual void doupdate(); 00255 00256 protected: 00257 00262 void addPIfMatch(tPDPtr); 00263 00268 void addMIfMatch(tPMPtr); 00269 00274 template <typename Iterator> 00275 void addPIfMatch(Iterator first, Iterator last) { 00276 for ( ; first != last; ++first ) addPIfMatch(*first); 00277 } 00278 00283 template <typename Cont> 00284 void addPIfMatchFrom(const Cont & c) { 00285 addPIfMatch(c.begin(), c.end()); 00286 } 00287 00292 template <typename Iterator> 00293 void addMIfMatch(Iterator first, Iterator last) { 00294 for ( ; first != last; ++first ) addMIfMatch(*first); 00295 } 00296 00301 template <typename Cont> 00302 void addMIfMatchFrom(const Cont & c) { 00303 addMIfMatch(c.begin(), c.end()); 00304 } 00305 00309 void clear(); 00310 00314 void setCC(tPMPtr pm, tPMPtr apm) const { 00315 pm->theAntiPartner = apm; 00316 apm->theAntiPartner = pm; 00317 } 00318 00319 private: 00320 00324 tPDSet matchingParticles; 00325 00329 tPMSet matchingMatchers; 00330 00334 Energy theMaxMass; 00335 00339 Energy theMinMass; 00340 00344 Energy commonMass; 00345 00349 Energy commonWidth; 00350 00354 Length commonCTau; 00355 00359 PDT::Charge commonCharge; 00360 00364 PDT::Spin commonSpin; 00365 00369 PDT::Colour commonColour; 00370 00374 int commonStable; 00375 00380 tPMPtr theAntiPartner; 00381 00382 private: 00383 00388 static AbstractClassDescription<MatcherBase> initMatcherBase; 00389 00393 MatcherBase & operator=(const MatcherBase &); 00394 00395 }; 00396 00401 template <> 00402 struct BaseClassTrait<MatcherBase,1>: public ClassTraitsType { 00404 typedef Interfaced NthBase; 00405 }; 00406 00409 template <> 00410 struct ClassTraits<MatcherBase>: 00411 public ClassTraitsBase<MatcherBase> { 00413 static string className() { return "ThePEG::MatcherBase"; } 00414 }; 00415 00418 } 00419 00420 #endif /* ThePEG_MatcherBase_H */