EvtGen
2.2.0
Monte Carlo generator of particle decays, in particular the weak decays of heavy flavour particles such as B mesons.
Toggle main menu visibility
Loading...
Searching...
No Matches
EvtGenBase
EvtValError.hh
Go to the documentation of this file.
1
2
/***********************************************************************
3
* Copyright 1998-2020 CERN for the benefit of the EvtGen authors *
4
* *
5
* This file is part of EvtGen. *
6
* *
7
* EvtGen is free software: you can redistribute it and/or modify *
8
* it under the terms of the GNU General Public License as published by *
9
* the Free Software Foundation, either version 3 of the License, or *
10
* (at your option) any later version. *
11
* *
12
* EvtGen is distributed in the hope that it will be useful, *
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15
* GNU General Public License for more details. *
16
* *
17
* You should have received a copy of the GNU General Public License *
18
* along with EvtGen. If not, see <https://www.gnu.org/licenses/>. *
19
***********************************************************************/
20
21
#ifndef EVT_VAL_ERROR_HH
22
#define EVT_VAL_ERROR_HH
23
24
#include <assert.h>
25
#include <iostream>
26
#include <math.h>
27
28
// Value and its associated error. E.g. this could be interval size and
29
// the error associated with numerical integration.
30
31
class
EvtValError
final {
32
public
:
33
EvtValError
();
34
EvtValError
(
double
val );
35
EvtValError
(
double
val,
double
err );
36
EvtValError
(
const
EvtValError
& other );
37
38
inline
int
valueKnown
()
const
{
return
m_valKnown
; }
39
inline
double
value
()
const
40
{
41
assert(
m_valKnown
);
42
return
m_val
;
43
}
44
inline
int
errorKnown
()
const
{
return
m_errKnown
; }
45
inline
double
error
()
const
46
{
47
assert(
m_errKnown
);
48
return
m_err
;
49
}
50
51
double
prec
()
const
;
52
void
operator=
(
const
EvtValError
& other );
53
void
operator*=
(
const
EvtValError
& other );
54
void
operator/=
(
const
EvtValError
& other );
55
void
operator+=
(
const
EvtValError
& other );
56
void
operator*=
(
double
c );
57
58
void
print
( std::ostream& )
const
;
59
60
private
:
61
int
m_valKnown
;
62
double
m_val
;
63
int
m_errKnown
;
64
double
m_err
;
65
};
66
67
EvtValError
operator*
(
const
EvtValError
& x1,
const
EvtValError
& x2 );
68
EvtValError
operator/
(
const
EvtValError
& x1,
const
EvtValError
& x2 );
69
EvtValError
operator+
(
const
EvtValError
& x1,
const
EvtValError
& x2 );
70
EvtValError
operator*
(
const
EvtValError
& x,
double
c );
71
EvtValError
operator*
(
double
c,
const
EvtValError
& x );
72
73
std::ostream&
operator<<
( std::ostream&,
const
EvtValError
& );
74
75
// Perform an accept/reject fraction count
76
77
template
<
class
InputIterator,
class
Predicate>
78
EvtValError
accept_reject
( InputIterator it, InputIterator end, Predicate pred )
79
{
80
int
itsTried = 0;
81
int
itsPassed = 0;
82
while
( it != end ) {
83
itsTried++;
84
if
( pred( *it++ ) )
85
itsPassed++;
86
}
87
88
return
EvtValError
( ( (
double
)itsPassed ) / ( (
double
)itsTried ),
89
sqrt( itsPassed ) / ( (
double
)itsTried ) );
90
}
91
92
#endif
operator<<
std::ostream & operator<<(std::ostream &, const EvtValError &)
operator+
EvtValError operator+(const EvtValError &x1, const EvtValError &x2)
Definition
EvtValError.cpp:147
operator/
EvtValError operator/(const EvtValError &x1, const EvtValError &x2)
Definition
EvtValError.cpp:140
accept_reject
EvtValError accept_reject(InputIterator it, InputIterator end, Predicate pred)
Definition
EvtValError.hh:78
operator*
EvtValError operator*(const EvtValError &x1, const EvtValError &x2)
Definition
EvtValError.cpp:133
EvtValError
Definition
EvtValError.hh:31
EvtValError::errorKnown
int errorKnown() const
Definition
EvtValError.hh:44
EvtValError::operator=
void operator=(const EvtValError &other)
Definition
EvtValError.cpp:58
EvtValError::error
double error() const
Definition
EvtValError.hh:45
EvtValError::EvtValError
EvtValError()
Definition
EvtValError.cpp:29
EvtValError::m_valKnown
int m_valKnown
Definition
EvtValError.hh:61
EvtValError::operator/=
void operator/=(const EvtValError &other)
Definition
EvtValError.cpp:81
EvtValError::valueKnown
int valueKnown() const
Definition
EvtValError.hh:38
EvtValError::operator+=
void operator+=(const EvtValError &other)
Definition
EvtValError.cpp:110
EvtValError::operator*=
void operator*=(const EvtValError &other)
Definition
EvtValError.cpp:66
EvtValError::m_val
double m_val
Definition
EvtValError.hh:62
EvtValError::prec
double prec() const
Definition
EvtValError.cpp:52
EvtValError::value
double value() const
Definition
EvtValError.hh:39
EvtValError::print
void print(std::ostream &) const
Definition
EvtValError.cpp:96
EvtValError::m_err
double m_err
Definition
EvtValError.hh:64
EvtValError::m_errKnown
int m_errKnown
Definition
EvtValError.hh:63
Generated by
1.17.0