Skip to content

Commit fdd1d13

Browse files
author
Benjamin Huber
committed
L1GT3BodyCut: Improve readability of dynamic resolution reduction
Also use `floor` +1 instead to get the bit beyond the most significant set bit
1 parent f4be974 commit fdd1d13

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

L1Trigger/Phase2L1GT/plugins/L1GT3BodyCut.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,19 +51,23 @@ namespace l1t {
5151
})),
5252
scaleNormalShift_(std::round(std::log2(std::ceil(coshEtaLUT_.output_scale() / coshEtaLUT2_.output_scale())))),
5353
invMassResolutionReduceShift_([&]() {
54+
// Computation of the dynamic input two-body mass resolution w.r.t. the cut value.
55+
// The result is a resolution of inputs between 2^-15 to 2^-16 of the cut value.
5456
if (minInvMassSqrDiv2_) {
55-
return std::max<int>(std::ceil(std::log2(minInvMassSqrDiv2_.value() + 1.0)) - 16, 0);
57+
return std::max<int>(std::floor(std::log2(minInvMassSqrDiv2_.value())) + 1 - CALC_BITS, 0);
5658
} else if (maxInvMassSqrDiv2_) {
57-
return std::max<int>(std::ceil(std::log2(maxInvMassSqrDiv2_.value())) - 16, 0);
59+
return std::max<int>(std::floor(std::log2(maxInvMassSqrDiv2_.value())) + 1 - CALC_BITS, 0);
5860
} else {
5961
return 0;
6062
}
6163
}()),
6264
transMassResolutionReduceShift_([&]() {
65+
// Computation of the dynamic input two-body mass resolution w.r.t. the cut value.
66+
// The result is a resolution of inputs between 2^-15 to 2^-16 of the cut value.
6367
if (minTransMassSqrDiv2_) {
64-
return std::max<int>(std::ceil(std::log2(minTransMassSqrDiv2_.value() + 1.0)) - 16, 0);
68+
return std::max<int>(std::floor(std::log2(minTransMassSqrDiv2_.value())) + 1 - CALC_BITS, 0);
6569
} else if (maxTransMassSqrDiv2_) {
66-
return std::max<int>(std::ceil(std::log2(maxTransMassSqrDiv2_.value())) - 16, 0);
70+
return std::max<int>(std::floor(std::log2(maxTransMassSqrDiv2_.value())) + 1 - CALC_BITS, 0);
6771
} else {
6872
return 0;
6973
}
@@ -108,6 +112,7 @@ namespace l1t {
108112

109113
private:
110114
static constexpr int HW_PI = 1 << (P2GTCandidate::hwPhi_t::width - 1); // assumes phi in [-pi, pi)
115+
static constexpr int CALC_BITS = 16; // Allocate 16 bits to the calculation
111116

112117
int64_t calc2BodyInvMass(const P2GTCandidate& obj1,
113118
const P2GTCandidate& obj2,

0 commit comments

Comments
 (0)