EICrecon
JANA based reconstruction for the EPIC detector
Loading...
Searching...
No Matches
Public Member Functions | List of all members
eicrecon::EvaluatorSvc Class Reference

Provides an interface to a compiler that converts string expressions to native std::function. More...

#include <EvaluatorSvc.h>

Inheritance diagram for eicrecon::EvaluatorSvc:
Inheritance graph
[legend]
Collaboration diagram for eicrecon::EvaluatorSvc:
Collaboration graph
[legend]

Public Member Functions

void init ()
 
template<class... Args>
std::function< double(Args...)> compile (const std::string &expr, std::function< std::unordered_map< std::string, double >(Args...)> transform)
 Compile expression expr to std::function.
 
std::function< double(const std::unordered_map< std::string, double > &)> _compile (const std::string &expr, const std::vector< std::string > &params)
 Compile expression expr to std::function.
 

Detailed Description

Provides an interface to a compiler that converts string expressions to native std::function.

The underlying implementation relies on ROOT's TInterpreter, but this may change in the future. User can inspect the full C++ code by setting -PEvaluatorSvc:LogLevel=debug, the list of provided variables is apparent from the same output.

Currently, return type is fixed to double, and all input parameters have to be convertible to double.

Member Function Documentation

◆ _compile()

std::function< double(const std::unordered_map< std::string, double > &)> eicrecon::EvaluatorSvc::_compile ( const std::string &  expr,
const std::vector< std::string > &  params 
)

Compile expression expr to std::function.

Parameters
exprString expression to compile (e.g. "a + b")
paramsList of parameter names used in the expression (e.g. {"a", "b"})

The resulting function accepts a dictionary (std::unordered_map) of parameter values.

◆ compile()

template<class... Args>
std::function< double(Args...)> eicrecon::EvaluatorSvc::compile ( const std::string &  expr,
std::function< std::unordered_map< std::string, double >(Args...)>  transform 
)
inline

Compile expression expr to std::function.

Parameters
exprString expression to compile (e.g. "0.998", "a + b")
ArgsTypes of arguments for the resulting function
transformFunction providing mapping from Args

The Args must be default-constructible types, since transform need to be called at compilation time to determine the list of available parameters.

◆ init()

void eicrecon::EvaluatorSvc::init ( )

The documentation for this class was generated from the following files: