CMS 3D CMS Logo

Firmware2DiscretePF.h
Go to the documentation of this file.
1 #ifndef L1Trigger_Phase2L1ParticleFlow_FIRMWARE2DISCRETEPF_H
2 #define L1Trigger_Phase2L1ParticleFlow_FIRMWARE2DISCRETEPF_H
3 
5 
6 #include "../firmware/data.h"
7 #include <vector>
8 #include <cassert>
9 
10 namespace fw2dpf {
11 
12  // convert inputs from discrete to firmware
13  inline void convert(const PFChargedObj &src,
15  std::vector<l1tpf_impl::PFParticle> &out) {
17  pf.hwPt = src.hwPt;
18  pf.hwEta = src.hwEta;
19  pf.hwPhi = src.hwPhi;
20  pf.hwVtxEta = src.hwEta; // FIXME: get from the track
21  pf.hwVtxPhi = src.hwPhi; // before propagation
22  pf.track = track; // FIXME: ok only as long as there is a 1-1 mapping
23  pf.cluster.hwPt = 0;
24  pf.cluster.src = nullptr;
25  pf.muonsrc = nullptr;
26  switch (src.hwId) {
27  case PID_Electron:
28  pf.hwId = 1;
29  break;
30  case PID_Muon:
31  pf.hwId = 4;
32  break;
33  default:
34  pf.hwId = 0;
35  break;
36  };
37  pf.hwStatus = 0;
38  out.push_back(pf);
39  }
40  // convert inputs from discrete to firmware
41  inline void convert(const TkObj &in, l1tpf_impl::PropagatedTrack &out);
42  inline void convert(const PFChargedObj &src, const TkObj &track, std::vector<l1tpf_impl::PFParticle> &out) {
44  pf.hwPt = src.hwPt;
45  pf.hwEta = src.hwEta;
46  pf.hwPhi = src.hwPhi;
47  pf.hwVtxEta = src.hwEta; // FIXME: get from the track
48  pf.hwVtxPhi = src.hwPhi; // before propagation
49  convert(track, pf.track); // FIXME: ok only as long as there is a 1-1 mapping
50  pf.cluster.hwPt = 0;
51  pf.cluster.src = nullptr;
52  pf.muonsrc = nullptr;
53  switch (src.hwId) {
54  case PID_Electron:
55  pf.hwId = 1;
56  break;
57  case PID_Muon:
58  pf.hwId = 4;
59  break;
60  default:
61  pf.hwId = 0;
62  break;
63  };
64  pf.hwStatus = 0;
65  out.push_back(pf);
66  }
67  inline void convert(const PFNeutralObj &src, std::vector<l1tpf_impl::PFParticle> &out) {
69  pf.hwPt = src.hwPt;
70  pf.hwEta = src.hwEta;
71  pf.hwPhi = src.hwPhi;
72  pf.hwVtxEta = src.hwEta;
73  pf.hwVtxPhi = src.hwPhi;
74  pf.track.hwPt = 0;
75  pf.track.src = nullptr;
76  pf.cluster.hwPt = src.hwPt;
77  pf.cluster.src = nullptr;
78  pf.muonsrc = nullptr;
79  switch (src.hwId) {
80  case PID_Photon:
81  pf.hwId = 3;
82  break;
83  default:
84  pf.hwId = 2;
85  break;
86  }
87  pf.hwStatus = 0;
88  out.push_back(pf);
89  }
90 
91  // convert inputs from discrete to firmware
93  out.hwPt = in.hwPt;
94  out.hwCaloPtErr = in.hwPtErr;
95  out.hwEta = in.hwEta; // @calo
96  out.hwPhi = in.hwPhi; // @calo
97  out.hwZ0 = in.hwZ0;
98  out.src = nullptr;
99  }
101  out.hwPt = in.hwPt;
102  out.hwEmPt = in.hwEmPt;
103  out.hwEta = in.hwEta;
104  out.hwPhi = in.hwPhi;
105  out.isEM = in.hwIsEM;
106  out.src = nullptr;
107  }
109  out.hwPt = in.hwPt;
110  out.hwPtErr = in.hwPtErr;
111  out.hwEta = in.hwEta;
112  out.hwPhi = in.hwPhi;
113  out.src = nullptr;
114  }
115  inline void convert(const MuObj &in, l1tpf_impl::Muon &out) {
116  out.hwPt = in.hwPt;
117  out.hwEta = in.hwEta; // @calo
118  out.hwPhi = in.hwPhi; // @calo
119  out.src = nullptr;
120  }
121 
122  template <unsigned int NMAX, typename In>
123  void convert(const In in[NMAX], std::vector<l1tpf_impl::PFParticle> &out) {
124  for (unsigned int i = 0; i < NMAX; ++i) {
125  if (in[i].hwPt > 0)
126  convert(in[i], out);
127  }
128  }
129  template <typename In>
130  void convert(unsigned int NMAX, const In in[], std::vector<l1tpf_impl::PFParticle> &out) {
131  for (unsigned int i = 0; i < NMAX; ++i) {
132  if (in[i].hwPt > 0)
133  convert(in[i], out);
134  }
135  }
136  template <unsigned int NMAX>
137  void convert(const PFChargedObj in[NMAX],
138  std::vector<l1tpf_impl::PropagatedTrack> srctracks,
139  std::vector<l1tpf_impl::PFParticle> &out) {
140  for (unsigned int i = 0; i < NMAX; ++i) {
141  if (in[i].hwPt > 0) {
142  assert(i < srctracks.size());
143  convert(in[i], srctracks[i], out);
144  }
145  }
146  }
147  inline void convert(unsigned int NMAX,
148  const PFChargedObj in[],
149  std::vector<l1tpf_impl::PropagatedTrack> srctracks,
150  std::vector<l1tpf_impl::PFParticle> &out) {
151  for (unsigned int i = 0; i < NMAX; ++i) {
152  if (in[i].hwPt > 0) {
153  assert(i < srctracks.size());
154  convert(in[i], srctracks[i], out);
155  }
156  }
157  }
158 
159 } // namespace fw2dpf
160 
161 #endif
mps_fire.i
i
Definition: mps_fire.py:428
HLT_FULL_cff.track
track
Definition: HLT_FULL_cff.py:11713
PID_Muon
Definition: data.h:16
l1tpf_impl::PropagatedTrack
Definition: DiscretePFInputs.h:119
fw2dpf::convert
void convert(const PFChargedObj &src, const l1tpf_impl::PropagatedTrack &track, std::vector< l1tpf_impl::PFParticle > &out)
Definition: Firmware2DiscretePF.h:13
cms::cuda::assert
assert(be >=bs)
fw2dpf
NOTE: this include is not standalone, since the path to DiscretePFInputs is different in CMSSW & Viva...
Definition: Firmware2DiscretePF.h:10
l1tpf_impl::PFParticle
Definition: DiscretePFInputs.h:184
PID_Photon
Definition: data.h:16
EmCaloObj
Definition: data.h:132
PFChargedObj
Definition: data.h:169
l1tpf_impl::Muon
Definition: DiscretePFInputs.h:156
TrackRefitter_38T_cff.src
src
Definition: TrackRefitter_38T_cff.py:24
PFNeutralObj
Definition: data.h:183
TkObj
Definition: data.h:143
recoMuon::in
Definition: RecoMuonEnumerators.h:6
MuObj
Definition: data.h:158
l1tpf_impl::CaloCluster
Definition: DiscretePFInputs.h:25
packedPFCandidateRefMixer_cfi.pf
pf
Definition: packedPFCandidateRefMixer_cfi.py:4
PID_Electron
Definition: data.h:16
HadCaloObj
Definition: data.h:120
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31