59 if (!ScellContainer.
isValid()) {
61 return StatusCode::FAILURE;
67 if (!triggerTowerContainer.
isValid()) {
69 << triggerTowerContainer.
key());
70 return StatusCode::FAILURE;
75 ATH_CHECK( gTowersContainer.
record(std::make_unique<xAOD::gFexTowerContainer>(),
76 std::make_unique<xAOD::gFexTowerAuxContainer>()) );
77 ATH_MSG_DEBUG(
"Recorded gFexEmulatedTower container with key " << gTowersContainer.
key());
79 if (ScellContainer->empty() || triggerTowerContainer->empty()) {
81 "Cannot fill gTowers here, at least one container is empty. "
82 "ScellContainer.size="
83 << ScellContainer->size()
84 <<
" or triggerTowerContainer.size=" << triggerTowerContainer->size());
85 return StatusCode::SUCCESS;
89 std::unordered_map<uint64_t, const CaloCell*> map_ScellID2ptr;
90 map_ScellID2ptr.reserve(ScellContainer->size());
92 for (
const CaloCell* scell : *ScellContainer) {
93 const uint64_t
ID = scell->ID().get_compact();
94 map_ScellID2ptr[
ID] = scell;
98 std::unordered_map<uint32_t, const xAOD::TriggerTower*> map_TileID2ptr;
99 map_TileID2ptr.reserve(triggerTowerContainer->size());
102 map_TileID2ptr[tower->coolId()] = tower;
105 unsigned int towerID = key;
106 const auto [fpga,
eta,
phi, source] = element;
109 uint16_t total_et_encoded = 0;
118 <<
" not found on map m_map_TTower2SCells");
119 return StatusCode::FAILURE;
128 bool isConnected =
true;
129 for (
const auto& scellID : it_TTower2SCells->second) {
131 auto it_ScellID2ptr = map_ScellID2ptr.find(scellID);
134 if (scellID == 0xffffffffffffffff) {
140 std::string str_hex = std::format(
"{:x}", scellID);
142 if (it_ScellID2ptr == map_ScellID2ptr.end()) {
146 <<
" not found in the CaloCellContainer, skipping");
150 const CaloCell* scell = it_ScellID2ptr->second;
151 int val = std::round(
153 (12.5 * std::cosh(scell->
eta())));
162 invalid &= isInvalid;
165 gTower_sat |= isSaturated;
181 total_et_encoded = 0;
183 total_et_encoded = 0;
185 total_et_encoded = 4095;
191 }
else if (source == 1) {
198 for (
auto const& TileTowerID : it_TTower2Tile->second) {
199 auto it_TileID2ptr = map_TileID2ptr.find(TileTowerID);
200 if (it_TileID2ptr == map_TileID2ptr.end()) {
203 <<
" not found in the xAOD::TriggerTower (map_TileID2ptr)");
208 unsigned int jepEt = tileTower->
jepET();
212 total_et_encoded = Tile_Et;
214 }
else if (source == 2) {
216 total_et_encoded = 0;
220 float total_et_encoded_flt = total_et_encoded;
222 unsigned int fpga_out = (towerID < 10000) ? 0 : (towerID < 20000) ? 1 : 2;
223 unsigned int iEta = 0;
224 unsigned int iPhi = 0;
226 gTowersContainer->push_back(std::make_unique<xAOD::gFexTower>());
227 gTowersContainer->back()->initialize(iEta, iPhi,
eta,
phi,
228 total_et_encoded_flt, fpga_out,
229 gTower_sat, towerID);
232 return StatusCode::SUCCESS;
237 std::ifstream
file(fileName);
239 if (!
file.is_open()) {
241 return StatusCode::FAILURE;
245 while (std::getline(
file, line)) {
247 if (line[0] ==
'#')
continue;
250 std::stringstream oneLine(line);
252 std::vector<float> elements;
255 while (std::getline(oneLine, element,
' ')) {
256 elements.push_back(std::stof(element));
262 if (elements.size() != 5) {
264 "Unexpected number of elements (5 expected) in file: " << fileName);
265 return StatusCode::FAILURE;
269 std::array<float, 4> aux_arr{{elements.at(1), elements.at(3),
270 elements.at(4), elements.at(2)}};
278 return StatusCode::SUCCESS;
284 std::ifstream
file(fileName);
286 if (!
file.is_open()) {
288 return StatusCode::FAILURE;
294 while (std::getline(
file, line)) {
299 std::vector<uint64_t> SCellvector;
302 std::stringstream oneSCellID(line);
305 std::string substr =
"";
309 while (std::getline(oneSCellID, substr,
' ')) {
312 TTID = std::stoi(substr);
316 return StatusCode::FAILURE;
322 std::string scell_full =
323 (substr ==
"0xffffffffffffffff") ? substr : substr +
"00000000";
324 uint64_t scid_uint64 = std::strtoull(scell_full.c_str(),
nullptr, 0);
325 SCellvector.push_back(scid_uint64);
333 return StatusCode::SUCCESS;
353 std::ifstream myfile(fileName);
355 if (!myfile.is_open()) {
357 return StatusCode::FAILURE;
362 while (std::getline(myfile, myline)) {
364 myline.erase(myline.begin(),
365 std::find_if(myline.begin(), myline.end(),
366 [](
int ch) { return !std::isspace(ch); }));
367 if (myline[0] ==
'#')
370 std::vector<uint32_t> Tilevector;
373 std::stringstream oneTileID(myline);
376 std::string substr =
"";
380 while (std::getline(oneTileID, substr,
' ')) {
383 gTowerID = std::stoi(substr);
385 uint32_t tileid_uint32 = std::strtoul(substr.c_str(),
nullptr, 0);
386 Tilevector.push_back(tileid_uint32);
393 return StatusCode::SUCCESS;