Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // -*- C++ -*-
0002 //
0003 // DiagramBase.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_DiagramBase_H
0010 #define ThePEG_DiagramBase_H
0011 // This is the declaration of the DiagramBase class.
0012 
0013 #include "ThePEG/Config/ThePEG.h"
0014 #include "ThePEG/PDT/ParticleData.h"
0015 #include "ThePEG/MatrixElement/ColourLines.h"
0016 #include "ThePEG/Handlers/StandardXComb.fh"
0017 #include "DiagramBase.fh"
0018 #include "DiagramBase.xh"
0019 
0020 namespace ThePEG {
0021 
0022 /**
0023  * DiagramBase is the base class of all classes which describes
0024  * Feynman diagrams which can be generated by a matrix element class
0025  * inheriting from MEBase, as reported by the
0026  * MEBase::includedDiagrams() method.
0027  *
0028  * To work properly, a sub-class must in its constructor report the
0029  * incoming and outgoing parton types with the partons(int, const
0030  * cPDVector &, int) method. Also an id number should be given to be
0031  * used internally by the matrix element class. In addition, the
0032  * construct() method must be implemented to construct the actual
0033  * partons and connect them together in a SubProcess object, also
0034  * performing the colour connections using a given ColourLines object.
0035  *
0036  * @see MEBase
0037  * @see SubProcess
0038  * @see ColourLines
0039  * 
0040  */
0041 class DiagramBase: public Base {
0042 
0043 public:
0044 
0045   /** @name Standard constructors and destructors. */
0046   //@{
0047   /**
0048    * Default constructor.
0049    */
0050   DiagramBase() : theNIncoming(-1), theId(0) {}
0051 
0052   /**
0053    * Destructor.
0054    */
0055   virtual ~DiagramBase();
0056   //@}
0057 
0058 public:
0059 
0060   /** @name Main virtual function to be overridden in sub-classes. */
0061   //@{
0062   /**
0063    * Construct a sub process corresponding to this diagram. The
0064    * incoming partons, and the momenta of the outgoing ones, are given
0065    * by the XComb object. All parent/children pointers should be set
0066    * correspondingly and the partons should be colour connected as
0067    * specified by the ColourLines object.
0068    */
0069   virtual tPVector construct(SubProPtr sb, const StandardXComb &,
0070                  const ColourLines &) const = 0;
0071   //@}
0072   
0073   /** @name Access the underlying information. */
0074   //@{
0075   /**
0076    * Return the number of incoming partons for this diagram. I.e. the
0077    * incoming partons plus the number of space-like lines.
0078    */
0079   int nIncoming() const { return theNIncoming; }
0080 
0081   /**
0082    * Return the incoming, followed by the outgoing partons for this
0083    * diagram.
0084    */
0085   const cPDVector& partons() const { return thePartons; }
0086 
0087   /**
0088    * Return the id number of this diagram.
0089    */
0090   int id() const { return theId; }
0091 
0092   /**
0093    * Generate a tag which is unique for diagrams with the same
0094    * type of incoming and outgoing partons.
0095    */
0096   string getTag() const;
0097 
0098   /**
0099    * Compare this diagram to another one modulo
0100    * the ids of the diagrams.
0101    */
0102   virtual bool isSame (tcDiagPtr other) const {
0103     return 
0104       nIncoming() == other->nIncoming() &&
0105       partons() == other->partons();
0106   }
0107   //@}
0108 
0109 protected:
0110 
0111   /**
0112    * To be used by sub classes to report the incoming and outgoing
0113    * particle types, and an id number.
0114    *
0115    * @param ninc the number of incoming and other space-like lines in
0116    * the diagram.
0117    *
0118    * @param parts the types of partons for each external line in the
0119    * diagram.
0120    *
0121    * @param newId the id number of this diagram.
0122    */
0123   void partons(int ninc, const cPDVector & parts, int newId) {
0124     theNIncoming = ninc;
0125     thePartons = parts;
0126     theId = newId;
0127   }
0128 
0129   /**
0130    * Complete the missing information, provided partons() has already been
0131    * filled
0132    */
0133   void diagramInfo(int ninc, int newId) {
0134     theNIncoming = ninc;
0135     theId = newId;
0136   }
0137 
0138   /**
0139    * Returns true if the partons(int, const cPDVector &, int) function
0140    * has been called properly from the sub class.
0141    */
0142   bool done() const { return nIncoming() >= 0; }
0143 
0144   /**
0145    * Add to the partons
0146    */
0147   void addParton(tcPDPtr pd) { thePartons.push_back(pd); }
0148 
0149 public:
0150 
0151   /** @name Functions used by the persistent I/O system. */
0152   //@{
0153   /**
0154    * Function used to write out object persistently.
0155    * @param os the persistent output stream written to.
0156    */
0157   void persistentOutput(PersistentOStream & os) const;
0158 
0159   /**
0160    * Function used to read in object persistently.
0161    * @param is the persistent input stream read from.
0162    * @param version the version number of the object when written.
0163    */
0164   void persistentInput(PersistentIStream & is, int version);
0165   //@}
0166 
0167   /**
0168    * Standard Init function.
0169    */
0170   static void Init();
0171 
0172 private:
0173 
0174   /**
0175    * The number of incoming partons for this diagram.
0176    */
0177   int theNIncoming;
0178 
0179   /**
0180    * The incoming, followed by the outgoing partons for this
0181    * diagram.
0182    */
0183   cPDVector thePartons;
0184 
0185   /**
0186    * The id number of this diagram.
0187    */
0188   int theId;
0189 
0190 private:
0191 
0192   /**
0193    * Describe an abstract base class with persistent data.
0194    */
0195   static AbstractClassDescription<DiagramBase> initDiagramBase;
0196 
0197   /**
0198    *  Private and non-existent assignment operator.
0199    */
0200   DiagramBase & operator=(const DiagramBase &) = delete;
0201 
0202 };
0203 
0204 }
0205 
0206 
0207 namespace ThePEG {
0208 
0209 /** @cond TRAITSPECIALIZATIONS */
0210 
0211 /**
0212  * This template specialization informs ThePEG about the
0213  * base class of DiagramBase.
0214  */
0215 template <>
0216 struct BaseClassTrait<DiagramBase,1>: public ClassTraitsType {
0217   /** Typedef of the base class of DiagramBase. */
0218   typedef Base NthBase;
0219 };
0220 
0221 /**
0222  * This template specialization informs ThePEG about the name of the
0223  * DiagramBase class.
0224  */
0225 template <>
0226 struct ClassTraits<DiagramBase>: public ClassTraitsBase<DiagramBase> {
0227   /** Return the class name. */
0228   static string className() { return "ThePEG::DiagramBase"; }
0229 };
0230 
0231 /** @endcond */
0232 
0233 }
0234 
0235 #endif /* ThePEG_DiagramBase_H */