|
|
#include <PhysicsTools/PatAlgos/plugins/BaseMVAValueMapProducer.cc>
template<typename T>
class BaseMVAValueMapProducer< T >
Description: [one line class summary]
Implementation: [Notes on implementation]
Definition at line 56 of file BaseMVAValueMapProducer.h.
◆ BaseMVAValueMapProducer()
Definition at line 58 of file BaseMVAValueMapProducer.h.
93 for (
const auto&
s : iConfig.
getParameter<std::vector<std::string>>(
"outputFormulas")) {
100 throw cms::Exception(
"ConfigError") <<
"Only 'TF' and 'TMVA' backends are supported\n";
103 produces<edm::ValueMap<float>>();
106 produces<edm::ValueMap<float>>(
n);
◆ ~BaseMVAValueMapProducer()
◆ beginStream()
◆ endStream()
◆ fillAdditionalVariables()
◆ fillDescriptions()
◆ getDescription()
Definition at line 201 of file BaseMVAValueMapProducer.h.
203 desc.
add<
edm::InputTag>(
"src")->setComment(
"input physics object collection");
204 desc.
add<std::vector<std::string>>(
"variablesOrder")->setComment(
"ordered list of MVA input variable names");
205 desc.
add<
std::string>(
"name")->setComment(
"output score variable name");
206 desc.
add<
bool>(
"isClassifier")->setComment(
"is a classifier discriminator");
211 desc.
add<
std::string>(
"backend",
"TMVA")->setComment(
"TMVA or TF");
212 desc.
add<
std::string>(
"inputTensorName",
"")->setComment(
"Name of tensorflow input tensor in the model");
213 desc.
add<
std::string>(
"outputTensorName",
"")->setComment(
"Name of tensorflow output tensor in the model");
214 desc.
add<std::vector<std::string>>(
"outputNames", std::vector<std::string>())
215 ->setComment(
"Names of the output values to be used in the output valuemap");
216 desc.
add<std::vector<std::string>>(
"outputFormulas", std::vector<std::string>())
217 ->setComment(
"Formulas to be used to post process the output");
218 desc.
add<
unsigned int>(
"nThreads", 1)->setComment(
"number of threads");
Referenced by BJetEnergyRegressionMVA::fillDescriptions().
◆ produce()
Definition at line 152 of file BaseMVAValueMapProducer.h.
157 for (
auto&
v : mvaOut)
158 v.reserve(
src->size());
160 for (
auto const&
o : *
src) {
170 tensorflow::TensorShape input_size{1, (
long long int)
positions_.size()};
172 input_tensors.resize(1);
176 input_tensors[0].second.matrix<
float>()(0,
j) =
values_[
j];
178 std::vector<tensorflow::Tensor>
outputs;
179 std::vector<std::string>
names;
182 std::vector<float> tmpOut;
184 tmpOut.push_back(
outputs.at(0).matrix<
float>()(0,
k));
190 for (
auto&
m : mvaOut) {
◆ readAdditionalCollections()
◆ setValue()
◆ backend_
◆ funcs_
◆ graph_
◆ inputTensorName_
◆ isClassifier_
◆ name_
◆ output_formulas_
◆ output_names_
◆ outputTensorName_
◆ positions_
◆ reader_
◆ session_
◆ singleThreadPool_
◆ src_
◆ tf_
◆ tmva_
◆ values_
◆ variablesOrder_
◆ weightfilename_
std::vector< std::string > output_names_
Session * createSession(SessionOptions &sessionOptions)
uint32_t dimension(pat::CandKinResolution::Parametrization parametrization)
Returns the number of free parameters in a parametrization (3 or 4)
virtual void readAdditionalCollections(edm::Event &, const edm::EventSetup &)
to be implemented in derived classes, filling values for additional variables
ParameterDescriptionBase * add(U const &iLabel, T const &value)
std::vector< StringObjectFunction< std::vector< float > > > output_formulas_
std::pair< std::string, Tensor > NamedTensor
void setValue(const std::string var, float val)
std::vector< float > values_
std::string outputTensorName_
Analysis-level muon class.
std::string inputTensorName_
tensorflow::GraphDef * graph_
std::string weightfilename_
std::vector< std::pair< std::string, StringObjectFunction< T, true > > > funcs_
Analysis-level calorimeter jet class.
void add(std::string const &label, ParameterSetDescription const &psetDescription)
const std::string names[nVars_]
std::vector< std::string > variablesOrder_
edm::EDGetTokenT< edm::View< T > > src_
std::string singleThreadPool_
std::vector< NamedTensor > NamedTensorList
std::vector< std::string > getParameterNamesForType(bool trackiness=true) const
void setLogging(const std::string &level="3")
tensorflow::Session * session_
GraphDef * loadGraphDef(const std::string &pbFile)
T getParameter(std::string const &) const
std::map< std::string, size_t > positions_
TMVA::IMethod * loadTMVAWeights(TMVA::Reader *reader, const std::string &method, const std::string &weightFile, bool verbose=false)
void run(Session *session, const NamedTensorList &inputs, const std::vector< std::string > &outputNames, std::vector< Tensor > *outputs, const thread::ThreadPoolOptions &threadPoolOptions)
static edm::ParameterSetDescription getDescription()
Analysis-level electron class.
std::string fullPath() const
virtual void fillAdditionalVariables(const T &)