43 std::vector<const reco::PFBlockElement*> selected_elements;
44 unsigned int num_elements_total = 0;
45 for (
const auto* pelem : all_elements) {
49 num_elements_total += 1;
50 selected_elements.push_back(pelem);
62 std::cout <<
"tensor_size=" << tensor_size << std::endl;
67 unsigned int ielem = 0;
68 for (
const auto* pelem : selected_elements) {
69 if (ielem > tensor_size) {
73 const auto& elem = *pelem;
80 inputs[0][ielem * NUM_ELEMENT_FEATURES + iprop] =
normalize(props[iprop]);
87 const auto&
output = outputs[0];
92 std::vector<reco::PFCandidate> pOutputCandidateCollection;
93 for (
size_t ielem = 0; ielem < num_elements_total; ielem++) {
94 std::vector<float> pred_id_probas(
IDX_CLASS + 1, 0.0);
97 for (
unsigned int idx_id = 0; idx_id <=
IDX_CLASS; idx_id++) {
102 pred_id_probas[idx_id] = pred_proba;
105 auto imax =
argMax(pred_id_probas);
111 std::cout <<
"ielem=" << ielem <<
" inputs:";
113 std::cout << iprop <<
"=" <<
inputs[0][ielem * NUM_ELEMENT_FEATURES + iprop] <<
" ";
116 std::cout <<
"ielem=" << ielem <<
" pred: pid=" << pred_pid << std::endl;
130 if (pred_pid == 13 && eltTrack->muonRef().isNull()) {
135 if ((pred_pid == 211) && (eltTrack->isLinkedToDisplacedVertex())) {
148 auto cand =
makeCandidate(pred_pid, pred_charge, pred_pt, pred_eta, pred_sin_phi, pred_cos_phi, pred_e);
150 pOutputCandidateCollection.push_back(cand);
153 std::cout <<
"ielem=" << ielem <<
" cand: pid=" << cand.pdgId() <<
" E=" << cand.energy() <<
" pt=" << cand.pt()
154 <<
" eta=" << cand.eta() <<
" phi=" << cand.phi() <<
" charge=" << cand.charge() << std::endl;
Abstract base class for a PFBlock element (track, cluster...)
static constexpr unsigned int IDX_ETA
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_PT
static constexpr unsigned int IDX_ENERGY
const std::vector< const reco::PFBlockElement * > getPFElements(const reco::PFBlockCollection &blocks)
static constexpr unsigned int NUM_OUTPUT_FEATURES
const edm::EDPutTokenT< reco::PFCandidateCollection > pfCandidatesPutToken_
static constexpr unsigned int IDX_CHARGE
reco::PFCandidate makeCandidate(int pred_pid, int pred_charge, float pred_pt, float pred_eta, float pred_sin_phi, float pred_cos_phi, float pred_e)
static constexpr unsigned int IDX_CLASS
static constexpr unsigned int IDX_SIN_PHI
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 constexpr unsigned int IDX_COS_PHI
static const std::vector< int > pdgid_encoding
static constexpr int LSH_BIN_SIZE
static constexpr int NUM_MAX_ELEMENTS_BATCH