Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // -*- C++ -*-
0002 //
0003 // MatchboxMEBase.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_MatchboxMEBase_H
0010 #define HERWIG_MatchboxMEBase_H
0011 //
0012 // This is the declaration of the MatchboxMEBase class.
0013 //
0014 
0015 #include "ThePEG/MatrixElement/MEBase.h"
0016 #include "Herwig/MatrixElement/Matchbox/Utility/SpinCorrelationTensor.h"
0017 #include "Herwig/MatrixElement/Matchbox/Utility/Tree2toNGenerator.h"
0018 #include "Herwig/MatrixElement/Matchbox/Utility/MatchboxScaleChoice.h"
0019 #include "Herwig/MatrixElement/Matchbox/Utility/ProcessData.h"
0020 #include "Herwig/MatrixElement/Matchbox/Base/MatchboxAmplitude.h"
0021 #include "Herwig/MatrixElement/Matchbox/Base/MatchboxReweightBase.h"
0022 #include "Herwig/MatrixElement/Matchbox/Base/MatchboxMEBase.fh"
0023 #include "Herwig/MatrixElement/Matchbox/Base/MergerBase.h"
0024 #include "Herwig/MatrixElement/Matchbox/Dipoles/SubtractionDipole.fh"
0025 #include "Herwig/MatrixElement/Matchbox/InsertionOperators/MatchboxInsertionOperator.h"
0026 #include "Herwig/MatrixElement/Matchbox/MatchboxFactory.fh"
0027 #include "Herwig/MatrixElement/Matchbox/Utility/LastMatchboxXCombInfo.h"
0028 #include "Herwig/MatrixElement/Matchbox/Utility/MatchboxXComb.h"
0029 
0030 namespace Herwig {
0031 
0032 using namespace ThePEG;
0033 
0034 /**
0035  * \ingroup Matchbox
0036  * \author Simon Platzer
0037  *
0038  * \brief MatchboxMEBase is the base class for matrix elements
0039  * in the context of the matchbox NLO interface.
0040  *
0041  * @see \ref MatchboxMEBaseInterfaces "The interfaces"
0042  * defined for MatchboxMEBase.
0043  */
0044 class MatchboxMEBase: 
0045     public MEBase, public LastMatchboxXCombInfo {
0046 
0047 public:
0048 
0049   /**
0050    * The default constructor.
0051    */
0052   MatchboxMEBase();
0053 
0054 public:
0055 
0056   /**
0057    * Return the factory which produced this matrix element
0058    */
0059   Ptr<MatchboxFactory>::tptr factory() const;
0060 
0061   /** @name Subprocess and diagram information. */
0062   //@{
0063 
0064   /**
0065    * Return the subprocess.
0066    */
0067   const Process& subProcess() const { return theSubprocess; }
0068 
0069   /**
0070    * Access the subprocess.
0071    */
0072   Process& subProcess() { return theSubprocess; }
0073 
0074   /**
0075    * Return the diagram generator.
0076    */
0077   Ptr<Tree2toNGenerator>::tptr diagramGenerator() const;
0078 
0079   /**
0080    * Return the process data.
0081    */
0082   Ptr<ProcessData>::tptr processData() const;
0083 
0084   /**
0085    * Return true, if this matrix element does not want to
0086    * make use of mirroring processes; in this case all
0087    * possible partonic subprocesses with a fixed assignment
0088    * of incoming particles need to be provided through the diagrams
0089    * added with the add(...) method.
0090    */
0091   virtual bool noMirror () const { return true; }
0092 
0093   /**
0094    * Add all possible diagrams with the add() function.
0095    */
0096   virtual void getDiagrams() const;
0097   using MEBase::getDiagrams;
0098 
0099   /**
0100    * With the information previously supplied with the
0101    * setKinematics(...) method, a derived class may optionally
0102    * override this method to weight the given diagrams with their
0103    * (although certainly not physical) relative probabilities.
0104    */
0105   virtual Selector<DiagramIndex> diagrams(const DiagramVector &) const;
0106   using MEBase::diagrams;
0107 
0108   /**
0109    * Return a Selector with possible colour geometries for the selected
0110    * diagram weighted by their relative probabilities.
0111    */
0112   virtual Selector<const ColourLines *>
0113   colourGeometries(tcDiagPtr diag) const;
0114 
0115   /**
0116    * Return true, if this amplitude is capable of consistently filling
0117    * the rho matrices for the spin correllations
0118    */
0119   virtual bool canFillRhoMatrix() const { 
0120     if ( matchboxAmplitude() )
0121       return matchboxAmplitude()->canFillRhoMatrix();
0122     return false;
0123   }
0124 
0125   /**
0126    * construct the spin information for the interaction
0127    */
0128   virtual void constructVertex(tSubProPtr) {}
0129 
0130   /**
0131    * construct the spin information for the interaction
0132    */
0133   virtual void constructVertex(tSubProPtr sub, const ColourLines* cl);
0134 
0135   /**
0136    * Return the order in \f$\alpha_S\f$ in which this matrix element
0137    * is given.
0138    */
0139   virtual unsigned int orderInAlphaS() const;
0140   using MEBase::orderInAlphaS;
0141 
0142   /**
0143    * Return the order in \f$\alpha_{EM}\f$ in which this matrix
0144    * element is given. Returns 0.
0145    */
0146   virtual unsigned int orderInAlphaEW() const;
0147   using MEBase::orderInAlphaEW;  
0148 
0149   /**
0150    * Return true, if this amplitude already includes averaging over
0151    * incoming parton's quantum numbers.
0152    */
0153   virtual bool hasInitialAverage() const { 
0154     return matchboxAmplitude() ? matchboxAmplitude()->hasInitialAverage() : false;
0155   }
0156 
0157   /**
0158    * Return true, if this amplitude already includes symmetry factors
0159    * for identical outgoing particles.
0160    */
0161   virtual bool hasFinalStateSymmetry() const { 
0162     return matchboxAmplitude() ? matchboxAmplitude()->hasFinalStateSymmetry() : false; 
0163   }
0164 
0165 
0166   /**
0167    * Return the number of light flavours, this matrix
0168    * element is calculated for.
0169    */
0170   virtual unsigned int getNLight() const;
0171 
0172   /**
0173    * Return the vector that contains the PDG ids of 
0174    * the light flavours, which are contained in the
0175    * jet particle group.
0176    */
0177   virtual vector<long> getNLightJetVec() const;
0178 
0179   /**
0180    * Return the vector that contains the PDG ids of 
0181    * the heavy flavours, which are contained in the
0182    * jet particle group.
0183    */
0184   virtual vector<long> getNHeavyJetVec() const;
0185 
0186   /**
0187    * Return the vector that contains the PDG ids of 
0188    * the light flavours, which are contained in the
0189    * proton particle group.
0190    */
0191   virtual vector<long> getNLightProtonVec() const;
0192 
0193   /**
0194    * Return true, if this matrix element is handled by a BLHA one-loop provider
0195    */
0196   virtual bool isOLPTree() const { 
0197     return matchboxAmplitude() ? matchboxAmplitude()->isOLPTree() : false;
0198   }
0199 
0200   /**
0201    * Return true, if this matrix element is handled by a BLHA one-loop provider
0202    */
0203   virtual bool isOLPLoop() const { 
0204     return matchboxAmplitude() ? matchboxAmplitude()->isOLPLoop() : false;
0205   }
0206 
0207   /**
0208    * Return true, if colour and spin correlated matrix elements should
0209    * be ordered from the OLP
0210    */
0211   virtual bool needsOLPCorrelators() const { 
0212     return matchboxAmplitude() ? matchboxAmplitude()->needsOLPCorrelators() : true;
0213   }
0214 
0215   /**
0216    * Return the process index, if this is an OLP handled matrix element
0217    */
0218   const vector<int>& olpProcess() const { return theOLPProcess; }
0219 
0220   /**
0221    * Set the process index, if this is an OLP handled matrix element
0222    */
0223   void olpProcess(int pType, int id) { 
0224     if ( theOLPProcess.empty() )
0225       theOLPProcess.resize(5,0);
0226     theOLPProcess[pType] = id;
0227   }
0228 
0229   /**
0230    * Return true, if this is a real emission matrix element which does
0231    * not require colour correlators.
0232    */
0233   bool noCorrelations() const {
0234     return theNoCorrelations;
0235   }
0236 
0237   /**
0238    * Indicate that this is a real emission matrix element which does
0239    * not require colour correlators.
0240    */
0241   void needsNoCorrelations() {
0242     theNoCorrelations = true;
0243   }
0244 
0245   /**
0246    * Indicate that this is a virtual matrix element which does
0247    * require colour correlators.
0248    */
0249   void needsCorrelations() {
0250     theNoCorrelations = false;
0251   }
0252 
0253   //@}
0254 
0255   /** @name Phasespace generation */
0256   //@{
0257 
0258   /**
0259    * Return the phase space generator to be used.
0260    */
0261   Ptr<MatchboxPhasespace>::tptr phasespace() const { return thePhasespace; }
0262 
0263   /**
0264    * Set the phase space generator to be used.
0265    */
0266   void phasespace(Ptr<MatchboxPhasespace>::ptr ps) { thePhasespace = ps; }
0267 
0268   /**
0269    * Set the XComb object to be used in the next call to
0270    * generateKinematics() and dSigHatDR().
0271    */
0272   virtual void setXComb(tStdXCombPtr xc);
0273 
0274   /**
0275    * Return true, if the XComb steering this matrix element
0276    * should keep track of the random numbers used to generate
0277    * the last phase space point
0278    */
0279   virtual bool keepRandomNumbers() const { return true; }
0280 
0281   /**
0282    * Generate incoming parton momenta. This default
0283    * implementation performs the standard mapping
0284    * from x1,x2 -> tau,y making 1/tau flat; incoming
0285    * parton momenta are stored in meMomenta()[0,1],
0286    * only massless partons are supported so far;
0287    * return the Jacobian of the mapping
0288    */
0289   double generateIncomingPartons(const double* r1, const double* r2);
0290 
0291   /**
0292    * Generate internal degrees of freedom given nDim() uniform random
0293    * numbers in the interval ]0,1[. To help the phase space generator,
0294    * the 'dSigHatDR' should be a smooth function of these numbers,
0295    * although this is not strictly necessary. The return value should
0296    * be true of the generation succeeded. If so the generated momenta
0297    * should be stored in the meMomenta() vector. Derived classes
0298    * must call this method once internal degrees of freedom are setup
0299    * and finally return the result of this method.
0300    */
0301   virtual bool generateKinematics(const double * r);
0302 
0303   /**
0304    * Set the typed and momenta of the incoming and outgoing partons to
0305    * be used in subsequent calls to me() and colourGeometries()
0306    * according to the associated XComb object. If the function is
0307    * overridden in a sub class the new function must call the base
0308    * class one first.
0309    */
0310   virtual void setKinematics();
0311 
0312   /**
0313    * Clear the information previously provided by a call to
0314    * setKinematics(...).
0315    */
0316   virtual void clearKinematics();
0317 
0318   /**
0319    * The number of internal degreed of freedom used in the matrix
0320    * element.
0321    */
0322   virtual int nDim() const;
0323 
0324   /**
0325    * The number of internal degrees of freedom used in the matrix
0326    * element for generating a Born phase space point
0327    */
0328   virtual int nDimBorn() const;
0329 
0330   /**
0331    * Return true, if this matrix element will generate momenta for the
0332    * incoming partons itself.  The matrix element is required to store
0333    * the incoming parton momenta in meMomenta()[0,1]. No mapping in
0334    * tau and y is performed by the PartonExtractor object, if a
0335    * derived class returns true here. The phase space jacobian is to
0336    * include a factor 1/(x1 x2).
0337    */
0338   virtual bool haveX1X2() const { 
0339     return 
0340       (phasespace() ? phasespace()->haveX1X2() : false) ||
0341       diagrams().front()->partons().size() == 3;
0342   }
0343 
0344   /**
0345    * Return true, if this matrix element expects
0346    * the incoming partons in their center-of-mass system
0347    */
0348   virtual bool wantCMS() const { 
0349     return 
0350       (phasespace() ? phasespace()->wantCMS() : true) &&
0351       diagrams().front()->partons().size() != 3; }
0352 
0353   /**
0354    * Return the meMomenta as generated at the last
0355    * phase space point.
0356    */
0357   const vector<Lorentz5Momentum>& lastMEMomenta() const { return meMomenta(); }
0358 
0359   /**
0360    * Access the meMomenta.
0361    */
0362   vector<Lorentz5Momentum>& lastMEMomenta() { return meMomenta(); }
0363   
0364   
0365   /**
0366    * leg size
0367    */
0368   
0369   int legsize() const {return int(meMomenta().size());}
0370 
0371   //@}
0372 
0373   /** @name Scale choices, couplings and PDFs */
0374   //@{
0375 
0376   /**
0377    * Set the scale choice object
0378    */
0379   void scaleChoice(Ptr<MatchboxScaleChoice>::ptr sc) { theScaleChoice = sc; }
0380 
0381   /**
0382    * Return the scale choice object
0383    */
0384   Ptr<MatchboxScaleChoice>::tptr scaleChoice() const { return theScaleChoice; }
0385 
0386   /**
0387    * Set scales and alphaS
0388    */
0389   void setScale(Energy2 ren=ZERO,Energy2 fac=ZERO) const;
0390 
0391   /**
0392    * Indicate that this matrix element is running alphas by itself.
0393    */
0394   virtual bool hasRunningAlphaS() const { 
0395     if ( matchboxAmplitude() )
0396       return matchboxAmplitude()->hasRunningAlphaS();
0397     return false;
0398   }
0399 
0400   /**
0401    * Indicate that this matrix element  is running alphaew by itself.
0402    */
0403   virtual bool hasRunningAlphaEW() const {
0404     if ( matchboxAmplitude() )
0405       return matchboxAmplitude()->hasRunningAlphaEW();
0406     return false;
0407   }
0408 
0409   /**
0410    * Return the scale associated with the phase space point provided
0411    * by the last call to setKinematics().
0412    */
0413   virtual Energy2 scale() const { return lastScale(); }
0414 
0415   /**
0416    * Return the renormalization scale for the last generated phasespace point.
0417    */
0418   virtual Energy2 factorizationScale() const;
0419 
0420   /**
0421    * Get the factorization scale factor
0422    */
0423   virtual double factorizationScaleFactor() const;
0424       
0425       
0426   /**
0427     * Get the factorization scale factor
0428     */
0429   virtual double facFac() const{return factorizationScaleFactor();}
0430 
0431   /**
0432    * Return the (QCD) renormalization scale for the last generated phasespace point.
0433    */
0434   virtual Energy2 renormalizationScale() const;
0435 
0436   /**
0437    * Get the renormalization scale factor
0438    */
0439   virtual double renormalizationScaleFactor() const;
0440       
0441       
0442   /**
0443    * Get the renormalization scale factor
0444    */
0445   virtual double renFac() const{return renormalizationScaleFactor();}
0446 
0447   /**
0448    * Return the QED renormalization scale for the last generated phasespace point.
0449    */
0450   virtual Energy2 renormalizationScaleQED() const;
0451 
0452   /**
0453    * Return the shower scale for the last generated phasespace point.
0454    */
0455   virtual Energy2 showerScale() const;
0456 
0457   /**
0458    * Set veto scales on the particles at the given
0459    * SubProcess which has been generated using this
0460    * matrix element.
0461    */
0462   virtual void setVetoScales(tSubProPtr) const;
0463 
0464   /**
0465    * Return true, if fixed couplings are used.
0466    */
0467   bool fixedCouplings() const;
0468 
0469   /**
0470    * Return true, if fixed couplings are used.
0471    */
0472   bool fixedQEDCouplings() const;
0473 
0474   /**
0475    * Return the value of \f$\alpha_S\f$ associated with the phase
0476    * space point provided by the last call to setKinematics(). This
0477    * versions returns SM().alphaS(scale()).
0478    */
0479   virtual double alphaS() const { return lastAlphaS(); }
0480 
0481   /**
0482    * Return the value of \f$\alpha_EM\f$ associated with the phase
0483    * space point provided by the last call to setKinematics(). This
0484    * versions returns SM().alphaEM(scale()).
0485    */
0486   virtual double alphaEM() const { return lastAlphaEM(); }
0487 
0488   /**
0489    * Return true, if this matrix element provides the PDF
0490    * weight for the first incoming parton itself.
0491    */
0492   virtual bool havePDFWeight1() const;
0493 
0494   /**
0495    * Return true, if this matrix element provides the PDF
0496    * weight for the second incoming parton itself.
0497    */
0498   virtual bool havePDFWeight2() const;
0499 
0500   /**
0501    * Set the PDF weight.
0502    */
0503   void getPDFWeight(Energy2 factorizationScale = ZERO) const;
0504 
0505   /**
0506    * Supply the PDF weight for the first incoming parton.
0507    */
0508   double pdf1(Energy2 factorizationScale = ZERO,
0509           double xEx = 1., double xFactor = 1.) const;
0510 
0511   /**
0512    * Supply the PDF weight for the second incoming parton.
0513    */
0514   double pdf2(Energy2 factorizationScale = ZERO,
0515           double xEx = 1., double xFactor = 1.) const;
0516 
0517   //@}
0518 
0519   /** @name Amplitude information and matrix element evaluation */
0520   //@{
0521 
0522   /**
0523    * Return the amplitude.
0524    */
0525   Ptr<MatchboxAmplitude>::tptr matchboxAmplitude() const { return theAmplitude; }
0526 
0527   /**
0528    * Set the amplitude.
0529    */
0530   void matchboxAmplitude(Ptr<MatchboxAmplitude>::ptr amp) { theAmplitude = amp; }
0531 
0532   /**
0533    * Return the matrix element for the kinematical configuation
0534    * previously provided by the last call to setKinematics(), suitably
0535    * scaled by sHat() to give a dimension-less number.
0536    */
0537   virtual double me2() const;
0538 
0539   /**
0540    * Return the matrix element for the kinematical configuation
0541    * previously provided by the last call to setKinematics(), suitably
0542    * scaled by sHat() to give a dimension-less number.
0543    */
0544   virtual double largeNME2(Ptr<ColourBasis>::tptr largeNBasis) const;
0545 
0546   /**
0547    * Return the symmetry factor for identical final state particles.
0548    */
0549   virtual double finalStateSymmetry() const;
0550 
0551   /**
0552    * Return the normalizing factor for the matrix element averaged
0553    * over quantum numbers and including running couplings.
0554    */
0555   double me2Norm(unsigned int addAlphaS = 0) const;
0556 
0557   /**
0558    * Return the matrix element squared differential in the variables
0559    * given by the last call to generateKinematics().
0560    */
0561   virtual CrossSection dSigHatDR() const;
0562 
0563   /**
0564    * Same prefactor for all dSigHat
0565    **/
0566   CrossSection prefactor()const;
0567 
0568   /**
0569    * Born part of the cross section
0570    **/
0571   CrossSection dSigHatDRB() const ;
0572       
0573   /**
0574    * Virtual corrections of the cross section
0575    **/
0576   CrossSection dSigHatDRV() const ;
0577       
0578   /**
0579    * Insertion operators of the cross section
0580    **/
0581   CrossSection dSigHatDRI() const ;
0582       
0583   /**
0584    * If diffAlpha is not 1 and the matrix element has insertion operators 
0585    * this routine adds the difference between the insertion operator calculated 
0586    * with an alpha-Parameter to the insertion operator without alpha-parameter.
0587    */ 
0588   CrossSection dSigHatDRAlphaDiff(double alpha) const ;
0589       
0590 
0591   //@}
0592 
0593   /** @name One-loop corrections */
0594   //@{
0595 
0596   /**
0597    * Return the one-loop/tree interference.
0598    */
0599   virtual double oneLoopInterference() const;
0600 
0601   /**
0602    * Return true, if this matrix element is capable of calculating
0603    * one-loop (QCD) corrections.
0604    */
0605   virtual bool haveOneLoop() const;
0606 
0607   /**
0608    * Return true, if this matrix element only provides
0609    * one-loop (QCD) corrections.
0610    */
0611   virtual bool onlyOneLoop() const;
0612 
0613   /**
0614    * Return true, if the amplitude is DRbar renormalized, otherwise
0615    * MSbar is assumed.
0616    */
0617   virtual bool isDRbar() const;
0618 
0619   /**
0620    * Return true, if one loop corrections have been calculated in
0621    * dimensional reduction. Otherwise conventional dimensional
0622    * regularization is assumed. Note that renormalization is always
0623    * assumed to be MSbar.
0624    */
0625   virtual bool isDR() const;
0626 
0627   /**
0628    * Return true, if one loop corrections are given in the conventions
0629    * of the integrated dipoles.
0630    */
0631   virtual bool isCS() const;
0632 
0633   /**
0634    * Return true, if one loop corrections are given in the conventions
0635    * of BDK.
0636    */
0637   virtual bool isBDK() const;
0638 
0639   /**
0640    * Return true, if one loop corrections are given in the conventions
0641    * of everything expanded.
0642    */
0643   virtual bool isExpanded() const;
0644 
0645   /**
0646    * Return the value of the dimensional regularization
0647    * parameter. Note that renormalization scale dependence is fully
0648    * restored in DipoleIOperator.
0649    */
0650   virtual Energy2 mu2() const;
0651 
0652   /**
0653    * If defined, return the coefficient of the pole in epsilon^2
0654    */
0655   virtual double oneLoopDoublePole() const;
0656 
0657   /**
0658    * If defined, return the coefficient of the pole in epsilon
0659    */
0660   virtual double oneLoopSinglePole() const;
0661 
0662   /**
0663    * Return true, if cancellationn of epsilon poles should be checked.
0664    */
0665   bool checkPoles() const;
0666 
0667   /**
0668    * Simple histogram for accuracy checks
0669    */
0670   struct AccuracyHistogram {
0671 
0672     /**
0673      * The lower bound
0674      */
0675     double lower;
0676 
0677     /**
0678      * The upper bound
0679      */
0680     double upper;
0681 
0682     /**
0683      * The bins, indexed by upper bound.
0684      */
0685     map<double,double> bins;
0686 
0687     /**
0688      * The number of points of same sign
0689      */
0690     unsigned long sameSign;
0691 
0692     /**
0693      * The number of points of opposite sign
0694      */
0695     unsigned long oppositeSign;
0696 
0697     /**
0698      * The number of points being nan or inf
0699      */
0700     unsigned long nans;
0701 
0702     /**
0703      * The overflow
0704      */
0705     unsigned long overflow;
0706 
0707     /**
0708      * The underflow
0709      */
0710     unsigned long underflow;
0711 
0712     /**
0713      * Constructor
0714      */
0715     AccuracyHistogram(double low = -40.,
0716               double up = 0.,
0717               unsigned int nbins = 80);
0718 
0719     /**
0720      * Book two values to be checked for numerical compatibility
0721      */
0722     void book(double a, double b);
0723 
0724     /**
0725      * Write to file.
0726      */
0727     void dump(const std::string& folder, const std::string& prefix,
0728           const cPDVector& proc) const;
0729 
0730     /**
0731      * Write to persistent ostream
0732      */
0733     void persistentOutput(PersistentOStream&) const;
0734 
0735     /**
0736      * Read from persistent istream
0737      */
0738     void persistentInput(PersistentIStream&);
0739 
0740   };
0741 
0742   /**
0743    * Perform the check of epsilon pole cancellation.
0744    */
0745   void logPoles() const;
0746 
0747   /**
0748    * Return the virtual corrections
0749    */
0750   const vector<Ptr<MatchboxInsertionOperator>::ptr>& virtuals() const {
0751     return theVirtuals;
0752   }
0753 
0754   /**
0755    * Return the virtual corrections
0756    */
0757   vector<Ptr<MatchboxInsertionOperator>::ptr>& virtuals() {
0758     return theVirtuals;
0759   }
0760 
0761   /**
0762    * Instruct this matrix element to include one-loop corrections
0763    */
0764   void doOneLoop() { theOneLoop = true; }
0765       
0766   /**
0767    * Instruct this matrix element not to include one-loop corrections
0768    */
0769       
0770   void noOneLoop() { theOneLoop = false; }
0771 
0772   /**
0773    * Return true, if this matrix element includes one-loop corrections
0774    */
0775   bool oneLoop() const { return theOneLoop; }
0776 
0777   /**
0778    * Instruct this matrix element to include one-loop corrections but
0779    * no Born contributions
0780    */
0781   void doOneLoopNoBorn() { theOneLoop = true; theOneLoopNoBorn = true; }
0782       
0783   void noOneLoopNoBorn() { theOneLoop = false; theOneLoopNoBorn = false; }
0784 
0785   /**
0786    * Return true, if this matrix element includes one-loop corrections
0787    * but no Born contributions
0788    */
0789   bool oneLoopNoBorn() const { return theOneLoopNoBorn || onlyOneLoop(); }
0790 
0791   /**
0792    * Instruct this matrix element to include one-loop corrections but
0793    * no actual loop contributions
0794    */
0795   void doOneLoopNoLoops() { theOneLoop = true; theOneLoopNoLoops = true; }
0796 
0797   /**
0798    * Return true, if this matrix element includes one-loop corrections
0799    * but no actual loop contributions
0800    */
0801   bool oneLoopNoLoops() const { return theOneLoopNoLoops; }
0802 
0803   //@}
0804 
0805   /** @name Dipole subtraction */
0806   //@{
0807 
0808   /**
0809    * If this matrix element is considered a real
0810    * emission matrix element, return all subtraction
0811    * dipoles needed given a set of subtraction terms
0812    * and underlying Born matrix elements to choose
0813    * from.
0814    */
0815   vector<Ptr<SubtractionDipole>::ptr> 
0816   getDipoles(const vector<Ptr<SubtractionDipole>::ptr>&,
0817          const vector<Ptr<MatchboxMEBase>::ptr>&,bool slim=false) const;
0818 
0819   
0820   /**
0821    * If this matrix element is considered a real emission matrix
0822    * element, but actually neglecting a subclass of the contributing
0823    * diagrams, return true if the given emitter-emission-spectator
0824    * configuration should not be considered when setting up
0825    * subtraction dipoles.
0826    */
0827   virtual bool noDipole(int,int,int) const { return false; }
0828 
0829   /**
0830    * If this matrix element is considered an underlying Born matrix
0831    * element in the context of a subtracted real emission, but
0832    * actually neglecting a subclass of the contributing diagrams,
0833    * return true if the given emitter-spectator configuration
0834    * should not be considered when setting up subtraction dipoles.
0835    */
0836   virtual bool noDipole(int,int) const { return false; }
0837 
0838   /**
0839    * Return the colour correlated matrix element squared with
0840    * respect to the given two partons as appearing in mePartonData(),
0841    * suitably scaled by sHat() to give a dimension-less number.
0842    */
0843   virtual double colourCorrelatedME2(pair<int,int>) const;
0844 
0845   /**
0846    * Return the colour correlated matrix element squared in the
0847    * large-N approximation with respect to the given two partons as
0848    * appearing in mePartonData(), suitably scaled by sHat() to give a
0849    * dimension-less number.
0850    */
0851   virtual double largeNColourCorrelatedME2(pair<int,int> ij,
0852                        Ptr<ColourBasis>::tptr largeNBasis) const;
0853 
0854   /**
0855    * Return the colour and spin correlated matrix element squared for
0856    * the gluon indexed by the first argument using the given
0857    * correlation tensor.
0858    */
0859   virtual double spinColourCorrelatedME2(pair<int,int> emitterSpectator,
0860                      const SpinCorrelationTensor& c) const;
0861 
0862   /**
0863    * Return the spin correlated matrix element squared for
0864    * the vector boson indexed by the first argument using the given
0865    * correlation tensor.
0866    */
0867   virtual double spinCorrelatedME2(pair<int,int> emitterSpectator,
0868                    const SpinCorrelationTensor& c) const;
0869 
0870   //@}
0871 
0872   /** @name Caching and diagnostic information */
0873   //@{
0874 
0875   /**
0876    * Inform this matrix element that a new phase space
0877    * point is about to be generated, so all caches should
0878    * be flushed.
0879    */
0880   virtual void flushCaches();
0881 
0882   /**
0883    * Return true, if verbose
0884    */
0885   bool verbose() const;
0886 
0887   /**
0888    * Return true, if verbose
0889    */
0890   bool initVerbose() const;
0891 
0892   /**
0893    * Dump the setup to an ostream
0894    */
0895   void print(ostream&) const;
0896 
0897   /**
0898    * Print debug information on the last event
0899    */
0900   virtual void printLastEvent(ostream&) const;
0901 
0902   /**
0903    * Write out diagnostic information for
0904    * generateKinematics
0905    */
0906   void logGenerateKinematics(const double * r) const;
0907 
0908   /**
0909    * Write out diagnostic information for
0910    * setting scales
0911    */
0912   void logSetScale() const;
0913 
0914   /**
0915    * Write out diagnostic information for
0916    * pdf evaluation
0917    */
0918   void logPDFWeight() const;
0919 
0920   /**
0921    * Write out diagnostic information for
0922    * me2 evaluation
0923    */
0924   void logME2() const;
0925 
0926   /**
0927    * Write out diagnostic information
0928    * for dsigdr evaluation
0929    */
0930   void logDSigHatDR() const;
0931 
0932   //@}
0933 
0934   /** @name Reweight objects */
0935   //@{
0936 
0937   /**
0938    * Insert a reweight object
0939    */
0940   void addReweight(Ptr<MatchboxReweightBase>::ptr rw) { theReweights.push_back(rw); }
0941 
0942   /**
0943    * Return the reweights
0944    */
0945   const vector<Ptr<MatchboxReweightBase>::ptr>& reweights() const { return theReweights; }
0946 
0947   /**
0948    * Access the reweights
0949    */
0950   vector<Ptr<MatchboxReweightBase>::ptr>& reweights() { return theReweights; }
0951 
0952   /**
0953    * Return the theMerger.
0954    */
0955   const MergerBasePtr merger() const;
0956     
0957   /**
0958    * Return the theMerger.
0959    */
0960   MergerBasePtr merger() ;
0961       
0962   /**
0963    * Set the theMerger.
0964    */
0965   void merger(MergerBasePtr v);
0966   
0967   //@}
0968 
0969   /** @name Methods used to setup MatchboxMEBase objects */
0970   //@{
0971 
0972   /**
0973    * Return true if this object needs to be initialized before all
0974    * other objects (except those for which this function also returns
0975    * true).  This default version always returns false, but subclasses
0976    * may override it to return true.
0977    */
0978   virtual bool preInitialize() const { return true; }
0979 
0980   /**
0981    * Clone this matrix element.
0982    */
0983   Ptr<MatchboxMEBase>::ptr cloneMe() const {
0984     return dynamic_ptr_cast<Ptr<MatchboxMEBase>::ptr>(clone());
0985   }
0986 
0987   /**
0988    * Clone the dependencies, using a given prefix.
0989    */
0990   void cloneDependencies(const std::string& prefix = "",bool slim = false );
0991 
0992   /**
0993    * Prepare an xcomb
0994    */
0995   void prepareXComb(MatchboxXCombData&) const;
0996 
0997   /**
0998    * For the given event generation setup return a xcomb object
0999    * appropriate to this matrix element.
1000    */
1001   virtual StdXCombPtr makeXComb(Energy newMaxEnergy, const cPDPair & inc,
1002                 tEHPtr newEventHandler,tSubHdlPtr newSubProcessHandler,
1003                 tPExtrPtr newExtractor, tCascHdlPtr newCKKW,
1004                 const PBPair & newPartonBins, tCutsPtr newCuts,
1005                 const DiagramVector & newDiagrams, bool mir,
1006                 const PartonPairVec& allPBins,
1007                 tStdXCombPtr newHead = tStdXCombPtr(),
1008                 tMEPtr newME = tMEPtr());
1009 
1010   /**
1011    * For the given event generation setup return a dependent xcomb object
1012    * appropriate to this matrix element.
1013    */
1014   virtual StdXCombPtr makeXComb(tStdXCombPtr newHead,
1015                 const PBPair & newPartonBins,
1016                 const DiagramVector & newDiagrams,
1017                 tMEPtr newME = tMEPtr());
1018 
1019   //@}
1020 
1021 public:
1022 
1023   /** @name Functions used by the persistent I/O system. */
1024   //@{
1025   /**
1026    * Function used to write out object persistently.
1027    * @param os the persistent output stream written to.
1028    */
1029   void persistentOutput(PersistentOStream & os) const;
1030 
1031   /**
1032    * Function used to read in object persistently.
1033    * @param is the persistent input stream read from.
1034    * @param version the version number of the object when written.
1035    */
1036   void persistentInput(PersistentIStream & is, int version);
1037   //@}
1038 
1039   /**
1040    * The standard Init function used to initialize the interfaces.
1041    * Called exactly once for each class by the class description system
1042    * before the main function starts or
1043    * when this class is dynamically loaded.
1044    */
1045   static void Init();
1046 
1047 protected:
1048 
1049   /** @name Clone Methods. */
1050   //@{
1051   /**
1052    * Make a simple clone of this object.
1053    * @return a pointer to the new object.
1054    */
1055   virtual IBPtr clone() const;
1056 
1057   /** Make a clone of this object, possibly modifying the cloned object
1058    * to make it sane.
1059    * @return a pointer to the new object.
1060    */
1061   virtual IBPtr fullclone() const;
1062   //@}
1063 
1064 protected:
1065 
1066   /** @name Standard Interfaced functions. */
1067   //@{
1068   /**
1069    * Initialize this object after the setup phase before saving an
1070    * EventGenerator to disk.
1071    * @throws InitException if object could not be initialized properly.
1072    */
1073   virtual void doinit();
1074 
1075   /**
1076    * Initialize this object. Called in the run phase just before
1077    * a run begins.
1078    */
1079   virtual void doinitrun();
1080 
1081   /**
1082    * Finalize this object. Called in the run phase just after a
1083    * run has ended. Used eg. to write out statistics.
1084    */
1085   virtual void dofinish();
1086   //@}
1087 
1088 private:
1089 
1090   /**
1091    * The phase space generator to be used.
1092    */
1093   Ptr<MatchboxPhasespace>::ptr thePhasespace;
1094 
1095   /**
1096    * The amplitude to be used
1097    */
1098   Ptr<MatchboxAmplitude>::ptr theAmplitude;
1099 
1100   /**
1101    * The scale choice object
1102    */
1103   Ptr<MatchboxScaleChoice>::ptr theScaleChoice;
1104 
1105   /**
1106    * The virtual corrections.
1107    */
1108   vector<Ptr<MatchboxInsertionOperator>::ptr> theVirtuals;
1109 
1110   /**
1111    * A vector of reweight objects the sum of which
1112    * should be applied to reweight this matrix element
1113    */
1114   vector<Ptr<MatchboxReweightBase>::ptr> theReweights;
1115 
1116 private:
1117 
1118   /**
1119    * The subprocess to be considered.
1120    */
1121   Process theSubprocess;
1122 
1123   /**
1124    * True, if this matrix element includes one-loop corrections
1125    */
1126   bool theOneLoop;
1127 
1128   /**
1129    * True, if this matrix element includes one-loop corrections
1130    * but no Born contributions
1131    */
1132   bool theOneLoopNoBorn;
1133 
1134   /**
1135    * True, if this matrix element includes one-loop corrections
1136    * but no actual loop contributions (e.g. finite collinear terms)
1137    */
1138   bool theOneLoopNoLoops;
1139 
1140   /**
1141    * The process index, if this is an OLP handled matrix element
1142    */
1143   vector<int> theOLPProcess;
1144 
1145   /**
1146    * Histograms of epsilon^2 pole cancellation
1147    */
1148   mutable map<cPDVector,AccuracyHistogram> epsilonSquarePoleHistograms;
1149 
1150   /**
1151    * Histograms of epsilon pole cancellation
1152    */
1153   mutable map<cPDVector,AccuracyHistogram> epsilonPoleHistograms;
1154 
1155   /**
1156    * True, if this is a real emission matrix element which does
1157    * not require colour correlators.
1158    */
1159   bool theNoCorrelations;
1160 
1161   /**
1162    * Flag which pdfs should be included.
1163    */
1164   mutable pair<bool,bool> theHavePDFs;
1165 
1166   /**
1167    * True, if already checked for which PDFs to include.
1168    */
1169   mutable bool checkedPDFs;
1170   
1171   /**
1172    * The merging helper to be used. 
1173    * Only the head ME has a pointer to this helper.
1174    */
1175 
1176   MergerBasePtr theMerger;
1177 
1178 
1179 private:
1180 
1181   /**
1182    * The assignment operator is private and must never be called.
1183    * In fact, it should not even be implemented.
1184    */
1185   MatchboxMEBase & operator=(const MatchboxMEBase &) = delete;
1186 
1187 };
1188 
1189 inline PersistentOStream& operator<<(PersistentOStream& os,
1190                      const MatchboxMEBase::AccuracyHistogram& h) {
1191   h.persistentOutput(os);
1192   return os;
1193 }
1194 
1195 inline PersistentIStream& operator>>(PersistentIStream& is,
1196                      MatchboxMEBase::AccuracyHistogram& h) {
1197   h.persistentInput(is);
1198   return is;
1199 }
1200 
1201 }
1202 
1203 #endif /* HERWIG_MatchboxMEBase_H */