ATLAS Offline Software
eTowerMakerFromSuperCells.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 
7 
8 #include "L1CaloFEXSim/eTower.h"
13 
14 #include "StoreGate/WriteHandle.h"
15 
16 #include <fstream>
17 
18 namespace LVL1 {
19 
20  eTowerMakerFromSuperCells::eTowerMakerFromSuperCells(const std::string& name, ISvcLocator* pSvcLocator)
21  : AthReentrantAlgorithm(name, pSvcLocator)
22  {
23 
24  }
25 
26 
28 {
29  ATH_CHECK( m_eTowerBuilderTool.retrieve() );
30 
32 
34 
35  return StatusCode::SUCCESS;
36 }
37 
38 
39  StatusCode eTowerMakerFromSuperCells::execute(const EventContext& ctx) const
40 {
41  // STEP 0 - Make a fresh local eTowerContainer
42  std::unique_ptr<eTowerContainer> local_eTowerContainerRaw = std::make_unique<eTowerContainer>();
43 
44  // STEP 1 - Make some eTowers and fill the local container
45  m_eTowerBuilderTool->init(local_eTowerContainerRaw);
46  local_eTowerContainerRaw->clearContainerMap();
47  local_eTowerContainerRaw->fillContainerMap();
48 
49  // STEP 2 - Do the supercell-tower mapping - put this information into the eTowerContainer
50  ATH_CHECK(m_eSuperCellTowerMapperTool->AssignSuperCellsToTowers(local_eTowerContainerRaw));
51  ATH_CHECK(m_eSuperCellTowerMapperTool->AssignTriggerTowerMapper(local_eTowerContainerRaw));
52 
53  // STEP 2.5 - Set up a the first CSV file if necessary (should only need to be done if the mapping changes, which should never happen unless major changes to the simulation are required)
54  if(false){ // CSV CODE TO BE RE-INTRODUCED VERY SOON
55  //if (first event){
56  std::ofstream sc_tower_map;
57  sc_tower_map.open("./sc_tower_map.csv");
58  sc_tower_map << "#eTowerID,scID,slot,isSplit" << "\n";
59 
60  for (auto thistower : *local_eTowerContainerRaw){
61  int slotcount = 0;
62  for (int layer = 0; layer<=4; layer++){
63  std::vector<Identifier> scIDs = thistower->getLayerSCIDs(layer);
64  std::vector<unsigned int> splits = thistower->getETSplits();
65  for (auto scid : scIDs){
66  sc_tower_map << thistower->id() << "," << scid << "," << slotcount << "," << splits[slotcount] << "\n";
67  slotcount++;
68  }
69  }
70  }
71  sc_tower_map.close();
72  }
73 
74 
75  // STEP 3 - Write the completed eTowerContainer into StoreGate (move the local copy in memory)
77  ATH_CHECK(eTowerContainerSG.record(std::move(/*my_eTowerContainerRaw*/local_eTowerContainerRaw)));
78 
79  // STEP 4 - Close and clean the event
81  m_eTowerBuilderTool->reset();
82 
83  return StatusCode::SUCCESS;
84 }
85 
86 
87 } // end of LVL1 namespace
LVL1::eTowerMakerFromSuperCells::initialize
virtual StatusCode initialize() override
Definition: eTowerMakerFromSuperCells.cxx:27
eTowerMakerFromSuperCells.h
LVL1::eTowerMakerFromSuperCells::m_eSuperCellTowerMapperTool
ToolHandle< IeSuperCellTowerMapper > m_eSuperCellTowerMapperTool
Definition: eTowerMakerFromSuperCells.h:36
eTowerContainer.h
LVL1::eTowerMakerFromSuperCells::m_eTowerBuilderTool
ToolHandle< IeTowerBuilder > m_eTowerBuilderTool
Definition: eTowerMakerFromSuperCells.h:35
TriggerTowerContainer.h
LVL1::eTowerMakerFromSuperCells::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition: eTowerMakerFromSuperCells.cxx:39
LVL1
eFexTowerBuilder creates xAOD::eFexTowerContainer from supercells (LATOME) and triggerTowers (TREX) i...
Definition: ICMMCPHitsCnvTool.h:18
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
WriteHandle.h
Handle class for recording to StoreGate.
eSuperCellTowerMapper.h
LVL1::eTowerMakerFromSuperCells::eTowerMakerFromSuperCells
eTowerMakerFromSuperCells(const std::string &name, ISvcLocator *pSvcLocator)
Definition: eTowerMakerFromSuperCells.cxx:20
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
TRT::Hit::layer
@ layer
Definition: HitInfo.h:79
eTowerBuilder.h
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
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
TrigConf::name
Definition: HLTChainList.h:35
LVL1::eTowerMakerFromSuperCells::m_eTowerContainerSGKey
SG::WriteHandleKey< LVL1::eTowerContainer > m_eTowerContainerSGKey
Definition: eTowerMakerFromSuperCells.h:33
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
eTower.h