Skip to content

Commit c9f66bc

Browse files
authored
Merge pull request cms-sw#42424 from pallabidas/Phase-2_CaloPFclusters_PR
emulator for Phase-2 Calo PF clusters using GCT firmware
2 parents 75b5f3c + cdab3d6 commit c9f66bc

File tree

6 files changed

+450
-0
lines changed

6 files changed

+450
-0
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#ifndef DataFormats_L1TCalorimeterPhase2_CaloPFCluster_h
2+
#define DataFormats_L1TCalorimeterPhase2_CaloPFCluster_h
3+
4+
#include <vector>
5+
#include <map>
6+
#include <string>
7+
#include <algorithm>
8+
#include "DataFormats/L1Trigger/interface/L1Candidate.h"
9+
10+
namespace l1tp2 {
11+
12+
class CaloPFCluster : public l1t::L1Candidate {
13+
public:
14+
CaloPFCluster()
15+
: l1t::L1Candidate(),
16+
clusterEt_(0.),
17+
clusterIEta_(-99),
18+
clusterIPhi_(-99),
19+
clusterEta_(-99.),
20+
clusterPhi_(-99.){};
21+
22+
CaloPFCluster(const PolarLorentzVector& p4,
23+
float clusterEt,
24+
int clusterIEta,
25+
int clusterIPhi,
26+
float clusterEta,
27+
float clusterPhi)
28+
: l1t::L1Candidate(p4),
29+
clusterEt_(clusterEt),
30+
clusterIEta_(clusterIEta),
31+
clusterIPhi_(clusterIPhi),
32+
clusterEta_(clusterEta),
33+
clusterPhi_(clusterPhi){};
34+
35+
inline float clusterEt() const { return clusterEt_; };
36+
inline int clusterIEta() const { return clusterIEta_; };
37+
inline int clusterIPhi() const { return clusterIPhi_; };
38+
inline float clusterEta() const { return clusterEta_; };
39+
inline float clusterPhi() const { return clusterPhi_; };
40+
void setClusterEt(float clusterEtIn) { clusterEt_ = clusterEtIn; };
41+
void setClusterIEta(int clusterIEtaIn) { clusterIEta_ = clusterIEtaIn; };
42+
void setClusterIPhi(int clusterIPhiIn) { clusterIPhi_ = clusterIPhiIn; };
43+
void setClusterEta(float clusterEtaIn) { clusterEta_ = clusterEtaIn; };
44+
void setClusterPhi(float clusterPhiIn) { clusterPhi_ = clusterPhiIn; };
45+
46+
private:
47+
// ET
48+
float clusterEt_;
49+
// GCT ieta
50+
int clusterIEta_;
51+
// GCT iphi
52+
int clusterIPhi_;
53+
// Tower (real) eta
54+
float clusterEta_;
55+
// Tower (real) phi
56+
float clusterPhi_;
57+
};
58+
59+
// Concrete collection of output objects (with extra tuning information)
60+
typedef std::vector<l1tp2::CaloPFCluster> CaloPFClusterCollection;
61+
} // namespace l1tp2
62+
#endif

DataFormats/L1TCalorimeterPhase2/src/classes.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@
1414
#include "DataFormats/L1TCalorimeterPhase2/interface/DigitizedClusterCorrelator.h"
1515
#include "DataFormats/L1TCalorimeterPhase2/interface/DigitizedTowerCorrelator.h"
1616
#include "DataFormats/L1TCalorimeterPhase2/interface/DigitizedClusterGT.h"
17+
#include "DataFormats/L1TCalorimeterPhase2/interface/CaloPFCluster.h"

DataFormats/L1TCalorimeterPhase2/src/classes_def.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,13 @@
4242
</class>
4343
<class name="l1tp2::DigitizedClusterGTCollection" />
4444
<class name="edm::Wrapper<l1tp2::DigitizedClusterGTCollection>" />
45+
46+
<class name="l1tp2::CaloPFCluster" ClassVersion="3">
47+
<version ClassVersion="3" checksum="4176166177"/>
48+
</class>
49+
<class name="std::vector<l1tp2::CaloPFCluster>" />
50+
<class name="l1tp2::CaloPFClusterCollection" />
51+
<class name="edm::Wrapper<l1tp2::CaloPFClusterCollection>" />
52+
4553
</lcgdict>
4654

Lines changed: 197 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,197 @@
1+
#ifndef _PHASE_2_L1_CALO_PFCLUSTER_EMULATOR_H_
2+
#define _PHASE_2_L1_CALO_PFCLUSTER_EMULATOR_H_
3+
4+
#include <cstdlib>
5+
6+
// eta: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
7+
// 0 | |
8+
// 1 | |
9+
// |-----------------------------------------------------|
10+
// 2 | |
11+
// 3 | |
12+
// 4 | |
13+
// 5 | |
14+
// | ----------------------------------------------------|
15+
// 6 | |
16+
// 7 | |
17+
//
18+
// 8 PFclusters are created in one 21x8 (2+17+2 x 2+4+2)
19+
20+
static constexpr int nTowerEta = 34;
21+
static constexpr int nTowerPhi = 72;
22+
static constexpr int nSLR = 36;
23+
static constexpr int nTowerEtaSLR = 21; // including overlap: 2+17+2
24+
static constexpr int nTowerPhiSLR = 8; // including overlap: 2+4+2
25+
static constexpr int nPFClusterSLR = 8;
26+
27+
namespace gctpf {
28+
29+
typedef struct {
30+
float et;
31+
int eta;
32+
int phi;
33+
} GCTpfcluster_t;
34+
35+
typedef struct {
36+
GCTpfcluster_t GCTpfclusters[nPFClusterSLR];
37+
} PFcluster_t;
38+
39+
typedef struct {
40+
float et;
41+
int eta;
42+
int phi;
43+
} GCTint_t;
44+
45+
typedef struct {
46+
GCTint_t t[nTowerPhiSLR];
47+
} GCTEtaStrip_t;
48+
49+
typedef struct {
50+
GCTint_t p[nTowerEtaSLR - 2];
51+
} GCTEtaStripPeak_t;
52+
53+
typedef struct {
54+
GCTEtaStrip_t s[nTowerEtaSLR];
55+
} Region_t;
56+
57+
inline GCTint_t bestOf2(const GCTint_t& t0, const GCTint_t& t1) {
58+
GCTint_t x;
59+
x = (t0.et > t1.et) ? t0 : t1;
60+
61+
return x;
62+
}
63+
64+
inline GCTint_t getPeakOfStrip(const GCTEtaStrip_t& etaStrip) {
65+
GCTint_t best12 = bestOf2(etaStrip.t[1], etaStrip.t[2]);
66+
GCTint_t best34 = bestOf2(etaStrip.t[3], etaStrip.t[4]);
67+
GCTint_t best56 = bestOf2(etaStrip.t[5], etaStrip.t[6]);
68+
GCTint_t best1234 = bestOf2(best12, best34);
69+
GCTint_t bestAll = bestOf2(best1234, best56);
70+
71+
return bestAll;
72+
}
73+
74+
inline GCTint_t getPeakBin(const GCTEtaStripPeak_t& etaStripPeak) {
75+
GCTint_t best01 = bestOf2(etaStripPeak.p[0], etaStripPeak.p[1]);
76+
GCTint_t best23 = bestOf2(etaStripPeak.p[2], etaStripPeak.p[3]);
77+
GCTint_t best45 = bestOf2(etaStripPeak.p[4], etaStripPeak.p[5]);
78+
GCTint_t best67 = bestOf2(etaStripPeak.p[6], etaStripPeak.p[7]);
79+
GCTint_t best89 = bestOf2(etaStripPeak.p[8], etaStripPeak.p[9]);
80+
GCTint_t best1011 = bestOf2(etaStripPeak.p[10], etaStripPeak.p[11]);
81+
GCTint_t best1213 = bestOf2(etaStripPeak.p[12], etaStripPeak.p[13]);
82+
GCTint_t best1415 = bestOf2(etaStripPeak.p[14], etaStripPeak.p[15]);
83+
GCTint_t best1617 = bestOf2(etaStripPeak.p[16], etaStripPeak.p[17]);
84+
GCTint_t best0123 = bestOf2(best01, best23);
85+
GCTint_t best4567 = bestOf2(best45, best67);
86+
GCTint_t best891011 = bestOf2(best89, best1011);
87+
GCTint_t best12131415 = bestOf2(best1213, best1415);
88+
GCTint_t best01234567 = bestOf2(best0123, best4567);
89+
GCTint_t best01234567891011 = bestOf2(best01234567, best891011);
90+
GCTint_t best121314151617 = bestOf2(best12131415, best1617);
91+
GCTint_t best12131415161718 = bestOf2(best121314151617, etaStripPeak.p[18]);
92+
GCTint_t bestAll = bestOf2(best01234567891011, best12131415161718);
93+
94+
return bestAll;
95+
}
96+
97+
inline GCTint_t getPeakPosition(const Region_t& region) {
98+
GCTEtaStripPeak_t etaPeak;
99+
for (int i = 0; i < nTowerEtaSLR - 2; i++) {
100+
etaPeak.p[i] = getPeakOfStrip(region.s[i + 1]);
101+
}
102+
GCTint_t max = getPeakBin(etaPeak);
103+
104+
return max;
105+
}
106+
107+
inline Region_t initStructure(float temp[nTowerEtaSLR][nTowerPhiSLR]) {
108+
Region_t r;
109+
110+
for (int i = 0; i < nTowerPhiSLR; i++) {
111+
for (int j = 0; j < nTowerEtaSLR; j++) {
112+
r.s[j].t[i].et = temp[j][i];
113+
r.s[j].t[i].eta = j;
114+
r.s[j].t[i].phi = i;
115+
}
116+
}
117+
118+
return r;
119+
}
120+
121+
inline float getEt(float temp[nTowerEtaSLR][nTowerPhiSLR], int eta, int phi) {
122+
float et_sumEta[3];
123+
124+
for (int i = 0; i < (nTowerEtaSLR - 2); i++) {
125+
for (int j = 0; j < (nTowerPhiSLR - 2); j++) {
126+
if (i + 1 == eta && j + 1 == phi) {
127+
for (int k = 0; k < 3; k++) {
128+
et_sumEta[k] = temp[i + k][j] + temp[i + k][j + 1] + temp[i + k][j + 2];
129+
}
130+
}
131+
}
132+
}
133+
134+
float pfcluster_et = et_sumEta[0] + et_sumEta[1] + et_sumEta[2];
135+
136+
return pfcluster_et;
137+
}
138+
139+
inline void RemoveTmp(float temp[nTowerEtaSLR][nTowerPhiSLR], int eta, int phi) {
140+
for (int i = 0; i < nTowerEtaSLR; i++) {
141+
if (i + 1 >= eta && i <= eta + 1) {
142+
for (int j = 0; j < nTowerPhiSLR; j++) {
143+
if (j + 1 >= phi && j <= phi + 1) {
144+
temp[i][j] = 0;
145+
}
146+
}
147+
}
148+
}
149+
150+
return;
151+
}
152+
153+
inline GCTpfcluster_t recoPfcluster(float temporary[nTowerEtaSLR][nTowerPhiSLR], int etaoffset, int phioffset) {
154+
GCTpfcluster_t pfclusterReturn;
155+
156+
Region_t region;
157+
158+
region = initStructure(temporary);
159+
160+
GCTint_t regionMax = getPeakPosition(region);
161+
162+
float pfcluster_et = getEt(temporary, regionMax.eta, regionMax.phi);
163+
164+
RemoveTmp(temporary, regionMax.eta, regionMax.phi);
165+
166+
if (!(regionMax.eta >= 2 && regionMax.eta < (nTowerEtaSLR - 2) && regionMax.phi >= 2 &&
167+
regionMax.phi < (nTowerPhiSLR - 2)))
168+
pfcluster_et = 0;
169+
170+
pfclusterReturn.et = pfcluster_et;
171+
pfclusterReturn.eta = regionMax.eta - 2 + etaoffset;
172+
pfclusterReturn.phi = regionMax.phi - 2 + phioffset;
173+
174+
return pfclusterReturn;
175+
}
176+
177+
inline PFcluster_t pfcluster(float temporary[nTowerEtaSLR][nTowerPhiSLR], int etaoffset, int phioffset) {
178+
GCTpfcluster_t pfcluster[nPFClusterSLR];
179+
180+
for (int i = 0; i < nPFClusterSLR; i++) {
181+
pfcluster[i] = recoPfcluster(temporary, etaoffset, phioffset);
182+
}
183+
184+
PFcluster_t GCTPfclusters;
185+
186+
for (int i = 0; i < nPFClusterSLR; i++) {
187+
GCTPfclusters.GCTpfclusters[i].et = pfcluster[i].et;
188+
GCTPfclusters.GCTpfclusters[i].eta = pfcluster[i].eta;
189+
GCTPfclusters.GCTpfclusters[i].phi = pfcluster[i].phi;
190+
}
191+
192+
return GCTPfclusters;
193+
}
194+
195+
} // namespace gctpf
196+
197+
#endif

0 commit comments

Comments
 (0)