Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // -*- C++ -*-
0002 //
0003 // DecayMode.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_DecayMode_H
0010 #define ThePEG_DecayMode_H
0011 // This is the declaration of the DecayMode class.
0012 
0013 #include "ThePEG/Config/ThePEG.h"
0014 #include "ThePEG/Interface/Interfaced.h"
0015 #include "DecayMode.fh"
0016 #include "MatcherBase.h"
0017 #include "Decayer.h"
0018 
0019 namespace ThePEG {
0020 
0021 ThePEG_DECLARE_MULTISET(tPDPtr,ParticleMSet);
0022 ThePEG_DECLARE_MULTISET(tPMPtr,MatcherMSet);
0023 ThePEG_DECLARE_MULTISET(tDMPtr,ModeMSet);
0024 
0025 /**
0026  * The DecayMode class describes a decay channel of a particle. In its
0027  * simplest form it contains simply a parent ParticleData object and a
0028  * list of decay products, but it can also specify a set of
0029  * MatcherBase objects each representing one of a set of possible
0030  * decay products. A matcher can also be specified to represents an
0031  * unlimited set of decay products. Decay chains can be represented by
0032  * specifying other decay channels where the parents are taken to be
0033  * intermediate resonances. It is also possible to specify the absence
0034  * of intermediate resonances.
0035  *
0036  * Each decay mode can be uniquely described by a character string on
0037  * the form
0038  * <code>{decaying-particle-name}->{decay-product-specifier}[,{decay-product-specifier},...];</code>
0039  * where no spaces are allowed anywhere. The decaying-particle-name
0040  * should be a path to a particle in the Repository or a
0041  * PDG-standardized particle name (see ParticleData::PDGName()) and
0042  * the decay-product-specifier can be one of the following:
0043  *
0044  * <ul>
0045  *
0046  * <li> a path to a particle in the Repository or a PDG-standardized
0047  * particle name if it is a specific decay product,
0048  *
0049  * <li> a question mark followed by the name of a particle matcher
0050  * object in the Repository if representing one of several different
0051  * alternative decay products,
0052  *
0053  * <li> a star followed by the name of a particle matcher object in
0054  * the Repository if representing any number of several different
0055  * alternative decay products (note that only one of these
0056  * <i>wild-card</i> matchers may be specified, if several are given
0057  * only the last one will be taken into account),
0058  *
0059  * <li> a whole decay mode string enclosed in square brackets if
0060  * representing a resonance decay product with a specified decay mode,
0061  *
0062  * <li> an exclamation mark followed by a path to a particle in the
0063  * Repository or a PDG-standardized particle name representing the
0064  * exclusion of an intermediate resonance decaying into the other
0065  * specified decay products.
0066  *
0067  * <li> two paths to particles in the Repository or PDG-standardized
0068  * particle names with an equal sign between, indicating two coloured
0069  * particles which are in a colour-singlet state.
0070  *
0071  * </ul>
0072  *
0073  * Note that the order of the specified decay products will be
0074  * preserved when the corresponding particles are produced in a decay.
0075  *
0076  * The possibility of specifying matchers as decay products means that
0077  * one decay mode may overlap with another one. When an EventGenerator
0078  * is initialized all decay modes are checked so that a given decay
0079  * mode afterwards will report if there are other modes which are
0080  * matched by its matchers through the overlap() function.
0081  *
0082  * @see \ref DecayModeInterfaces "The interfaces"
0083  * defined for DecayMode.
0084  * @see ParticleData
0085  * @see MatcherBase
0086  */
0087 class DecayMode: public Interfaced {
0088 
0089 public:
0090 
0091   /** ParticleData is a friend. */
0092   friend class ParticleData;
0093 
0094   /** RemnantData is a friend. */
0095   friend class RemnantData;
0096 
0097   /** The EventGenerator is a friend. */
0098   friend class EventGenerator;
0099 
0100 public:
0101 
0102   /** A vector of DecayMode pointers. */
0103   typedef vector<tcDMPtr> ModeVector;
0104   /** A vector of pairs of ParticleData pointers. */
0105   typedef vector<tPDPair> LinkVector;
0106 
0107 public:
0108 
0109   /**
0110    * Create a decay mode from a given tag. This function is used
0111    * directly by the Repository. If name of the decaying particle is a
0112    * valid path to a particle object, the decaymode will be added to
0113    * that particle, otherwise it will be added to the default particle
0114    * of that name.
0115    */
0116   static DMPtr constructDecayMode(string & tag, vector<DMPtr> * save = 0);
0117 
0118   /** @name Standard constructors and destructors. */
0119   //@{
0120   /**
0121    * Default constructor.
0122    */
0123   DecayMode();
0124 
0125   /**
0126    * Copy-constructor.
0127    */
0128   DecayMode(const DecayMode &);
0129   //@}
0130 
0131   /**
0132    * Return a clone of this decay mode with \a pd as the decaying
0133    * particle.
0134    */
0135   virtual DMPtr clone(tPDPtr pd) const;
0136 
0137 public:
0138 
0139   /**
0140    * Return the tag for this decay mode. This string is a unique
0141    * identifier for this decay mode.
0142    */
0143   const string & tag() const {
0144     return theTag.size() ? theTag : ( theTag = makeTag() );
0145   }
0146 
0147   /**
0148    * Get a pointer to the particle data object corresponding to
0149    * the decaying particle.
0150    */
0151   tcPDPtr parent() const { return theParent; }
0152 
0153   /**
0154    * The set of identified decay products.
0155    */
0156   const ParticleMSet & products() const { return theProducts; }
0157 
0158   /**
0159    * The set of identified decay products in the order they were specified.
0160    */
0161   const tPDVector & orderedProducts() const { return theOrderedProducts; }
0162 
0163   /**
0164    * Produce particles corresponding to the identified decay
0165    * products. They will be orderd in the same order they were
0166    * sspecified.
0167    */
0168   PVector produceProducts() const;
0169 
0170   /**
0171    * The set of identified resonance products with specified decay
0172    * modes
0173    */
0174   const ModeMSet & cascadeProducts() const { return theCascadeProducts; }
0175 
0176   /**
0177    * The set of matchers each corresponding to one decay product.
0178    */
0179   const MatcherMSet & productMatchers() const { return theMatchers; }
0180 
0181   /**
0182    * The pointer to a matcher corresponding to any number of decay
0183    * products
0184    */
0185   tPMPtr wildProductMatcher() const { return theWildMatcher; }
0186 
0187   /**
0188    * The set particles corresponding to excluded intermediate
0189    * resonances.
0190    */
0191   const ParticleMSet & excluded() const { return theExcluded; }
0192 
0193   /**
0194    * Return the branching ratio to be used.
0195    */
0196   double brat() const;
0197 
0198   /**
0199    * Calculate the branching ratio for a particular particle instance.
0200    */
0201   double brat(const Particle &) const;
0202 
0203   /**
0204    * Get the decayer assigned to this mode.
0205    */
0206   tDecayerPtr decayer() const { return theDecayer; }
0207 
0208   /**
0209    * Check if another decay mode is included in this one.
0210    */
0211   bool includes(const DecayMode &) const;
0212 
0213   /**
0214    * Return a pointer to the corresponding decaymode for the
0215    * antiparticle decay.
0216    */
0217   tDMPtr CC() const { return theAntiPartner; }
0218 
0219   /**
0220    * Check if another decay mode has the same final state as this
0221    * one.
0222    */
0223   bool operator == (const DecayMode & d) const { 
0224     return tag() == d.tag() ;
0225   }
0226 
0227   /**
0228    * Return a vector of pairs of decay products which are linked
0229    * together (e.g. colourless q-qbar pairs).
0230    */
0231   const LinkVector & links() const { return theLinks; }
0232 
0233   /**
0234    * Return the list of overlapping decay modes.
0235    */
0236   const ModeVector & overlap() const { return theOverlap; }
0237 
0238   /**
0239    * Modify this mode to have properties corresponding to its anti-partner.
0240    */
0241   void synchronize();
0242 
0243   /**
0244    *  Check whether this decay mode is switched on
0245    */
0246   bool on() const { return isOn; }
0247 
0248 public:
0249 
0250   /** @name Functions used by the persistent I/O system. */
0251   //@{
0252   /**
0253    * Function used to write out object persistently.
0254    * @param os the persistent output stream written to.
0255    */
0256   void persistentOutput(PersistentOStream & os) const;
0257 
0258   /**
0259    * Function used to read in object persistently.
0260    * @param is the persistent input stream read from.
0261    * @param version the version number of the object when written.
0262    */
0263   void persistentInput(PersistentIStream & is, int version);
0264   //@}
0265 
0266   /**
0267    * Standard Init function used to initialize the interface.
0268    */
0269   static void Init();
0270 
0271 protected:
0272 
0273   /** @name Standard Interfaced functions. */
0274   //@{
0275   /**
0276    * Check sanity of the object during the setup phase.
0277    */
0278   virtual void doupdate();
0279 
0280   /**
0281    * Rebind pointer to other Interfaced objects. Called in the setup phase
0282    * after all objects used in an EventGenerator has been cloned so that
0283    * the pointers will refer to the cloned objects afterwards.
0284    * @param trans a TranslationMap relating the original objects to
0285    * their respective clones.
0286    * @throws RebindException if no cloned object was found for a given
0287    * pointer.
0288    */
0289   virtual void rebind(const TranslationMap & trans)
0290    ;
0291 
0292   /**
0293    * Return a vector of all pointers to Interfaced objects used in this
0294    * object.
0295    * @return a vector of pointers.
0296    */
0297   virtual IVector getReferences();
0298   //@}
0299 
0300 protected:
0301 
0302   /**
0303    * Set a pointer to the particle data object corresponding to
0304    * the decaying particle.
0305    */
0306   void parent(tPDPtr pd) { theParent = pd; }
0307 
0308   /**
0309    * Set the branching ratio to be used.
0310    */
0311   void brat(double);
0312 
0313   /**
0314    * Switch on this decay mode.
0315    */
0316   void switchOn();
0317 
0318   /**
0319    * Switch off this decay mode.
0320    */
0321   void switchOff();
0322 
0323   /**
0324    * Set the decayer. The set method returns false if the decayer
0325    * does not claim to be able to handle the decay.
0326    */
0327   void decayer(tDecayerPtr);
0328 
0329   /**
0330    * Add identified decay products.
0331    */
0332   void addProduct(tPDPtr);
0333 
0334   /**
0335    * Add a pair of decay products which are linked together
0336    * (e.g. colourless q-qbar pairs).
0337    */
0338   void addLink(tPDPtr a, tPDPtr b);
0339 
0340   /**
0341    * Add identified resonant product with specified decay mode.
0342    */
0343   void addCascadeProduct(tDMPtr);
0344 
0345   /**
0346    * Add a mathcer corresponding to one decay product.
0347    */
0348   void addProductMatcher(tPMPtr);
0349 
0350   /**
0351    * Add a matcher corresponding to any number of decay products.
0352    */
0353   void setWildMatcher(tPMPtr);
0354 
0355   /**
0356    * Add a particle corresponding to an excluded intermediate
0357    * resonance.
0358    */
0359   void addExcluded(tPDPtr);
0360 
0361   /**
0362    * Protected creation and clone methods.
0363    */
0364   static DMPtr Create(tPDPtr newParent, double newBrat = 0.0,
0365               bool newOn = false);
0366   /**
0367    * Protected constructor.
0368    */
0369   DecayMode(tPDPtr newParticle, double newBrat, bool newOn);
0370 
0371   /** @name Clone Methods. */
0372   //@{
0373   /**
0374    * Make a simple clone of this object.
0375    * @return a pointer to the new object.
0376    */
0377   virtual IBPtr clone() const;
0378 
0379   /** Make a clone of this object, possibly modifying the cloned object
0380    * to make it sane.
0381    * @return a pointer to the new object.
0382    */
0383   virtual IBPtr fullclone() const;
0384   //@}
0385 
0386   /**
0387    * Protected special clone function.
0388    */
0389   DMPtr dmclone() const;
0390 
0391   /**
0392    * Read setup info from a standard stream used by the
0393    * Repository. The following information must be supplied in a
0394    * white-space separated list: the branching ratio, on or off (true
0395    * or false), and the name of a Decayer.
0396    */
0397   virtual void readSetup(istream & is);
0398 
0399   /**
0400    * The set of identified decay products.
0401    */
0402   ParticleMSet & products() { return theProducts; }
0403 
0404   /**
0405    * The set of identified resonant products with specified decay
0406    * modes
0407    */
0408   ModeMSet & cascadeProducts() { return theCascadeProducts; }
0409 
0410   /**
0411    * The set of matchers each corresponding to one decay product.
0412    */
0413   MatcherMSet & productMatchers() { return theMatchers; }
0414 
0415   /**
0416    * The pointer to a matcher corresponding to any number of decay
0417    * products
0418    */
0419   tPMPtr & wildProductMatcher() { return theWildMatcher; }
0420 
0421   /**
0422    * The set particles corresponding to excluded intermediate
0423    * resonances.
0424    */
0425   ParticleMSet & excluded() { return theExcluded; }
0426 
0427   /**
0428    *  Set the pointer to the corresponding decaymode for the
0429    * antiparticle decay.
0430    */
0431   void CC(tDMPtr cc) {theAntiPartner = cc;}
0432 
0433 private:
0434 
0435   /**
0436    * Add a decay mode to the list of overlapping modes if included.
0437    */
0438   bool addOverlap(tcDMPtr);
0439 
0440   /**
0441    * Remove all decay modes from the list of overlapping modes.
0442    */
0443   void resetOverlap();
0444 
0445   /**
0446    * Check if two sets of particles have equivalent types.
0447    */
0448   bool compareId(const ParticleMSet &, const ParticleMSet &) const;
0449 
0450   /**
0451    * Check if a particle set contains a given particle ID.
0452    */
0453   ParticleMSet::const_iterator findId(const ParticleMSet &,
0454                       const ParticleData &) const;
0455   
0456   /**
0457    * Use the members in this decay channel and generate the
0458    * corresponding tag.
0459    */
0460   string makeTag() const;
0461 
0462   /**
0463    * Delete the tag (it will be regenerated later if asked for).
0464    */
0465   void resetTag() {
0466     theTag = "";
0467     if ( CC() ) CC()->theTag = "";
0468   }
0469 
0470 
0471 private:
0472 
0473   /**
0474    * Utility function for the interface.
0475    */
0476   void setOn(long);
0477 
0478   /**
0479    * Utility function for the interface.
0480    */
0481   long getOn() const;
0482 
0483   /**
0484    * Utility function for the interface.
0485    */
0486   void setDecayer(DecayerPtr);
0487 
0488 private:
0489 
0490   /**
0491    * The tag.
0492    */
0493   mutable string theTag;
0494 
0495   /**
0496    * The branching ratio.
0497    */
0498   double theBrat;
0499 
0500   /**
0501    * True if this mode is switched on.
0502    */
0503   bool isOn;
0504 
0505   /**
0506    * Pointer to a particle data object corresponding to the decaying
0507    * particle.
0508    */
0509   tPDPtr theParent;
0510 
0511   /**
0512    * The set of specified decay particles.
0513    */
0514   ParticleMSet theProducts;
0515 
0516   /**
0517    * The set of specified decay particles in the order they was specified.
0518    */
0519   tPDVector theOrderedProducts;
0520 
0521   /**
0522    * The set of matching decay channels corresponding to a specified
0523    * with a specified subsequent decay mode.
0524    */
0525   ModeMSet theCascadeProducts;
0526 
0527   /**
0528    * The set of matching decay products. Each of the matchers
0529    * correspond to one particle.
0530    */
0531   MatcherMSet theMatchers;
0532 
0533   /**
0534    * A particle matcher which corresponds to zero or more particles.
0535    */
0536   tPMPtr theWildMatcher;
0537 
0538   /**
0539    * A set of particles which are not allowed as intermediate
0540    * resonances.
0541    */
0542   ParticleMSet theExcluded;
0543 
0544   /**
0545    * A list of decay modes which are included in this one.
0546    */
0547   ModeVector theOverlap;
0548 
0549   /**
0550    * The decayer object responsible for performing the decay.
0551    */
0552   DecayerPtr theDecayer;
0553 
0554   /**
0555    * The corresponding decay mode of the anti particle.
0556    */
0557   tDMPtr theAntiPartner;
0558 
0559   /**
0560    * The vector of pairs of decay products which are linked together
0561    * (e.g. colourless q-qbar pairs).
0562    */
0563   LinkVector theLinks;
0564 
0565 private:
0566 
0567   /**
0568    * Describe a concrete class with persistent data.
0569    */
0570   static ClassDescription<DecayMode> initDecayMode;
0571 
0572   /**
0573    *  Private and non-existent assignment operator.
0574    */
0575   DecayMode & operator=(const DecayMode &) = delete;
0576 
0577 };
0578 
0579 /** @cond TRAITSPECIALIZATIONS */
0580 
0581 /** This template specialization informs ThePEG about the
0582  *  base classes of DecayMode. */
0583 template <>
0584 struct BaseClassTrait<DecayMode,1>: public ClassTraitsType {
0585   /** Typedef of the first base class of DecayMode. */
0586   typedef Interfaced NthBase;
0587 };
0588 
0589 /** This template specialization informs ThePEG about the name of the
0590  *  DecayMode class. */
0591 template <>
0592 struct ClassTraits<DecayMode>:
0593     public ClassTraitsBase<DecayMode> {
0594   /** Return a platform-independent class name */
0595   static string className() { return "ThePEG::DecayMode"; }
0596 };
0597 
0598 /** @endcond */
0599 
0600 }
0601 
0602 #endif /* ThePEG_DecayMode_H */