Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // -*- C++ -*-
0002 //
0003 // Measurement.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 LWH_Measurement_H
0010 #define LWH_Measurement_H
0011 //
0012 // This is the declaration of the Measurement class representing
0013 //
0014 
0015 
0016 #include <limits>
0017 #include <cmath>
0018 #include <algorithm>
0019 #include "AIMeasurement.h"
0020 
0021 namespace LWH {
0022 
0023 using namespace AIDA;
0024 
0025 /**
0026  * Basic user-level interface class for holding a single "measurement"
0027  * with positive and negative errors (to allow for asymmetric errors).
0028  * "IMeasurement" = "value" + "errorPlus" - "errorMinus"
0029  */
0030 class Measurement: public IMeasurement {
0031 
0032 public: 
0033 
0034   /**
0035    * Standard constructor.
0036    */
0037   Measurement(double v = 0.0, double ep = 0.0, double em = 0.0)
0038     : val(v), errp(ep), errm(em) {}
0039 
0040   /**
0041    * Copy constructor.
0042    */
0043   Measurement(const Measurement & m)
0044     :IMeasurement(m), val(m.val), errp(m.errp), errm(m.errm) {}
0045 
0046   /**
0047    *  Default assignment operator (to avoid compiler warnings).
0048    */
0049   Measurement & operator=(const Measurement &) = default;
0050 
0051   /**
0052    * Destructor.
0053    */
0054   virtual ~Measurement() { /* nop */; }
0055 
0056   /**
0057    * Get the value of the Measurement.
0058    * @return The value of the Measurement.
0059    */
0060   double value() const {
0061     return val;
0062   }
0063 
0064   /**
0065    * Get the plus error of the IMeasurement.
0066    * @return The plus error.
0067    */
0068   double errorPlus() const {
0069     return errp;
0070   }
0071 
0072   /**
0073    * Get the minus error of the IMeasurement.
0074    * @return The minus error.
0075    */
0076   double errorMinus() const {
0077     return errm;
0078   }
0079 
0080   /**
0081    * Set the value of the IMeasurement.
0082    * @param v The new value of the IMeasurement.
0083    * @return false If the value cannot be set.
0084    */
0085   bool setValue(double v) {
0086     val = v;
0087     return true;
0088   }
0089 
0090   /**
0091    * Set the plus error of the IMeasurement.
0092    * @param ep The new plus error of the IMeasurement.
0093    * @return false If the error cannot be set or it is negative.
0094    */
0095   bool setErrorPlus(double ep) {
0096     errp = ep;
0097     return ep < 0.0;
0098   }
0099 
0100   /**
0101    * Set the minus error of the IMeasurement.
0102    * @param em The new minus error of the IMeasurement.
0103    * @return false If the error cannot be set or it is negative.
0104    */
0105   bool setErrorMinus(double em) {
0106     errm = em;
0107     return em < 0.0;
0108   }
0109 
0110 private:
0111 
0112   /**
0113    * The value.
0114    */
0115   double val;
0116 
0117   /**
0118    * The plus error.
0119    */
0120   double errp;
0121 
0122   /**
0123    * The minus error.
0124    */
0125   double errm;
0126 
0127 };
0128 
0129 }
0130 
0131 #endif /* LWH_Measurement_H */