triggerflow 0.1.4__py3-none-any.whl → 0.2.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- trigger_dataset/__init__.py +0 -0
- trigger_dataset/core.py +88 -0
- trigger_loader/__init__.py +0 -0
- trigger_loader/cluster_manager.py +107 -0
- trigger_loader/loader.py +147 -0
- trigger_loader/processor.py +211 -0
- triggerflow/cli.py +122 -0
- triggerflow/core.py +127 -69
- triggerflow/interfaces/__init__.py +0 -0
- triggerflow/interfaces/uGT.py +127 -0
- triggerflow/mlflow_wrapper.py +190 -19
- triggerflow/starter/.gitignore +143 -0
- triggerflow/starter/README.md +0 -0
- triggerflow/starter/cookiecutter.json +5 -0
- triggerflow/starter/prompts.yml +9 -0
- triggerflow/starter/{{ cookiecutter.repo_name }}/.dvcignore +3 -0
- triggerflow/starter/{{ cookiecutter.repo_name }}/.gitignore +143 -0
- triggerflow/starter/{{ cookiecutter.repo_name }}/.gitlab-ci.yml +56 -0
- triggerflow/starter/{{ cookiecutter.repo_name }}/README.md +29 -0
- triggerflow/starter/{{ cookiecutter.repo_name }}/conf/README.md +26 -0
- triggerflow/starter/{{ cookiecutter.repo_name }}/conf/base/catalog.yml +84 -0
- triggerflow/starter/{{ cookiecutter.repo_name }}/conf/base/parameters.yml +0 -0
- triggerflow/starter/{{ cookiecutter.repo_name }}/conf/base/parameters_compile.yml +14 -0
- triggerflow/starter/{{ cookiecutter.repo_name }}/conf/base/parameters_data_processing.yml +8 -0
- triggerflow/starter/{{ cookiecutter.repo_name }}/conf/base/parameters_load_data.yml +5 -0
- triggerflow/starter/{{ cookiecutter.repo_name }}/conf/base/parameters_model_training.yml +9 -0
- triggerflow/starter/{{ cookiecutter.repo_name }}/conf/base/parameters_model_validation.yml +5 -0
- triggerflow/starter/{{ cookiecutter.repo_name }}/conf/local/catalog.yml +84 -0
- triggerflow/starter/{{ cookiecutter.repo_name }}/conf/local/parameters.yml +0 -0
- triggerflow/starter/{{ cookiecutter.repo_name }}/conf/local/parameters_compile.yml +14 -0
- triggerflow/starter/{{ cookiecutter.repo_name }}/conf/local/parameters_data_processing.yml +8 -0
- triggerflow/starter/{{ cookiecutter.repo_name }}/conf/local/parameters_load_data.yml +5 -0
- triggerflow/starter/{{ cookiecutter.repo_name }}/conf/local/parameters_model_training.yml +9 -0
- triggerflow/starter/{{ cookiecutter.repo_name }}/conf/local/parameters_model_validation.yml +5 -0
- triggerflow/starter/{{ cookiecutter.repo_name }}/conf/logging.yml +43 -0
- triggerflow/starter/{{ cookiecutter.repo_name }}/data/01_raw/.gitkeep +0 -0
- triggerflow/starter/{{ cookiecutter.repo_name }}/data/01_raw/samples.json +15 -0
- triggerflow/starter/{{ cookiecutter.repo_name }}/data/01_raw/samples_dummy.json +26 -0
- triggerflow/starter/{{ cookiecutter.repo_name }}/data/02_loaded/.gitkeep +0 -0
- triggerflow/starter/{{ cookiecutter.repo_name }}/data/03_preprocessed/.gitkeep +0 -0
- triggerflow/starter/{{ cookiecutter.repo_name }}/data/04_models/.gitkeep +0 -0
- triggerflow/starter/{{ cookiecutter.repo_name }}/data/05_validation/.gitkeep +0 -0
- triggerflow/starter/{{ cookiecutter.repo_name }}/data/06_compile/.gitkeep +0 -0
- triggerflow/starter/{{ cookiecutter.repo_name }}/data/07_reporting/.gitkeep +0 -0
- triggerflow/starter/{{ cookiecutter.repo_name }}/dvc.yaml +7 -0
- triggerflow/starter/{{ cookiecutter.repo_name }}/environment.yml +21 -0
- triggerflow/starter/{{ cookiecutter.repo_name }}/pyproject.toml +50 -0
- triggerflow/starter/{{ cookiecutter.repo_name }}/src/{{ cookiecutter.python_package }}/__init__.py +3 -0
- triggerflow/starter/{{ cookiecutter.repo_name }}/src/{{ cookiecutter.python_package }}/__main__.py +25 -0
- triggerflow/starter/{{ cookiecutter.repo_name }}/src/{{ cookiecutter.python_package }}/datasets/any_object.py +20 -0
- triggerflow/starter/{{ cookiecutter.repo_name }}/src/{{ cookiecutter.python_package }}/datasets/base_dataset.py +137 -0
- triggerflow/starter/{{ cookiecutter.repo_name }}/src/{{ cookiecutter.python_package }}/datasets/meta_dataset.py +88 -0
- triggerflow/starter/{{ cookiecutter.repo_name }}/src/{{ cookiecutter.python_package }}/datasets/{{ cookiecutter.python_package }}_dataset.py +35 -0
- triggerflow/starter/{{ cookiecutter.repo_name }}/src/{{ cookiecutter.python_package }}/models/__init__.py +0 -0
- triggerflow/starter/{{ cookiecutter.repo_name }}/src/{{ cookiecutter.python_package }}/models/base_model.py +155 -0
- triggerflow/starter/{{ cookiecutter.repo_name }}/src/{{ cookiecutter.python_package }}/models/{{ cookiecutter.python_package }}_model.py +16 -0
- triggerflow/starter/{{ cookiecutter.repo_name }}/src/{{ cookiecutter.python_package }}/pipeline_registry.py +17 -0
- triggerflow/starter/{{ cookiecutter.repo_name }}/src/{{ cookiecutter.python_package }}/pipelines/compile/__init__.py +10 -0
- triggerflow/starter/{{ cookiecutter.repo_name }}/src/{{ cookiecutter.python_package }}/pipelines/compile/nodes.py +50 -0
- triggerflow/starter/{{ cookiecutter.repo_name }}/src/{{ cookiecutter.python_package }}/pipelines/compile/pipeline.py +10 -0
- triggerflow/starter/{{ cookiecutter.repo_name }}/src/{{ cookiecutter.python_package }}/pipelines/data_processing/__init__.py +10 -0
- triggerflow/starter/{{ cookiecutter.repo_name }}/src/{{ cookiecutter.python_package }}/pipelines/data_processing/nodes.py +40 -0
- triggerflow/starter/{{ cookiecutter.repo_name }}/src/{{ cookiecutter.python_package }}/pipelines/data_processing/pipeline.py +28 -0
- triggerflow/starter/{{ cookiecutter.repo_name }}/src/{{ cookiecutter.python_package }}/pipelines/load_data/__init__.py +10 -0
- triggerflow/starter/{{ cookiecutter.repo_name }}/src/{{ cookiecutter.python_package }}/pipelines/load_data/nodes.py +12 -0
- triggerflow/starter/{{ cookiecutter.repo_name }}/src/{{ cookiecutter.python_package }}/pipelines/load_data/pipeline.py +20 -0
- triggerflow/starter/{{ cookiecutter.repo_name }}/src/{{ cookiecutter.python_package }}/pipelines/model_training/__init__.py +10 -0
- triggerflow/starter/{{ cookiecutter.repo_name }}/src/{{ cookiecutter.python_package }}/pipelines/model_training/nodes.py +31 -0
- triggerflow/starter/{{ cookiecutter.repo_name }}/src/{{ cookiecutter.python_package }}/pipelines/model_training/pipeline.py +24 -0
- triggerflow/starter/{{ cookiecutter.repo_name }}/src/{{ cookiecutter.python_package }}/pipelines/model_validation/__init__.py +10 -0
- triggerflow/starter/{{ cookiecutter.repo_name }}/src/{{ cookiecutter.python_package }}/pipelines/model_validation/nodes.py +29 -0
- triggerflow/starter/{{ cookiecutter.repo_name }}/src/{{ cookiecutter.python_package }}/pipelines/model_validation/pipeline.py +24 -0
- triggerflow/starter/{{ cookiecutter.repo_name }}/src/{{ cookiecutter.python_package }}/settings.py +46 -0
- triggerflow/starter/{{ cookiecutter.repo_name }}/src/{{ cookiecutter.python_package }}/utils/__init__.py +0 -0
- triggerflow/starter/{{ cookiecutter.repo_name }}/src/{{ cookiecutter.python_package }}/utils/metric.py +4 -0
- triggerflow/starter/{{ cookiecutter.repo_name }}/src/{{ cookiecutter.python_package }}/utils/plotting.py +598 -0
- triggerflow/starter/{{ cookiecutter.repo_name }}/tests/__init__.py +0 -0
- triggerflow/starter/{{ cookiecutter.repo_name }}/tests/pipelines/__init__.py +0 -0
- triggerflow/starter/{{ cookiecutter.repo_name }}/tests/pipelines/compile/__init__.py +0 -0
- triggerflow/starter/{{ cookiecutter.repo_name }}/tests/pipelines/compile/test_pipeline.py +9 -0
- triggerflow/starter/{{ cookiecutter.repo_name }}/tests/pipelines/data_processing/__init__.py +0 -0
- triggerflow/starter/{{ cookiecutter.repo_name }}/tests/pipelines/data_processing/test_pipeline.py +9 -0
- triggerflow/starter/{{ cookiecutter.repo_name }}/tests/pipelines/load_data/__init__.py +0 -0
- triggerflow/starter/{{ cookiecutter.repo_name }}/tests/pipelines/load_data/test_pipeline.py +9 -0
- triggerflow/starter/{{ cookiecutter.repo_name }}/tests/pipelines/model_training/__init__.py +0 -0
- triggerflow/starter/{{ cookiecutter.repo_name }}/tests/pipelines/model_training/test_pipeline.py +9 -0
- triggerflow/starter/{{ cookiecutter.repo_name }}/tests/pipelines/model_validation/__init__.py +0 -0
- triggerflow/starter/{{ cookiecutter.repo_name }}/tests/pipelines/model_validation/test_pipeline.py +9 -0
- triggerflow/starter/{{ cookiecutter.repo_name }}/tests/test_run.py +27 -0
- triggerflow/templates/build_ugt.tcl +46 -0
- triggerflow/templates/data_types.h +524 -0
- triggerflow/templates/makefile +3 -3
- triggerflow/templates/makefile_version +2 -2
- triggerflow/templates/model-gt.cpp +104 -0
- triggerflow/templates/model_template.cpp +19 -18
- triggerflow/templates/scales.h +1 -1
- triggerflow-0.2.4.dist-info/METADATA +192 -0
- triggerflow-0.2.4.dist-info/RECORD +102 -0
- triggerflow-0.2.4.dist-info/entry_points.txt +2 -0
- triggerflow-0.2.4.dist-info/top_level.txt +3 -0
- triggerflow-0.1.4.dist-info/METADATA +0 -61
- triggerflow-0.1.4.dist-info/RECORD +0 -11
- triggerflow-0.1.4.dist-info/top_level.txt +0 -1
- {triggerflow-0.1.4.dist-info → triggerflow-0.2.4.dist-info}/WHEEL +0 -0
triggerflow/starter/{{ cookiecutter.repo_name }}/tests/pipelines/model_training/test_pipeline.py
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"""
|
|
2
|
+
This is a boilerplate test file for pipeline 'model_training'
|
|
3
|
+
generated using Kedro 1.0.0
|
|
4
|
+
Please add your pipeline tests here.
|
|
5
|
+
|
|
6
|
+
Kedro recommends using `pytest` framework, more info about it can be found
|
|
7
|
+
in the official documentation:
|
|
8
|
+
https://docs.pytest.org/en/latest/getting-started.html
|
|
9
|
+
"""
|
|
File without changes
|
triggerflow/starter/{{ cookiecutter.repo_name }}/tests/pipelines/model_validation/test_pipeline.py
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"""
|
|
2
|
+
This is a boilerplate test file for pipeline 'model_validation'
|
|
3
|
+
generated using Kedro 1.0.0
|
|
4
|
+
Please add your pipeline tests here.
|
|
5
|
+
|
|
6
|
+
Kedro recommends using `pytest` framework, more info about it can be found
|
|
7
|
+
in the official documentation:
|
|
8
|
+
https://docs.pytest.org/en/latest/getting-started.html
|
|
9
|
+
"""
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"""
|
|
2
|
+
This module contains example tests for a Kedro project.
|
|
3
|
+
Tests should be placed in ``src/tests``, in modules that mirror your
|
|
4
|
+
project's structure, and in files named test_*.py.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import pytest
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
from kedro.framework.session import KedroSession
|
|
10
|
+
from kedro.framework.startup import bootstrap_project
|
|
11
|
+
|
|
12
|
+
# The tests below are here for the demonstration purpose
|
|
13
|
+
# and should be replaced with the ones testing the project
|
|
14
|
+
# functionality
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class TestKedroRun:
|
|
18
|
+
def test_kedro_run_no_pipeline(self):
|
|
19
|
+
# This example test expects a pipeline run failure, since
|
|
20
|
+
# the default project template contains no pipelines.
|
|
21
|
+
bootstrap_project(Path.cwd())
|
|
22
|
+
|
|
23
|
+
with pytest.raises(Exception) as excinfo:
|
|
24
|
+
with KedroSession.create(project_path=Path.cwd()) as session:
|
|
25
|
+
session.run()
|
|
26
|
+
|
|
27
|
+
assert "Pipeline contains no nodes" in str(excinfo.value)
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
file mkdir prj_{{ MODEL_NAME }}
|
|
2
|
+
|
|
3
|
+
open_project -reset prj_{{ MODEL_NAME }}
|
|
4
|
+
|
|
5
|
+
set_top {{ MODEL_NAME }}_GT
|
|
6
|
+
|
|
7
|
+
set core_files "model-gt.cpp {{ MODEL_NAME }}_project.cpp"
|
|
8
|
+
|
|
9
|
+
if { [file exists "BDT.cpp"] } {
|
|
10
|
+
set all_files "$core_files BDT.cpp"
|
|
11
|
+
} else {
|
|
12
|
+
set all_files "$core_files"
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
add_files $all_files -cflags "-std=c++11 -I../"
|
|
16
|
+
|
|
17
|
+
open_solution -reset solution1
|
|
18
|
+
set_part {xc7vx690t-ffg1927-2}
|
|
19
|
+
|
|
20
|
+
create_clock -period 25
|
|
21
|
+
set_clock_uncertainty 0
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
config_array_partition -complete_threshold 2
|
|
25
|
+
|
|
26
|
+
csynth_design
|
|
27
|
+
|
|
28
|
+
file mkdir firmware
|
|
29
|
+
file mkdir firmware/hdl
|
|
30
|
+
file mkdir firmware/hdl/payload
|
|
31
|
+
file mkdir firmware/hdl/payload/gtl
|
|
32
|
+
file mkdir firmware/hdl/payload/gtl/model
|
|
33
|
+
file mkdir firmware/cfg
|
|
34
|
+
|
|
35
|
+
set f [open firmware/cfg/model.dep "w"]
|
|
36
|
+
|
|
37
|
+
if {[file exists prj_{{ MODEL_NAME }}/solution1/syn/vhdl]} {
|
|
38
|
+
foreach filepath [glob -nocomplain prj_{{ MODEL_NAME }}/solution1/syn/vhdl/*] {
|
|
39
|
+
set filename [file tail $filepath]
|
|
40
|
+
file copy -force $filepath firmware/hdl/payload/gtl/model/$filename
|
|
41
|
+
puts $f "src payload/gtl/model/$filename"
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
close $f
|
|
46
|
+
exit
|
|
@@ -0,0 +1,524 @@
|
|
|
1
|
+
#ifndef L1GT_DATATYPES
|
|
2
|
+
#define L1GT_DATATYPES
|
|
3
|
+
|
|
4
|
+
#include "ap_fixed.h"
|
|
5
|
+
#include <cmath>
|
|
6
|
+
|
|
7
|
+
// Author: sioni@cern.ch August 2022
|
|
8
|
+
// Object data types defined in https://github.com/cms-l1-globaltrigger/mp7_ugt_legacy/blob/master/firmware/hdl/packages/gtl_pkg.vhd
|
|
9
|
+
// Code mimics Phase 2 L1Trigger Particle Flow data types HLS:
|
|
10
|
+
// https://github.com/cms-sw/cmssw/tree/master/DataFormats/L1TParticleFlow/interface
|
|
11
|
+
|
|
12
|
+
typedef ap_fixed<9,2> cossin_t;
|
|
13
|
+
typedef ap_fixed<13,7> sinh_t;
|
|
14
|
+
|
|
15
|
+
static constexpr int N_TABLE = 2048;
|
|
16
|
+
|
|
17
|
+
/* ---
|
|
18
|
+
* Constants useful for converting physical units to hardware integers
|
|
19
|
+
* --- */
|
|
20
|
+
namespace Scales{
|
|
21
|
+
static const double MUON_PHI_LSB = 2 * M_PI / 576;
|
|
22
|
+
static const double CALO_PHI_LSB = 2 * M_PI / 144;
|
|
23
|
+
|
|
24
|
+
static const double MUON_ETA_LSB = 0.0870 / 8;
|
|
25
|
+
static const double CALO_ETA_LSB = 0.0870 / 2;
|
|
26
|
+
|
|
27
|
+
static const double MUON_PT_LSB = 0.5;
|
|
28
|
+
static const double CALO_PT_LSB = 0.5;
|
|
29
|
+
|
|
30
|
+
const int INTPHI_PI = 720;
|
|
31
|
+
|
|
32
|
+
static const int MUON_HALF_PI = 144;
|
|
33
|
+
static const int CALO_HALF_PI = 36;
|
|
34
|
+
}; // namespace Scales
|
|
35
|
+
|
|
36
|
+
/* ---
|
|
37
|
+
* Functions for packing and unpacking ap_ objects
|
|
38
|
+
* --- */
|
|
39
|
+
template <typename U, typename T>
|
|
40
|
+
inline void pack_into_bits(U& u, unsigned int& start, const T& data) {
|
|
41
|
+
const unsigned int w = T::width;
|
|
42
|
+
u(start + w - 1, start) = data(w - 1, 0);
|
|
43
|
+
start += w;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
template <typename U, typename T>
|
|
47
|
+
inline void unpack_from_bits(const U& u, unsigned int& start, T& data) {
|
|
48
|
+
const unsigned int w = T::width;
|
|
49
|
+
data(w - 1, 0) = u(start + w - 1, start);
|
|
50
|
+
start += w;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/* ---
|
|
54
|
+
* Definitions of the objects received by the GT
|
|
55
|
+
* --- */
|
|
56
|
+
/* ---
|
|
57
|
+
* Muon
|
|
58
|
+
* --- */
|
|
59
|
+
struct Muon{
|
|
60
|
+
ap_uint<10> phi_extrapolated;
|
|
61
|
+
ap_ufixed<9,8> pt;
|
|
62
|
+
ap_uint<4> quality;
|
|
63
|
+
ap_int<9> eta_extrapolated;
|
|
64
|
+
ap_uint<2> iso;
|
|
65
|
+
ap_uint<1> charge_sign;
|
|
66
|
+
ap_uint<1> charge_valid;
|
|
67
|
+
ap_uint<7> index_bits;
|
|
68
|
+
ap_uint<10> phi_out;
|
|
69
|
+
ap_uint<8> pt_unconstrained;
|
|
70
|
+
ap_uint<1> hadronic_shower_trigger;
|
|
71
|
+
ap_uint<2> impact_parameter;
|
|
72
|
+
|
|
73
|
+
static const int BITWIDTH = 64;
|
|
74
|
+
|
|
75
|
+
inline void clear(){
|
|
76
|
+
phi_extrapolated = 0;
|
|
77
|
+
pt = 0;
|
|
78
|
+
quality = 0;
|
|
79
|
+
eta_extrapolated = 0;
|
|
80
|
+
iso = 0;
|
|
81
|
+
charge_sign = 0;
|
|
82
|
+
charge_valid = 0;
|
|
83
|
+
index_bits = 0;
|
|
84
|
+
phi_out = 0;
|
|
85
|
+
pt_unconstrained = 0;
|
|
86
|
+
hadronic_shower_trigger = 0;
|
|
87
|
+
impact_parameter = 0;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
inline ap_uint<BITWIDTH> pack() const{
|
|
91
|
+
ap_uint<BITWIDTH> ret;
|
|
92
|
+
unsigned int start = 0;
|
|
93
|
+
pack_into_bits(ret, start, phi_extrapolated);
|
|
94
|
+
pack_into_bits(ret, start, pt);
|
|
95
|
+
pack_into_bits(ret, start, quality);
|
|
96
|
+
pack_into_bits(ret, start, eta_extrapolated);
|
|
97
|
+
pack_into_bits(ret, start, iso);
|
|
98
|
+
pack_into_bits(ret, start, charge_sign);
|
|
99
|
+
pack_into_bits(ret, start, charge_valid);
|
|
100
|
+
pack_into_bits(ret, start, index_bits);
|
|
101
|
+
pack_into_bits(ret, start, phi_out);
|
|
102
|
+
pack_into_bits(ret, start, pt_unconstrained);
|
|
103
|
+
pack_into_bits(ret, start, hadronic_shower_trigger);
|
|
104
|
+
pack_into_bits(ret, start, impact_parameter);
|
|
105
|
+
return ret;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
inline void initFromBits(const ap_uint<BITWIDTH> &src){
|
|
109
|
+
unsigned int start = 0;
|
|
110
|
+
unpack_from_bits(src, start, phi_extrapolated);
|
|
111
|
+
unpack_from_bits(src, start, pt);
|
|
112
|
+
unpack_from_bits(src, start, quality);
|
|
113
|
+
unpack_from_bits(src, start, eta_extrapolated);
|
|
114
|
+
unpack_from_bits(src, start, iso);
|
|
115
|
+
unpack_from_bits(src, start, charge_sign);
|
|
116
|
+
unpack_from_bits(src, start, charge_valid);
|
|
117
|
+
unpack_from_bits(src, start, index_bits);
|
|
118
|
+
unpack_from_bits(src, start, phi_out);
|
|
119
|
+
unpack_from_bits(src, start, pt_unconstrained);
|
|
120
|
+
unpack_from_bits(src, start, hadronic_shower_trigger);
|
|
121
|
+
unpack_from_bits(src, start, impact_parameter);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
inline static Muon unpack(const ap_uint<BITWIDTH> &src){
|
|
125
|
+
Muon ret;
|
|
126
|
+
ret.initFromBits(src);
|
|
127
|
+
return ret;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
inline static Muon initFromPhysicalDoubles(const double pt, const double eta, const double phi){
|
|
131
|
+
Muon ret;
|
|
132
|
+
ret.clear();
|
|
133
|
+
ret.pt = pt;
|
|
134
|
+
ret.eta_extrapolated = round(eta / Scales::MUON_ETA_LSB);
|
|
135
|
+
ret.phi_extrapolated = round(phi / Scales::MUON_PHI_LSB);
|
|
136
|
+
return ret;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
inline static Muon initFromHWInt(int pt, int eta, int phi){
|
|
140
|
+
Muon muon;
|
|
141
|
+
muon.clear();
|
|
142
|
+
muon.pt.V = pt;
|
|
143
|
+
muon.eta_extrapolated.V = eta;
|
|
144
|
+
muon.phi_extrapolated.V = phi;
|
|
145
|
+
return muon;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
}; // struct Muon
|
|
149
|
+
|
|
150
|
+
/* ---
|
|
151
|
+
* Jet
|
|
152
|
+
* --- */
|
|
153
|
+
struct Jet{
|
|
154
|
+
ap_ufixed<11,10> et;
|
|
155
|
+
ap_int<8> eta;
|
|
156
|
+
ap_uint<8> phi;
|
|
157
|
+
ap_uint<1> disp;
|
|
158
|
+
ap_uint<2> quality;
|
|
159
|
+
ap_uint<2> spare;
|
|
160
|
+
|
|
161
|
+
static const int BITWIDTH = 32;
|
|
162
|
+
|
|
163
|
+
inline void clear(){
|
|
164
|
+
et = 0;
|
|
165
|
+
eta = 0;
|
|
166
|
+
phi = 0;
|
|
167
|
+
disp = 0;
|
|
168
|
+
quality = 0;
|
|
169
|
+
spare = 0;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
inline ap_uint<BITWIDTH> pack() const{
|
|
173
|
+
ap_uint<BITWIDTH> ret;
|
|
174
|
+
unsigned int start = 0;
|
|
175
|
+
pack_into_bits(ret, start, et);
|
|
176
|
+
pack_into_bits(ret, start, eta);
|
|
177
|
+
pack_into_bits(ret, start, phi);
|
|
178
|
+
pack_into_bits(ret, start, disp);
|
|
179
|
+
pack_into_bits(ret, start, quality);
|
|
180
|
+
pack_into_bits(ret, start, spare);
|
|
181
|
+
return ret;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
inline void initFromBits(const ap_uint<BITWIDTH> &src){
|
|
185
|
+
unsigned int start = 0;
|
|
186
|
+
unpack_from_bits(src, start, et);
|
|
187
|
+
unpack_from_bits(src, start, eta);
|
|
188
|
+
unpack_from_bits(src, start, phi);
|
|
189
|
+
unpack_from_bits(src, start, disp);
|
|
190
|
+
unpack_from_bits(src, start, quality);
|
|
191
|
+
unpack_from_bits(src, start, spare);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
inline static Jet unpack(const ap_uint<BITWIDTH> &src){
|
|
195
|
+
Jet ret;
|
|
196
|
+
ret.initFromBits(src);
|
|
197
|
+
return ret;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
inline static Jet initFromPhysicalDoubles(const double et, const double eta, const double phi){
|
|
201
|
+
Jet ret;
|
|
202
|
+
ret.clear();
|
|
203
|
+
ret.et = et;
|
|
204
|
+
ret.eta = round(eta / Scales::CALO_ETA_LSB);
|
|
205
|
+
ret.phi = round(phi / Scales::CALO_PHI_LSB);
|
|
206
|
+
return ret;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
inline static Jet initFromHWInt(const int et, const int eta, const int phi){
|
|
210
|
+
Jet ret;
|
|
211
|
+
ret.clear();
|
|
212
|
+
ret.et.V = et;
|
|
213
|
+
ret.eta.V = eta;
|
|
214
|
+
ret.phi.V = phi;
|
|
215
|
+
return ret;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
}; // struct Jet
|
|
219
|
+
|
|
220
|
+
/* ---
|
|
221
|
+
* e / gamma or tau (same format)
|
|
222
|
+
* --- */
|
|
223
|
+
struct CaloCommon{
|
|
224
|
+
ap_ufixed<9,8> et;
|
|
225
|
+
ap_int<8> eta;
|
|
226
|
+
ap_uint<8> phi;
|
|
227
|
+
ap_uint<2> iso;
|
|
228
|
+
ap_uint<5> spare;
|
|
229
|
+
|
|
230
|
+
static const int BITWIDTH = 32;
|
|
231
|
+
|
|
232
|
+
inline void clear(){
|
|
233
|
+
et = 0;
|
|
234
|
+
eta = 0;
|
|
235
|
+
phi = 0;
|
|
236
|
+
iso = 0;
|
|
237
|
+
spare = 0;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
inline ap_uint<BITWIDTH> pack() const{
|
|
241
|
+
ap_uint<BITWIDTH> ret;
|
|
242
|
+
unsigned int start = 0;
|
|
243
|
+
pack_into_bits(ret, start, et);
|
|
244
|
+
pack_into_bits(ret, start, eta);
|
|
245
|
+
pack_into_bits(ret, start, phi);
|
|
246
|
+
pack_into_bits(ret, start, iso);
|
|
247
|
+
pack_into_bits(ret, start, spare);
|
|
248
|
+
return ret;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
inline void initFromBits(const ap_uint<BITWIDTH> &src){
|
|
252
|
+
unsigned int start = 0;
|
|
253
|
+
unpack_from_bits(src, start, et);
|
|
254
|
+
unpack_from_bits(src, start, eta);
|
|
255
|
+
unpack_from_bits(src, start, phi);
|
|
256
|
+
unpack_from_bits(src, start, iso);
|
|
257
|
+
unpack_from_bits(src, start, spare);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
inline static CaloCommon unpack(const ap_uint<BITWIDTH> &src){
|
|
261
|
+
CaloCommon ret;
|
|
262
|
+
ret.initFromBits(src);
|
|
263
|
+
return ret;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
inline static CaloCommon initFromPhysicalDoubles(const double et, const double eta, const double phi){
|
|
267
|
+
CaloCommon ret;
|
|
268
|
+
ret.clear();
|
|
269
|
+
ret.et = et;
|
|
270
|
+
ret.eta = round(eta / Scales::CALO_ETA_LSB);
|
|
271
|
+
ret.phi = round(phi / Scales::CALO_PHI_LSB);
|
|
272
|
+
return ret;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
inline static CaloCommon initFromHWInt(const int et, const int eta, const int phi){
|
|
276
|
+
CaloCommon ret;
|
|
277
|
+
ret.clear();
|
|
278
|
+
ret.et.V = et;
|
|
279
|
+
ret.eta.V = eta;
|
|
280
|
+
ret.phi.V = phi;
|
|
281
|
+
return ret;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
}; // struct CaloCommon
|
|
285
|
+
|
|
286
|
+
typedef CaloCommon EGamma;
|
|
287
|
+
typedef CaloCommon Tau;
|
|
288
|
+
|
|
289
|
+
/* ---
|
|
290
|
+
* Scalar Sums
|
|
291
|
+
* --- */
|
|
292
|
+
struct ET{
|
|
293
|
+
ap_ufixed<12,11> et;
|
|
294
|
+
ap_ufixed<12,11> ettem;
|
|
295
|
+
ap_uint<4> spare;
|
|
296
|
+
ap_uint<4> minimum_bias_hf;
|
|
297
|
+
|
|
298
|
+
static const int BITWIDTH = 32;
|
|
299
|
+
|
|
300
|
+
inline void clear(){
|
|
301
|
+
et = 0;
|
|
302
|
+
ettem = 0;
|
|
303
|
+
spare = 0;
|
|
304
|
+
minimum_bias_hf = 0;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
inline ap_uint<BITWIDTH> pack() const{
|
|
308
|
+
ap_uint<BITWIDTH> ret;
|
|
309
|
+
unsigned int start = 0;
|
|
310
|
+
pack_into_bits(ret, start, et);
|
|
311
|
+
pack_into_bits(ret, start, ettem);
|
|
312
|
+
pack_into_bits(ret, start, spare);
|
|
313
|
+
pack_into_bits(ret, start, minimum_bias_hf);
|
|
314
|
+
return ret;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
inline void initFromBits(const ap_uint<BITWIDTH> &src){
|
|
318
|
+
unsigned int start = 0;
|
|
319
|
+
unpack_from_bits(src, start, et);
|
|
320
|
+
unpack_from_bits(src, start, ettem);
|
|
321
|
+
unpack_from_bits(src, start, spare);
|
|
322
|
+
unpack_from_bits(src, start, minimum_bias_hf);
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
inline static ET unpack(const ap_uint<BITWIDTH> &src){
|
|
326
|
+
ET ret;
|
|
327
|
+
ret.initFromBits(src);
|
|
328
|
+
return ret;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
inline static ET initFromPhysicalDoubles(const double et, const double ettem){
|
|
332
|
+
ET ret;
|
|
333
|
+
ret.clear();
|
|
334
|
+
ret.et = et;
|
|
335
|
+
ret.ettem = ettem;
|
|
336
|
+
return ret;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
inline static ET initFromHWInt(const int et, const int ettem){
|
|
340
|
+
ET ret;
|
|
341
|
+
ret.clear();
|
|
342
|
+
ret.et.V = et;
|
|
343
|
+
ret.ettem.V = ettem;
|
|
344
|
+
return ret;
|
|
345
|
+
}
|
|
346
|
+
}; // struct ET
|
|
347
|
+
|
|
348
|
+
struct HT{
|
|
349
|
+
ap_ufixed<12,11> et;
|
|
350
|
+
ap_uint<13> tower_count;
|
|
351
|
+
ap_uint<3> spare;
|
|
352
|
+
ap_uint<4> minimum_bias_hf;
|
|
353
|
+
|
|
354
|
+
static const int BITWIDTH = 32;
|
|
355
|
+
|
|
356
|
+
inline void clear(){
|
|
357
|
+
et = 0;
|
|
358
|
+
tower_count = 0;
|
|
359
|
+
spare = 0;
|
|
360
|
+
minimum_bias_hf = 0;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
inline ap_uint<BITWIDTH> pack() const{
|
|
364
|
+
ap_uint<BITWIDTH> ret;
|
|
365
|
+
unsigned int start = 0;
|
|
366
|
+
pack_into_bits(ret, start, et);
|
|
367
|
+
pack_into_bits(ret, start, tower_count);
|
|
368
|
+
pack_into_bits(ret, start, spare);
|
|
369
|
+
pack_into_bits(ret, start, minimum_bias_hf);
|
|
370
|
+
return ret;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
inline void initFromBits(const ap_uint<BITWIDTH> &src){
|
|
374
|
+
unsigned int start = 0;
|
|
375
|
+
unpack_from_bits(src, start, et);
|
|
376
|
+
unpack_from_bits(src, start, tower_count);
|
|
377
|
+
unpack_from_bits(src, start, spare);
|
|
378
|
+
unpack_from_bits(src, start, minimum_bias_hf);
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
inline static HT unpack(const ap_uint<BITWIDTH> &src){
|
|
382
|
+
HT ret;
|
|
383
|
+
ret.initFromBits(src);
|
|
384
|
+
return ret;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
inline static HT initFromPhysicalDoubles(const double et){
|
|
388
|
+
HT ret;
|
|
389
|
+
ret.clear();
|
|
390
|
+
ret.et = et;
|
|
391
|
+
return ret;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
inline static HT initFromHWInt(const int et){
|
|
395
|
+
HT ret;
|
|
396
|
+
ret.clear();
|
|
397
|
+
ret.et.V = et;
|
|
398
|
+
return ret;
|
|
399
|
+
}
|
|
400
|
+
}; // struct HT
|
|
401
|
+
|
|
402
|
+
/* ---
|
|
403
|
+
* Vector Sums
|
|
404
|
+
* --- */
|
|
405
|
+
struct VectorSumsCommon{
|
|
406
|
+
ap_ufixed<12,11> et;
|
|
407
|
+
ap_uint<8> phi;
|
|
408
|
+
ap_uint<8> asy;
|
|
409
|
+
ap_uint<4> other;
|
|
410
|
+
|
|
411
|
+
static const int BITWIDTH = 32;
|
|
412
|
+
|
|
413
|
+
inline void clear(){
|
|
414
|
+
et = 0;
|
|
415
|
+
phi = 0;
|
|
416
|
+
asy = 0;
|
|
417
|
+
other = 0;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
inline ap_uint<BITWIDTH> pack() const{
|
|
421
|
+
ap_uint<BITWIDTH> ret;
|
|
422
|
+
unsigned int start = 0;
|
|
423
|
+
pack_into_bits(ret, start, et);
|
|
424
|
+
pack_into_bits(ret, start, phi);
|
|
425
|
+
pack_into_bits(ret, start, asy);
|
|
426
|
+
pack_into_bits(ret, start, other);
|
|
427
|
+
return ret;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
inline void initFromBits(const ap_uint<BITWIDTH> &src){
|
|
431
|
+
unsigned int start = 0;
|
|
432
|
+
unpack_from_bits(src, start, et);
|
|
433
|
+
unpack_from_bits(src, start, phi);
|
|
434
|
+
unpack_from_bits(src, start, asy);
|
|
435
|
+
unpack_from_bits(src, start, other);
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
inline static VectorSumsCommon unpack(const ap_uint<BITWIDTH> &src){
|
|
439
|
+
VectorSumsCommon ret;
|
|
440
|
+
ret.initFromBits(src);
|
|
441
|
+
return ret;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
inline static VectorSumsCommon initFromPhysicalDoubles(const double et, const double phi){
|
|
445
|
+
VectorSumsCommon ret;
|
|
446
|
+
ret.clear();
|
|
447
|
+
ret.et = et;
|
|
448
|
+
ret.phi = round(phi / Scales::CALO_PHI_LSB);
|
|
449
|
+
return ret;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
inline static VectorSumsCommon initFromHWInt(const int et, const int phi){
|
|
453
|
+
VectorSumsCommon ret;
|
|
454
|
+
ret.clear();
|
|
455
|
+
ret.et.V = et;
|
|
456
|
+
ret.phi.V = phi;
|
|
457
|
+
return ret;
|
|
458
|
+
}
|
|
459
|
+
}; // struct VectorSumsCommon
|
|
460
|
+
|
|
461
|
+
typedef VectorSumsCommon ETMiss;
|
|
462
|
+
typedef VectorSumsCommon HTMiss;
|
|
463
|
+
typedef VectorSumsCommon ETHFMiss;
|
|
464
|
+
typedef VectorSumsCommon HTHFMiss;
|
|
465
|
+
|
|
466
|
+
static const int NMUONS = 8;
|
|
467
|
+
static const int NJETS = 12;
|
|
468
|
+
static const int NEGAMMAS = 12;
|
|
469
|
+
static const int NTAUS = 12;
|
|
470
|
+
|
|
471
|
+
/* ---
|
|
472
|
+
* Definitions of common objects used for ML triggers
|
|
473
|
+
* TODO: this is a first implementation, to be improved & expanded
|
|
474
|
+
* TODO: these data types for px, py, pz are not optimized
|
|
475
|
+
* --- */
|
|
476
|
+
typedef ap_fixed<18,13> unscaled_t;
|
|
477
|
+
struct PxPyPz{
|
|
478
|
+
|
|
479
|
+
unscaled_t px;
|
|
480
|
+
unscaled_t py;
|
|
481
|
+
unscaled_t pz;
|
|
482
|
+
|
|
483
|
+
|
|
484
|
+
static const int BITWIDTH = 36;
|
|
485
|
+
|
|
486
|
+
inline void clear(){
|
|
487
|
+
px = 0;
|
|
488
|
+
py = 0;
|
|
489
|
+
pz = 0;
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
inline ap_uint<BITWIDTH> pack() const{
|
|
493
|
+
ap_uint<BITWIDTH> ret;
|
|
494
|
+
unsigned int start = 0;
|
|
495
|
+
pack_into_bits(ret, start, px);
|
|
496
|
+
pack_into_bits(ret, start, py);
|
|
497
|
+
pack_into_bits(ret, start, pz);
|
|
498
|
+
return ret;
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
inline void initFromBits(const ap_uint<BITWIDTH> &src){
|
|
502
|
+
unsigned int start = 0;
|
|
503
|
+
unpack_from_bits(src, start, px);
|
|
504
|
+
unpack_from_bits(src, start, py);
|
|
505
|
+
unpack_from_bits(src, start, pz);
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
inline static PxPyPz unpack(const ap_uint<BITWIDTH> &src){
|
|
509
|
+
PxPyPz ret;
|
|
510
|
+
ret.initFromBits(src);
|
|
511
|
+
return ret;
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
inline static PxPyPz initFromPhysicalDoubles(const double px, const double py, const double pz){
|
|
515
|
+
PxPyPz ret;
|
|
516
|
+
ret.clear();
|
|
517
|
+
ret.px = px;
|
|
518
|
+
ret.py = py;
|
|
519
|
+
ret.pz = pz;
|
|
520
|
+
return ret;
|
|
521
|
+
}
|
|
522
|
+
}; // struct PxPyPz
|
|
523
|
+
|
|
524
|
+
#endif
|
triggerflow/templates/makefile
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
CPP_STANDARD := c++17
|
|
2
2
|
CXXFLAGS := -O3 -fPIC -std=$(CPP_STANDARD)
|
|
3
3
|
PREFIX := .
|
|
4
|
-
EMULATOR_EXTRAS :=
|
|
4
|
+
EMULATOR_EXTRAS := /cvmfs/cms.cern.ch/el8_amd64_gcc11/external/hls4mlEmulatorExtras/1.1.1-6933fcc7cdb4cdd5a649bd6579151d1b/
|
|
5
5
|
AP_TYPES := $(EMULATOR_EXTRAS)/include/ap_types
|
|
6
|
-
HLS_ROOT :=
|
|
6
|
+
HLS_ROOT := /cvmfs/cms.cern.ch/el8_amd64_gcc11/external/hls/2019.08-fd724004387c2a6770dc3517446d30d9
|
|
7
7
|
HLS4ML_INCLUDE := $(EMULATOR_EXTRAS)/include/hls4ml
|
|
8
8
|
INCLUDES := -I$(HLS4ML_INCLUDE) -I$(AP_TYPES) -I$(HLS_ROOT)/include
|
|
9
|
-
LD_FLAGS := -L$(EMULATOR_EXTRAS)/lib64 -lemulator_interface
|
|
9
|
+
LD_FLAGS := -L$(EMULATOR_EXTRAS)/lib64 -lemulator_interface -ldl
|
|
10
10
|
ALL_VERSIONS := {{MODEL_NAME}}/{{MODEL_NAME}}.so
|
|
11
11
|
|
|
12
12
|
.DEFAULT_GOAL := all
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
MODEL_NAME = {{MODEL_NAME}}
|
|
4
4
|
|
|
5
|
-
$(MODEL_NAME).so: $(MODEL_NAME)_project.o
|
|
5
|
+
$(MODEL_NAME).so: $(MODEL_NAME)_project.o emulator.o
|
|
6
6
|
$(CXX) $(CXXFLAGS) $(LD_FLAGS) -shared $^ -o $@
|
|
7
7
|
|
|
8
8
|
%.o: NN/%.cpp
|
|
@@ -12,4 +12,4 @@ $(MODEL_NAME).so: $(MODEL_NAME)_project.o $(MODEL_NAME).o
|
|
|
12
12
|
$(CXX) $(CXXFLAGS) $(INCLUDES) -c $< -o $@
|
|
13
13
|
|
|
14
14
|
clean:
|
|
15
|
-
rm -f $(MODEL_NAME)_project.o
|
|
15
|
+
rm -f $(MODEL_NAME)_project.o emulator.o $(MODEL_NAME).so
|