Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // -*- C++ -*-
0002 //
0003 // GoSamAmplitude.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_GoSamAmplitude_H
0010 #define Herwig_GoSamAmplitude_H
0011 //
0012 // This is the declaration of the GoSamAmplitude class.
0013 //
0014 
0015 #include "Herwig/MatrixElement/Matchbox/Base/MatchboxOLPME.h"
0016 #include "ThePEG/Utilities/DynamicLoader.h"
0017 
0018 
0019 namespace Herwig {
0020 
0021 using namespace ThePEG;
0022 
0023 
0024 class gosamprocinfo{
0025 
0026     public:
0027         gosamprocinfo(){};
0028         gosamprocinfo(int HID,int GID, string procstr,string typestr):
0029             theHOlpId(HID),theGOlpId(GID),theProcstr(procstr),theTypestr(typestr){
0030         }
0031         ~gosamprocinfo(){}
0032         int HID() const {return theHOlpId;}
0033         int GID() const {return theGOlpId;}
0034         string Pstr() const {return theProcstr;}
0035         string Tstr() const {return theTypestr;}
0036         void setGID(int g){theGOlpId=g;}
0037         void setOAs(int i){ orderAlphas=i;}
0038         int orderAs(){return orderAlphas;}
0039         void setOAew(int j){ orderAlphaew=j;}
0040         int orderAew(){return orderAlphaew;}
0041     private:
0042         int theHOlpId;
0043         int theGOlpId;
0044         string theProcstr;
0045         string theTypestr;
0046         int orderAlphas;
0047         int orderAlphaew;
0048     public:
0049         void persistentOutput(PersistentOStream & os) const{os<<theHOlpId<<theGOlpId<<theProcstr<<theTypestr<<orderAlphas<<orderAlphaew;}
0050         void persistentInput(PersistentIStream &is) {is>>theHOlpId>>theGOlpId>>theProcstr>>theTypestr>>orderAlphas>>orderAlphaew;}
0051 };
0052 
0053 
0054 /**
0055  * \ingroup Matchbox
0056  * \author Simon Platzer
0057  *
0058  * \brief GoSamAmplitude implements an interface to GoSam
0059  */
0060 class GoSamAmplitude: public MatchboxOLPME {
0061 
0062 public:
0063 
0064   /**
0065    * The default constructor.
0066    */
0067   GoSamAmplitude();
0068 
0069 public:
0070 
0071   virtual void fillOrderFile(const map<pair<Process,int>,int>& procs, string OrderFileName);
0072   
0073   virtual bool isCS() const { return false; }
0074   virtual bool isExpanded() const { return true; }
0075   virtual bool isBDK() const { return false; }
0076   virtual bool isDR() const { return isitDR; }
0077   virtual bool isDRbar() const {return false;}
0078 
0079   /**
0080    * Start the one loop provider, if appropriate, giving order and
0081    * contract files
0082    */
0083   virtual void signOLP(const string&, const string&);
0084 
0085   virtual bool checkOLPContract(string contractFileName);
0086 
0087   /**
0088    * Return true, if this amplitude already includes symmetry factors
0089    * for identical outgoing particles.
0090    */
0091   // virtual bool hasFinalStateSymmetry() const { return true; }
0092   virtual bool hasFinalStateSymmetry() const { return false; }
0093   
0094   virtual bool buildGoSam();
0095 
0096   /**
0097    * Start the one loop provider, if appropriate
0098    */
0099   virtual void startOLP(const string&, int& status);
0100 
0101   /**
0102    * Return the value of the dimensional regularization
0103    * parameter. Note that renormalization scale dependence is fully
0104    * restored in DipoleIOperator.
0105    */
0106   // virtual Energy2 mu2() const { return lastSHat(); }
0107 
0108   /**
0109    * Start the one loop provider, if appropriate. This default
0110    * implementation writes an BLHA 2.0 order file and starts the OLP
0111    */
0112   virtual bool startOLP(const map<pair<Process,int>,int>& procs);
0113 
0114   /**
0115    * Call OLP_EvalSubProcess and fill in the results
0116    */
0117   void evalSubProcess() const;
0118 
0119   /**
0120    * Fill in results for the given colour correlator
0121    */
0122   virtual void evalColourCorrelator(pair<int,int> ij) const;
0123 
0124   /**
0125    * Return a positive helicity polarization vector for a gluon of
0126    * momentum p (with reference vector n) to be used when evaluating
0127    * spin correlations.
0128    */
0129   virtual LorentzVector<Complex> plusPolarization(const Lorentz5Momentum& p,
0130                           const Lorentz5Momentum& n, int inc) const;
0131 
0132   /**
0133    * Fill in results for the given colour/spin correlator
0134    */
0135   virtual void evalSpinColourCorrelator(pair<int,int> ij) const;
0136 
0137   void getids() const;
0138 
0139   int accuracyTargetNegExp() const { return theAccuracyTarget; }
0140 
0141 public:
0142 
0143   /** @name Functions used by the persistent I/O system. */
0144   //@{
0145 
0146   /**
0147    * Function used to write out object persistently.
0148    * @param os the persistent output stream written to.
0149    */
0150   void persistentOutput(PersistentOStream & os) const;
0151 
0152   /**
0153    * Function used to read in object persistently.
0154    * @param is the persistent input stream read from.
0155    * @param version the version number of the object when written.
0156    */
0157   void persistentInput(PersistentIStream & is, int version);
0158 
0159   //@}
0160 
0161   /**
0162    * The standard Init function used to initialize the interfaces.
0163    * Called exactly once for each class by the class description system
0164    * before the main function starts or
0165    * when this class is dynamically loaded.
0166    */
0167   static void Init();
0168 
0169 
0170 protected:
0171 
0172   /** @name Standard Interfaced functions. */
0173   //@{
0174 
0175   /**
0176    * Initialize this object after the setup phase before saving an
0177    * EventGenerator to disk.
0178    * @throws InitException if object could not be initialized properly.
0179    */
0180   virtual void doinit();
0181 
0182   /**
0183    * Initialize this object. Called in the run phase just before
0184    * a run begins.
0185    */
0186   virtual void doinitrun();
0187   //@}
0188 
0189 
0190 protected:
0191 
0192   /** @name Clone Methods. */
0193   //@{
0194 
0195   /**
0196    * Make a simple clone of this object.
0197    * @return a pointer to the new object.
0198    */
0199   virtual IBPtr clone() const;
0200 
0201   /** Make a clone of this object, possibly modifying the cloned object
0202    * to make it sane.
0203    * @return a pointer to the new object.
0204    */
0205   virtual IBPtr fullclone() const;
0206 
0207   //@}
0208 
0209 
0210 // If needed, insert declarations of virtual function defined in the
0211 // InterfacedBase class here (using ThePEG-interfaced-decl in Emacs).
0212 
0213 
0214 private:
0215 
0216   /**
0217    * The assignment operator is private and must never be called.
0218    * In fact, it should not even be implemented.
0219    */
0220   GoSamAmplitude & operator=(const GoSamAmplitude &) = delete;
0221 
0222   /**
0223    * Store colour correlator results
0224    */
0225   mutable vector<double> colourCorrelatorResults;
0226 
0227   /**
0228    * Store spin colour correlator results
0229    */
0230   mutable vector<double> spinColourCorrelatorResults;
0231 
0232   /**
0233    * first is the olp id from herwig, second the answer from gosam
0234    */
0235   mutable vector<int> idpair;
0236 
0237   /**
0238    * first is the olp id from herwig, second the amplitude type
0239    */
0240   mutable vector<string> idtypepair;
0241 
0242    /**
0243    * Map to store all processes handled by this Amplitude
0244    */
0245   map<int , gosamprocinfo > processmap;
0246 
0247   mutable string gosamPathInterface;
0248   mutable string gosamSetupInFileNameInterface;
0249   mutable string gosamBuildScript;
0250 
0251   mutable string gosamPath;
0252   mutable string gosamSourcePath;
0253   mutable string gosamInstallPath;
0254 
0255   mutable string gosamSetupInFileName;
0256 
0257   mutable string orderFileTitle;
0258   mutable string contractFileTitle;
0259   mutable string contractFileName;
0260   mutable string orderFileName;
0261 
0262   mutable string accuracyFileTitle;
0263   mutable string accuracyFile;
0264   int theAccuracyTarget;
0265 
0266   bool theCodeExists;
0267   bool theFormOpt;
0268   bool theNinja;
0269   bool theHiggsEff;
0270   bool theMassiveLeptons;
0271 
0272   int theLoopInducedOption;
0273 
0274   bool isitDR;
0275 
0276   mutable bool doneGoSamInit;
0277   mutable bool doneGoSamInitRun;
0278   
0279   /**
0280    * The PDG codes of those quarks with mass
0281    */
0282   vector<int> massiveParticles; //theMassiveParticles;
0283 
0284   /**
0285    * Method to create the setup.in file for GoSam
0286    */
0287   void setupGoSamIn(string setupGoSamInFile);
0288 
0289 protected:
0290 
0291   /**
0292    *   Location of the installed executables
0293    */
0294   string bindir_;
0295 
0296   /**
0297    *   Location of the data files
0298    */
0299   string pkgdatadir_;
0300 
0301   /**
0302    *  Location of GOSAM
0303    */
0304   string GoSamPrefix_;
0305 
0306 }; // end "class GoSamAmplitude: public MatchboxOLPME"
0307 
0308   inline PersistentOStream& operator<<(PersistentOStream& os, const gosamprocinfo& p) {
0309     p.persistentOutput(os); return os;
0310   }
0311 
0312   inline PersistentIStream& operator>>(PersistentIStream& is, gosamprocinfo& p) {
0313     p.persistentInput(is); return is;
0314   }
0315 
0316 } // end "namespace Herwig"
0317 
0318 #endif /* Herwig_GoSamAmplitude_H */