Skip to content

Commit 5dcd169

Browse files
committed
Added bx counters to patterns.
1 parent 689a9b7 commit 5dcd169

2 files changed

Lines changed: 23 additions & 8 deletions

File tree

ugmt_patterns/generate_patterns_from_emulator.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def get_muon_list_out(emu_product, mu_type, vhdl_dict):
4141
return mulist
4242

4343

44-
def get_muon_list(emu_product, mu_type, vhdl_dict, check=False):
44+
def get_muon_list(emu_product, mu_type, vhdl_dict, bx, check=False):
4545
nexpected = 18
4646
if mu_type == "BARREL":
4747
nexpected = 36
@@ -51,7 +51,7 @@ def get_muon_list(emu_product, mu_type, vhdl_dict, check=False):
5151
link_offset = vhdl_dict[mu_type+"_LOW"]
5252
for mu in emu_product:
5353
loc_link = mu.link()-link_offset
54-
mu_tmp = Muon(vhdl_dict, mu_type="IN", obj=mu)
54+
mu_tmp = Muon(vhdl_dict, mu_type="IN", obj=mu, bx=bx)
5555
# only take muons from the right side of the detector
5656
if mu_type.endswith("POS") and mu_tmp.etaBits < 0:
5757
continue
@@ -61,10 +61,13 @@ def get_muon_list(emu_product, mu_type, vhdl_dict, check=False):
6161
# because we don't book all 72*3 muons but only 18*3/36*3
6262
loc_link = mu.link()-link_offset
6363
if mulist[loc_link*3].ptBits == 0:
64+
mu_tmp.setBunchCounter(0)
6465
mulist[loc_link*3] = mu_tmp
6566
elif mulist[loc_link*3+1].ptBits == 0:
67+
mu_tmp.setBunchCounter(1)
6668
mulist[loc_link*3+1] = mu_tmp
6769
elif mulist[loc_link*3+2].ptBits == 0:
70+
mu_tmp.setBunchCounter(2)
6871
mulist[loc_link*3+2] = mu_tmp
6972

7073
if check:
@@ -160,13 +163,13 @@ def main():
160163
imd_prod = imd_handle.product()
161164
imdmuons = get_muon_list_out(imd_prod, "IMD", vhdl_dict)
162165
emu_bar_muons = bar_handle.product()
163-
bar_muons = get_muon_list(emu_bar_muons, "BARREL", vhdl_dict)
166+
bar_muons = get_muon_list(emu_bar_muons, "BARREL", vhdl_dict, i)
164167
emu_ovl_muons = ovl_handle.product()
165-
ovlp_muons = get_muon_list(emu_ovl_muons, "OVL_POS", vhdl_dict)
166-
ovln_muons = get_muon_list(emu_ovl_muons, "OVL_NEG", vhdl_dict)
168+
ovlp_muons = get_muon_list(emu_ovl_muons, "OVL_POS", vhdl_dict, i)
169+
ovln_muons = get_muon_list(emu_ovl_muons, "OVL_NEG", vhdl_dict, i)
167170
emu_fwd_muons = fwd_handle.product()
168-
fwdp_muons = get_muon_list(emu_fwd_muons, "FWD_POS", vhdl_dict)
169-
fwdn_muons = get_muon_list(emu_fwd_muons, "FWD_NEG", vhdl_dict)
171+
fwdp_muons = get_muon_list(emu_fwd_muons, "FWD_POS", vhdl_dict, i)
172+
fwdn_muons = get_muon_list(emu_fwd_muons, "FWD_NEG", vhdl_dict, i)
170173

171174
conversion_time = time.time() - evt_start - get_label_time
172175
input_buffer.writeFrameBasedInputBX(bar_muons, fwdp_muons, fwdn_muons, ovlp_muons, ovln_muons, calo_sums)

ugmt_patterns/helpers/muon.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ def __init__(self, vhdl_dict, mu_type, bitword = None, obj = None, link = -1, fr
1717
"""
1818

1919
# get the bit boundaries for the muon quantities
20+
self.bx = bx
21+
2022
pt_low = vhdl_dict["PT_{t}_LOW".format(t=mu_type)]
2123
pt_high = vhdl_dict["PT_{t}_HIGH".format(t=mu_type)]
2224

@@ -92,7 +94,17 @@ def __init__(self, vhdl_dict, mu_type, bitword = None, obj = None, link = -1, fr
9294
elif self.local_link < vhdl_dict["BARREL_HIGH"]: self.local_link -= vhdl_dict["BARREL_LOW"]
9395
elif self.local_link < vhdl_dict["OVL_NEG_HIGH"]: self.local_link -= vhdl_dict["OVL_NEG_LOW"]
9496
else: self.local_link -= vhdl_dict["FWD_NEG_LOW"]
95-
self.bx = bx
97+
98+
def setBunchCounter(self, n_mu):
99+
if n_mu == 1:
100+
self.bitword += ((self.bx & 0b1) << 31)
101+
# since it is the second bit only need to shift by 62 instead of 63
102+
self.bitword += (self.bx & 0b10) << 62
103+
if n_mu == 2:
104+
self.bitword += (((self.bx & 0b100) >> 2) << 31)
105+
if self.bx == 0 and n_mu == 0:
106+
self.bitword += 1 << 31
107+
pass
96108

97109
def getBx(self):
98110
"""

0 commit comments

Comments
 (0)