ATLAS Offline Software
jFEXsumETAlgo.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 // jFEXsumETAlgo - Algorithm for Sum ET Algorithm in jFEX
6 // -------------------
7 // begin : 12 05 2021
8 // email : Sergi.Rodriguez@cern.ch
9 //***************************************************************************
10 #include <iostream>
11 #include <vector>
12 #include <stdio.h>
13 #include <math.h>
15 #include "L1CaloFEXSim/jTower.h"
21 #include "StoreGate/StoreGateSvc.h"
23 
24 namespace LVL1{
25 
26 //Default Constructor
27 LVL1::jFEXsumETAlgo::jFEXsumETAlgo(const std::string& type, const std::string& name, const IInterface* parent): AthAlgTool(type, name, parent) {
28  declareInterface<IjFEXsumETAlgo>(this);
29 }
30 
33 }
34 
36  ATH_CHECK(m_jTowerContainerKey.initialize());
37  return StatusCode::SUCCESS;
38 }
39 
40 //calls container for TT
42 
43  m_jTowerContainer = SG::ReadHandle<jTowerContainer>(m_jTowerContainerKey);
44  if(! m_jTowerContainer.isValid()) {
45  ATH_MSG_ERROR("Could not retrieve jTowerContainer " << m_jTowerContainerKey.key());
46  return StatusCode::FAILURE;
47  }
48 
49  return StatusCode::SUCCESS;
50 }
51 
53  m_FPGA.clear();
54  m_FPGA_phi02.clear();
55  m_FPGA_fcal.clear();
56  return StatusCode::SUCCESS;
57 }
58 
59 //
61 
62  ATH_MSG_DEBUG("---------------- jFEXsumETAlgo::setup ----------------");
64  for(int iphi=0;iphi<FEXAlgoSpaceDefs::jFEX_algoSpace_height;iphi++){
65  for(int ieta=8;ieta<16;ieta++){
66  m_FPGA[iphi].push_back(FPGA[iphi][ieta]);
67  }
68  }
69 }
70 
72 
73  ATH_MSG_DEBUG("---------------- jFEXsumETAlgo::setup ----------------");
75  for(int iphi=0;iphi<FEXAlgoSpaceDefs::jFEX_algoSpace_height;iphi++){
76  for(int ieta=8;ieta<17;ieta++){
77  m_FPGA[iphi].push_back(FPGA[iphi][ieta]);
78  }
79  }
80  m_FPGA_phi02.resize(16);
81  for(int iphi=0;iphi<16;iphi++){
82  for(int ieta=17;ieta<21;ieta++){
83  m_FPGA_phi02[iphi].push_back(FPGA[iphi][ieta]);
84  }
85  }
86  m_FPGA_fcal.resize(8);
87  for(int iphi=0;iphi<8;iphi++){
88  for(int ieta=21;ieta<FEXAlgoSpaceDefs::jFEX_wide_algoSpace_width;ieta++){
89  m_FPGA_fcal[iphi].push_back(FPGA[iphi][ieta]);
90  }
91  }
92 
93 }
94 
95 //this function calculates SumET for the barrel region
97 {
98  ATH_MSG_DEBUG("---------------- jFEXsumETAlgo::buildBarrelSumET ----------------");
99 
100  m_SumET.clear();
101  m_SumET.resize(8,0);
102  m_SumETSat.clear();
103  m_SumETSat.resize(8,0);
104 
105  for(uint iphi=0;iphi<m_FPGA.size();iphi++){
106  for(uint ieta=0;ieta<m_FPGA[iphi].size();ieta++){
107  m_SumET[ieta]+=getTTowerET(m_FPGA[iphi][ieta]);
108  m_SumETSat[ieta] = m_SumETSat[ieta] || getTTowerSat(m_FPGA[iphi][ieta]);
109  }
110  }
111 
112 }
113 
114 //this function calculates SumET for the forward region
116 {
117  ATH_MSG_DEBUG("---------------- jFEXsumETAlgo::buildFWDSumET ----------------");
118 
119  m_SumET.clear();
120  m_SumET.resize(14,0);
121  m_SumETSat.clear();
122  m_SumETSat.resize(14,0);
123 
124  // ECal with resolution of 0.1x0.1
125  for(uint iphi=0;iphi<m_FPGA.size();iphi++){
126  for(uint ieta=0;ieta<m_FPGA[iphi].size();ieta++){
127  m_SumET[ieta]+=getTTowerET(m_FPGA[iphi][ieta]);
128  m_SumETSat.at(ieta) = m_SumETSat.at(ieta) || getTTowerSat(m_FPGA[iphi][ieta]);
129  }
130  }
131 
132  // ECal with resolution of 0.2x0.2
133  for(uint iphi=0;iphi<m_FPGA_phi02.size();iphi++){
134  for(uint ieta=0;ieta<m_FPGA_phi02[iphi].size();ieta++){
135  m_SumET[ieta+9]+=getTTowerET(m_FPGA_phi02[iphi][ieta]);
136  m_SumETSat.at(ieta+9) = m_SumETSat.at(ieta+9) || getTTowerSat(m_FPGA_phi02[iphi][ieta]);
137  }
138  }
139 
140  // Fcal
141  for(uint iphi=0;iphi<m_FPGA_fcal.size();iphi++){
142  for(uint ieta=0;ieta<m_FPGA_fcal[iphi].size();ieta++){
143  m_SumET[13]+=getTTowerET(m_FPGA_fcal[iphi][ieta]); //All FCAL is considered one slice due to the non-aligment of the FCal layers
144  m_SumETSat.at(13) = m_SumETSat.at(13) || getTTowerSat(m_FPGA_fcal[iphi][ieta]);
145  }
146  }
147 
148 }
149 
151 {
152  uint max = m_SumET.size() > (bin + 1) ? bin : m_SumET.size();
153  m_SumlowEta = 0;
154  m_SumlowEtaSat = 0;
155  for(uint ieta=0;ieta<max;ieta++){
156  m_SumlowEta+=m_SumET.at(ieta);
157  m_SumlowEtaSat = m_SumlowEtaSat || m_SumETSat.at(ieta);
158  }
159  return {m_SumlowEta,m_SumlowEtaSat};
160 }
161 
162 
163 
165 {
166  uint min = m_SumET.size() > (bin + 1) ? bin : m_SumET.size();
167  m_SumhighEta = 0;
168  m_SumhighEtaSat = 0;
169  for(uint ieta=min;ieta<m_SumET.size();ieta++){
170  m_SumhighEta+=m_SumET.at(ieta);
171  m_SumhighEtaSat = m_SumhighEtaSat || m_SumETSat.at(ieta);
172  }
173  return {m_SumhighEta,m_SumhighEtaSat};
174 }
175 
176 
177 //getter for tower saturation
178 bool LVL1::jFEXsumETAlgo::getTTowerSat(unsigned int TTID ) {
179  if(TTID == 0) {
180  return false;
181  }
182 
183  const LVL1::jTower * tmpTower = m_jTowerContainer->findTower(TTID);
184  return tmpTower->getTowerSat();
185 }
186 
187 //Gets the ET for the TT. This ET is EM + HAD
188 int LVL1::jFEXsumETAlgo::getTTowerET(unsigned int TTID ) {
189  if(TTID == 0) {
190  return 0;
191  }
192 
193  auto itr = m_map_Etvalues.find(TTID);
194  if( itr == m_map_Etvalues.end()) {
195  return 0;
196  }
197 
198  return (itr->second).at(1);
199 }
200 
201 
202 void LVL1::jFEXsumETAlgo::setFPGAEnergy(std::unordered_map<int,std::vector<int> > et_map){
203  m_map_Etvalues=et_map;
204 }
205 
206 
207 }// end of namespace LVL1
LVL1::jFEXsumETAlgo::reset
virtual StatusCode reset() override
Definition: jFEXsumETAlgo.cxx:52
max
#define max(a, b)
Definition: cfImp.cxx:41
LVL1::FEXAlgoSpaceDefs::jFEX_thin_algoSpace_width
constexpr static int jFEX_thin_algoSpace_width
Definition: FEXAlgoSpaceDefs.h:26
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
LVL1::jFEXsumETAlgo::~jFEXsumETAlgo
virtual ~jFEXsumETAlgo()
Destructor.
Definition: jFEXsumETAlgo.cxx:32
bin
Definition: BinsDiffFromStripMedian.h:43
LVL1::FEXAlgoSpaceDefs::jFEX_algoSpace_height
constexpr static int jFEX_algoSpace_height
Definition: FEXAlgoSpaceDefs.h:27
LVL1::jFEXsumETAlgo::initialize
virtual StatusCode initialize() override
standard Athena-Algorithm method
Definition: jFEXsumETAlgo.cxx:35
LVL1
eFexTowerBuilder creates xAOD::eFexTowerContainer from supercells (LATOME) and triggerTowers (TREX) i...
Definition: ICMMCPHitsCnvTool.h:18
LVL1::jFEXsumETAlgo::setup
virtual void setup(int FPGA[FEXAlgoSpaceDefs::jFEX_algoSpace_height][FEXAlgoSpaceDefs::jFEX_thin_algoSpace_width]) override
Definition: jFEXsumETAlgo.cxx:60
LVL1::jTower::getTowerSat
bool getTowerSat() const
Definition: jTower.h:65
AthAlgorithm.h
LVL1::jFEXsumETAlgo::getETupperEta
virtual std::tuple< int, bool > getETupperEta(uint bin) override
Definition: jFEXsumETAlgo.cxx:164
LVL1::jFEXsumETAlgo::getETlowerEta
virtual std::tuple< int, bool > getETlowerEta(uint bin) override
Definition: jFEXsumETAlgo.cxx:150
uint
unsigned int uint
Definition: LArOFPhaseFill.cxx:20
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
jFEXsumETAlgo.h
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
LVL1::jFEXsumETAlgo::getTTowerET
virtual int getTTowerET(unsigned int TTID=0) override
Definition: jFEXsumETAlgo.cxx:188
LVL1::FEXAlgoSpaceDefs::jFEX_wide_algoSpace_width
constexpr static int jFEX_wide_algoSpace_width
Definition: FEXAlgoSpaceDefs.h:25
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::jFEXsumETAlgo::setFPGAEnergy
virtual void setFPGAEnergy(std::unordered_map< int, std::vector< int > > et_map) override
Definition: jFEXsumETAlgo.cxx:202
FEXAlgoSpaceDefs.h
TrigConf::name
Definition: HLTChainList.h:35
min
#define min(a, b)
Definition: cfImp.cxx:40
jTowerContainer.h
LVL1::jFEXsumETAlgo::jFEXsumETAlgo
jFEXsumETAlgo(const std::string &type, const std::string &name, const IInterface *parent)
Constructors.
Definition: jFEXsumETAlgo.cxx:27
CaloCellContainer.h
LVL1::jFEXsumETAlgo::buildFWDSumET
virtual void buildFWDSumET() override
Definition: jFEXsumETAlgo.cxx:115
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
LVL1::jFEXsumETAlgo::getTTowerSat
bool getTTowerSat(unsigned int TTID)
Definition: jFEXsumETAlgo.cxx:178
LVL1::jTower
The jTower class is an interface object for jFEX trigger algorithms The purposes are twofold:
Definition: jTower.h:40
CaloIdManager.h
LVL1::gFEX::FPGA
FPGA
Definition: GTowerHelpers.h:17
AthAlgTool
Definition: AthAlgTool.h:26
jTower.h
StoreGateSvc.h
LVL1::jFEXsumETAlgo::safetyTest
virtual StatusCode safetyTest() override
Definition: jFEXsumETAlgo.cxx:41
LVL1::jFEXsumETAlgo::buildBarrelSumET
virtual void buildBarrelSumET() override
Definition: jFEXsumETAlgo.cxx:96