Belle II Software
release-05-02-19
Main Page
Modules
Namespaces
Namespace List
Namespace Members
All
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Functions
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
r
s
t
u
v
w
x
z
Variables
a
b
c
d
e
f
g
h
i
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Typedefs
a
b
c
d
e
h
i
l
m
n
p
r
s
t
v
w
Enumerations
Enumerator
c
d
f
p
t
u
v
w
Classes
Class List
Class Hierarchy
Class Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
Enumerations
a
b
c
d
e
f
g
h
i
l
m
o
p
r
s
t
u
v
Enumerator
a
b
c
d
e
f
g
h
k
l
m
n
o
p
r
s
t
u
v
w
z
Related Functions
b
c
d
g
i
o
r
s
t
Files
File List
File Members
All
Functions
VariableFormulaConstructor.h
1
#include <analysis/VariableManager/Manager.h>
2
#include <framework/utilities/FormulaParser.h>
3
4
namespace
Belle2
{
12
struct
VariableFormulaConstructor
{
14
typedef
Variable::Manager::FunctionPtr
type
;
16
typedef
FormulaParserBase::EOperator
Op
;
18
type
operator()
(
const
std::string& name)
19
{
20
auto
var =
Variable::Manager::Instance
().
getVariable
(name);
21
if
(!var)
throw
std::runtime_error(
"Could not find "
+ name +
" via the Variable::Manager. Check the name"
);
22
return
var->function;
23
}
24
26
type
operator()
(
double
value)
27
{
28
return
[value](
const
Particle
*) {
return
value; };
29
}
30
32
type
operator()
(
Op
op,
const
type
& a,
const
type
& b)
33
{
34
return
[op, a, b](
const
Particle
* p) {
35
switch
(op) {
36
case
Op::c_plus
:
return
a(p) + b(p);
37
case
Op::c_minus
:
return
a(p) - b(p);
38
case
Op::c_multiply
:
return
a(p) * b(p);
39
case
Op::c_divide
:
return
a(p) / b(p);
40
case
Op::c_power
:
return
std::pow(a(p), b(p));
41
default
:
break
;
42
}
43
throw
std::runtime_error(
"Cannot handle operator "
+ std::to_string((
int
)op));
44
};
45
}
46
48
type
operator()
(
Op
op,
double
& a,
const
type
& b)
49
{
50
return
[op, a, b](
const
Particle
* p) {
51
switch
(op) {
52
case
Op::c_plus
:
return
a + b(p);
53
case
Op::c_minus
:
return
a - b(p);
54
case
Op::c_multiply
:
return
a * b(p);
55
case
Op::c_divide
:
return
a / b(p);
56
case
Op::c_power
:
return
std::pow(a, b(p));
57
default
:
break
;
58
}
59
throw
std::runtime_error(
"Cannot handle operator "
+ std::to_string((
int
)op));
60
};
61
}
62
64
type
operator()
(
Op
op,
const
type
& a,
double
b)
65
{
66
return
[op, a, b](
const
Particle
* p) {
67
switch
(op) {
68
case
Op::c_plus
:
return
a(p) + b;
69
case
Op::c_minus
:
return
a(p) - b;
70
case
Op::c_multiply
:
return
a(p) * b;
71
case
Op::c_divide
:
return
a(p) / b;
72
case
Op::c_power
:
return
std::pow(a(p), b);
73
default
:
break
;
74
}
75
throw
std::runtime_error(
"Cannot handle operator "
+ std::to_string((
int
)op));
76
};
77
}
78
};
80
}
Belle2::VariableFormulaConstructor::operator()
type operator()(const std::string &name)
Construct a variable from a given name.
Definition:
VariableFormulaConstructor.h:18
Belle2::FormulaParserBase::EOperator::c_plus
@ c_plus
Addition.
Belle2::FormulaParserBase::EOperator::c_divide
@ c_divide
Division.
Belle2::VariableFormulaConstructor
Struct to construct new variable function objects from a name or a double value or to apply operation...
Definition:
VariableFormulaConstructor.h:12
Belle2::VariableFormulaConstructor::type
Variable::Manager::FunctionPtr type
Return value we want for the FormulaParser::parse.
Definition:
VariableFormulaConstructor.h:14
Belle2::Variable::Manager::getVariable
const Var * getVariable(std::string name)
Get the variable belonging to the given key.
Definition:
Manager.cc:33
Belle2::FormulaParserBase::EOperator::c_power
@ c_power
Exponentation.
Belle2::VariableFormulaConstructor::operator()
type operator()(Op op, double &a, const type &b)
Apply operator on a double and a variable.
Definition:
VariableFormulaConstructor.h:48
Belle2::VariableFormulaConstructor::operator()
type operator()(Op op, const type &a, double b)
Apply operator on a variable and a double.
Definition:
VariableFormulaConstructor.h:64
Belle2::FormulaParserBase::EOperator::c_multiply
@ c_multiply
Multiply.
Belle2::VariableFormulaConstructor::operator()
type operator()(double value)
Construct a variable from a double value.
Definition:
VariableFormulaConstructor.h:26
Belle2
Abstract base class for different kinds of events.
Definition:
MillepedeAlgorithm.h:19
Belle2::Variable::Manager::FunctionPtr
std::function< double(const Particle *)> FunctionPtr
NOTE: the python interface is documented manually in analysis/doc/Variables.rst (because we use ROOT ...
Definition:
Manager.h:118
Belle2::Particle
Class to store reconstructed particles.
Definition:
Particle.h:77
Belle2::FormulaParserBase::EOperator
EOperator
List of known operators.
Definition:
FormulaParser.h:41
Belle2::VariableFormulaConstructor::operator()
type operator()(Op op, const type &a, const type &b)
Apply operator on two variables.
Definition:
VariableFormulaConstructor.h:32
Belle2::VariableFormulaConstructor::Op
FormulaParserBase::EOperator Op
Shorthand for the operator enum.
Definition:
VariableFormulaConstructor.h:16
Belle2::FormulaParserBase::EOperator::c_minus
@ c_minus
Subtraction.
Belle2::Variable::Manager::Instance
static Manager & Instance()
get singleton instance.
Definition:
Manager.cc:27
analysis
variables
include
VariableFormulaConstructor.h
Generated on Tue Jan 4 2022 02:50:53 for Belle II Software by
1.8.17