1 #ifndef L1HPSPFTAUEMULATOR_H 2 #define L1HPSPFTAUEMULATOR_H 54 template <
int W,
int I, ap_q_mode _AP_Q, ap_o_mode _AP_O>
55 ap_ufixed<W, I>
fp_abs(ap_fixed<W, I, _AP_Q, _AP_O> x) {
79 if ((
part.pID == 0) || (
part.pID == 1) || (
part.pID == 4)) {
88 ap_ufixed<16, 14> total_pt = tpt * 4;
89 ap_uint<20> SignalConeSizeSquare;
91 SignalConeSizeSquare = 23 * 23;
92 }
else if (total_pt < 120) {
93 SignalConeSizeSquare = 22 * 22;
94 }
else if (total_pt < 126) {
95 SignalConeSizeSquare = 21 * 21;
96 }
else if (total_pt < 132) {
97 SignalConeSizeSquare = 20 * 20;
98 }
else if (total_pt < 139) {
99 SignalConeSizeSquare = 19 * 19;
100 }
else if (total_pt < 147) {
101 SignalConeSizeSquare = 18 * 18;
102 }
else if (total_pt < 156) {
103 SignalConeSizeSquare = 17 * 17;
104 }
else if (total_pt < 166) {
105 SignalConeSizeSquare = 16 * 16;
106 }
else if (total_pt < 178) {
107 SignalConeSizeSquare = 15 * 15;
108 }
else if (total_pt < 191) {
109 SignalConeSizeSquare = 14 * 14;
110 }
else if (total_pt < 206) {
111 SignalConeSizeSquare = 13 * 13;
112 }
else if (total_pt < 224) {
113 SignalConeSizeSquare = 12 * 12;
115 SignalConeSizeSquare = 12 * 12;
117 return SignalConeSizeSquare;
124 if (
part.hwPt != 0) {
142 bool isPotentialLead =
false;
150 if (
part.hwPt != 0) {
161 if (isPotentialLead) {
166 }
else if (((deltaEta2 + deltaPhi2) < cone2) && !((
part.pID == 0) && (track_count > 3)) &&
168 if (isPotentialLead) {
184 const pt_t total_pt ) {
193 ap_fixed<22, 20> sum_eta = 0;
194 ap_fixed<22, 20> sum_phi = 0;
200 pt_t chargedIsoPileup = 0;
201 std::vector<Particle> signalParts;
202 std::vector<Particle> outsideParts;
206 bool leadSet =
false;
211 signalParts.push_back(
parts.at(
i));
216 if (leadSet ==
false) {
230 outsideParts.push_back(
parts.at(
i));
273 std::vector<Particle> parts_copy;
274 parts_copy.resize(
parts.size());
278 parts_copy.begin(), parts_copy.end(), [](
const Particle&
i,
const Particle&
j) {
return (
i.hwPt >
j.hwPt); });
281 std::vector<Particle> jets_copy;
282 jets_copy.resize(
jets.size());
285 jets_copy.begin(), jets_copy.end(), [](
const Particle&
i,
const Particle&
j) {
return (
i.hwPt >
j.hwPt); });
287 std::vector<Tau>
taus;
288 std::vector<Tau> cleaned_taus;
290 std::vector<Particle> preseed;
291 preseed.reserve(144);
296 int jets_max = jets_copy.size();
298 std::vector<Particle> jseeds;
302 int parts_max = parts_copy.size();
304 while (preseed.size() < 128 && parts_index != parts_max) {
305 Particle pSeed = parts_copy.at(parts_index);
308 preseed.push_back(pSeed);
314 std::vector<Particle>
seeds;
317 while (
seeds.size() < 16 && pseed_index < preseed.size()) {
318 seeds.push_back(preseed.at(pseed_index));
324 while (jseeds.size() < 4 && jets_index != jets_max) {
325 Particle jSeed = jets_copy.at(jets_index);
328 jseeds.push_back(jSeed);
336 std::vector<Particle> iso_parts;
338 iso_parts.reserve(30);
341 while (iso_index < parts_copy.size() && iso_parts.size() < 30) {
342 Particle isoCand = parts_copy.at(iso_index);
344 iso_parts.push_back(isoCand);
345 total_pt += isoCand.
hwPt;
357 std::vector<Particle> iso_parts;
358 iso_parts.reserve(30);
363 while (iso_index < parts_copy.size()) {
364 Particle isoCand = parts_copy.at(iso_index);
371 max_pt_j = isoCand.
hwPt;
374 if (iso_parts.size() < 30) {
375 iso_parts.push_back(isoCand);
376 total_pt += isoCand.
hwPt;
387 int taus_max =
taus.size();
391 for (
int i = 0;
i < (taus_max - 1);
i++) {
392 for (
int j =
i + 1;
j < taus_max;
j++) {
405 cleaned_taus.push_back(
taus.at(0));
410 for (
int i = 0;
i < 20;
i++) {
413 for (
int i = 1;
i < taus_max;
i++) {
414 for (
int j =
i - 1;
j >= 0;
j--) {
418 cleaned_taus.push_back(
taus.at(
i));
Tau makeHPSTauHW(const std::vector< Particle > &parts, const Particle seed, const pt_t total_pt)
bool is_charged(inP part)
const detaphi_t strip_eta
const pt_t min_leadChargedPfCand_pt
const detaphi_t delta_Rclean
const detaphi_t isoConeSize
pt_t makePtFromFloat(float pt)
std::vector< Tau > emulateEvent(std::vector< Particle > &parts, std::vector< Particle > &jets, bool jEnable)
InputIterator leadCand(InputIterator begin, InputIterator end)
static const double deltaEta
ap_uint< W > int_abs(ap_int< W > x)
bool inSignalCone(Particle part, Particle seed, const int track_count, ap_uint< 20 > cone2, pt_t &iso_pt, bool &isLead)
static void clean(char *s)
bool inIsolationCone(Particle part, Particle seed)
const detaphi_t strip_phi
ap_ufixed< 14, 12, AP_TRN, AP_SAT > pt_t
ap_uint< 20 > setSConeSize2(pt_t tpt)
bool inCone(l1t::PFCandidate seed, l1t::PFCandidate part, detaphi_t cone2)
ap_ufixed< W, I > fp_abs(ap_fixed< W, I, _AP_Q, _AP_O > x)
constexpr float etaphi_base