1 #ifndef RecoEgamma_EgammaTools_MVAVariableManager_H
2 #define RecoEgamma_EgammaTools_MVAVariableManager_H
11 template <
class ParticleType>
14 template <
class IndexMap>
17 std::ifstream
file(variableDefinitionFileEdm.
fullPath());
25 if (name.find(
'#') != std::string::npos) {
29 file >> formula >> lower >> upper;
38 std::map<std::string, int>::iterator it =
indexMap_.find(name);
55 if (varInfo.auxIndex >= 0)
56 value = auxVariables[varInfo.auxIndex];
60 if (varInfo.hasLowerClip && value < varInfo.lowerClipValue) {
61 value = varInfo.lowerClipValue;
63 if (varInfo.hasUpperClip && value > varInfo.upperClipValue) {
64 value = varInfo.upperClipValue;
78 template <
class IndexMap>
83 IndexMap
const &indexMap) {
84 bool hasLowerClip = lowerClip.find(
"None") == std::string::npos;
85 bool hasUpperClip = upperClip.find(
"None") == std::string::npos;
86 bool isAuxiliary = formula.find(
"Rho") != std::string::npos;
87 float lowerClipValue = hasLowerClip ? (float)::atof(lowerClip.c_str()) : 0.;
88 float upperClipValue = hasUpperClip ? (float)::atof(upperClip.c_str()) : 0.;
99 int auxIndex = isAuxiliary ? indexMap.at(formula) : -1;
101 MVAVariableInfo varInfo{
102 .hasLowerClip = hasLowerClip,
103 .hasUpperClip = hasUpperClip,
104 .lowerClipValue = lowerClipValue,
105 .upperClipValue = upperClipValue,
106 .auxIndex = auxIndex,
118 std::vector<ThreadSafeFunctor<StringObjectFunction<ParticleType>>>
functions_;
const std::string & getName(int index) const
std::vector< ThreadSafeFunctor< StringObjectFunction< ParticleType > > > functions_
void addVariable(const std::string &name, const std::string &formula, const std::string &lowerClip, const std::string &upperClip, IndexMap const &indexMap)
std::vector< std::string > names_
std::map< std::string, int > indexMap_
std::vector< std::string > formulas_
float getValue(int index, const ParticleType &particle, const std::vector< float > &auxVariables) const
MVAVariableManager(const std::string &variableDefinitionFileName, IndexMap const &indexMap)
int getVarIndex(const std::string &name)
std::string fullPath() const
std::vector< MVAVariableInfo > variableInfos_
ParticleType
Definition of particle types.