Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // -*- C++ -*-
0002 //
0003 // SimplePhaseSpace.h is a part of ThePEG - Toolkit for HEP Event Generation
0004 // Copyright (C) 1999-2019 Leif Lonnblad
0005 //
0006 // ThePEG 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 ThePEG_SimplePhaseSpace_H
0010 #define ThePEG_SimplePhaseSpace_H
0011 
0012 #include "ThePEG/Config/ThePEG.h"
0013 
0014 #include "ThePEG/Vectors/LorentzRotation.h"
0015 #include "ThePEG/Vectors/LorentzRotation.h"
0016 #include "ThePEG/EventRecord/Particle.h"
0017 #include "ThePEG/EventRecord/ParticleTraits.h"
0018 #include "ThePEG/Repository/UseRandom.h"
0019 #include "SimplePhaseSpace.xh"
0020 #include <numeric>
0021 
0022 namespace ThePEG {
0023 
0024 /**
0025  * SimplePhaseSpace defines a set of static functions to be used for
0026  * distributing momenta evenly in phase space. In most cases pointers
0027  * and references to both particle and momentum objects can be used as
0028  * arguments as long as the ParticleTraits class is specialized
0029  * properly. When needed, random numbers are generated with the
0030  * generator given by the static UseRandom class.
0031  */
0032 namespace SimplePhaseSpace {
0033 
0034   /**
0035    * Set two momenta in their center of mass system. Their total
0036    * invariant mass squared is given by s, and their direction is
0037    * distributed isotropically.
0038    * @param s the total invariant mass squared.
0039    * @param p1 pointer or reference to the first momentum. Its
0040    * invariant mass will be preserved.
0041    * @param p2 pointer or reference to the second momentum. Its
0042    * invariant mass will be preserved.
0043    * @throw ImpossibleKinematics if the sum of the invariant masses was
0044    * larger than the given invariant mass (\f$\sqrt{s}\f$).
0045    */
0046   template <typename PType>
0047   void CMS(Energy2 s, PType & p1, PType & p2);
0048 
0049   /**
0050    * Set two momenta in their center of mass system. Their total
0051    * invariant mass squared is given by s, and their direction is
0052    * given in terms of the polar and azimuth angle of the first
0053    * momenta.
0054    * @param s the total invariant mass squared.
0055    * @param p1 pointer or reference to the first momentum. Its
0056    * invariant mass will be preserved.
0057    * @param p2 pointer or reference to the second momentum. Its
0058    * invariant mass will be preserved.
0059    * @param cosTheta cosine of the azimuth angle of the first momentum.
0060    * @param phi azimuth angle of the first momentum.
0061    * @throw ImpossibleKinematics if the sum of the invariant masses was
0062    * larger than the given invariant mass (\f$\sqrt{s}\f$).
0063    */
0064   template <typename PType>
0065   void CMS(PType & p1, PType & p2, Energy2 s,
0066           double cosTheta, double phi);
0067 
0068   /**
0069    * Set two momenta in their center of mass system. Their total
0070    * invariant mass squared is given by s. The helper momentum p0 is
0071    * used so that afterwards \f$t=(p0-p1)^2\f$ and p1 has the azimuth
0072    * angle phi around p0.
0073    * @param p1 pointer or reference to the first momentum. Its
0074    * invariant mass will be preserved.
0075    * @param p2 pointer or reference to the second momentum. Its
0076    * invariant mass will be preserved.
0077    * @param s the total invariant mass squared.
0078    * @param t \f$=(p0-p1)^2\f$.
0079    * @param phi azimuth angle of the first momentum around p0.
0080    * @param p0 pointer or reference to an auxiliary momentum.
0081    * @throw ImpossibleKinematics if the sum of the invariant masses was
0082    * larger than the given invariant mass (\f$\sqrt{s}\f$).
0083    */
0084   template <typename PType>
0085   void CMS(PType & p1, PType & p2, Energy2 s, Energy2 t, double phi,
0086           const PType & p0);
0087 
0088   /**
0089    * Set two momenta in their center of mass system. Their total
0090    * invariant mass squared is given by s. p1 will be along the z-axis.
0091    * @param p1 pointer or reference to the first momentum. Its
0092    * invariant mass will be preserved.
0093    * @param p2 pointer or reference to the second momentum. Its
0094    * invariant mass will be preserved.
0095    * @param s the total invariant mass squared.
0096    * @throw ImpossibleKinematics if the sum of the invariant masses was
0097    * larger than the given invariant mass (\f$\sqrt{s}\f$).
0098    */
0099   template <typename PType>
0100   void CMS(PType & p1, PType & p2, Energy2 s);
0101 
0102   /**
0103    * Set two momenta in their center of mass system. Their total
0104    * invariant mass squared is given by s. The first will be along the
0105    * z-axis.
0106    * @param p a pair of pointers or references to the two momenta. Their
0107    * invariant masses will be preserved.
0108    * @param s the total invariant mass squared.
0109    * @throw ImpossibleKinematics if the sum of the invariant masses was
0110    * larger than the given invariant mass (\f$\sqrt{s}\f$).
0111    */
0112   template <typename PPairType>
0113   void CMS(const PPairType & p, Energy2 s)
0114   {
0115     CMS(*p.first, *p.second, s);
0116   }
0117 
0118   /**
0119    * Set three momenta in their center of mass system. Their total
0120    * invariant mass squared is given by s. The energy fraction of
0121    * particle p1(3) is x1(3) of the total energy and the angles of the
0122    * system is distributed isotropically.
0123    * @param p1 pointer or reference to the first momentum. Its
0124    * invariant mass will be preserved.
0125    * @param p2 pointer or reference to the second momentum. Its
0126    * invariant mass will be preserved.
0127    * @param p3 pointer or reference to the second momentum. Its
0128    * invariant mass will be preserved.
0129    * @param s the total invariant mass squared.
0130    * @param x1 the energy fraction \f$2e_1/\sqrt{s}\f$.
0131    * @param x3 the energy fraction \f$2e_3/\sqrt{s}\f$.
0132    * @throw ImpossibleKinematics if the sum of the invariant masses was
0133    * larger than the given invariant mass (\f$\sqrt{s}\f$).
0134    */
0135   template <typename PType>
0136   void CMS(PType & p1, PType & p2, PType & p3, Energy2 s,
0137           double x1, double x3);
0138 
0139   /**
0140    * Set three momenta in their center of mass system. Their total
0141    * invariant mass squared is given by s. The energy fraction of
0142    * particle p1(3) is x1(3) of the total energy. Particle p1 is
0143    * initially placed along the z-axis and particle p2 is given
0144    * azimuth angle phii. Then the system is then rotated with
0145    * theta and phi respectively.
0146    * @param p1 pointer or reference to the first momentum. Its
0147    * invariant mass will be preserved.
0148    * @param p2 pointer or reference to the second momentum. Its
0149    * invariant mass will be preserved.
0150    * @param p3 pointer or reference to the second momentum. Its
0151    * invariant mass will be preserved.
0152    * @param s the total invariant mass squared.
0153    * @param x1 the energy fraction \f$2e_1/\sqrt{s}\f$.
0154    * @param x3 the energy fraction \f$2e_3/\sqrt{s}\f$.
0155    * @param phii the azimuth angle of p2 around p1.
0156    * @param theta the polar angle of p1.
0157    * @param phi the azimuth angle of p1.
0158    * @throw ImpossibleKinematics if the sum of the invariant masses was
0159    * larger than the given invariant mass (\f$\sqrt{s}\f$).
0160    */
0161   template <typename PType>
0162   void CMS(PType & p1, PType & p2, PType & p3, Energy2 s,
0163           double x1, double x3, double phii = 0.0,
0164           double theta = 0.0, double phi = 0.0);
0165 
0166   /**
0167    * Calculate the absolute magnitude of the momenta of two particles
0168    * with masses m1 and m2 when put in their CMS of total invariant
0169    * mass squared s.
0170    * @param s the total invariant mass squared.
0171    * @param m1 the mass of particle 1.
0172    * @param m2 the mass of particle 2.
0173    * @throw ImpossibleKinematics if the sum of the masses was
0174    * larger than the given invariant mass (\f$\sqrt{s}\f$).
0175    */
0176   Energy getMagnitude(Energy2 s, Energy m1, Energy m2);
0177 
0178   /**
0179    * Calculate the absolute magnitude of the momenta of two particles
0180    * with masses m1 and m2 when put in their CMS of total invariant
0181    * mass squared s.
0182    * @param s the total invariant mass squared.
0183    * @param m1 the mass of particle 1.
0184    * @param m2 the mass of particle 2.
0185    * @return a negative value if the sum of the masses was
0186    * larger than the given invariant mass (\f$\sqrt{s}\f$).
0187    */
0188 //  static Energy checkMagnitude(Energy2 s, Energy m1, Energy m2);
0189 
0190   /**
0191    * Return a three-vector given the absolute momentum, cos(theta) and
0192    * phi.
0193    * @param p the magnitude of the momentum.
0194    * @param costheta the cosine of the polar angle.
0195    * @param phi the azimuth angle.
0196    */
0197   inline Momentum3 polar3Vector(Energy p, double costheta, double phi)
0198   {
0199     return Momentum3(p*sqrt(1.0 - sqr(costheta))*sin(phi),
0200              p*sqrt(1.0 - sqr(costheta))*cos(phi),
0201              p*costheta);
0202   }
0203 
0204   /**
0205    * Get a number of randomly distributed momenta.
0206    * Given a number specified invariant masses and a
0207    * total invariant mass m0, return corresponding four-momenta
0208    * randomly distributed according to phase space. 
0209    * @param m0 the
0210    * total invariant mass of the resulting momenta.
0211    * @param m a vector
0212    * of invariant masses of the resulting momenta.
0213    * @return a vector
0214    * of momenta with the given masses randomly distributed.
0215    * @throw ImpossibleKinematics if the sum of the masses was
0216    * larger than the given invariant mass (\f$\sqrt{s}\f$).
0217    */
0218   vector<LorentzMomentum>
0219   CMSn(Energy m0, const vector<Energy> & m);
0220 
0221   /**
0222    * Set the momentum of a number of particles. Given a number of
0223    * particles and a total invariant mass m0, distribute their
0224    * four-momenta randomly according to phase space.
0225    * @param particles a container of particles or pointers to
0226    * particles. The invariant mass of these particles will not be
0227    * chaned.
0228    * @param m0 the
0229    * total invariant mass of the resulting momenta.
0230    * @throw ImpossibleKinematics if the sum of the masses was
0231    * larger than the given invariant mass (\f$\sqrt{s}\f$).
0232    */
0233   template <typename Container>
0234   void CMSn(Container & particles, Energy m0);
0235 
0236 }
0237 
0238 }
0239 
0240 #ifndef ThePEG_TEMPLATES_IN_CC_FILE
0241 #include "SimplePhaseSpace.tcc"
0242 #endif
0243 
0244 #endif /* ThePEG_SimplePhaseSpace_H */