ATLAS Offline Software
Loading...
Searching...
No Matches
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
9#include "eTowerBuilder.h"
13
15
16#include <fstream>
17
18namespace 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
33 ATH_CHECK( m_eTowerContainerSGKey.initialize() );
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
#define ATH_CHECK
Evaluate an expression and check for errors.
Handle class for recording to StoreGate.
An algorithm that can be simultaneously executed in multiple threads.
virtual StatusCode execute(const EventContext &ctx) const override
SG::WriteHandleKey< LVL1::eTowerContainer > m_eTowerContainerSGKey
eTowerMakerFromSuperCells(const std::string &name, ISvcLocator *pSvcLocator)
ToolHandle< IeSuperCellTowerMapper > m_eSuperCellTowerMapperTool
ToolHandle< IeTowerBuilder > m_eTowerBuilderTool
virtual StatusCode initialize() override
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...