21 static std::unique_ptr<tensorflow::SessionCache> initializeGlobalCache(
const edm::ParameterSet&);
40 norm_(
cfg.getParameter<double>(
"norm_factor")),
41 ignore_leptons_(
cfg.getParameter<
bool>(
"ignore_leptons")),
42 max_n_pf_(
cfg.getParameter<unsigned
int>(
"max_n_pf")),
43 session_(
cache->getSession()) {
44 produces<pat::METCollection>();
47 const tensorflow::TensorShape cat_shape({1,
max_n_pf_, 1});
49 input_ = tensorflow::Tensor(tensorflow::DT_FLOAT,
shape);
50 input_cat0_ = tensorflow::Tensor(tensorflow::DT_FLOAT, cat_shape);
51 input_cat1_ = tensorflow::Tensor(tensorflow::DT_FLOAT, cat_shape);
52 input_cat2_ = tensorflow::Tensor(tensorflow::DT_FLOAT, cat_shape);
62 input_.flat<
float>().setZero();
68 float px_leptons = 0.;
69 float py_leptons = 0.;
71 for (
const auto&
pf : pfs) {
75 px_leptons +=
pf.px();
76 py_leptons +=
pf.py();
83 float* ptr = &
input_.tensor<
float, 3>()(0, i_pf, 0);
102 std::vector<tensorflow::Tensor>
outputs;
103 const std::vector<std::string>
output_names = {
"output/BiasAdd"};
115 LogDebug(
"produce") <<
"<DeepMETProducer::produce>:" << std::endl
116 <<
" MET from DeepMET Producer is MET_x " <<
px <<
" and MET_y " <<
py << std::endl;
118 auto pf_mets = std::make_unique<pat::METCollection>();
120 pf_mets->emplace_back(
reco::MET(p4, {}));
127 return std::make_unique<tensorflow::SessionCache>(
graphPath);
133 desc.add<
bool>(
"ignore_leptons",
false);
134 desc.add<
double>(
"norm_factor", 50.);
135 desc.add<
unsigned int>(
"max_n_pf", 4500);
136 desc.add<
std::string>(
"graph_path",
"RecoMET/METPUSubtraction/data/models/deepmet/deepmet_v1_2018/model.graphdef");
137 descriptions.
add(
"deepMETProducer",
desc);
std::vector< NamedTensor > NamedTensorList
MPlex< T, D1, D2, N > hypot(const MPlex< T, D1, D2, N > &a, const MPlex< T, D1, D2, N > &b)
const bool ignore_leptons_
std::string fullPath() const
void produce(edm::Event &event, const edm::EventSetup &setup) override
tensorflow::Tensor input_cat0_
tensorflow::Tensor input_cat1_
float rm_outlier(float val)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
tensorflow::Tensor input_
static std::unique_ptr< tensorflow::SessionCache > initializeGlobalCache(const edm::ParameterSet &)
static const std::unordered_map< int, int32_t > charge_embedding
void run(Session *session, const NamedTensorList &inputs, const std::vector< std::string > &outputNames, std::vector< Tensor > *outputs, const thread::ThreadPoolOptions &threadPoolOptions)
Abs< T >::type abs(const T &t)
static void globalEndJob(tensorflow::SessionCache *)
#define DEFINE_FWK_MODULE(type)
static const std::unordered_map< int, int32_t > pdg_id_embedding
const tensorflow::Session * session_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
tensorflow::Tensor input_cat2_
math::XYZTLorentzVector LorentzVector
Lorentz vector.
DeepMETProducer(const edm::ParameterSet &, const tensorflow::SessionCache *)
float scale_and_rm_outlier(float val, float scale)
const unsigned int max_n_pf_
const edm::EDGetTokenT< std::vector< pat::PackedCandidate > > pf_token_