1 #ifndef RecoEgamma_EgammaTools_MVAVariableManager_H 2 #define RecoEgamma_EgammaTools_MVAVariableManager_H 14 template <
class ParticleType>
26 init(variableDefinitionFileName);
43 std::ifstream
file(variableDefinitionFileEdm.
fullPath());
51 if (name.find(
"#") != std::string::npos) {
66 std::map<std::string,int>::iterator it =
indexMap_.find(name);
86 if (varInfo.fromVariableHelper >= 0) {
89 value = (*vMap)[ptclPtr];
90 }
else if (varInfo.isGlobalVariable >= 0) {
97 if (varInfo.hasLowerClip && value < varInfo.lowerClipValue) {
98 value = varInfo.lowerClipValue;
100 if (varInfo.hasUpperClip && value > varInfo.upperClipValue) {
101 value = varInfo.upperClipValue;
110 if (varInfo.fromVariableHelper >= 0) {
113 value = (*vMap)[ptclPtr];
114 }
else if (varInfo.isGlobalVariable >= 0) {
117 value = *valueHandle;
121 if (varInfo.hasLowerClip && value < varInfo.lowerClipValue) {
122 value = varInfo.lowerClipValue;
124 if (varInfo.hasUpperClip && value > varInfo.upperClipValue) {
125 value = varInfo.upperClipValue;
155 bool hasLowerClip = lowerClip.find(
"None") == std::string::npos;
156 bool hasUpperClip = upperClip.find(
"None") == std::string::npos;
158 formula.find(
"IDValueMapProducer") != std::string::npos ||
159 formula.find(
"egmPhotonIsolation") != std::string::npos;
166 if ( !(fromVariableHelper || isGlobalVariable) ) {
176 if (fromVariableHelper) {
179 if (isGlobalVariable) {
184 fromVariableHelper = fromVariableHelper ?
nHelperVars_++ : -1;
185 isGlobalVariable = isGlobalVariable ?
nGlobalVars_++ : - 1;
187 MVAVariableInfo varInfo = {
193 .isGlobalVariable = isGlobalVariable
void setConsumes(edm::ConsumesCollector &&cc)
const std::string & getName(int index) const
float getValue(int index, const edm::Ptr< ParticleType > &ptclPtr, const edm::Event &iEvent) const
MVAVariableManager(const std::string &variableDefinitionFileName)
std::vector< std::string > names_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
std::map< std::string, int > indexMap_
std::vector< std::string > formulas_
std::vector< edm::EDGetToken > globalTokens_
void addVariable(const std::string &name, const std::string &formula, const std::string &lowerClip, const std::string &upperClip)
std::vector< edm::InputTag > helperInputTags_
int getVarIndex(const std::string &name)
std::vector< edm::EDGetToken > helperTokens_
float getValue(int index, const edm::Ptr< ParticleType > &ptclPtr, const edm::EventBase &iEvent) const
std::vector< edm::InputTag > globalInputTags_
std::vector< StringObjectFunction< ParticleType > > functions_
bool getByLabel(InputTag const &, Handle< T > &) const
std::string fullPath() const
std::vector< MVAVariableInfo > variableInfos_
int init(const std::string &variableDefinitionFileName)