cepgen is hosted by Hepforge, IPPP Durham
CepGen 1.2.5
Central exclusive processes event generator
Loading...
Searching...
No Matches
Value.h
Go to the documentation of this file.
1/*
2 * CepGen: a central exclusive processes event generator
3 * Copyright (C) 2023 Laurent Forthomme
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef CepGen_Utils_Value_h
20#define CepGen_Utils_Value_h
21
22#include <iosfwd>
23
24namespace cepgen {
26 class Value {
27 public:
28 explicit Value(double val = 0., double unc = 0.);
29
30 friend std::ostream& operator<<(std::ostream&, const Value&);
31
33 operator double() const { return val_; }
35 double uncertainty() const { return unc_; }
37 double relativeUncertainty() const;
38
40 bool operator<(const Value& oth) const { return val_ < oth.val_; }
41
42 //--- error propagation operators
43
44 Value operator+(const Value&) const;
45 template <typename T>
46 inline Value operator+(T cst) const {
47 return Value{val_ + cst, unc_};
48 }
49 Value operator-(const Value&) const;
50 template <typename T>
51 inline Value operator-(T cst) const {
52 return Value{val_ - cst, unc_};
53 }
54 Value operator*(const Value&) const;
55 template <typename T>
56 inline Value operator*(T cst) const {
57 return Value{val_ * cst, unc_ * cst};
58 }
59 Value operator/(const Value&) const;
60 template <typename T>
61 inline Value operator/(T cst) const {
62 return Value{val_ / cst, unc_ / cst};
63 }
64
65 private:
66 double val_;
67 double unc_;
68 };
69} // namespace cepgen
70
71#endif
A scalar value with its uncertainty.
Definition Value.h:26
friend std::ostream & operator<<(std::ostream &, const Value &)
Definition Value.cpp:44
Value operator-(T cst) const
Definition Value.h:51
Value operator+(const Value &) const
Definition Value.cpp:30
bool operator<(const Value &oth) const
Comparison operator.
Definition Value.h:40
Value operator+(T cst) const
Definition Value.h:46
Value operator*(const Value &) const
Definition Value.cpp:34
Value operator/(const Value &) const
Definition Value.cpp:39
Value operator*(T cst) const
Definition Value.h:56
double relativeUncertainty() const
Relative uncertainty around the central value.
Definition Value.cpp:28
Value operator/(T cst) const
Definition Value.h:61
Value operator-(const Value &) const
Definition Value.cpp:32
double uncertainty() const
Absolute uncertainty around the central value.
Definition Value.h:35
Common namespace for this Monte Carlo generator.