Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // -*- C++ -*-
0002 //
0003 // Hint.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_Hint_H
0010 #define ThePEG_Hint_H
0011 // This is the declaration of the Hint class.
0012 
0013 #include "ThePEG/Config/ThePEG.h"
0014 #include "ThePEG/Utilities/ClassDescription.h"
0015 
0016 namespace ThePEG {
0017 
0018 /**
0019  * Hint is a base class to be used to pass information
0020  * between <code>StepHandler</code> s, which cannot be convayed
0021  * through the Event record. The base class contains a vector of of
0022  * tagged particles. A StepHandler is always given a hint, and is only
0023  * allowed to treat Particles from the current Step which are listed
0024  * in the vector of tagged particles in the hint (if this vector is
0025  * empty the StepHandler may treat all particles in the Step.
0026  *
0027  * A Hint may have the stop flag set. In this case
0028  * the StepHandler to which the hint is assigned is
0029  * not called, and the event generation is stopped.
0030  *
0031  * A Hint may be given a scale, but what a StepHandler does with this
0032  * and other pieces of information possibly supplied by subclasses of
0033  * Hint, is not defined.
0034  *
0035  * There is a special Hint which is kept as the static member called
0036  * Hint::theDefaultHint. Although any default constructed Hint object
0037  * would work as a default hint, only pointers to this static object
0038  * should be used where a default hint is needed.
0039  *
0040  *
0041  * @see StepHandler
0042  * @see EventHandler
0043  * @see Particle
0044  * @see Event
0045  * @see Step
0046  * 
0047  */
0048 class Hint: public Base {
0049 
0050 public:
0051 
0052   /** @name Standard constructors and destructors. */
0053   //@{
0054   /**
0055    * Default constructor.
0056    */
0057   Hint() : theScale(Energy2()), theStopFlag(false) {}
0058   //@}
0059 
0060 public:
0061 
0062   /**
0063    * Return true if there are tagged particles in the hint.
0064    */
0065   bool tagged() const { return !theTagged.empty(); }
0066 
0067   /**
0068    * Return a list of pointers to particles to be handled. A handler
0069    * is not allowed to touch other particles in the event record. If a
0070    * particle which has been flagged by the hint is no longer present
0071    * in the current Step, a null pointer is inserted in its place.
0072    */
0073   tPVector tagged(const Step & s) const;
0074 
0075   /**
0076    * Add a range of particles to the list of tagged particles.
0077    */
0078   template <typename InputIterator>
0079   void tag(InputIterator first, InputIterator last) 
0080   { 
0081     theTagged.insert(theTagged.end(), first, last); 
0082   }
0083 
0084   /**
0085    * Add a particle to the list of tagged particles.
0086    */
0087   void tag(tPPtr p) { if (p) theTagged.push_back(p); }
0088 
0089   /**
0090    * Set the stop hint.
0091    */
0092   void stop(bool newStopFlag) 
0093   {
0094     theStopFlag = newStopFlag;
0095     if ( theStopFlag ) theTagged.clear(); 
0096   }
0097 
0098   /**
0099    * Get the stop hint.
0100    */
0101   bool stop() const { return theStopFlag; }
0102 
0103   /**
0104    * Set the scale.
0105    */
0106   void scale(const Scale & newScale) { theScale = newScale; }
0107   /**
0108    * Get the scale.
0109    */
0110   const Scale & scale() const { return theScale; }
0111 
0112   /**
0113    * Return a pointer to the default hint.
0114    */
0115   static tHintPtr Default() { return tHintPtr(&theDefaultHint); }
0116 
0117 public:
0118 
0119   /** @name Functions used by the persistent I/O system. */
0120   //@{
0121   /**
0122    * Function used to write out object persistently.
0123    * @param os the persistent output stream written to.
0124    */
0125   void persistentOutput(PersistentOStream & os) const;
0126 
0127   /**
0128    * Function used to read in object persistently.
0129    * @param is the persistent input stream read from.
0130    * @param version the version number of the object when written.
0131    */
0132   void persistentInput(PersistentIStream & is, int version);
0133   //@}
0134 
0135   /**
0136    * Standard Init function used to initialize the interface.
0137    */
0138   static void Init();
0139 
0140 private:
0141 
0142   /**
0143    * The vector of tagged particles.
0144    */
0145   tPVector theTagged;
0146 
0147   /**
0148    * The scale.
0149    */
0150   Scale theScale;
0151 
0152   /**
0153    * The stop hint.
0154    */
0155   bool theStopFlag;
0156 
0157   /**
0158    * The default hint.
0159    */
0160   static Hint theDefaultHint;
0161 
0162 private:
0163 
0164   /**
0165    * Describe a concrete class with persistent data.
0166    */
0167   static ClassDescription<Hint> initHint;
0168 
0169   /**
0170    * Assignment is private and non-existing.
0171    */
0172   Hint & operator=(const Hint & h) = delete;
0173 
0174 };
0175 
0176 
0177 /** @cond TRAITSPECIALIZATIONS */
0178 
0179 /**
0180  * This template specialization informs ThePEG about the
0181  * base class of Hint.
0182  */
0183 template <>
0184 struct BaseClassTrait<Hint,1>: public ClassTraitsType {
0185   /** Typedef of the base class of Hint. */
0186   typedef Base NthBase;
0187 };
0188 
0189 /**
0190  * This template specialization informs ThePEG about the name of the
0191  * Hint class.
0192  */
0193 template <>
0194 struct ClassTraits<Hint>:
0195     public ClassTraitsBase<Hint> {
0196   /** Return the class name. */
0197   static string className() { return "ThePEG::Hint"; }
0198 };
0199 
0200 /** @endcond */
0201 
0202 }
0203 
0204 #endif /* ThePEG_Hint_H */