Skip to content

Commit

Permalink
add x.1.2 models and update makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
aloeliger committed Jan 16, 2024
1 parent 56a5d15 commit 2baca92
Show file tree
Hide file tree
Showing 157 changed files with 22,968 additions and 1 deletion.
10 changes: 10 additions & 0 deletions CICADA_v1p1p2/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.PHONY: clean

CICADAModel_v1p1p2.so: cicada.o caloADModel_v1p1p2.o
$(CXX) $(CXXFLAGS) $(LD_FLAGS) -shared $^ -o $@

%.o: %.cpp
$(CXX) $(CXXFLAGS) $(INCLUDES) -c $< -o $@

clean:
rm CICADAModel_v1p1p2.so
115 changes: 115 additions & 0 deletions CICADA_v1p1p2/PU_LUT.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
#include "ap_int.h"
#include "hls_math.h"
#include "PU_LUT.h"

const ap_ufixed<7, 3, AP_RND, AP_SAT> pum_lut[18][26] =
{
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
//pumLUT00
{ 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.33, 0.36, 0.29, 0.32, 0.43, 0.45, 0.32, 0.29, 0.35, 0.31, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25 },
//pumLUT01
{ 0.25, 0.25, 0.25, 0.25, 0.26, 0.26, 0.27, 0.26, 0.39, 0.44, 0.33, 0.39, 0.60, 0.60, 0.39, 0.33, 0.41, 0.35, 0.26, 0.27, 0.26, 0.26, 0.25, 0.25, 0.25, 0.25 },
//pumLUT02
{ 0.25, 0.26, 0.27, 0.29, 0.31, 0.34, 0.41, 0.33, 0.52, 0.57, 0.46, 0.52, 0.76, 0.75, 0.52, 0.46, 0.55, 0.48, 0.34, 0.42, 0.34, 0.31, 0.29, 0.27, 0.26, 0.25 },
//pumLUT03
{ 0.25, 0.27, 0.29, 0.33, 0.37, 0.41, 0.58, 0.39, 0.62, 0.69, 0.56, 0.63, 0.90, 0.90, 0.64, 0.56, 0.66, 0.57, 0.39, 0.58, 0.41, 0.37, 0.33, 0.29, 0.26, 0.25 },
//pumLUT04
{ 0.25, 0.28, 0.32, 0.39, 0.45, 0.50, 0.80, 0.45, 0.72, 0.80, 0.66, 0.74, 1.03, 1.03, 0.76, 0.67, 0.77, 0.67, 0.46, 0.81, 0.50, 0.45, 0.39, 0.32, 0.27, 0.25 },
//pumLUT05
{ 0.26, 0.29, 0.37, 0.47, 0.55, 0.60, 1.09, 0.53, 0.83, 0.92, 0.77, 0.86, 1.17, 1.18, 0.88, 0.77, 0.89, 0.77, 0.54, 1.10, 0.61, 0.55, 0.47, 0.35, 0.29, 0.26 },
//pumLUT06
{ 0.26, 0.31, 0.42, 0.57, 0.66, 0.72, 1.44, 0.61, 0.93, 1.04, 0.88, 0.98, 1.32, 1.32, 1.00, 0.89, 1.01, 0.88, 0.63, 1.46, 0.73, 0.67, 0.57, 0.41, 0.30, 0.26 },
//pumLUT07
{ 0.27, 0.34, 0.50, 0.69, 0.81, 0.86, 1.86, 0.71, 1.05, 1.17, 1.01, 1.11, 1.47, 1.48, 1.14, 1.01, 1.13, 0.99, 0.73, 1.89, 0.87, 0.82, 0.70, 0.47, 0.33, 0.27 },
//pumLUT08
{ 0.28, 0.37, 0.59, 0.85, 0.98, 1.02, 2.37, 0.82, 1.17, 1.30, 1.14, 1.26, 1.63, 1.64, 1.28, 1.15, 1.26, 1.11, 0.85, 2.41, 1.03, 0.99, 0.86, 0.56, 0.36, 0.28 },
//pumLUT09
{ 0.30, 0.42, 0.71, 1.03, 1.18, 1.20, 2.98, 0.95, 1.31, 1.45, 1.28, 1.41, 1.81, 1.82, 1.45, 1.29, 1.41, 1.24, 0.98, 3.02, 1.21, 1.19, 1.05, 0.67, 0.40, 0.29 },
//pumLUT10
{ 0.32, 0.48, 0.87, 1.26, 1.42, 1.41, 3.70, 1.10, 1.45, 1.62, 1.43, 1.58, 2.01, 2.02, 1.61, 1.46, 1.58, 1.38, 1.13, 3.73, 1.42, 1.43, 1.27, 0.82, 0.46, 0.31 },
//pumLUT11
{ 0.36, 0.57, 1.08, 1.55, 1.71, 1.64, 4.55, 1.27, 1.60, 1.78, 1.61, 1.78, 2.24, 2.21, 1.82, 1.63, 1.75, 1.53, 1.31, 4.67, 1.67, 1.71, 1.57, 1.01, 0.54, 0.36 },
//pumLUT12
{ 0.42, 0.68, 1.31, 1.87, 2.01, 1.85, 5.56, 1.56, 1.81, 1.91, 1.82, 2.00, 2.50, 2.44, 2.02, 1.90, 2.01, 1.70, 1.51, 5.61, 1.96, 2.04, 1.80, 1.24, 0.65, 0.43 },
//pumLUT13
{ 0.59, 0.90, 1.67, 2.17, 2.43, 2.41, 8.05, 1.76, 2.01, 2.41, 2.14, 2.40, 2.96, 3.28, 2.64, 2.26, 2.23, 1.97, 1.89, 7.61, 2.27, 2.33, 2.26, 1.44, 0.79, 0.52 },
//pumLUT14
{ 0.59, 0.90, 1.67, 2.17, 2.43, 2.41, 8.05, 1.76, 2.01, 2.41, 2.14, 2.40, 2.96, 3.28, 2.64, 2.26, 2.23, 1.97, 1.89, 7.61, 2.27, 2.33, 2.26, 1.44, 0.79, 0.52 },
//pumLUT15
{ 0.59, 0.90, 1.67, 2.17, 2.43, 2.41, 8.05, 1.76, 2.01, 2.41, 2.14, 2.40, 2.96, 3.28, 2.64, 2.26, 2.23, 1.97, 1.89, 7.61, 2.27, 2.33, 2.26, 1.44, 0.79, 0.52 },
//pumLUT16
{ 0.59, 0.90, 1.67, 2.17, 2.43, 2.41, 8.05, 1.76, 2.01, 2.41, 2.14, 2.40, 2.96, 3.28, 2.64, 2.26, 2.23, 1.97, 1.89, 7.61, 2.27, 2.33, 2.26, 1.44, 0.79, 0.52 },
//pumLUT17
{ 0.59, 0.90, 1.67, 2.17, 2.43, 2.41, 8.05, 1.76, 2.01, 2.41, 2.14, 2.40, 2.96, 3.28, 2.64, 2.26, 2.23, 1.97, 1.89, 7.61, 2.27, 2.33, 2.26, 1.44, 0.79, 0.52 },

};

const float pum_lut_cntr[18][14] =
{
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13
{ 0.25, 0.25, 0.33, 0.36, 0.29, 0.32, 0.43, 0.45, 0.32, 0.29, 0.35, 0.31, 0.25, 0.25 },
{ 0.27, 0.26, 0.39, 0.44, 0.33, 0.39, 0.60, 0.60, 0.39, 0.33, 0.41, 0.35, 0.26, 0.27 },
{ 0.41, 0.33, 0.52, 0.57, 0.46, 0.52, 0.76, 0.75, 0.52, 0.46, 0.55, 0.48, 0.34, 0.42 },
{ 0.58, 0.39, 0.62, 0.69, 0.56, 0.63, 0.90, 0.90, 0.64, 0.56, 0.66, 0.57, 0.39, 0.58 },
{ 0.80, 0.45, 0.72, 0.80, 0.66, 0.74, 1.03, 1.03, 0.76, 0.67, 0.77, 0.67, 0.46, 0.81 },
{ 1.09, 0.53, 0.83, 0.92, 0.77, 0.86, 1.17, 1.18, 0.88, 0.77, 0.89, 0.77, 0.54, 1.10 },
{ 1.44, 0.61, 0.93, 1.04, 0.88, 0.98, 1.32, 1.32, 1.00, 0.89, 1.01, 0.88, 0.63, 1.46 },
{ 1.86, 0.71, 1.05, 1.17, 1.01, 1.11, 1.47, 1.48, 1.14, 1.01, 1.13, 0.99, 0.73, 1.89 },
{ 2.37, 0.82, 1.17, 1.30, 1.14, 1.26, 1.63, 1.64, 1.28, 1.15, 1.26, 1.11, 0.85, 2.41 },
{ 2.98, 0.95, 1.31, 1.45, 1.28, 1.41, 1.81, 1.82, 1.45, 1.29, 1.41, 1.24, 0.98, 3.02 },
{ 3.70, 1.10, 1.45, 1.62, 1.43, 1.58, 2.01, 2.02, 1.61, 1.46, 1.58, 1.38, 1.13, 3.73 },
{ 4.55, 1.27, 1.60, 1.78, 1.61, 1.78, 2.24, 2.21, 1.82, 1.63, 1.75, 1.53, 1.31, 4.67 },
{ 5.56, 1.56, 1.81, 1.91, 1.82, 2.00, 2.50, 2.44, 2.02, 1.90, 2.01, 1.70, 1.51, 5.61 },
{ 8.05, 1.76, 2.01, 2.41, 2.14, 2.40, 2.96, 3.28, 2.64, 2.26, 2.23, 1.97, 1.89, 7.61 },
{ 8.05, 1.76, 2.01, 2.41, 2.14, 2.40, 2.96, 3.28, 2.64, 2.26, 2.23, 1.97, 1.89, 7.61 },
{ 8.05, 1.76, 2.01, 2.41, 2.14, 2.40, 2.96, 3.28, 2.64, 2.26, 2.23, 1.97, 1.89, 7.61 },
{ 8.05, 1.76, 2.01, 2.41, 2.14, 2.40, 2.96, 3.28, 2.64, 2.26, 2.23, 1.97, 1.89, 7.61 },
{ 8.05, 1.76, 2.01, 2.41, 2.14, 2.40, 2.96, 3.28, 2.64, 2.26, 2.23, 1.97, 1.89, 7.61 },

};

void pu_lut(ap_uint<5> pum_bin, ap_uint<10> et[NR_CALO_REG],
ap_uint<10> pu_sub_et[NR_CALO_REG])
{
#pragma HLS ARRAY_RESHAPE variable=et complete dim=1
#pragma HLS ARRAY_RESHAPE variable=pu_sub_et complete dim=1

ap_uint<10> et_tmp, et_pu_min, pu_tmp;

pu_lut_loop: for (int idx = 0; idx < NR_CALO_REG; idx++)
{
#pragma HLS UNROLL
et_tmp = et[idx];

pu_tmp = pum_lut[pum_bin][idx % 26];

if (et_tmp >= pu_tmp)
pu_sub_et[idx] = et_tmp - pu_tmp;
else
pu_sub_et[idx] = 0;
}
return;
}

void pu_lut_cntr(ap_uint<5> pum_bin, ap_uint<10> et[NR_CNTR_REG],
ap_uint<10> pu_sub_et[NR_CNTR_REG])
{
#pragma HLS ARRAY_RESHAPE variable=et complete dim=1
#pragma HLS ARRAY_RESHAPE variable=pu_sub_et complete dim=1

ap_uint<10> et_tmp, et_pu_min, pu_tmp;

pu_lut_centr_loop: for (int idx = 0; idx < NR_CNTR_REG; idx++)
{
#pragma HLS UNROLL
et_tmp = et[idx];

pu_tmp = round(pum_lut_cntr[pum_bin][idx % 14]/0.5); // add caloScaleFactor; add round;

if (et_tmp >= pu_tmp)
pu_sub_et[idx] = et_tmp - pu_tmp;
else
pu_sub_et[idx] = 0;
}
return;
}
12 changes: 12 additions & 0 deletions CICADA_v1p1p2/PU_LUT.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#ifndef PU_LUT_H
#define PU_LUT_H

#include "UCTSummaryCard.hpp"

void pu_lut(ap_uint<5> pum_bin, ap_uint<10> et[NR_CALO_REG],
ap_uint<10> pu_sub_et[NR_CALO_REG]);

void pu_lut_cntr(ap_uint<5> pum_bin, ap_uint<10> et[NR_CNTR_REG],
ap_uint<10> pu_sub_et[NR_CNTR_REG]);

#endif
53 changes: 53 additions & 0 deletions CICADA_v1p1p2/UCTSummaryCard.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#ifndef UCT_SUMMARY_CARD_H_
#define UCT_SUMMARY_CARD_H_

#include <stdint.h>
#include <ap_int.h>
#include <bitset>

using std::bitset;

// Number of central regions
#define NR_CNTR_REG (252)
// Number of forward regions
#define NR_FWD_REG (216)
// Number of calorimeter regions (central + forward)
#define NR_CALO_REG (NR_CNTR_REG + NR_FWD_REG)
// Number of central super-regions (2x2)
#define NR_SCNTR_REG (63)

#define PUM_LEVEL_BITSIZE (9)

typedef struct
{
ap_uint<10> pum_thr;
ap_uint<10> jet_seed;

ap_uint<10> egamma_seed;
ap_ufixed<7, 1, AP_RND, AP_SAT> egamma_IsoFact;

ap_uint<10> tau_seed;
ap_ufixed<7, 1, AP_RND, AP_SAT> tau_IsoFact;

} algo_config_t;

typedef struct
{
ap_uint<10> et;
bool eg_veto;
bool tau_veto;
ap_uint<2> rloc_phi;
ap_uint<2> rloc_eta;
} region_t;

ap_uint<8> popcount(ap_uint<NR_CNTR_REG> bitString);

void et_3by3(ap_uint<10> et[NR_CNTR_REG], ap_uint<10> et_3by3[NR_CNTR_REG]);

void boostedjet(ap_uint<10> jet_seed,
region_t regions[NR_CNTR_REG],
ap_uint<10> et_3by3[NR_CNTR_REG],
ap_uint<10> jet_et[NR_SCNTR_REG],
ap_uint<9> rIdx_boostedjet[NR_SCNTR_REG]);

#endif
Loading

0 comments on commit 2baca92

Please sign in to comment.