Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // -*- C++ -*-
0002 //
0003 // MultiEventGenerator.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_MultiEventGenerator_H
0010 #define ThePEG_MultiEventGenerator_H
0011 // This is the declaration of the MultiEventGenerator class.
0012 
0013 #include "EventGenerator.h"
0014 
0015 namespace ThePEG {
0016 
0017 /**
0018  * The MultiEventGenerator class is derived from the
0019  * EventGenerator class and is capable of making several runs with
0020  * a pre-defined set of parameter and switch values.
0021  *
0022  * With the Command<MultiEventGenerator> interface AddInterface set of
0023  * parameters for an included object can be specified as eg.
0024  * <code>object:interface arg1, arg2, arg3 ...</code>. The event
0025  * generator will then be run once with the specified objects
0026  * interface set to <code>arg1</code>, then once with
0027  * <code>arg2</code> etc. If several AddInterface commands are given
0028  * the event generator will be run once for each possible combination
0029  * arguments to object interfaces.
0030  *
0031  * @see EventGenerator
0032  * 
0033  */
0034 class MultiEventGenerator: public EventGenerator {
0035 
0036 public:
0037 
0038   /** @name Standard constructors and destructors. */
0039   //@{
0040   /**
0041    * Default constructor.
0042    */
0043   MultiEventGenerator(): firstSubrun(0), lastSubrun(0) {}
0044 
0045   /**
0046    * Destructor.
0047    */
0048   virtual ~MultiEventGenerator();
0049   //@}
0050 
0051   /**
0052    * Append a tag to the run name. Derived classes may put special
0053    * meaning to the tags. In this case a tag on the form #n will
0054    * select only subrun number n, while #n-m will select subruns n
0055    * through m.
0056    */
0057   virtual void addTag(string tag);
0058 
0059 protected:
0060 
0061   /** @name Public virtual functions required by the base class. */
0062   //@{
0063   /**
0064    * Run this EventGenerator session. Is called from
0065    * EventGenerator::go(long,long,bool).
0066    */
0067   virtual void doGo(long next, long maxevent, bool tics);
0068   //@}
0069 
0070   /** @name Functions used by the Command<MultiEventGenerator>
0071       interfaces to set up the different parameters of the runs. */
0072   //@{
0073   /**
0074    * Used to add an interface of an object which should be used with a
0075    * set of different values. The argument should be given as
0076    * "object:interface arg1, arg2, ..."
0077    */
0078   string addInterface(string);
0079 
0080   /**
0081    * Used to add an interface of an object a random value each
0082    * run. The argument should be given as "object:interface N min max
0083    * mean width"
0084    */
0085   string addRndInterface(string);
0086 
0087   /**
0088    * Helper function for addInterface(string) and addRndInterface(string).
0089    */
0090   string addInterface(string, bool rnd);
0091 
0092 
0093   /**
0094    * Used to remove an interface of an object which should be used
0095    * with a set of different values. The argument should be given as
0096    * "object:interface arg1, arg2, ..."
0097    */
0098   string removeInterface(string);
0099   //@}
0100 
0101   /**
0102    * return a header for this sub-run.
0103    */
0104   string heading(long, const vector<const InterfaceBase *> &, string) const;
0105 
0106   /**
0107    * A separate random number generator to be used for generating
0108    * random parameter values (to ensure reproducable sequences).
0109    */
0110   RandomGenerator & randomArg() const {
0111     return theSeparateRandom? *theSeparateRandom: random();
0112   }
0113 
0114 public:
0115 
0116 
0117   /** @name Functions used by the persistent I/O system. */
0118   //@{
0119   /**
0120    * Function used to write out object persistently.
0121    * @param os the persistent output stream written to.
0122    */
0123   void persistentOutput(PersistentOStream & os) const;
0124 
0125   /**
0126    * Function used to read in object persistently.
0127    * @param is the persistent input stream read from.
0128    * @param version the version number of the object when written.
0129    */
0130   void persistentInput(PersistentIStream & is, int version);
0131   //@}
0132 
0133   /**
0134    * Standard Init function used to initialize the interfaces.
0135    */
0136   static void Init();
0137 
0138 protected:
0139 
0140   /** @name Clone Methods. */
0141   //@{
0142   /**
0143    * Make a simple clone of this object.
0144    * @return a pointer to the new object.
0145    */
0146   virtual IBPtr clone() const;
0147 
0148   /** Make a clone of this object, possibly modifying the cloned object
0149    * to make it sane.
0150    * @return a pointer to the new object.
0151    */
0152   virtual IBPtr fullclone() const;
0153   //@}
0154 
0155 protected:
0156 
0157   /** @name Standard Interfaced functions. */
0158   //@{
0159   /**
0160    * Rebind pointer to other Interfaced objects. Called in the setup phase
0161    * after all objects used in an EventGenerator has been cloned so that
0162    * the pointers will refer to the cloned objects afterwards.
0163    * @param trans a TranslationMap relating the original objects to
0164    * their respective clones.
0165    * @throws RebindException if no cloned object was found for a given
0166    * pointer.
0167    */
0168   virtual void rebind(const TranslationMap & trans);
0169 
0170   /**
0171    * Return a vector of all pointers to Interfaced objects used in this
0172    * object.
0173    * @return a vector of pointers.
0174    */
0175   virtual IVector getReferences();
0176   //@}
0177 
0178 private:
0179 
0180   /** A vector of character strings. */
0181   typedef vector<string> StringVector;
0182 
0183   /**
0184    * The objects for which there are different interface settings.
0185    */
0186   IVector theObjects;
0187 
0188   /**
0189    * The interfaces to be modified for the corresponding objects in
0190    * theObjects.
0191    */
0192   StringVector theInterfaces;
0193 
0194   /**
0195    * If the there are positional arguments to theInterfaces these are
0196    * specified here.
0197    */
0198   StringVector thePosArgs;
0199 
0200   /**
0201    * The arguments to be used for each of theInterfaces.
0202    */
0203   vector<StringVector> theValues;
0204 
0205   /**
0206    * If non zero, the first subrun to be considered.
0207    */
0208   int firstSubrun;
0209 
0210   /**
0211    * If non zero, the last subrun to be considered.
0212    */
0213   int lastSubrun;
0214 
0215   /**
0216    * A separate random number generator to be used for generating
0217    * random parameter values (to ensure reproducable sequences).
0218    */
0219   RanGenPtr theSeparateRandom;
0220 
0221 private:
0222 
0223   /**
0224    * Describe a concrete class with persistent data.
0225    */
0226   static ClassDescription<MultiEventGenerator> initMultiEventGenerator;
0227 
0228   /**
0229    *  Private and non-existent assignment operator.
0230    */
0231   MultiEventGenerator & operator=(const MultiEventGenerator &) = delete;
0232 
0233 };
0234 
0235 
0236 /** @cond TRAITSPECIALIZATIONS */
0237 
0238 /** This template specialization informs ThePEG about the base classes
0239  *  of MultiEventGenerator. */
0240 template <>
0241 struct BaseClassTrait<MultiEventGenerator,1>: public ClassTraitsType {
0242   /** Typedef of the first base class of MultiEventGenerator. */
0243   typedef EventGenerator NthBase;
0244 };
0245 
0246 /** This template specialization informs ThePEG about the name of the
0247  *  MultiEventGenerator class and the shared object where it is
0248  *  defined. */
0249 template <>
0250 struct ClassTraits<MultiEventGenerator>:
0251     public ClassTraitsBase<MultiEventGenerator> {
0252   /** Return a platform-independent class name */
0253   static string className() { return "ThePEG::MultiEventGenerator"; }
0254   /** Return the name of the shared library be loaded to get access to
0255    *  the MultiEventGenerator class and every other class it uses
0256    *  (except the base class). */
0257   static string library() { return "MultiEventGenerator.so"; }
0258 
0259 };
0260 
0261 /** @endcond */
0262 
0263 }
0264 
0265 #endif /* ThePEG_MultiEventGenerator_H */