ATLAS Offline Software
RecJetRoI.cxx
Go to the documentation of this file.
1 // Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
2 
3 /***************************************************************************
4  RecJetRoI.cxx - description
5  -------------------
6  begin : Mon Jan 22 2001
7  email : moyse@heppch.ph.qmw.ac.uk
8 ***************************************************************************/
9 
10 // STL include(s):
11 #include <cmath>
12 
13 // Trigger config includes:
19 #include "TrigConfData/L1Menu.h"
20 
21 // Local include(s):
24 
25 using namespace std;
26 using namespace TrigConf;
27 
29 LVL1::RecJetRoI::RecJetRoI( unsigned int RoIWord,
30  const std::vector<TriggerThreshold *> *caloThresholds) {
31 
32  m_roiWord = RoIWord;
33  m_decoder = new JEPRoIDecoder();
34  m_version = m_decoder->jetRoIVersion(m_roiWord);
35  m_coordRange = m_decoder->coordinate(m_roiWord);
36 
37  if (m_version > 1)
38  this->constructRun2(caloThresholds);
39  else
40  this->constructRun1(caloThresholds);
41 }
42 
43 LVL1::RecJetRoI::RecJetRoI( unsigned int RoIWord,
44  const TrigConf::L1Menu * const l1menu) :
45  m_roiWord(RoIWord),
46  m_decoder(new JEPRoIDecoder()),
47  m_version(m_decoder->jetRoIVersion(m_roiWord)),
48  m_coordRange(m_decoder->coordinate(m_roiWord))
49 {
51 }
52 
53 // copy constructor
55  m_roiWord(obj.m_roiWord),
56  m_decoder(new JEPRoIDecoder()),
57  m_version(obj.m_version),
58  m_coordRange(obj.m_coordRange),
59  m_triggerThresholdValue(obj.m_triggerThresholdValue),
60  m_windowSize(obj.m_windowSize)
61 {}
62 
63 // assignment operator
66  if(this != &rhs) {
67  m_roiWord = rhs.m_roiWord;
68  delete m_decoder;
69  m_decoder = new JEPRoIDecoder();
70  m_version = rhs.m_version;
71  m_coordRange = rhs.m_coordRange;
72  m_thresholdMask = rhs.m_thresholdMask;
73  m_triggerThresholdValue = rhs.m_triggerThresholdValue;
74  m_windowSize = rhs.m_windowSize;
75  }
76  return *this;
77 }
78 
79 LVL1::RecJetRoI::~RecJetRoI() { delete m_decoder; }
80 
90 void LVL1::RecJetRoI::constructRun1(const std::vector<TriggerThreshold *> *caloThresholds)
91 {
92 
93  m_thresholdMask = m_roiWord & 0xfff;
94 
95  std::string jetTriggerType = L1DataDef::jetType();
96  if (this->isForwardJet())
97  jetTriggerType =
98  ((this->eta() > 0) ? L1DataDef::jfType() : L1DataDef::jbType());
99 
100  //
101  // Copy the thresholds into a map - makes matching up the passed ones very
102  // easy
103  //
104 
105  std::map<unsigned int, TriggerThreshold *> thrMap;
106  for (std::vector<TriggerThreshold *>::const_iterator it =
107  caloThresholds->begin();
108  it != caloThresholds->end(); ++it)
109  {
110  if ((*it)->type() == jetTriggerType)
111  {
112  unsigned int num = static_cast<unsigned int>((*it)->thresholdNumber());
113  thrMap.insert(std::map<unsigned int, TriggerThreshold *>::value_type(num, (*it)));
114  }
115  }
116 
117  //
118  // Extract the properties of the passed thresholds:
119  //
120  const vector<unsigned int> passed_thresholds =
121  (this->isForwardJet() ? m_decoder->fwdThresholdsPassed(m_roiWord)
122  : m_decoder->thresholdsPassed(m_roiWord));
123 
124  int iphi = int((m_coordRange.phiRange().min() + 0.025) * 32 / M_PI);
125  int ieta =
126  int((this->eta() + ((this->eta() > 0.01) ? 0.025 : -0.025)) / 0.1) - 1;
127  // Adjustment due to irregular geometries
128  if (ieta > 24)
129  ieta += 2;
130 
131  for (vector<unsigned int>::const_iterator itp = passed_thresholds.begin();
132  itp != passed_thresholds.end(); ++itp)
133  {
134  std::map<unsigned int, TriggerThreshold *>::const_iterator thr =
135  thrMap.find(*itp - 1);
136  if (thr != thrMap.end())
137  {
138  TriggerThresholdValue *ttv =
139  thr->second->triggerThresholdValue(ieta, iphi);
140  JetThresholdValue *jtv = dynamic_cast<JetThresholdValue *>(ttv);
141  if (jtv)
142  {
143  m_triggerThresholdValue.insert(std::map<unsigned int, unsigned int>::value_type(
144  *itp, jtv->thresholdValueCount()));
145  m_windowSize.insert(
146  std::map<unsigned int, unsigned int>::value_type(*itp, jtv->window()));
147  }
148  } // end "found threshold in map"
149  } // end loop through passed thresholds
150 
151  return;
152 }
153 
155 void
156 LVL1::RecJetRoI::constructRun2(const std::vector<TriggerThreshold *> *caloThresholds)
157 {
158 
159  m_thresholdMask = 0;
160  m_triggerThresholdValue.clear();
161  m_windowSize.clear();
162 
163  int ieta =
164  int((this->eta() + ((this->eta() > 0.01) ? 0.025 : -0.025)) / 0.1) - 1;
165  // Adjustment due to irregular geometries
166  if (ieta > 24)
167  ieta += 2;
168  int iphi = int((m_coordRange.phiRange().min() + 0.025) * 32 / M_PI);
169  //
170  // Iterate through vector of thresholds and see which ones this RoI satisfies
171  //
172  for (std::vector<TriggerThreshold *>::const_iterator it =
173  caloThresholds->begin();
174  it != caloThresholds->end(); ++it) {
175  if ((*it)->type() == L1DataDef::jetType()) {
176  // Does it satisfy this one?
177  // Start by extracting threshold values
178  TriggerThresholdValue *ttv = (*it)->triggerThresholdValue(ieta, iphi);
179  JetThresholdValue *jtv = dynamic_cast<JetThresholdValue *>(ttv);
180  if (jtv) {
181  float scale = jtv->caloInfo().globalJetScale();
182  unsigned int etCut = jtv->ptcut();
183  unsigned int threshold = etCut * scale;
184  JetWindowSize::Size window = jtv->windowSize();
185  unsigned int roiET =
186  (window == JetWindowSize::LARGE ? etLarge() : etSmall());
187  if (roiET > threshold) {
188  unsigned int num = static_cast<unsigned int>((*it)->thresholdNumber());
189  m_triggerThresholdValue.insert(
190  std::map<unsigned int, unsigned int>::value_type(num, etCut));
191  m_windowSize.insert(
192  std::map<unsigned int, unsigned int>::value_type(num, window));
193  m_thresholdMask |= (1 << num);
194  } // passes cuts
195  } // JetThresholdValue pointer valid
196  } // correct threshold type
197  } // Loop over thresholds
198 }
199 
200 void
202 {
203  int ieta = int((this->eta() + ((this->eta() > 0.01) ? 0.025 : -0.025)) / 0.1) - 1;
204  // Adjustment due to irregular geometries
205  if (ieta > 24)
206  {
207  ieta += 2;
208  }
209 
210  // Iterate through vector of thresholds and see which ones this RoI satisfies
211  for (shared_ptr<TrigConf::L1Threshold> thr : l1menu->thresholds("JET"))
212  {
213  // Does it satisfy this one?
214  // Start by extracting threshold values
215  auto jetThr = std::dynamic_pointer_cast<TrigConf::L1Threshold_JET>(thr);
216  if (!jetThr)
217  {
218  continue;
219  }
220 
221  // test eT
222  unsigned int etCut = std::round(jetThr->thrValue(ieta)); // threshold value in GeV (integer for legacy thr)
223  unsigned int etCounts = jetThr->thrValueCounts(ieta); // threshold counts (threshold value * emscale)
225  unsigned int roiET = (window == TrigConf::JetWindowSize::LARGE) ? RecJetRoI::etLarge() : RecJetRoI::etSmall();
226  bool eTPassed = (roiET > etCounts);
227 
228  if (eTPassed)
229  {
230  const unsigned int num = thr->mapping();
231  m_triggerThresholdValue[num] = etCut;
232  m_windowSize[num] = window;
233  m_thresholdMask |= (1 << num);
234  } // passes cuts
235  } // Loop over thresholds
236 }
237 
238 unsigned int
239 LVL1::RecJetRoI::roiWord() const { return m_roiWord; }
240 
242 double
244 {
245  double roiPhi = m_coordRange.phi();
246  if (roiPhi > M_PI)
247  roiPhi -= 2 * M_PI;
248  return roiPhi;
249 }
250 
252 double
253 LVL1::RecJetRoI::eta() const { return m_coordRange.eta(); }
254 
256 unsigned int
257 LVL1::RecJetRoI::crate() const { return m_decoder->crate(m_roiWord); }
258 
260 unsigned int
261 LVL1::RecJetRoI::module() const { return m_decoder->module(m_roiWord); }
262 
264 unsigned int
266  unsigned int row = m_decoder->row(m_roiWord);
267  unsigned int col = m_decoder->column(m_roiWord);
268  return ((col & 2) << 1) + (row >> 1);
269 }
270 
272 unsigned int
274  unsigned int row = m_decoder->row(m_roiWord);
275  unsigned int col = m_decoder->column(m_roiWord);
276  return (col & 1) + ((row & 1) << 1);
277 }
278 
281 unsigned int
283  if (m_version > 1) {
284  return m_decoder->etLarge(m_roiWord);
285  } else {
286  float highest = 0;
287  std::map<unsigned int, unsigned int>::const_iterator it =
288  m_triggerThresholdValue.begin();
289  for (; it != m_triggerThresholdValue.end(); ++it)
290  if (it->second > highest)
291  highest = it->second;
292  return highest;
293  }
294 }
295 
298 unsigned int
300  if (m_version > 1) {
301  return m_decoder->etSmall(m_roiWord);
302  } else {
303  float highest = 0;
304  std::map<unsigned int, unsigned int>::const_iterator it =
305  m_triggerThresholdValue.begin();
306  for (; it != m_triggerThresholdValue.end(); ++it)
307  if (it->second > highest)
308  highest = it->second;
309  return highest;
310  }
311 }
312 
314 unsigned int
315 LVL1::RecJetRoI::thresholdPattern() const { return m_thresholdMask; }
316 
319 bool
320 LVL1::RecJetRoI::passedThreshold(unsigned int thresholdNumber) const {
321 
322  bool value = false;
323 
324  std::map<unsigned int, unsigned int>::const_iterator it =
325  m_triggerThresholdValue.find(thresholdNumber);
326  if (it != m_triggerThresholdValue.end())
327  value = true;
328 
329  return value;
330 }
331 
335 bool
336 LVL1::RecJetRoI::passedFwdThreshold(unsigned int thresholdNumber) const {
337 
338  if ((m_version < 2) && this->isValidThreshold(thresholdNumber)) {
339  return (((1 << (thresholdNumber + 7)) & m_roiWord) > 0);
340  }
341  return false;
342 }
343 
348 LVL1::RecJetRoI::coord() const { return m_coordRange; }
349 
351 std::vector<unsigned int>
353 
354  std::vector<unsigned int> newVec;// = new std::vector<unsigned int>;
355 
356  unsigned int nThresh = TrigT1CaloDefs::numOfJetCMXThresholds;
357  if (m_version == 1) {
358  if (this->isForwardJet())
360  else
362  }
363 
364  for (unsigned int iTh = 0; iTh <= nThresh; ++iTh) {
365  std::map<unsigned int, unsigned int>::const_iterator it =
366  m_triggerThresholdValue.find(iTh);
367  if (it != m_triggerThresholdValue.end())
368  newVec.push_back(iTh);
369  }
370 
371  return newVec;
372 }
373 
374 
378 unsigned int
379 LVL1::RecJetRoI::triggerThreshold(const unsigned int thresh) const {
380  map<unsigned int, unsigned int>::const_iterator it =
381  m_triggerThresholdValue.find(thresh);
382  if (it != m_triggerThresholdValue.end()) {
383  return it->second;
384  }
385  return TrigT1CaloDefs::Error;
386 }
387 
389 unsigned int
390 LVL1::RecJetRoI::windowSize(const unsigned int thresh) const {
391  map<unsigned int, unsigned int>::const_iterator it = m_windowSize.find(thresh);
392  if (it != m_windowSize.end()) {
393  return it->second;
394  }
395  return TrigT1CaloDefs::Error;
396 }
397 
399 bool
400 LVL1::RecJetRoI::isValidThreshold(const unsigned int thresh) const
401 {
402  if (!this->isForwardJet()) {
404  } else {
406  }
407 }
408 
412 bool
414 {
415  if (m_version <= 1 && ((1 << 18) & m_roiWord))
416  return true;
417  return false;
418 }
419 
TrigConf::TriggerThresholdValue
Definition: TriggerThresholdValue.h:22
LVL1::RecJetRoI::triggerThreshold
unsigned int triggerThreshold(unsigned int thresh) const
returns the value of the trigger threshold for the threshold passed.
Definition: RecJetRoI.cxx:379
query_example.row
row
Definition: query_example.py:24
TruthTest.itp
itp
Definition: TruthTest.py:46
LVL1::RecJetRoI::module
virtual unsigned int module() const
returns JEM number
Definition: RecJetRoI.cxx:261
LVL1::RecJetRoI::thresholdPattern
unsigned int thresholdPattern() const
returns bitmask of passed thresholds
Definition: RecJetRoI.cxx:315
HLTSeedingRoIToolDefs::roiPhi
constexpr float roiPhi(const AnyRoIPointer &roi)
Definition: HLTSeedingRoIToolDefs.h:167
LVL1::RecJetRoI
This class defines the reconstructed em/tau hadron ROI.
Definition: RecJetRoI.h:39
LVL1::RecJetRoI::m_coordRange
CoordinateRange m_coordRange
this contains the coordinate range worked out from the RoIWord hardware coord (i.e.
Definition: RecJetRoI.h:142
LVL1::RecJetRoI::passedFwdThreshold
bool passedFwdThreshold(unsigned int thresholdNumber) const
Same for forward jets.
Definition: RecJetRoI.cxx:336
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
physval_make_web_display.thresh
thresh
Definition: physval_make_web_display.py:35
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:79
TrigConf::JetWindowSize::Size
Size
Definition: TriggerThresholdValue.h:17
TrigConf::JetThresholdValue::windowSize
virtual JetWindowSize::Size windowSize() const override
Definition: JetThresholdValue.cxx:31
LVL1::RecJetRoI::~RecJetRoI
~RecJetRoI()
Definition: RecJetRoI.cxx:79
LVL1::JEPRoIDecoder
A level 1 calorimeter trigger conversion service: returns the Coordinate represented by a RoI word.
Definition: JEPRoIDecoder.h:33
LVL1::RecJetRoI::constructRun2
void constructRun2(const std::vector< TrigConf::TriggerThreshold * > *caloThresholds)
construct call for Run 2 Jet RoIs
Definition: RecJetRoI.cxx:156
MuonGM::round
float round(const float toRound, const unsigned int decimals)
Definition: Mdt.cxx:27
CSV_InDetExporter.new
new
Definition: CSV_InDetExporter.py:145
LVL1::RecJetRoI::thresholdsPassed
std::vector< unsigned int > thresholdsPassed() const
returns a vector of thresholds passed.
Definition: RecJetRoI.cxx:352
skel.it
it
Definition: skel.GENtoEVGEN.py:423
TrigConf::TriggerThresholdValue::ptcut
float ptcut() const
Definition: TriggerThresholdValue.h:45
LVL1::RecJetRoI::etSmall
virtual unsigned int etSmall() const
returns roi ET in smaller cluster.
Definition: RecJetRoI.cxx:299
M_PI
#define M_PI
Definition: ActiveFraction.h:11
athena.value
value
Definition: athena.py:122
NSWL1::coordinate
float coordinate(const Vertex &v)
Definition: GeoUtils.h:56
LVL1::TrigT1CaloDefs::numOfJetThresholds
static const unsigned int numOfJetThresholds
Definition: TrigT1CaloDefs.h:125
TrigConf::L1Menu
L1 menu configuration.
Definition: L1Menu.h:28
LVL1::RecJetRoI::RecJetRoI
RecJetRoI()
Definition: RecJetRoI.h:43
yodamerge_tmp.scale
scale
Definition: yodamerge_tmp.py:138
LVL1::RecJetRoI::m_version
int m_version
Store the RoI format version.
Definition: RecJetRoI.h:137
LVL1::RecJetRoI::m_roiWord
unsigned long int m_roiWord
this is the actual format of the data sent from the LVL1 hardware.
Definition: RecJetRoI.h:131
LVL1::RecJetRoI::coord
CoordinateRange coord() const
returns the CoordinateRange.
Definition: RecJetRoI.cxx:348
TrigConf
Forward iterator to traverse the main components of the trigger configuration.
Definition: Config.h:22
LVL1::CoordinateRange
CoordinateRange class declaration.
Definition: CoordinateRange.h:36
LVL1::RecJetRoI::localcoord
virtual unsigned int localcoord() const
returns local coordinate within frame
Definition: RecJetRoI.cxx:273
LVL1::RecJetRoI::windowSize
unsigned int windowSize(unsigned int thresh) const
returns the size of the window.
Definition: RecJetRoI.cxx:390
LVL1::RecJetRoI::etLarge
virtual unsigned int etLarge() const
returns roi ET in larger cluster.
Definition: RecJetRoI.cxx:282
CaloInfo.h
LVL1::RecJetRoI::constructRun1
void constructRun1(const std::vector< TrigConf::TriggerThreshold * > *caloThresholds)
The "construct" calls unpack the RoIWord and copy information about the passed thresholds from the ve...
Definition: RecJetRoI.cxx:90
TrigConf::JetWindowSize::LARGE
@ LARGE
Definition: TriggerThresholdValue.h:17
JetThresholdValue.h
TriggerThreshold.h
TriggerThresholdValue.h
JEPRoIDecoder.h
LVL1::RecJetRoI::m_windowSize
std::map< unsigned int, unsigned int > m_windowSize
Definition: RecJetRoI.h:148
trigbs_pickEvents.num
num
Definition: trigbs_pickEvents.py:76
LVL1::RecJetRoI::isForwardJet
bool isForwardJet() const
returns true if the RoI is a forward jet RoI.
Definition: RecJetRoI.cxx:413
TrigConf::JetWindowSize::SMALL
@ SMALL
Definition: TriggerThresholdValue.h:17
LVL1::RecJetRoI::passedThreshold
bool passedThreshold(unsigned int thresholdNumber) const
returns TRUE if threshold number threshold_number has been passed by this ROI.
Definition: RecJetRoI.cxx:320
LVL1::TrigT1CaloDefs::numOfJetCMXThresholds
static const unsigned int numOfJetCMXThresholds
Definition: TrigT1CaloDefs.h:133
threshold
Definition: chainparser.cxx:74
TrigConf::CaloInfo::globalJetScale
float globalJetScale() const
Definition: CaloInfo.h:44
query_example.col
col
Definition: query_example.py:7
LVL1::RecJetRoI::isValidThreshold
bool isValidThreshold(unsigned int thresh) const
returns true if thresh is a valid threshold number
Definition: RecJetRoI.cxx:400
L1DataDef.h
LVL1::RecJetRoI::crate
virtual unsigned int crate() const
returns JEP crate number
Definition: RecJetRoI.cxx:257
ConvertOldUJHistosToNewHistos.jetType
string jetType
Definition: ConvertOldUJHistosToNewHistos.py:121
LVL1::RecJetRoI::roiWord
virtual unsigned int roiWord() const
returns roi word
Definition: RecJetRoI.cxx:239
TrigConf::JetThresholdValue
Definition: JetThresholdValue.h:12
LVL1::RecJetRoI::m_thresholdMask
unsigned long int m_thresholdMask
Information on trigger thresholds passed by RoI.
Definition: RecJetRoI.h:145
LVL1::RecJetRoI::constructRun3
void constructRun3(const TrigConf::L1Menu *const l1menu)
Definition: RecJetRoI.cxx:201
LVL1::RecJetRoI::operator=
RecJetRoI & operator=(RecJetRoI const &obj)
Definition: RecJetRoI.cxx:65
TrigConf::TriggerThresholdValue::caloInfo
const CaloInfo & caloInfo() const
Definition: TriggerThresholdValue.cxx:35
python.XMLReader.l1menu
l1menu
Definition: XMLReader.py:73
LARGE
@ LARGE
Definition: sTGCenumeration.h:40
LVL1::RecJetRoI::eta
virtual double eta() const
returns eta coord of ROI
Definition: RecJetRoI.cxx:253
LVL1::RecJetRoI::frame
virtual unsigned int frame() const
returns RoI frame number
Definition: RecJetRoI.cxx:265
L1Menu.h
python.PyAthena.obj
obj
Definition: PyAthena.py:135
LVL1::TrigT1CaloDefs::numOfFwdJetThresholds
static const unsigned int numOfFwdJetThresholds
Definition: TrigT1CaloDefs.h:126
TrigConf::JetThresholdValue::thresholdValueCount
virtual int thresholdValueCount() const override
Definition: JetThresholdValue.cxx:22
RecJetRoI.h
LVL1::RecJetRoI::m_triggerThresholdValue
std::map< unsigned int, unsigned int > m_triggerThresholdValue
Definition: RecJetRoI.h:147
LVL1::TrigT1CaloDefs::Error
static const unsigned int Error
Definition: TrigT1CaloDefs.h:121
TrigConf::TriggerThresholdValue::window
unsigned int window() const
Definition: TriggerThresholdValue.h:49
LVL1::RecJetRoI::phi
virtual double phi() const
returns phi coord of ROI
Definition: RecJetRoI.cxx:243