ATLAS Offline Software
Loading...
Searching...
No Matches
gTowerMakerFromGfexTowers.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5//***************************************************************************
6// gTowerMakerFromGfexTowers - description
7// ---------------------------------------------------------
8// This algorithm is meant to create from the xAOD::gFexTowerContainer (EDM) a gTowerContainer (a SG object the gFEX simulation needs)
9// It needs to get both inputs available:
10// * Decoded gFex input data, known as L1_gFexDataTowers
11// * Emulated gFex input data, known as L1_gFexEmulatedTowers (to be confirmed if this is the name in gFex)
12//
13// begin : 14 07 2023
14// email : cecilia.tosciri@cern.ch
15//
16//***************************************************************************/
17
19
20#include "L1CaloFEXSim/gTower.h"
21#include "gTowerBuilder.h"
25
28
29
30namespace LVL1 {
31
32gTowerMakerFromGfexTowers::gTowerMakerFromGfexTowers(const std::string& name, ISvcLocator* pSvcLocator)
33 : AthReentrantAlgorithm(name, pSvcLocator)
34{}
35
36
38{
39 ATH_CHECK( m_gDataTowerKey.initialize() );
41 ATH_CHECK( m_gTowerBuilderTool.retrieve() );
42 ATH_CHECK( m_gTowerContainerSGKey.initialize() );
43
44 return StatusCode::SUCCESS;
45
46}
47
48
49StatusCode gTowerMakerFromGfexTowers::execute(const EventContext& ctx) const
50{
51 ATH_MSG_DEBUG("Executing " << name() << ", input: " << m_gDataTowerKey.key() << ", output: " << m_gTowerContainerSGKey.key());
52
53 //Reading the decoded Data gTower container
55 if(!gDataTowerContainer.isValid()) {
56 ATH_MSG_FATAL("Could not retrieve collection " << gDataTowerContainer.key() );
57 return StatusCode::FAILURE;
58 }
59
60 // STEP 0 - Make a fresh local gTowerContainer
61 std::unique_ptr<gTowerContainer> local_gTowerContainerRaw = std::make_unique<gTowerContainer>();
62
63 // STEP 1 - Make some gTowers and fill the local container (This is the one the simulation reads)
64 m_gTowerBuilderTool->BuildAllTowers(local_gTowerContainerRaw);
65
66 // STEP 2 - Mapping gFexTowers with decoded Energies
67 if( !gDataTowerContainer->empty() ) {
68
69 ATH_MSG_DEBUG("Collection used to build the gTower for simulation: " << gDataTowerContainer.key() << " with size: "<< gDataTowerContainer->size() << ". Expected towers 1152");
70
71 for(const xAOD::gFexTower* my_gTower : *gDataTowerContainer) {
72
73 unsigned int TTID = my_gTower->gFEXtowerID(); //This is the simulation tower ID
74
75 // Find the simulation ID from this firmware ID
76 int ID = local_gTowerContainerRaw->getIDfromFWID(TTID);
77 if (ID == -1) {
78 ATH_MSG_WARNING("Cannot find simulation ID from firmware ID - This gFexTower will be ignored. (Needs investigation). Please report this!" );
79 continue;
80 }
81
82 LVL1::gTower *targetTower;
83 if( (targetTower = local_gTowerContainerRaw->findTower(ID)) ) {
84
85 targetTower->setTotalEt(my_gTower->towerEt());
86 targetTower->setIsSaturated(my_gTower->isSaturated());
87
88 }
89 else {
90 ATH_MSG_WARNING("Tower ID is officially unknown - it will be ignored. (Needs investigation). Please report this!" );
91 continue;
92 }
93 }
94 }
95 else{
96 ATH_MSG_DEBUG("Falling into the legacy path");
97 ATH_CHECK(m_gSuperCellTowerMapperTool->AssignSuperCellsToTowers(local_gTowerContainerRaw));
98 ATH_CHECK(m_gSuperCellTowerMapperTool->AssignTriggerTowerMapper(local_gTowerContainerRaw));
99 }
100
101 // STEP 3 - Write the completed gTowerContainer into StoreGate (move the local copy in memory)
103 ATH_CHECK(gTowerContainerSG.record(std::move( local_gTowerContainerRaw ) ) );
104
105 return StatusCode::SUCCESS;
106}
107
108
109} // end of LVL1 namespace
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_FATAL(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
Handle class for reading from StoreGate.
Handle class for recording to StoreGate.
An algorithm that can be simultaneously executed in multiple threads.
virtual StatusCode initialize() override
virtual StatusCode execute(const EventContext &ctx) const override
ToolHandle< IgSuperCellTowerMapper > m_gSuperCellTowerMapperTool
SG::WriteHandleKey< LVL1::gTowerContainer > m_gTowerContainerSGKey
SG::ReadHandleKey< xAOD::gFexTowerContainer > m_gDataTowerKey
gTowerMakerFromGfexTowers(const std::string &name, ISvcLocator *pSvcLocator)
ToolHandle< IgTowerBuilder > m_gTowerBuilderTool
The gTower class is an interface object for gFEX trigger algorithms The purposes are twofold:
Definition gTower.h:38
void setIsSaturated(char isSaturated)
Sets saturation flag.
Definition gTower.cxx:168
void setTotalEt(int totEt)
Definition gTower.cxx:86
virtual bool isValid() override final
Can the handle be successfully dereferenced?
virtual const std::string & key() const override final
Return the StoreGate ID for the referenced object.
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
eFexTowerBuilder creates xAOD::eFexTowerContainer from supercells (LATOME) and triggerTowers (TREX) i...
gFexTower_v1 gFexTower
Define the latest version of the TriggerTower class.
Definition gFexTower.h:15