ATLAS Offline Software
Loading...
Searching...
No Matches
RecEmTauRoI.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4/***************************************************************************
5 RecEmTauRoI.cxx - description
6 -------------------
7 begin : Mon Jan 22 2001
8 email : moyse@heppch.ph.qmw.ac.uk
9***************************************************************************/
10
11
12// STL include(s):
13#include <cmath>
14
15// Trigger config includes:
21#include "TrigConfData/L1Menu.h"
22
23// Local include(s):
26
27using namespace std;
28using namespace TrigConf;
29
32LVL1::RecEmTauRoI::RecEmTauRoI( unsigned int RoIWord,
33 const std::vector<TriggerThreshold *> *caloThresholds)
34 : m_roiWord(RoIWord),
37 m_coordRange(m_decoder->coordinate(m_roiWord))
38{
40 this->constructRun1(caloThresholds);
41 }
44 {
45 this->constructRun2(caloThresholds);
46 }
47 else
48 {
51 m_isolationMask.clear();
52 m_emIsolation.clear();
53 m_hadIsolation.clear();
54 m_hadCoreIsolation.clear();
55 m_thresholdType.clear();
56 }
57}
58
59LVL1::RecEmTauRoI::RecEmTauRoI(unsigned int RoIWord,
60 const TrigConf::L1Menu *const l1menu) :
61 m_roiWord(RoIWord),
64 m_coordRange(m_decoder->coordinate(m_roiWord))
65{
66 constructRun3(l1menu);
67}
68
69// written copy constructor
83
84// written assignment operator
104
108
118
120 const std::vector<TriggerThreshold *> *caloThresholds)
121{
122
123 m_thresholdMask = m_roiWord & 0xffff;
124
126 m_isolationMask.clear();
127 m_emIsolation.clear();
128 m_hadIsolation.clear();
129 m_hadCoreIsolation.clear();
130 m_thresholdType.clear();
131
132 const vector<unsigned int> passed_thresholds =
133 m_decoder->thresholdsPassed(m_roiWord);
134
135 // Copy the thresholds into a map - makes matching up the passed ones very easy
136 std::map<int, TriggerThreshold *> thrMap;
137
138 for (std::vector<TriggerThreshold *>::const_iterator it =
139 caloThresholds->begin();
140 it != caloThresholds->end(); ++it)
141 {
142 if ((*it)->type() == L1DataDef::typeAsString(L1DataDef::EM) ||
143 (*it)->type() == L1DataDef::typeAsString(L1DataDef::TAU))
144 {
145 int num = (*it)->thresholdNumber();
146 thrMap.insert(std::map<int, TriggerThreshold *>::value_type(num, (*it)));
147 }
148 }
149
150 //
151 // Extract the properties of the passed thresholds:
152 //
153
154 int ieta = int((m_coordRange.etaRange().min() + 0.025) / 0.1) +
155 ((m_coordRange.etaRange().min() + 0.025 > 0) ? 0 : -1);
156 int iphi = int((m_coordRange.phiRange().min() + 0.025) * 32 / M_PI);
157
158 for (vector<unsigned int>::const_iterator itp = passed_thresholds.begin();
159 itp != passed_thresholds.end(); ++itp)
160 {
161 std::map<int, TriggerThreshold *>::const_iterator thr =
162 thrMap.find(*itp - 1);
163 if (thr != thrMap.end())
164 {
166 thr->second->triggerThresholdValue(ieta, iphi);
167 ClusterThresholdValue *ctv = dynamic_cast<ClusterThresholdValue *>(ttv);
168 if (ctv)
169 {
170 m_triggerThresholdValue.insert(std::map<int, unsigned int>::value_type(
171 *itp, ctv->thresholdValueCount()));
172 m_emIsolation.insert(std::map<int, unsigned int>::value_type(
173 *itp, ctv->emIsolationCount()));
174 m_hadIsolation.insert(std::map<int, unsigned int>::value_type(
175 *itp, ctv->hadIsolationCount()));
176 m_hadCoreIsolation.insert(
177 std::map<int, unsigned int>::value_type(*itp, ctv->hadVetoCount()));
181 m_thresholdType.insert(
182 std::map<int, TrigT1CaloDefs::ClusterAlgorithm>::value_type(*itp,
183 type));
184 }
185 } // end "found threshold in map"
186 } // end loop through passed thresholds
187
188 return;
189}
190
195void LVL1::RecEmTauRoI::constructRun2(const std::vector<TriggerThreshold *> *caloThresholds)
196{
197
198 m_thresholdMask = 0;
200 m_isolationMask.clear();
201 m_emIsolation.clear();
202 m_hadIsolation.clear();
203 m_hadCoreIsolation.clear();
204 m_thresholdType.clear();
205
206 std::string triggerType =
209
210 int ieta = int((m_coordRange.etaRange().min() + 0.025) / 0.1) +
211 ((m_coordRange.etaRange().min() + 0.025 > 0) ? 0 : -1);
212 int iphi = int((m_coordRange.phiRange().min() + 0.025) * 32 / M_PI);
213
214 unsigned int isolWord = isolation();
215
216 // Iterate through vector of thresholds and see which ones this RoI satisfies
217 for (std::vector<TriggerThreshold *>::const_iterator it =
218 caloThresholds->begin();
219 it != caloThresholds->end(); ++it) {
220 if ((*it)->type() == triggerType) {
221 // Does it satisfy this one?
222 // Start by extracting threshold values
223 TriggerThresholdValue *ttv = (*it)->triggerThresholdValue(ieta, iphi);
224 ClusterThresholdValue *ctv = dynamic_cast<ClusterThresholdValue *>(ttv);
225 if (ctv) {
226 float scale = ctv->caloInfo().globalEmScale();
227 unsigned int etCut = ctv->ptcut();
228 unsigned int threshold = etCut * scale;
229 unsigned int isolMask = ctv->isolationMask();
230
231 bool isolationPassed = true;
232 for (unsigned int bit = 0; bit < TrigT1CaloDefs::numOfIsolationBits;
233 ++bit)
234 if ((isolMask & (1 << bit)) && !(isolWord & (1 << bit)))
235 isolationPassed = false;
236
237 if (et() > threshold && isolationPassed) {
238 int num = (*it)->thresholdNumber();
240 std::map<int, unsigned int>::value_type(num, etCut));
241 m_isolationMask.insert(
242 std::map<int, unsigned int>::value_type(num, isolMask));
246 m_thresholdType.insert(
247 std::map<int, TrigT1CaloDefs::ClusterAlgorithm>::value_type(
248 num, type));
249 m_thresholdMask |= (1 << num);
250 } // passes cuts
251 } // ClusterThresholdValue pointer valid
252 } // correct threshold type
253 } // Loop over thresholds
254}
255
257{
258 m_thresholdMask = 0;
260 m_isolationMask.clear();
261 m_emIsolation.clear();
262 m_hadIsolation.clear();
263 m_hadCoreIsolation.clear();
264 m_thresholdType.clear();
265
266 std::string triggerType = (m_type == TrigT1CaloDefs::EMRoIWordType ? "EM" : "TAU");
267
268 // get the integer eta value
269 // eta value of ROIs goes in steps of 0.1 and on the negative side 1 is subtracted to avoid overlap at 0
270 // (copied from constructRun2)
271 int ieta = int((m_coordRange.etaRange().min() + 0.025) / 0.1) +
272 ((m_coordRange.etaRange().min() + 0.025 > 0) ? 0 : -1);
273
274 unsigned int isolWord = RecEmTauRoI::isolation();
275
276 // Iterate through the configured thresholds and see which ones this RoI satisfies
277 for (const shared_ptr<TrigConf::L1Threshold> &thr : l1menu->thresholds(triggerType))
278 {
279 // Start by extracting threshold values
280 auto caloThr = dynamic_cast<TrigConf::L1Threshold_Calo*>(thr.get());
281 if (!caloThr)
282 {
283 continue;
284 }
285
286 // test eT
287 unsigned int etCut = std::round(caloThr->thrValue(ieta)); // threshold value in GeV (integer for legacy thr)
288 unsigned int etCounts = caloThr->thrValueCounts(ieta); // threshold counts (threshold value * emscale)
289 bool eTPassed = (RecEmTauRoI::et() > etCounts);
290
291 // test isolation
292 unsigned int isolMask = 0;
293 if (triggerType == "EM")
294 {
295 auto emThr = dynamic_cast<TrigConf::L1Threshold_EM*>(thr.get());
296 if (emThr)
297 {
298 isolMask = emThr->isolationMask(ieta);
299 }
300 }
301 else if (triggerType == "TAU")
302 {
303 auto tauThr = dynamic_cast<TrigConf::L1Threshold_TAU*>(thr.get());
304 if (tauThr)
305 {
306 isolMask = tauThr->isolationMask();
307 }
308 }
309 bool isolationPassed = true;
310 for (unsigned int bit = 0; bit < TrigT1CaloDefs::numOfIsolationBits; ++bit)
311 {
312 if ((isolMask & (1 << bit)) && !(isolWord & (1 << bit)))
313 {
314 isolationPassed = false;
315 }
316 }
317
318 if (eTPassed && isolationPassed)
319 {
320 int num = thr->mapping();
321 m_triggerThresholdValue[num] = etCut;
322 m_isolationMask[num] = isolMask;
324 m_thresholdMask |= (1 << num);
325 } // passes cuts
326 } // Loop over thresholds
327}
328
329unsigned int LVL1::RecEmTauRoI::roiWord() const { return m_roiWord; }
330
333{
334
335 double roiPhi = m_coordRange.phi();
336 if (roiPhi > M_PI)
337 roiPhi -= 2 * M_PI;
338 return roiPhi;
339}
340
342double LVL1::RecEmTauRoI::eta() const { return m_coordRange.eta(); }
343
345unsigned int LVL1::RecEmTauRoI::crate() const { return m_decoder->crate(m_roiWord); }
346
348unsigned int LVL1::RecEmTauRoI::module() const
349{
350 return m_decoder->module(m_roiWord);
351}
352
354unsigned int LVL1::RecEmTauRoI::fpga() const { return m_decoder->chip(m_roiWord); }
355
358{
359 return m_decoder->localcoord(m_roiWord);
360}
361
363unsigned int LVL1::RecEmTauRoI::et() const { return m_decoder->et(m_roiWord); }
364
367{
368
369 return m_decoder->isolationWord(m_roiWord);
370}
371
374
378
381bool LVL1::RecEmTauRoI::passedThreshold(unsigned int threshold_number) const
382{
383 if (this->isValidThreshold(threshold_number)) {
384 return ((1 << threshold_number) & m_thresholdMask) != 0;
385 }
386 return false;
387}
388
393
395std::vector<unsigned int> *
397{
398 std::vector<unsigned int> *newVec = new std::vector<unsigned int>;
399
400 unsigned int nThresh = TrigT1CaloDefs::numOfCPThresholds;
405
406 for (unsigned int iTh = 0; iTh <= nThresh; ++iTh) {
407 std::map<int, unsigned int>::const_iterator it =
408 m_triggerThresholdValue.find(iTh);
409 if (it != m_triggerThresholdValue.end())
410 newVec->push_back(iTh);
411 }
412
413 return newVec;
414}
415
418unsigned int LVL1::RecEmTauRoI::triggerThreshold(const unsigned int thresh) const
419{
420
421 std::map<int, unsigned int>::const_iterator it =
422 m_triggerThresholdValue.find(thresh);
423 if (it != m_triggerThresholdValue.end())
424 {
425 return (it->second);
426 }
428}
429
432unsigned int LVL1::RecEmTauRoI::isolationMask(const unsigned int thresh) const
433{
434
436 return 0;
437
438 std::map<int, unsigned int>::const_iterator it = m_isolationMask.find(thresh);
439 if (it != m_isolationMask.end())
440 {
441 return (it->second);
442 }
444}
445
448unsigned int LVL1::RecEmTauRoI::emIsolation(const unsigned int thresh) const
449{
450
452 return 0;
453
454 std::map<int, unsigned int>::const_iterator it = m_emIsolation.find(thresh);
455 if (it != m_emIsolation.end())
456 {
457 return (it->second);
458 }
460}
461
464unsigned int LVL1::RecEmTauRoI::hadIsolation(const unsigned int thresh) const
465{
467 return 0;
468
470 if (it != m_hadIsolation.end())
471 {
472 return (it->second);
473 }
475}
476
479unsigned int LVL1::RecEmTauRoI::hadCoreIsolation(const unsigned int thresh) const
480{
481
483 return 0;
484
486 if (it != m_hadCoreIsolation.end())
487 {
488 return (it->second);
489 }
491}
492
494bool LVL1::RecEmTauRoI::isValidThreshold(const unsigned int thresh) const
495{
497 {
498 return (thresh <= TrigT1CaloDefs::numOfCPThresholds);
499 }
501 {
502 return (thresh <= TrigT1CaloDefs::numOfEMCMXThresholds);
503 }
505 {
506 return (thresh <= TrigT1CaloDefs::numOfTauCMXThresholds);
507 }
508 return false;
509}
510
514LVL1::RecEmTauRoI::thresholdType(const unsigned int thresh) const
515{
516
518 m_thresholdType.find(thresh);
519 if (it != m_thresholdType.end())
520 {
521 return it->second;
522 }
524}
#define M_PI
float et(const xAOD::jFexSRJetRoI *j)
#define min(a, b)
Definition cfImp.cxx:40
A level 1 calorimeter trigger conversion service: returns the Coordinate represented by a RoI word.
CoordinateRange class declaration.
This class defines the reconstructed em/tau hadron ROI.
Definition RecEmTauRoI.h:44
virtual unsigned int isolation() const
returns roi isolation results (Run 2 only)
virtual double eta() const
returns eta coord of ROI
unsigned long int m_roiWord
this is the actual format of the data sent from the LVL1 hardware.
virtual TrigT1CaloDefs::RoIType roiType() const
returns roi type (EM = TrigT1CaloDefs::EMRoIWordType, Tau = TrigT1CaloDefs::TauRoIWordType,...
CoordinateRange m_coordRange
this contains the coordinate range worked out from the RoIWord hardware coord (i.e.
void constructRun3(const TrigConf::L1Menu *const l1menu)
TrigT1CaloDefs::ClusterAlgorithm thresholdType(unsigned int thresh) const
returns the type of the threshold, which is either EMAlg or TauAlg.
void constructRun2(const std::vector< TrigConf::TriggerThreshold * > *caloThresholds)
Content of RoI word different in Run 2.
unsigned int hadIsolation(unsigned int thresh) const
returns the value of the hadronic layer isolation ring for the threshold passed.
void constructRun1(const std::vector< TrigConf::TriggerThreshold * > *caloThresholds)
The "construct" call unpacks the RoIWord and copies information about the passed thresholds from the ...
std::map< int, unsigned int > m_hadIsolation
virtual unsigned int et() const
returns roi ET (Run 2 only)
virtual unsigned int crate() const
returns CP crate number
std::map< int, unsigned int > m_emIsolation
unsigned int triggerThreshold(unsigned int thresh) const
returns the value of the trigger threshold for the threshold passed.
std::map< int, TrigT1CaloDefs::ClusterAlgorithm > m_thresholdType
virtual unsigned int roiWord() const
returns roi word
std::map< int, unsigned int > m_hadCoreIsolation
unsigned int hadCoreIsolation(unsigned int thresh) const
returns the value of the hadronic layer core isolation for the threshold passed.
unsigned long int m_thresholdMask
bool isValidThreshold(unsigned int thresh) const
returns true if thresh is a valid threshold number
unsigned int isolationMask(unsigned int thresh) const
returns the isolation bits required for the threshold passed (Run 2)
virtual unsigned int fpga() const
returns FPGA number
CPRoIDecoder * m_decoder
Used for decoding RoI word.
unsigned int thresholdPattern() const
returns bitmask of passed thresholds
TrigT1CaloDefs::RoIType m_type
Stored properties of the RoI:
bool passedThreshold(unsigned int threshold_number) const
returns TRUE if threshold number threshold_number has been passed by this ROI.
virtual double phi() const
returns phi coord of ROI
virtual unsigned int localcoord() const
returns local coordinate within FPGA
std::vector< unsigned int > * thresholdsPassed() const
returns a vector of thresholds passed.
std::map< int, unsigned int > m_triggerThresholdValue
std::map< int, unsigned int > m_isolationMask
RecEmTauRoI & operator=(const RecEmTauRoI &obj)
unsigned int emIsolation(unsigned int thresh) const
returns the value of the em isolation ring for the threshold passed.
const CoordinateRange & coord() const
returns the CoordinateRange.
virtual unsigned int module() const
returns CPM number
static const unsigned int numOfCPThresholds
static const unsigned int Error
static const unsigned int numOfTauCMXThresholds
static const unsigned int numOfIsolationBits
static const unsigned int numOfEMCMXThresholds
float globalEmScale() const
Definition CaloInfo.h:43
virtual int thresholdValueCount() const override
static std::string & typeAsString(TriggerType tt)
Definition L1DataDef.h:53
L1 menu configuration.
Definition L1Menu.h:28
const std::string & type() const
STL iterator class.
Forward iterator to traverse the main components of the trigger configuration.
Definition Config.h:22
STL namespace.