1 #ifndef __RecoEgamma_EgammaTools_MVAValueMapProducer_H__
2 #define __RecoEgamma_EgammaTools_MVAValueMapProducer_H__
23 template <
class ParticleType>
50 template <
typename ValueType,
class HandleType>
53 const std::vector<ValueType>&
values,
55 auto valMap = std::make_unique<edm::ValueMap<ValueType>>();
63 std::vector<std::unique_ptr<AnyMVAEstimatorRun2Base>> mvaEstimators;
67 for (
auto& imva : vConfig) {
71 mvaEstimators.emplace_back(
76 <<
" failed to find proper configuration for one of the MVAs in the main python script " << std::endl;
83 std::vector<std::string>
names;
84 for (
auto& imva : vConfig) {
92 template <
class ParticleType>
95 mvaEstimators_(getMVAEstimators(iConfig.getParameterSetVector(
"mvaConfigurations"))),
96 mvaValueMapNames_(getValueMapNames(iConfig.getParameterSetVector(
"mvaConfigurations"),
"Values")),
97 mvaRawValueMapNames_(getValueMapNames(iConfig.getParameterSetVector(
"mvaConfigurations"),
"RawValues")),
98 mvaCategoriesMapNames_(getValueMapNames(iConfig.getParameterSetVector(
"mvaConfigurations"),
"Categories")),
99 variableHelper_(consumesCollector()) {
101 produces<edm::ValueMap<float>>(
name);
103 produces<edm::ValueMap<float>>(
name);
105 produces<edm::ValueMap<int>>(
name);
108 template <
class ParticleType>
112 std::vector<float> auxVariables = variableHelper_.getAuxVariables(
iEvent);
117 for (
unsigned iEstimator = 0; iEstimator < mvaEstimators_.size(); iEstimator++) {
118 std::vector<float> mvaValues;
119 std::vector<float> mvaRawValues;
120 std::vector<int> mvaCategories;
123 for (
auto const&
cand :
src->ptrs()) {
125 const float response = mvaEstimators_[iEstimator]->mvaValue(
cand.get(), auxVariables,
cat);
126 mvaRawValues.push_back(response);
127 mvaValues.push_back(2.0 / (1.0 +
exp(-2.0 * response)) - 1);
128 mvaCategories.push_back(
cat);
131 writeValueMap(
iEvent,
src, mvaValues, mvaValueMapNames_[iEstimator]);
132 writeValueMap(
iEvent,
src, mvaRawValues, mvaRawValueMapNames_[iEstimator]);
133 writeValueMap(
iEvent,
src, mvaCategories, mvaCategoriesMapNames_[iEstimator]);
138 template <
class ParticleType>