CMS 3D CMS Logo

P2GTCandidate.h
Go to the documentation of this file.
1 #ifndef DataFormats_L1Trigger_P2GTCandidate_h
2 #define DataFormats_L1Trigger_P2GTCandidate_h
3 
4 #include <vector>
5 #include <ap_int.h>
6 #include <stdexcept>
7 
11 
12 namespace l1t {
13 
14  class L1GTProducer;
15 
17  typedef std::vector<P2GTCandidate> P2GTCandidateCollection;
20  typedef std::vector<P2GTCandidateRef> P2GTCandidateVectorRef;
21 
23  public:
25 
26  using Base::Base;
27 
28  friend class L1GTProducer;
29 
30  typedef ap_uint<16> hwPT_t;
31  typedef ap_int<13> hwPhi_t;
32  typedef ap_int<14> hwEta_t;
33  typedef ap_int<18> hwZ0_t;
34  typedef ap_uint<11> hwIsolationPT_t;
35  typedef ap_uint<4> hwQualityFlags_t;
36  typedef ap_uint<10> hwQualityScore_t;
37  typedef ap_uint<1> hwCharge_t;
38  typedef ap_int<12> hwD0_t;
39  typedef ap_uint<4> hwBeta_t;
40  typedef ap_uint<10> hwMass_t;
41  typedef ap_uint<16> hwIndex_t;
42  typedef ap_uint<10> hwSeed_pT_t;
43  typedef ap_int<10> hwSeed_z0_t;
44  typedef ap_uint<16> hwScalarSumPT_t;
45  typedef ap_uint<5> hwNumber_of_tracks_t;
46  typedef ap_uint<12> hwSum_pT_pv_t;
47  typedef ap_uint<2> hwType_t;
48  typedef ap_uint<8> hwNumber_of_tracks_in_pv_t;
49  typedef ap_uint<10> hwNumber_of_tracks_not_in_pv_t;
50 
51  // Similar to std::optional<T> but avoids inheritance for ROOT file embedding
52  template <typename T>
53  struct Optional {
54  Optional() : value_(0), set_(false) {}
56 
57  operator T() const { return value_; }
58  operator bool() const { return set_; }
59 
60  bool operator==(bool rhs) const { return set_ == rhs; }
61  bool operator!=(bool rhs) const { return set_ != rhs; }
62 
63  private:
65  bool set_;
66  };
67 
68  enum ObjectType {
99  };
100 
101  void setHwPT(hwPT_t hwPT) { hwPT_ = hwPT.to_int(); }
102  void setHwPhi(hwPhi_t hwPhi) { hwPhi_ = hwPhi.to_int(); }
103  void setHwEta(hwEta_t hwEta) { hwEta_ = hwEta.to_int(); }
104  void setHwZ0(hwZ0_t hwZ0) { hwZ0_ = hwZ0.to_int(); }
109  void setHwD0(hwD0_t hwD0) { hwD0_ = hwD0.to_int(); }
110  void setHwBeta(hwBeta_t hwBeta) { hwBeta_ = hwBeta.to_int(); }
111  void setHwMass(hwMass_t hwMass) { hwMass_ = hwMass.to_int(); }
118  }
119 
121  void setHwType(hwType_t hwType) { hwType_ = hwType.to_int(); }
124  }
127  }
128 
129  hwPT_t hwPT() const {
130  if (!hwPT_) {
131  throw std::invalid_argument("Object doesn't have pT");
132  }
133  return static_cast<int>(hwPT_);
134  }
135 
136  hwPhi_t hwPhi() const {
137  if (!hwPhi_) {
138  throw std::invalid_argument("Object doesn't have phi");
139  }
140  return static_cast<int>(hwPhi_);
141  }
142 
143  hwEta_t hwEta() const {
144  if (!hwEta_) {
145  throw std::invalid_argument("Object doesn't have eta");
146  }
147  return static_cast<int>(hwEta_);
148  }
149 
150  hwZ0_t hwZ0() const {
151  if (!hwZ0_) {
152  throw std::invalid_argument("Object doesn't have z0");
153  }
154  return static_cast<int>(hwZ0_);
155  }
156 
158  if (!hwIsolationPT_) {
159  throw std::invalid_argument("Object doesn't have isolationPT");
160  }
161  return static_cast<int>(hwIsolationPT_);
162  }
163 
165  if (!hwQualityFlags_) {
166  throw std::invalid_argument("Object doesn't have qualityFlags");
167  }
168  return static_cast<int>(hwQualityFlags_);
169  }
170 
172  if (!hwQualityScore_) {
173  throw std::invalid_argument("Object doesn't have qualityScore");
174  }
175  return static_cast<int>(hwQualityScore_);
176  }
177 
179  if (!hwCharge_) {
180  throw std::invalid_argument("Object doesn't have charge");
181  }
182  return static_cast<int>(hwCharge_);
183  }
184 
185  hwD0_t hwD0() const {
186  if (!hwD0_) {
187  throw std::invalid_argument("Object doesn't have d0");
188  }
189  return static_cast<int>(hwD0_);
190  }
191 
192  hwBeta_t hwBeta() const {
193  if (!hwBeta_) {
194  throw std::invalid_argument("Object doesn't have beta");
195  }
196  return static_cast<int>(hwBeta_);
197  }
198 
199  hwMass_t hwMass() const {
200  if (!hwMass_) {
201  throw std::invalid_argument("Object doesn't have mass");
202  }
203  return static_cast<int>(hwMass_);
204  }
205 
206  hwIndex_t hwIndex() const {
207  if (!hwIndex_) {
208  throw std::invalid_argument("Object doesn't have index");
209  }
210  return static_cast<int>(hwIndex_);
211  }
212 
214  if (!hwSeed_pT_) {
215  throw std::invalid_argument("Object doesn't have seed_pT");
216  }
217  return static_cast<int>(hwSeed_pT_);
218  }
219 
221  if (!hwSeed_z0_) {
222  throw std::invalid_argument("Object doesn't have seed_z0");
223  }
224  return static_cast<int>(hwSeed_z0_);
225  }
226 
228  if (!hwScalarSumPT_) {
229  throw std::invalid_argument("Object doesn't have scalarSumPT");
230  }
231  return static_cast<int>(hwScalarSumPT_);
232  }
233 
235  if (!hwNumber_of_tracks_) {
236  throw std::invalid_argument("Object doesn't have number_of_tracks");
237  }
238  return static_cast<int>(hwNumber_of_tracks_);
239  }
240 
242  if (!hwSum_pT_pv_) {
243  throw std::invalid_argument("Object doesn't have sum_pT_pv");
244  }
245  return static_cast<int>(hwSum_pT_pv_);
246  }
247 
248  hwType_t hwType() const {
249  if (!hwType_) {
250  throw std::invalid_argument("Object doesn't have type");
251  }
252  return static_cast<int>(hwType_);
253  }
254 
257  throw std::invalid_argument("Object doesn't have number_of_tracks_in_pv");
258  }
259  return static_cast<int>(hwNumber_of_tracks_in_pv_);
260  }
261 
264  throw std::invalid_argument("Object doesn't have hwNumber_of_tracks_not_in_pv");
265  }
266  return static_cast<int>(hwNumber_of_tracks_not_in_pv_);
267  }
268 
269  ObjectType objectType() const { return objectType_; }
270 
271  // Nano SimpleCandidateFlatTableProducer accessor functions
272  int hwPT_toInt() const { return hwPT().to_int(); }
273  int hwPhi_toInt() const { return hwPhi().to_int(); }
274  int hwEta_toInt() const { return hwEta().to_int(); }
275  int hwZ0_toInt() const { return hwZ0().to_int(); }
276  int hwIsolationPT_toInt() const { return hwIsolationPT().to_int(); }
277  int hwQualityFlags_toInt() const { return hwQualityFlags().to_int(); }
278  int hwQualityScore_toInt() const { return hwQualityScore().to_int(); }
279  int hwCharge_toInt() const { return hwCharge().to_int(); }
280  int hwD0_toInt() const { return hwD0().to_int(); }
281  int hwBeta_toInt() const { return hwBeta().to_int(); }
282  int hwMass_toInt() const { return hwMass().to_int(); }
283  int hwIndex_toInt() const { return hwIndex().to_int(); }
284  int hwSeed_pT_toInt() const { return hwSeed_pT().to_int(); }
285  int hwSeed_z0_toInt() const { return hwSeed_z0().to_int(); }
286  int hwScalarSumPT_toInt() const { return hwScalarSumPT().to_int(); }
287  int hwNumber_of_tracks_toInt() const { return hwNumber_of_tracks().to_int(); }
288  int hwSum_pT_pv_toInt() const { return hwSum_pT_pv().to_int(); }
289  int hwType_toInt() const { return hwType().to_int(); }
290  int hwNumber_of_tracks_in_pv_toInt() const { return hwNumber_of_tracks_in_pv().to_int(); }
292 
293  bool operator==(const P2GTCandidate& rhs) const;
294  bool operator!=(const P2GTCandidate& rhs) const;
295 
296  bool isElectron() const override { return objectType_ == CL2Electrons; };
297 
298  bool isMuon() const override {
300  };
301 
302  bool isStandAloneMuon() const override {
304  };
305 
306  bool isTrackerMuon() const override { return objectType_ == GMTTkMuons; }
307 
308  bool isPhoton() const override { return objectType_ == CL2Photons; }
309 
310  bool isJet() const override {
313  }
314 
315  private:
332 
333  // TODO ?
338 
340  };
341 
342 }; // namespace l1t
343 
344 #endif // DataFormats_L1Trigger_P2GTCandidate_h
int hwIsolationPT_toInt() const
ap_uint< 5 > hwNumber_of_tracks_t
Definition: P2GTCandidate.h:45
void setHwD0(hwD0_t hwD0)
ap_uint< 11 > hwIsolationPT_t
Definition: P2GTCandidate.h:34
void setHwType(hwType_t hwType)
ap_uint< 1 > hwCharge_t
Definition: P2GTCandidate.h:37
Optional< int > hwMass_
void setHwIsolationPT(hwIsolationPT_t hwIso)
Optional< int > hwNumber_of_tracks_in_pv_
void setHwBeta(hwBeta_t hwBeta)
bool operator!=(const P2GTCandidate &rhs) const
hwNumber_of_tracks_in_pv_t hwNumber_of_tracks_in_pv() const
std::vector< P2GTCandidate > P2GTCandidateCollection
Definition: P2GTCandidate.h:16
ap_uint< 4 > hwBeta_t
Definition: P2GTCandidate.h:39
ap_uint< 10 > hwSeed_pT_t
Definition: P2GTCandidate.h:42
hwBeta_t hwBeta() const
int hwMass_toInt() const
hwIsolationPT_t hwIsolationPT() const
Optional< int > hwIsolationPT_
int hwD0_toInt() const
void setHwNumber_of_tracks_in_pv(hwNumber_of_tracks_in_pv_t hwNumber_of_tracks_in_pv)
int hwSeed_z0_toInt() const
hwEta_t hwEta() const
Optional< int > hwSeed_z0_
ap_int< 13 > hwPhi_t
Definition: P2GTCandidate.h:31
edm::Ref< P2GTCandidateCollection > P2GTCandidateRef
Definition: P2GTCandidate.h:18
ObjectType objectType_
def Base(process)
hwD0_t hwD0() const
delete x;
Definition: CaloConfig.h:22
Optional< int > hwD0_
void setHwSum_pT_pv(hwSum_pT_pv_t hwSum_pT_pv)
int hwNumber_of_tracks_toInt() const
Optional< int > hwIndex_
hwScalarSumPT_t hwScalarSumPT() const
Optional< int > hwCharge_
ObjectType objectType() const
int hwZ0_toInt() const
int hwPT_toInt() const
bool isTrackerMuon() const override
ap_uint< 8 > hwNumber_of_tracks_in_pv_t
Definition: P2GTCandidate.h:48
Optional< int > hwQualityScore_
void setHwEta(hwEta_t hwEta)
void setHwMass(hwMass_t hwMass)
int hwEta_toInt() const
int hwNumber_of_tracks_in_pv_toInt() const
Optional< int > hwQualityFlags_
int hwNumber_of_tracks_not_in_pv_toInt() const
ap_uint< 16 > hwIndex_t
Definition: P2GTCandidate.h:41
ap_uint< 2 > hwType_t
Definition: P2GTCandidate.h:47
Optional< int > hwPT_
hwCharge_t hwCharge() const
bool isStandAloneMuon() const override
Optional< int > hwSeed_pT_
ap_uint< 16 > hwScalarSumPT_t
Definition: P2GTCandidate.h:44
void setHwPT(hwPT_t hwPT)
int hwType_toInt() const
Definition: value.py:1
bool isJet() const override
int hwQualityScore_toInt() const
hwMass_t hwMass() const
bool isElectron() const override
Optional< int > hwType_
hwQualityFlags_t hwQualityFlags() const
void setHwQualityScore(hwQualityScore_t hwQualityScore)
ap_int< 10 > hwSeed_z0_t
Definition: P2GTCandidate.h:43
void setHwSeed_z0(hwSeed_z0_t hwSeed_z0)
hwQualityScore_t hwQualityScore() const
ap_uint< 10 > hwNumber_of_tracks_not_in_pv_t
Definition: P2GTCandidate.h:49
Optional< int > hwNumber_of_tracks_
void setHwScalarSumPT(hwScalarSumPT_t hwScalarSumPT)
hwSum_pT_pv_t hwSum_pT_pv() const
hwZ0_t hwZ0() const
void setHwNumber_of_tracks_not_in_pv(hwNumber_of_tracks_not_in_pv_t hwNumber_of_tracks_not_in_pv)
int hwBeta_toInt() const
void setHwSeed_pT(hwSeed_pT_t hwSeed_pT)
int hwSeed_pT_toInt() const
bool operator==(const P2GTCandidate &rhs) const
Definition: P2GTCandidate.cc:5
hwSeed_pT_t hwSeed_pT() const
ap_int< 14 > hwEta_t
Definition: P2GTCandidate.h:32
std::vector< P2GTCandidateRef > P2GTCandidateVectorRef
Definition: P2GTCandidate.h:20
void setHwIndex(hwIndex_t hwIndex)
int hwPhi_toInt() const
ap_uint< 12 > hwSum_pT_pv_t
Definition: P2GTCandidate.h:46
ap_uint< 16 > hwPT_t
Definition: P2GTCandidate.h:30
ap_uint< 10 > hwMass_t
Definition: P2GTCandidate.h:40
int hwIndex_toInt() const
edm::RefVector< P2GTCandidateCollection > P2GTCandidateRefVector
Definition: P2GTCandidate.h:19
hwIndex_t hwIndex() const
int hwSum_pT_pv_toInt() const
Optional< int > hwSum_pT_pv_
Optional< int > hwScalarSumPT_
hwSeed_z0_t hwSeed_z0() const
int hwQualityFlags_toInt() const
Optional< int > hwNumber_of_tracks_not_in_pv_
int hwCharge_toInt() const
hwNumber_of_tracks_t hwNumber_of_tracks() const
ap_uint< 10 > hwQualityScore_t
Definition: P2GTCandidate.h:36
Optional< int > hwPhi_
ap_int< 12 > hwD0_t
Definition: P2GTCandidate.h:38
ap_uint< 4 > hwQualityFlags_t
Definition: P2GTCandidate.h:35
hwNumber_of_tracks_not_in_pv_t hwNumber_of_tracks_not_in_pv() const
ap_int< 18 > hwZ0_t
Definition: P2GTCandidate.h:33
Optional< int > hwEta_
long double T
void setHwCharge(hwCharge_t hwCharge)
hwPhi_t hwPhi() const
void setHwQualityFlags(hwQualityFlags_t hwQualityFlags)
void setHwZ0(hwZ0_t hwZ0)
void setHwNumber_of_tracks(hwNumber_of_tracks_t hwNumber_of_tracks)
bool isPhoton() const override
Optional< int > hwBeta_
void setHwPhi(hwPhi_t hwPhi)
int hwScalarSumPT_toInt() const
bool operator==(bool rhs) const
Definition: P2GTCandidate.h:60
Optional< int > hwZ0_
hwPT_t hwPT() const
bool isMuon() const override
bool operator!=(bool rhs) const
Definition: P2GTCandidate.h:61
hwType_t hwType() const