CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
l1t::L1GT3BodyCut Class Reference

#include <L1GT3BodyCut.h>

Public Member Functions

bool checkObjects (const P2GTCandidate &obj1, const P2GTCandidate &obj2, const P2GTCandidate &obj3, InvariantMassErrorCollection &massErrors) const
 
 L1GT3BodyCut (const edm::ParameterSet &config, const edm::ParameterSet &lutConfig, const L1GTScales &scales, bool inv_mass_checks=false)
 

Static Public Member Functions

static void fillPSetDescription (edm::ParameterSetDescription &desc)
 

Private Member Functions

int64_t calc2BodyInvMass (const P2GTCandidate &obj1, const P2GTCandidate &obj2, InvariantMassErrorCollection &massErrors) const
 
int64_t calc2BodyTransMass (const P2GTCandidate &obj1, const P2GTCandidate &obj2) const
 

Private Attributes

const L1GTSingleInOutLUT coshEtaLUT2_
 
const L1GTSingleInOutLUT coshEtaLUT_
 
const L1GTSingleInOutLUT cosPhiLUT_
 
const bool inv_mass_checks_
 
const int invMassResolutionReduceShift_
 
const std::optional< int64_t > maxInvMassSqrDiv2_
 
const std::optional< int64_t > maxTransMassSqrDiv2_
 
const std::optional< int64_t > minInvMassSqrDiv2_
 
const std::optional< int64_t > minTransMassSqrDiv2_
 
const int scaleNormalShift_
 
const L1GTScalesscales_
 
const int transMassResolutionReduceShift_
 

Static Private Attributes

static constexpr int HW_PI = 1 << (P2GTCandidate::hwPhi_t::width - 1)
 

Detailed Description

Definition at line 20 of file L1GT3BodyCut.h.

Constructor & Destructor Documentation

◆ L1GT3BodyCut()

l1t::L1GT3BodyCut::L1GT3BodyCut ( const edm::ParameterSet config,
const edm::ParameterSet lutConfig,
const L1GTScales scales,
bool  inv_mass_checks = false 
)
inline

Definition at line 22 of file L1GT3BodyCut.h.

References cosPhiLUT_, l1t::L1GTSingleInOutLUT::output_scale(), and l1tGTDoubleObjectCond_cfi::scales.

26  : scales_(scales),
27  coshEtaLUT_(lutConfig.getParameterSet("cosh_eta_lut")),
28  coshEtaLUT2_(lutConfig.getParameterSet("cosh_eta_lut2")),
29  cosPhiLUT_(lutConfig.getParameterSet("cos_phi_lut")),
30  minInvMassSqrDiv2_(getOptionalParam<int64_t, double>("minInvMass",
31  config,
32  [&](double value) {
33  return std::round(scales.to_hw_InvMassSqrDiv2(value) *
35  })),
36  maxInvMassSqrDiv2_(getOptionalParam<int64_t, double>("maxInvMass",
37  config,
38  [&](double value) {
39  return std::round(scales.to_hw_InvMassSqrDiv2(value) *
41  })),
42  minTransMassSqrDiv2_(getOptionalParam<int64_t, double>(
43  "minTransMass",
44  config,
45  [&](double value) {
46  return std::round(scales.to_hw_TransMassSqrDiv2(value) * cosPhiLUT_.output_scale());
47  })),
48  maxTransMassSqrDiv2_(getOptionalParam<int64_t, double>(
49  "maxTransMass",
50  config,
51  [&](double value) {
52  return std::round(scales.to_hw_TransMassSqrDiv2(value) * cosPhiLUT_.output_scale());
53  })),
56  if (minInvMassSqrDiv2_) {
57  return std::max<int>(
58  std::ceil(std::log2(minInvMassSqrDiv2_.value() * cosPhiLUT_.output_scale() + 1.0)) - 16, 0);
59  } else if (maxInvMassSqrDiv2_) {
60  return std::max<int>(std::ceil(std::log2(maxInvMassSqrDiv2_.value() * cosPhiLUT_.output_scale())) - 16,
61  0);
62  } else {
63  return 0;
64  }
65  }()),
68  return std::max<int>(
69  std::ceil(std::log2(minTransMassSqrDiv2_.value() * cosPhiLUT_.output_scale() + 1.0)) - 16, 0);
70  } else if (maxTransMassSqrDiv2_) {
71  return std::max<int>(std::ceil(std::log2(maxTransMassSqrDiv2_.value() * cosPhiLUT_.output_scale())) - 16,
72  0);
73  } else {
74  return 0;
75  }
76  }()),
const L1GTSingleInOutLUT cosPhiLUT_
Definition: L1GT3BodyCut.h:176
constexpr int32_t ceil(float num)
const L1GTSingleInOutLUT coshEtaLUT2_
Definition: L1GT3BodyCut.h:175
const std::optional< int64_t > maxInvMassSqrDiv2_
Definition: L1GT3BodyCut.h:179
ParameterSet const & getParameterSet(std::string const &) const
const int transMassResolutionReduceShift_
Definition: L1GT3BodyCut.h:185
Definition: config.py:1
const bool inv_mass_checks_
Definition: L1GT3BodyCut.h:187
const std::optional< int64_t > minInvMassSqrDiv2_
Definition: L1GT3BodyCut.h:178
const std::optional< int64_t > minTransMassSqrDiv2_
Definition: L1GT3BodyCut.h:180
Definition: value.py:1
const L1GTScales & scales_
Definition: L1GT3BodyCut.h:172
const std::optional< int64_t > maxTransMassSqrDiv2_
Definition: L1GT3BodyCut.h:181
const int scaleNormalShift_
Definition: L1GT3BodyCut.h:183
const int invMassResolutionReduceShift_
Definition: L1GT3BodyCut.h:184
const L1GTSingleInOutLUT coshEtaLUT_
Definition: L1GT3BodyCut.h:174

Member Function Documentation

◆ calc2BodyInvMass()

int64_t l1t::L1GT3BodyCut::calc2BodyInvMass ( const P2GTCandidate obj1,
const P2GTCandidate obj2,
InvariantMassErrorCollection massErrors 
) const
inlineprivate

Definition at line 118 of file L1GT3BodyCut.h.

References funct::abs(), funct::cos(), coshEtaLUT2_, coshEtaLUT_, cosPhiLUT_, HLT_2024v14_cff::dEta, l1t::L1GTSingleInOutLUT::DETA_LUT_SPLIT, relativeConstraints::error, l1t::L1GTScales::eta_lsb(), HW_PI, l1t::P2GTCandidate::hwEta(), l1t::P2GTCandidate::hwPhi(), l1t::P2GTCandidate::hwPT(), inv_mass_checks_, l1t::L1GTSingleInOutLUT::output_scale(), l1t::L1GTScales::phi_lsb(), l1t::L1GTScales::pT_lsb(), scaleNormalShift_, scales_, and mathSSE::sqrt().

Referenced by checkObjects().

120  {
121  uint32_t dEta = (obj1.hwEta() > obj2.hwEta()) ? obj1.hwEta().to_int() - obj2.hwEta().to_int()
122  : obj2.hwEta().to_int() - obj1.hwEta().to_int();
123  int32_t lutCoshDEta = dEta < L1GTSingleInOutLUT::DETA_LUT_SPLIT
124  ? coshEtaLUT_[dEta]
126 
127  // Ensure dPhi is always the smaller angle, i.e. always between [0, pi]
128  uint32_t dPhi = HW_PI - abs(abs(obj1.hwPhi().to_int() - obj2.hwPhi().to_int()) - HW_PI);
129 
130  // Optimization: (cos(x + pi) = -cos(x), x in [0, pi))
131  int32_t lutCosDPhi = dPhi >= HW_PI ? -cosPhiLUT_[dPhi] : cosPhiLUT_[dPhi];
132 
133  int64_t invMassSqrDiv2;
134 
136  // dEta [0, 2pi)
137  invMassSqrDiv2 = obj1.hwPT().to_int64() * obj2.hwPT().to_int64() * (lutCoshDEta - lutCosDPhi);
138  } else {
139  // dEta [2pi, 4pi), ignore cos
140  invMassSqrDiv2 = obj1.hwPT().to_int64() * obj2.hwPT().to_int64() * lutCoshDEta;
141  }
142 
143  if (inv_mass_checks_) {
144  double precInvMass =
145  scales_.pT_lsb() * std::sqrt(2 * obj1.hwPT().to_double() * obj2.hwPT().to_double() *
146  (std::cosh(dEta * scales_.eta_lsb()) - std::cos(dPhi * scales_.phi_lsb())));
147 
148  double lutInvMass =
149  scales_.pT_lsb() * std::sqrt(2 * static_cast<double>(invMassSqrDiv2) /
152 
153  double error = std::abs(precInvMass - lutInvMass);
154  massErrors.emplace_back(InvariantMassError{error, error / precInvMass, precInvMass});
155  }
156 
157  // Normalize scales required due to LUT split in dEta with different scale factors.
158  return dEta < L1GTSingleInOutLUT::DETA_LUT_SPLIT ? invMassSqrDiv2 : invMassSqrDiv2 << scaleNormalShift_;
159  }
const L1GTSingleInOutLUT cosPhiLUT_
Definition: L1GT3BodyCut.h:176
double eta_lsb() const
Definition: L1GTScales.h:91
const L1GTSingleInOutLUT coshEtaLUT2_
Definition: L1GT3BodyCut.h:175
double pT_lsb() const
Definition: L1GTScales.h:89
double phi_lsb() const
Definition: L1GTScales.h:90
const bool inv_mass_checks_
Definition: L1GT3BodyCut.h:187
T sqrt(T t)
Definition: SSEVec.h:23
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const L1GTScales & scales_
Definition: L1GT3BodyCut.h:172
static constexpr int HW_PI
Definition: L1GT3BodyCut.h:116
static constexpr uint32_t DETA_LUT_SPLIT
const int scaleNormalShift_
Definition: L1GT3BodyCut.h:183
const L1GTSingleInOutLUT coshEtaLUT_
Definition: L1GT3BodyCut.h:174

◆ calc2BodyTransMass()

int64_t l1t::L1GT3BodyCut::calc2BodyTransMass ( const P2GTCandidate obj1,
const P2GTCandidate obj2 
) const
inlineprivate

Definition at line 161 of file L1GT3BodyCut.h.

References funct::abs(), cosPhiLUT_, HW_PI, l1t::P2GTCandidate::hwPhi(), l1t::P2GTCandidate::hwPT(), and l1t::L1GTSingleInOutLUT::output_scale().

Referenced by checkObjects().

161  {
162  // Ensure dPhi is always the smaller angle, i.e. always between [0, pi]
163  uint32_t dPhi = HW_PI - abs(abs(obj1.hwPhi().to_int() - obj2.hwPhi().to_int()) - HW_PI);
164 
165  // Optimization: (cos(x + pi) = -cos(x), x in [0, pi))
166  int32_t lutCosDPhi = dPhi >= HW_PI ? -cosPhiLUT_[dPhi] : cosPhiLUT_[dPhi];
167 
168  return obj1.hwPT().to_int64() * obj2.hwPT().to_int64() *
169  (static_cast<int64_t>(std::round(cosPhiLUT_.output_scale())) - lutCosDPhi);
170  }
const L1GTSingleInOutLUT cosPhiLUT_
Definition: L1GT3BodyCut.h:176
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
static constexpr int HW_PI
Definition: L1GT3BodyCut.h:116

◆ checkObjects()

bool l1t::L1GT3BodyCut::checkObjects ( const P2GTCandidate obj1,
const P2GTCandidate obj2,
const P2GTCandidate obj3,
InvariantMassErrorCollection massErrors 
) const
inline

Definition at line 79 of file L1GT3BodyCut.h.

References calc2BodyInvMass(), calc2BodyTransMass(), invMassResolutionReduceShift_, maxInvMassSqrDiv2_, maxTransMassSqrDiv2_, minInvMassSqrDiv2_, minTransMassSqrDiv2_, and transMassResolutionReduceShift_.

Referenced by L1GTTripleObjectCond::filter(), and L1GTQuadObjectCond::filter().

82  {
83  bool res = true;
84 
86  int64_t invMassSqrDiv2 = (calc2BodyInvMass(obj1, obj2, massErrors) >> invMassResolutionReduceShift_) +
87  (calc2BodyInvMass(obj1, obj3, massErrors) >> invMassResolutionReduceShift_) +
88  (calc2BodyInvMass(obj2, obj3, massErrors) >> invMassResolutionReduceShift_);
89 
90  res &= minInvMassSqrDiv2_ ? invMassSqrDiv2 > minInvMassSqrDiv2_.value() >> invMassResolutionReduceShift_ : true;
91  res &= maxInvMassSqrDiv2_ ? invMassSqrDiv2 < maxInvMassSqrDiv2_.value() >> invMassResolutionReduceShift_ : true;
92  }
93 
95  int64_t transMassDiv2 = (calc2BodyTransMass(obj1, obj2) >> transMassResolutionReduceShift_) +
98 
100  : true;
102  : true;
103  }
104 
105  return res;
106  }
const std::optional< int64_t > maxInvMassSqrDiv2_
Definition: L1GT3BodyCut.h:179
const int transMassResolutionReduceShift_
Definition: L1GT3BodyCut.h:185
Definition: Electron.h:6
int64_t calc2BodyInvMass(const P2GTCandidate &obj1, const P2GTCandidate &obj2, InvariantMassErrorCollection &massErrors) const
Definition: L1GT3BodyCut.h:118
const std::optional< int64_t > minInvMassSqrDiv2_
Definition: L1GT3BodyCut.h:178
const std::optional< int64_t > minTransMassSqrDiv2_
Definition: L1GT3BodyCut.h:180
const std::optional< int64_t > maxTransMassSqrDiv2_
Definition: L1GT3BodyCut.h:181
int64_t calc2BodyTransMass(const P2GTCandidate &obj1, const P2GTCandidate &obj2) const
Definition: L1GT3BodyCut.h:161
const int invMassResolutionReduceShift_
Definition: L1GT3BodyCut.h:184

◆ fillPSetDescription()

static void l1t::L1GT3BodyCut::fillPSetDescription ( edm::ParameterSetDescription desc)
inlinestatic

Definition at line 108 of file L1GT3BodyCut.h.

References submitPVResolutionJobs::desc.

108  {
109  desc.addOptional<double>("minInvMass");
110  desc.addOptional<double>("maxInvMass");
111  desc.addOptional<double>("minTransMass");
112  desc.addOptional<double>("maxTransMass");
113  }

Member Data Documentation

◆ coshEtaLUT2_

const L1GTSingleInOutLUT l1t::L1GT3BodyCut::coshEtaLUT2_
private

Definition at line 175 of file L1GT3BodyCut.h.

Referenced by calc2BodyInvMass().

◆ coshEtaLUT_

const L1GTSingleInOutLUT l1t::L1GT3BodyCut::coshEtaLUT_
private

Definition at line 174 of file L1GT3BodyCut.h.

Referenced by calc2BodyInvMass().

◆ cosPhiLUT_

const L1GTSingleInOutLUT l1t::L1GT3BodyCut::cosPhiLUT_
private

Definition at line 176 of file L1GT3BodyCut.h.

Referenced by calc2BodyInvMass(), calc2BodyTransMass(), and L1GT3BodyCut().

◆ HW_PI

constexpr int l1t::L1GT3BodyCut::HW_PI = 1 << (P2GTCandidate::hwPhi_t::width - 1)
staticprivate

Definition at line 116 of file L1GT3BodyCut.h.

Referenced by calc2BodyInvMass(), and calc2BodyTransMass().

◆ inv_mass_checks_

const bool l1t::L1GT3BodyCut::inv_mass_checks_
private

Definition at line 187 of file L1GT3BodyCut.h.

Referenced by calc2BodyInvMass().

◆ invMassResolutionReduceShift_

const int l1t::L1GT3BodyCut::invMassResolutionReduceShift_
private

Definition at line 184 of file L1GT3BodyCut.h.

Referenced by checkObjects().

◆ maxInvMassSqrDiv2_

const std::optional<int64_t> l1t::L1GT3BodyCut::maxInvMassSqrDiv2_
private

Definition at line 179 of file L1GT3BodyCut.h.

Referenced by checkObjects().

◆ maxTransMassSqrDiv2_

const std::optional<int64_t> l1t::L1GT3BodyCut::maxTransMassSqrDiv2_
private

Definition at line 181 of file L1GT3BodyCut.h.

Referenced by checkObjects().

◆ minInvMassSqrDiv2_

const std::optional<int64_t> l1t::L1GT3BodyCut::minInvMassSqrDiv2_
private

Definition at line 178 of file L1GT3BodyCut.h.

Referenced by checkObjects().

◆ minTransMassSqrDiv2_

const std::optional<int64_t> l1t::L1GT3BodyCut::minTransMassSqrDiv2_
private

Definition at line 180 of file L1GT3BodyCut.h.

Referenced by checkObjects().

◆ scaleNormalShift_

const int l1t::L1GT3BodyCut::scaleNormalShift_
private

Definition at line 183 of file L1GT3BodyCut.h.

Referenced by calc2BodyInvMass().

◆ scales_

const L1GTScales& l1t::L1GT3BodyCut::scales_
private

Definition at line 172 of file L1GT3BodyCut.h.

Referenced by calc2BodyInvMass().

◆ transMassResolutionReduceShift_

const int l1t::L1GT3BodyCut::transMassResolutionReduceShift_
private

Definition at line 185 of file L1GT3BodyCut.h.

Referenced by checkObjects().