Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // -*- C++ -*-
0002 //
0003 // DecayIntegrator.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_DecayIntegrator_H
0010 #define Herwig_DecayIntegrator_H
0011 //
0012 // This is the declaration of the DecayIntegrator class.
0013 //
0014 
0015 #include "DecayIntegrator.fh"
0016 #include "HwDecayerBase.h"
0017 #include "PhaseSpaceMode.fh"
0018 #include "Herwig/PDT/WidthCalculatorBase.fh"
0019 #include "Radiation/DecayRadiationGenerator.h"
0020 #include <Herwig/Decay/DecayVertex.h>
0021 
0022 namespace Herwig {
0023 
0024 using namespace ThePEG;
0025 
0026   /** \ingroup Decay
0027    * \class DecayIntegrator
0028    * \brief Main class for Decayers implementing multi-channel phase space integration.
0029    * \author Peter Richardson
0030    *
0031    *  This class is designed to be the base class for Herwig decays including
0032    *  the implementation of a multichannel decayer or n-body phase space decays.
0033    *
0034    *  The <code>DecayIntegrator</code> class inherits from ThePEG's Decayer class
0035    *  and makes use of the <code>PhaseSpaceMode</code> class to specify a number
0036    *  of decay modes.
0037    *
0038    *  Additional modes can be added using the addMode method. In practice the 
0039    *  phase space channels for a particular mode are usually constructed in the 
0040    *  doinit member of a Decayer and then the modes added to the Decayer.
0041    *
0042    *  For the majority of the decays currently implemented the 
0043    *  phase-space integration has been optimised and the maximum weight set.
0044    *  If the parameters of the decay model are changed the Initialize interface 
0045    *  can be used to optimise the integration and calculate the maximum weight.
0046    *
0047    *  In classes inheriting from this the me2() member which gives the matrix element
0048    *  squared must be implemented. This should be combined with the setting of the
0049    *  phase space channels, and the setting of which channels to use and their
0050    *  initial weights in the doinit() member. The different decay modes should then
0051    *  be initialized in the initrun() member if needed. The generate member can then
0052    *  be called from the decay() member to generate a phase-space configuration for a 
0053    *  decay.
0054    *   
0055    * @see DecayPhaseSpaceMode
0056    * @see DecayPhaseSpaceChannel
0057    * @see \ref DecayIntegratorInterfaces "The interfaces"
0058    * defined for DecayIntegrator.
0059    */
0060 class DecayIntegrator: public HwDecayerBase {
0061 
0062 public:
0063   
0064   /**
0065    *  and DecayPhaseMode
0066    */
0067   friend class PhaseSpaceMode;
0068 
0069   /**
0070    *  Enum for the matrix element option
0071    */
0072   enum MEOption {Initialize,Calculate,Terminate};
0073 
0074 public:
0075 
0076   /**
0077    * The default constructor.
0078    */
0079   DecayIntegrator() : nIter_(10), nPoint_(10000), nTry_(500),
0080                generateInter_(false), iMode_(-1),
0081                realME_(false), virtualME_(false), eps_(ZERO), warnings_(false)
0082   {}
0083 
0084 public:
0085   
0086   /**
0087    * Check if this decayer can perfom the decay for a particular mode.
0088    * Uses the modeNumber member but can be overridden
0089    * @param parent The decaying particle
0090    * @param children The decay products
0091    */
0092   virtual bool accept(tcPDPtr parent, const tPDVector & children) const {
0093     bool cc;
0094     return modeNumber(cc,parent,children)>=0;
0095   }
0096   
0097   /**
0098    * For a given decay mode and a given particle instance, perform the
0099    * decay and return the decay products. As this is the base class this
0100    * is not implemented.
0101    * @return The vector of particles produced in the decay.
0102    */
0103   virtual ParticleVector decay(const Particle & parent,
0104                    const tPDVector & children) const;
0105   
0106   /**
0107    * Which of the possible decays is required
0108    * @param cc Is this mode the charge conjugate
0109    * @param parent The decaying particle
0110    * @param children The decay products
0111    */
0112   virtual int modeNumber(bool & cc, tcPDPtr parent, 
0113              const tPDVector & children) const = 0;
0114 
0115   /**
0116    * The mode being used for this decay
0117    */
0118   int imode() const {return iMode_;}
0119 
0120   /**
0121    * Add a phase-space mode to the list
0122    * @param mode The mode being added.
0123    */
0124   void addMode(PhaseSpaceModePtr mode) const;
0125 
0126   /**
0127    * Return the matrix element squared for a given mode and phase-space channel.
0128    * @param ichan The channel we are calculating the matrix element for. 
0129    * @param part The decaying Particle.
0130    * @param outgoing The particles produced in the decay
0131    * @param momenta  The momenta of the particles produced in the decay
0132    * @param meopt Option for the calculation of the matrix element
0133    * @return The matrix element squared for the phase-space configuration.
0134    */
0135   virtual double me2(const int ichan, const Particle & part,
0136              const tPDVector & outgoing,
0137              const vector<Lorentz5Momentum> & momenta,
0138              MEOption meopt) const = 0;
0139 
0140   /**
0141    *   Construct the SpinInfos for the particles produced in the decay
0142    */
0143   virtual void constructSpinInfo(const Particle & part,
0144                  ParticleVector outgoing) const = 0;
0145   
0146   /**
0147    * Output the setup information for the particle database
0148    * @param os The stream to output the information to
0149    * @param header Whether or not to output the information for MySQL
0150    */
0151   virtual void dataBaseOutput(ofstream & os,bool header) const;
0152   
0153   /**
0154    * Set the code for the partial width. Finds the partial width in the
0155    * GenericWidthGenerator class which corresponds to the decay mode.
0156    * @param dm The DecayMode
0157    * @param imode The mode. 
0158    */
0159   void setPartialWidth(const DecayMode & dm, int imode);
0160   /**
0161    * Specify the \f$1\to2\f$ matrix element to be used in the running width calculation.
0162    * @param mecode The code for the matrix element as described
0163    *               in the GenericWidthGenerator class.
0164    * @param coupling The coupling for the matrix element.
0165    * @return True or False if this mode can be handled.
0166    */
0167   virtual bool twoBodyMEcode(const DecayMode &, int & mecode,
0168                  double & coupling) const {
0169     coupling = 1.;
0170     mecode   = -1;
0171     return false;
0172   }                  
0173   
0174   /**
0175    * Method to return an object to calculate the 3 (or higher body) partial width
0176    * @param dm The DecayMode
0177    * @return A pointer to a WidthCalculatorBase object capable of calculating the width
0178    */
0179   virtual WidthCalculatorBasePtr threeBodyMEIntegrator(const DecayMode & dm) const;
0180   
0181   /**
0182    * The matrix element to be integrated for the three-body decays as a function
0183    * of the invariant masses of pairs of the outgoing particles.
0184    * @param imode The mode for which the matrix element is needed.
0185    * @param q2 The scale, \e i.e. the mass squared of the decaying particle.
0186    * @param s3 The invariant mass squared of particles 1 and 2, \f$s_3=m^2_{12}\f$.
0187    * @param s2 The invariant mass squared of particles 1 and 3, \f$s_2=m^2_{13}\f$.
0188    * @param s1 The invariant mass squared of particles 2 and 3, \f$s_1=m^2_{23}\f$.
0189    * @param m1 The mass of the first  outgoing particle.
0190    * @param m2 The mass of the second outgoing particle.
0191    * @param m3 The mass of the third  outgoing particle.
0192    * @return The matrix element
0193    */
0194   virtual double threeBodyMatrixElement(const int imode,  const Energy2 q2,
0195                     const Energy2 s3, const Energy2 s2, 
0196                     const Energy2 s1, const Energy  m1, 
0197                     const Energy  m2, const Energy  m3) const;
0198   
0199   /**
0200    * The differential three body decay rate with one integral performed.
0201    * @param imode The mode for which the matrix element is needed.
0202    * @param q2 The scale, \e i.e. the mass squared of the decaying particle.
0203    * @param s  The invariant mass which still needs to be integrate over.
0204    * @param m1 The mass of the first  outgoing particle.
0205    * @param m2 The mass of the second outgoing particle.
0206    * @param m3 The mass of the third  outgoing particle.
0207    * @return The differential rate \f$\frac{d\Gamma}{ds}\f$
0208    */
0209   virtual InvEnergy threeBodydGammads(const int imode, const Energy2 q2,
0210                       const Energy2 s,
0211                       const Energy m1, const Energy m2, 
0212                       const Energy m3) const;
0213 
0214   /**
0215    * Finds the phase-space mode corresponding to a given decay mode
0216    * @param dm The DecayMode
0217    */
0218   int findMode(const DecayMode & dm);
0219   
0220 public:
0221 
0222   /**
0223    *  Members for the generation of QED radiation in the decays
0224    */
0225   //@{
0226   /**
0227    * Use the DecayRadiationGenerator to generate photons in the decay.
0228    * @param p The Particle instance being decayed
0229    * @param children The decay products
0230    * @return A particle vector containing the decay products after the generation
0231    * of photons.
0232    */
0233   ParticleVector generatePhotons(const Particle & p,ParticleVector children) {
0234     return photonGen_->generatePhotons(p,children,this);
0235   }
0236 
0237   /**
0238    *  check if photons can be generated in the decay
0239    */
0240   bool canGeneratePhotons() {return photonGen_;}
0241 
0242   /**
0243    *  The one-loop virtual correction.
0244    * @param imode The mode required.
0245    * @param part  The decaying particle.
0246    * @param products The decay products including the radiated photon.
0247    * @return Whether the correction is implemented
0248    */
0249   virtual double oneLoopVirtualME(unsigned int imode,
0250                   const Particle & part, 
0251                   const ParticleVector & products);
0252 
0253   /**
0254    *  Whether or not the one loop matrix element is implemented
0255    */
0256   bool hasOneLoopME() {return virtualME_;}
0257   
0258   /**
0259    *  The real emission matrix element
0260    * @param imode The mode required
0261    * @param part  The decaying particle
0262    * @param products The decay products including the radiated photon
0263    * @param iemitter The particle which emitted the photon
0264    * @param ctheta   The cosine of the polar angle between the photon and the
0265    *                 emitter
0266    * @param stheta   The sine of the polar angle between the photon and the
0267    *                 emitter 
0268    * @param rot1 Rotation from rest frame to frame for real emission
0269    * @param rot2 Rotation to place emitting particle along z
0270    */
0271   virtual InvEnergy2 realEmissionME(unsigned int imode,
0272                     const Particle & part, 
0273                     ParticleVector & products,
0274                     unsigned int iemitter,
0275                     double ctheta, double stheta,
0276                     const LorentzRotation & rot1,
0277                     const LorentzRotation & rot2);
0278 
0279   /**
0280    *  Whether or not the real emission matrix element is implemented
0281    */
0282   bool hasRealEmissionME() {return realME_;}
0283   //@}
0284   
0285 public:
0286 
0287   /**
0288    *  The output operator is a friend, this is mainly for debugging
0289    */    
0290   friend ostream & operator<<(ostream & os, const DecayIntegrator & decay);
0291 
0292   
0293 public:
0294 
0295   /** @name Functions used by the persistent I/O system. */
0296   //@{
0297   /**
0298    * Function used to write out object persistently.
0299    * @param os the persistent output stream written to.
0300    */
0301   void persistentOutput(PersistentOStream & os) const;
0302 
0303   /**
0304    * Function used to read in object persistently.
0305    * @param is the persistent input stream read from.
0306    * @param version the version number of the object when written.
0307    */
0308   void persistentInput(PersistentIStream & is, int version);
0309   //@}
0310 
0311   /**
0312    * The standard Init function used to initialize the interfaces.
0313    * Called exactly once for each class by the class description system
0314    * before the main function starts or
0315    * when this class is dynamically loaded.
0316    */
0317   static void Init();
0318 
0319   
0320 protected:
0321 
0322   /** @name Standard Interfaced functions. */
0323   //@{
0324   /**
0325    * Initialize this object. Called in the run phase just before
0326    * a run begins.
0327    */
0328   virtual void doinitrun();
0329   //@}
0330 
0331 protected:
0332 
0333   /**
0334    * Generate the momenta for the decay
0335    * @param inter Generate the intermediates produced in the decay as well as the
0336    * final particles.
0337    * @param cc Is this the mode defined or its charge conjugate.
0338    * @param imode The mode being generated.
0339    * @param inpart The decaying particle.
0340    * @return The particles produced inthe decay.
0341    */
0342   ParticleVector generate(bool inter,bool cc, const unsigned int & imode,
0343               const Particle & inpart) const;
0344 
0345   /**
0346    * Set the mode being use for this decay.
0347    */
0348   void imode(int in) { iMode_ = in;}
0349   
0350   /**
0351    * Set the helicity matrix element for the decay.
0352    */
0353   void ME(DecayMEPtr in) const { matrixElement_ = in;}
0354   
0355   /**
0356    * The helicity amplitude matrix element for spin correlations.
0357    */
0358   DecayMEPtr ME() const {return matrixElement_;}
0359    
0360   /**
0361    * Reset the properities of all intermediates.
0362    * @param part The intermediate particle being reset.
0363    * @param mass The mass of the particle.
0364    * @param width The width of the particle.
0365    */
0366   void resetIntermediate(tcPDPtr part, Energy mass, Energy width);
0367 
0368   /**
0369    * Initialize the phase-space mode
0370    * @param imode The mode
0371    * @param init Whether or not to perform the initialization
0372    */
0373   Energy initializePhaseSpaceMode(unsigned int imode,bool init, bool onShell=false) const;
0374   
0375 protected:
0376   
0377   /**
0378    *    Methods to set variables in inheriting classes
0379    */
0380   //@{
0381   /**
0382    * Set whether or not the intermediates are included 
0383    */ 
0384   void generateIntermediates(bool in) {generateInter_=in;}
0385 
0386   /**
0387    * Set whether or not the intermediates are included 
0388    */ 
0389   bool generateIntermediates() const {return generateInter_;}
0390   
0391   /**
0392    *  Whether or not the one loop matrix element is implemented
0393    */
0394   void hasOneLoopME(bool in) {virtualME_=in;}
0395 
0396   /**
0397    *  Whether or not the real emission matrix element is implemented
0398    */
0399   void hasRealEmissionME(bool in) {realME_=in;}
0400 
0401   /**
0402    * Set the epsilon parameter
0403    */
0404   void epsilonPS(Energy in) {eps_=in;}
0405 
0406   /**
0407    *  Clear the models
0408    */
0409   void clearModes() {modes_.clear();}
0410 
0411 protected:
0412   
0413   /**
0414    * Number of decay modes
0415    */
0416   unsigned int numberModes() const {return modes_.size();}
0417 
0418   /**
0419    * Pointer to a mode
0420    */
0421   tPhaseSpaceModePtr mode(unsigned int ix) {
0422     return modes_[ix];
0423   }
0424   /**
0425    * Pointer to a mode
0426    */
0427   tcPhaseSpaceModePtr mode(unsigned int ix) const {
0428     return modes_[ix];
0429   }
0430   
0431 public:
0432 
0433 bool warnings() const {
0434   return warnings_;
0435 }
0436 
0437 private:
0438 
0439   /**
0440    * Private and non-existent assignment operator.
0441    */
0442   DecayIntegrator & operator=(const DecayIntegrator &) = delete;
0443 
0444   /**
0445    *  Parameters for the integration
0446    */
0447   //@{
0448   /**
0449    * Number of iterations for th initialization.
0450    */
0451   unsigned int nIter_;
0452 
0453   /**
0454    * Number of points for initialisation
0455    */
0456   unsigned int nPoint_;
0457 
0458   /**
0459    * number of attempts to generate the decay
0460    */
0461   unsigned int nTry_;
0462   
0463   /**
0464    * List of the decay modes
0465    */
0466   mutable vector<PhaseSpaceModePtr> modes_;
0467 
0468   //@}
0469   
0470   /**
0471    *  Whether to include the intermediates whne outputing the results.
0472    */
0473   bool generateInter_;
0474   
0475   /**
0476    *  Pointer to the object generating the QED radiation in the decay
0477    */
0478   DecayRadiationGeneratorPtr photonGen_;
0479 
0480   /**
0481    * mode currently being generated  
0482    */
0483   mutable int iMode_;
0484 
0485   /**
0486    * The helicity matrix element for the current decay
0487    */
0488   mutable DecayMEPtr matrixElement_;
0489 
0490   /**
0491    *  Whether or not the real photon emission matrix element exists
0492    */
0493   bool realME_;
0494 
0495   /**
0496    *  Whether or not the one-loop matrix element exists
0497    */
0498   bool virtualME_;
0499 
0500   /**
0501    *   Epsilon parameter for phase-space integration
0502    */
0503   Energy eps_;
0504 
0505   /**
0506    * option for turinh on/off log warnings in Phase class
0507    */
0508   bool warnings_;
0509 
0510 protected:
0511 
0512   /**
0513    * Exception for this class and those inheriting from it
0514    */
0515   class DecayIntegratorError: public Exception {};
0516 
0517 };
0518   
0519 /**
0520  * Output information on the DecayIntegrator for debugging purposes
0521  */
0522 ostream & operator<<(ostream &, const DecayIntegrator &);
0523 
0524 }
0525 
0526 #endif /* Herwig_DecayIntegrator_H */