Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // -*- C++ -*-
0002 //
0003 // SubtractionDipole.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_SubtractionDipole_H
0010 #define HERWIG_SubtractionDipole_H
0011 //
0012 // This is the declaration of the SubtractionDipole class.
0013 //
0014 
0015 #include "Herwig/MatrixElement/Matchbox/Dipoles/SubtractionDipole.fh"
0016 #include "Herwig/MatrixElement/Matchbox/Phasespace/TildeKinematics.fh"
0017 #include "Herwig/MatrixElement/Matchbox/Phasespace/InvertedTildeKinematics.fh"
0018 
0019 #include "ThePEG/MatrixElement/MEBase.h"
0020 #include "ThePEG/Handlers/StandardXComb.h"
0021 #include "Herwig/MatrixElement/Matchbox/Base/MatchboxMEBase.h"
0022 #include "Herwig/MatrixElement/Matchbox/Matching/ShowerApproximation.h"
0023 #include "Herwig/MatrixElement/Matchbox/MatchboxFactory.fh"
0024 
0025 namespace Herwig {
0026 
0027 using namespace ThePEG;
0028 
0029 /**
0030  * \ingroup Matchbox
0031  * \author Simon Platzer
0032  *
0033  * \brief SubtractionDipole represents a dipole subtraction
0034  * term in the formalism of Catani and Seymour.
0035  *
0036  */
0037 class SubtractionDipole: 
0038     public MEBase,  public LastMatchboxXCombInfo {
0039 
0040 public:
0041 
0042   /** @name Standard constructors and destructors. */
0043   //@{
0044   /**
0045    * The default constructor.
0046    */
0047   SubtractionDipole();
0048 
0049   /**
0050    * The destructor.
0051    */
0052   virtual ~SubtractionDipole();
0053   //@}
0054 
0055 public:
0056 
0057   /**
0058    * Return the factory which produced this matrix element
0059    */
0060   Ptr<MatchboxFactory>::tptr factory() const;
0061 
0062   /** @name Subprocess and diagram information. */
0063   //@{
0064 
0065   /**
0066    * A helpre struct to communicate diagram merging and remapping
0067    * information
0068    */
0069   struct MergeInfo {
0070 
0071     /**
0072      * The merged emitter
0073      */
0074     int emitter;
0075 
0076     /**
0077      * The Born diagram
0078      */
0079     Ptr<Tree2toNDiagram>::ptr diagram;
0080 
0081     /**
0082      * The merging map
0083      */
0084     map<int,int> mergeLegs;
0085 
0086   };
0087 
0088   /**
0089    * Return true, if this dipole can possibly handle the indicated
0090    * emitter.
0091    */
0092   virtual bool canHandleEmitter(const cPDVector& partons, int emitter) const = 0;
0093 
0094   /**
0095    * Return true, if this dipole can possibly handle the indicated
0096    * splitting.
0097    */
0098   virtual bool canHandleSplitting(const cPDVector& partons, int emitter, int emission) const = 0;
0099 
0100   /**
0101    * Return true, if this dipole can possibly handle the indicated
0102    * spectator.
0103    */
0104   virtual bool canHandleSpectator(const cPDVector& partons, int spectator) const = 0;
0105 
0106   /**
0107    * Return true, if this dipole applies to the selected
0108    * configuration.
0109    */
0110   virtual bool canHandle(const cPDVector& partons,
0111              int emitter, int emission, int spectator) const = 0;
0112 
0113   /**
0114    * Return true, if this dipole is symmetric with respect to emitter
0115    * and emission.
0116    */
0117   virtual bool isSymmetric() const { return false; }
0118 
0119   /**
0120    * If this is a dependent matrix element in a ME group, return true,
0121    * if it applies to the process set in lastXComb()
0122    */
0123   virtual bool apply() const { return theApply; }
0124 
0125   /**
0126    * Clear the bookkeeping
0127    */
0128   void clearBookkeeping();
0129 
0130   /**
0131    * Setup bookkeeping maps.
0132    */
0133   void setupBookkeeping(const map<Ptr<DiagramBase>::ptr,MergeInfo>& mergeInfo,bool slim);
0134 
0135   /**
0136    * Get bookkeeping information for the given
0137    * real emission diagram
0138    */
0139   void subtractionBookkeeping();
0140 
0141   /**
0142    * Determine bookkeeping information for
0143    * the underlying Born process supplied through
0144    * the lastHeadXComb() object.
0145    */
0146   void splittingBookkeeping();
0147 
0148   /**
0149    * For the given event generation setup return a xcomb object
0150    * appropriate to this matrix element.
0151    */
0152   virtual StdXCombPtr makeXComb(Energy newMaxEnergy, const cPDPair & inc,
0153                 tEHPtr newEventHandler,tSubHdlPtr newSubProcessHandler,
0154                 tPExtrPtr newExtractor, tCascHdlPtr newCKKW,
0155                 const PBPair & newPartonBins, tCutsPtr newCuts,
0156                 const DiagramVector & newDiagrams, bool mir,
0157                 const PartonPairVec& allPBins,
0158                 tStdXCombPtr newHead = tStdXCombPtr(),
0159                 tMEPtr newME = tMEPtr());
0160 
0161   /**
0162    * For the given event generation setup return a dependent xcomb object
0163    * appropriate to this matrix element.
0164    */
0165   virtual StdXCombPtr makeXComb(tStdXCombPtr newHead,
0166                 const PBPair & newPartonBins,
0167                 const DiagramVector & newDiagrams,
0168                 tMEPtr newME = tMEPtr());
0169 
0170   /**
0171    * Create a dependent xcomb object for the underlying
0172    * Born process, given a XComb driving the real emission
0173    */
0174   StdXCombPtr makeBornXComb(tStdXCombPtr realXC);
0175 
0176   /**
0177    * Create dependent xcomb objects for the real emission process,
0178    * given a XComb driving the underlying Born
0179    */
0180   vector<StdXCombPtr> makeRealXCombs(tStdXCombPtr bornXC);
0181 
0182   /**
0183    * Return true, if bookkeeping did not find a non-trivial setup.
0184    */
0185   bool empty() const { return theSplittingMap.empty()&&theMergingMap.empty(); }
0186 
0187   /**
0188    * Return the emitter as referred to by the real emission
0189    * matrix element.
0190    */
0191   int realEmitter() const { return theRealEmitter; }
0192 
0193   /**
0194    * Set the emitter as referred to by the real emission
0195    * matrix element.
0196    */
0197   void realEmitter(int id) { theRealEmitter = id; }
0198 
0199   /**
0200    * Return the emission as referred to by the real emission
0201    * matrix element.
0202    */
0203   int realEmission() const { return theRealEmission; }
0204 
0205   /**
0206    * Set the emission as referred to by the real emission
0207    * matrix element.
0208    */
0209   void realEmission(int id) { theRealEmission = id; }
0210 
0211   /**
0212    * Return the spectator as referred to by the real emission
0213    * matrix element.
0214    */
0215   int realSpectator() const { return theRealSpectator; }
0216 
0217   /**
0218    * Set the spectator as referred to by the real emission
0219    * matrix element.
0220    */
0221   void realSpectator(int id) { theRealSpectator = id; }
0222 
0223   /**
0224    * Return the emitter as referred to by the underlying
0225    * Born process.
0226    */
0227   int bornEmitter() const { return theBornEmitter; }
0228 
0229   /**
0230    * Set the emitter as referred to by the underlying
0231    * Born process.
0232    */
0233   void bornEmitter(int id) { theBornEmitter = id; }
0234 
0235   /**
0236    * Return the spectator as referred to by the underlying
0237    * Born process.
0238    */
0239   int bornSpectator() const { return theBornSpectator; }
0240 
0241   /**
0242    * Set the spectator as referred to by the underlying
0243    * Born process.
0244    */
0245   void bornSpectator(int id) { theBornSpectator = id; }
0246 
0247   /**
0248    * Define the real emission key type
0249    */
0250   typedef pair<pair<cPDVector,int>,pair<int,int> > RealEmissionKey;
0251 
0252   /**
0253    * Create a real emission key
0254    */
0255   static RealEmissionKey realEmissionKey(const cPDVector& proc, 
0256                      int em, int emm, int sp) {
0257     return make_pair(make_pair(proc,emm),make_pair(em,sp));
0258   }
0259 
0260   /**
0261    * Return the diagram of a real emission key
0262    */
0263   static const cPDVector& process(const RealEmissionKey& key) {
0264     return key.first.first;
0265   }
0266 
0267   /**
0268    * Return the emission id of a real emission key
0269    */
0270   static int emission(const RealEmissionKey& key) {
0271     return key.first.second;
0272   }
0273 
0274   /**
0275    * Return the emitter id of a real emission key
0276    */
0277   static int emitter(const RealEmissionKey& key) {
0278     return key.second.first;
0279   }
0280 
0281   /**
0282    * Return the spectator id of a real emission key
0283    */
0284   static int spectator(const RealEmissionKey& key) {
0285     return key.second.second;
0286   }
0287 
0288   /**
0289    * Define the underlying Born key type
0290    */
0291   typedef pair<cPDVector,pair<int,int> > UnderlyingBornKey;
0292 
0293   /**
0294    * Create a underlying Born key
0295    */
0296   static UnderlyingBornKey underlyingBornKey(const cPDVector& proc, 
0297                          int em, int sp) {
0298     return make_pair(proc,make_pair(em,sp));
0299   }
0300 
0301   /**
0302    * Return the diagram of a underlying Born key
0303    */
0304   static const cPDVector& process(const UnderlyingBornKey& key) {
0305     return key.first;
0306   }
0307 
0308   /**
0309    * Return the emitter id of a underlying Born key
0310    */
0311   static int emitter(const UnderlyingBornKey& key) {
0312     return key.second.first;
0313   }
0314 
0315   /**
0316    * Return the spectator id of a underlying Born key
0317    */
0318   static int spectator(const UnderlyingBornKey& key) {
0319     return key.second.second;
0320   }
0321 
0322   /**
0323    * Define real emission key and index dictionary
0324    * for partons not involved in the given dipole.
0325    */
0326   typedef pair<RealEmissionKey,map<int,int> > RealEmissionInfo;
0327 
0328   /**
0329    * Define underlying Born key and index dictionary
0330    * for partons not involved in the given dipole.
0331    */
0332   typedef pair<UnderlyingBornKey,map<int,int> > UnderlyingBornInfo;
0333 
0334   /**
0335    * Return the merging map
0336    */
0337   const map<RealEmissionKey,UnderlyingBornInfo>& mergingMap() const { return theMergingMap; }
0338 
0339   /**
0340    * Return the splitting map
0341    */
0342   const multimap<UnderlyingBornKey,RealEmissionInfo>& splittingMap() const { return theSplittingMap; }
0343 
0344   /**
0345    * Return the underlying Born diagrams to be considered
0346    * for the given real emission process.
0347    */
0348   const DiagramVector& underlyingBornDiagrams(const cPDVector& real) const;
0349 
0350   /**
0351    * Find the underlying Born diagram for the given real emission diagram
0352    */
0353   tcDiagPtr underlyingBornDiagram(tcDiagPtr realDiag) const;
0354 
0355   /**
0356    * Return the real emission diagrams to be considered
0357    * for the given Born process.
0358    */
0359   const DiagramVector& realEmissionDiagrams(const cPDVector& born) const;
0360 
0361   /**
0362    * Find the real emission diagram for the given underlying Born diagram
0363    */
0364   tcDiagPtr realEmissionDiagram(tcDiagPtr bornDiag) const;
0365 
0366   /**
0367    * Add all possible diagrams with the add() function.
0368    */
0369   virtual void getDiagrams() const;
0370 
0371   /**
0372    * Return true, if this matrix element does not want to
0373    * make use of mirroring processes; in this case all
0374    * possible partonic subprocesses with a fixed assignment
0375    * of incoming particles need to be provided through the diagrams
0376    * added with the add(...) method.
0377    */
0378   virtual bool noMirror () const { return true; }
0379 
0380   /**
0381    * With the information previously supplied with the
0382    * setKinematics(...) method, a derived class may optionally
0383    * override this method to weight the given diagrams with their
0384    * (although certainly not physical) relative probabilities.
0385    */
0386   virtual Selector<DiagramIndex> diagrams(const DiagramVector & dv) const;
0387 
0388   /**
0389    * Return a Selector with possible colour geometries for the selected
0390    * diagram weighted by their relative probabilities.
0391    */
0392   virtual Selector<const ColourLines *>
0393   colourGeometries(tcDiagPtr diag) const;
0394 
0395   /**
0396    * Select a ColpurLines geometry. The default version returns a
0397    * colour geometry selected among the ones returned from
0398    * colourGeometries(tcDiagPtr).
0399    */
0400   virtual const ColourLines &
0401   selectColourGeometry(tcDiagPtr diag) const;
0402 
0403   /**
0404    * Return the order in \f$\alpha_S\f$ in which this matrix element
0405    * is given.
0406    */
0407   virtual unsigned int orderInAlphaS() const { return realEmissionME()->orderInAlphaS(); }
0408 
0409   /**
0410    * Return the order in \f$\alpha_{EM}\f$ in which this matrix
0411    * element is given. Returns 0.
0412    */
0413   virtual unsigned int orderInAlphaEW() const { return underlyingBornME()->orderInAlphaEW(); }
0414 
0415   //@}
0416 
0417   /** @name Phasespace generation */
0418   //@{
0419 
0420   /**
0421    * Set the XComb object to be used in the next call to
0422    * generateKinematics() and dSigHatDR().
0423    */
0424   virtual void setXComb(tStdXCombPtr xc);
0425 
0426   /**
0427    * Set the typed and momenta of the incoming and outgoing partons to
0428    * be used in subsequent calls to me() and colourGeometries()
0429    * according to the associated XComb object. If the function is
0430    * overridden in a sub class the new function must call the base
0431    * class one first.
0432    */
0433   virtual void setKinematics();
0434 
0435   /**
0436    * Generate internal degrees of freedom given nDim() uniform random
0437    * numbers in the interval ]0,1[. To help the phase space generator,
0438    * the 'dSigHatDR' should be a smooth function of these numbers,
0439    * although this is not strictly necessary. The return value should
0440    * be true of the generation succeeded. If so the generated momenta
0441    * should be stored in the meMomenta() vector.
0442    */
0443   virtual bool generateKinematics(const double * r);
0444 
0445   /**
0446    * The number of internal degreed of freedom used in the matrix
0447    * element. This default version returns 0;
0448    */
0449   virtual int nDim() const;
0450 
0451   /**
0452    * Return true, if this matrix element expects
0453    * the incoming partons in their center-of-mass system
0454    */
0455   virtual bool wantCMS () const { return realEmissionME()->wantCMS(); }
0456 
0457   /**
0458    * Clear the information previously provided by a call to
0459    * setKinematics(...).
0460    */
0461   virtual void clearKinematics();
0462 
0463   /**
0464    * If this is a dependent matrix element in a ME group, return true,
0465    * if cuts should be ignored.
0466    */
0467   virtual bool ignoreCuts() const { return theIgnoreCuts; }
0468 
0469   /**
0470    * Indicate that cuts should be ignored
0471    */
0472   void doIgnoreCuts(bool is = true) { theIgnoreCuts = is; }
0473 
0474   //@}
0475 
0476   /** @name Tilde kinematics */
0477   //@{
0478 
0479   /**
0480    * Return the TildeKinematics object used
0481    */
0482   Ptr<TildeKinematics>::tcptr tildeKinematics() const { return theTildeKinematics; }
0483 
0484   /**
0485    * Set the TildeKinematics object used
0486    */
0487   void tildeKinematics(Ptr<TildeKinematics>::tptr);
0488 
0489   /**
0490    * Generate the tilde kinematics from real emission
0491    * kinematics accessible through the XComb's
0492    * head object and store it in meMomenta(). This default
0493    * implemenation uses the tildeKinematics() object.
0494    */
0495   virtual bool generateTildeKinematics();
0496 
0497   /**
0498    * Return the InvertedTildeKinematics object used
0499    */
0500   Ptr<InvertedTildeKinematics>::tcptr invertedTildeKinematics() const { return theInvertedTildeKinematics; }
0501 
0502   /**
0503    * Set the InvertedTildeKinematics object used
0504    */
0505   void invertedTildeKinematics(Ptr<InvertedTildeKinematics>::tptr);
0506 
0507   /**
0508    * Return the number of additional random numbers
0509    * needed to generate real emission kinematics off
0510    * the tilde kinematics previously supplied through
0511    * the XComb object. This default implementation
0512    * returns invertedTildeKinematics()->nDimRadiation()
0513    */
0514   virtual int nDimRadiation() const;
0515 
0516   /**
0517    * Generate the real emission kinematics
0518    * off the Born kinematics accessible through the XComb's
0519    * head object and store it in meMomenta(); store
0520    * the single particle phasespace in units of lastHeadXComb()->lastSHat()
0521    * in jacobian(). This default
0522    * implemenation uses the invertedTildeKinematics() object
0523    */
0524   virtual bool generateRadiationKinematics(const double *);
0525 
0526   /**
0527    * Set a pt cut when splitting
0528    */
0529   void ptCut(Energy cut);
0530 
0531   /**
0532    * Return the relevant dipole scale
0533    */
0534   Energy lastDipoleScale() const {
0535     return splitting() ? theLastSplittingScale : theLastSubtractionScale;
0536   }
0537 
0538   /**
0539    * Return the relevant pt
0540    */
0541   Energy lastPt() const {
0542     return splitting() ? theLastSplittingPt : theLastSubtractionPt;
0543   }
0544 
0545   /**
0546    * Return the relevant momentum fractions
0547    */
0548   double lastZ() const {
0549     return splitting() ? theLastSplittingZ : theLastSubtractionZ;
0550   }
0551 
0552   /**
0553    * Return true, if this dipole acts in splitting mode.
0554    */
0555   bool splitting() const { return theSplitting; }
0556 
0557   /**
0558    * Switch on splitting mode for this dipole.
0559    */  
0560   void doSplitting() { theSplitting = true; }
0561 
0562   /**
0563    * Switch off splitting mode for this dipole.
0564    */  
0565   void doSubtraction() { theSplitting = false; }
0566 
0567   /**
0568    * Return the subtraction parameters.
0569    */
0570   const vector<double>& subtractionParameters() const { return theSubtractionParameters; }
0571 
0572   /**
0573    * Access the subtraction parameters.
0574    */
0575   vector<double>& subtractionParameters() { return theSubtractionParameters; }
0576 
0577   /**
0578    * Return the shower hard scale encountered
0579    */
0580   Energy showerHardScale() const { return theShowerHardScale; }
0581 
0582   /**
0583    * Set the shower hard scale encountered
0584    */
0585   void showerHardScale(Energy s) { theShowerHardScale = s; }
0586 
0587   /**
0588    * Return the shower evolution scale encountered
0589    */
0590   Energy showerScale() const { return theShowerScale; }
0591 
0592   /**
0593    * Set the shower evolution scale encountered
0594    */
0595   void showerScale(Energy s) { theShowerScale = s; }
0596 
0597   /**
0598    * Return the shower splitting variables encountered
0599    */
0600   const vector<double>& showerParameters() const { return theShowerParameters; }
0601 
0602   /**
0603    * Access the shower splitting variables encountered
0604    */
0605   vector<double>& showerParameters() { return theShowerParameters; }
0606 
0607   /**
0608    * Return true, if this configuration is in the shower phase space
0609    */
0610   bool isInShowerPhasespace() const { return theIsInShowerPhasespace; }
0611 
0612   /**
0613    * Indicate whether this configuration is in the shower phase space
0614    */
0615   void isInShowerPhasespace(bool yes) { theIsInShowerPhasespace = yes; }
0616 
0617   /**
0618    * Return true, if this configuration is above the shower infrared cutoff
0619    */
0620   bool isAboveCutoff() const { return theIsAboveCutoff; }
0621 
0622   /**
0623    * Indicate whether this configuration is above the shower infrared cutoff
0624    */
0625   void isAboveCutoff(bool yes) { theIsAboveCutoff = yes; }
0626 
0627   //@}
0628 
0629   /** @name Scale choices, couplings and PDFs */
0630   //@{
0631 
0632   /**
0633    * Return true, if scales should be calculated from real emission kinematics
0634    */
0635   bool realEmissionScales() const { return theRealEmissionScales; }
0636 
0637   /**
0638    * Switch on or off that scales should be calculated from real emission kinematics
0639    */
0640   void doRealEmissionScales(bool on = true) { theRealEmissionScales = on; }
0641 
0642   /**
0643    * Return the scale associated with the phase space point provided
0644    * by the last call to setKinematics().
0645    */
0646   virtual Energy2 scale() const { 
0647     return realEmissionScales() ? 
0648       realEmissionME()->scale() :
0649       underlyingBornME()->scale();
0650   }
0651 
0652   /**
0653    * Return the value of \f$\alpha_S\f$ associated with the phase
0654    * space point provided by the last call to setKinematics(). This
0655    * versions returns SM().alphaS(scale()).
0656    */
0657   virtual double alphaS() const { 
0658     return realEmissionScales() ? 
0659       realEmissionME()->alphaS() :
0660       underlyingBornME()->alphaS();
0661   }
0662 
0663   /**
0664    * Return the value of \f$\alpha_EM\f$ associated with the phase
0665    * space point provided by the last call to setKinematics(). This
0666    * versions returns SM().alphaEM(scale()).
0667    */
0668   virtual double alphaEM() const { 
0669     return realEmissionScales() ? 
0670       realEmissionME()->alphaEM() :
0671       underlyingBornME()->alphaEM();
0672   }
0673 
0674   /**
0675    * Return true, if this matrix element provides the PDF
0676    * weight for the first incoming parton itself.
0677    */
0678   virtual bool havePDFWeight1() const { return realEmissionME()->havePDFWeight1(); }
0679 
0680   /**
0681    * Return true, if this matrix element provides the PDF
0682    * weight for the second incoming parton itself.
0683    */
0684   virtual bool havePDFWeight2() const { return realEmissionME()->havePDFWeight2(); }
0685 
0686   /**
0687    *  How to sample the z-distribution.
0688    *  FlatZ = 1
0689    *  OneOverZ = 2
0690    *  OneOverOneMinusZ = 3
0691    *  OneOverZOneMinusZ = 4
0692    */
0693 
0694   virtual int samplingZ() const {return 4;}
0695   //@}
0696 
0697   /** @name Matrix elements and evaluation */
0698   //@{
0699 
0700   /**
0701    * Return the real emission matrix element
0702    */
0703   Ptr<MatchboxMEBase>::tcptr realEmissionME() const { 
0704     return theRealEmissionME;
0705   }
0706 
0707   /**
0708    * Return the real emission matrix element
0709    */
0710   Ptr<MatchboxMEBase>::tptr realEmissionME() { 
0711     return theRealEmissionME;
0712   }
0713 
0714   /**
0715    * Set the real emission matrix element
0716    */
0717   void realEmissionME(Ptr<MatchboxMEBase>::tptr me) { theRealEmissionME = me; }
0718 
0719   /**
0720    * Return the underlying Born matrix element
0721    */
0722   Ptr<MatchboxMEBase>::tcptr underlyingBornME() const { 
0723     return theUnderlyingBornME;
0724   }
0725 
0726   /**
0727    * Return the underlying Born matrix element
0728    */
0729   Ptr<MatchboxMEBase>::tptr underlyingBornME() { 
0730     return theUnderlyingBornME;
0731   }
0732 
0733   /**
0734    * Set the underlying Born matrix element
0735    */
0736   void underlyingBornME(Ptr<MatchboxMEBase>::tptr me) { theUnderlyingBornME = me; }
0737 
0738   /**
0739    * Set the dipoles which have been found along with this dipole
0740    */
0741   void partnerDipoles(const vector<Ptr<SubtractionDipole>::tptr>& p) {
0742     thePartners = p;
0743   }
0744 
0745   /**
0746    * Return the dipoles which have been found along with this dipole
0747    */
0748   const vector<Ptr<SubtractionDipole>::tptr>& partnerDipoles() const {
0749     return thePartners;
0750   }
0751 
0752   /**
0753    * Return the matrix element averaged over spin correlations.
0754    */
0755   virtual double me2Avg(double ccme2) const = 0;
0756 
0757   /**
0758    * Return the matrix element squared differential in the variables
0759    * given by the last call to generateKinematics().
0760    */
0761   virtual CrossSection dSigHatDR(Energy2 factorizationScale) const;
0762 
0763   /**
0764    * Return the matrix element squared differential in the variables
0765    * given by the last call to generateKinematics().
0766    */
0767   virtual CrossSection dSigHatDR() const { return dSigHatDR(ZERO); }
0768 
0769       
0770         /// calculate the general prefactor for merging.
0771   CrossSection prefactor(Energy2 factorizationScale)const;
0772       
0773   /**
0774    *  Calculate the parton shower approximation for this dipole.
0775    **/
0776       
0777   CrossSection ps(Energy2 factorizationScale,Ptr<ColourBasis>::tptr largeNBasis) const;
0778 
0779   /**
0780    *  Calculate the dipole with clusterfsafe flag.
0781    **/
0782 
0783   CrossSection dip(Energy2 factorizationScale) const;
0784 
0785   
0786 
0787   /**
0788    *  Calculate the dipole dSigDR and the parton shower approximation for this dipole.
0789    **/
0790 
0791   pair<CrossSection,CrossSection> dipandPs(Energy2 factorizationScale,Ptr<ColourBasis>::tptr largeNBasis) const;
0792 
0793   //@}
0794 
0795   /** @name Methods relevant to matching */
0796   //@{
0797 
0798   /**
0799    * Set the shower approximation.
0800    */
0801   void showerApproximation(Ptr<ShowerApproximation>::tptr app) {
0802     theShowerApproximation = app;
0803   }
0804 
0805   /**
0806    * Return the shower approximation.
0807    */
0808   Ptr<ShowerApproximation>::tptr showerApproximation() const { return theShowerApproximation; }
0809 
0810   /**
0811    * Indicate that the shower real emission contribution should be subtracted.
0812    */
0813   void doRealShowerSubtraction() { theRealShowerSubtraction = true; }
0814 
0815   /**
0816    * Return true, if the shower real emission contribution should be subtracted.
0817    */
0818   bool realShowerSubtraction() const { return theRealShowerSubtraction; }
0819 
0820   /**
0821    * Indicate that the shower virtual contribution should be subtracted.
0822    */
0823   void doVirtualShowerSubtraction() { theVirtualShowerSubtraction = true; }
0824 
0825   /**
0826    * Return true, if the shower virtual contribution should be subtracted.
0827    */
0828   bool virtualShowerSubtraction() const { return theVirtualShowerSubtraction; }
0829 
0830   /**
0831    * Indicate that the loopsim matched virtual contribution should be subtracted.
0832    */
0833   void doLoopSimSubtraction() { theLoopSimSubtraction = true; }
0834 
0835   /**
0836    * Return true, if the loopsim matched virtual contribution should be subtracted.
0837    */
0838   bool loopSimSubtraction() const { return theLoopSimSubtraction; }
0839 
0840   //@}
0841 
0842   /** @name Caching and diagnostic information */
0843   //@{
0844 
0845   /**
0846    * Inform this matrix element that a new phase space
0847    * point is about to be generated, so all caches should
0848    * be flushed.
0849    */
0850   virtual void flushCaches();
0851 
0852   /**
0853    * Indicate that the subtraction is being tested.
0854    */
0855   void doTestSubtraction() { theSubtractionTest = true; }
0856 
0857   /**
0858    * Return true, if the subtraction is being tested.
0859    */
0860   bool testSubtraction() const { return theSubtractionTest; }
0861 
0862   /**
0863    * Return true, if verbose
0864    */
0865   bool verbose() const { return realEmissionME()->verbose() || underlyingBornME()->verbose(); }
0866 
0867   /**
0868    * Dump the setup to an ostream
0869    */
0870   void print(ostream&) const;
0871 
0872   /**
0873    * Print debug information on the last event
0874    */
0875   virtual void printLastEvent(ostream&) const;
0876 
0877   /**
0878    * Write out diagnostic information for
0879    * generateTildeKinematics
0880    */
0881   void logGenerateTildeKinematics() const;
0882 
0883   /**
0884    * Write out diagnostic information for
0885    * generateRadiationKinematics
0886    */
0887   void logGenerateRadiationKinematics(const double * r) const;
0888 
0889   /**
0890    * Write out diagnostic information for
0891    * me2 evaluation
0892    */
0893   void logME2() const;
0894 
0895   /**
0896    * Write out diagnostic information
0897    * for dsigdr evaluation
0898    */
0899   void logDSigHatDR(double effectiveJac) const;
0900 
0901   //@}
0902 
0903   /** @name Reweight objects */
0904   //@{
0905 
0906   /**
0907    * Insert a reweight object
0908    */
0909   void addReweight(Ptr<MatchboxReweightBase>::ptr rw) { theReweights.push_back(rw); }
0910 
0911   /**
0912    * Return the reweight objects
0913    */
0914   const vector<Ptr<MatchboxReweightBase>::ptr>& reweights() const { return theReweights; }
0915 
0916   /**
0917    * Access the reweight objects
0918    */
0919   vector<Ptr<MatchboxReweightBase>::ptr>& reweights() { return theReweights; }
0920 
0921   //@}
0922 
0923   /** @name Methods used to setup SubtractionDipole objects */
0924   //@{
0925 
0926   /**
0927    * Clone this dipole.
0928    */
0929   Ptr<SubtractionDipole>::ptr cloneMe() const {
0930     return dynamic_ptr_cast<Ptr<SubtractionDipole>::ptr>(clone());
0931   }
0932 
0933   /**
0934    * Clone the dependencies, using a given prefix.
0935    */
0936       
0937   void cloneDependencies(const std::string& prefix = "", bool slim=false);
0938 
0939   //@}
0940 
0941   /** @name Methods required to setup the event record */
0942   //@{
0943 
0944   /**
0945    * construct the spin information for the interaction
0946    */
0947   virtual void constructVertex(tSubProPtr sub);
0948 
0949   /**
0950    * construct the spin information for the interaction
0951    */
0952   virtual void constructVertex(tSubProPtr sub, const ColourLines* cl);
0953 
0954   /**
0955    * Comlete a SubProcess object using the internal degrees of freedom
0956    * generated in the last generateKinematics() (and possible other
0957    * degrees of freedom which was intergated over in dSigHatDR(). This
0958    * default version does nothing. Will be made purely virtual in the
0959    * future.
0960    */
0961   virtual void generateSubCollision(SubProcess & sub);
0962       
0963   /**
0964    * Alpha parameter as in Nagy
0965    * (http://arxiv.org/pdf/hep-ph/0307268v2.pdf) to restrict dipole
0966    * phase space
0967    */
0968    double alpha() const;
0969       
0970    /*
0971     * True if phase space point is above the alpha cut for this dipole.
0972     */
0973       
0974    bool aboveAlpha() const;
0975 
0976   //@}
0977 
0978 public:
0979 
0980   /** @name Functions used by the persistent I/O system. */
0981   //@{
0982   /**
0983    * Function used to write out object persistently.
0984    * @param os the persistent output stream written to.
0985    */
0986   void persistentOutput(PersistentOStream & os) const;
0987 
0988   /**
0989    * Function used to read in object persistently.
0990    * @param is the persistent input stream read from.
0991    * @param version the version number of the object when written.
0992    */
0993   void persistentInput(PersistentIStream & is, int version);
0994   //@}
0995 
0996   /**
0997    * The standard Init function used to initialize the interfaces.
0998    * Called exactly once for each class by the class description system
0999    * before the main function starts or
1000    * when this class is dynamically loaded.
1001    */
1002   static void Init();
1003 
1004 protected:
1005 
1006   /** @name Standard Interfaced functions. */
1007   //@{
1008 
1009   /**
1010    * Initialize this object after the setup phase before saving an
1011    * EventGenerator to disk.
1012    * @throws InitException if object could not be initialized properly.
1013    */
1014   virtual void doinit();
1015 
1016   /**
1017    * Initialize this object. Called in the run phase just before
1018    * a run begins.
1019    */
1020   virtual void doinitrun();
1021   //@}
1022 
1023 private:
1024 
1025   /**
1026    * Wether or not this dipole acts in splitting mode.
1027    */
1028   bool theSplitting;
1029 
1030   /**
1031    * True, if should apply to process in the xcomb.
1032    */
1033   bool theApply;
1034 
1035   /**
1036    * True, if the subtraction is being tested.
1037    */
1038   bool theSubtractionTest;
1039 
1040   /**
1041    * True if cuts should be ignored
1042    */
1043   bool theIgnoreCuts;
1044 
1045   /**
1046    * The real emission matrix element to be considered
1047    */
1048   Ptr<MatchboxMEBase>::ptr theRealEmissionME;
1049 
1050   /**
1051    * The underlying Born matrix element
1052    */
1053   Ptr<MatchboxMEBase>::ptr theUnderlyingBornME;
1054 
1055   /**
1056    * The dipoles which have been found along with this dipole
1057    */
1058   vector<Ptr<SubtractionDipole>::tptr> thePartners;
1059 
1060   /**
1061    * The TildeKinematics to be used.
1062    */
1063   Ptr<TildeKinematics>::ptr theTildeKinematics;
1064 
1065   /**
1066    * The InvertedTildeKinematics to be used.
1067    */
1068   Ptr<InvertedTildeKinematics>::ptr theInvertedTildeKinematics;
1069 
1070   /**
1071    * A vector of reweight objects the sum of which
1072    * should be applied to reweight this dipole
1073    */
1074   vector<Ptr<MatchboxReweightBase>::ptr> theReweights;
1075 
1076   /**
1077    * The emitter as referred to by the real emission
1078    * matrix element.
1079    */
1080   int theRealEmitter;
1081 
1082   /**
1083    * The emission as referred to by the real emission
1084    * matrix element.
1085    */
1086   int theRealEmission;
1087 
1088   /**
1089    * The spectator as referred to by the real emission
1090    * matrix element.
1091    */
1092   int theRealSpectator;
1093 
1094   /**
1095    * The subtraction parameters
1096    */
1097   vector<double> theSubtractionParameters;
1098 
1099   /**
1100    * Map real emission diagrams to underlying Born diagrams 
1101    * and tilde emitter/spectator.
1102    */
1103   map<RealEmissionKey,UnderlyingBornInfo> theMergingMap;
1104 
1105   /**
1106    * Map underlying Born diagrams and tilde emitter/spectator
1107    * to real emission diagram containing the splitting.
1108    */
1109   multimap<UnderlyingBornKey,RealEmissionInfo> theSplittingMap;
1110 
1111   /**
1112    * Map underlying Born diagrams to emitter/spectator pairs
1113    */
1114   map<cPDVector,pair<int,int> > theIndexMap;
1115 
1116   /**
1117    * Map real emission processes to Born diagrams
1118    */
1119   map<cPDVector,DiagramVector> theUnderlyingBornDiagrams;
1120 
1121   /**
1122    * Map Born processes to real emission diagrams
1123    */
1124   map<cPDVector,DiagramVector> theRealEmissionDiagrams;
1125 
1126   /**
1127    * Map underlying Born diagrams to real emission diagrams.
1128    */
1129   map<tcDiagPtr,tcDiagPtr> theBornToRealDiagrams;
1130 
1131   /**
1132    * Map real emission diagrams to underlying Born diagrams.
1133    */
1134   map<tcDiagPtr,tcDiagPtr> theRealToBornDiagrams;
1135 
1136   /**
1137    * The last real emission key encountered
1138    */
1139   RealEmissionKey lastRealEmissionKey;
1140 
1141   /**
1142    * The last underlying Born key encountered
1143    */
1144   UnderlyingBornKey lastUnderlyingBornKey;
1145 
1146   /**
1147    * The last real emission info encountered
1148    */
1149   multimap<UnderlyingBornKey,RealEmissionInfo>::const_iterator lastRealEmissionInfo;
1150 
1151   /**
1152    * The emitter as referred to by the underlying Born
1153    * matrix element.
1154    */
1155   int theBornEmitter;
1156 
1157   /**
1158    * The spectator as referred to by the underlying Born
1159    * matrix element.
1160    */
1161   int theBornSpectator;
1162 
1163   /**
1164    * The last scale as generated from the tilde mapping
1165    */
1166   Energy theLastSubtractionScale;
1167 
1168   /**
1169    * The last scale as generated from the splitting mapping
1170    */
1171   Energy theLastSplittingScale;
1172 
1173   /**
1174    * The last pt as generated from the tilde mapping
1175    */
1176   Energy theLastSubtractionPt;
1177 
1178   /**
1179    * The last pt as generated from the splitting mapping
1180    */
1181   Energy theLastSplittingPt;
1182 
1183   /**
1184    * The last z as generated from the tilde mapping
1185    */
1186   double theLastSubtractionZ;
1187 
1188   /**
1189    * The last z as generated from the splitting mapping
1190    */
1191   double theLastSplittingZ;
1192 
1193   /**
1194    * The shower approximation.
1195    */
1196   Ptr<ShowerApproximation>::ptr theShowerApproximation;
1197 
1198   /**
1199    * True, if the shower real emission contribution should be subtracted.
1200    */
1201   bool theRealShowerSubtraction;
1202 
1203   /**
1204    * True, if the shower virtual contribution should be subtracted.
1205    */
1206   bool theVirtualShowerSubtraction;
1207 
1208   /**
1209    * True, if the loopsim matched virtual contribution should be subtracted.
1210    */
1211   bool theLoopSimSubtraction;
1212 
1213   /**
1214    * True, if scales should be calculated from real emission kinematics
1215    */
1216   bool theRealEmissionScales;
1217 
1218   /**
1219    * Return the shower hard scale encountered
1220    */
1221   Energy theShowerHardScale;
1222 
1223   /**
1224    * The shower evolution scale encountered
1225    */
1226   Energy theShowerScale;
1227 
1228   /**
1229    * The shower splitting variables encountered
1230    */
1231   vector<double> theShowerParameters;
1232 
1233   /**
1234    * True, if this configuration is in the shower phase space
1235    */
1236   bool theIsInShowerPhasespace;
1237 
1238   /**
1239    * True, if this configuration is above the shower infrared cutoff
1240    */
1241   bool theIsAboveCutoff;
1242 
1243 private:
1244 
1245   /**
1246    * The assignment operator is private and must never be called.
1247    * In fact, it should not even be implemented.
1248    */
1249   SubtractionDipole & operator=(const SubtractionDipole &) = delete;
1250 
1251 };
1252 
1253 }
1254 
1255 #endif /* HERWIG_SubtractionDipole_H */