9#include <analysis/VariableManager/Manager.h>
10#include <framework/utilities/FormulaParser.h>
29 if (!var)
throw std::runtime_error(
"Could not find " + name +
" via the Variable::Manager. Check the name");
36 return [value](
const Particle*) {
return value; };
42 return [op, a, b](
const Particle * p) {
46 return std::get<double>(a(p)) + std::get<double>(b(p));
47 }
catch (std::bad_variant_access&) {
49 return std::get<double>(a(p)) + std::get<int>(b(p));
50 }
catch (std::bad_variant_access&) {
52 return std::get<int>(a(p)) + std::get<double>(b(p));
53 }
catch (std::bad_variant_access&) {
54 return double(std::get<int>(a(p)) + std::get<int>(b(p)));
60 return std::get<double>(a(p)) - std::get<double>(b(p));
61 }
catch (std::bad_variant_access&) {
63 return std::get<double>(a(p)) - std::get<int>(b(p));
64 }
catch (std::bad_variant_access&) {
66 return std::get<int>(a(p)) - std::get<double>(b(p));
67 }
catch (std::bad_variant_access&) {
68 return double(std::get<int>(a(p)) - std::get<int>(b(p)));
74 return std::get<double>(a(p)) * std::get<double>(b(p));
75 }
catch (std::bad_variant_access&) {
77 return std::get<double>(a(p)) * std::get<int>(b(p));
78 }
catch (std::bad_variant_access&) {
80 return std::get<int>(a(p)) * std::get<double>(b(p));
81 }
catch (std::bad_variant_access&) {
82 return double(std::get<int>(a(p)) * std::get<int>(b(p)));
88 return std::get<double>(a(p)) / std::get<double>(b(p));
89 }
catch (std::bad_variant_access&) {
91 return std::get<double>(a(p)) / std::get<int>(b(p));
92 }
catch (std::bad_variant_access&) {
94 return std::get<int>(a(p)) / std::get<double>(b(p));
95 }
catch (std::bad_variant_access&) {
96 return double(std::get<int>(a(p)) / std::get<int>(b(p)));
102 return std::pow(std::get<double>(a(p)), std::get<double>(b(p)));
103 }
catch (std::bad_variant_access&) {
105 return std::pow(std::get<double>(a(p)), std::get<int>(b(p)));
106 }
catch (std::bad_variant_access&) {
108 return std::pow(std::get<int>(a(p)), std::get<double>(b(p)));
109 }
catch (std::bad_variant_access&) {
110 return std::pow(std::get<int>(a(p)), std::get<int>(b(p)));
116 throw std::runtime_error(
"Cannot handle operator " + std::to_string((
int)op));
123 return [op, a, b](
const Particle * p) {
127 return a + std::get<double>(b(p));
128 }
catch (std::bad_variant_access&) {
130 return a + std::get<int>(b(p));
131 }
catch (std::bad_variant_access&) {
132 return a + std::get<bool>(b(p));
137 return a - std::get<double>(b(p));
138 }
catch (std::bad_variant_access&) {
140 return a - std::get<int>(b(p));
141 }
catch (std::bad_variant_access&) {
142 return a - std::get<bool>(b(p));
147 return a * std::get<double>(b(p));
148 }
catch (std::bad_variant_access&) {
150 return a * std::get<int>(b(p));
151 }
catch (std::bad_variant_access&) {
152 return a * std::get<bool>(b(p));
157 return a / std::get<double>(b(p));
158 }
catch (std::bad_variant_access&) {
160 return a / std::get<int>(b(p));
161 }
catch (std::bad_variant_access&) {
162 return a / std::get<bool>(b(p));
167 return std::pow(a, std::get<double>(b(p)));
168 }
catch (std::bad_variant_access&) {
170 return std::pow(a, std::get<int>(b(p)));
171 }
catch (std::bad_variant_access&) {
172 return std::pow(a, std::get<bool>(b(p)));
177 throw std::runtime_error(
"Cannot handle operator " + std::to_string((
int)op));
184 return [op, a, b](
const Particle * p) {
188 return std::get<double>(a(p)) + b;
189 }
catch (std::bad_variant_access&) {
191 return std::get<int>(a(p)) + b;
192 }
catch (std::bad_variant_access&) {
193 return std::get<bool>(a(p)) + b;
198 return std::get<double>(a(p)) - b;
199 }
catch (std::bad_variant_access&) {
201 return std::get<int>(a(p)) - b;
202 }
catch (std::bad_variant_access&) {
203 return std::get<bool>(a(p)) - b;
208 return std::get<double>(a(p)) * b;
209 }
catch (std::bad_variant_access&) {
211 return std::get<int>(a(p)) * b;
212 }
catch (std::bad_variant_access&) {
213 return std::get<bool>(a(p)) * b;
218 return std::get<double>(a(p)) / b;
219 }
catch (std::bad_variant_access&) {
221 return std::get<int>(a(p)) / b;
222 }
catch (std::bad_variant_access&) {
223 return std::get<bool>(a(p)) / b;
228 return std::pow(std::get<double>(a(p)), b);
229 }
catch (std::bad_variant_access&) {
231 return std::pow(std::get<int>(a(p)), b);
232 }
catch (std::bad_variant_access&) {
233 return std::pow(std::get<bool>(a(p)), b);
238 throw std::runtime_error(
"Cannot handle operator " + std::to_string((
int)op));
Class to store reconstructed particles.
std::function< VarVariant(const Particle *)> FunctionPtr
functions stored take a const Particle* and return VarVariant.
const Var * getVariable(std::string name)
Get the variable belonging to the given key.
static Manager & Instance()
get singleton instance.
Abstract base class for different kinds of events.