CMS 3D CMS Logo

L1GTSingleCollectionCut.h
Go to the documentation of this file.
1 #ifndef L1Trigger_Phase2L1GT_L1GTSingleCollectionCut_h
2 #define L1Trigger_Phase2L1GT_L1GTSingleCollectionCut_h
3 
7 
9 
10 #include "L1GTOptionalParam.h"
11 
12 #include <functional>
13 #include <optional>
14 
15 namespace l1t {
16 
17  template <typename T, typename K>
18  inline std::vector<T> getParamVector(const std::string& name,
20  std::function<T(K)> conv) {
21  const std::vector<K>& values = config.getParameter<std::vector<K>>(name);
22  std::vector<T> convertedValues(values.size());
23  for (std::size_t i = 0; i < values.size(); i++) {
24  convertedValues[i] = conv(values[i]);
25  }
26  return convertedValues;
27  }
28 
30  public:
32  const edm::ParameterSet& lutConfig,
33  const L1GTScales& scales)
34  : scales_(scales),
35  tag_(config.getParameter<edm::InputTag>("tag")),
36  minPt_(getOptionalParam<int, double>(
37  "minPt", config, [&scales](double value) { return scales.to_hw_pT(value); })),
38  maxPt_(getOptionalParam<int, double>(
39  "maxPt", config, [&scales](double value) { return scales.to_hw_pT(value); })),
40  minEta_(getOptionalParam<int, double>(
41  "minEta", config, [&scales](double value) { return scales.to_hw_eta(value); })),
42  maxEta_(getOptionalParam<int, double>(
43  "maxEta", config, [&scales](double value) { return scales.to_hw_eta(value); })),
44  minPhi_(getOptionalParam<int, double>(
45  "minPhi", config, [&scales](double value) { return scales.to_hw_phi(value); })),
46  maxPhi_(getOptionalParam<int, double>(
47  "maxPhi", config, [&scales](double value) { return scales.to_hw_phi(value); })),
48  minZ0_(getOptionalParam<int, double>(
49  "minZ0", config, [&scales](double value) { return scales.to_hw_z0(value); })),
50  maxZ0_(getOptionalParam<int, double>(
51  "maxZ0", config, [&scales](double value) { return scales.to_hw_z0(value); })),
52  minScalarSumPt_(getOptionalParam<int, double>(
53  "minScalarSumPt", config, [&scales](double value) { return scales.to_hw_pT(value); })),
54  maxScalarSumPt_(getOptionalParam<int, double>(
55  "maxScalarSumPt", config, [&scales](double value) { return scales.to_hw_pT(value); })),
56  qual_(config.getParameter<std::vector<unsigned int>>("qual")),
57  minAbsEta_(getOptionalParam<int, double>(
58  "minAbsEta", config, [&scales](double value) { return scales.to_hw_eta(value); })),
59  maxAbsEta_(getOptionalParam<int, double>(
60  "maxAbsEta", config, [&scales](double value) { return scales.to_hw_eta(value); })),
61  maxIso_(getOptionalParam<int, double>(
62  "maxIso", config, [&scales](double value) { return scales.to_hw_isolation(value); })),
63  minHwIso_(getOptionalParam<int>("minHwIso", config)),
64  regionsAbsEtaLowerBounds_(getParamVector<int, double>(
65  "regionsAbsEtaLowerBounds", config, [&scales](double value) { return scales.to_hw_eta(value); })),
66  regionsMinPt_(getParamVector<int, double>(
67  "regionsMinPt", config, [&scales](double value) { return scales.to_hw_pT(value); })),
68  regionsMaxIso_(getParamVector<int, double>(
69  "regionsMaxIso", config, [&scales](double value) { return scales.to_hw_isolation(value); })),
70  regionsQual_(config.getParameter<std::vector<unsigned int>>("regionsQual")) {}
71 
73  bool res = true;
74 
75  unsigned int index;
76  index = atIndex(obj.hwEta());
77  res &= regionsMinPt_.empty() ? true : obj.hwPT() > regionsMinPt_[index];
78  res &= regionsMaxIso_.empty()
79  ? true
80  : obj.hwIso().to_int() << scales_.isolation_shift() < regionsMaxIso_[index] * obj.hwPT().to_int();
81  res &= regionsQual_.empty() ? true : (obj.hwQual().to_uint() & regionsQual_[index]) == regionsQual_[index];
82  return res;
83  }
84 
85  unsigned int atIndex(int objeta) const {
86  // Function that checks at which index the eta of the object is
87  // If object abs(eta) < regionsAbsEtaLowerBounds_[0] the function returns the last index,
88  // Might be undesired behaviour
89  for (unsigned int i = 0; i < regionsAbsEtaLowerBounds_.size() - 1; i++) {
90  if (std::abs(objeta) >= regionsAbsEtaLowerBounds_[i] && std::abs(objeta) < regionsAbsEtaLowerBounds_[i + 1]) {
91  return i;
92  }
93  }
94  return regionsAbsEtaLowerBounds_.size() - 1;
95  }
96 
97  bool checkObject(const P2GTCandidate& obj) const {
98  bool result = true;
99 
100  result &= minPt_ ? (obj.hwPT() > minPt_) : true;
101  result &= maxPt_ ? (obj.hwPT() < maxPt_) : true;
102 
103  result &= minEta_ ? (obj.hwEta() > minEta_) : true;
104  result &= maxEta_ ? (obj.hwEta() < maxEta_) : true;
105 
106  result &= minPhi_ ? (obj.hwPhi() > minPhi_) : true;
107  result &= maxPhi_ ? (obj.hwPhi() < maxPhi_) : true;
108 
109  result &= minZ0_ ? (obj.hwZ0() > minZ0_) : true;
110  result &= maxZ0_ ? (obj.hwZ0() < maxZ0_) : true;
111 
112  result &= minAbsEta_ ? (abs(obj.hwEta()) > minAbsEta_) : true;
113  result &= maxAbsEta_ ? (abs(obj.hwEta()) < maxAbsEta_) : true;
114 
115  result &= minScalarSumPt_ ? (obj.hwSca_sum() > minScalarSumPt_) : true;
116  result &= maxScalarSumPt_ ? (obj.hwSca_sum() < minScalarSumPt_) : true;
117 
118  result &= qual_.empty() ? true : std::find(qual_.begin(), qual_.end(), obj.hwQual().to_uint()) != qual_.end();
119  result &=
120  maxIso_ ? obj.hwIso().to_int() << scales_.isolation_shift() < maxIso_.value() * obj.hwPT().to_int() : true;
121 
122  result &= minHwIso_ ? (obj.hwIso() > minHwIso_) : true;
124  return result;
125  }
126 
128  desc.add<edm::InputTag>("tag");
129  desc.addOptional<double>("minPt");
130  desc.addOptional<double>("maxPt");
131  desc.addOptional<double>("minEta");
132  desc.addOptional<double>("maxEta");
133  desc.addOptional<double>("minPhi");
134  desc.addOptional<double>("maxPhi");
135  desc.addOptional<double>("minZ0");
136  desc.addOptional<double>("maxZ0");
137  desc.addOptional<double>("minScalarSumPt");
138  desc.addOptional<double>("maxScalarSumPt");
139  desc.add<std::vector<unsigned int>>("qual", {});
140  desc.addOptional<double>("minAbsEta");
141  desc.addOptional<double>("maxAbsEta");
142  desc.addOptional<double>("maxIso");
143  desc.addOptional<int>("minHwIso");
144  desc.add<std::vector<double>>("regionsAbsEtaLowerBounds", {});
145  desc.add<std::vector<double>>("regionsMinPt", {});
146  desc.add<std::vector<double>>("regionsMaxIso", {});
147  desc.add<std::vector<unsigned int>>("regionsQual", {});
148  }
149 
150  const edm::InputTag& tag() const { return tag_; }
151 
152  private:
155  const std::optional<int> minPt_;
156  const std::optional<int> maxPt_;
157  const std::optional<int> minEta_;
158  const std::optional<int> maxEta_;
159  const std::optional<int> minPhi_;
160  const std::optional<int> maxPhi_;
161  const std::optional<int> minZ0_;
162  const std::optional<int> maxZ0_;
163  const std::optional<int> minScalarSumPt_;
164  const std::optional<int> maxScalarSumPt_;
165  const std::vector<unsigned int> qual_;
166  const std::optional<int> minAbsEta_;
167  const std::optional<int> maxAbsEta_;
168  const std::optional<int> maxIso_;
169  const std::optional<int> minHwIso_;
170  const std::vector<int> regionsAbsEtaLowerBounds_;
171  const std::vector<int> regionsMinPt_;
172  const std::vector<int> regionsMaxIso_;
173  const std::vector<unsigned int> regionsQual_;
174  };
175 
176 } // namespace l1t
177 
178 #endif // L1Trigger_Phase2L1GT_L1GTSingleCollectionCut_h
const std::optional< int > maxAbsEta_
const std::optional< int > maxIso_
bool checkEtadependentcuts(const P2GTCandidate &obj) const
const std::optional< int > minPhi_
bool checkObject(const P2GTCandidate &obj) const
const std::vector< unsigned int > regionsQual_
const std::optional< int > maxEta_
const std::optional< int > maxPhi_
static void fillPSetDescription(edm::ParameterSetDescription &desc)
const edm::InputTag & tag() const
const std::vector< int > regionsAbsEtaLowerBounds_
const std::optional< int > maxScalarSumPt_
delete x;
Definition: CaloConfig.h:22
Definition: config.py:1
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
L1GTSingleCollectionCut(const edm::ParameterSet &config, const edm::ParameterSet &lutConfig, const L1GTScales &scales)
Definition: Electron.h:6
const std::optional< int > minAbsEta_
std::optional< T > getOptionalParam(const std::string &name, const edm::ParameterSet &config, std::function< T(K)> conv)
unsigned int atIndex(int objeta) const
const std::optional< int > minEta_
const std::optional< int > minHwIso_
const std::optional< int > maxPt_
const std::vector< unsigned int > qual_
const std::optional< int > minZ0_
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const std::vector< int > regionsMaxIso_
Definition: value.py:1
int isolation_shift() const
Definition: L1GTScales.h:76
EPOS::IO_EPOS conv
const std::vector< int > regionsMinPt_
HLT enums.
std::vector< T > getParamVector(const std::string &name, const edm::ParameterSet &config, std::function< T(K)> conv)
long double T
const std::optional< int > maxZ0_
const std::optional< int > minPt_
const std::optional< int > minScalarSumPt_