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> hwIso_t;
35  typedef ap_uint<8> hwQual_t;
36  typedef ap_uint<1> hwCharge_t;
37  typedef ap_int<12> hwD0_t;
38  typedef ap_uint<4> hwBeta_t;
39  typedef ap_uint<10> hwMass_t;
40  typedef ap_uint<16> hwIndex_t;
41  typedef ap_uint<10> hwSeed_pT_t;
42  typedef ap_int<10> hwSeed_z0_t;
43  typedef ap_uint<16> hwSca_sum_t;
44  typedef ap_uint<5> hwNumber_of_tracks_t;
45  typedef ap_uint<12> hwSum_pT_pv_t;
46  typedef ap_uint<2> hwType_t;
47  typedef ap_uint<8> hwNumber_of_tracks_in_pv_t;
48  typedef ap_uint<10> hwNumber_of_tracks_not_in_pv_t;
49 
50  // Similar to std::optional<T> but avoids inheritance for ROOT file embedding
51  template <typename T>
52  struct Optional {
53  Optional() : value_(0), set_(false) {}
55 
56  operator T() const { return value_; }
57  operator bool() const { return set_; }
58 
59  bool operator==(bool rhs) const { return set_ == rhs; }
60  bool operator!=(bool rhs) const { return set_ != rhs; }
61 
62  private:
64  bool set_;
65  };
66 
67  enum ObjectType {
95  };
96 
97  void setHwPT(hwPT_t hwPT) { hwPT_ = hwPT.to_int(); }
98  void setHwPhi(hwPhi_t hwPhi) { hwPhi_ = hwPhi.to_int(); }
99  void setHwEta(hwEta_t hwEta) { hwEta_ = hwEta.to_int(); }
100  void setHwZ0(hwZ0_t hwZ0) { hwZ0_ = hwZ0.to_int(); }
101  void setHwIso(hwIso_t hwIso) { hwIso_ = hwIso.to_int(); }
102  void setHwQual(hwQual_t hwQual) { hwQual_ = hwQual.to_int(); }
104  void setHwD0(hwD0_t hwD0) { hwD0_ = hwD0.to_int(); }
105  void setHwBeta(hwBeta_t hwBeta) { hwBeta_ = hwBeta.to_int(); }
106  void setHwMass(hwMass_t hwMass) { hwMass_ = hwMass.to_int(); }
113  }
114 
116  void setHwType(hwType_t hwType) { hwType_ = hwType.to_int(); }
119  }
122  }
123 
124  hwPT_t hwPT() const {
125  if (!hwPT_) {
126  throw std::invalid_argument("Object doesn't have pT");
127  }
128  return static_cast<int>(hwPT_);
129  }
130 
131  hwPhi_t hwPhi() const {
132  if (!hwPhi_) {
133  throw std::invalid_argument("Object doesn't have phi");
134  }
135  return static_cast<int>(hwPhi_);
136  }
137 
138  hwEta_t hwEta() const {
139  if (!hwEta_) {
140  throw std::invalid_argument("Object doesn't have eta");
141  }
142  return static_cast<int>(hwEta_);
143  }
144 
145  hwZ0_t hwZ0() const {
146  if (!hwZ0_) {
147  throw std::invalid_argument("Object doesn't have z0");
148  }
149  return static_cast<int>(hwZ0_);
150  }
151 
152  hwIso_t hwIso() const {
153  if (!hwIso_) {
154  throw std::invalid_argument("Object doesn't have iso");
155  }
156  return static_cast<int>(hwIso_);
157  }
158 
159  hwQual_t hwQual() const {
160  if (!hwQual_) {
161  throw std::invalid_argument("Object doesn't have qual");
162  }
163  return static_cast<int>(hwQual_);
164  }
165 
167  if (!hwCharge_) {
168  throw std::invalid_argument("Object doesn't have charge");
169  }
170  return static_cast<int>(hwCharge_);
171  }
172 
173  hwD0_t hwD0() const {
174  if (!hwD0_) {
175  throw std::invalid_argument("Object doesn't have d0");
176  }
177  return static_cast<int>(hwD0_);
178  }
179 
180  hwBeta_t hwBeta() const {
181  if (!hwBeta_) {
182  throw std::invalid_argument("Object doesn't have beta");
183  }
184  return static_cast<int>(hwBeta_);
185  }
186 
187  hwMass_t hwMass() const {
188  if (!hwMass_) {
189  throw std::invalid_argument("Object doesn't have mass");
190  }
191  return static_cast<int>(hwMass_);
192  }
193 
194  hwIndex_t hwIndex() const {
195  if (!hwIndex_) {
196  throw std::invalid_argument("Object doesn't have index");
197  }
198  return static_cast<int>(hwIndex_);
199  }
200 
202  if (!hwSeed_pT_) {
203  throw std::invalid_argument("Object doesn't have seed_pT");
204  }
205  return static_cast<int>(hwSeed_pT_);
206  }
207 
209  if (!hwSeed_z0_) {
210  throw std::invalid_argument("Object doesn't have seed_z0");
211  }
212  return static_cast<int>(hwSeed_z0_);
213  }
214 
216  if (!hwSca_sum_) {
217  throw std::invalid_argument("Object doesn't have sca_sum");
218  }
219  return static_cast<int>(hwSca_sum_);
220  }
221 
223  if (!hwNumber_of_tracks_) {
224  throw std::invalid_argument("Object doesn't have number_of_tracks");
225  }
226  return static_cast<int>(hwNumber_of_tracks_);
227  }
228 
230  if (!hwSum_pT_pv_) {
231  throw std::invalid_argument("Object doesn't have sum_pT_pv");
232  }
233  return static_cast<int>(hwSum_pT_pv_);
234  }
235 
236  hwType_t hwType() const {
237  if (!hwType_) {
238  throw std::invalid_argument("Object doesn't have type");
239  }
240  return static_cast<int>(hwType_);
241  }
242 
245  throw std::invalid_argument("Object doesn't have number_of_tracks_in_pv");
246  }
247  return static_cast<int>(hwNumber_of_tracks_in_pv_);
248  }
249 
252  throw std::invalid_argument("Object doesn't have hwNumber_of_tracks_not_in_pv");
253  }
254  return static_cast<int>(hwNumber_of_tracks_not_in_pv_);
255  }
256 
257  ObjectType objectType() const { return objectType_; }
258 
259  bool operator==(const P2GTCandidate& rhs) const;
260  bool operator!=(const P2GTCandidate& rhs) const;
261 
262  bool isElectron() const override { return objectType_ == CL2Electrons; };
263 
264  bool isMuon() const override {
266  };
267 
268  bool isStandAloneMuon() const override {
270  };
271 
272  bool isTrackerMuon() const override { return objectType_ == GMTTkMuons; }
273 
274  bool isPhoton() const override { return objectType_ == CL2Photons; }
275 
276  bool isJet() const override {
278  objectType_ == CL2Jets;
279  }
280 
281  private:
297 
298  // TODO ?
303 
305  };
306 
307 }; // namespace l1t
308 
309 #endif // DataFormats_L1Trigger_P2GTCandidate_h
ap_uint< 5 > hwNumber_of_tracks_t
Definition: P2GTCandidate.h:44
void setHwD0(hwD0_t hwD0)
Optional< int > hwIso_
void setHwType(hwType_t hwType)
ap_uint< 1 > hwCharge_t
Definition: P2GTCandidate.h:36
Optional< int > hwMass_
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:38
ap_uint< 10 > hwSeed_pT_t
Definition: P2GTCandidate.h:41
void setHwIso(hwIso_t hwIso)
hwBeta_t hwBeta() const
void setHwNumber_of_tracks_in_pv(hwNumber_of_tracks_in_pv_t hwNumber_of_tracks_in_pv)
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)
Optional< int > hwIndex_
Optional< int > hwCharge_
ObjectType objectType() const
void setHwSca_sum(hwSca_sum_t hwSca_sum)
bool isTrackerMuon() const override
ap_uint< 11 > hwIso_t
Definition: P2GTCandidate.h:34
ap_uint< 8 > hwNumber_of_tracks_in_pv_t
Definition: P2GTCandidate.h:47
ap_uint< 8 > hwQual_t
Definition: P2GTCandidate.h:35
void setHwEta(hwEta_t hwEta)
Definition: P2GTCandidate.h:99
void setHwMass(hwMass_t hwMass)
ap_uint< 16 > hwIndex_t
Definition: P2GTCandidate.h:40
ap_uint< 2 > hwType_t
Definition: P2GTCandidate.h:46
Optional< int > hwPT_
hwCharge_t hwCharge() const
bool isStandAloneMuon() const override
Optional< int > hwSeed_pT_
void setHwPT(hwPT_t hwPT)
Definition: P2GTCandidate.h:97
Definition: value.py:1
hwSca_sum_t hwSca_sum() const
bool isJet() const override
hwMass_t hwMass() const
void setHwQual(hwQual_t hwQual)
bool isElectron() const override
Optional< int > hwType_
ap_int< 10 > hwSeed_z0_t
Definition: P2GTCandidate.h:42
void setHwSeed_z0(hwSeed_z0_t hwSeed_z0)
ap_uint< 10 > hwNumber_of_tracks_not_in_pv_t
Definition: P2GTCandidate.h:48
Optional< int > hwNumber_of_tracks_
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)
void setHwSeed_pT(hwSeed_pT_t hwSeed_pT)
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
ap_uint< 16 > hwSca_sum_t
Definition: P2GTCandidate.h:43
std::vector< P2GTCandidateRef > P2GTCandidateVectorRef
Definition: P2GTCandidate.h:20
void setHwIndex(hwIndex_t hwIndex)
ap_uint< 12 > hwSum_pT_pv_t
Definition: P2GTCandidate.h:45
hwIso_t hwIso() const
ap_uint< 16 > hwPT_t
Definition: P2GTCandidate.h:30
ap_uint< 10 > hwMass_t
Definition: P2GTCandidate.h:39
edm::RefVector< P2GTCandidateCollection > P2GTCandidateRefVector
Definition: P2GTCandidate.h:19
hwIndex_t hwIndex() const
Optional< int > hwSum_pT_pv_
hwSeed_z0_t hwSeed_z0() const
Optional< int > hwNumber_of_tracks_not_in_pv_
Optional< int > hwQual_
hwNumber_of_tracks_t hwNumber_of_tracks() const
Optional< int > hwPhi_
ap_int< 12 > hwD0_t
Definition: P2GTCandidate.h:37
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 setHwZ0(hwZ0_t hwZ0)
void setHwNumber_of_tracks(hwNumber_of_tracks_t hwNumber_of_tracks)
bool isPhoton() const override
hwQual_t hwQual() const
Optional< int > hwBeta_
void setHwPhi(hwPhi_t hwPhi)
Definition: P2GTCandidate.h:98
bool operator==(bool rhs) const
Definition: P2GTCandidate.h:59
Optional< int > hwSca_sum_
Optional< int > hwZ0_
hwPT_t hwPT() const
bool isMuon() const override
bool operator!=(bool rhs) const
Definition: P2GTCandidate.h:60
hwType_t hwType() const