Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // -*- C++ -*-
0002 //
0003 // FFDipole.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_FFDipole_H
0010 #define HERWIG_FFDipole_H
0011 //
0012 // This is the declaration of the FFDipole class.
0013 //
0014 
0015 #include "ThePEG/Repository/EventGenerator.h"
0016 #include "Herwig/Decay/DecayIntegrator.fh"
0017 #include "Herwig/Utilities/Kinematics.h"
0018 #include "Herwig/Utilities/Maths.h"
0019 #include "ThePEG/StandardModel/StandardModelBase.h"
0020 #include "ThePEG/Vectors/Lorentz5Vector.h"
0021 #include "ThePEG/Interface/Interfaced.h"
0022 #include "FFDipole.fh"
0023 
0024 namespace Herwig {
0025 using namespace ThePEG;
0026 using ThePEG::Constants::pi;
0027 
0028 /** \ingroup Decay
0029  *
0030  * The FFDipole class generates radiation from a final-final dipole for
0031  * the generation of photons in decay by the SOPTHY algorithm.
0032  * 
0033  * @see SOPTHY 
0034  * @see \ref FFDipoleInterfaces "The interfaces"
0035  * defined for FFDipole.
0036 
0037  */
0038 class FFDipole: public Interfaced {
0039 
0040 public:
0041 
0042   /**
0043    * The default constructor.
0044    */
0045   FFDipole() :
0046     _emin(1.e-6*MeV), _eminrest(100*MeV), _eminlab(100*MeV), _emax(),
0047     _multiplicity(), _m(3), _charge(), _qdrf(2),
0048     _qnewdrf(2), _qprf(2), _qnewprf(2), _qlab(2), _qnewlab(2), _dipolewgt(),
0049     _yfswgt(), _jacobianwgt(), _mewgt(), _maxwgt(7.0), _mode(1), _maxtry(500),
0050     _energyopt(1), _betaopt(4), _dipoleopt(), _nweight(0), _wgtsum(0.), _wgtsq(0.),
0051     _weightOutput(false) {}
0052 
0053 public:
0054 
0055   /**
0056    * Member to generate the photons from the dipole
0057    * @param p The decaying particle
0058    * @param children The decay products
0059    * @param decayer The decayer for this mode
0060    * @return The decay products with additional radiation
0061    */
0062   virtual ParticleVector generatePhotons(const Particle & p,
0063                      ParticleVector children,
0064                      tDecayIntegratorPtr decayer);
0065 
0066 public:
0067 
0068   /** @name Functions used by the persistent I/O system. */
0069   //@{
0070   /**
0071    * Function used to write out object persistently.
0072    * @param os the persistent output stream written to.
0073    */
0074   void persistentOutput(PersistentOStream & os) const;
0075 
0076   /**
0077    * Function used to read in object persistently.
0078    * @param is the persistent input stream read from.
0079    * @param version the version number of the object when written.
0080    */
0081   void persistentInput(PersistentIStream & is, int version);
0082   //@}
0083 
0084   /**
0085    * The standard Init function used to initialize the interfaces.
0086    * Called exactly once for each class by the class description system
0087    * before the main function starts or
0088    * when this class is dynamically loaded.
0089    */
0090   static void Init();
0091 
0092 protected:
0093 
0094   /** @name Clone Methods. */
0095   //@{
0096   /**
0097    * Make a simple clone of this object.
0098    * @return a pointer to the new object.
0099    */
0100   virtual IBPtr clone() const {return new_ptr(*this);}
0101 
0102   /** Make a clone of this object, possibly modifying the cloned object
0103    * to make it sane.
0104    * @return a pointer to the new object.
0105    */
0106   virtual IBPtr fullclone() const {return new_ptr(*this);}
0107   //@}
0108 
0109 protected:
0110 
0111   /**
0112    * Generate the momentum of a photon 
0113    * @param beta1 The velocity, \f$\beta_1\f$, of the first charged particle
0114    * @param ombeta1 One minus the velocity, \f$1-\beta_1\f$, of the first 
0115    * charged particle which is supplied for numerical stability
0116    * @param beta2 The velocity, \f$\beta_2\f$, of the second charged particle
0117    * @param ombeta2 One minus the velocity, \f$1-\beta_2\f$, of the 
0118    * second charged particle which is supplied for numerical stability
0119    * @return The contribution to the dipole weight
0120    */
0121   double photon(double beta1,double ombeta1, double beta2, double ombeta2);
0122 
0123   /**
0124    * Calculate the exact weight for the dipole.
0125    * @param beta1 Velocity of the first charged particle, \f$\beta_1\f$
0126    * @param beta2 Velocity of the second charged particle, \f$\beta_2\f$.
0127    * @param ombeta1 One minus the velocity of the first particle,  \f$1-\beta_1\f$
0128    * @param ombeta2 One minus the velocity of the second particle,  \f$1-\beta_2\f$
0129    * @param iphot The number of the photon for which the weight is required
0130    * @return The weight
0131    */
0132   double exactDipoleWeight(double beta1,double ombeta1,
0133                double beta2,double ombeta2,unsigned int iphot) {
0134     double opbc,ombc;
0135     // if cos is greater than zero use result accurate as cos->1
0136     if(_cosphot[iphot]>0) {
0137       opbc=1.+beta2*_cosphot[iphot];
0138       ombc=ombeta1+beta1*sqr(_sinphot[iphot])/(1.+_cosphot[iphot]);
0139     }
0140     // if cos is less    than zero use result accurate as cos->-1
0141     else {
0142       opbc=ombeta2+beta2*sqr(_sinphot[iphot])/(1.-_cosphot[iphot]);
0143       ombc=1.-beta1*_cosphot[iphot];
0144     }
0145     return 0.5/(opbc*ombc)*(1.+beta1*beta2
0146                 -0.5*ombeta1*(1.+beta1)*opbc/ombc        
0147                 -0.5*ombeta2*(1.+beta2)*ombc/opbc);
0148   }
0149   
0150   /**
0151    * Jacobian factor for the weight
0152    */
0153   double jacobianWeight() {
0154     Energy pcm1=Kinematics::pstarTwoBodyDecay(_m[0],_m[1],_m[2]);
0155     Energy m12 =sqrt((_qnewdrf[0]+_qnewdrf[1]).m2())            ;
0156     Energy pcm2=Kinematics::pstarTwoBodyDecay(m12,_m[1],_m[2])  ;
0157     double betaprobeta = pcm2*_m[0]/pcm1/m12   ;
0158     double spros       = sqr(m12/_m[0])        ;
0159     double deltafn     = m12/(m12+_bigLdrf.e());
0160     return betaprobeta*spros*deltafn           ;
0161   }
0162 
0163   /**
0164    * Matrix element weight
0165    */
0166   double meWeight(const ParticleVector & children);
0167 
0168   /**
0169    * Member which generates the photons
0170    * @param boost Boost vector to take the particles produced back from
0171    * the decaying particle's rest frame to the lab
0172    * @param children The decay products
0173    */
0174   double makePhotons(const Boost & boost, 
0175              const ParticleVector & children);
0176 
0177   /**
0178    *  Boost all the momenta from the dipole rest frame via the parent rest frame
0179    * to the lab
0180    * @param boost The boost vector from the rest frame to the lab
0181    * @return Whether or not it suceeded
0182    */
0183   bool boostMomenta(const Boost & boost);
0184 
0185   /**
0186    *  Remove any photons which fail the energy cuts
0187    * @return Number of photons removed
0188    */
0189   unsigned int removePhotons();
0190 
0191   /**
0192    *  The real emission weight in the collinear limit
0193    */
0194   double collinearWeight(const ParticleVector & children);
0195 
0196   /**
0197    *  The vrtiual correction weight
0198    */
0199   double virtualWeight(const ParticleVector & children);
0200 
0201 protected:
0202 
0203   /** @name Standard Interfaced functions. */
0204   //@{
0205   /**
0206    * Finalize this object. Called in the run phase just after a
0207    * run has ended. Used eg. to write out statistics.
0208    */
0209   virtual void dofinish();
0210   //@}
0211 
0212 private:
0213 
0214   /**
0215    * The assignment operator is private and must never be called.
0216    * In fact, it should not even be implemented.
0217    */
0218   FFDipole & operator=(const FFDipole &) = delete;
0219 
0220 private:
0221 
0222   /**
0223    * Debug output
0224    **/
0225   void printDebugInfo(const Particle & p,
0226               const ParticleVector & children,
0227               double wgt) const;
0228 
0229 private:
0230 
0231   /**
0232    *  The minimum photon energy in the boosted frame
0233    */
0234   Energy _emin;
0235 
0236   /**
0237    *  The minimum photon energy in the rest frame
0238    */
0239   Energy _eminrest;
0240 
0241   /**
0242    *  The minimum photon energy in the lab  frame
0243    */
0244   Energy _eminlab;
0245 
0246   /**
0247    *  The maximum photon energy
0248    */
0249   Energy _emax;
0250 
0251   /**
0252    *  Photon multiplicity being generated
0253    */
0254   unsigned int _multiplicity;
0255 
0256   /**
0257    *  Masses of the particles involved
0258    */
0259   vector<Energy> _m;
0260 
0261   /**
0262    *  Produce of the particles charges
0263    */
0264   double _charge;
0265 
0266   /**
0267    *   Momenta of the particles in the dipole rest frame
0268    */
0269   //@{
0270   /**
0271    *  Momenta of the charged particles in the dipole rest frame before radiation
0272    */
0273   vector<Lorentz5Momentum> _qdrf;
0274 
0275   /**   *  Momenta of the charged particles in the dipole rest frame after radiation
0276    */
0277   vector<Lorentz5Momentum> _qnewdrf;
0278 
0279   /**
0280    *  Momenta of the photons in the dipole rest frame
0281    */
0282   vector<Lorentz5Momentum> _ldrf;
0283 
0284   /**
0285    * Total momentum of the photons in the dipole rest frame
0286    */
0287   Lorentz5Momentum _bigLdrf;
0288   //@}
0289 
0290   /**
0291    *  Momentum of the particles in the parent's rest frame
0292    */
0293   //@{
0294   /**
0295    *  Momenta of the charged particles in the parent's rest frame before radiation
0296    */
0297   vector<Lorentz5Momentum> _qprf;
0298 
0299   /**
0300    *  Momenta of the charged particles in the parent's rest frame after radiation
0301    */
0302   vector<Lorentz5Momentum> _qnewprf;
0303 
0304   /**
0305    *  Momenta of the photons in the parent rest frame
0306    */
0307   vector<Lorentz5Momentum> _lprf;
0308 
0309   /**
0310    * Total momentum of the photons in the parent rest frame
0311    */
0312   Lorentz5Momentum _bigLprf;
0313   //@}
0314 
0315   /**
0316    *  Momentum of the particles in the lab frame
0317    */
0318   //@{
0319   /**
0320    *  Momenta of the charged particles in the lab frame before radiation
0321    */
0322   vector<Lorentz5Momentum> _qlab;
0323   
0324   /**
0325    *  Momenta of the charged particles in the lab frame after  radiation
0326    */
0327   vector<Lorentz5Momentum> _qnewlab;
0328 
0329   /**
0330    *  Momenta of the photons in the lab frame
0331    */
0332   vector<Lorentz5Momentum> _llab;
0333 
0334   /**
0335    * Total momentum of the photons in the lab frame
0336    */
0337   Lorentz5Momentum _bigLlab;
0338   //@}
0339 
0340 
0341   /**
0342    *  Reweighting factors due to differences between the true and crude
0343    *  distributions
0344    */
0345   //@{
0346   /**
0347    *  Reweighting factor for the real emission
0348    */
0349   double _dipolewgt;
0350 
0351   /**
0352    *  Reweighting factor for the YFS form-factor
0353    */
0354   double _yfswgt;
0355 
0356   /**
0357    *  Reweighting factor due to phase space
0358    */
0359   double _jacobianwgt;
0360 
0361   /**
0362    *  Reweighting factor due to matrix element corrections
0363    */
0364   double _mewgt;
0365 
0366   /**
0367    *  Maximum weight
0368    */
0369   double _maxwgt;
0370   //@}
0371 
0372   /**
0373    *  Angles of the photons with respect to the first charged particle
0374    * which are stored for numerical accuracy
0375    */
0376   //@{
0377   /**
0378    *  Cosine of the photon angles
0379    */
0380   vector<double> _cosphot;
0381 
0382   /**
0383    *  Sine of the photon angles
0384    */
0385   vector<double> _sinphot;
0386   //@}
0387 
0388   /**
0389    *  Weights for the individual photons
0390    */
0391   vector<double> _photonwgt;
0392 
0393   /**
0394    *  Whether a given photon passes the energy cut
0395    */
0396   vector<bool> _photcut;
0397 
0398   /**
0399    *  Type of unweighting to perform
0400    */
0401   unsigned int _mode;
0402 
0403   /**
0404    *  Maximum number of attempts to generate a result
0405    */
0406   unsigned int _maxtry;
0407 
0408   /**
0409    *  Option for the energy cut-off
0410    */
0411   unsigned int _energyopt;
0412 
0413   /**
0414    *  Option for the inclusion of higher order corrections
0415    */
0416   unsigned int _betaopt;
0417 
0418   /**
0419    *  Option for the form of the primary distribution
0420    */
0421   unsigned int _dipoleopt;
0422 
0423   /**
0424    *  The decayer
0425    */
0426   tDecayIntegratorPtr _decayer;
0427 
0428   /**
0429    *  The decaying particle
0430    */
0431   tPPtr _parent;
0432 
0433   /**
0434    *  Storage of averages etc for testing
0435    */
0436   //@{
0437   /**
0438    *  Number of attempts
0439    */
0440   unsigned int _nweight;
0441 
0442   /**
0443    *  Sum of weights
0444    */
0445   double _wgtsum;
0446 
0447   /**
0448    *  Sum of squares of weights
0449    */
0450   double _wgtsq;
0451 
0452   /**
0453    *  Whether or not to output the averages
0454    */
0455   bool _weightOutput;
0456   //@}
0457 };
0458 
0459 }
0460 
0461 #endif /* HERWIG_FFDipole_H */