diff --git a/README.md b/README.md index 95d69e1..a8ae47d 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Install using pip (>= 19.0) ```bash pip install --upgrade pip -pip install git+https://github.com/cms-l1-globaltrigger/tm-vhdlproducer.git@2.11.1 +pip install git+https://github.com/cms-l1-globaltrigger/tm-vhdlproducer.git@2.12.0 ``` ## Build from source diff --git a/changelog b/changelog index 3de6871..be37e30 100644 --- a/changelog +++ b/changelog @@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [2.12.0] - 2021-12-06 +### Added +- support for displaced jets +### Changed +- depending on tm-python 0.10.0 +- depending on tm-reporter 2.10.1 + ## [2.11.1] - 2021-10-12 ### Changed - refactored resource calculation diff --git a/requirements.txt b/requirements.txt index 746b008..82b8848 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,3 @@ Jinja2==2.11.* -tm-python @ git+https://github.com/cms-l1-globaltrigger/tm-python@0.9.1 -tm-reporter @ git+https://github.com/cms-l1-globaltrigger/tm-reporter@2.9.0 +tm-python @ git+https://github.com/cms-l1-globaltrigger/tm-python@0.10.0 +tm-reporter @ git+https://github.com/cms-l1-globaltrigger/tm-reporter@2.10.1 diff --git a/setup.py b/setup.py index c16599f..208018d 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ setup( name="tm-vhdlproducer", - version='2.11.1', + version='2.12.0', url="https://github.com/cms-l1-globaltrigger/tm-vhdlproducer", author="Bernhard Arnold", author_email="bernhard.arnold@cern.ch", @@ -23,8 +23,8 @@ }, install_requires=[ 'Jinja2==2.11.*', - 'tm-python @ git+https://github.com/cms-l1-globaltrigger/tm-python@0.9.1', - 'tm-reporter @ git+https://github.com/cms-l1-globaltrigger/tm-reporter@2.9.0' + 'tm-python @ git+https://github.com/cms-l1-globaltrigger/tm-python@0.10.0', + 'tm-reporter @ git+https://github.com/cms-l1-globaltrigger/tm-reporter@2.10.1' ], entry_points={ 'console_scripts': [ diff --git a/tests/test_vhdlhelper.py b/tests/test_vhdlhelper.py index 010ef77..6f1e50b 100644 --- a/tests/test_vhdlhelper.py +++ b/tests/test_vhdlhelper.py @@ -1,7 +1,12 @@ import unittest +from collections import namedtuple from tmVhdlProducer import vhdlhelper + +CutHandle = namedtuple('CutHandle', 'data') + + class VhdlHelperTest(unittest.TestCase): def test_snakecase(self): @@ -96,5 +101,20 @@ def test_bx_encode_4_array(self): r = vhdlhelper.bx_encode_4_array(key) self.assertEqual(r, value) + def test_cut_helper(self): + cut = vhdlhelper.CutHelper() + self.assertEqual(cut.enabled, False) + + def test_boolean_cut_helper(self): + cut = vhdlhelper.BooleanCutHelper() + self.assertEqual(cut.enabled, False) + self.assertEqual(cut.state, False) + cut.update(CutHandle(data="1")) + self.assertEqual(cut.enabled, True) + self.assertEqual(cut.state, True) + cut.update(CutHandle(data="0")) + self.assertEqual(cut.enabled, True) + self.assertEqual(cut.state, False) + if __name__ == '__main__': unittest.main() diff --git a/tmVhdlProducer/__init__.py b/tmVhdlProducer/__init__.py index d3583e9..0b288f8 100644 --- a/tmVhdlProducer/__init__.py +++ b/tmVhdlProducer/__init__.py @@ -1 +1 @@ -__version__ = '2.11.1' +__version__ = '2.12.0' diff --git a/tmVhdlProducer/algodist.py b/tmVhdlProducer/algodist.py index 1487690..48d68c3 100644 --- a/tmVhdlProducer/algodist.py +++ b/tmVhdlProducer/algodist.py @@ -176,6 +176,7 @@ kCharge = 'Charge' kQuality = 'Quality' kIsolation = 'Isolation' +kDisplaced = 'Displaced' kDeltaEta = 'DeltaEta' kDeltaPhi = 'DeltaPhi' kDeltaR = 'DeltaR' @@ -215,6 +216,7 @@ tmEventSetup.Charge: kCharge, tmEventSetup.Quality: kQuality, tmEventSetup.Isolation: kIsolation, + tmEventSetup.Displaced: kDisplaced, tmEventSetup.DeltaEta: kDeltaEta, tmEventSetup.DeltaPhi: kDeltaPhi, tmEventSetup.DeltaR: kDeltaR, diff --git a/tmVhdlProducer/config/resource_default.json b/tmVhdlProducer/config/resource_default.json index 6db0bd6..adf7ea0 100644 --- a/tmVhdlProducer/config/resource_default.json +++ b/tmVhdlProducer/config/resource_default.json @@ -225,6 +225,11 @@ "brams": 0, "sliceLUTs": 1 }, + "Displaced": { + "processors": 0, + "brams": 0, + "sliceLUTs": 1 + }, "Slice": { "processors": 0, "brams": 0, diff --git a/tmVhdlProducer/templates/vhdl/instances/base/object_cuts_comb.vhd b/tmVhdlProducer/templates/vhdl/instances/base/object_cuts_comb.vhd index 5533b00..00bc8bb 100644 --- a/tmVhdlProducer/templates/vhdl/instances/base/object_cuts_comb.vhd +++ b/tmVhdlProducer/templates/vhdl/instances/base/object_cuts_comb.vhd @@ -43,6 +43,10 @@ {%- if (o1.isolation) or (o2.isolation) or (o3.isolation) or (o4.isolation) %} iso_luts_obj1 => (X"{{ o1.isolation.value | X01 }}", X"{{ o2.isolation.value | X01 }}", X"{{ o3.isolation.value | X01 }}", X"{{ o4.isolation.value | X01 }}"), {%- endif %} + {%- if (o1.displaced) or (o2.displaced) or (o3.displaced) or (o4.displaced) %} + disp_cuts_obj1 => ({{ o1.displaced | vhdl_bool }}, {{ o2.displaced | vhdl_bool }}, {{ o3.displaced | vhdl_bool }}, {{ o4.displaced | vhdl_bool }}), + disp_requs_obj1 => ({{ o1.displaced.state | vhdl_bool }}, {{ o2.displaced.state | vhdl_bool}}, {{ o3.displaced.state | vhdl_bool}}, {{ o4.displaced.state | vhdl_bool}}), + {% endif %} {%- if (o1.charge) or (o2.charge) or (o3.charge) or (o4.charge) %} requested_charges_obj1 => ("{{ o1.charge.value }}", "{{ o2.charge.value }}", "{{ o3.charge.value }}", "{{ o4.charge.value }}"), {%- endif %} diff --git a/tmVhdlProducer/templates/vhdl/instances/base/object_cuts_correlation.vhd b/tmVhdlProducer/templates/vhdl/instances/base/object_cuts_correlation.vhd index 276541f..fa37064 100644 --- a/tmVhdlProducer/templates/vhdl/instances/base/object_cuts_correlation.vhd +++ b/tmVhdlProducer/templates/vhdl/instances/base/object_cuts_correlation.vhd @@ -44,6 +44,10 @@ {%- if o.isolation %} iso_lut_obj{{i+1}} => X"{{ o.isolation.value | X01 }}", {%- endif %} + {%- if o.displaced %} + disp_cut_obj{{i+1}} => {{ o.displaced | vhdl_bool }}, + disp_requ_obj{{i+1}} => {{ o.displaced.state | vhdl_bool }}, + {% endif %} {%- if o.upt %} upt_cut_obj{{i+1}} => {{ o.upt | vhdl_bool }}, upt_upper_limit_obj{{i+1}} => X"{{ o.upt.upper | X04 }}", diff --git a/tmVhdlProducer/templates/vhdl/instances/correlation_cuts_calculations.vhd b/tmVhdlProducer/templates/vhdl/instances/correlation_cuts_calculations.vhd index cd0b90d..f93727e 100644 --- a/tmVhdlProducer/templates/vhdl/instances/correlation_cuts_calculations.vhd +++ b/tmVhdlProducer/templates/vhdl/instances/correlation_cuts_calculations.vhd @@ -126,8 +126,13 @@ calc_cut_mass_over_dr_{{ o1.type | lower }}_{{ o2.type | lower }}_bx_{{ o1.bx }} ) port map( lhc_clk, + {%- if o1.is_calo_type and o2.is_calo_type %} deta_integer => {{ o1.type | lower }}_{{ o2.type | lower }}_bx_{{ o1.bx }}_bx_{{ o2.bx }}_deta_integer, dphi_integer => {{ o1.type | lower }}_{{ o2.type | lower }}_bx_{{ o1.bx }}_bx_{{ o2.bx }}_dphi_integer, + {%- elif o1.is_muon_type or o2.is_muon_type %} + deta_integer => {{ o1.type | lower }}_{{ o2.type | lower }}_bx_{{ o1.bx }}_bx_{{ o2.bx }}_deta_integer_half_res, + dphi_integer => {{ o1.type | lower }}_{{ o2.type | lower }}_bx_{{ o1.bx }}_bx_{{ o2.bx }}_dphi_integer_half_res, + {%- endif %} inv_mass_pt_in => {{ o1.type | lower }}_{{ o2.type | lower }}_bx_{{ o1.bx }}_bx_{{ o2.bx }}_mass_inv_pt, mass_over_dr => {{ o1.type | lower }}_{{ o2.type | lower }}_bx_{{ o1.bx }}_bx_{{ o2.bx }}_mass_over_dr ); diff --git a/tmVhdlProducer/templates/vhdl/instances/deta_dphi_calculations.vhd b/tmVhdlProducer/templates/vhdl/instances/deta_dphi_calculations.vhd index 9b3b477..8ecf934 100644 --- a/tmVhdlProducer/templates/vhdl/instances/deta_dphi_calculations.vhd +++ b/tmVhdlProducer/templates/vhdl/instances/deta_dphi_calculations.vhd @@ -3,6 +3,7 @@ calc_deta_dphi_integer_{{ o1.type | lower }}_{{ o2.type | lower }}_bx_{{ o1.bx } generic map( {%- if o1.is_muon_type or o2.is_muon_type %} phi_half_range => MUON_PHI_HALF_RANGE_BINS, + phi_h_r_half_range => MUON_PHI_HALF_RES_HALF_RANGE_BINS, {%- endif %} nr_obj1 => NR_{{ o1.type | upper }}_OBJECTS, type_obj1 => {{ o1.type | upper }}_TYPE, @@ -30,6 +31,16 @@ calc_deta_dphi_integer_{{ o1.type | lower }}_{{ o2.type | lower }}_bx_{{ o1.bx } phi_integer_obj1 => {{ o1.type | lower }}_bx_{{ o1.bx }}_phi_integer, phi_integer_obj2 => {{ o2.type | lower }}_bx_{{ o2.bx }}_phi_conv_2_muon_phi_integer, {%- endif %} + {%- if (o1.is_muon_type and o2.is_muon_type) %} + eta_integer_h_r_obj1 => {{ o1.type | lower }}_bx_{{ o1.bx }}_eta_integer_half_res, + phi_integer_h_r_obj1 => {{ o1.type | lower }}_bx_{{ o1.bx }}_phi_integer_half_res, + eta_integer_h_r_obj2 => {{ o2.type | lower }}_bx_{{ o2.bx }}_eta_integer_half_res, + phi_integer_h_r_obj2 => {{ o2.type | lower }}_bx_{{ o2.bx }}_phi_integer_half_res, + {%- endif %} + {%- if (o1.is_muon_type and o2.is_muon_type) %} + deta_integer_half_res => {{ o1.type | lower }}_{{ o2.type | lower }}_bx_{{ o1.bx }}_bx_{{ o2.bx }}_deta_integer_half_res, + dphi_integer_half_res => {{ o1.type | lower }}_{{ o2.type | lower }}_bx_{{ o1.bx }}_bx_{{ o2.bx }}_dphi_integer_half_res, + {%- endif %} {%- if not o2.is_esums_type %} deta_integer => {{ o1.type | lower }}_{{ o2.type | lower }}_bx_{{ o1.bx }}_bx_{{ o2.bx }}_deta_integer, {%- endif %} diff --git a/tmVhdlProducer/templates/vhdl/instances/obj_parameter.vhd b/tmVhdlProducer/templates/vhdl/instances/obj_parameter.vhd index 6903982..fd6644f 100644 --- a/tmVhdlProducer/templates/vhdl/instances/obj_parameter.vhd +++ b/tmVhdlProducer/templates/vhdl/instances/obj_parameter.vhd @@ -23,6 +23,10 @@ calc_obj_parameter_{{ o.type | lower }}_bx_{{ o.bx }}_i: entity work.obj_paramet eta_integer => {{ o.type | lower }}_bx_{{ o.bx }}_eta_integer, {%- endif %} phi_integer => {{ o.type | lower }}_bx_{{ o.bx }}_phi_integer, + {%- if o.is_muon_type %} + eta_integer_h_r => {{ o.type | lower }}_bx_{{ o.bx }}_eta_integer_half_res, + phi_integer_h_r => {{ o.type | lower }}_bx_{{ o.bx }}_phi_integer_half_res, + {%- endif %} cos_phi => {{ o.type | lower }}_bx_{{ o.bx }}_cos_phi, {%- if not o.is_muon_type %} sin_phi => {{ o.type | lower }}_bx_{{ o.bx }}_sin_phi, diff --git a/tmVhdlProducer/templates/vhdl/signals/signal_correlation_conditions_parameter.vhd b/tmVhdlProducer/templates/vhdl/signals/signal_correlation_conditions_parameter.vhd index 77557e3..a7e518a 100644 --- a/tmVhdlProducer/templates/vhdl/signals/signal_correlation_conditions_parameter.vhd +++ b/tmVhdlProducer/templates/vhdl/signals/signal_correlation_conditions_parameter.vhd @@ -15,6 +15,8 @@ signal {{ o.type|lower }}_bx_{{ o.bx }}_upt_vector: diff_inputs_array(0 to NR_{{ o.type|upper }}_OBJECTS-1) := (others => (others => '0')); signal {{ o.type|lower }}_bx_{{ o.bx }}_eta_integer: integer_array(0 to NR_{{ o.type|upper }}_OBJECTS-1) := (others => 0); signal {{ o.type|lower }}_bx_{{ o.bx }}_phi_integer: integer_array(0 to NR_{{ o.type|upper }}_OBJECTS-1) := (others => 0); + signal {{ o.type|lower }}_bx_{{ o.bx }}_eta_integer_half_res: integer_array(0 to NR_{{ o.type|upper }}_OBJECTS-1) := (others => 0); + signal {{ o.type|lower }}_bx_{{ o.bx }}_phi_integer_half_res: integer_array(0 to NR_{{ o.type|upper }}_OBJECTS-1) := (others => 0); signal {{ o.type|lower }}_bx_{{ o.bx }}_cos_phi: integer_array(0 to NR_{{ o.type|upper }}_OBJECTS-1) := (others => 0); signal {{ o.type|lower }}_bx_{{ o.bx }}_sin_phi: integer_array(0 to NR_{{ o.type|upper }}_OBJECTS-1) := (others => 0); {%- elif o.is_esums_type %} diff --git a/tmVhdlProducer/templates/vhdl/signals/signal_correlation_cuts.vhd b/tmVhdlProducer/templates/vhdl/signals/signal_correlation_cuts.vhd index 284bb08..0e2e806 100644 --- a/tmVhdlProducer/templates/vhdl/signals/signal_correlation_cuts.vhd +++ b/tmVhdlProducer/templates/vhdl/signals/signal_correlation_cuts.vhd @@ -9,6 +9,10 @@ signal {{ o1.type|lower }}_{{ o2.type|lower }}_bx_{{ o1.bx }}_bx_{{ o2.bx }}_dphi_integer: dim2_max_phi_range_array(0 to NR_{{ o1.type|upper }}_OBJECTS-1, 0 to NR_{{ o2.type|upper }}_OBJECTS-1) := (others => (others => 0)); signal {{ o1.type|lower }}_{{ o2.type|lower }}_bx_{{ o1.bx }}_bx_{{ o2.bx }}_dphi: deta_dphi_vector_array(0 to NR_{{ o1.type|upper }}_OBJECTS-1, 0 to NR_{{ o2.type|upper }}_OBJECTS-1) := (others => (others => (others => '0'))); {%- endif %} + {%- if o2.is_muon_type %} + signal {{ o1.type|lower }}_{{ o2.type|lower }}_bx_{{ o1.bx }}_bx_{{ o2.bx }}_deta_integer_half_res: dim2_max_eta_range_array(0 to NR_{{ o1.type|upper }}_OBJECTS-1, 0 to NR_{{ o2.type|upper }}_OBJECTS-1) := (others => (others => 0)); + signal {{ o1.type|lower }}_{{ o2.type|lower }}_bx_{{ o1.bx }}_bx_{{ o2.bx }}_dphi_integer_half_res: dim2_max_phi_range_array(0 to NR_{{ o1.type|upper }}_OBJECTS-1, 0 to NR_{{ o2.type|upper }}_OBJECTS-1) := (others => (others => 0)); + {%- endif %} {%- endfor %} {%- for o1, o2 in module.correlationCombinationsDeltaR %} diff --git a/tmVhdlProducer/vhdlhelper.py b/tmVhdlProducer/vhdlhelper.py index 5afbcbd..09f152c 100644 --- a/tmVhdlProducer/vhdlhelper.py +++ b/tmVhdlProducer/vhdlhelper.py @@ -1205,6 +1205,7 @@ class ObjectHelper(VhdlHelper): count [CountCutHelper] upt [UptCutHelper] impactParameter [ImpactParameterCutHelper] + displaced [DisplacedCutHelper] etaNrCuts [int] etaLowerLimit [list] etaLowerLimit [list] @@ -1236,6 +1237,7 @@ def __init__(self): self.count = CountCutHelper() self.upt = UptCutHelper() self.impactParameter = ImpactParameterCutHelper(0xf) + self.displaced = DisplacedCutHelper() # spatial cuts self.etaNrCuts = 0 self.etaLowerLimit = [0, 0, 0, 0, 0] @@ -1281,6 +1283,8 @@ def update(self, object_handle): self.upt.update(cut_handle) elif cut_handle.cut_type == tmEventSetup.ImpactParameter: self.impactParameter.update(cut_handle) + elif cut_handle.cut_type == tmEventSetup.Displaced: + self.displaced.update(cut_handle) if cut_handle.cut_type == tmEventSetup.Slice: self.slice.update(cut_handle) # setup eta windows @@ -1348,7 +1352,7 @@ def __init__(self): def __bool__(self): return self.enabled - + class ThresholdCutHelper(CutHelper): def __init__(self, threshold=0): @@ -1401,6 +1405,20 @@ def update(self, cut_handle): self.value = int(cut_handle.data) self.enabled = True +class BooleanCutHelper(CutHelper): + + def __init__(self, state=False): + super().__init__() + self.state = state + + def update(self, cut_handle): + self.state = bool(int(cut_handle.data)) + self.enabled = True + +class DisplacedCutHelper(BooleanCutHelper): + + pass + class ChargeCutHelper(CutHelper): def __init__(self, value):