CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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
Definition: data.h:158
etaphi_t hwEta
Definition: data.h:185
pt_t hwPt
Definition: data.h:133
etaphi_t hwEta
Definition: data.h:171
const l1t::Muon * src
particleid_t hwId
Definition: data.h:172
bool hwIsEM
Definition: data.h:122
assert(be >=bs)
pt_t hwPt
Definition: data.h:144
etaphi_t hwEta
Definition: data.h:160
void convert(const PFChargedObj &src, const l1tpf_impl::PropagatedTrack &track, std::vector< l1tpf_impl::PFParticle > &out)
etaphi_t hwEta
Definition: data.h:134
pt_t hwEmPt
Definition: data.h:121
pt_t hwPt
Definition: data.h:184
pt_t hwPt
Definition: data.h:170
pt_t hwPtErr
Definition: data.h:133
particleid_t hwId
Definition: data.h:186
etaphi_t hwPhi
Definition: data.h:185
const l1t::PFTrack * src
pt_t hwPt
Definition: data.h:159
etaphi_t hwPhi
Definition: data.h:118
pt_t hwPt
Definition: data.h:117
etaphi_t hwPhi
Definition: data.h:171
pt_t hwPtErr
Definition: data.h:144
z0_t hwZ0
Definition: data.h:146
etaphi_t hwPhi
Definition: data.h:134
etaphi_t hwEta
Definition: data.h:118
Definition: data.h:16
etaphi_t hwPhi
Definition: data.h:145
const l1t::Muon * muonsrc
etaphi_t hwPhi
Definition: data.h:160
etaphi_t hwEta
Definition: data.h:145
const l1t::PFCluster * src
Definition: data.h:143