Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // -*- C++ -*-
0002 //
0003 // Strategy.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_Strategy_H
0010 #define ThePEG_Strategy_H
0011 // This is the declaration of the Strategy class.
0012 
0013 #include "ThePEG/Config/ThePEG.h"
0014 #include "Strategy.fh"
0015 #include "ThePEG/Interface/Interfaced.h"
0016 
0017 namespace ThePEG {
0018 
0019 /**
0020  * The Strategy class represents a general strategy to be assigned to
0021  * an EventGenerator. It contains a set of default ParticleData
0022  * objects which takes presedence over the ones in the Repository
0023  * (although not over the ones in the EventGenerator). It also
0024  * contains a set of other default objects which are automatically
0025  * assigned to all Reference and RefVector interfaces which have the
0026  * InterfaceBase::defaultIfNull() flag set. In this case each of the
0027  * objects in defaultObjects() are tested in turn, and the first
0028  * object which has the correct class and can be set will be used.
0029  *
0030  * Sub-classes may implement other behaviors by overriding the
0031  * doinit() function.
0032  *
0033  * @see \ref StrategyInterfaces "The interfaces"
0034  * defined for Strategy.
0035  * @see EventGenerator
0036  * @see ParticleData
0037  * @see Repository
0038  * @see Reference
0039  * 
0040  */
0041 class Strategy: public Interfaced {
0042 
0043 public:
0044 
0045   /** @name Access the special objects in this Strategy. */
0046   //@{
0047   /**
0048    * Return the map of local particles indexed by their PDG id number.
0049    */
0050   const ParticleMap & particles() const { return theParticles; }
0051 
0052   /**
0053    * A directory in the repository which will be scanned for particles
0054    * which will be included as default particles in a run. These
0055    * particles will be overridden by particles specified in
0056    * LocalParticles and default particles
0057    * specified directly in the EventGenerator.
0058    */
0059   string localParticlesDir() const;
0060 
0061   /**
0062    * By default all particles in the Repository are included in a run,
0063    * although only one particle per PDG id number. If directories are
0064    * listed here, only particles in these will be considered for
0065    * inclusion in a run. Only particles which have a PDG id which is
0066    * not given by particles in localParticlesDir(), particles(), or in
0067    * EventGenerator::localParticles() will be considered.
0068    */
0069   const vector<string> & defaultParticlesDirs() const {
0070     return theDefaultParticlesDirs;
0071   }
0072 
0073   /**
0074    * Return the vector of default objects.
0075    */
0076   const vector<IPtr> & defaultObjects() const { return theDefaultObjects; }
0077   //@}
0078 
0079   /**
0080    * Return a freeform version string. Client code should not rely on the 
0081    * string's format. It can be used e.g. to annotate plots.
0082    */
0083   virtual const string versionstring() const { return ""; }
0084 
0085 public:
0086 
0087   /** @name Functions used by the persistent I/O system. */
0088   //@{
0089   /**
0090    * Function used to write out object persistently.
0091    * @param os the persistent output stream written to.
0092    */
0093   void persistentOutput(PersistentOStream & os) const;
0094 
0095   /**
0096    * Function used to read in object persistently.
0097    * @param is the persistent input stream read from.
0098    * @param version the version number of the object when written.
0099    */
0100   void persistentInput(PersistentIStream & is, int version);
0101   //@}
0102 
0103   /**
0104    * Standard Init function used to initialize the interface.
0105    */
0106   static void Init();
0107 
0108 protected:
0109 
0110   /** @name Clone Methods. */
0111   //@{
0112   /**
0113    * Make a simple clone of this object.
0114    * @return a pointer to the new object.
0115    */
0116   virtual IBPtr clone() const;
0117 
0118   /** Make a clone of this object, possibly modifying the cloned object
0119    * to make it sane.
0120    * @return a pointer to the new object.
0121    */
0122   virtual IBPtr fullclone() const;
0123   //@}
0124 
0125 private:
0126 
0127   /**
0128    * Return the map of local particles.
0129    */
0130   ParticleMap & particles() { return theParticles; }
0131 
0132 private:
0133 
0134   /**
0135    * the map of default particles.
0136    */
0137   ParticleMap theParticles;
0138 
0139   /**
0140    * A directory in the repository which will be scanned for particles
0141    * which will be included as default particles in a run. These
0142    * particles will be overridden by particles specified in
0143    * LocalParticles and default particles
0144    * specified directly in the EventGenerator.
0145    */
0146   string theLocalParticlesDir;
0147 
0148   /**
0149    * A vector of default objects.
0150    */
0151   vector<IPtr> theDefaultObjects;
0152 
0153   /**
0154    * By default all particles in the Repository are included in a run,
0155    * although only one particle per PDG id number. If directories are
0156    * listed in theDefaultParticlesDirs, only particles in these will
0157    * be considered for inclusion in a run. Only particles which have a
0158    * PDG id which is not given by particles in localParticlesDir(),
0159    * particles(), or in EventGenerator::localParticles() will be
0160    * considered.
0161    */
0162   vector<string> theDefaultParticlesDirs;
0163 
0164 private:
0165 
0166   /**
0167    * Utility function used by the interface.
0168    */
0169   void setLocalParticles(PDPtr pd, int);
0170 
0171   /**
0172    * Utility function used by the interface.
0173    */
0174   void insLocalParticles(PDPtr pd, int);
0175 
0176   /**
0177    * Utility function used by the interface.
0178    */
0179   void delLocalParticles(int place);
0180 
0181   /**
0182    * Utility function used by the interface.
0183    */
0184   vector<PDPtr> getLocalParticles() const;
0185 
0186   /**
0187    * Utility function used by the interface.
0188    */
0189   void setLocalParticlesDir(string);
0190 
0191   /**
0192    * Utility function used by the interface.
0193    */
0194   void setDefaultParticlesDirs(string,int);
0195 
0196   /**
0197    * Utility function used by the interface.
0198    */
0199   void insDefaultParticlesDirs(string,int);
0200 
0201   /**
0202    * Utility function used by the interface.
0203    */
0204   static bool checkDir(string);
0205 
0206 private:
0207 
0208   /**
0209    * Describe a concrete class with persistent data.
0210    */
0211   static ClassDescription<Strategy> initStrategy;
0212 
0213   /**
0214    *  Private and non-existent assignment operator.
0215    */
0216   Strategy & operator=(const Strategy &) = delete;
0217 
0218 };
0219 
0220 /** @cond TRAITSPECIALIZATIONS */
0221 
0222 /** This template specialization informs ThePEG about the base classes
0223  *  of Strategy. */
0224 template <>
0225 struct BaseClassTrait<Strategy,1>: public ClassTraitsType {
0226   /** Typedef of the first base class of Strategy. */
0227   typedef Interfaced NthBase;
0228 };
0229 
0230 /** This template specialization informs ThePEG about the name of the
0231  *  Strategy class. */
0232 template <>
0233 struct ClassTraits<Strategy>: public ClassTraitsBase<Strategy> {
0234   /** Return a platform-independent class name */
0235   static string className() { return "ThePEG::Strategy"; }
0236 };
0237 
0238 /** @endcond */
0239 
0240 }
0241 
0242 #endif /* ThePEG_Strategy_H */