Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-08-06 09:24:13

0001 // -*- C++ -*-
0002 //
0003 // MadGraphAmplitude.h is a part of Herwig - A multi-purpose Monte Carlo event generator
0004 // Copyright (C) 2002-2019 The Herwig Collaboration
0005 //
0006 // Herwig 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 Herwig_MadGraphAmplitude_H
0010 #define Herwig_MadGraphAmplitude_H
0011 //
0012 // This is the declaration of the MadGraphAmplitude class.
0013 //
0014 
0015 #include "Herwig/MatrixElement/Matchbox/Base/MatchboxAmplitude.h"
0016 #include "Herwig/MatrixElement/Matchbox/Builtin/Amplitudes/MatchboxCurrents.h"
0017 #include "ThePEG/Utilities/DynamicLoader.h"
0018 
0019 namespace Herwig {
0020 
0021 
0022 using namespace ThePEG; 
0023 
0024 /**
0025  * \ingroup Matchbox
0026  * \author Johannes Bellm, Simon Platzer
0027  *
0028  * \brief MadGraphAmplitude implements an interface to MadGraph
0029  */
0030 class MadGraphAmplitude: 
0031     public MatchboxAmplitude {
0032 
0033 public:
0034 
0035   /** @name Standard constructors and destructors. */
0036   //@{
0037   /**
0038    * The default constructor.
0039    */
0040   MadGraphAmplitude();
0041 
0042   /**
0043    * The destructor.
0044    */
0045   virtual ~MadGraphAmplitude();
0046   //@}
0047 
0048 public:
0049 
0050   /**
0051    * Return true, if this amplitude can handle the given process.
0052    */
0053   virtual bool canHandle(const PDVector&,
0054              Ptr<MatchboxFactory>::tptr,
0055              bool) const;
0056 
0057   /**
0058    * Return true, if this amplitude already includes symmetry factors
0059    * for identical outgoing particles.
0060    */
0061   virtual bool hasFinalStateSymmetry() const { return false; }
0062 
0063   /**
0064    * Set the (tree-level) order in \f$g_S\f$ in which this matrix
0065    * element should be evaluated.
0066    */
0067   virtual void orderInGs(unsigned int ogs) { theOrderInGs = ogs; }
0068 
0069   /**
0070    * Return the (tree-level) order in \f$g_S\f$ in which this matrix
0071    * element is given.
0072    */
0073   virtual unsigned int orderInGs() const { return theOrderInGs; }
0074 
0075   /**
0076    * Set the (tree-level) order in \f$g_{EM}\f$ in which this matrix
0077    * element should be evaluated.
0078    */
0079   virtual void orderInGem(unsigned int oge) { theOrderInGem = oge; }
0080 
0081   /**
0082    * Return the (tree-level) order in \f$g_{EM}\f$ in which this matrix
0083    * element is given.
0084    */
0085   virtual unsigned int orderInGem() const { return theOrderInGem; }
0086 
0087   /**
0088    * Return true, if this amplitude is capable of calculating one-loop
0089    * (QCD) corrections.
0090    */
0091   virtual bool haveOneLoop() const { return true; }
0092 
0093   /**
0094    * Calculate the tree level amplitudes for the phasespace point
0095    * stored in lastXComb.
0096    */
0097   virtual void prepareAmplitudes(Ptr<MatchboxMEBase>::tcptr);
0098   
0099   /**
0100    * Calculate the one-loop amplitudes for the phasespace point
0101    * stored in lastXComb, if provided.
0102    */
0103   virtual void prepareOneLoopAmplitudes(Ptr<MatchboxMEBase>::tcptr);
0104 
0105   /**
0106    * Evaluate the amplitude for the given colour tensor id and
0107    * helicity assignment
0108    */
0109   virtual Complex evaluate(size_t, const vector<int>&, Complex&);
0110 
0111    /**
0112    * Return true, if one-loop contributions will be evaluated at amplitude level.
0113    */
0114   virtual bool oneLoopAmplitudes() const { return false; }
0115   
0116    /**
0117    * Return the one-loop/tree interference.
0118    */
0119   virtual double oneLoopInterference() const;
0120   
0121   void evaloneLoopInterference() const;
0122 
0123 
0124   /**
0125    * Return true, if one loop corrections are given in the conventions
0126    * of BDK.
0127    */
0128 
0129   virtual bool isCS() const { return false; }
0130   virtual bool isExpanded() const { return true; }
0131   virtual bool isBDK() const { return false; }
0132   virtual bool isDR() const { return false; }
0133   virtual bool isDRbar() const {return false;}
0134 
0135   /**
0136    * Return the value of the dimensional regularization
0137    * parameter. Note that renormalization scale dependence is fully
0138    * restored in DipoleIOperator.
0139    */
0140   virtual Energy2 mu2() const { return sqr(91.18800000000*GeV);}
0141   //virtual Energy2 mu2() const { return lastSHat(); }
0142   
0143   
0144   virtual LorentzVector<Complex> plusPolarization(const Lorentz5Momentum& p,
0145                           const Lorentz5Momentum& n,
0146                           int id = -1) const;
0147   /**
0148    * Return the colour and spin correlated matrix element.
0149    */
0150   virtual double spinColourCorrelatedME2(pair<int,int> emitterSpectator,
0151                      const SpinCorrelationTensor& c) const;
0152 
0153   /**
0154    * Order process in MadGraph conventions
0155    */                         
0156   vector<size_t> gluonsFirst(vector<size_t> i);
0157 
0158   /**
0159    * Flush all cashes.
0160    */
0161   virtual void flushCaches() {
0162     MatchboxAmplitude::flushCaches();
0163   }
0164 
0165   /**
0166    * Return true, if this amplitude needs to initialize an external
0167    * code.
0168    */
0169   virtual bool isExternal() const { return true; }
0170 
0171   /**
0172    * Initialize this amplitude
0173    */
0174   virtual bool initializeExternal();
0175 
0176   /**
0177    * Return a generic process id for the given process
0178    */
0179   virtual int externalId(const cPDVector&);
0180       
0181   
0182   /**
0183    * Write out BornAmplitudes.dat and VirtualAmplitudes.dat,
0184    * return true if new files are written.
0185    */
0186       
0187   virtual bool writeAmplitudesDat();
0188       
0189   /**
0190    * CHeck if all amplitudes are in the Libary.
0191    */
0192       
0193   virtual bool checkAmplitudes();
0194       
0195   
0196   string mgProcLibPath();
0197 
0198   /**
0199    * Return true, if this amplitude is capable of consistently filling
0200    * the rho matrices for the spin correllations
0201    */
0202   virtual bool canFillRhoMatrix() const { return true; }
0203 
0204   /**
0205    * Return the helicity combination of the physical process in the
0206    * conventions used by the spin correlation algorithm.
0207    */
0208   virtual vector<unsigned int> physicalHelicities(const vector<int>&) const;
0209 
0210 public:
0211 
0212   /** @name Functions used by the persistent I/O system. */
0213   //@{
0214   /**
0215    * Function used to write out object persistently.
0216    * @param os the persistent output stream written to.
0217    */
0218   void persistentOutput(PersistentOStream & os) const;
0219 
0220   /**
0221    * Function used to read in object persistently.
0222    * @param is the persistent input stream read from.
0223    * @param version the version number of the object when written.
0224    */
0225   void persistentInput(PersistentIStream & is, int version);
0226   //@}
0227 
0228   /**
0229    * The standard Init function used to initialize the interfaces.
0230    * Called exactly once for each class by the class description system
0231    * before the main function starts or
0232    * when this class is dynamically loaded.
0233    */
0234   static void Init();
0235 
0236 protected:
0237 
0238   /** @name Clone Methods. */
0239   //@{
0240   /**
0241    * Make a simple clone of this object.
0242    * @return a pointer to the new object.
0243    */
0244   virtual IBPtr clone() const;
0245 
0246   /** Make a clone of this object, possibly modifying the cloned object
0247    * to make it sane.
0248    * @return a pointer to the new object.
0249    */
0250   virtual IBPtr fullclone() const;
0251   //@}
0252 
0253 
0254 // If needed, insert declarations of virtual function defined in the
0255 // InterfacedBase class here (using ThePEG-interfaced-decl in Emacs).
0256 
0257 protected:
0258 
0259   /** @name Standard Interfaced functions. */
0260   //@{
0261   /**
0262    * Initialize this object after the setup phase before saving an
0263    * EventGenerator to disk.
0264    * @throws InitException if object could not be initialized properly.
0265    */
0266   virtual void doinit();
0267 
0268   /**
0269    * Initialize this object. Called in the run phase just before
0270    * a run begins.
0271    */
0272   virtual void doinitrun();
0273 
0274   /**
0275    * The (tree-level) order in \f$g_S\f$ in which this matrix
0276    * element is given.
0277    */
0278   unsigned int theOrderInGs;
0279 
0280   /**
0281    * The (tree-level) order in \f$g_{EM}\f$ in which this matrix
0282    * element is given.
0283    */
0284   unsigned int theOrderInGem;
0285   
0286   /**
0287    * The path for the process libraries.
0288    */
0289   static string theProcessPath;
0290   
0291   /**
0292    * The path to generate amplitudes in.
0293    */
0294   static string theMGmodel;
0295   
0296   bool keepinputtopmass;
0297 
0298 
0299   /**
0300    * Initialize the given process
0301    */
0302   void initProcess(const cPDVector&);
0303 
0304 
0305   /**
0306    * Storage for Amplitudes 
0307    */
0308   static vector<string>  BornAmplitudes,VirtAmplitudes;
0309    
0310     /**
0311    * Helper for color and crossing handling 
0312    */ 
0313   mutable vector<int>  colourindex, crossing;
0314   
0315         
0316   /**
0317   * Static Variables to handle initialization.
0318   */
0319         
0320   static bool ranMadGraphInitializeExternal;
0321   static bool initializedMad;
0322   
0323 
0324   
0325   //@}
0326 
0327 protected:
0328 
0329   /**
0330    *   Location of the installed executables
0331    */
0332   static string bindir_;
0333 
0334   /**
0335    *   Location of the installed include files
0336    */
0337   static string includedir_;
0338 
0339   /**
0340    *   Location of the data files
0341    */
0342   static string pkgdatadir_;
0343 
0344   /**
0345    *  Location of MADGRAPH
0346    */
0347   static string madgraphPrefix_;
0348       
0349   /**
0350    *  Helper functions to make long strings static
0351    */
0352       
0353   void setProcessPath(string );
0354   string getProcessPath() const;
0355       
0356   void setBinDir(string p);
0357   string getBinDir() const;
0358       
0359   void setDataDir(string p);
0360   string getDataDir() const;
0361      
0362   void setModel(string p);
0363   string getModel() const;
0364       
0365   void setMadgraphPrefix(string p);
0366   string getMadgraphPrefix() const ;
0367 
0368 private:
0369 
0370   /**
0371    * The assignment operator is private and must never be called.
0372    * In fact, it should not even be implemented.
0373    */
0374   MadGraphAmplitude & operator=(const MadGraphAmplitude &) = delete;
0375 
0376 
0377 };
0378 
0379 }
0380 
0381 #endif /* Herwig_MadGraphAmplitude_H */