ATLAS Offline Software
Loading...
Searching...
No Matches
L1ThresholdBase.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef TRIGCONFDATA_L1THRESHOLDBASE_H
6#define TRIGCONFDATA_L1THRESHOLDBASE_H
7
9
10#include <map>
11#include <vector>
12#include <optional>
13
14namespace TrigConf {
15
23 unsigned int energyInCounts(unsigned int energyMeV, unsigned int energyResolutionMeV);
24
34 template<class T>
36 class RangeValue {
37 public:
38 RangeValue(const T & value, int etaMin, int etaMax, unsigned int priority, bool symmetric);
39 const T & value() const { return m_value; }
40 int etaMin() const { return m_etaMin; };
41 int etaMax() const { return m_etaMax; };
42 unsigned int priority() const { return m_priority; }
43 bool symmetric() const { return m_symmetric; }
44 private:
45 T m_value {}; // the value (energy, set of isolation variables)
46 int m_etaMin { -49 }; // range boundaries, always inclusive
47 int m_etaMax { 49 }; // etaMin is always smaller than etaMax, e.g. on the negative side: etaMin=-49, etaMax=-31
48 unsigned int m_priority {0}; // higher number has higher priority when resolving overlapping regions
49 bool m_symmetric { true }; // if true, also applies to the opposity side ( requires etaMax to be positive )
50 };
51 public:
52 typedef typename std::vector<RangeValue>::const_iterator const_iterator;
53 ValueWithEtaDependence(const std::string& name) : m_name(name) {};
54 const std::string & name() const { return m_name; }
55 bool empty() const;
56 size_t size() const;
57 const T & at(int eta) const;
58 std::optional<std::reference_wrapper<const T>> outsideRangeValue() const;
61 void addRangeValue(const T & value, int etaMin, int etaMax, unsigned int priority, bool symmetric = true);
62 void setOutsideRangeValue(const T & value);
63 private:
64 const std::string m_name {""};
65 std::vector<RangeValue> m_rangeValues{};
66 std::optional<T> m_outsideRangeValue {std::nullopt};
67 };
68
69
70
73 public:
74
75 static std::unique_ptr<L1ThrExtraInfoBase> createExtraInfo(const std::string & thrTypeName, const ptree & data);
76
77 // Constructors
83 virtual ~L1ThrExtraInfoBase() override = default;
84
85 // Constructor initialized with configuration data
86 // @param data The data containing the L1 menu
87 //
88 L1ThrExtraInfoBase(const std::string & thrTypeName, const ptree & data);
89
90 virtual std::string className() const override {
91 return "L1ThrExtraInfoBase";
92 }
93
94 const std::string & thresholdTypeName() const;
95
96 bool hasExtraInfo( const std::string & key = "") const;
97
98 std::optional<std::reference_wrapper<const TrigConf::DataStructure>>
99 getExtraInfo( const std::string & key) const;
100
101 unsigned int resolutionMeV() const {
102 return m_resolutionMeV;
103 }
104
105 protected:
106 virtual void update() override {
107 load();
108 }
109 std::map<std::string, DataStructure> m_extraInfo{};
110
111 private:
112 // load the internal members
113 void load();
114
115 unsigned int m_resolutionMeV { 1000 }; // default resolution is 1 GeV
116 };
117
118
119
125 class L1Threshold : public DataStructure {
126 public:
127
135 static std::shared_ptr<L1Threshold> createThreshold( const std::string & name, const std::string & type,
136 std::weak_ptr<L1ThrExtraInfoBase> extraInfo, const ptree & data );
137
139 L1Threshold() = default;
140
147 L1Threshold( const std::string & name, const std::string & type,
148 std::weak_ptr<L1ThrExtraInfoBase> extraInfo, const ptree & data);
149
151 virtual ~L1Threshold() override = default;
152
153 virtual std::string className() const override
154 { return "L1Threshold"; }
155
157 const std::string & type() const
158 { return m_type; }
159
163 unsigned int mapping() const
164 { return m_mapping; }
165
170 virtual float thrValue(int eta = 0) const;
171
172 protected:
173
175 virtual void update() override;
176
177 std::weak_ptr<L1ThrExtraInfoBase> m_extraInfo;
178
179 private:
180
181 void load();
182
183 std::string m_type{""};
184 unsigned int m_mapping{0};
185 };
186
187
189 public:
190
193
200 L1Threshold_Calo( const std::string & name, const std::string & type,
201 std::weak_ptr<L1ThrExtraInfoBase> extraInfo, const ptree & data);
202
204 virtual ~L1Threshold_Calo() override = default;
205
206 // Accessors to the threshold value for eta-dependent threholds
207
208 /* @brief Accessor to the threshold value in GeV
209 * @param eta the eta value should be given for potentially eta-dependent thresholds
210 * @returns threshold in GeV
211 */
212 virtual float thrValue(int eta = 0) const override;
213
214 /* @brief Accessor to the threshold value in energy units
215 * @param eta the eta value should be given for potentially eta-dependent thresholds
216 * @returns threshold in energy units
217 */
218 virtual unsigned int thrValueCounts(int eta = 0) const;
219
220 /* @brief Accessor to the threshold value in MeV
221 * @param eta the eta value should be given for potentially eta-dependent thresholds
222 * @returns threshold in MeV
223 */
224 virtual unsigned int thrValueMeV(int eta = 0) const;
225
227 virtual unsigned int thrValue100MeV(int eta = 0) const;
228
231
233 virtual const ValueWithEtaDependence<unsigned int> & thrValuesMeV() const;
234
237
240
241 protected:
242
244 virtual void update() override;
245
246 std::string m_input{""};
247
248 // internally the threshold cuts are represented in MeV
249 // - it is human readible
250 // - integer are preferred over float by the L1Calo/L1Calo firmware experts
251 // - GeV is not possible as we would like to support cuts with finer granularity than GeV
252
253 unsigned int m_thrValue {0};
254
256
257 private:
258 void load();
259 };
260
261 /******************************************
262 * Isolation for legacy L1Calo thresholds
263 ******************************************/
265 public:
266 IsolationLegacy() = default;
267 IsolationLegacy( const boost::property_tree::ptree & );
268 bool isDefined() const { return m_isDefined; }
269 int isobit() const { return m_isobit; }
270 int offset() const { return m_offset; }
271 int slope() const { return m_slope; }
272 int mincut() const { return m_mincut; }
273 int upperlimit() const { return m_upperlimit; }
274 int etamin() const { return m_etamin; }
275 int etamax() const { return m_etamax; }
276 int priority() const { return m_priority; }
277 private:
278 bool m_isDefined { false };
279 int m_isobit { 0 };
280 int m_offset { 0 };
281 int m_slope { 0 };
282 int m_mincut { 0 };
283 int m_upperlimit { 0 };
284 int m_etamin { 0 };
285 int m_etamax { 0 };
286 int m_priority { 0 };
287 };
288 std::ostream & operator<<(std::ostream & os, const TrigConf::IsolationLegacy & iso);
289
290
291 /**************************************
292 * Selection points for L1Calo thresholds
293 **************************************/
294 class Selection {
295 public:
296 enum class WP {
297 NONE = 0,
298 LOOSE = 1, MEDIUM = 2, TIGHT = 3,
299 HADLOOSE = 4, HADMEDIUM = 5, HADTIGHT = 6, HAD = 7, // HAD = HADMEDIUM for backward compatibility
300
301 // cTAU-specific WPs
302 LOOSE12 = 8, LOOSE20 = 9, LOOSE30 = 10, LOOSE35 = 11,
303 MEDIUM12 = 12, MEDIUM20 = 13, MEDIUM30 = 14, MEDIUM35 = 15,
304 TIGHT12 = 16, TIGHT20 = 17, TIGHT30 = 18, TIGHT35 = 19,
305 LOOSE50 = 20, MEDIUM50 = 21, TIGHT50 = 22,
306 LOOSE55 = 23, MEDIUM55 = 24, TIGHT55 = 25
307 };
308 static std::string wpToString(WP);
309 static WP stringToWP(const std::string &);
310 };
311}
312
314
315#endif
Scalar eta() const
pseudorapidity method
virtual const std::string & name() const final
const ptree & data() const
Access to the underlying data, if needed.
DataStructure()
Default constructor, leading to an uninitialized configuration object.
boost::property_tree::ptree ptree
unsigned int resolutionMeV() const
L1ThrExtraInfoBase & operator=(L1ThrExtraInfoBase &&)=default
const std::string & thresholdTypeName() const
std::map< std::string, DataStructure > m_extraInfo
L1ThrExtraInfoBase & operator=(const L1ThrExtraInfoBase &)=delete
virtual void update() override
Update the internal data after modification of the data object.
std::optional< std::reference_wrapper< const TrigConf::DataStructure > > getExtraInfo(const std::string &key) const
bool hasExtraInfo(const std::string &key="") const
L1ThrExtraInfoBase(const L1ThrExtraInfoBase &)=delete
static std::unique_ptr< L1ThrExtraInfoBase > createExtraInfo(const std::string &thrTypeName, const ptree &data)
virtual std::string className() const override
A string that is the name of the class.
L1ThrExtraInfoBase(L1ThrExtraInfoBase &&)=default
virtual ~L1ThrExtraInfoBase() override=default
virtual void update() override
Update the internal data after modification of the data object.
L1Threshold_Calo()=delete
Constructor.
virtual ~L1Threshold_Calo() override=default
Destructor.
virtual const ValueWithEtaDependence< unsigned int > & thrValuesMeV() const
access to the list of ThresholdValues in MeV
virtual float thrValue(int eta=0) const override
Accessor to the threshold value for eta-dependent threholds.
virtual ValueWithEtaDependence< unsigned int > thrValues100MeV() const
access to the list of ThresholdValues in 100 MeV (for L1Topo multiplicity)
virtual ValueWithEtaDependence< float > thrValues() const
access to the list of ThresholdValues in GeV
ValueWithEtaDependence< unsigned int > m_etaDepThrValue
eta-dependent threshold value in MeV
virtual unsigned int thrValueMeV(int eta=0) const
virtual unsigned int thrValueCounts(int eta=0) const
unsigned int m_thrValue
threshold value in MeV
virtual ValueWithEtaDependence< unsigned int > thrValuesCounts() const
access to the list of ThresholdValues in energy units
virtual unsigned int thrValue100MeV(int eta=0) const
as above above but in 100 MeV
virtual void update() override
Update the internal data after modification of the data object.
std::string m_type
threshold type
L1Threshold()=default
Constructor.
virtual float thrValue(int eta=0) const
Accessor to the threshold value for eta-dependent threholds.
unsigned int mapping() const
Accessor to the mapping number The mapping is unique within a type.
const std::string & type() const
Accessor to the threshold type.
virtual ~L1Threshold() override=default
Destructor.
unsigned int m_mapping
unique identifier amongst thresholds of the same type
static std::shared_ptr< L1Threshold > createThreshold(const std::string &name, const std::string &type, std::weak_ptr< L1ThrExtraInfoBase > extraInfo, const ptree &data)
static method to create type-specific L1Thresholds
std::weak_ptr< L1ThrExtraInfoBase > m_extraInfo
virtual std::string className() const override
A string that is the name of the class.
static std::string wpToString(WP)
static WP stringToWP(const std::string &)
RangeValue(const T &value, int etaMin, int etaMax, unsigned int priority, bool symmetric)
class to implement a L1 threshold cut that varies with eta
ValueWithEtaDependence(const std::string &name)
std::optional< std::reference_wrapper< const T > > outsideRangeValue() const
const_iterator end() const noexcept
void addRangeValue(const T &value, int etaMin, int etaMax, unsigned int priority, bool symmetric=true)
std::vector< RangeValue > m_rangeValues
const std::string & name() const
const T & at(int eta) const
const_iterator begin() const noexcept
std::vector< RangeValue >::const_iterator const_iterator
void setOutsideRangeValue(const T &value)
std::optional< T > m_outsideRangeValue
Forward iterator to traverse the main components of the trigger configuration.
Definition Config.h:22
unsigned int energyInCounts(unsigned int energyMeV, unsigned int energyResolutionMeV)
helper funtion to translate energies into counts
std::ostream & operator<<(std::ostream &os, const TrigConf::IsolationLegacy &iso)
STL namespace.
#define private