38 throw edm::Exception(static_cast<edm::errors::ErrorCodes>(code), message);
40 std::stringstream
error;
41 error << message <<
" Error code: " << code;
42 throw std::runtime_error(
error.str());
59 for (
auto&
i :
init) {
60 set(
i.first,
i.second);
117 std::vector<float>
values;
123 "' but no value for this parameter has been specified. Please call the appropriate 'set' "
124 "function of the JME::JetParameters object");
127 values.push_back(it->second);
134 std::vector<std::string> tokens = getTokens(definition);
137 if (tokens.size() < 3) {
139 "Definition line needs at least three tokens. Please check file format.");
142 size_t n_bins = std::stoul(tokens[0]);
144 if (tokens.size() < (n_bins + 2)) {
148 for (
size_t i = 0;
i < n_bins;
i++) {
152 size_t n_variables = std::stoul(tokens[n_bins + 1]);
154 if (tokens.size() < (1 + n_bins + 1 + n_variables + 1)) {
158 for (
size_t i = 0;
i < n_variables;
i++) {
165 std::transform(formula_str_lower.begin(), formula_str_lower.end(), formula_str_lower.begin(), ::tolower);
167 if (formula_str_lower ==
"none") {
170 if ((tokens.size() > n_bins + n_variables + 3) && (std::atoi(tokens[n_bins + n_variables + 3].c_str()))) {
171 size_t n_parameters = std::stoul(tokens[n_bins + n_variables + 3]);
173 if (tokens.size() < (1 + n_bins + 1 + n_variables + 1 + 1 + n_parameters)) {
177 for (
size_t i = 0;
i < n_parameters;
i++) {
187 if (!m_formula_str.empty()) {
188 if (m_formula_str.find(
' ') == std::string::npos)
190 m_formula = std::make_shared<reco::FormulaEvaluator>(m_formula_str);
192 m_formula = std::make_shared<TFormula>(
"jet_resolution_formula", m_formula_str.c_str());
195 m_parameters_name = getTokens(m_formula_str);
197 for (
const auto&
bin : m_bins_name) {
202 m_bins.push_back(
b->second);
205 for (
const auto&
v : m_variables_name) {
210 m_variables.push_back(
var->second);
215 std::vector<std::string> tokens = getTokens(
line);
217 if (tokens.size() < (
def.nBins() * 2 +
def.nVariables() * 2 + 1)) {
223 for (
size_t i = 0;
i <
def.nBins();
i++) {
224 Range r(std::stof(tokens[
pos]), std::stof(tokens[
pos + 1]));
226 m_bins_range.push_back(
r);
229 size_t n_parameters = std::stoul(tokens[
pos++]);
231 if (tokens.size() < (
def.nBins() * 2 +
def.nVariables() * 2 + 1 + (n_parameters -
def.nVariables() * 2))) {
235 for (
size_t i = 0;
i <
def.nVariables();
i++) {
236 Range r(std::stof(tokens[
pos]), std::stof(tokens[
pos + 1]));
238 m_variables_range.push_back(
r);
242 for (
size_t i = 0;
i < n_parameters;
i++) {
243 m_parameters_values.push_back(std::stof(tokens[
pos++]));
256 if ((
line.empty()) || (
line[0] ==
'#'))
261 if (!definition.empty()) {
284 std::cout <<
"Definition: " << std::endl;
299 std::cout << std::endl <<
"Bin contents" << std::endl;
304 for (
const auto&
bin :
record.getBinsRange()) {
312 for (
const auto&
r :
record.getVariablesRange()) {
320 for (
const auto& par :
record.getParametersValues()) {
321 std::cout <<
" Parameter #" <<
index <<
" = " << par << std::endl;
329 fout.setf(std::ios::right);
343 <<
" Resolution}" << std::endl;
347 for (
auto&
r :
record.getBinsRange()) {
348 fout << std::left << std::setw(15) <<
r.min << std::setw(15) <<
r.max << std::setw(15);
352 for (
auto&
r :
record.getVariablesRange()) {
353 fout <<
r.min << std::setw(15) <<
r.max << std::setw(15);
356 for (
auto&
p :
record.getParametersValues()) {
357 fout <<
p << std::setw(15);
360 fout << std::endl << std::setw(0);
373 const Record* good_record =
nullptr;
376 size_t valid_bins = 0;
377 size_t current_bin = 0;
378 for (
const auto&
bin :
record.getBinsRange()) {
379 if (
bin.is_inside(
bins[current_bin]))
411 double variables_[4] = {0};
428 return formula.EvalPar(variables_);