Skip to content

Commit 2c267b2

Browse files
Benjamin Huberqvyzjheikkil
committed
Implement Phase-2 GT
Co-authored-by: Elias <[email protected]> Co-authored-by: jheikkil <[email protected]>
1 parent 8cc6f24 commit 2c267b2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+5815
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#ifndef DataFormats_L1Trigger_P2GTAlgoBlock_h
2+
#define DataFormats_L1Trigger_P2GTAlgoBlock_h
3+
4+
#include "P2GTCandidate.h"
5+
6+
#include <vector>
7+
#include <string>
8+
#include <utility>
9+
10+
namespace l1t {
11+
12+
class P2GTAlgoBlock;
13+
typedef std::vector<P2GTAlgoBlock> P2GTAlgoBlockCollection;
14+
15+
class P2GTAlgoBlock {
16+
public:
17+
P2GTAlgoBlock()
18+
: algoName_(""),
19+
decisionBeforeBxMaskAndPrescale_(false),
20+
decisionBeforePrescale_(false),
21+
decisionFinal_(false),
22+
trigObjects_() {}
23+
P2GTAlgoBlock(std::string name,
24+
bool decisionBeforeBxMaskAndPrescale,
25+
bool decisionBeforePrescale,
26+
bool decisionFinal,
27+
P2GTCandidateVectorRef trigObjects)
28+
: algoName_(std::move(name)),
29+
decisionBeforeBxMaskAndPrescale_(decisionBeforeBxMaskAndPrescale),
30+
decisionBeforePrescale_(decisionBeforePrescale),
31+
decisionFinal_(decisionFinal),
32+
trigObjects_(std::move(trigObjects)) {}
33+
34+
const std::string& algoName() const { return algoName_; }
35+
bool decisionBeforeBxMaskAndPrescale() const { return decisionBeforeBxMaskAndPrescale_; }
36+
bool decisionBeforePrescale() const { return decisionBeforePrescale_; }
37+
bool decisionFinal() const { return decisionFinal_; }
38+
const P2GTCandidateVectorRef& trigObjects() const { return trigObjects_; }
39+
40+
private:
41+
const std::string algoName_;
42+
const bool decisionBeforeBxMaskAndPrescale_;
43+
const bool decisionBeforePrescale_;
44+
const bool decisionFinal_;
45+
const P2GTCandidateVectorRef trigObjects_;
46+
};
47+
48+
} // namespace l1t
49+
50+
#endif // DataFormats_L1Trigger_P2GTAlgoBlock_h
Lines changed: 309 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,309 @@
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+
8+
#include "DataFormats/Common/interface/Ref.h"
9+
#include "DataFormats/Common/interface/RefVector.h"
10+
#include "DataFormats/Candidate/interface/LeafCandidate.h"
11+
12+
namespace l1t {
13+
14+
class L1GTProducer;
15+
16+
class P2GTCandidate;
17+
typedef std::vector<P2GTCandidate> P2GTCandidateCollection;
18+
typedef edm::Ref<P2GTCandidateCollection> P2GTCandidateRef;
19+
typedef edm::RefVector<P2GTCandidateCollection> P2GTCandidateRefVector;
20+
typedef std::vector<P2GTCandidateRef> P2GTCandidateVectorRef;
21+
22+
class P2GTCandidate : public reco::LeafCandidate {
23+
public:
24+
using Base = reco::LeafCandidate;
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) {}
54+
Optional(T value) : value_(value), set_(true) {}
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:
63+
T value_;
64+
bool set_;
65+
};
66+
67+
enum ObjectType {
68+
Undefined,
69+
GCTNonIsoEg,
70+
GCTIsoEg,
71+
GCTJets,
72+
GCTTaus,
73+
GCTHtSum,
74+
GCTEtSum,
75+
GMTSaPromptMuons,
76+
GMTSaDisplacedMuons,
77+
GMTTkMuons,
78+
GMTTopo,
79+
GTTPromptJets,
80+
GTTDisplacedJets,
81+
GTTPhiCandidates,
82+
GTTRhoCandidates,
83+
GTTBsCandidates,
84+
GTTHadronicTaus,
85+
GTTPrimaryVert,
86+
GTTPromptHtSum,
87+
GTTDisplacedHtSum,
88+
GTTEtSum,
89+
CL2Jets,
90+
CL2Taus,
91+
CL2Electrons,
92+
CL2Photons,
93+
CL2HtSum,
94+
CL2EtSum
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(); }
103+
void setHwCharge(hwCharge_t hwCharge) { hwCharge_ = hwCharge.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(); }
107+
void setHwIndex(hwIndex_t hwIndex) { hwIndex_ = hwIndex.to_int(); }
108+
void setHwSeed_pT(hwSeed_pT_t hwSeed_pT) { hwSeed_pT_ = hwSeed_pT.to_int(); }
109+
void setHwSeed_z0(hwSeed_z0_t hwSeed_z0) { hwSeed_z0_ = hwSeed_z0.to_int(); }
110+
void setHwSca_sum(hwSca_sum_t hwSca_sum) { hwSca_sum_ = hwSca_sum.to_int(); }
111+
void setHwNumber_of_tracks(hwNumber_of_tracks_t hwNumber_of_tracks) {
112+
hwNumber_of_tracks_ = hwNumber_of_tracks.to_int();
113+
}
114+
115+
void setHwSum_pT_pv(hwSum_pT_pv_t hwSum_pT_pv) { hwSum_pT_pv_ = hwSum_pT_pv.to_int(); }
116+
void setHwType(hwType_t hwType) { hwType_ = hwType.to_int(); }
117+
void setHwNumber_of_tracks_in_pv(hwNumber_of_tracks_in_pv_t hwNumber_of_tracks_in_pv) {
118+
hwNumber_of_tracks_in_pv_ = hwNumber_of_tracks_in_pv.to_int();
119+
}
120+
void setHwNumber_of_tracks_not_in_pv(hwNumber_of_tracks_not_in_pv_t hwNumber_of_tracks_not_in_pv) {
121+
hwNumber_of_tracks_not_in_pv_ = hwNumber_of_tracks_not_in_pv.to_int();
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+
166+
hwCharge_t hwCharge() const {
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+
201+
hwSeed_pT_t hwSeed_pT() const {
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+
208+
hwSeed_z0_t hwSeed_z0() const {
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+
215+
hwSca_sum_t hwSca_sum() const {
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+
222+
hwNumber_of_tracks_t hwNumber_of_tracks() const {
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+
229+
hwSum_pT_pv_t hwSum_pT_pv() const {
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+
243+
hwNumber_of_tracks_in_pv_t hwNumber_of_tracks_in_pv() const {
244+
if (!hwNumber_of_tracks_in_pv_) {
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+
250+
hwNumber_of_tracks_not_in_pv_t hwNumber_of_tracks_not_in_pv() const {
251+
if (!hwNumber_of_tracks_not_in_pv_) {
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 {
265+
return objectType_ == GMTSaPromptMuons || objectType_ == GMTSaDisplacedMuons || objectType_ == GMTTkMuons;
266+
};
267+
268+
bool isStandAloneMuon() const override {
269+
return objectType_ == GMTSaPromptMuons || objectType_ == GMTSaDisplacedMuons;
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 {
277+
return objectType_ == GCTJets || objectType_ == GTTPromptJets || objectType_ == GTTDisplacedJets ||
278+
objectType_ == CL2Jets;
279+
}
280+
281+
private:
282+
Optional<int> hwPT_;
283+
Optional<int> hwPhi_;
284+
Optional<int> hwEta_;
285+
Optional<int> hwZ0_;
286+
Optional<int> hwIso_;
287+
Optional<int> hwQual_;
288+
Optional<int> hwCharge_;
289+
Optional<int> hwD0_;
290+
Optional<int> hwBeta_;
291+
Optional<int> hwMass_;
292+
Optional<int> hwIndex_;
293+
Optional<int> hwSeed_pT_;
294+
Optional<int> hwSeed_z0_;
295+
Optional<int> hwSca_sum_;
296+
Optional<int> hwNumber_of_tracks_;
297+
298+
// TODO ?
299+
Optional<int> hwSum_pT_pv_;
300+
Optional<int> hwType_;
301+
Optional<int> hwNumber_of_tracks_in_pv_;
302+
Optional<int> hwNumber_of_tracks_not_in_pv_;
303+
304+
ObjectType objectType_ = Undefined;
305+
};
306+
307+
}; // namespace l1t
308+
309+
#endif // DataFormats_L1Trigger_P2GTCandidate_h
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#include "DataFormats/L1Trigger/interface/P2GTCandidate.h"
2+
3+
namespace l1t {
4+
5+
bool P2GTCandidate::operator==(const P2GTCandidate& rhs) const {
6+
return hwPT_ == rhs.hwPT_ && hwPhi_ == rhs.hwPhi_ && hwEta_ == rhs.hwEta_ && hwZ0_ == rhs.hwZ0_ &&
7+
hwIso_ == rhs.hwIso_ && hwQual_ == rhs.hwQual_ && hwCharge_ == rhs.hwCharge_ && hwD0_ == rhs.hwD0_ &&
8+
hwBeta_ == rhs.hwBeta_ && hwMass_ == rhs.hwMass_ && hwIndex_ == rhs.hwIndex_ &&
9+
hwSeed_pT_ == rhs.hwSeed_pT_ && hwSeed_z0_ == rhs.hwSeed_z0_ && hwSca_sum_ == rhs.hwSca_sum_ &&
10+
hwNumber_of_tracks_ == rhs.hwNumber_of_tracks_ && hwSum_pT_pv_ == rhs.hwSum_pT_pv_ &&
11+
hwType_ == rhs.hwType_ && hwNumber_of_tracks_in_pv_ == rhs.hwNumber_of_tracks_in_pv_ &&
12+
hwNumber_of_tracks_not_in_pv_ == rhs.hwNumber_of_tracks_not_in_pv_;
13+
}
14+
15+
bool P2GTCandidate::operator!=(const P2GTCandidate& rhs) const {
16+
return hwPT_ != rhs.hwPT_ && hwPhi_ != rhs.hwPhi_ && hwEta_ != rhs.hwEta_ && hwZ0_ != rhs.hwZ0_ &&
17+
hwIso_ != rhs.hwIso_ && hwQual_ != rhs.hwQual_ && hwCharge_ != rhs.hwCharge_ && hwD0_ != rhs.hwD0_ &&
18+
hwBeta_ != rhs.hwBeta_ && hwMass_ != rhs.hwMass_ && hwIndex_ != rhs.hwIndex_ &&
19+
hwSeed_pT_ != rhs.hwSeed_pT_ && hwSeed_z0_ != rhs.hwSeed_z0_ && hwSca_sum_ != rhs.hwSca_sum_ &&
20+
hwNumber_of_tracks_ != rhs.hwNumber_of_tracks_ && hwSum_pT_pv_ != rhs.hwSum_pT_pv_ &&
21+
hwType_ != rhs.hwType_ && hwNumber_of_tracks_in_pv_ != rhs.hwNumber_of_tracks_in_pv_ &&
22+
hwNumber_of_tracks_not_in_pv_ != rhs.hwNumber_of_tracks_not_in_pv_;
23+
};
24+
} // namespace l1t

DataFormats/L1Trigger/src/classes.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,5 @@
3636
#include "DataFormats/L1Trigger/interface/VertexWord.h"
3737
#include "DataFormats/L1Trigger/interface/TkJetWord.h"
3838
#include "DataFormats/Common/interface/RefToBase.h"
39+
#include "DataFormats/L1Trigger/interface/P2GTCandidate.h"
40+
#include "DataFormats/L1Trigger/interface/P2GTAlgoBlock.h"

0 commit comments

Comments
 (0)