Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-04-19 09:06:49

0001 // -*- C++ -*-
0002 #ifndef RIVET_SINGLEVALUEPROJECTION_HH
0003 #define RIVET_SINGLEVALUEPROJECTION_HH
0004 
0005 #include "Rivet/Projection.hh"
0006 
0007 namespace Rivet {
0008 
0009 
0010   /// @brief Base class for projections returning a single floating point value.
0011   ///
0012   /// @author Leif Lönnblad
0013   ///
0014   /// Project an event down to a single floating point value accessible
0015   /// through the operator() function.
0016   ///
0017   class SingleValueProjection: public Projection {
0018   public:
0019 
0020     /// The default constructor.
0021     SingleValueProjection() : _value(-1.0), _isSet(false) {
0022       setName("SingleValueProjection");
0023     }
0024 
0025     /// Import to avoid warnings about overload-hiding
0026     using Projection::operator =;
0027 
0028 
0029     /// Returns true if the value has been set.
0030     bool isValueSet() const {
0031       return _isSet;
0032     }
0033 
0034     /// Return the single value.
0035     double value() const {
0036       return _value;
0037     }
0038 
0039     /// Return the single value.
0040     double operator()() const {
0041       return value();
0042     }
0043 
0044 
0045   protected:
0046 
0047     /// Set the value.
0048     void setValue(double v) {
0049       _value = v;
0050       _isSet = true;
0051     }
0052 
0053     /// Unset the value.
0054     void clear() {
0055       _value = -1.0;
0056       _isSet = false;
0057     }
0058 
0059 
0060   protected:
0061 
0062     double _value;
0063 
0064     /// @todo Use std::optional?
0065     bool _isSet;
0066 
0067   };
0068 
0069 
0070 }
0071 
0072 #endif