32 : pfCandidatesPutToken_{produces<reco::PFCandidateCollection>()},
44 const long long int num_elements_total = all_elements.size();
52 tensorflow::Tensor
input(tensorflow::DT_FLOAT, shape);
53 input.flat<
float>().setZero();
56 unsigned int ielem = 0;
57 for (
const auto* pelem : all_elements) {
58 const auto& elem = *pelem;
65 input.tensor<float, 3>()(0, ielem, iprop) =
normalize(props[iprop]);
72 const std::vector<std::string> output_names = {
"Identity:0"};
75 std::vector<tensorflow::Tensor> outputs;
86 const auto out_arr = outputs[0].tensor<float, 3>();
88 std::vector<reco::PFCandidate> pOutputCandidateCollection;
89 for (
unsigned int ielem = 0; ielem < all_elements.size(); ielem++) {
91 std::vector<float> pred_id_logits;
92 for (
unsigned int idx_id = 0; idx_id <=
NUM_CLASS; idx_id++) {
93 pred_id_logits.push_back(out_arr(0, ielem, idx_id));
100 float pred_eta = out_arr(0, ielem,
IDX_ETA);
101 float pred_phi = out_arr(0, ielem,
IDX_PHI);
102 float pred_charge = out_arr(0, ielem,
IDX_CHARGE);
107 auto cand =
makeCandidate(pred_pid, pred_charge, pred_e, pred_eta, pred_phi);
109 pOutputCandidateCollection.push_back(cand);
118 std::unique_ptr<MLPFCache> cache = std::make_unique<MLPFCache>();
135 desc.
add<
std::string>(
"model_path",
"RecoParticleFlow/PFProducer/data/mlpf/mlpf_2020_11_04.pb");
Session * createSession(SessionOptions &sessionOptions)
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
std::vector< NamedTensor > NamedTensorList
static constexpr unsigned int IDX_ETA
static constexpr unsigned int NUM_CLASS
std::array< float, NUM_ELEMENT_FEATURES > getElementProperties(const reco::PFBlockElement &orig)
int argMax(std::vector< float > const &vec)
#define DEFINE_FWK_MODULE(type)
GraphDef * loadGraphDef(const std::string &pbFile)
static constexpr unsigned int NUM_ELEMENT_FEATURES
static void globalEndJob(MLPFCache *)
static constexpr unsigned int IDX_ENERGY
static constexpr int BATCH_SIZE
void produce(edm::Event &event, const edm::EventSetup &setup) override
const std::vector< const reco::PFBlockElement * > getPFElements(const reco::PFBlockCollection &blocks)
static std::string const input
const tensorflow::GraphDef * graph_def
static std::unique_ptr< MLPFCache > initializeGlobalCache(const edm::ParameterSet &)
const edm::EDPutTokenT< reco::PFCandidateCollection > pfCandidatesPutToken_
void run(Session *session, const NamedTensorList &inputs, const std::vector< std::string > &outputNames, std::vector< Tensor > *outputs, const thread::ThreadPoolOptions &threadPoolOptions)
static constexpr unsigned int IDX_PHI
tensorflow::Session * session_
static constexpr unsigned int IDX_CHARGE
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void setCandidateRefs(reco::PFCandidate &cand, const std::vector< const reco::PFBlockElement * > elems, size_t ielem_originator)
T getParameter(std::string const &) const
float normalize(float in)
const edm::EDGetTokenT< reco::PFBlockCollection > inputTagBlocks_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
std::string fullPath() const
static const std::vector< int > pdgid_encoding
const std::string model_path_
reco::PFCandidate makeCandidate(int pred_pid, int pred_charge, float pred_e, float pred_eta, float pred_phi)
static constexpr int LSH_BIN_SIZE
MLPFProducer(const edm::ParameterSet &, const MLPFCache *)
static constexpr int NUM_MAX_ELEMENTS_BATCH