Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-08-06 09:38:29

0001 // -*- C++ -*-
0002 //
0003 // StandardMatchers.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_StandardMatchers_H
0010 #define ThePEG_StandardMatchers_H
0011 // This is the declaration of the AnyMatcher,
0012 
0013 
0014 #include "Matcher.h"
0015 #include "ThePEG/PDT/EnumParticles.h"
0016 
0017 namespace ThePEG {
0018 
0019 /** \file StandardMatchers.h
0020  *
0021  * This file declare a set of standard matcher classes. The
0022  * ChargedMatcher, NegativeMatcher, PositiveMatcher, NeutralMatcher,
0023  * BaryonMatcher, MesonMatcher, DiquarkMatcher, LeptonMatcher,
0024  * LightAntiQuarkMatcher, LightQuarkMatcher and
0025  * StandardQCDPartonMatcher classes can be used by themselves (with
0026  * their static functions) or together with the Matcher class to
0027  * define Interfaced objects of the MatcherBase type to be used in the
0028  * Repository. Suitable typedefs are declared for the latter.
0029  *
0030  * @see Matcher
0031  * @see MatcherBase
0032  */
0033 
0034 /**
0035  * A Matcher class which matches any particle.
0036  */
0037 struct AnyMatcher: public MatcherType {
0038   /** Typedef the class matching the complex conjugate particles. */
0039   typedef AnyMatcher CC;
0040   /** The main static function to check if a given particle type \a pd
0041       matches. */
0042   static bool Check(const ParticleData & pd) {
0043     return bool(pd.id());
0044   }
0045   /** A simplified but unique class name. */
0046   static string className() { return "Any"; }
0047 };
0048 /** Gives a MatcherBase class based on AnyMatcher. */
0049 typedef Matcher<AnyMatcher> MatchAny;
0050 
0051 
0052 /**
0053  * A Matcher class which matches any charged particle.
0054  */
0055 struct ChargedMatcher: public MatcherType {
0056   /** Typedef the class matching the complex conjugate particles. */
0057   typedef ChargedMatcher CC;
0058   /** The main static function to check if a given particle type \a pd
0059       matches. */
0060   static bool Check(const ParticleData & pd) {
0061     return PDT::charged(pd.iCharge());
0062   }
0063   /** A simplified but unique class name. */
0064   static string className() { return "Charged"; }
0065 };
0066 /** Gives a MatcherBase class based on ChargedMatcher. */
0067 typedef Matcher<ChargedMatcher> MatchCharged;
0068 
0069 struct NegativeMatcher;
0070 
0071 /**
0072  * A Matcher class which matches any positively charged particle.
0073  */
0074 struct PositiveMatcher: public MatcherType {
0075   /** Typedef the class matching the complex conjugate particles. */
0076   typedef NegativeMatcher CC;
0077   /** The main static function to check if a given particle type \a pd
0078       matches. */
0079   static bool Check(const ParticleData & pd) {
0080     return PDT::positive(pd.iCharge());
0081   }
0082   /** A simplified but unique class name. */
0083   static string className() { return "Positive"; }
0084 };
0085 /** Gives a MatcherBase class based on PositiveMatcher. */
0086 typedef Matcher<PositiveMatcher> MatchPositive;
0087 
0088 
0089 /**
0090  * A Matcher class which matches any uncharged particle.
0091  */
0092 struct NeutralMatcher: public MatcherType {
0093   /** Typedef the class matching the complex conjugate particles. */
0094   typedef NeutralMatcher CC;
0095   /** The main static function to check if a given particle type \a pd
0096       matches. */
0097   static bool Check(const ParticleData & pd) {
0098     return pd.iCharge() == PDT::Charge0;
0099   }
0100   /** A simplified but unique class name. */
0101   static string className() { return "Neutral"; }
0102 };
0103 /** Gives a MatcherBase class based on NeutralMatcher. */
0104 typedef Matcher<NeutralMatcher> MatchNeutral;
0105 
0106 /**
0107  * A Matcher class which matches any negatively charged particle.
0108  */
0109 struct NegativeMatcher: public MatcherType {
0110   /** Typedef the class matching the complex conjugate particles. */
0111   typedef PositiveMatcher CC;
0112   /** The main static function to check if a given particle type \a pd
0113       matches. */
0114   static bool Check(const ParticleData & pd) {
0115     return PDT::negative(pd.iCharge());
0116   }
0117   /** A simplified but unique class name. */
0118   static string className() { return "Negative"; }
0119 };
0120 /** Gives a MatcherBase class based on NegativeMatcher. */
0121 typedef Matcher<NegativeMatcher> MatchNegative;
0122 
0123 /**
0124  * A Matcher class which matches any baryon.
0125  */
0126 struct BaryonMatcher: public MatcherType {
0127   /** Typedef the class matching the complex conjugate particles. */
0128   typedef BaryonMatcher CC;
0129   /** The main static function to check if a given particle type \a pd
0130       matches. */
0131   static bool Check(const ParticleData & pd) { return Check(pd.id()); }
0132   /** The main static function to check if a given particle with type
0133       \a id matches. */
0134   static bool Check(long id) {
0135     return (id/10)%10 && (id/100)%10 && (id/1000)%10;
0136   }
0137   /** A simplified but unique class name. */
0138   static string className() { return "Baryon"; }
0139 };
0140 /** Gives a MatcherBase class based on BaryonMatcher. */
0141 typedef Matcher<BaryonMatcher> MatchBaryon;
0142 
0143 
0144 /**
0145  * A Matcher class which matches any meson.
0146  */
0147 struct MesonMatcher: public MatcherType {
0148   /** Typedef the class matching the complex conjugate particles. */
0149   typedef MesonMatcher CC;
0150   /** The main static function to check if a given particle type \a pd
0151       matches. */
0152   static bool Check(const ParticleData & pd) { return Check(pd.id()); }
0153   /** The main static function to check if a given particle with type
0154       \a id matches. */
0155   static bool Check(long id) {
0156     return (id/10)%10 && (id/100)%10 && (id/1000)%10 == 0;
0157   }
0158   /** A simplified but unique class name. */
0159   static string className() { return "Meson"; }
0160 };
0161 /** Gives a MatcherBase class based on MesonMatcher. */
0162 typedef Matcher<MesonMatcher> MatchMeson;
0163 
0164 
0165 /**
0166  * A Matcher class which matches any (anti-)diquark.
0167  */
0168 struct DiquarkMatcher: public MatcherType {
0169   /** Typedef the class matching the complex conjugate particles. */
0170   typedef DiquarkMatcher CC;
0171   /** The main static function to check if a given particle type \a pd
0172       matches. */
0173   static bool Check(const ParticleData & pd) { return Check(pd.id()); }
0174   /** The main static function to check if a given particle with type
0175       \a id matches. */
0176   static bool Check(long id) {
0177     return id/10 && (id/10)%10 == 0 && (id/100)%10 && (id/1000)%10;
0178   }
0179   /** A simplified but unique class name. */
0180   static string className() { return "Diquark"; }
0181 };
0182 /** Gives a MatcherBase class based on DiquarkMatcher. */
0183 typedef Matcher<DiquarkMatcher> MatchDiquark;
0184 
0185 /**
0186  * A Matcher class which matches any (anti-)quark.
0187  */
0188 struct QuarkMatcher: public MatcherType {
0189   /** Typedef the class matching the complex conjugate particles. */
0190   typedef QuarkMatcher CC;
0191   /** The main static function to check if a given particle type \a pd
0192       matches. */
0193   static bool Check(const ParticleData & pd) { return Check(pd.id()); }
0194   /** The main static function to check if a given particle with type
0195       \a id matches. */
0196   static bool Check(long id) {
0197     return id && abs(id) < 10;
0198   }
0199   /** A simplified but unique class name. */
0200   static string className() { return "Quark"; }
0201 };
0202 /** Gives a MatcherBase class based on QuarkMatcher. */
0203 typedef Matcher<QuarkMatcher> MatchQuark;
0204 
0205 /**
0206  * A Matcher class which matches any lepton.
0207  */
0208 struct LeptonMatcher: public MatcherType {
0209   /** Typedef the class matching the complex conjugate particles. */
0210   typedef LeptonMatcher CC;
0211   /** The main static function to check if a given particle type \a pd
0212       matches. */
0213   static bool Check(const ParticleData & pd) { return Check(pd.id()); }
0214   /** The main static function to check if a given particle with type
0215       \a id matches. */
0216   static bool Check(long id) {
0217     return abs(id) > 10 && abs(id) <= 20;
0218   }
0219   /** A simplified but unique class name. */
0220   static string className() { return "Lepton"; }
0221 };
0222 /** Gives a MatcherBase class based on LeptonMatcher. */
0223 typedef Matcher<LeptonMatcher> MatchLepton;
0224 
0225 /**
0226  * A Matcher class which matches any neutrino.
0227  */
0228 struct NeutrinoMatcher: public MatcherType {
0229   /** Typedef the class matching the complex conjugate particles. */
0230   typedef NeutrinoMatcher CC;
0231   /** The main static function to check if a given particle type \a pd
0232       matches. */
0233   static bool Check(const ParticleData & pd) { return Check(pd.id()); }
0234   /** The main static function to check if a given particle with type
0235       \a id matches. */
0236   static bool Check(long id) {
0237     return abs(id)-10 >= 2 && abs(id)-10 <= 8 && abs(id)%2 == 0;
0238   }
0239   /** A simplified but unique class name. */
0240   static string className() { return "Neutrino"; }
0241 };
0242 
0243 /** Gives a MatcherBase class based on VectorMesonMatcher. */
0244 typedef Matcher<NeutrinoMatcher> MatchNeutrino;
0245 
0246 struct LightAntiQuarkMatcher;
0247 
0248 /**
0249  * A Matcher class which matches any light quark (d,u or s).
0250  */
0251 struct LightQuarkMatcher: public MatcherType {
0252   /** Typedef the class matching the complex conjugate particles. */
0253   typedef LightAntiQuarkMatcher CC;
0254   /** The main static function to check if a given particle type \a pd
0255       matches. */
0256   static bool Check(const ParticleData & pd) { return Check(pd.id()); }
0257   /** The main static function to check if a given particle with type
0258       \a id matches. */
0259   static bool Check(long id) {
0260     return id > 0 && id < 4 ;
0261   }
0262   /** A simplified but unique class name. */
0263   static string className() { return "LightQuark"; }
0264 };
0265 /** Gives a MatcherBase class based on LightQuarkMatcher. */
0266 typedef Matcher<LightQuarkMatcher> MatchLightQuark;
0267 
0268 
0269 /**
0270  * A Matcher class which matches any light anti-quark
0271  * (\f$\bar{\mbox{d}}\f$,\f$\bar{\mbox{u}}\f$ or
0272  * \f$\bar{\mbox{s}}\f$).
0273  */
0274 struct LightAntiQuarkMatcher: public MatcherType {
0275   /** Typedef the class matching the complex conjugate particles. */
0276   typedef LightQuarkMatcher CC;
0277   /** The main static function to check if a given particle type \a pd
0278       matches. */
0279   static bool Check(const ParticleData & pd) { return Check(pd.id()); }
0280   /** The main static function to check if a given particle with type
0281       \a id matches. */
0282   static bool Check(long id) {
0283     return id < 0 && id > -4 ;
0284   }
0285   /** A simplified but unique class name. */
0286   static string className() { return "LightAntiQuark"; }
0287 };
0288 /** Gives a MatcherBase class based on LightAntiQuarkMatcher. */
0289 typedef Matcher<LightAntiQuarkMatcher> MatchLightAntiQuark;
0290 
0291 /**
0292  * A Matcher class which matches any standard QCD parton, ie. gluons
0293  * and quarks up to bottom.
0294  */
0295 struct StandardQCDPartonMatcher: public MatcherType {
0296   /** Typedef the class matching the complex conjugate particles. */
0297   typedef StandardQCDPartonMatcher CC;
0298   /** The main static function to check if a given particle type \a pd
0299       matches. */
0300   static bool Check(const ParticleData & pd) { return Check(pd.id()); }
0301   /** The main static function to check if a given particle with type
0302       \a id matches. */
0303   static bool Check(long id) {
0304     return id && ( abs(id) <= 5 || id == ParticleID::g );
0305   }
0306   /** A simplified but unique class name. */
0307   static string className() { return "StandardQCDParton"; }
0308 };
0309 
0310 /** Gives a MatcherBase class based on StandardQCDPartonMatcher. */
0311 typedef Matcher<StandardQCDPartonMatcher> MatchStandardQCDParton;
0312 
0313 /**
0314  * A Matcher class which matches any pseudo scalar meson.
0315  */
0316 struct PseudoScalarMesonMatcher: public MatcherType {
0317   /** Typedef the class matching the complex conjugate particles. */
0318   typedef PseudoScalarMesonMatcher CC;
0319   /** The main static function to check if a given particle type \a pd
0320       matches. */
0321   static bool Check(const ParticleData & pd) { return Check(pd.id()); }
0322   /** The main static function to check if a given particle with type
0323       \a id matches. */
0324   static bool Check(long id) {
0325     return ( (abs(id)/1000)%1 == 0 && abs(id) > 100 && abs(id)%10 == 1 ) ||
0326       ( id == ParticleID::K_L0 || id == ParticleID::K_S0 );
0327   }
0328   /** A simplified but unique class name. */
0329   static string className() { return "PseudoScalarMeson"; }
0330 };
0331 
0332 /** Gives a MatcherBase class based on PseudoScalarMesonMatcher. */
0333 typedef Matcher<PseudoScalarMesonMatcher> MatchPseudoScalarMeson;
0334 
0335 
0336 /**
0337  * A Matcher class which matches any vector meson.
0338  */
0339 struct VectorMesonMatcher: public MatcherType {
0340   /** Typedef the class matching the complex conjugate particles. */
0341   typedef VectorMesonMatcher CC;
0342   /** The main static function to check if a given particle type \a pd
0343       matches. */
0344   static bool Check(const ParticleData & pd) { return Check(pd.id()); }
0345   /** The main static function to check if a given particle with type
0346       \a id matches. */
0347   static bool Check(long id) {
0348     return (abs(id)/1000)%1 == 0 && abs(id) > 100 && abs(id)%10 == 3;
0349   }
0350   /** A simplified but unique class name. */
0351   static string className() { return "VectorMeson"; }
0352 };
0353 
0354 /** Gives a MatcherBase class based on VectorMesonMatcher. */
0355 typedef Matcher<VectorMesonMatcher> MatchVectorMeson;
0356 
0357 }
0358 
0359 #endif /* ThePEG_StandardMatchers_H */