ATLAS Offline Software
jFEXSmallRJetAlgo.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 // jFEXSmallRJetAlgo - Algorithm for small R jet Algorithm in jFEX
6 // -------------------
7 // begin : 03 11 2020
8 // email : varsiha.sothilingam@cern.ch
9 //***************************************************************************
10 #include <vector>
11 #include "jFEXSmallRJetAlgo.h"
12 #include "L1CaloFEXSim/jTower.h"
14 
15 namespace LVL1{
16 
17 //Default Constructor
18 LVL1::jFEXSmallRJetAlgo::jFEXSmallRJetAlgo(const std::string& type, const std::string& name, const IInterface* parent):
20  {
21  declareInterface<IjFEXSmallRJetAlgo>(this);
22  }
23 
26 {
27 }
29 {
30  ATH_CHECK(m_jTowerContainerKey.initialize());
31 
32  return StatusCode::SUCCESS;
33 
34 }
35 
36 //calls container for TT
38 
39  m_jTowerContainer = SG::ReadHandle<jTowerContainer>(m_jTowerContainerKey);
40  if(! m_jTowerContainer.isValid()) {
41  ATH_MSG_ERROR("Could not retrieve jTowerContainer " << m_jTowerContainerKey.key());
42  return StatusCode::FAILURE;
43  }
44 
45  return StatusCode::SUCCESS;
46 }
47 
48 void LVL1::jFEXSmallRJetAlgo::setup(int inputTable[7][7], int inputTableDisplaced[7][7]) {
49 
50  for(int phi=0; phi<7; phi++) {
51  for (int eta=0; eta<7; eta++) {
52  m_jFEXalgoTowerID[phi][eta] = inputTable[6-phi][eta];
53  }
54  }
55 
56  for(int phi=0; phi<7; phi++) {
57  for (int eta=0; eta<7; eta++) {
58  m_jFEXalgoTowerID_displaced[phi][eta] = inputTableDisplaced[6-phi][eta];
59  }
60  }
61 }
62 
63 //Gets the ET for the TT. This ET is EM + HAD
64 unsigned int LVL1::jFEXSmallRJetAlgo::getTTowerET(unsigned int TTID ) const {
65  if(TTID == 0) {
66  return 0;
67  }
68 
69  if(m_map_Etvalues.find(TTID) != m_map_Etvalues.end()) {
70  return m_map_Etvalues.at(TTID).at(0);
71  }
72 
73  //we shouldn't arrive here
74  return 0;
75 }
76 
77 //this function calculates seed for a given TT
79 {
80 
81  for(int mphi = 1; mphi < 6; mphi++) {
82  for(int meta = 1; meta< 6; meta++) {
83 
84  int seedTotalET = 0;
85  int seedTotalET_displaced = 0;
86  for(int iphi = -1; iphi < 2; iphi++) {
87  for(int ieta = -1; ieta < 2; ieta++) {
88  //for that TT, build the seed
89  //here we sum TT ET to calculate seed
90  seedTotalET += getTTowerET(m_jFEXalgoTowerID [mphi + iphi][meta + ieta]);
91  seedTotalET_displaced += getTTowerET(m_jFEXalgoTowerID_displaced[mphi + iphi][meta + ieta]);
92  }
93  }
94  m_jFEXalgoSearchWindowSeedET[mphi -1][meta -1] = seedTotalET;
95  m_jFEXalgoSearchWindowSeedET_displaced[mphi -1][meta -1] = seedTotalET_displaced;
96  }
97  }
98 }
99 
100 
101 bool LVL1::jFEXSmallRJetAlgo::CalculateLM(int mymatrix[5][5]) {
102 
103  //here put the 24 conditions to determine if the TT seed is a local maxima.
104  int central_seed = mymatrix[2][2];
105  for (int iphi = 0; iphi < 5; iphi++) {
106  for (int ieta = 0; ieta < 5; ieta++) {
107  //avoid comparing central seed to itself
108  if ((ieta == 2) && (iphi == 2)) {
109  continue;
110  }
111  //strictly less than central
112  if( (iphi > ieta) || (iphi == 0 && ieta == 0) || (iphi == 1 && ieta == 1) ) {
113  if(central_seed < mymatrix[iphi][ieta]) {
114  return false;
115  }
116  }
117  //less than or equal to central
118  if((iphi < ieta) || (iphi == 3 && ieta == 3) || (iphi == 4 && ieta == 4)) {
119  if(central_seed <= mymatrix[iphi][ieta]) {
120  return false;
121  }
122  }
123  }
124  }
125 
126  return true;
127 }
128 
129 //check if central TT is a local maxima
131 
132  bool isCentralLM = CalculateLM(m_jFEXalgoSearchWindowSeedET) &&
133  ( getTTowerET(m_jFEXalgoTowerID[3][3]) >= getTTowerET(m_jFEXalgoTowerID[4][2]) || m_jFEXalgoSearchWindowSeedET[2][2] > m_jFEXalgoSearchWindowSeedET[3][1]);
134 
135  bool isDisplacedLM = CalculateLM(m_jFEXalgoSearchWindowSeedET_displaced) &&
136  ( getTTowerET(m_jFEXalgoTowerID[3][3]) > getTTowerET(m_jFEXalgoTowerID[2][4]) && m_jFEXalgoSearchWindowSeedET[2][2] == m_jFEXalgoSearchWindowSeedET[1][3]);
137 
138  if(isCentralLM || isDisplacedLM ){
139  calcSaturation();
140  return m_jFEXalgoSearchWindowSeedET[2][2] > seedThreshold;
141  }
142  return false;
143 }
144 
146  // only valid after calling buildSeeds() !
147  return m_jFEXalgoSearchWindowSeedET[2][2];
148 }
149 
150 
151 //in this clustering func, the central TT in jet is the parameters
153 
154  int SRJetClusterET = 0;
155  for(int nphi = -3; nphi< 4; nphi++) {
156  for(int neta = -3; neta< 4; neta++) {
157  int DeltaRSquared = std::pow(nphi,2)+std::pow(neta,2);
158  if(DeltaRSquared < 16) {
159  SRJetClusterET += getTTowerET(m_jFEXalgoTowerID[3+nphi][3+neta]);
160  }
161  }
162  }
163  return SRJetClusterET;
164 }
165 
167 
168  m_JetSaturation = false;
169  for(int nphi = -3; nphi< 4; nphi++) {
170  for(int neta = -3; neta< 4; neta++) {
171  int DeltaRSquared = std::pow(nphi,2)+std::pow(neta,2);
172  if(DeltaRSquared < 16) {
173  m_JetSaturation = m_JetSaturation || getTTowerSat(m_jFEXalgoTowerID[3+nphi][3+neta]);
174  }
175  }
176  }
177 }
178 
180  return m_JetSaturation;
181 }
182 
184  int SmallETRing = getSmallClusterET() - m_jFEXalgoSearchWindowSeedET[3][3];
185  return SmallETRing;
186 }
187 
189  return m_jFEXalgoTowerID[3][3];
190 }
191 
192 
193 void LVL1::jFEXSmallRJetAlgo::setFPGAEnergy(const std::unordered_map<int,std::vector<int> >& et_map){
194  m_map_Etvalues=et_map;
195 }
196 
197 //getter for tower saturation
198 bool LVL1::jFEXSmallRJetAlgo::getTTowerSat(unsigned int TTID ) {
199  if(TTID == 0) {
200  return false;
201  }
202 
203  const LVL1::jTower * tmpTower = m_jTowerContainer->findTower(TTID);
204  return tmpTower->getTowerSat();
205 }
206 
207 }// end of namespace LVL1
LVL1::jFEXSmallRJetAlgo::isSeedLocalMaxima
virtual bool isSeedLocalMaxima(int seedThreshold) override
Definition: jFEXSmallRJetAlgo.cxx:130
jFEXSmallRJetAlgo.h
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:67
LVL1::jFEXSmallRJetAlgo::getTTIDcentre
virtual unsigned int getTTIDcentre() const override
Definition: jFEXSmallRJetAlgo.cxx:188
LVL1::jFEXSmallRJetAlgo::getSmallETRing
virtual unsigned int getSmallETRing() const override
Definition: jFEXSmallRJetAlgo.cxx:183
LVL1::jFEXSmallRJetAlgo::setFPGAEnergy
virtual void setFPGAEnergy(const std::unordered_map< int, std::vector< int > > &et_map) override
Definition: jFEXSmallRJetAlgo.cxx:193
LVL1::jFEXSmallRJetAlgo::getSmallClusterET
virtual unsigned int getSmallClusterET() const override
Definition: jFEXSmallRJetAlgo.cxx:152
LVL1
eFexTowerBuilder creates xAOD::eFexTowerContainer from supercells (LATOME) and triggerTowers (TREX) i...
Definition: ICMMCPHitsCnvTool.h:18
LVL1::jFEXSmallRJetAlgo::~jFEXSmallRJetAlgo
virtual ~jFEXSmallRJetAlgo()
Destructor.
Definition: jFEXSmallRJetAlgo.cxx:25
LVL1::jFEXSmallRJetAlgo::getTTowerSat
bool getTTowerSat(unsigned int TTID)
Definition: jFEXSmallRJetAlgo.cxx:198
LVL1::jFEXSmallRJetAlgo::getTTowerET
virtual unsigned int getTTowerET(unsigned int TTID) const override
Definition: jFEXSmallRJetAlgo.cxx:64
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
LVL1::jFEXSmallRJetAlgo::initialize
virtual StatusCode initialize() override
standard Athena-Algorithm method
Definition: jFEXSmallRJetAlgo.cxx:28
LVL1::jFEXSmallRJetAlgo::safetyTest
virtual StatusCode safetyTest() override
Definition: jFEXSmallRJetAlgo.cxx:37
LVL1::jTower::getTowerSat
bool getTowerSat() const
Definition: jTower.h:61
LVL1::jFEXSmallRJetAlgo::CalculateLM
bool CalculateLM(int mymatrix[5][5])
Definition: jFEXSmallRJetAlgo.cxx:101
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
LVL1::jFEXSmallRJetAlgo::jFEXSmallRJetAlgo
jFEXSmallRJetAlgo(const std::string &type, const std::string &name, const IInterface *parent)
Constructors.
Definition: jFEXSmallRJetAlgo.cxx:18
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
LVL1::jFEXSmallRJetAlgo::buildSeeds
virtual void buildSeeds() override
Definition: jFEXSmallRJetAlgo.cxx:78
TrigConf::name
Definition: HLTChainList.h:35
jTowerContainer.h
LVL1::jFEXSmallRJetAlgo::getSRjetSat
virtual bool getSRjetSat() const override
Definition: jFEXSmallRJetAlgo.cxx:179
LVL1::jFEXSmallRJetAlgo::calcSaturation
void calcSaturation()
Definition: jFEXSmallRJetAlgo.cxx:166
LVL1::jFEXSmallRJetAlgo::setup
virtual void setup(int inputTable[7][7], int inputTableDisplaced[7][7]) override
Definition: jFEXSmallRJetAlgo.cxx:48
LVL1::jTower
The jTower class is an interface object for jFEX trigger algorithms The purposes are twofold:
Definition: jTower.h:36
AthAlgTool
Definition: AthAlgTool.h:26
jTower.h
pow
constexpr int pow(int base, int exp) noexcept
Definition: ap_fixedTest.cxx:15
LVL1::jFEXSmallRJetAlgo::getSeedET
virtual unsigned int getSeedET() const override
Definition: jFEXSmallRJetAlgo.cxx:145