Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // -*- C++ -*-
0002 //
0003 // Tree2toNDiagram.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_Tree2toNDiagram_H
0010 #define ThePEG_Tree2toNDiagram_H
0011 // This is the declaration of the Tree2toNDiagram class.
0012 
0013 #include "ThePEG/MatrixElement/DiagramBase.h"
0014 #include "ThePEG/MatrixElement/ColourLines.h"
0015 #include "ThePEG/Handlers/StandardXComb.fh"
0016 #include "Tree2toNDiagram.xh"
0017 
0018 namespace ThePEG {
0019 
0020 /**
0021  * The Tree2toNDiagram class inherits from DiagramBase and represents
0022  * a Feynman tree diagram. It is represented by a chain of \f$n\f$
0023  * space-like propagators, where one incoming particle has index 1 and
0024  * other incoming one index \f$n\f$. For adiagram with in total
0025  * \f$m\f$ propagators the timelike propagators are then numbered
0026  * \f$n+1\f$ through \f$m\f$. The vector of type of the propagators
0027  * are accessible from the partons() method, and the parents of
0028  * propagator \f$i\f$ form the parents(int) method. The parent of a
0029  * space-like propagator is simply the previous space-like one. The
0030  * parent of a time-like propagator is either a previous time-like
0031  * propagator or the first of the connecting space-like ones.
0032  *
0033  * A Tree2toNDiagram is created by first constructing it with an
0034  * integer corresponding to the number of space-like propagators. Then
0035  * the comma operator is used to add first the particle data objects
0036  * corresponding to the space-like propagators, then the time-like
0037  * ones preceeded with the index of their parents. To complete a
0038  * Tree2toNDiagram, a negative integer is added with the comma
0039  * operator. This number is then used as an identifier. Note that the
0040  * parent must have been added before a child is. As an example, the
0041  * s-channel diagram \f$e \nu_e \rightarrow u \bar{d}\f$ is created
0042  * thus:<br>
0043  * <code>Tree2toNDiagram(2),eplus,nue,1,Wplus,3,u,3,dbar</code>.<br>
0044  * Similarly the t-channel diagram \f$e d \rightarrow \nu_e u\f$ is
0045  * created thus:<br>
0046  * <code>Tree2toNDiagram(3),eplus,Wplus,d,1,nu,2,u</code>.  Note that
0047  * only two chidren are allowed per propagator. This means that
0048  * four-propagator vertices are not allowed, but must be represented
0049  * by two three-propagator ones.
0050  *
0051  * Please note that for technical reasons, when specifying the
0052  * diagrams with the comma operator the numbering of the particles is
0053  * \f$1\ldots m\f$, while the internal representation (in the
0054  * parent(int) and children(int) function) is using \f$0\ldots m-1\f$
0055  *
0056  * @see DiagramBase
0057  * @see ColourLines
0058  * 
0059  */
0060 class Tree2toNDiagram: public DiagramBase {
0061 
0062 public:
0063 
0064   /** The integer type reresenting vector sizes. */
0065   typedef cPDVector::size_type size_type;
0066   /** A multi-set of particle data objects. */
0067   typedef multiset<tcPDPtr> PDMSet;
0068 
0069 public:
0070 
0071   /** @name Standard constructors and destructors. */
0072   //@{
0073   /**
0074    * Default constructor.
0075    */
0076   Tree2toNDiagram()
0077     : theNSpace(0), theNOutgoing(0), nextOrig(0) {}
0078 
0079   /**
0080    * Destructor.
0081    */
0082   ~Tree2toNDiagram();
0083 
0084   /**
0085    * The standard constructor giving the number of \a space-like
0086    * propagators.
0087    */
0088   explicit Tree2toNDiagram(int space) 
0089     : theNSpace(space), theNOutgoing(0), nextOrig(-1) {}
0090   //@}
0091 
0092 public:
0093 
0094   /**
0095    * If less than zero indicate that this tree is competed. Otherwise
0096    * signal the parent of the next added parton.
0097    */
0098   Tree2toNDiagram & operator,(int o) {
0099     nextOrig = o - 1;
0100     if ( o < 0 ) check();
0101     return *this;
0102   }
0103 
0104   /**
0105    * Add a space- or time-like parton.
0106    */
0107   Tree2toNDiagram & operator,(PDPtr pd) { return add(pd); }
0108 
0109   /**
0110    * Add a space- or time-like parton.
0111    */
0112   Tree2toNDiagram & operator,(cPDPtr pd) { return add(pd); }
0113 
0114   /**
0115    * Add a space- or time-like parton.
0116    */
0117   Tree2toNDiagram & operator,(tPDPtr pd) { return add(pd); }
0118 
0119   /**
0120    * Add a space- or time-like parton.
0121    */
0122   Tree2toNDiagram & operator,(tcPDPtr pd) { return add(pd); }
0123 
0124   /**
0125    * Construct a sub process corresponding to this diagram. The
0126    * incoming partons, and the momenta of the outgoing ones, are given
0127    * by the XComb object. All parent/children pointers should be set
0128    * correspondingly and the partons should be colour connected as
0129    * specified by the ColourLines object.
0130    */
0131   virtual tPVector construct(SubProPtr sb, const StandardXComb &,
0132                  const ColourLines &) const;
0133 
0134   /**
0135    * Return the types of the incoming partons.
0136    */
0137   tcPDPair incoming() const;
0138 
0139   /**
0140    * Return the complete vector of partons in this tree diagram.
0141    */
0142   const cPDVector & allPartons() const { return thePartons; }
0143 
0144   /**
0145    * Return the outgoing parton types of this tree diagram.
0146    */
0147   tcPDVector outgoing() const;
0148 
0149   /**
0150    * Return the incoming followed by the outgoing parton types of this
0151    * tree diagram.
0152    */
0153   tcPDVector external() const;
0154 
0155   /**
0156    * Return the index of the parent of the given parton.
0157    */
0158   int parent(int i) const { return theParents[i]; }
0159 
0160   /**
0161    * Return the indices of the children of the given parton.
0162    */
0163   pair<int,int> children(int) const;
0164 
0165   /**
0166    * Return the number of space-like partons
0167    */
0168   int nSpace() const { return theNSpace; }
0169 
0170   /**
0171    * Extend this diagram to accomodate the given number of space-like lines
0172    */
0173   void resize(size_type nSpace) {
0174     theNSpace = max(nSpace,theNSpace);
0175   }
0176 
0177   /**
0178    * Return the number of outgoing partons.
0179    */
0180   int nOutgoing() const { return theNOutgoing; }
0181 
0182 private:
0183 
0184   /**
0185    * Check the consistency of this tree diagram.
0186    */
0187   void check();
0188 
0189   /**
0190    * Add a space-like parton to this diagram.
0191    */
0192   void addSpacelike(tcPDPtr pd) {
0193     if ( thePartons.size() >= theNSpace ) throw Tree2toNDiagramError();
0194     theParents.push_back(thePartons.size() - 1);
0195     thePartons.push_back(pd);
0196   }
0197   /**
0198    * Add a time-like parton to this diagram.
0199    */
0200   void addTimelike(tcPDPtr);
0201 
0202   /**
0203    * Add a time-like parton to this diagram indicating its \a origin.
0204    */
0205   void addTimelike(tcPDPtr, size_type origin);
0206 
0207   /**
0208    * Add a parton to this diagram.
0209    */
0210   Tree2toNDiagram & add(tcPDPtr);
0211 
0212 public:
0213 
0214   /**
0215    * Compare this diagram's topology to another one.
0216    */
0217   virtual bool isSame(tcDiagPtr) const;
0218 
0219   /**
0220    * Compare this diagram's topology to another one modulo
0221    * permutations of external legs; provide a map of this diagram's
0222    * external legs to the other diagram's external legs.
0223    */
0224   virtual bool isSame(tcDiagPtr, map<int,int>&) const;
0225 
0226   /**
0227    * Check for equality.
0228    */
0229   bool equals(Ptr<Tree2toNDiagram>::tcptr, int start=0, int startCmp=0) const;
0230 
0231   /**
0232    * Check for equality modulo permutations of external legs.
0233    */
0234   bool equals(Ptr<Tree2toNDiagram>::tcptr, 
0235           map<int,int>&,
0236           int start=0, int startCmp=0) const;
0237 
0238   /**
0239    * Merge the two external partons referred to by indices as in the
0240    * partons() vector returned by DiagramBase. If both are timelike,
0241    * the parent will become the new outgoing parton, if one is space-
0242    * and the other timelike, the spacelike child will become the new
0243    * incoming parton.  Return the position of the merged parton in the
0244    * resulting diagram or -1 if the merging is not possible. In
0245    * addition, return a mapping of a certain (non-merged) external leg
0246    * id to the id in the merged diagram.
0247    */
0248   int mergeEmission(int emitter, int id, map<int,int>& remap);
0249 
0250   /**
0251    * Translate a parton's id in the diagram to a parton's id in a
0252    * vector of incoming followed by outgoing partons.
0253    */
0254   int externalId(int id) const;
0255 
0256   /**
0257    * Translate a parton's id in a vector of incoming followed by
0258    * outgoing partons to a parton's id in the diagram.
0259    */
0260   int diagramId(int id) const;
0261 
0262 public:
0263 
0264   /** @name Functions used by the persistent I/O system. */
0265   //@{
0266   /**
0267    * Function used to write out object persistently.
0268    * @param os the persistent output stream written to.
0269    */
0270   void persistentOutput(PersistentOStream & os) const;
0271 
0272   /**
0273    * Function used to read in object persistently.
0274    * @param is the persistent input stream read from.
0275    * @param version the version number of the object when written.
0276    */
0277   void persistentInput(PersistentIStream & is, int version);
0278   //@}
0279 
0280 private:
0281 
0282   /**
0283    * The number of space-like partons
0284    */
0285   size_type theNSpace;
0286 
0287   /**
0288    * The number of outgoing partons.
0289    */
0290   int theNOutgoing;
0291 
0292   /**
0293    * The parent of the next added parton.
0294    */
0295   int nextOrig;
0296 
0297   /**
0298    * The complete vector of partons in this tree diagram.
0299    */
0300   cPDVector thePartons;
0301 
0302   /**
0303    * The index of the parents.
0304    */
0305   vector<int> theParents;
0306 
0307 private:
0308 
0309   /**
0310    * Describe a concrete class with persistent data.
0311    */
0312   static ClassDescription<Tree2toNDiagram> initTree2toNDiagram;
0313 
0314   /**
0315    *  Private and non-existent assignment operator.
0316    */
0317   Tree2toNDiagram & operator=(const Tree2toNDiagram &) = delete;
0318 
0319 };
0320 
0321 }
0322 
0323 namespace ThePEG {
0324 
0325 /** @cond TRAITSPECIALIZATIONS */
0326 
0327 /**
0328  * This template specialization informs ThePEG about the
0329  * base class of Tree2toNDiagram.
0330  */
0331 template <>
0332 struct BaseClassTrait<Tree2toNDiagram,1>: public ClassTraitsType {
0333   /** Typedef of the base class of Tree2toNDiagram. */
0334   typedef DiagramBase NthBase;
0335 };
0336 
0337 /**
0338  * This template specialization informs ThePEG about the name of the
0339  * Tree2toNDiagram class.
0340  */
0341 template <>
0342 struct ClassTraits<Tree2toNDiagram>: public ClassTraitsBase<Tree2toNDiagram> {
0343   /** Return the class name. */
0344   static string className() { return "ThePEG::Tree2toNDiagram"; }
0345 };
0346 
0347 /** @endcond */
0348 
0349 }
0350 
0351 #endif /* ThePEG_Tree2toNDiagram_H */