1 #ifndef PhysicsTools_PatAlgos_BaseMVAValueMapProducer 2 #define PhysicsTools_PatAlgos_BaseMVAValueMapProducer 37 #include "TMVA/Factory.h" 38 #include "TMVA/Reader.h" 53 src_(consumes<
edm::
View<
T>>(iConfig.getParameter<
edm::InputTag>(
"src"))),
72 produces<edm::ValueMap<float>>();
96 std::vector<std::pair<std::string,StringObjectFunction<T,true>>>
funcs_;
105 template <
typename T>
113 std::vector<float> mvaOut;
114 mvaOut.reserve(src->size());
115 for(
auto const &
o: *src) {
124 filler.
insert(src,mvaOut.begin(),mvaOut.end());
130 template <
typename T>
134 desc.
add<
edm::InputTag>(
"src")->setComment(
"input physics object collection");
135 desc.
add<std::vector<std::string>>(
"variablesOrder")->setComment(
"ordered list of MVA input variable names");
136 desc.
add<
std::string>(
"name")->setComment(
"output score variable name");
137 desc.
add<
bool>(
"isClassifier")->setComment(
"is a classifier discriminator");
145 template <
typename T>
150 if (
typeid(
T) ==
typeid(
pat::Jet)) modname+=
"Jet";
151 else if (
typeid(
T) ==
typeid(
pat::Muon)) modname+=
"Muon";
153 modname+=
"BaseMVAValueMapProducer";
154 descriptions.
add(modname,desc);
std::vector< float > values_
static edm::ParameterSetDescription getDescription()
void endStream() override
T getParameter(std::string const &) const
virtual void fillAdditionalVariables(const T &)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
bool getByToken(EDGetToken token, Handle< PROD > &result) const
void setAllowAnything()
allow any parameter label/value pairs
void insert(const H &h, I begin, I end)
void produce(edm::Event &, const edm::EventSetup &) override
void setValue(const std::string var, float val)
BaseMVAValueMapProducer(const edm::ParameterSet &iConfig)
std::vector< std::string > getParameterNamesForType(bool trackiness=true) const
std::map< std::string, size_t > positions_
std::vector< std::string > variablesOrder_
ParameterDescriptionBase * add(U const &iLabel, T const &value)
edm::EDGetTokenT< edm::View< T > > src_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Analysis-level electron class.
Analysis-level calorimeter jet class.
void add(std::string const &label, ParameterSetDescription const &psetDescription)
TMVA::IMethod * loadTMVAWeights(TMVA::Reader *reader, const std::string &method, const std::string &weightFile, bool verbose=false)
std::string fullPath() const
~BaseMVAValueMapProducer() override
void beginStream(edm::StreamID) override
Analysis-level muon class.
std::vector< std::pair< std::string, StringObjectFunction< T, true > > > funcs_
virtual void readAdditionalCollections(edm::Event &, const edm::EventSetup &)
to be implemented in derived classes, filling values for additional variables