ATLAS Offline Software
Loading...
Searching...
No Matches
RecJetRoI.cxx
Go to the documentation of this file.
1// Copyright (C) 2002-2025 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
25using namespace std;
26using namespace TrigConf;
27
29LVL1::RecJetRoI::RecJetRoI( unsigned int RoIWord,
30 const std::vector<TriggerThreshold *> *caloThresholds) {
31
32 m_roiWord = RoIWord;
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
43LVL1::RecJetRoI::RecJetRoI( unsigned int RoIWord,
44 const TrigConf::L1Menu * const l1menu) :
45 m_roiWord(RoIWord),
47 m_version(m_decoder->jetRoIVersion(m_roiWord)),
48 m_coordRange(m_decoder->coordinate(m_roiWord))
49{
50 constructRun3(l1menu);
51}
52
53// copy constructor
62
63// assignment operator
66 if(this != &rhs) {
67 m_roiWord = rhs.m_roiWord;
68 delete m_decoder;
70 m_version = rhs.m_version;
75 }
76 return *this;
77}
78
80
88
90void LVL1::RecJetRoI::constructRun1(const std::vector<TriggerThreshold *> *caloThresholds)
91{
92
93 m_thresholdMask = m_roiWord & 0xfff;
94
95 std::string jetTriggerType = L1DataDef::typeAsString(L1DataDef::JET);
96 if (this->isForwardJet())
97 jetTriggerType =
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 {
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
155void
156LVL1::RecJetRoI::constructRun2(const std::vector<TriggerThreshold *> *caloThresholds)
157{
158
159 m_thresholdMask = 0;
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::typeAsString(L1DataDef::JET)) {
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());
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
200void
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 (const shared_ptr<TrigConf::L1Threshold> &thr : l1menu->thresholds("JET"))
212 {
213 // Does it satisfy this one?
214 // Start by extracting threshold values
215 auto jetThr = dynamic_cast<TrigConf::L1Threshold_JET*>(thr.get());
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
238unsigned int
240
242double
244{
245 double roiPhi = m_coordRange.phi();
246 if (roiPhi > M_PI)
247 roiPhi -= 2 * M_PI;
248 return roiPhi;
249}
250
252double
253LVL1::RecJetRoI::eta() const { return m_coordRange.eta(); }
254
256unsigned int
257LVL1::RecJetRoI::crate() const { return m_decoder->crate(m_roiWord); }
258
260unsigned int
261LVL1::RecJetRoI::module() const { return m_decoder->module(m_roiWord); }
262
264unsigned 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
272unsigned 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
281unsigned 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 =
289 for (; it != m_triggerThresholdValue.end(); ++it)
290 if (it->second > highest)
291 highest = it->second;
292 return highest;
293 }
294}
295
298unsigned 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 =
306 for (; it != m_triggerThresholdValue.end(); ++it)
307 if (it->second > highest)
308 highest = it->second;
309 return highest;
310 }
311}
312
314unsigned int
316
319bool
320LVL1::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
335bool
336LVL1::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
349
351std::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
378unsigned int
379LVL1::RecJetRoI::triggerThreshold(const unsigned int thresh) const {
381 m_triggerThresholdValue.find(thresh);
382 if (it != m_triggerThresholdValue.end()) {
383 return it->second;
384 }
386}
387
389unsigned int
390LVL1::RecJetRoI::windowSize(const unsigned int thresh) const {
392 if (it != m_windowSize.end()) {
393 return it->second;
394 }
396}
397
399bool
400LVL1::RecJetRoI::isValidThreshold(const unsigned int thresh) const
401{
402 if (!this->isForwardJet()) {
403 return (thresh <= TrigT1CaloDefs::numOfJetThresholds);
404 } else {
405 return (thresh <= TrigT1CaloDefs::numOfFwdJetThresholds);
406 }
407}
408
412bool
414{
415 if (m_version <= 1 && ((1 << 18) & m_roiWord))
416 return true;
417 return false;
418}
419
#define M_PI
Scalar eta() const
pseudorapidity method
CoordinateRange class declaration.
A level 1 calorimeter trigger conversion service: returns the Coordinate represented by a RoI word.
This class defines the reconstructed em/tau hadron ROI.
Definition RecJetRoI.h:39
bool passedFwdThreshold(unsigned int thresholdNumber) const
Same for forward jets.
unsigned int windowSize(unsigned int thresh) const
returns the size of the window.
void constructRun2(const std::vector< TrigConf::TriggerThreshold * > *caloThresholds)
construct call for Run 2 Jet RoIs
int m_version
Store the RoI format version.
Definition RecJetRoI.h:137
virtual unsigned int frame() const
returns RoI frame number
bool isValidThreshold(unsigned int thresh) const
returns true if thresh is a valid threshold number
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
virtual unsigned int etLarge() const
returns roi ET in larger cluster.
virtual unsigned int etSmall() const
returns roi ET in smaller cluster.
virtual unsigned int module() const
returns JEM number
unsigned int triggerThreshold(unsigned int thresh) const
returns the value of the trigger threshold for the threshold passed.
void constructRun3(const TrigConf::L1Menu *const l1menu)
CoordinateRange m_coordRange
this contains the coordinate range worked out from the RoIWord hardware coord (i.e.
Definition RecJetRoI.h:142
virtual double eta() const
returns eta coord of ROI
virtual unsigned int crate() const
returns JEP crate number
std::vector< unsigned int > thresholdsPassed() const
returns a vector of thresholds passed.
std::map< unsigned int, unsigned int > m_triggerThresholdValue
Definition RecJetRoI.h:147
virtual unsigned int roiWord() const
returns roi word
virtual double phi() const
returns phi coord of ROI
bool passedThreshold(unsigned int thresholdNumber) const
returns TRUE if threshold number threshold_number has been passed by this ROI.
JEPRoIDecoder * m_decoder
Used for decoding RoI word.
Definition RecJetRoI.h:134
virtual unsigned int localcoord() const
returns local coordinate within frame
std::map< unsigned int, unsigned int > m_windowSize
Definition RecJetRoI.h:148
unsigned int thresholdPattern() const
returns bitmask of passed thresholds
unsigned long int m_thresholdMask
Information on trigger thresholds passed by RoI.
Definition RecJetRoI.h:145
unsigned long int m_roiWord
this is the actual format of the data sent from the LVL1 hardware.
Definition RecJetRoI.h:131
const CoordinateRange & coord() const
returns the CoordinateRange.
bool isForwardJet() const
returns true if the RoI is a forward jet RoI.
RecJetRoI & operator=(RecJetRoI const &obj)
Definition RecJetRoI.cxx:65
static const unsigned int Error
static const unsigned int numOfJetCMXThresholds
static const unsigned int numOfJetThresholds
static const unsigned int numOfFwdJetThresholds
float globalJetScale() const
Definition CaloInfo.h:44
virtual JetWindowSize::Size windowSize() const override
virtual int thresholdValueCount() const override
static std::string & typeAsString(TriggerType tt)
Definition L1DataDef.h:53
L1 menu configuration.
Definition L1Menu.h:28
STL iterator class.
Forward iterator to traverse the main components of the trigger configuration.
Definition Config.h:22
STL namespace.