25 static std::unique_ptr<ONNXRuntime> initializeGlobalCache(
const edm::ParameterSet&);
34 : pfCandidatesPutToken_{produces<reco::PFCandidateCollection>()},
35 inputTagBlocks_(consumes<reco::PFBlockCollection>(
cfg.getParameter<
edm::InputTag>(
"src"))) {}
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;
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:";
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;
174 "RecoParticleFlow/PFProducer/data/mlpf/" 175 "mlpf_2021_11_16__no_einsum__all_data_cms-best-of-asha-scikit_20211026_042043_178263.workergpu010.onnx"));
Abstract base class for a PFBlock element (track, cluster...)
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
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 std::unique_ptr< ONNXRuntime > initializeGlobalCache(const edm::ParameterSet &)
static constexpr unsigned int NUM_ELEMENT_FEATURES
static constexpr unsigned int IDX_PT
static constexpr unsigned int IDX_ENERGY
void produce(edm::Event &event, const edm::EventSetup &setup) override
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 void globalEndJob(const ONNXRuntime *)
#define DEFINE_FWK_MODULE(type)
MLPFProducer(const edm::ParameterSet &, const ONNXRuntime *)
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
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
float normalize(float in)
const edm::EDGetTokenT< reco::PFBlockCollection > inputTagBlocks_
static constexpr unsigned int IDX_COS_PHI
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
static const std::vector< int > pdgid_encoding
void setCandidateRefs(reco::PFCandidate &cand, const std::vector< const reco::PFBlockElement *> elems, size_t ielem_originator)
static constexpr int LSH_BIN_SIZE
static constexpr int NUM_MAX_ELEMENTS_BATCH