Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // -*- C++ -*-
0002 //
0003 // MonacoSampler.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_MonacoSampler_H
0010 #define Herwig_MonacoSampler_H
0011 //
0012 // This is the declaration of the MonacoSampler class.
0013 //
0014 
0015 #include "Herwig/Sampling/BinSampler.h"
0016 
0017 #include "Herwig/Utilities/XML/Element.h"
0018 
0019 // work around a Boost 1.64 bug where ublas headers would fail otherwise
0020 #include <boost/version.hpp>
0021 #if (BOOST_VERSION / 100 >= 1064)
0022 #include <boost/serialization/array_wrapper.hpp>
0023 #endif
0024 
0025 #include <boost/numeric/ublas/matrix.hpp>
0026 
0027 namespace Herwig {
0028 
0029 using namespace ThePEG;
0030 
0031 /**
0032  * \ingroup Matchbox
0033  * \author Michael Rauch
0034  *
0035  * \brief MonacoSampler samples XCombs bins using using Monaco
0036  *
0037  * @see \ref MonacoSamplerInterfaces "The interfaces"
0038  * defined for MonacoSampler.
0039  */
0040 class MonacoSampler: public Herwig::BinSampler {
0041 
0042 public:
0043 
0044   /** @name Standard constructors and destructors. */
0045   //@{
0046   /**
0047    * The default constructor.
0048    */
0049   MonacoSampler();
0050 
0051   /**
0052    * The destructor.
0053    */
0054   virtual ~MonacoSampler();
0055   //@}
0056 
0057 public:
0058 
0059   /**
0060    * Clone this object.
0061    */
0062   Ptr<MonacoSampler>::ptr cloneMe() const {
0063     return dynamic_ptr_cast<Ptr<MonacoSampler>::ptr>(clone());
0064   }
0065 
0066 public:
0067 
0068 
0069   /**
0070    * Generate the next point and return its weight; store the point in
0071    * lastPoint().
0072    */
0073   virtual double generate();
0074 
0075   /**
0076    * Adapt this sampler after an iteration has been run
0077    */
0078   virtual void adapt();
0079 
0080   /**
0081    * Return true, if grid data exists for this sampler.
0082    */
0083   virtual bool existsGrid() const;
0084 
0085   /**
0086    * Save grid data
0087    */
0088   virtual void saveGrid() const;
0089 
0090   /**
0091    * Initialize this bin sampler. This default version calls runIteration.
0092    */
0093   virtual void initialize(bool progress);
0094 
0095   /**
0096    * Finalize this sampler.
0097    */
0098   virtual void finalize(bool); 
0099 
0100   /**
0101    * Fill Monaco grid data from an XML element
0102    */
0103   virtual void fromXML(const XML::Element&);
0104 
0105   /**
0106    * Return an XML element for the data of the Monaco grid
0107    */
0108   virtual XML::Element toXML() const;
0109 
0110 
0111 public:
0112 
0113   /** @name Functions used by the persistent I/O system. */
0114   //@{
0115   /**
0116    * Function used to write out object persistently.
0117    * @param os the persistent output stream written to.
0118    */
0119   void persistentOutput(PersistentOStream & os) const;
0120 
0121   /**
0122    * Function used to read in object persistently.
0123    * @param is the persistent input stream read from.
0124    * @param version the version number of the object when written.
0125    */
0126   void persistentInput(PersistentIStream & is, int version);
0127   //@}
0128 
0129   /**
0130    * The standard Init function used to initialize the interfaces.
0131    * Called exactly once for each class by the class description system
0132    * before the main function starts or
0133    * when this class is dynamically loaded.
0134    */
0135   static void Init();
0136 
0137 protected:
0138 
0139   /** @name Clone Methods. */
0140   //@{
0141   /**
0142    * Make a simple clone of this object.
0143    * @return a pointer to the new object.
0144    */
0145   virtual IBPtr clone() const;
0146 
0147   /** Make a clone of this object, possibly modifying the cloned object
0148    * to make it sane.
0149    * @return a pointer to the new object.
0150    */
0151   virtual IBPtr fullclone() const;
0152   //@}
0153 
0154 
0155 // If needed, insert declarations of virtual function defined in the
0156 // InterfacedBase class here (using ThePEG-interfaced-decl in Emacs).
0157 
0158 private:
0159 
0160    /**
0161     * Rate of grid modification (0 for no modification)
0162     */
0163   double theAlpha;
0164 
0165    /**
0166     * Number of grid divisions per dimension
0167     */
0168   size_t theGridDivisions;
0169 
0170    /**
0171     * Grid boundaries 
0172     * (first index: dimension of random numbers,
0173     * second index: dimension of partitions per random number) 
0174     */
0175   boost::numeric::ublas::matrix<double> theGrid;
0176 
0177    /**
0178     * Collected value per grid bin
0179     */
0180   boost::numeric::ublas::matrix<double> theGridData;
0181 
0182 private:
0183 
0184    /**
0185     * Number of points collected in iteration so far
0186     */
0187   size_t theIterationPoints;
0188 
0189 private:
0190 
0191   /**
0192    * The assignment operator is private and must never be called.
0193    * In fact, it should not even be implemented.
0194    */
0195   MonacoSampler & operator=(const MonacoSampler &) = delete;
0196 
0197 };
0198 
0199 }
0200 
0201 #endif /* Herwig_MonacoSampler_H */