ATLAS Offline Software
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 
26 #include "StoreGate/WriteHandle.h"
27 #include "StoreGate/ReadHandle.h"
28 
29 
30 namespace LVL1 {
31 
32 gTowerMakerFromGfexTowers::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() );
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
56  SG::ReadHandle<xAOD::gFexTowerContainer> gDataTowerContainer;
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
gFexTowerContainer.h
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
LVL1::gTower::setIsSaturated
void setIsSaturated(char isSaturated)
Sets saturation flag.
Definition: gTower.cxx:170
ID
std::vector< Identifier > ID
Definition: CalibHitIDCheck.h:24
LVL1::gTowerMakerFromGfexTowers::m_gSuperCellTowerMapperTool
ToolHandle< IgSuperCellTowerMapper > m_gSuperCellTowerMapperTool
Definition: gTowerMakerFromGfexTowers.h:42
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:67
gTowerContainer.h
LVL1::gTower
The gTower class is an interface object for gFEX trigger algorithms The purposes are twofold:
Definition: gTower.h:38
LVL1::gTower::setTotalEt
void setTotalEt(int totEt)
Definition: gTower.cxx:88
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
LVL1
eFexTowerBuilder creates xAOD::eFexTowerContainer from supercells (LATOME) and triggerTowers (TREX) i...
Definition: ICMMCPHitsCnvTool.h:18
gFEXCompression.h
gTowerBuilder.h
LVL1::gTowerMakerFromGfexTowers::execute
virtual StatusCode execute() override
Definition: gTowerMakerFromGfexTowers.cxx:49
WriteHandle.h
Handle class for recording to StoreGate.
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
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
xAOD::gFexTower_v1
Class describing input data of a LVL1 eFEX.
Definition: gFexTower_v1.h:22
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
AthAlgorithm
Definition: AthAlgorithm.h:47
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
LVL1::gTowerMakerFromGfexTowers::m_gDataTowerKey
SG::ReadHandleKey< xAOD::gFexTowerContainer > m_gDataTowerKey
Definition: gTowerMakerFromGfexTowers.h:36
TrigConf::name
Definition: HLTChainList.h:35
LVL1::gTowerMakerFromGfexTowers::gTowerMakerFromGfexTowers
gTowerMakerFromGfexTowers(const std::string &name, ISvcLocator *pSvcLocator)
Definition: gTowerMakerFromGfexTowers.cxx:32
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
LVL1::gTowerMakerFromGfexTowers::initialize
virtual StatusCode initialize() override
Definition: gTowerMakerFromGfexTowers.cxx:37
SG::VarHandleBase::key
virtual const std::string & key() const override final
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleBase.cxx:64
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:73
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
LVL1::gTowerMakerFromGfexTowers::m_gTowerBuilderTool
ToolHandle< IgTowerBuilder > m_gTowerBuilderTool
Definition: gTowerMakerFromGfexTowers.h:41
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
ReadHandle.h
Handle class for reading from StoreGate.
LVL1::gTowerMakerFromGfexTowers::m_gTowerContainerSGKey
SG::WriteHandleKey< LVL1::gTowerContainer > m_gTowerContainerSGKey
Definition: gTowerMakerFromGfexTowers.h:39
gTower.h
DataVector::empty
bool empty() const noexcept
Returns true if the collection is empty.
gTowerMakerFromGfexTowers.h