1 #ifndef __RecoEgamma_EgammaTools_MVAValueMapProducer_H__ 2 #define __RecoEgamma_EgammaTools_MVAValueMapProducer_H__ 21 template <
class ParticleType>
38 const std::vector<T> &
values,
57 template <
class ParticleType>
69 const std::vector<edm::ParameterSet>& mvaEstimatorConfigs
72 for(
auto &imva : mvaEstimatorConfigs ){
83 <<
" failed to find proper configuration for one of the MVAs in the main python script " << std::endl;
94 const std::string thisValueMapName = fullName +
"Values";
95 const std::string thisRawValueMapName = fullName +
"RawValues";
96 const std::string thisCategoriesMapName = fullName +
"Categories";
103 produces<edm::ValueMap<float>>(thisValueMapName );
104 produces<edm::ValueMap<float>>(thisRawValueMapName );
105 produces<edm::ValueMap<int>> (thisCategoriesMapName);
111 template <
class ParticleType>
115 template <
class ParticleType>
128 <<
" failed to find a standard AOD or miniAOD particle collection " << std::endl;
133 for(
unsigned iEstimator = 0; iEstimator <
mvaEstimators_.size(); iEstimator++ ){
135 std::vector<float> mvaValues;
136 std::vector<float> mvaRawValues;
137 std::vector<int> mvaCategories;
140 for (
size_t i = 0;
i < src->size(); ++
i){
141 auto iCand = src->ptrAt(
i);
142 const float response =
mvaEstimators_[iEstimator]->mvaValue( iCand, iEvent );
143 mvaRawValues.push_back( response );
144 mvaValues.push_back( 2.0/(1.0+
exp(-2.0*response))-1 );
145 mvaCategories.push_back(
mvaEstimators_[iEstimator]->findCategory( iCand ) );
156 template<
class ParticleType>
template<
typename T>
159 const std::vector<T> &
values,
162 auto valMap = std::make_unique<edm::ValueMap<T>>();
164 filler.insert(
handle, values.begin(), values.end());
169 template <
class ParticleType>
T getParameter(std::string const &) const
VParameterSet const & getParameterSetVector(std::string const &name) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
def create(alignables, pedeDump, additionalData, outputFile, config)
std::vector< std::string > mvaValueMapNames_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
std::vector< std::string > mvaRawValueMapNames_
std::vector< std::unique_ptr< AnyMVAEstimatorRun2Base > > mvaEstimators_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void addDefault(ParameterSetDescription const &psetDescription)
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() override
MVAValueMapProducer(const edm::ParameterSet &)
edm::EDGetToken srcMiniAOD_
T get(const Candidate &c)