ATLAS Offline Software
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 
14 namespace 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;
60  const_iterator end() const noexcept;
61  void addRangeValue(const T & value, int etaMin, int etaMax, unsigned int priority, bool symmetric = true);
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
78  L1ThrExtraInfoBase() = delete;
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 
188  class L1Threshold_Calo : public L1Threshold {
189  public:
190 
192  L1Threshold_Calo() = delete;
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;
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  };
306  static std::string wpToString(WP);
307  static WP stringToWP(const std::string &);
308  };
309 }
310 
312 
313 #endif
TrigConf::L1ThrExtraInfoBase::L1ThrExtraInfoBase
L1ThrExtraInfoBase(L1ThrExtraInfoBase &&)=default
TrigConf::DataStructure::data
const ptree & data() const
Access to the underlying data, if needed.
Definition: DataStructure.h:83
TrigConf::Selection::WP
WP
Definition: L1ThresholdBase.h:298
TrigConf::L1Threshold_Calo::thrValuesCounts
virtual ValueWithEtaDependence< unsigned int > thrValuesCounts() const
access to the list of ThresholdValues in energy units
Definition: L1ThresholdBase.cxx:317
TrigConf::ValueWithEtaDependence::setOutsideRangeValue
void setOutsideRangeValue(const T &value)
TrigConf::Selection::WP::LOOSE
@ LOOSE
TrigConf::L1ThrExtraInfoBase::className
virtual std::string className() const override
A string that is the name of the class.
Definition: L1ThresholdBase.h:90
TrigConf::L1Threshold::mapping
unsigned int mapping() const
Accessor to the mapping number The mapping is unique within a type.
Definition: L1ThresholdBase.h:163
L1ThresholdBase.icc
TrigConf::ValueWithEtaDependence::m_rangeValues
std::vector< RangeValue > m_rangeValues
Definition: L1ThresholdBase.h:65
TrigConf::operator<<
std::ostream & operator<<(std::ostream &os, const TrigConf::IsolationLegacy &iso)
Definition: L1ThresholdBase.cxx:339
TrigConf::ValueWithEtaDependence::size
size_t size() const
TrigConf::Selection
Definition: L1ThresholdBase.h:294
TrigConf::L1ThrExtraInfoBase::operator=
L1ThrExtraInfoBase & operator=(L1ThrExtraInfoBase &&)=default
TrigConf::Selection::WP::MEDIUM12
@ MEDIUM12
TrigConf::IsolationLegacy::m_upperlimit
int m_upperlimit
Definition: L1ThresholdBase.h:285
TrigConf::IsolationLegacy::m_etamax
int m_etamax
Definition: L1ThresholdBase.h:287
TrigConf::Selection::stringToWP
static WP stringToWP(const std::string &)
Definition: L1ThresholdBase.cxx:393
TrigConf::ValueWithEtaDependence::begin
const_iterator begin() const noexcept
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:79
TrigConf::ValueWithEtaDependence::RangeValue::m_value
T m_value
Definition: L1ThresholdBase.h:45
TrigConf::L1ThrExtraInfoBase::operator=
L1ThrExtraInfoBase & operator=(const L1ThrExtraInfoBase &)=delete
TrigConf::Selection::WP::TIGHT35
@ TIGHT35
TrigConf::Selection::wpToString
static std::string wpToString(WP)
Definition: L1ThresholdBase.cxx:347
TrigConf::IsolationLegacy::m_isDefined
bool m_isDefined
Definition: L1ThresholdBase.h:280
xAOD::etaMax
etaMax
Definition: HIEventShape_v2.cxx:46
athena.value
value
Definition: athena.py:122
python.selector.AtlRunQuerySelectorLhcOlc.priority
priority
Definition: AtlRunQuerySelectorLhcOlc.py:611
TrigConf::L1Threshold::type
const std::string & type() const
Accessor to the threshold type.
Definition: L1ThresholdBase.h:157
TrigConf::ValueWithEtaDependence
class to implement a L1 threshold cut that varies with eta
Definition: L1ThresholdBase.h:35
TrigConf::L1ThrExtraInfoBase
L1 extra information for certain threshold types.
Definition: L1ThresholdBase.h:72
TrigConf::IsolationLegacy
Definition: L1ThresholdBase.h:264
TrigConf::L1ThrExtraInfoBase::thresholdTypeName
const std::string & thresholdTypeName() const
Definition: L1ThresholdBase.cxx:184
TrigConf::L1Threshold_Calo::load
void load()
Definition: L1ThresholdBase.cxx:241
TrigConf::IsolationLegacy::m_priority
int m_priority
Definition: L1ThresholdBase.h:288
const
bool const RAWDATA *ch2 const
Definition: LArRodBlockPhysicsV0.cxx:562
TrigConf::IsolationLegacy::m_offset
int m_offset
Definition: L1ThresholdBase.h:282
TrigConf::L1Threshold_Calo::m_input
std::string m_input
Definition: L1ThresholdBase.h:246
TrigConf::IsolationLegacy::offset
int offset() const
Definition: L1ThresholdBase.h:272
TrigConf::IsolationLegacy::m_isobit
int m_isobit
Definition: L1ThresholdBase.h:281
TrigConf::ValueWithEtaDependence::RangeValue::etaMax
int etaMax() const
Definition: L1ThresholdBase.h:41
TrigConf::L1Threshold::m_mapping
unsigned int m_mapping
unique identifier amongst thresholds of the same type
Definition: L1ThresholdBase.h:184
TrigConf::L1ThrExtraInfoBase::~L1ThrExtraInfoBase
virtual ~L1ThrExtraInfoBase() override=default
TrigConf::ValueWithEtaDependence::at
const T & at(int eta) const
TrigConf::Selection::WP::NONE
@ NONE
TrigConf::Selection::WP::HADLOOSE
@ HADLOOSE
TrigConf::Selection::WP::TIGHT12
@ TIGHT12
TrigConf::L1ThrExtraInfoBase::m_extraInfo
std::map< std::string, DataStructure > m_extraInfo
Definition: L1ThresholdBase.h:109
TrigConf::Selection::WP::LOOSE35
@ LOOSE35
TrigConf::IsolationLegacy::mincut
int mincut() const
Definition: L1ThresholdBase.h:274
TrigConf::ValueWithEtaDependence::empty
bool empty() const
TrigConf::L1Threshold_Calo::~L1Threshold_Calo
virtual ~L1Threshold_Calo() override=default
Destructor.
TrigConf::L1Threshold_Calo
Definition: L1ThresholdBase.h:188
TrigConf::Selection::WP::TIGHT30
@ TIGHT30
TrigConf
Forward iterator to traverse the main components of the trigger configuration.
Definition: Config.h:22
TrigConf::L1Threshold_Calo::thrValue100MeV
virtual unsigned int thrValue100MeV(int eta=0) const
as above above but in 100 MeV
Definition: L1ThresholdBase.cxx:284
TrigConf::ValueWithEtaDependence::RangeValue::priority
unsigned int priority() const
Definition: L1ThresholdBase.h:42
TrigConf::L1Threshold::createThreshold
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
Definition: L1ThresholdBase.cxx:28
TrigConf::ValueWithEtaDependence::RangeValue::value
const T & value() const
Definition: L1ThresholdBase.h:39
TrigConf::L1Threshold::update
virtual void update() override
Update the internal data after modification of the data object.
Definition: L1ThresholdBase.cxx:132
TrigConf::L1Threshold::className
virtual std::string className() const override
A string that is the name of the class.
Definition: L1ThresholdBase.h:153
TrigConf::L1Threshold_Calo::thrValue
virtual float thrValue(int eta=0) const override
Accessor to the threshold value for eta-dependent threholds.
Definition: L1ThresholdBase.cxx:272
TrigConf::L1Threshold_Calo::thrValueCounts
virtual unsigned int thrValueCounts(int eta=0) const
Definition: L1ThresholdBase.cxx:278
TrigConf::L1ThrExtraInfoBase::createExtraInfo
static std::unique_ptr< L1ThrExtraInfoBase > createExtraInfo(const std::string &thrTypeName, const ptree &data)
TrigConf::IsolationLegacy::etamin
int etamin() const
Definition: L1ThresholdBase.h:276
TrigConf::IsolationLegacy::m_mincut
int m_mincut
Definition: L1ThresholdBase.h:284
TrigConf::ValueWithEtaDependence::RangeValue::m_etaMin
int m_etaMin
Definition: L1ThresholdBase.h:46
TrigConf::L1Threshold_Calo::update
virtual void update() override
Update the internal data after modification of the data object.
Definition: L1ThresholdBase.cxx:222
TrigConf::L1Threshold_Calo::m_thrValue
unsigned int m_thrValue
threshold value in MeV
Definition: L1ThresholdBase.h:253
TrigConf::ValueWithEtaDependence::m_outsideRangeValue
std::optional< T > m_outsideRangeValue
Definition: L1ThresholdBase.h:66
TrigConf::L1ThrExtraInfoBase::update
virtual void update() override
Update the internal data after modification of the data object.
Definition: L1ThresholdBase.h:106
TrigConf::ValueWithEtaDependence::RangeValue::etaMin
int etaMin() const
Definition: L1ThresholdBase.h:40
TrigConf::L1ThrExtraInfoBase::getExtraInfo
std::optional< std::reference_wrapper< const TrigConf::DataStructure > > getExtraInfo(const std::string &key) const
Definition: L1ThresholdBase.cxx:199
TrigConf::L1Threshold_Calo::m_etaDepThrValue
ValueWithEtaDependence< unsigned int > m_etaDepThrValue
eta-dependent threshold value in MeV
Definition: L1ThresholdBase.h:255
TrigConf::Selection::WP::LOOSE20
@ LOOSE20
TrigConf::L1ThrExtraInfoBase::L1ThrExtraInfoBase
L1ThrExtraInfoBase()=delete
TrigConf::IsolationLegacy::etamax
int etamax() const
Definition: L1ThresholdBase.h:277
TrigConf::ValueWithEtaDependence::outsideRangeValue
std::optional< std::reference_wrapper< const T > > outsideRangeValue() const
TrigConf::ValueWithEtaDependence::RangeValue::m_priority
unsigned int m_priority
Definition: L1ThresholdBase.h:48
TrigConf::L1Threshold::thrValue
virtual float thrValue(int eta=0) const
Accessor to the threshold value for eta-dependent threholds.
Definition: L1ThresholdBase.cxx:127
TrigConf::ValueWithEtaDependence::RangeValue::m_etaMax
int m_etaMax
Definition: L1ThresholdBase.h:47
TrigConf::Selection::WP::MEDIUM20
@ MEDIUM20
TrigConf::L1Threshold::m_extraInfo
std::weak_ptr< L1ThrExtraInfoBase > m_extraInfo
Definition: L1ThresholdBase.h:177
TrigConf::IsolationLegacy::slope
int slope() const
Definition: L1ThresholdBase.h:273
ReadFromCoolCompare.os
os
Definition: ReadFromCoolCompare.py:231
TrigConf::ValueWithEtaDependence::const_iterator
std::vector< RangeValue >::const_iterator const_iterator
Definition: L1ThresholdBase.h:52
TrigConf::name
Definition: HLTChainList.h:35
TrigConf::Selection::WP::HADTIGHT
@ HADTIGHT
TrigConf::L1Threshold_Calo::thrValues
virtual ValueWithEtaDependence< float > thrValues() const
access to the list of ThresholdValues in GeV
Definition: L1ThresholdBase.cxx:294
ptree
boost::property_tree::ptree ptree
Definition: JsonFileLoader.cxx:16
TrigConf::energyInCounts
unsigned int energyInCounts(unsigned int energyMeV, unsigned int energyResolutionMeV)
helper funtion to translate energies into counts
Definition: L1ThresholdBase.cxx:18
TrigConf::L1ThrExtraInfoBase::L1ThrExtraInfoBase
L1ThrExtraInfoBase(const L1ThrExtraInfoBase &)=delete
private
#define private
Definition: DetDescrConditionsDict_dict_fixes.cxx:13
TrigConf::IsolationLegacy::priority
int priority() const
Definition: L1ThresholdBase.h:278
TrigConf::L1Threshold::~L1Threshold
virtual ~L1Threshold() override=default
Destructor.
TrigConf::ValueWithEtaDependence::RangeValue::RangeValue
RangeValue(const T &value, int etaMin, int etaMax, unsigned int priority, bool symmetric)
TrigConf::ValueWithEtaDependence::m_name
const std::string m_name
Definition: L1ThresholdBase.h:64
TrigConf::L1ThrExtraInfoBase::resolutionMeV
unsigned int resolutionMeV() const
Definition: L1ThresholdBase.h:101
TrigConf::ValueWithEtaDependence::RangeValue::m_symmetric
bool m_symmetric
Definition: L1ThresholdBase.h:49
TrigConf::DataStructure
Base class for Trigger configuration data and wrapper around underlying representation.
Definition: DataStructure.h:37
TrigConf::Selection::WP::LOOSE12
@ LOOSE12
TrigConf::Selection::WP::MEDIUM30
@ MEDIUM30
TrigConf::Selection::WP::HAD
@ HAD
TrigConf::IsolationLegacy::isDefined
bool isDefined() const
Definition: L1ThresholdBase.h:270
TrigConf::Selection::WP::MEDIUM
@ MEDIUM
TrigConf::Selection::WP::TIGHT
@ TIGHT
TrigConf::Selection::WP::MEDIUM35
@ MEDIUM35
LArCellBinning.etaMin
etaMin
Definition: LArCellBinning.py:84
TrigConf::L1Threshold::m_type
std::string m_type
threshold type
Definition: L1ThresholdBase.h:183
TrigConf::Selection::WP::HADMEDIUM
@ HADMEDIUM
TrigConf::ValueWithEtaDependence::addRangeValue
void addRangeValue(const T &value, int etaMin, int etaMax, unsigned int priority, bool symmetric=true)
TrigConf::IsolationLegacy::m_slope
int m_slope
Definition: L1ThresholdBase.h:283
TrigConf::L1ThrExtraInfoBase::load
void load()
Definition: L1ThresholdBase.cxx:157
TrigConf::IsolationLegacy::m_etamin
int m_etamin
Definition: L1ThresholdBase.h:286
TrigConf::ValueWithEtaDependence::RangeValue::symmetric
bool symmetric() const
Definition: L1ThresholdBase.h:43
TrigConf::L1ThrExtraInfoBase::m_resolutionMeV
unsigned int m_resolutionMeV
Definition: L1ThresholdBase.h:115
TrigConf::ValueWithEtaDependence::ValueWithEtaDependence
ValueWithEtaDependence(const std::string &name)
Definition: L1ThresholdBase.h:53
TrigConf::Selection::WP::LOOSE30
@ LOOSE30
TrigConf::L1Threshold::load
void load()
Definition: L1ThresholdBase.cxx:138
TrigConf::ValueWithEtaDependence::end
const_iterator end() const noexcept
TrigConf::L1Threshold_Calo::L1Threshold_Calo
L1Threshold_Calo()=delete
Constructor.
TrigConf::Selection::WP::TIGHT20
@ TIGHT20
TrigConf::L1Threshold_Calo::thrValueMeV
virtual unsigned int thrValueMeV(int eta=0) const
Definition: L1ThresholdBase.cxx:289
TrigConf::IsolationLegacy::upperlimit
int upperlimit() const
Definition: L1ThresholdBase.h:275
TrigConf::L1Threshold_Calo::thrValues100MeV
virtual ValueWithEtaDependence< unsigned int > thrValues100MeV() const
access to the list of ThresholdValues in 100 MeV (for L1Topo multiplicity)
Definition: L1ThresholdBase.cxx:308
TrigConf::IsolationLegacy::IsolationLegacy
IsolationLegacy()=default
DataStructure.h
TrigConf::DataStructure::ptree
boost::property_tree::ptree ptree
Definition: DataStructure.h:40
TrigConf::IsolationLegacy::isobit
int isobit() const
Definition: L1ThresholdBase.h:271
TrigConf::L1Threshold::L1Threshold
L1Threshold()=default
Constructor.
TrigConf::ValueWithEtaDependence::RangeValue
Definition: L1ThresholdBase.h:36
TrigConf::L1ThrExtraInfoBase::hasExtraInfo
bool hasExtraInfo(const std::string &key="") const
Definition: L1ThresholdBase.cxx:190
TrigConf::L1Threshold
Standard L1 threshold configuration.
Definition: L1ThresholdBase.h:125
TrigConf::L1Threshold_Calo::thrValuesMeV
virtual const ValueWithEtaDependence< unsigned int > & thrValuesMeV() const
access to the list of ThresholdValues in MeV
Definition: L1ThresholdBase.cxx:303
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37
TrigConf::ValueWithEtaDependence::name
const std::string & name() const
Definition: L1ThresholdBase.h:54