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<6> 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<4> hwNumber_of_displaced_tracks_t;
47  typedef ap_uint<12> hwSum_pT_pv_t;
48  typedef ap_uint<2> hwType_t;
49  typedef ap_uint<8> hwNumber_of_tracks_in_pv_t;
50  typedef ap_uint<10> hwNumber_of_tracks_not_in_pv_t;
51 
52  // Similar to std::optional<T> but avoids inheritance for ROOT file embedding
53  template <typename T>
54  struct Optional {
55  Optional() : value_(0), set_(false) {}
57 
58  operator T() const { return value_; }
59  operator bool() const { return set_; }
60 
61  bool operator==(bool rhs) const { return set_ == rhs; }
62  bool operator!=(bool rhs) const { return set_ != rhs; }
63 
64  private:
66  bool set_;
67  };
68 
69  enum ObjectType {
100  };
101 
102  void setHwPT(hwPT_t hwPT) { hwPT_ = hwPT.to_int(); }
103  void setHwPhi(hwPhi_t hwPhi) { hwPhi_ = hwPhi.to_int(); }
104  void setHwEta(hwEta_t hwEta) { hwEta_ = hwEta.to_int(); }
105  void setHwZ0(hwZ0_t hwZ0) { hwZ0_ = hwZ0.to_int(); }
110  void setHwD0(hwD0_t hwD0) { hwD0_ = hwD0.to_int(); }
111  void setHwBeta(hwBeta_t hwBeta) { hwBeta_ = hwBeta.to_int(); }
112  void setHwMass(hwMass_t hwMass) { hwMass_ = hwMass.to_int(); }
119  }
120 
123  }
124 
126  void setHwType(hwType_t hwType) { hwType_ = hwType.to_int(); }
129  }
132  }
133 
134  hwPT_t hwPT() const {
135  if (!hwPT_) {
136  throw std::invalid_argument("Object doesn't have pT");
137  }
138  return static_cast<int>(hwPT_);
139  }
140 
141  hwPhi_t hwPhi() const {
142  if (!hwPhi_) {
143  throw std::invalid_argument("Object doesn't have phi");
144  }
145  return static_cast<int>(hwPhi_);
146  }
147 
148  hwEta_t hwEta() const {
149  if (!hwEta_) {
150  throw std::invalid_argument("Object doesn't have eta");
151  }
152  return static_cast<int>(hwEta_);
153  }
154 
155  hwZ0_t hwZ0() const {
156  if (!hwZ0_) {
157  throw std::invalid_argument("Object doesn't have z0");
158  }
159  return static_cast<int>(hwZ0_);
160  }
161 
163  if (!hwIsolationPT_) {
164  throw std::invalid_argument("Object doesn't have isolationPT");
165  }
166  return static_cast<int>(hwIsolationPT_);
167  }
168 
170  if (!hwQualityFlags_) {
171  throw std::invalid_argument("Object doesn't have qualityFlags");
172  }
173  return static_cast<int>(hwQualityFlags_);
174  }
175 
177  if (!hwQualityScore_) {
178  throw std::invalid_argument("Object doesn't have qualityScore");
179  }
180  return static_cast<int>(hwQualityScore_);
181  }
182 
184  if (!hwCharge_) {
185  throw std::invalid_argument("Object doesn't have charge");
186  }
187  return static_cast<int>(hwCharge_);
188  }
189 
190  hwD0_t hwD0() const {
191  if (!hwD0_) {
192  throw std::invalid_argument("Object doesn't have d0");
193  }
194  return static_cast<int>(hwD0_);
195  }
196 
197  hwBeta_t hwBeta() const {
198  if (!hwBeta_) {
199  throw std::invalid_argument("Object doesn't have beta");
200  }
201  return static_cast<int>(hwBeta_);
202  }
203 
204  hwMass_t hwMass() const {
205  if (!hwMass_) {
206  throw std::invalid_argument("Object doesn't have mass");
207  }
208  return static_cast<int>(hwMass_);
209  }
210 
211  hwIndex_t hwIndex() const {
212  if (!hwIndex_) {
213  throw std::invalid_argument("Object doesn't have index");
214  }
215  return static_cast<int>(hwIndex_);
216  }
217 
219  if (!hwSeed_pT_) {
220  throw std::invalid_argument("Object doesn't have seed_pT");
221  }
222  return static_cast<int>(hwSeed_pT_);
223  }
224 
226  if (!hwSeed_z0_) {
227  throw std::invalid_argument("Object doesn't have seed_z0");
228  }
229  return static_cast<int>(hwSeed_z0_);
230  }
231 
233  if (!hwScalarSumPT_) {
234  throw std::invalid_argument("Object doesn't have scalarSumPT");
235  }
236  return static_cast<int>(hwScalarSumPT_);
237  }
238 
240  if (!hwNumber_of_tracks_) {
241  throw std::invalid_argument("Object doesn't have number_of_tracks");
242  }
243  return static_cast<int>(hwNumber_of_tracks_);
244  }
245 
248  throw std::invalid_argument("Object doesn't have hwNumber_of_displaced_tracks");
249  }
250  return static_cast<int>(hwNumber_of_displaced_tracks_);
251  }
252 
254  if (!hwSum_pT_pv_) {
255  throw std::invalid_argument("Object doesn't have sum_pT_pv");
256  }
257  return static_cast<int>(hwSum_pT_pv_);
258  }
259 
260  hwType_t hwType() const {
261  if (!hwType_) {
262  throw std::invalid_argument("Object doesn't have type");
263  }
264  return static_cast<int>(hwType_);
265  }
266 
269  throw std::invalid_argument("Object doesn't have number_of_tracks_in_pv");
270  }
271  return static_cast<int>(hwNumber_of_tracks_in_pv_);
272  }
273 
276  throw std::invalid_argument("Object doesn't have hwNumber_of_tracks_not_in_pv");
277  }
278  return static_cast<int>(hwNumber_of_tracks_not_in_pv_);
279  }
280 
281  ObjectType objectType() const { return objectType_; }
282 
283  // Nano SimpleCandidateFlatTableProducer accessor functions
284  int hwPT_toInt() const { return hwPT().to_int(); }
285  int hwPhi_toInt() const { return hwPhi().to_int(); }
286  int hwEta_toInt() const { return hwEta().to_int(); }
287  int hwZ0_toInt() const { return hwZ0().to_int(); }
288  int hwIsolationPT_toInt() const { return hwIsolationPT().to_int(); }
289  int hwQualityFlags_toInt() const { return hwQualityFlags().to_int(); }
290  int hwQualityScore_toInt() const { return hwQualityScore().to_int(); }
291  int hwCharge_toInt() const { return hwCharge().to_int(); }
292  int hwD0_toInt() const { return hwD0().to_int(); }
293  int hwBeta_toInt() const { return hwBeta().to_int(); }
294  int hwMass_toInt() const { return hwMass().to_int(); }
295  int hwIndex_toInt() const { return hwIndex().to_int(); }
296  int hwSeed_pT_toInt() const { return hwSeed_pT().to_int(); }
297  int hwSeed_z0_toInt() const { return hwSeed_z0().to_int(); }
298  int hwScalarSumPT_toInt() const { return hwScalarSumPT().to_int(); }
299  int hwNumber_of_tracks_toInt() const { return hwNumber_of_tracks().to_int(); }
301  int hwSum_pT_pv_toInt() const { return hwSum_pT_pv().to_int(); }
302  int hwType_toInt() const { return hwType().to_int(); }
303  int hwNumber_of_tracks_in_pv_toInt() const { return hwNumber_of_tracks_in_pv().to_int(); }
305 
306  bool operator==(const P2GTCandidate& rhs) const;
307  bool operator!=(const P2GTCandidate& rhs) const;
308 
309  bool isElectron() const override { return objectType_ == CL2Electrons; };
310 
311  bool isMuon() const override {
313  };
314 
315  bool isStandAloneMuon() const override {
317  };
318 
319  bool isTrackerMuon() const override { return objectType_ == GMTTkMuons; }
320 
321  bool isPhoton() const override { return objectType_ == CL2Photons; }
322 
323  bool isJet() const override {
326  }
327 
328  private:
346 
347  // TODO ?
352 
354  };
355 
356 }; // namespace l1t
357 
358 #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
Optional< int > hwNumber_of_displaced_tracks_
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:49
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:48
Optional< int > hwPT_
int hwNumber_of_displaced_tracks_toInt() const
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
ap_uint< 4 > hwNumber_of_displaced_tracks_t
Definition: P2GTCandidate.h:46
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_uint< 6 > hwQualityFlags_t
Definition: P2GTCandidate.h:35
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:50
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:47
hwNumber_of_displaced_tracks_t hwNumber_of_displaced_tracks() const
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
void setHwNumber_of_displaced_tracks(hwNumber_of_displaced_tracks_t hwNumber_of_displaced_tracks)
Optional< int > hwPhi_
ap_int< 12 > hwD0_t
Definition: P2GTCandidate.h:38
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:61
Optional< int > hwZ0_
hwPT_t hwPT() const
bool isMuon() const override
bool operator!=(bool rhs) const
Definition: P2GTCandidate.h:62
hwType_t hwType() const