ATLAS Offline Software
Loading...
Searching...
No Matches
gTowerMakerFromGfexTowers.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//***************************************************************************
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 : AthAlgorithm(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
50{
51 ATH_MSG_DEBUG("Executing " << name() << ", input: " << m_gDataTowerKey.key() << ", output: " << m_gTowerContainerSGKey.key());
52
53 const EventContext& ctx = Gaudi::Hive::currentContext();
54
55 //Reading the decoded Data gTower container
57 bool gDataTowerFilled = false;
58
60 if(!gDataTowerContainer.isValid()) {
61 ATH_MSG_FATAL("Could not retrieve collection " << gDataTowerContainer.key() );
62 return StatusCode::FAILURE;
63 }
64 gDataTowerFilled = !gDataTowerContainer->empty();
65
66 // STEP 0 - Make a fresh local gTowerContainer
67 std::unique_ptr<gTowerContainer> local_gTowerContainerRaw = std::make_unique<gTowerContainer>();
68
69 // STEP 1 - Make some gTowers and fill the local container (This is the one the simulation reads)
70 m_gTowerBuilderTool->init(local_gTowerContainerRaw);
71
72 // STEP 2 - Mapping gFexTowers with decoded Energies
73 if( gDataTowerFilled ) {
74
75 SG::ReadHandle<xAOD::gFexTowerContainer> * data_gTowerContainer = &gDataTowerContainer;
76
77 data_gTowerContainer = &gDataTowerContainer;
78
79 ATH_MSG_DEBUG("Collection used to build the gTower for simulation: " << (*data_gTowerContainer).key() << " with size: "<<(*data_gTowerContainer)->size() << ". Expected towers 1152");
80
81 for(const xAOD::gFexTower* my_gTower : *(*data_gTowerContainer) ) {
82
83 unsigned int TTID = my_gTower->gFEXtowerID(); //This is the simulation tower ID
84
85 // Find the simulation ID from this firmware ID
86 int ID = local_gTowerContainerRaw->getIDfromFWID(TTID);
87 if (ID == -1) {
88 ATH_MSG_WARNING("Cannot find simulation ID from firmware ID - This gFexTower will be ignored. (Needs investigation). Please report this!" );
89 continue;
90 }
91
92 LVL1::gTower *targetTower;
93 if( (targetTower = local_gTowerContainerRaw->findTower(ID)) ) {
94
95 targetTower->setTotalEt(my_gTower->towerEt());
96 targetTower->setIsSaturated(my_gTower->isSaturated());
97
98 }
99 else {
100 ATH_MSG_WARNING("Tower ID is officially unknown - it will be ignored. (Needs investigation). Please report this!" );
101 continue;
102 }
103 }
104 }
105 else{
106 ATH_MSG_DEBUG("Falling into the legacy path");
107 ATH_CHECK(m_gSuperCellTowerMapperTool->AssignSuperCellsToTowers(local_gTowerContainerRaw));
108 ATH_CHECK(m_gSuperCellTowerMapperTool->AssignTriggerTowerMapper(local_gTowerContainerRaw));
109 }
110
111 // STEP 3 - Write the completed gTowerContainer into StoreGate (move the local copy in memory)
113 ATH_CHECK(gTowerContainerSG.record(std::move( local_gTowerContainerRaw ) ) );
114
115 // STEP 4 - Close and clean the event
116 m_gTowerBuilderTool->reset();
117
118 return StatusCode::SUCCESS;
119}
120
121
122} // 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)
std::vector< Identifier > ID
Handle class for reading from StoreGate.
Handle class for recording to StoreGate.
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
virtual StatusCode initialize() override
ToolHandle< IgSuperCellTowerMapper > m_gSuperCellTowerMapperTool
SG::WriteHandleKey< LVL1::gTowerContainer > m_gTowerContainerSGKey
SG::ReadHandleKey< xAOD::gFexTowerContainer > m_gDataTowerKey
virtual StatusCode execute() override
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:170
void setTotalEt(int totEt)
Definition gTower.cxx:88
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