Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // -*- C++ -*-
0002 //
0003 // StandardXComb.h is a part of ThePEG - Toolkit for HEP Event Generation
0004 // Copyright (C) 1999-2019 Leif Lonnblad
0005 // Copyright (C) 2009-2019 Simon Platzer
0006 //
0007 // ThePEG is licenced under version 3 of the GPL, see COPYING for details.
0008 // Please respect the MCnet academic guidelines, see GUIDELINES for details.
0009 //
0010 #ifndef ThePEG_StandardXComb_H
0011 #define ThePEG_StandardXComb_H
0012 // This is the declaration of the StandardXComb class.
0013 
0014 #include "ThePEG/Config/ThePEG.h"
0015 #include "SubProcessHandler.fh"
0016 #include "ThePEG/PDF/PartonExtractor.fh"
0017 #include "ThePEG/PDF/PartonBin.h"
0018 #include "ThePEG/PDF/PartonBinInstance.h"
0019 #include "ThePEG/Utilities/VSelector.h"
0020 #include "ThePEG/Utilities/ClassDescription.h"
0021 #include "ThePEG/Utilities/Maths.h"
0022 #include "ThePEG/Utilities/XSecStat.h"
0023 #include "ThePEG/EventRecord/Particle.h"
0024 #include "ThePEG/MatrixElement/MEBase.h"
0025 #include "ThePEG/Handlers/XComb.h"
0026 #include "ThePEG/Handlers/StandardEventHandler.h"
0027 #include "ThePEG/Handlers/SubProcessHandler.fh"
0028 #include "StandardXComb.fh"
0029 
0030 namespace ThePEG {
0031 
0032 /**
0033  * The StandardXComb class inherits from the more general XComb class
0034  * which stores all information about the generation of a hard
0035  * sub-proces for a given pair of incoming particles, a pair of
0036  * extracted partons, etc. This class stores more information related
0037  * to thestandard process generation scheme in ThePEG, such as the
0038  * PartonExtractor and MEBase object used. It also does some of the
0039  * administration of the process generation.
0040  *
0041  * The main function is dSigDR() which returns the differential cross
0042  * section w.r.t. a given vector of random numbers in the interval
0043  * ]0,1[. In the initialization this is used to pre-sample the phase
0044  * space. In the generation phase it is used to give the cross section
0045  * for a phase space point, and if this StandardXComb is chosen the
0046  * construct() function is called to generate the actual sub-process.
0047  *
0048  * @see ParonExtractor
0049  * @see MEBase
0050  * @see Cuts
0051  * @see StdXCombGroup
0052  */
0053 class StandardXComb: public XComb {
0054 
0055 public:
0056 
0057   /** A vector of DiagramBase objects. */
0058   typedef MEBase::DiagramVector DiagramVector;
0059 
0060   /** A vector of indices. */
0061   typedef MEBase::DiagramIndex DiagramIndex;
0062 
0063   /** MEBase needs to be a friend. */
0064   friend class MEBase;
0065 
0066 public:
0067 
0068   /** @name Standard constructors and destructors. */
0069   //@{
0070   /**
0071    * Standard constructor.
0072    */
0073   StandardXComb(Energy newMaxEnergy, const cPDPair & inc,
0074         tEHPtr newEventHandler,tSubHdlPtr newSubProcessHandler,
0075         tPExtrPtr newExtractor, tCascHdlPtr newCKKW,
0076         const PBPair & newPartonBins, tCutsPtr newCuts, tMEPtr newME,
0077         const DiagramVector & newDiagrams, bool mir,
0078         tStdXCombPtr newHead = tStdXCombPtr());
0079 
0080   /**
0081    * Constructor given a head xcomb.
0082    */
0083   StandardXComb(tStdXCombPtr newHead,
0084         const PBPair & newPartonBins, tMEPtr newME,
0085         const DiagramVector & newDiagrams);
0086 
0087   /**
0088    * Default constructor.
0089    */
0090   StandardXComb();
0091 
0092   /**
0093    * Destructor.
0094    */
0095   virtual ~StandardXComb();
0096 
0097   /**
0098    * Constructor used by MEBase to create a temporary object to store info.
0099    */
0100   StandardXComb(tMEPtr me, const tPVector & parts, DiagramIndex i);
0101 
0102   //@}
0103 
0104   /** @name Utilities for incoming partons. */
0105   //@{
0106 
0107   /**
0108    * Properly setup the PartonBinInstance objects provided a sub
0109    * process has been constructed using this XComb.
0110    */
0111   void recreatePartonBinInstances(Energy2 scale);
0112 
0113   /**
0114    * Fill the variables needed to generate remnants; momenta will be
0115    * used from the partons set in this xcomb, but random numbers need
0116    * to be provided to (re)generate variables not fixed by the
0117    * incoming partons.
0118    */
0119   void refillPartonBinInstances(const double* r);
0120 
0121   /**
0122    * Setup information on incoming partons depending
0123    * on the information previously supplied through the
0124    * choice of diagram and incoming momenta in the first
0125    * two entries of meMomenta(). Partons are not actually
0126    * extracted from the incoming particles, though a subprocess
0127    * detached from the current Event may be created.
0128    */
0129   bool setIncomingPartons(tStdXCombPtr labHead = tStdXCombPtr());
0130 
0131   /**
0132    * Fill phase space information as far as possible
0133    */
0134   void fill(const PPair& newParticles,
0135         const PPair& newPartons,
0136         const vector<Lorentz5Momentum>& newMEMomenta,
0137         const DVector& newLastRandomNumbers = DVector());
0138 
0139   //@}
0140 
0141   /** @name Access the assigned objects used in the generation. */
0142   //@{
0143   /**
0144    * Return a pointer to the corresponding sub-process handler. May be
0145    * null if the standard process generation in ThePEG was not used.
0146    */
0147   tcSubHdlPtr subProcessHandler() const { return theSubProcessHandler; }
0148 
0149   /**
0150    * The matrix element to be used.
0151    */
0152   tMEPtr matrixElement() const { return theME; }
0153 
0154   /**
0155    * Return a pointer to the head XComb this XComb
0156    * depends on. May return NULL, if this is not a
0157    * member of a XComb group.
0158    */
0159   tStdXCombPtr head() const { return theHead; }
0160 
0161   /**
0162    * Set the head XComb pointer.
0163    */
0164   void head(tStdXCombPtr headXC) { theHead = headXC; }
0165 
0166   /**
0167    * Return a selector object of xcombs to choose subprocesses
0168    * different than the one currently integrated.
0169    */
0170   Selector<tStdXCombPtr>& projectors() { return theProjectors; }
0171 
0172   /**
0173    * Return a selector object of xcombs to choose subprocesses
0174    * different than the one currently integrated.
0175    */
0176   const Selector<tStdXCombPtr>& projectors() const { return theProjectors; }
0177 
0178   /**
0179    * Return a pointer to a projector xcomb which will generate a subprocess
0180    * different from the one just integrated.
0181    */
0182   tStdXCombPtr lastProjector() const { return theProjector; }
0183 
0184   /**
0185    * Set a pointer to a projector xcomb which will generate a subprocess
0186    * different from the one just integrated.
0187    */
0188   void lastProjector(tStdXCombPtr pxc) { theProjector = pxc; }
0189 
0190   //@}
0191 
0192   /** @name Main functions used for the generation. */
0193   //@{
0194   /**
0195    * Try to determine if this subprocess is at all possible.
0196    */
0197   virtual bool checkInit();
0198 
0199   /**
0200    * The number of dimensions of the phase space used to generate this
0201    * process.
0202    */
0203   virtual int nDim() const { return theNDim; }
0204 
0205   /**
0206    * Return the parton extraction dimensions
0207    */
0208   const pair<int,int>& partonDimensions() const { return partonDims; }
0209 
0210   /**
0211    * Return true, if the current configuration will pass the cuts
0212    */
0213   bool willPassCuts();
0214 
0215   /**
0216    * Return the cut weight encountered from fuzzy cuts
0217    */
0218   double cutWeight() const { return theCutWeight; }
0219 
0220   /**
0221    * Reset all saved data about last generated phasespace point;
0222    */
0223   virtual void clean();
0224 
0225   /**
0226    * Return true, if kinematics have already been generated
0227    */
0228   bool kinematicsGenerated() const  { return theKinematicsGenerated; }
0229 
0230   /**
0231    * Indicate that kinematics have been generated
0232    */
0233   void didGenerateKinematics() { theKinematicsGenerated = true; }
0234 
0235   /**
0236    * Generate a phase space point from a vector \a r of \a nr numbers
0237    * in the interval ]0,1[ and return the corresponding differential
0238    * cross section.
0239    */
0240   virtual CrossSection dSigDR(const pair<double,double> ll, int nr, const double * r);
0241 
0242   /**
0243    * If this XComb has a head XComb, return the cross section
0244    * differential in the variables previously supplied. The PDF weight
0245    * is taken from the lastPDFWeight supplied by the head XComb
0246    * object.
0247    */
0248   CrossSection dSigDR(const double * r);
0249 
0250   /**
0251    * If variations are available for the subprocess handled, generate
0252    * and return a map of optional weights to be included for the
0253    * event; this version defaults to an implementation in MEBase but
0254    * can be overloaded by inheriting XComb objects.
0255    */
0256   virtual map<string,double> generateOptionalWeights();
0257 
0258   /**
0259    * Return the PDF weight used in the last call to dSigDR
0260    */
0261   double lastPDFWeight() const { return theLastPDFWeight; }
0262 
0263   /**
0264    * Return the cross section calculated in the last call to dSigDR
0265    */
0266   CrossSection lastCrossSection() const { return theLastCrossSection; }
0267 
0268   /**
0269    * Check if a reshuffling is required when constructing the hard
0270    * subprocess.
0271    */
0272   void checkReshufflingNeeds();
0273 
0274   /**
0275    * Return true if a reshuffling is required when constructing the hard
0276    * subprocess. 
0277    */
0278   bool needsReshuffling() const { return theNeedsReshuffling; }
0279 
0280   /**
0281    * Perform the reshuffling from hardProcessMass to mass values,
0282    * given outgoing momenta
0283    */
0284   void reshuffle(vector<Lorentz5Momentum>&) const;
0285 
0286   /**
0287    * Construct a sub-process object from the information available.
0288    */
0289   virtual tSubProPtr construct();
0290   //@}
0291 
0292   /** @name Functions used for collecting statistics. */
0293   //@{
0294   /**
0295    * The statistics object for this XComb.
0296    */
0297   virtual const XSecStat & stats() const { return theStats; }
0298 
0299   /**
0300    * Select the current event. It will later be rejected with a
0301    * probability given by \a weight.
0302    */
0303   virtual void select(double weight) { theStats.select(weight); }
0304 
0305   /**
0306    * Accept the current event assuming it was previously selcted.
0307    */
0308   virtual void accept() { theStats.accept(); }
0309 
0310   /**
0311    * Reweight a selected and accepted event.
0312    */
0313   void reweight(double oldWeight, double newWeight) {
0314     theStats.reweight(oldWeight,newWeight);
0315   }
0316 
0317   /**
0318    * Reject the current event assuming it was previously accepted. If
0319    * weighted events are produced, the \a weight should be the same as
0320    * the previous call to select(double).
0321    */
0322   virtual void reject(double weight = 1.0) { theStats.reject(weight); }
0323 
0324   /**
0325    * Reset statistics.
0326    */
0327   virtual void reset() { theStats.reset(); }
0328   //@}
0329 
0330   /** @name Access information used by the MEBase object. */
0331   //@{
0332   /**
0333    * The diagrams used by the matrix element.
0334    */
0335   const DiagramVector & diagrams() const { return theDiagrams; }
0336 
0337   /**
0338    * True if the TreeDiagram's for this matrix element should in fact
0339    * be mirrored before used to create an actual sub-rocess.
0340    */
0341   bool mirror() const { return isMirror; }
0342 
0343   /**
0344    * Return the momenta of the partons to be used by the matrix
0345    * element object, in the order specified by the TreeDiagram objects
0346    * given by the matrix element.
0347    */
0348   const vector<Lorentz5Momentum> & meMomenta() const { return theMEMomenta; }
0349 
0350   /**
0351    * Return the last selected diagram.
0352    */
0353   tcDiagPtr lastDiagram() const { 
0354     if ( !theExternalDiagram )
0355       return diagrams()[lastDiagramIndex()];
0356     return theExternalDiagram;
0357   }
0358 
0359   /**
0360    * Return the parton types to be used by the matrix element object,
0361    * in the order specified by the TreeDiagram objects given by the
0362    * matrix element.
0363    */
0364   const cPDVector & mePartonData() const { return theMEPartonData; }
0365 
0366   /**
0367    * Return the index of the last selected diagram.
0368    */
0369   DiagramIndex lastDiagramIndex() const { return theLastDiagramIndex; }
0370 
0371   /**
0372    * Get information saved by the matrix element in the calculation of
0373    * the cross section to be used later when selecting diagrams and
0374    * colour flow.
0375    */
0376   const DVector & meInfo() const { return theMEInfo; }
0377 
0378   /**
0379    * Set information saved by the matrix element in the calculation of
0380    * the cross section to be used later when selecting diagrams and
0381    * colour flow.
0382    */
0383   void meInfo(const DVector & info) { theMEInfo = info; }
0384 
0385   /**
0386    * Return the random numbers used to generate the
0387    * last phase space point, if the matrix element
0388    * requested so.
0389    */
0390   const DVector& lastRandomNumbers() const { return theLastRandomNumbers; }
0391 
0392   /**
0393    * Get the last jacobian obtained when generating the kinematics
0394    * for the call to dSigHatDR.
0395    */
0396   double jacobian() const { return theLastJacobian; }
0397 
0398   /**
0399    * Return the matrix element squared as calculated
0400    * for the last phase space point. This may optionally
0401    * be used by a matrix element for caching.
0402    */
0403   double lastME2() const { return theLastME2; }
0404 
0405   /**
0406    * Return the last preweight factor
0407    */
0408   double lastPreweight() const { return theLastPreweight; }
0409 
0410   /**
0411    * Return the partonic cross section as calculated
0412    * for the last phase space point. This may optionally
0413    * be used by a matrix element for caching.
0414    */
0415   CrossSection lastMECrossSection() const { return theLastMECrossSection; }
0416 
0417   /**
0418    * Return the PDF weight as calculated
0419    * for the last phase space point, if the matrix
0420    * element does supply PDF weights. This may optionally
0421    * be used by a matrix element for caching.
0422    */
0423   double lastMEPDFWeight() const { return theLastMEPDFWeight; }
0424 
0425   /**
0426    * Return the coupling factor as calculated for the lats phase space
0427    * point.
0428    */
0429   double lastMECouplings() const { return theLastMECouplings; }
0430   //@}
0431 
0432   /**
0433    * Construct the corresponding SubProcess object if it hasn't been
0434    * done before.
0435    */
0436   virtual void newSubProcess(bool group = false);
0437 
0438   /**
0439    * Return the momenta of the partons to be used by the matrix
0440    * element object, in the order specified by the TreeDiagram objects
0441    * given by the matrix element.
0442    */
0443   vector<Lorentz5Momentum> & meMomenta() { return theMEMomenta; }
0444 
0445   /**
0446    * Access the random numbers used to generate the
0447    * last phase space point, if the matrix element
0448    * requested so.
0449    */
0450   DVector& lastRandomNumbers() { return theLastRandomNumbers; }
0451 
0452   /**
0453    * Return the parton types to be used by the matrix element object,
0454    * in the order specified by the TreeDiagram objects given by the
0455    * matrix element.
0456    */
0457   cPDVector & mePartonData() { return theMEPartonData; }
0458 
0459   /**
0460    * Set a diagram to be used instead of the one selected by the matrix
0461    * element.
0462    */
0463   void externalDiagram(tcDiagPtr diag) { theExternalDiagram = diag; }
0464 
0465   /**
0466    * Set the last selected diagram.
0467    */
0468   void lastDiagramIndex(DiagramIndex i) { theLastDiagramIndex = i; }
0469 
0470   /**
0471    * Set the PDF weight used in the last call to dSigDR
0472    */
0473   void lastPDFWeight(double w) { theLastPDFWeight = w; }
0474 
0475   /**
0476    * Set the cross section calculated in the last call to dSigDR
0477    */
0478   void lastCrossSection(CrossSection s) { theLastCrossSection = s; }
0479 
0480   /**
0481    * Set the last jacobian obtained when generating the kinematics for
0482    * the call to dSigHatDR.
0483    */
0484   void jacobian(double j) { theLastJacobian = j; }
0485 
0486   /**
0487    * Set the matrix element squared as calculated
0488    * for the last phase space point. This may optionally
0489    * be used by a matrix element for caching.
0490    */
0491   void lastME2(double v) { theLastME2 = v; }
0492 
0493   /**
0494    * Set the last preweight factor
0495    */
0496   void lastPreweight(double w) { theLastPreweight = w; }
0497 
0498   /**
0499    * Set the partonic cross section as calculated
0500    * for the last phase space point. This may optionally
0501    * be used by a matrix element for caching.
0502    */
0503   void lastMECrossSection(CrossSection v) { theLastMECrossSection = v; }
0504 
0505   /**
0506    * Set the PDF weight as calculated
0507    * for the last phase space point, if the matrix
0508    * element does supply PDF weights. This may optionally
0509    * be used by a matrix element for caching.
0510    */
0511   void lastMEPDFWeight(double v) { theLastMEPDFWeight = v; }
0512 
0513   /**
0514    * Set the coupling factor
0515    */
0516   void lastMECouplings(double v) { theLastMECouplings = v; }
0517 
0518 public:
0519 
0520   /** @name Functions used by the persistent I/O system. */
0521   //@{
0522   /**
0523    * Function used to write out object persistently.
0524    * @param os the persistent output stream written to.
0525    */
0526   void persistentOutput(PersistentOStream & os) const;
0527 
0528   /**
0529    * Function used to read in object persistently.
0530    * @param is the persistent input stream read from.
0531    * @param version the version number of the object when written.
0532    */
0533   void persistentInput(PersistentIStream & is, int version);
0534   //@}
0535 
0536   /**
0537    * Standard Init function used to initialize the interface.
0538    */
0539   static void Init();
0540 
0541 private:
0542 
0543   /**
0544    * The corresponding sub-process handler
0545    */
0546   tSubHdlPtr theSubProcessHandler;
0547 
0548   /**
0549    * The matrix element to be used.
0550    */
0551   tMEPtr theME;
0552 
0553   /**
0554    * Statistics gathering for this XComb.
0555    */
0556   XSecStat theStats;
0557 
0558   /**
0559    * The diagrams used by the matrix element.
0560    */
0561   DiagramVector theDiagrams;
0562 
0563   /**
0564    * True if the TreeDiagram's for this matrix element should in fact
0565    * be mirrored before used to create an actual sub-rocess.
0566    */
0567   bool isMirror;
0568 
0569   /**
0570    * The number of dimensions of the phase space used to generate this
0571    * process.
0572    */
0573   int theNDim;
0574 
0575 protected:
0576 
0577   /**
0578    * The number of dimensions of the phase space used for each of the
0579    * incoming partons.
0580    */
0581   pair<int,int> partonDims;
0582 
0583 private:
0584 
0585   /**
0586    * True, if kinematics have already been generated
0587    */
0588   bool theKinematicsGenerated;
0589 
0590   /**
0591    * The momenta of the partons to be used by the matrix element
0592    * object, in the order specified by the TreeDiagram objects given
0593    * by the matrix element.
0594    */
0595   vector<Lorentz5Momentum> theMEMomenta;
0596 
0597   /**
0598    * The parton types to be used by the matrix element object, in the
0599    * order specified by the TreeDiagram objects given by the matrix
0600    * element.
0601    */
0602   cPDVector theMEPartonData;
0603 
0604   /**
0605    * A diagram to be used instead of the one selected by the matrix element.
0606    */
0607   tcDiagPtr theExternalDiagram;
0608 
0609   /**
0610    * The last selected tree diagram.
0611    */
0612   DiagramIndex theLastDiagramIndex;
0613 
0614   /**
0615    * Information saved by the matrix element in the calculation of the
0616    * cross section to be used later when selecting diagrams and colour
0617    * flow.
0618    */
0619   DVector theMEInfo;
0620 
0621   /**
0622    * The random numbers used to generate the
0623    * last phase space point, if the matrix element
0624    * requested so.
0625    */
0626   DVector theLastRandomNumbers;
0627 
0628   /**
0629    * The PDF weight used in the last call to dSigDR
0630    */
0631   double theLastPDFWeight;
0632 
0633   /**
0634    * The cross section calculated in the last call to dSigDR
0635    */
0636   CrossSection theLastCrossSection;
0637 
0638   /**
0639    * Save the last jacobian obtained when generating the kinematics for
0640    * the call to dSigHatDR.
0641    */
0642   double theLastJacobian;
0643 
0644   /**
0645    * The matrix element squared as calculated
0646    * for the last phase space point. This may optionally
0647    * be used by a matrix element for caching.
0648    */
0649   double theLastME2;
0650 
0651   /**
0652    * The last preweight factor
0653    */
0654   double theLastPreweight;
0655 
0656   /**
0657    * The partonic cross section as calculated
0658    * for the last phase space point. This may optionally
0659    * be used by a matrix element for caching.
0660    */
0661   CrossSection theLastMECrossSection;
0662 
0663   /**
0664    * The PDF weight as calculated
0665    * for the last phase space point, if the matrix
0666    * element does supply PDF weights. This may optionally
0667    * be used by a matrix element for caching.
0668    */
0669   double theLastMEPDFWeight;
0670 
0671   /**
0672    * The coupling factor
0673    */
0674   double theLastMECouplings;
0675 
0676   /**
0677    * A pointer to the head XComb this XComb
0678    * depends on. May return NULL, if this is not a
0679    * member of a XComb group.
0680    */
0681   tStdXCombPtr theHead;
0682 
0683   /**
0684    * A selector object of xcombs to choose subprocesses
0685    * different than the one currently integrated.
0686    */
0687   Selector<tStdXCombPtr> theProjectors;
0688 
0689   /**
0690    * A pointer to a projector xcomb which will generate a subprocess
0691    * different from the one just integrated.
0692    */
0693   tStdXCombPtr theProjector;
0694 
0695   /**
0696    * True, if cuts have already been checked
0697    */
0698   bool checkedCuts;
0699 
0700   /**
0701    * The result of the last call to willPassCuts
0702    */
0703   bool passedCuts;
0704 
0705   /**
0706    * The cut weight encountered from fuzzy cuts
0707    */
0708   double theCutWeight;
0709 
0710   /**
0711    * True if a reshuffling is required when constructing the hard
0712    * subprocess.
0713    */
0714   bool theNeedsReshuffling;
0715 
0716   /**
0717    * Calculate the reshuffling equation given the coefficients
0718    */
0719   double reshuffleEquation(double, const vector<pair<Energy2,Energy2> >&, Energy2) const;
0720 
0721   /**
0722    * Solve the reshuffling equation given the coefficients
0723    */
0724   double solveReshuffleEquation(const vector<pair<Energy2,Energy2> >&, Energy2) const;
0725 
0726 private:
0727 
0728   /**
0729    * Describe a concrete class with persistent data.
0730    */
0731   static ClassDescription<StandardXComb> initStandardXComb;
0732  
0733   /**
0734    * Private and non-existent assignment operator.
0735    */
0736   StandardXComb & operator=(const StandardXComb &) = delete;
0737 
0738 };
0739 
0740 /** @cond TRAITSPECIALIZATIONS */
0741 
0742 /**
0743  * This template specialization informs ThePEG about the base class of
0744  * StandardXComb.
0745  */
0746 template <>
0747 struct BaseClassTrait<StandardXComb,1>: public ClassTraitsType {
0748   /** Typedef of the base class of StandardXComb. */
0749   typedef XComb NthBase;
0750 };
0751 
0752 /**
0753  * This template specialization informs ThePEG about the name of the
0754  * StandardXComb class.
0755  */
0756 template <>
0757 struct ClassTraits<StandardXComb>:
0758     public ClassTraitsBase<StandardXComb> {
0759   /** Return the class name. */
0760   static string className() { return "ThePEG::StandardXComb"; }
0761 };
0762 
0763 /** @endcond */
0764 
0765 }
0766 
0767 #endif /* ThePEG_StandardXComb_H */