Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // -*- C++ -*-
0002 //
0003 // Run.hpp is a part of myStatistics
0004 // Copyright (C) 2012-2019 Simon Platzer, The Herwig Collaboration
0005 //
0006 // myStatistics is licenced under version 3 of the GPL, see COPYING for details.
0007 //
0008 #ifndef MYSTATISTICS_Run_hpp_included
0009 #define MYSTATISTICS_Run_hpp_included
0010 
0011 #include "Histogram.h"
0012 
0013 namespace Statistics {
0014 
0015   /**
0016    * \brief A simulation run
0017    * \author Simon Platzer
0018    */
0019   class Run {
0020 
0021   public:
0022 
0023     /**
0024      * Default constructor
0025      */
0026     Run();
0027 
0028     /**
0029      * Construct giving a name and seed
0030      */
0031     explicit Run(const std::string& newName);
0032 
0033     /**
0034      * Destructor
0035      */
0036     virtual ~Run();
0037 
0038   public:
0039 
0040     /**
0041      * Initialize this run.
0042      */
0043     void initialize();
0044 
0045     /**
0046      * Reset this run.
0047      */
0048     void reset();
0049 
0050     /**
0051      * Finalize this run.
0052      */
0053     void finalize(size_t newAttemptedPoints);
0054 
0055   public:
0056 
0057     /**
0058      * Add a point to this run
0059      */
0060     void count(double weight) {
0061       theSumOfWeights += weight;
0062       theSumOfSquaredWeights += weight*weight;
0063     }
0064 
0065     /**
0066      * Add a histogram
0067      */
0068     Histogram& addHistogram(const std::string& newName,
0069                 const std::vector<double>& newBoundaries);
0070 
0071     /**
0072      * Add a histogram
0073      */
0074     Histogram& addHistogram(const std::string& newName,
0075                 const std::vector<double>& newBoundaries,
0076                 const std::pair<double,double>& newPeriodicity);
0077 
0078     /**
0079      * Return a given histogram
0080      */
0081     Histogram& histogram(const std::string& histoName);
0082 
0083     /**
0084      * Return a given histogram
0085      */
0086     const Histogram& histogram(const std::string& histoName) const;
0087 
0088     /**
0089      * Return the histograms
0090      */
0091     const std::map<std::string,Histogram>& histograms() const { return theHistograms; }
0092 
0093     /**
0094      * Return the name of the run
0095      */
0096     const std::string& name() const { return theName; }
0097 
0098     /**
0099      * Set the name of the run
0100      */
0101     void name(const std::string& newName) { theName = newName; }
0102 
0103     /**
0104      * Return the total number of attempted points
0105      */
0106     size_t attemptedPoints() const { return theAttemptedPoints; }
0107 
0108     /**
0109      * The sum of weights
0110      */
0111     double sumOfWeights() const { return theSumOfWeights; }
0112 
0113     /**
0114      * The sum of squared weights
0115      */
0116     double sumOfSquaredWeights() const { return theSumOfSquaredWeights; }
0117 
0118   public:
0119 
0120     /**
0121      * Add a run to this run
0122      */
0123     Run& operator+=(const Run& other);
0124 
0125   public:
0126 
0127     /**
0128      * Fill run data from an XML element
0129      */
0130     void fromXML(const XML::Element&);
0131 
0132     /**
0133      * Return an XML element for the data of this run
0134      */
0135     XML::Element toXML() const;
0136 
0137   private:
0138 
0139     /**
0140      * The name of the run
0141      */
0142     std::string theName;
0143 
0144     /**
0145      * The total number of attempted points
0146      */
0147     size_t theAttemptedPoints;
0148 
0149     /**
0150      * The sum of weights
0151      */
0152     double theSumOfWeights;
0153 
0154     /**
0155      * The sum of squared weights
0156      */
0157     double theSumOfSquaredWeights;
0158 
0159     /**
0160      * The histograms
0161      */
0162     std::map<std::string,Histogram> theHistograms;
0163 
0164 
0165   };
0166 
0167 }
0168 
0169 #endif // MYSTATISTICS_Run_hpp_included