CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
MLPFModel.h
Go to the documentation of this file.
1 #ifndef RecoParticleFlow_PFProducer_interface_MLPFModel
2 #define RecoParticleFlow_PFProducer_interface_MLPFModel
3 
7 
8 namespace reco::mlpf {
9  //The model takes the following number of features for each input PFElement
10  static constexpr unsigned int NUM_ELEMENT_FEATURES = 15;
11 
12  //these are defined at model creation time and set the random LSH codebook size
13  static constexpr int NUM_MAX_ELEMENTS_BATCH = 20000;
14  static constexpr int LSH_BIN_SIZE = 100;
15 
16  //In CPU mode, we only want to evaluate each event separately
17  static constexpr int BATCH_SIZE = 1;
18 
19  //The model has 12 outputs for each particle:
20  // out[0-7]: particle classification logits
21  // out[8]: regressed eta
22  // out[9]: regressed phi
23  // out[10]: regressed energy
24  // out[11]: regressed charge logit
25  static constexpr unsigned int NUM_OUTPUTS = 12;
26  static constexpr unsigned int NUM_CLASS = 7;
27  static constexpr unsigned int IDX_ETA = 8;
28  static constexpr unsigned int IDX_PHI = 9;
29  static constexpr unsigned int IDX_ENERGY = 10;
30  static constexpr unsigned int IDX_CHARGE = 11;
31 
32  //index [0, N_pdgids) -> PDGID
33  //this maps the absolute values of the predicted PDGIDs to an array of ascending indices
34  static const std::vector<int> pdgid_encoding = {0, 1, 2, 11, 13, 22, 130, 211};
35 
36  //PFElement::type -> index [0, N_types)
37  //this maps the type of the PFElement to an ascending index that is used by the model to distinguish between different elements
38  static const std::map<int, int> elem_type_encoding = {
39  {0, 0},
40  {1, 1},
41  {2, 2},
42  {3, 3},
43  {4, 4},
44  {5, 5},
45  {6, 6},
46  {7, 7},
47  {8, 8},
48  {9, 9},
49  {10, 10},
50  {11, 11},
51  };
52 
53  std::array<float, NUM_ELEMENT_FEATURES> getElementProperties(const reco::PFBlockElement& orig);
54  float normalize(float in);
55 
56  int argMax(std::vector<float> const& vec);
57 
58  reco::PFCandidate makeCandidate(int pred_pid, int pred_charge, float pred_e, float pred_eta, float pred_phi);
59 
60  const std::vector<const reco::PFBlockElement*> getPFElements(const reco::PFBlockCollection& blocks);
61 
63  const std::vector<const reco::PFBlockElement*> elems,
64  size_t ielem_originator);
65 }; // namespace reco::mlpf
66 
67 #endif
Abstract base class for a PFBlock element (track, cluster...)
static constexpr unsigned int IDX_ETA
Definition: MLPFModel.h:27
static constexpr unsigned int NUM_CLASS
Definition: MLPFModel.h:26
std::array< float, NUM_ELEMENT_FEATURES > getElementProperties(const reco::PFBlockElement &orig)
Definition: MLPFModel.cc:15
static constexpr unsigned int NUM_OUTPUTS
Definition: MLPFModel.h:25
int argMax(std::vector< float > const &vec)
Definition: MLPFModel.cc:158
static constexpr unsigned int NUM_ELEMENT_FEATURES
Definition: MLPFModel.h:10
tuple blocks
Definition: gather_cfg.py:90
static constexpr unsigned int IDX_ENERGY
Definition: MLPFModel.h:29
static constexpr int BATCH_SIZE
Definition: MLPFModel.h:17
const std::vector< const reco::PFBlockElement * > getPFElements(const reco::PFBlockCollection &blocks)
Definition: MLPFModel.cc:185
static constexpr unsigned int IDX_PHI
Definition: MLPFModel.h:28
static constexpr unsigned int IDX_CHARGE
Definition: MLPFModel.h:30
std::vector< PFBlock > PFBlockCollection
collection of PFBlock objects
Definition: PFBlockFwd.h:10
static const std::map< int, int > elem_type_encoding
Definition: MLPFModel.h:38
tuple mlpf
Definition: mlpf_cff.py:4
void setCandidateRefs(reco::PFCandidate &cand, const std::vector< const reco::PFBlockElement * > elems, size_t ielem_originator)
Definition: MLPFModel.cc:204
float normalize(float in)
Definition: MLPFModel.cc:149
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:41
static const std::vector< int > pdgid_encoding
Definition: MLPFModel.h:34
reco::PFCandidate makeCandidate(int pred_pid, int pred_charge, float pred_e, float pred_eta, float pred_phi)
Definition: MLPFModel.cc:162
static constexpr int LSH_BIN_SIZE
Definition: MLPFModel.h:14
static constexpr int NUM_MAX_ELEMENTS_BATCH
Definition: MLPFModel.h:13