|
|
|||
File indexing completed on 2026-08-06 09:38:29
0001 // -*- C++ -*- 0002 // 0003 // MatcherBase.h is a part of ThePEG - Toolkit for HEP Event Generation 0004 // Copyright (C) 1999-2019 Leif Lonnblad 0005 // 0006 // ThePEG is licenced under version 3 of the GPL, see COPYING for details. 0007 // Please respect the MCnet academic guidelines, see GUIDELINES for details. 0008 // 0009 #ifndef ThePEG_MatcherBase_H 0010 #define ThePEG_MatcherBase_H 0011 // This is the declaration of the MatcherBase class. 0012 0013 0014 #include "ParticleData.h" 0015 #include "ThePEG/EventRecord/Particle.h" 0016 0017 namespace ThePEG { 0018 0019 /** 0020 * MatcherBase is an abstract base class to be used for objects 0021 * representing groups of ParticleData objects. Concrete 0022 * implementations will typically use the templated Matcher class for 0023 * easy building of a full sub-class. 0024 * 0025 * @see ParticleData 0026 * @see Matcher 0027 * 0028 */ 0029 class MatcherBase: public Interfaced { 0030 0031 public: 0032 0033 /** Repository needs to be a friend. */ 0034 friend class Repository; 0035 0036 /** 0037 * Convenient typedef. 0038 */ 0039 typedef set<tPDPtr> tPDSet; 0040 0041 /** 0042 * Convenient typedef. 0043 */ 0044 typedef set<tPMPtr> tPMSet; 0045 0046 public: 0047 0048 /** @name Standard constructors and destructors. */ 0049 //@{ 0050 /** 0051 * Default constructor. 0052 */ 0053 MatcherBase(); 0054 0055 /** 0056 * Copy-constructor. 0057 */ 0058 MatcherBase(const MatcherBase &); 0059 //@} 0060 0061 public: 0062 0063 /** @name Virtual functions to be overridden by sub-classes. */ 0064 //@{ 0065 /** 0066 * Check if a particle type meets the criteria. 0067 */ 0068 virtual bool check(const ParticleData &) const = 0; 0069 0070 /** 0071 * Specialized clone method for MatcherBase used by the 0072 * Repository. A sub class must make sure that also the MatcherBase 0073 * object corresponding to the complex conjugate of this is cloned. 0074 */ 0075 virtual PMPtr pmclone() const = 0; 0076 //@} 0077 0078 /** @name Check if something is matched. */ 0079 //@{ 0080 /** 0081 * Check if a Particle meets the criteria. 0082 */ 0083 bool checkp(const Particle & p) const { return check(p.data()); } 0084 0085 /** 0086 * Check if a given particle type belongs to the set of 0087 * matches. This function looks for the same ParticleData object in 0088 * the set of all particles matched by this matcher. May be quicker 0089 * than to go through the check proceedure. 0090 */ 0091 bool matches(const ParticleData & pd) const { 0092 return member(matchingParticles, PDPtr(const_cast<ParticleData *>(&pd))); 0093 } 0094 0095 0096 /** 0097 * Check if a given particle belongs to the set of matches. This 0098 * function looks for the corresponding ParticleData object in the 0099 * set of all particles matched by this matcher. May be quicker than 0100 * to go through the check proceedure. 0101 */ 0102 bool matches(const Particle & p) const { return matches(p.data()); } 0103 0104 /** 0105 * Check if a given particle matcher belongs to the set of 0106 * matches. This function looks for the same MatcherBase object in 0107 * the set of all matchers matched by this matcher. 0108 */ 0109 bool matches(const MatcherBase & pm) const { 0110 return member(matchingMatchers, PMPtr(const_cast<MatcherBase *>(&pm))); 0111 } 0112 //@} 0113 0114 /** @name Access the sets of matching particles and matchers. */ 0115 //@{ 0116 /** 0117 * Access to the set of matching particles. 0118 */ 0119 const tPDSet & particles() const { return matchingParticles; } 0120 /** 0121 * Access to the set of matching matchers. 0122 */ 0123 const tPMSet & matchers() const { return matchingMatchers; } 0124 //@} 0125 0126 /** @name Access common properties of all matched particles. */ 0127 //@{ 0128 /** 0129 * Returns the minimum mass of the matching particles. 0130 */ 0131 Energy minMass() const { return theMinMass; } 0132 0133 /** 0134 * Returns the maximum mass of the matching particles. 0135 */ 0136 Energy maxMass() const { return theMaxMass; } 0137 0138 /** 0139 * Returns the common mass of the matching particles. If all matching 0140 * particles do not have exactly the same mass, -1.0 GeV is returned. 0141 */ 0142 Energy mass() const { return commonMass; } 0143 0144 /** 0145 * Returns the common width of the matching particles. If all matching 0146 * particles do not have exactly the same width, -1.0 GeV is returned. 0147 */ 0148 Energy width() const { return commonWidth; } 0149 0150 /** 0151 * Returns the common decay length of the matching particles. If all 0152 * matching particles do not have exactly the same decay length -1.0 0153 * mm is returned. 0154 */ 0155 Length cTau() const { return commonCTau; } 0156 0157 /** 0158 * Return common charge. If all matching particles have the same 0159 * charge the common charge is returned. Otherwise if all are 0160 * positive (negative), PDT::Positive (PDT::Negative) is 0161 * returned. Otherwise if all are charged, PDT::Charged is 0162 * returned. Otherwise PDT::ChargeUndefined is returned. 0163 */ 0164 PDT::Charge iCharge() const { return commonCharge; } 0165 0166 /** 0167 * Are the particles charged? If all matching particles are charged, return 0168 * true, otherwise false. 0169 */ 0170 bool charged() const { return PDT::charged(commonCharge); } 0171 0172 /** 0173 * Are the particles positively charged? If all matching particles 0174 * are positively charged, return true, otherwise false. 0175 */ 0176 bool positive() const { return PDT::positive(commonCharge); } 0177 0178 /** 0179 * Are the particles negatively charged? If all matching particles 0180 * are negatively charged, return true, otherwise false. 0181 */ 0182 bool negative() const { return PDT::negative(commonCharge); } 0183 0184 /** 0185 * Return common spin. If all matching particles have the same spin, 0186 * the common spin is returned. Otherwise PDT::SpinUndefined is 0187 * returned. 0188 */ 0189 PDT::Spin iSpin() const { return commonSpin; } 0190 0191 /** 0192 * If all matching particles have the same colour, the common colour 0193 * is returned. Otherwise if all are coloured, PDT::Coloured is 0194 * returned. Otherwise PDT::ColourUndefined is returned. 0195 */ 0196 PDT::Colour iColour() const { return commonColour; } 0197 0198 /** 0199 * Are the particles coloured? If all matching particles are 0200 * coloured, return true, otherwise false. 0201 */ 0202 bool coloured() const { return PDT::coloured(commonColour); } 0203 0204 /** 0205 * Are the particles stable? Returns (0)1 if all matching particles 0206 * are (un)stable. Otherwise -1 is returned. 0207 */ 0208 int stable() const { return commonStable; } 0209 //@} 0210 0211 /** 0212 * Get the matcher object matching the antiparticles of this. If 0213 * no-one exists null is returned. 0214 */ 0215 tPMPtr CC() const { return theAntiPartner; } 0216 0217 public: 0218 0219 0220 /** @name Functions used by the persistent I/O system. */ 0221 //@{ 0222 /** 0223 * Function used to write out object persistently. 0224 * @param os the persistent output stream written to. 0225 */ 0226 void persistentOutput(PersistentOStream & os) const; 0227 0228 /** 0229 * Function used to read in object persistently. 0230 * @param is the persistent input stream read from. 0231 * @param version the version number of the object when written. 0232 */ 0233 void persistentInput(PersistentIStream & is, int version); 0234 //@} 0235 0236 /** 0237 * Standard Init function used to initialize the interface. 0238 */ 0239 static void Init(); 0240 0241 protected: 0242 0243 /** @name Standard Interfaced functions. */ 0244 //@{ 0245 /** 0246 * Check sanity of the object during the setup phase. 0247 */ 0248 virtual void doupdate(); 0249 //@} 0250 0251 protected: 0252 0253 /** 0254 * Add a particle to the set of matching particles if it meets the 0255 * criteria. 0256 */ 0257 void addPIfMatch(tPDPtr); 0258 0259 /** 0260 * Add a particle matcher to the set of matching matchers if it 0261 * meets the criteria. 0262 */ 0263 void addMIfMatch(tPMPtr); 0264 0265 /** 0266 * Add a number of particles to the set of matching particles if 0267 * they meets the criteria. 0268 */ 0269 template <typename Iterator> 0270 void addPIfMatch(Iterator first, Iterator last) { 0271 for ( ; first != last; ++first ) addPIfMatch(*first); 0272 } 0273 0274 /** 0275 * Add a number of particles to the set of matching particles if 0276 * they meets the criteria. 0277 */ 0278 template <typename Cont> 0279 void addPIfMatchFrom(const Cont & c) { 0280 addPIfMatch(c.begin(), c.end()); 0281 } 0282 0283 /** 0284 * Add a number of particle matchers to the set of matching 0285 * matchers if they meets the criteria. 0286 */ 0287 template <typename Iterator> 0288 void addMIfMatch(Iterator first, Iterator last) { 0289 for ( ; first != last; ++first ) addMIfMatch(*first); 0290 } 0291 0292 /** 0293 * Add a number of particle matchers to the set of matching 0294 * matchers if they meets the criteria. 0295 */ 0296 template <typename Cont> 0297 void addMIfMatchFrom(const Cont & c) { 0298 addMIfMatch(c.begin(), c.end()); 0299 } 0300 0301 /** 0302 * Clear information about matching particles and matchers. 0303 */ 0304 void clear(); 0305 0306 /** 0307 * Set antipartner. 0308 */ 0309 static void setCC(tPMPtr pm, tPMPtr apm) { 0310 pm->theAntiPartner = apm; 0311 apm->theAntiPartner = pm; 0312 } 0313 0314 private: 0315 0316 /** 0317 * The set of particle data objects matched by this matcher. 0318 */ 0319 tPDSet matchingParticles; 0320 0321 /** 0322 * A set of matchers which matches a subset of this matcher. 0323 */ 0324 tPMSet matchingMatchers; 0325 0326 /** 0327 * The maximum mass of all matching particles. 0328 */ 0329 Energy theMaxMass; 0330 0331 /** 0332 * The minimum mass of all matching particles. 0333 */ 0334 Energy theMinMass; 0335 0336 /** 0337 * The common mass of all matching particles. 0338 */ 0339 Energy commonMass; 0340 0341 /** 0342 * The common width of all matching particles. 0343 */ 0344 Energy commonWidth; 0345 0346 /** 0347 * The common decay length of all matching particles. 0348 */ 0349 Length commonCTau; 0350 0351 /** 0352 * The common charge of all matching particles. 0353 */ 0354 PDT::Charge commonCharge; 0355 0356 /** 0357 * The common spin of all matching particles. 0358 */ 0359 PDT::Spin commonSpin; 0360 0361 /** 0362 * The common colour of all matching particles. 0363 */ 0364 PDT::Colour commonColour; 0365 0366 /** 0367 * The common stability of all matching particles. 0368 */ 0369 int commonStable; 0370 0371 /** 0372 * Pointer to a matcher object which matches all anti particles 0373 * which are matched by this matcher. 0374 */ 0375 tPMPtr theAntiPartner; 0376 0377 private: 0378 0379 /** 0380 * The static object used to initialize the description of this class. 0381 * Indicates that this is an abstract class with persistent data. 0382 */ 0383 static AbstractClassDescription<MatcherBase> initMatcherBase; 0384 0385 /** 0386 * Private and non-existent assignment operator. 0387 */ 0388 MatcherBase & operator=(const MatcherBase &) = delete; 0389 0390 }; 0391 0392 /** @cond TRAITSPECIALIZATIONS */ 0393 0394 /** This template specialization informs ThePEG about the base classes 0395 * of MatcherBase. */ 0396 template <> 0397 struct BaseClassTrait<MatcherBase,1>: public ClassTraitsType { 0398 /** Typedef of the first base class of MatcherBase. */ 0399 typedef Interfaced NthBase; 0400 }; 0401 0402 /** This template specialization informs ThePEG about the name of the 0403 * MatcherBase class. */ 0404 template <> 0405 struct ClassTraits<MatcherBase>: 0406 public ClassTraitsBase<MatcherBase> { 0407 /** Return a platform-independent class name */ 0408 static string className() { return "ThePEG::MatcherBase"; } 0409 }; 0410 0411 /** @endcond */ 0412 0413 } 0414 0415 #endif /* ThePEG_MatcherBase_H */
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|