Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // -*- C++ -*-
0002 //
0003 // FlavourGenerator.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_FlavourGenerator_H
0010 #define ThePEG_FlavourGenerator_H
0011 // This is the declaration of the FlavourGenerator class.
0012 
0013 #include "ThePEG/Config/ThePEG.h"
0014 #include "ThePEG/Handlers/HandlerBase.h"
0015 
0016 namespace ThePEG {
0017 
0018 /**
0019  * FlavourGenerator is an abstract base class to be used to implement
0020  * models describing the quark content of hadrons. FlavourGenerator
0021  * inherits from the HandlerBase class.
0022  *
0023  * The interface is based on the flavour generation implementation in
0024  * Pythia but is general enough to be used in other situations. The
0025  * main virtual functions to be overridden in subclasses are
0026  * generateHadron(tcPDPtr), getHadron(tcPDPtr, tcPDPtr),
0027  * getHadron(long, long) getBaryon(tcPDPtr, tcPDPtr, tcPDPtr),
0028  * getBaryon(long, long, long), selectQuark() and selectFlavour(). In
0029  * this base class the getHadron(tcPDPtr, tcPDPtr) and getHadron(long,
0030  * long) are implemented to call eachother, so a subclass must
0031  * implement at least one of them. The same thing is true for
0032  * getBaryon(tcPDPtr, tcPDPtr, tcPDPtr) and getBaryon(long, long,
0033  * long)
0034  *
0035  * @see \ref FlavourGeneratorInterfaces "The interfaces"
0036  * defined for FlavourGenerator.
0037  * @see HandlerBase
0038  */
0039 class FlavourGenerator: public HandlerBase {
0040 
0041 public:
0042 
0043   /** @name Virtual functions to be overridden by subclasses. */
0044   //@{
0045   /**
0046    * Generate a hadron from a quark. Given a quark(antiquark, diquark
0047    * or antidiquark), choose a quark-antiquark (or
0048    * antidiquark-diquark) pair. Return (first) a hadron formed by the
0049    * original quark and the antiquark together with (second) the
0050    * generated quark. Returns null pointers if the generation failed.
0051    * @param quark a quark, antiquark, diquark or antidiquark.
0052    * @return a pair of ParticleData pointers. The \a first is the
0053    * hadron produced and the \a second is the anti-partner of the
0054    * (anti-)(di-)quark generated to form the hadron.
0055    */
0056   virtual tcPDPair generateHadron(tcPDPtr quark) const = 0;
0057 
0058   /**
0059    * Same as generateHadron(tcPDPtr), but throws an exception if no
0060    * hadron could be produced.
0061    */
0062   tcPDPair alwaysGenerateHadron(tcPDPtr quark) const;
0063 
0064   /**
0065    * Get hadron from flavours. Return a hadron with the flavour
0066    * content given by the (anti-)(di-)quarks in the argument. The
0067    * arguments are given as ParticleData pointers. The default
0068    * versions will call the getHadron(long, long).
0069    * @param q1 the first flavour.
0070    * @param q2 the second flavour.
0071    * @return the corresponding hadron type or null if none could be
0072    * generated.
0073    */
0074   virtual tcPDPtr getHadron(tcPDPtr q1, tcPDPtr q2) const;
0075 
0076   /**
0077    * Get hadron from flavours. Return a hadron with the flavour
0078    * content given by the (anti-)(di-)quarks in the argument. The
0079    * arguments are given as PDG codes. The default
0080    * versions will call the getHadron(tcPDPtr, tcPDPtr).
0081    * @param iq1 the PDG code of the first flavour.
0082    * @param iq2 the PDG code of the second flavour.
0083    * @return the corresponding hadron type or null if none could be
0084    * generated.
0085    */
0086   virtual tcPDPtr getHadron(long iq1, long iq2) const;
0087 
0088   /**
0089    * Same as getHadron(tcPDPtr, tcPDPtr) but thows an exception if no
0090    * hadron could be produced.
0091    */
0092   tcPDPtr alwaysGetHadron(tcPDPtr q1, tcPDPtr q2) const;
0093 
0094   /**
0095    * Same as getHadron(long, long) but thows an exception if no hadron
0096    * could be produced.
0097    */
0098   tcPDPtr alwaysGetHadron(long iq1, long iq2) const;
0099 
0100   /**
0101    * Return a baryon with the flavour content given by the
0102    * (anti)quarks in the argument.  The arguments are given as
0103    * particle data pointers. The default versions will call
0104    * getBaryon(long, long, long). If no corresponding hadron was
0105    * formed it should return the null pointer.
0106    * @param q1 the first flavour.
0107    * @param q2 the second flavour.
0108    * @param q3 the third flavour.
0109    * @return the corresponding baryon type or null if none could be
0110    * generated.
0111    */
0112   virtual tcPDPtr getBaryon(tcPDPtr q1, tcPDPtr q2, tcPDPtr q3) const;
0113 
0114   /**
0115    * Return a baryon with the flavour content given by the
0116    * (anti)quarks in the argument.  The arguments are given as
0117    * particle data pointers. The default versions will call
0118    * getBaryon(tcPDPtr, tcPDPtr, tcPDPtr). If no corresponding hadron was
0119    * formed it should return the null pointer.
0120    * @param q1 the PDG code of the first flavour.
0121    * @param q2 the PDG code of the second flavour.
0122    * @param q3 the PDG code of the third flavour.
0123    * @return the corresponding baryon type or null if none could be
0124    * generated.
0125    */
0126   virtual tcPDPtr getBaryon(long q1, long q2, long q3) const;
0127 
0128   /**
0129    * Same as getBaryon(tcPDPtr, tcPDPtr, tcPDPtr), but throws an
0130    * exception if no baryon could be produced.
0131    */
0132   tcPDPtr alwaysGetBaryon(tcPDPtr q1, tcPDPtr q2, tcPDPtr q3) const;
0133   /**
0134    * Same as getBaryon(long, long, long), but throws an exception if
0135    * no baryon could be produced.
0136    */
0137   tcPDPtr alwaysGetBaryon(long q1, long q2, long q3) const;
0138 
0139   /**
0140    * Generate a random quark flavour.
0141    */
0142   virtual long selectQuark() const = 0;
0143 
0144   /**
0145    * Generate a random (di)quark flavour.
0146    */
0147   virtual long selectFlavour() const = 0;
0148   //@}
0149 
0150 public:
0151 
0152   /** @name Functions used by the persistent I/O system. */
0153   //@{
0154   /**
0155    * Function used to write out object persistently.
0156    * @param os the persistent output stream written to.
0157    */
0158   void persistentOutput(PersistentOStream & os) const;
0159 
0160   /**
0161    * Function used to read in object persistently.
0162    * @param is the persistent input stream read from.
0163    * @param version the version number of the object when written.
0164    */
0165   void persistentInput(PersistentIStream & is, int version);
0166   //@}
0167 
0168   /**
0169    * Standard Init function used to initialize the interface.
0170    */
0171   static void Init();
0172 
0173 
0174 private:
0175 
0176   /**
0177    * Describe aa abstract class without persistent data.
0178    */
0179   static AbstractNoPIOClassDescription<FlavourGenerator> initFlavourGenerator;
0180 
0181   /**
0182    *  Private and non-existent assignment operator.
0183    */
0184   FlavourGenerator & operator=(const FlavourGenerator &) = delete;
0185 
0186 };
0187 
0188 /** @cond EXCEPTIONCLASSES */
0189 /** An Exception class used by FlavourGenerator classes if no hadrons
0190     could be generated. */
0191 class FlavourGeneratorException: public Exception {};
0192 /** @endcond */
0193 
0194 /** @cond TRAITSPECIALIZATIONS */
0195 
0196 /**
0197  * This template specialization informs ThePEG about the
0198  * base class of FlavourGenerator.
0199  */
0200 template <>
0201 struct BaseClassTrait<FlavourGenerator,1>: public ClassTraitsType {
0202   /** Typedef of the base class of FlavourGenerator. */
0203   typedef HandlerBase NthBase;
0204 };
0205 
0206 /**
0207  * This template specialization informs ThePEG about the name of the
0208  * DecayHandler class.
0209  */
0210 template <>
0211 struct ClassTraits<FlavourGenerator>:
0212     public ClassTraitsBase<FlavourGenerator> {
0213   /** Return the class name. */
0214   static string className() {
0215     return "ThePEG::FlavourGenerator";
0216   }
0217 };
0218 
0219 /** @endcond */
0220 
0221 }
0222 
0223 #endif /* ThePEG_FlavourGenerator_H */