ATLAS Offline Software
Loading...
Searching...
No Matches
TileTTL1Overlay.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include "TileTTL1Overlay.h"
6#include "Identifier/Identifier.h"
7// Atlas includes
10
11namespace LVL1
12{
13
14TileTTL1Overlay::TileTTL1Overlay(const std::string& name, ISvcLocator* pSvcLocator)
15 : AthReentrantAlgorithm(name, pSvcLocator) { }
16
18{
19 ATH_MSG_DEBUG("Initialising");
20
21 // StoreGate keys for Tile
22 ATH_CHECK( m_bkgTileTTL1Key.initialize() );
23 ATH_MSG_VERBOSE("Initialized ReadHandleKey: " << m_bkgTileTTL1Key);
25 ATH_MSG_VERBOSE("Initialized ReadHandleKey: " << m_bkgTileMBTSTTL1Key);
26 ATH_CHECK( m_signalTileTTL1Key.initialize() );
27 ATH_MSG_VERBOSE("Initialized ReadHandleKey: " << m_signalTileTTL1Key);
29 ATH_MSG_VERBOSE("Initialized ReadHandleKey: " << m_signalTileMBTSTTL1Key);
30 ATH_CHECK( m_outputTileTTL1Key.initialize() );
31 ATH_MSG_VERBOSE("Initialized ReadHandleKey: " << m_outputTileTTL1Key);
33 ATH_MSG_VERBOSE("Initialized ReadHandleKey: " << m_outputTileMBTSTTL1Key);
34
35 return StatusCode::SUCCESS;
36}
37
39StatusCode TileTTL1Overlay::execute(const EventContext& ctx) const
40{
42 if (!m_outputTileMBTSTTL1Key.empty()) {
44 }
45
46 return StatusCode::SUCCESS;
47}
48
51 std::map<Identifier, std::vector<const TileTTL1*>> &towerMap) const
52{
53 // Step over all towers
54 for (const TileTTL1* tower : *towers) {
55 towerMap[tower->TTL1_ID()].push_back(tower);
56 }
57 return;
58}
59
61StatusCode TileTTL1Overlay::overlay(const EventContext& ctx,
65 const std::string &label) const
66{
67 // setup map
68 std::map<Identifier, std::vector<const TileTTL1*>> towerMap;
69
70 // Find Tile towers in TES
71 SG::ReadHandle<TileTTL1Container> bkgTowers(bkgKey, ctx);
72 if (!bkgTowers.isValid()) {
73 ATH_MSG_ERROR("Could not get background " << label << " TileTTL1Container container " << bkgTowers.name() << " from store " << bkgTowers.store());
74 return StatusCode::FAILURE;
75 }
76
79 SG::ReadHandle<TileTTL1Container> signalTowers(signalKey, ctx);
80 if (!signalTowers.isValid()) {
81 ATH_MSG_ERROR("Could not get signal " << label << " TileTTL1Container container " << signalTowers.name() << " from store " << signalTowers.store());
82 return StatusCode::FAILURE;
83 }
84
85 // Group towers by ID
86 groupTowers(bkgTowers.cptr(), towerMap);
87 groupTowers(signalTowers.cptr(), towerMap);
88
89 SG::WriteHandle<TileTTL1Container> outputContainer(outputKey, ctx);
90 // Register the TTL1 container in the TES
91 ATH_CHECK( outputContainer.record(std::make_unique<TileTTL1Container>()) );
92 ATH_MSG_DEBUG( "Output " << label << " TileTTL1Container registered successfully (" << outputKey.key() << ")" );
93
94 // Then the process Tile TTL1 collection
95 for (const auto &[dummy, towers] : towerMap) {
96 Identifier Id = towers.front()->TTL1_ID();
97
98 std::vector<float> mergedAmps;
99 for (const TileTTL1 *tower : towers) {
100 if (mergedAmps.empty()) {
101 mergedAmps = tower->fsamples();
102 } else {
103 std::vector<float> amps = tower->fsamples();
104 if (amps.size() != mergedAmps.size()) {
105 ATH_MSG_WARNING("Tile " << label << " vectors have different lengths: " << amps.size() << ", " << mergedAmps.size());
106 } else {
107 for (size_t i = 0; i < amps.size(); ++i) {
108 mergedAmps[i] += amps[i];
109 }
110 }
111 }
112 }
113
114 // Create new tower and add to output vector
115 std::unique_ptr<TileTTL1> ttL1 = std::make_unique<TileTTL1>(Id, mergedAmps);
116 outputContainer->push_back(ttL1.release());
117 }
118
119 return StatusCode::SUCCESS;
120}
121
122} // namespace LVL1
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
Handle class for reading from StoreGate.
Handle class for recording to StoreGate.
TileContainer< TileTTL1 > TileTTL1Container
An algorithm that can be simultaneously executed in multiple threads.
StatusCode overlay(const EventContext &ctx, const SG::ReadHandleKey< TileTTL1Container > &bkgKey, const SG::ReadHandleKey< TileTTL1Container > &signalKey, const SG::WriteHandleKey< TileTTL1Container > &outputKey, const std::string &label) const
Main algorithm execute.
SG::WriteHandleKey< TileTTL1Container > m_outputTileTTL1Key
void groupTowers(const TileTTL1Container *towers, std::map< Identifier, std::vector< const TileTTL1 * > > &towerMap) const
Real Tile overlay towers and overlay on existing event.
virtual StatusCode initialize() override final
SG::ReadHandleKey< TileTTL1Container > m_bkgTileMBTSTTL1Key
SG::WriteHandleKey< TileTTL1Container > m_outputTileMBTSTTL1Key
SG::ReadHandleKey< TileTTL1Container > m_signalTileMBTSTTL1Key
TileTTL1Overlay(const std::string &name, ISvcLocator *pSvcLocator)
SG::ReadHandleKey< TileTTL1Container > m_bkgTileTTL1Key
virtual StatusCode execute(const EventContext &ctx) const override final
Main algorithm execute.
SG::ReadHandleKey< TileTTL1Container > m_signalTileTTL1Key
Property holding a SG store/key/clid from which a ReadHandle is made.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const_pointer_type cptr()
Dereference the pointer.
std::string store() const
Return the name of the store holding the object we are proxying.
const std::string & name() const
Return the StoreGate ID for the referenced object.
const std::string & key() const
Return the StoreGate ID for the referenced object.
Property holding a SG store/key/clid from which a WriteHandle is made.
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
std::string label(const std::string &format, int i)
Definition label.h:19
bool overlay
Definition listroot.cxx:42
eFexTowerBuilder creates xAOD::eFexTowerContainer from supercells (LATOME) and triggerTowers (TREX) i...