Function executing the algorithm.
55 {
56
57
58 SG::ReadHandle<CaloCellContainer> ScellContainer(
m_SCellKey, ctx);
59 if (!ScellContainer.isValid()) {
60 ATH_MSG_ERROR(
"Could not retrieve collection " << ScellContainer.key());
61 return StatusCode::FAILURE;
62 }
63
64
65 SG::ReadHandle<xAOD::TriggerTowerContainer> triggerTowerContainer(
67 if (!triggerTowerContainer.isValid()) {
69 << triggerTowerContainer.key());
70 return StatusCode::FAILURE;
71 }
72
73
74
75 SG::WriteHandle<xAOD::gFexTowerContainer> gTowersContainer(
m_gTowersWriteKey, ctx);
76 ATH_CHECK( gTowersContainer.record(std::make_unique<xAOD::gFexTowerContainer>(),
77 std::make_unique<xAOD::gFexTowerAuxContainer>()) );
78 ATH_MSG_DEBUG(
"Recorded gFexEmulatedTower container with key " << gTowersContainer.key());
79
80 if (ScellContainer->empty() || triggerTowerContainer->empty()) {
82 "Cannot fill gTowers here, at least one container is empty. "
83 "ScellContainer.size="
84 << ScellContainer->size()
85 << " or triggerTowerContainer.size=" << triggerTowerContainer->size());
86 return StatusCode::SUCCESS;
87 }
88
89
90 std::unordered_map<uint64_t, const CaloCell*> map_ScellID2ptr;
91 map_ScellID2ptr.reserve(ScellContainer->size());
92
93 for (const CaloCell* scell : *ScellContainer) {
95 map_ScellID2ptr[
ID] = scell;
96 }
97
98
99 std::unordered_map<uint32_t, const xAOD::TriggerTower*> map_TileID2ptr;
100 map_TileID2ptr.reserve(triggerTowerContainer->size());
101
103 map_TileID2ptr[tower->coolId()] = tower;
104 }
106 unsigned int towerID =
key;
108
109
111 char gTower_sat = 0;
112
113 if (source == 0) {
114
115
119 << " not found on map m_map_TTower2SCells");
120 return StatusCode::FAILURE;
121 }
122
123
126
127
128 int total_Et = 0;
129 bool isConnected = true;
130 for (const auto& scellID : it_TTower2SCells->second) {
131
132 auto it_ScellID2ptr = map_ScellID2ptr.find(scellID);
133
134
135 if (scellID == 0xffffffffffffffff) {
136 isConnected = false;
137 continue;
138 }
139
140
141 std::string str_hex = std::format("{:x}", scellID);
142
143 if (it_ScellID2ptr == map_ScellID2ptr.end()) {
146 << scellID
147 << " not found in the CaloCellContainer, skipping");
148 continue;
149 }
150
151 unsigned int offset = (towerID > 20000) ? 20000 : (towerID > 10000 && towerID < 20000) ? 10000 : 0;
152 unsigned int iFiber = (towerID -
offset)/16;
153
154
156 if (iFiber >= maxFiberN) continue;
157
161
162
166
167 const CaloCell* scell = it_ScellID2ptr->second;
168 int val = std::round(scell->
energy() / (12.5 * std::cosh(scell->
eta())));
171 }
174 }
175
176 bool isMasked =
178 bool isInvalid =
181
182 invalid &= isInvalid;
183 masked &= isMasked;
184 if (!isMasked) {
185 gTower_sat |= isSaturated;
186 }
187
188 if (isMasked) {
192 }
193
194 if (val != 0)
196
197 }
198
199
200 if(!isConnected) {
201 total_et_encoded = 0;
202 } else if(masked) {
203 total_et_encoded = 0;
204 } else if(invalid) {
205 total_et_encoded = 4095;
206 } else {
208 }
209
210
211 } else if (source == 1) {
212
213
214
216
217 int Tile_Et = 0;
218 for (auto const& TileTowerID : it_TTower2Tile->second) {
219 auto it_TileID2ptr = map_TileID2ptr.find(TileTowerID);
220 if (it_TileID2ptr == map_TileID2ptr.end()) {
223 << " not found in the xAOD::TriggerTower (map_TileID2ptr)");
224 }
225 continue;
226 } else {
228 unsigned int jepEt = tileTower->
jepET();
229 Tile_Et += jepEt;
230 }
231 }
232 total_et_encoded = Tile_Et;
233
234 } else if (source == 2) {
235
236 total_et_encoded = 0;
237 }
238
239
240 float total_et_encoded_flt = total_et_encoded;
241
242 unsigned int fpga_out = (towerID < 10000) ? 0 : (towerID < 20000) ? 1 : 2;
243 unsigned int iEta = 0;
244 unsigned int iPhi = 0;
245
246 gTowersContainer->push_back(std::make_unique<xAOD::gFexTower>());
248 total_et_encoded_flt, fpga_out,
249 gTower_sat, towerID);
250 }
251
252 return StatusCode::SUCCESS;
253 }
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
double energy() const
get energy (data member)
uint16_t provenance() const
get provenance (data member)
virtual double eta() const override final
get eta (through CaloDetDescrElement)
uint16_t quality() const
get quality (data member)
static unsigned int compress(float Energy)
Compress data.
std::unordered_map< uint32_t, std::vector< uint64_t > > m_map_TTower2SCells
Gaudi::Property< bool > m_apply_masking
virtual StatusCode initialize() override
Function initialising the algorithm.
SG::ReadHandleKey< xAOD::TriggerTowerContainer > m_triggerTowerKey
SG::WriteHandleKey< xAOD::gFexTowerContainer > m_gTowersWriteKey
SG::ReadHandleKey< CaloCellContainer > m_SCellKey
std::unordered_map< unsigned int, std::array< float, 4 > > m_Firm2Tower_map
Gaudi::Property< bool > m_applyTimingCut
Gaudi::Property< bool > m_applyTimingCutAll
Gaudi::Property< bool > m_isDATA
std::unordered_map< uint32_t, std::vector< uint32_t > > m_map_TTower2Tile
uint8_t jepET() const
get jepET from peak of lut_jep
constexpr std::array< std::array< char, 20 >, 4 > CMPD_DTYP_ARR
constexpr std::array< int, 100 > CMPD_NFI
constexpr std::array< std::array< char, 20 >, 4 > AMPD_DTYP_ARR
constexpr std::array< std::array< char, 20 >, 4 > BMPD_DTYP_ARR
constexpr std::array< int, 100 > AMPD_NFI
constexpr std::array< int, 100 > BMPD_NFI
ID
//////////////////////////////////////// JetAlgorithmType::ID defines most common physics jet finding...
setScale setgFexType iEta
TriggerTower_v2 TriggerTower
Define the latest version of the TriggerTower class.