17 template <
class ParticleType>
34 const std::vector<T> &
values,
52 template <
class ParticleType>
64 const std::vector<edm::ParameterSet>& mvaEstimatorConfigs
66 for(
auto &imva : mvaEstimatorConfigs ){
68 std::unique_ptr<AnyMVAEstimatorRun2Base> thisEstimator;
69 thisEstimator.reset(
NULL);
79 estimator->setConsumes( consumesCollector() );
81 thisEstimator.reset(estimator);
85 <<
" failed to find proper configuration for one of the MVAs in the main python script " << std::endl;
89 mvaEstimators_.emplace_back( thisEstimator.release() );
94 const auto& currentEstimator = mvaEstimators_.back();
95 std::string thisValueMapName = currentEstimator->getName() +
"Values";
96 std::string thisCategoriesMapName = currentEstimator->getName() +
"Categories";
97 mvaValueMapNames_.push_back( thisValueMapName );
98 mvaCategoriesMapNames_.push_back( thisCategoriesMapName );
101 produces<edm::ValueMap<float> >(thisValueMapName);
102 produces<edm::ValueMap<int> >(thisCategoriesMapName);
109 template <
class ParticleType>
113 template <
class ParticleType>
124 if( !
src.isValid() ){
128 <<
" failed to find a standard AOD or miniAOD particle collection " << std::endl;
133 for(
unsigned iEstimator = 0; iEstimator < mvaEstimators_.size(); iEstimator++ ){
138 mvaEstimators_[iEstimator]->getEventContent( iEvent );
140 std::vector<float> mvaValues;
141 std::vector<int> mvaCategories;
144 for (
size_t i = 0;
i <
src->size(); ++
i){
145 auto iCand =
src->ptrAt(
i);
147 mvaValues.push_back( mvaEstimators_[iEstimator]->mvaValue( iCand ) );
148 mvaCategories.push_back( mvaEstimators_[iEstimator]->findCategory( iCand ) );
151 writeValueMap(iEvent,
src, mvaValues, mvaValueMapNames_[iEstimator] );
152 writeValueMap(iEvent,
src, mvaCategories, mvaCategoriesMapNames_[iEstimator] );
159 template<
class ParticleType>
template<
typename T>
162 const std::vector<T> &
values,
171 iEvent.
put(valMap, label);
174 template <
class ParticleType>
T getParameter(std::string const &) const
VParameterSet const & getParameterSetVector(std::string const &name) const
std::vector< std::string > mvaValueMapNames_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
void insert(const H &h, I begin, I end)
std::vector< std::unique_ptr< AnyMVAEstimatorRun2Base > > mvaEstimators_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void addDefault(ParameterSetDescription const &psetDescription)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
virtual void produce(edm::Event &, const edm::EventSetup &) override
void writeValueMap(edm::Event &iEvent, const edm::Handle< edm::View< ParticleType > > &handle, const std::vector< T > &values, const std::string &label) const
std::vector< std::string > mvaCategoriesMapNames_
MVAValueMapProducer(const edm::ParameterSet &)
edm::EDGetToken srcMiniAOD_
T get(const Candidate &c)