Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // -*- C++ -*-
0002 //
0003 // GenericWidthGenerator.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_GenericWidthGenerator_H
0010 #define HERWIG_GenericWidthGenerator_H
0011 //
0012 // This is the declaration of the GenericWidthGenerator class.
0013 //
0014 #include "ThePEG/PDT/WidthGenerator.h"
0015 #include "ThePEG/PDT/ParticleData.h"
0016 #include "ThePEG/PDT/DecayMode.h"
0017 #include "GenericWidthGenerator.fh"
0018 #include "Herwig/Decay/DecayIntegrator.h"
0019 #include "Herwig/Decay/PhaseSpaceMode.h"
0020 #include "Herwig/Utilities/Interpolator.h"
0021 #include "GenericMassGenerator.h"
0022 #include <iostream>
0023 
0024 namespace Herwig {
0025 using namespace ThePEG;
0026 
0027   /**
0028    *  Declare ModelGenerator class as must be friend to set the particle
0029    */
0030   class ModelGenerator;
0031 
0032   /**
0033    * Typedef to define a DecayMoap
0034    */
0035   typedef Selector<tDMPtr> DecayMap;
0036 
0037 
0038 /** \ingroup PDT
0039  *
0040  * The GenericWidthGenerator class is designed to automatically
0041  * calculate the running width for a given particle using information from
0042  * the decayModes and the Decayers to construct the running width.
0043  *
0044  * It also gives us the option of selecting the decay modes for a particle
0045  * based on the mass.
0046  *
0047  * @see WidthGenerator
0048  * @see DecayIntegrator
0049  * @see GenericMassGenerator
0050  */
0051 class GenericWidthGenerator: public WidthGenerator {
0052 
0053   /**
0054    *  ModelGenerator class as must be friend to set the particle
0055    */
0056   friend class ModelGenerator;
0057 
0058 public:
0059 
0060   /**
0061    * A friend class so the off-shell matrix elements can be integrated.
0062    */
0063   friend class TwoBodyAllOnCalculator;
0064 
0065 public:
0066 
0067   /**
0068    * Default constructor
0069    */
0070   GenericWidthGenerator()
0071     : mass_(), prefactor_(1.), initialize_(false),output_(false),
0072       BRnorm_(true),npoints_(50),
0073       BRminimum_(0.01), intOrder_(1), twoBodyOnly_(false)
0074   {}
0075 
0076   /** @name Functions used by the persistent I/O system. */
0077   //@{
0078   /**
0079    * Function used to write out object persistently.
0080    * @param os the persistent output stream written to.
0081    */
0082   void persistentOutput(PersistentOStream & os) const;
0083 
0084   /**
0085    * Function used to read in object persistently.
0086    * @param is the persistent input stream read from.
0087    * @param version the version number of the object when written.
0088    */
0089   void persistentInput(PersistentIStream & is, int version);
0090   //@}
0091 
0092   /**
0093    * Standard Init function used to initialize the interfaces.
0094    */
0095   static void Init();
0096 
0097 public:
0098 
0099   /**
0100    * Return true if this width generator can handle the given particle type.
0101    * @param part The particle data pointer of the particle.
0102    * @return True if this class can handle the particle and false otherwise
0103    */
0104   virtual bool accept(const ParticleData & part) const {
0105     if(!particle_) return false;
0106     return part.id() == particle_->id() ||
0107       ( part.CC() && part.CC()->id() == particle_->id() );
0108   }
0109 
0110   /** @name Members to calculate the width and decay modes. */
0111   //@{
0112   /**
0113    * Calculate the width.
0114    * @param part The particle data pointer of the particle.
0115    * @param m The scale for the width calculation
0116    * @return The width at the mass given.
0117    */
0118   virtual Energy width(const ParticleData & part, Energy m) const;
0119 
0120   /**
0121    * Initialize the given decay map for the given particle type.
0122    * @param part The particle data pointer of the particle.
0123    * @return The decay map
0124    */
0125   virtual DecayMap rate(const ParticleData & part) const {
0126     return part.decaySelector();
0127   }
0128 
0129   /**
0130    * Return a decay map for a given particle instance. This allows us to
0131    * vary the branching ratios as a function of the particles mass.
0132    * @param  part The particle instance
0133    * @return The decay map
0134    */
0135   virtual DecayMap rate (const Particle & part);
0136 
0137   /**
0138    * The partial width for a given mode
0139    * @param m The mass, or scale, for the calculation
0140    * @param iloc The location of the mode in the list
0141    * @return The partial width for the mode.
0142    */
0143   virtual Energy partialWidth(int iloc,Energy m) const;
0144 
0145   /**
0146    *  Return the total width and the sum of the partial widths for
0147    *  modes which are used
0148    */
0149   virtual pair<Energy,Energy> width(Energy, const ParticleData &) const;
0150   //@}
0151 
0152   /**
0153    * Output the initialisation info for the database
0154    * @param output The stream to output the information to
0155    * @param header output the header.
0156    **/
0157   virtual void dataBaseOutput(ofstream & output, bool header=true);
0158 
0159   /**
0160    * Given a particle type and a mass and a width of an instance of
0161    * that particle type, generate a life time.
0162    */
0163   virtual Length lifeTime(const ParticleData &, Energy m, Energy w) const;
0164 
0165 protected:
0166 
0167   /**
0168    * The \f$1\to2\f$ width for on-shell particles
0169    * @param q The mass, or scale, for the calculation
0170    * @param iloc The location of the mode in the list.
0171    * @return The partial width.
0172    */
0173   Energy partial2BodyWidth(int iloc,Energy q) const {
0174     return partial2BodyWidth(iloc,q,MEmass1_[iloc],MEmass2_[iloc]);
0175   }
0176 
0177   /**
0178    * The \f$1\to2\f$ width for outgoing particles which can be off-shell.
0179    * @param iloc The location of the mode in the list.
0180    * @param m0 The mass of the decaying particle.
0181    * @param m1 The mass of the first outgoing particle.
0182    * @param m2 The mass of the second outgoing particle.
0183    * @return The partial width.
0184    */
0185   virtual Energy partial2BodyWidth(int iloc,Energy m0,Energy m1,Energy m2) const;
0186 
0187   /**
0188    * Perform the set up for a mode in classes inheriting from this one
0189    * @param mode The decay mode
0190    * @param decayer The decayer for the mode.
0191    * @param imode The number of the mode.
0192    */
0193   virtual void setupMode(tcDMPtr mode, tDecayIntegratorPtr decayer, unsigned int imode);
0194 
0195   /**
0196    *  Access to the particle dat for inheriting classes
0197    */
0198   tPDPtr particle() const {return particle_;}
0199 
0200   /**
0201    * Set the particle
0202    */
0203   void particle(tPDPtr in) {particle_ = in;}
0204 
0205 protected:
0206 
0207   /** @name Clone Methods. */
0208   //@{
0209   /**
0210    * Make a simple clone of this object.
0211    * @return a pointer to the new object.
0212    */
0213   virtual IBPtr clone() const {return new_ptr(*this);}
0214 
0215   /** Make a clone of this object, possibly modifying the cloned object
0216    * to make it sane.
0217    * @return a pointer to the new object.
0218    */
0219   virtual IBPtr fullclone() const {return new_ptr(*this);}
0220   //@}
0221 
0222 protected:
0223 
0224   /** @name Standard Interfaced functions. */
0225   //@{
0226   /**
0227    * Initialize this object after the setup phase before saving and
0228    * EventGenerator to disk.
0229    * @throws InitException if object could not be initialized properly.
0230    */
0231   virtual void doinit();
0232 
0233   /**
0234    * Finalize this object. Called in the run phase just after a
0235    * run has ended. Used eg. to write out statistics.
0236    */
0237   virtual void dofinish();
0238 
0239   /**
0240    * Rebind pointer to other Interfaced objects. Called in the setup phase
0241    * after all objects used in an EventGenerator has been cloned so that
0242    * the pointers will refer to the cloned objects afterwards.
0243    * @param trans a TranslationMap relating the original objects to
0244    * their respective clones.
0245    * @throws RebindException if no cloned object was found for a given
0246    * pointer.
0247    */
0248   virtual void rebind(const TranslationMap & trans)
0249    ;
0250 
0251   /**
0252    * Return a vector of all pointers to Interfaced objects used in this
0253    * object.
0254    * @return a vector of pointers.
0255    */
0256   virtual IVector getReferences();
0257   //@}
0258 
0259   /**
0260    *  Matrix element code for a given mode 
0261    * @param imode The mode.
0262    */
0263   int MEcode(int imode) const {return MEcode_[imode];}
0264 
0265   /**
0266    *  Coupling for a given mode
0267    * @param imode The mode.
0268    */
0269   double MEcoupling(int imode) const {return MEcoupling_[imode];}
0270 
0271 
0272   /**
0273    *  The on-shell mass of the particle
0274    */
0275   Energy mass() const {return mass_;}
0276 
0277   /**
0278    *  Access to the decay modes
0279    */
0280 
0281   /**
0282    * Initialization option for use by the inheriting classes
0283    */
0284   bool initialize() const {return initialize_;}
0285 
0286   /**
0287    * Output option for use by the inheriting classes
0288    */
0289   bool output() const {return output_;}
0290 
0291   /**
0292    *  Access to the DecayModes
0293    */
0294   vector<tDMPtr> decayModes() const {return decayModes_;}
0295   
0296 private:
0297 
0298   /**
0299    * Helper function for the interface
0300    */
0301   void setParticle(string);
0302 
0303   /**
0304    * Helper function for the interface
0305    */
0306   string getParticle() const;
0307 
0308 private:
0309 
0310   /**
0311    * Private and non-existent assignment operator.
0312    */
0313   GenericWidthGenerator & operator=(const GenericWidthGenerator &) = delete;
0314 
0315 private:
0316 
0317   /**
0318    * The pointer to the ParticleData object for the particle for this width generator.
0319    */
0320   tPDPtr particle_;
0321 
0322   /**
0323    * The decaymodes
0324    */
0325   vector<tDMPtr> decayModes_;
0326 
0327   /**
0328    *  The tags for the DecayMode s
0329    */
0330   vector<string> decayTags_;
0331   
0332   /**
0333    *  The minimum mass of the decaying particle for which this decay mode is possible
0334    */
0335   vector<Energy> minMass_;
0336 
0337   /**
0338    * The on-shell mass of the particle
0339    */
0340   Energy mass_;
0341 
0342   /**
0343    * Prefactor to get the on-shell width
0344    */
0345   double prefactor_;
0346 
0347   /**
0348    * The type of ME, whether it is fixed, calculated by this class or interpolation
0349    */
0350   vector<int> MEtype_;
0351 
0352   /**
0353    * The code for the matrix element
0354    */
0355   vector<int> MEcode_;
0356 
0357   /**
0358    *  Mass of the first outgoing particle for the simple \f$1\to2\f$ ME's
0359    */
0360   vector<Energy> MEmass1_;
0361   /**
0362    *  Mass of the second outgoing particle for the simple \f$1\to2\f$ ME's
0363    */
0364   vector<Energy> MEmass2_;
0365 
0366   /**
0367    * the coupling for a given me
0368    */
0369   vector<double> MEcoupling_; 
0370 
0371   /**
0372    * is this mode used for the running width
0373    */
0374   vector<bool> modeOn_;
0375 
0376   /**
0377    * storage of the massesto set up the interpolation tables
0378    */
0379   vector<Energy> interMasses_;
0380 
0381   /**
0382    * storage of the widths to set up the interpolation tables
0383    */
0384   vector<Energy> interWidths_;
0385 
0386   /**
0387    * the number of entries in the decay table for a particular mode
0388    */
0389   vector<int> noOfEntries_;
0390 
0391   /**
0392    * initialize the generator using the particle data object
0393    */
0394   bool initialize_;
0395 
0396   /**
0397    *  Output the parameters
0398    */
0399   bool output_;
0400 
0401   /**
0402    * normalise the terms so that the partial widths for an on-shell particle are correct
0403    */
0404   bool BRnorm_;
0405 
0406   /**
0407    * number of points to use for interpolation tables
0408    */
0409   int npoints_;
0410 
0411   /**
0412    * intepolators for the running width
0413    */
0414   vector<Interpolator<Energy,Energy>::Ptr> interpolators_;
0415 
0416   /**
0417    * minimum branching ratio for the inclusion in the total running width
0418    */
0419   double BRminimum_;
0420 
0421   /**
0422    *  Order of the interpolation for the tables
0423    */
0424   unsigned int intOrder_;
0425 
0426   /**
0427    *  Whether or not to only include 2 body modes in the running
0428    * width calculation, higher modes flat
0429    */
0430   bool twoBodyOnly_;
0431 };
0432 
0433 }
0434 
0435 #endif /* HERWIG_GenericWidthGenerator_H */