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);
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)
static constexpr unsigned int NUM_ELEMENT_FEATURES
static constexpr unsigned int IDX_ENERGY
static constexpr int BATCH_SIZE
const std::vector< const reco::PFBlockElement * > getPFElements(const reco::PFBlockCollection &blocks)
static std::string const input
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
void setCandidateRefs(reco::PFCandidate &cand, const std::vector< const reco::PFBlockElement * > elems, size_t ielem_originator)
float normalize(float in)
const edm::EDGetTokenT< reco::PFBlockCollection > inputTagBlocks_
static const std::vector< int > pdgid_encoding
reco::PFCandidate makeCandidate(int pred_pid, int pred_charge, float pred_e, float pred_eta, float pred_phi)
static constexpr int LSH_BIN_SIZE
static constexpr int NUM_MAX_ELEMENTS_BATCH