Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // -*- C++ -*-
0002 //
0003 // GeneralTwoBodyDecayer.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_GeneralTwoBodyDecayer_H
0010 #define HERWIG_GeneralTwoBodyDecayer_H
0011 //
0012 // This is the declaration of the GeneralTwoBodyDecayer class.
0013 //
0014 
0015 #include "Herwig/Decay/PerturbativeDecayer.h"
0016 #include "Herwig/Decay/PhaseSpaceMode.h"
0017 #include "ThePEG/Helicity/Vertex/VertexBase.h"
0018 #include "GeneralTwoBodyDecayer.fh"
0019 
0020 namespace Herwig {
0021 using namespace ThePEG;
0022 using Helicity::VertexBasePtr;
0023 
0024 /** \ingroup Decay
0025  * The GeneralTwoBodyDecayer class is designed to be the base class 
0026  * for 2 body decays for some general model. It inherits from 
0027  * PerturbativeDecayer and implements the modeNumber() virtual function
0028  * that is the  same for all of the decays. A decayer for
0029  * a specific spin configuration should inherit from this and implement
0030  * the me2() and partialWidth() member functions. The colourConnections()
0031  * member should be called from inside me2() in the inheriting decayer
0032  * to set up the colour lines.
0033  *
0034  * @see \ref GeneralTwoBodyDecayerInterfaces "The interfaces"
0035  * defined for GeneralTwoBodyDecayer.
0036  * @see PerturbativeDecayer
0037  */
0038 class GeneralTwoBodyDecayer: public PerturbativeDecayer {
0039 
0040 public:
0041   
0042   /** A ParticleData ptr and (possible) mass pair.*/
0043   typedef pair<tcPDPtr, Energy> PMPair;
0044 
0045 public:
0046 
0047   /**
0048    * The default constructor.
0049    */
0050   GeneralTwoBodyDecayer() : maxWeight_(1.), colour_(1,DVector(1,1.))
0051   {}
0052 
0053 
0054   /** @name Virtual functions required by the Decayer2 class. */
0055   //@{
0056   /**
0057    * For a given decay mode and a given particle instance, perform the
0058    * decay and return the decay products. As this is the base class this
0059    * is not implemented.
0060    * @return The vector of particles produced in the decay.
0061    */
0062   virtual ParticleVector decay(const Particle & parent,
0063                    const tPDVector & children) const;
0064 
0065   /**
0066    * Which of the possible decays is required
0067    * @param cc Is this mode the charge conjugate
0068    * @param parent The decaying particle
0069    * @param children The decay products
0070    */
0071   virtual int modeNumber(bool & cc, tcPDPtr parent,const tPDVector & children) const;
0072   
0073   /**
0074    * Function to return partial Width
0075    * @param inpart The decaying particle.
0076    * @param outa One of the decay products.
0077    * @param outb The other decay product.
0078    */
0079   virtual Energy partialWidth(PMPair inpart, PMPair outa, 
0080                   PMPair outb) const;
0081 
0082   /**
0083    * Specify the \f$1\to2\f$ matrix element to be used in the running width 
0084    * calculation.
0085    * @param dm The DecayMode
0086    * @param mecode The code for the matrix element as described
0087    *               in the GenericWidthGenerator class.
0088    * @param coupling The coupling for the matrix element.
0089    * @return True if the the order of the particles in the 
0090    * decayer is the same as the DecayMode tag.
0091    */
0092   virtual bool twoBodyMEcode(const DecayMode & dm, int & mecode,
0093                  double & coupling) const;
0094 
0095   /**
0096    * An overidden member to calculate a branching ratio for a certain
0097    * particle instance.
0098    * @param dm The DecayMode of the particle
0099    * @param p The particle object
0100    * @param oldbrat The branching fraction given in the DecayMode object
0101    */
0102   virtual double brat(const DecayMode & dm, const Particle & p,
0103               double oldbrat) const;
0104   //@}
0105 
0106   /**
0107    *  Set the information on the decay
0108    */
0109   virtual void setDecayInfo(PDPtr incoming, PDPair outgoing,
0110                 vector<VertexBasePtr>,
0111                 map<ShowerInteraction,VertexBasePtr> &,
0112                 const vector<map<ShowerInteraction,VertexBasePtr> > &,
0113                 map<ShowerInteraction,VertexBasePtr>) =0;
0114 
0115 protected:
0116   
0117   /** @name Functions used by inheriting decayers. */
0118   //@{
0119   /**
0120    * Set integration weight
0121    * @param wgt Maximum integration weight 
0122    */
0123   void setWeight(double wgt) { maxWeight_ = wgt; }
0124 
0125   /**
0126    * Set colour connections
0127    * @param parent Parent particle
0128    * @param out Particle vector containing particles to 
0129    * connect colour lines
0130    */
0131   void colourConnections(const Particle & parent, 
0132              const ParticleVector & out) const;
0133 
0134   /**
0135    *  Compute the spin and colour factor
0136    */
0137   double colourFactor(tcPDPtr in, tcPDPtr out1, tcPDPtr out2) const;
0138 
0139   /**
0140    *  Calculate matrix element ratio R/B
0141    */
0142   double matrixElementRatio(const Particle & inpart, const ParticleVector & decay2,
0143                 const ParticleVector & decay3, MEOption meopt,
0144                 ShowerInteraction inter);
0145 
0146   /**
0147    *  Set the information on the decay
0148    */
0149   void decayInfo(PDPtr incoming, PDPair outgoing);
0150   //@}
0151 
0152 public:
0153 
0154   /** @name Functions used by the persistent I/O system. */
0155   //@{
0156   /**
0157    * Function used to write out object persistently.
0158    * @param os the persistent output stream written to.
0159    */
0160   void persistentOutput(PersistentOStream & os) const;
0161 
0162   /**
0163    * Function used to read in object persistently.
0164    * @param is the persistent input stream read from.
0165    * @param version the version number of the object when written.
0166    */
0167   void persistentInput(PersistentIStream & is, int version);
0168   //@}
0169 
0170   /**
0171    * The standard Init function used to initialize the interfaces.
0172    * Called exactly once for each class by the class description system
0173    * before the main function starts or
0174    * when this class is dynamically loaded.
0175    */
0176   static void Init();
0177 
0178 protected:
0179 
0180   /** @name Standard Interfaced functions. */
0181   //@{
0182   /**
0183    * Initialize this object after the setup phase before saving an
0184    * EventGenerator to disk.
0185    * @throws InitException if object could not be initialized properly.
0186    */
0187   virtual void doinit();
0188 
0189   /**
0190    * Initialize this object. Called in the run phase just before
0191    * a run begins.
0192    */
0193   virtual void doinitrun();
0194   //@}
0195 
0196 protected:
0197 
0198   /**
0199    *  Member for the generation of additional hard radiation
0200    */
0201   //@{
0202   /**
0203    * Return the matrix of colour factors 
0204    */
0205   typedef vector<pair<int,double > > CFlowPairVec;
0206   typedef vector<CFlowPairVec> CFlow;
0207 
0208   const vector<DVector> & getColourFactors(const Particle & inpart, 
0209                        const ParticleVector & decay, 
0210                        unsigned int & nflow); 
0211  
0212   const CFlow & colourFlows(const Particle & inpart,
0213                 const ParticleVector & decay);
0214 
0215   /**
0216    *  Three-body matrix element including additional QCD radiation
0217    */
0218   virtual double threeBodyME(const int , const Particle & inpart,
0219                  const ParticleVector & decay,
0220                  ShowerInteraction inter, MEOption meopt);
0221 
0222   //@}
0223 
0224 private:
0225 
0226   /**
0227    * The assignment operator is private and must never be called.
0228    * In fact, it should not even be implemented.
0229    */
0230   GeneralTwoBodyDecayer & operator=(const GeneralTwoBodyDecayer &) = delete;
0231  
0232 private:
0233 
0234   /**
0235    *  Store the incoming particle
0236    */
0237   PDPtr incoming_;
0238 
0239   /**
0240    *  Outgoing particles
0241    */
0242   vector<PDPtr> outgoing_;
0243 
0244   /**
0245    * Maximum weight for integration
0246    */
0247   double maxWeight_;
0248 
0249   /**
0250    * Store colour factors for ME calc.
0251    */
0252   vector<DVector> colour_;
0253 
0254 };
0255 
0256 
0257 /**
0258  * Write a map with ShowerInteraction as the key
0259  */
0260 template<typename T, typename Cmp, typename A>
0261 inline PersistentOStream & operator<<(PersistentOStream & os,
0262                       const map<ShowerInteraction,T,Cmp,A> & m) {
0263   os << m.size();
0264   if(m.find(ShowerInteraction::QCD)!=m.end()) {
0265     os << 0 << m.at(ShowerInteraction::QCD);
0266   }
0267   if(m.find(ShowerInteraction::QED)!=m.end()) {
0268     os << 1 << m.at(ShowerInteraction::QED);
0269   }
0270   return os;
0271 }
0272 
0273 /**
0274  * Read a map with ShowerInteraction as the key
0275  */
0276 template <typename T, typename Cmp, typename A>
0277 inline PersistentIStream & operator>>(PersistentIStream & is, map<ShowerInteraction,T,Cmp,A> & m) {
0278   m.clear();
0279   long size;
0280   int k;
0281   is >> size;
0282   while ( size-- && is ) {
0283     is >> k;
0284     if(k==0)
0285       is >> m[ShowerInteraction::QCD];
0286     else if(k==1)
0287       is >> m[ShowerInteraction::QED];
0288     else
0289       assert(false);
0290   }
0291   return is;
0292 }
0293 }
0294 
0295 #endif /* HERWIG_GeneralTwoBodyDecayer_H */