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