1 #ifndef __RecoEgamma_EgammaTools_MVAValueMapProducer_H__ 2 #define __RecoEgamma_EgammaTools_MVAValueMapProducer_H__ 21 template <
class ParticleType>
29 static std::unique_ptr<egamma::MVAObjectCache>
31 return std::make_unique<egamma::MVAObjectCache>(conf);
46 const std::vector<T> &
values,
63 template <
class ParticleType>
76 const auto& all_mvas = mva_cache->
allMVAs();
77 for(
auto mvaItr = all_mvas.begin(); mvaItr != all_mvas.end(); ++mvaItr ) {
83 const auto& currentEstimator = mvaItr->second;
84 const std::string full_name = ( currentEstimator->getName() +
85 currentEstimator->getTag() );
86 std::string thisValueMapName = full_name +
"Values";
87 std::string thisCategoriesMapName = full_name +
"Categories";
92 produces<edm::ValueMap<float> >(thisValueMapName);
93 produces<edm::ValueMap<int> >(thisCategoriesMapName);
99 template <
class ParticleType>
103 template <
class ParticleType>
118 <<
" failed to find a standard AOD or miniAOD particle collection " << std::endl;
123 const auto& all_mvas = globalCache()->allMVAs();
124 for(
auto mva_itr = all_mvas.begin(); mva_itr != all_mvas.end(); ++mva_itr ){
125 const int iEstimator =
std::distance(all_mvas.begin(),mva_itr);
130 const auto& thisEstimator = mva_itr->second;
132 std::vector<float> mvaValues;
133 std::vector<int> mvaCategories;
136 for (
size_t i = 0;
i < src->size(); ++
i){
137 auto iCand = src->ptrAt(
i);
138 mvaValues.push_back( thisEstimator->mvaValue( iCand, iEvent ) );
139 mvaCategories.push_back( thisEstimator->findCategory( iCand ) );
149 template<
class ParticleType>
template<
typename T>
152 const std::vector<T> &
values,
157 auto valMap = std::make_unique<ValueMap<T>>();
159 filler.insert(
handle, values.begin(), values.end());
164 template <
class ParticleType>
T getParameter(std::string const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
const std::unordered_map< std::string, MVAPtr > & allMVAs() const
std::vector< std::string > mvaValueMapNames_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void addDefault(ParameterSetDescription const &psetDescription)
void produce(edm::Event &, const edm::EventSetup &) override
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
void writeValueMap(edm::Event &iEvent, const edm::Handle< edm::View< ParticleType > > &handle, const std::vector< T > &values, const std::string &label) const
static std::unique_ptr< egamma::MVAObjectCache > initializeGlobalCache(const edm::ParameterSet &conf)
std::vector< std::string > mvaCategoriesMapNames_
~MVAValueMapProducer() override
MVAValueMapProducer(const edm::ParameterSet &, const egamma::MVAObjectCache *)
static void globalEndJob(const egamma::MVAObjectCache *)
edm::EDGetToken srcMiniAOD_