ATLAS Offline Software
Loading...
Searching...
No Matches
GBlockBuilder.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include "GBlockBuilder.h"
10#include "GTowerHelpers.h"
11#include <memory>
12
13namespace
14{
15 const static SG::AuxElement::ConstAccessor<std::size_t> accNextEtaIndex("nextEtaIndex");
16 const static SG::AuxElement::ConstAccessor<std::size_t> accPreviousEtaIndex("previousEtaIndex");
17 const static SG::AuxElement::ConstAccessor<std::size_t> accNextPhiIndex("nextPhiIndex");
18 const static SG::AuxElement::ConstAccessor<std::size_t> accPreviousPhiIndex("previousPhiIndex");
19 const static SG::AuxElement::ConstAccessor<float> accArea("area");
20} // namespace
21
22namespace LVL1
23{
24 GBlockBuilder::GBlockBuilder(const std::string &name, ISvcLocator *pSvcLocator)
25 : AthReentrantAlgorithm(name, pSvcLocator)
26 {
27 declareProperty("InputTowers", m_towersKey);
28 declareProperty("OutputBlocks", m_gBlocksKey);
29 declareProperty("ForwardEta", m_forwardEta = 3.2);
30 }
31
33
35 {
36 ATH_CHECK(m_towersKey.initialize());
37 ATH_CHECK(m_gBlocksKey.initialize());
38 return StatusCode::SUCCESS;
39 }
40
41 StatusCode GBlockBuilder::execute(const EventContext& ctx) const
42 {
43 auto towers = SG::makeHandle(m_towersKey, ctx);
44 if (!towers.isValid())
45 {
46 ATH_MSG_ERROR("Failed to retrieve " << m_towersKey.key());
47 return StatusCode::FAILURE;
48 }
49
50 auto outputGBlocks = std::make_unique<xAOD::GBlockContainer>();
51 auto outputGBlocksAux = std::make_unique<xAOD::GBlockAuxContainer>();
52 outputGBlocks->setStore(outputGBlocksAux.get());
53
54 for (const xAOD::JGTower *seedTower : *towers)
55 {
56 float et = 0;
57 float area = 0;
58 float dEta = seedTower->deta();
59 float dPhi = seedTower->dphi();
60 gFEX::FPGA currentFPGA = gFEX::getFPGA(seedTower->eta());
61 std::vector<const xAOD::JGTower *> inputs{seedTower};
62 // The forward region only uses 1x1 gBlocks as the towers are already larger
63 if (std::abs(seedTower->eta()) < m_forwardEta)
64 {
65 const xAOD::JGTower *nextPhiTower = towers->at(accNextPhiIndex(*seedTower));
66 dPhi += nextPhiTower->dphi();
67 const xAOD::JGTower *previousPhiTower = towers->at(accPreviousPhiIndex(*seedTower));
68 dPhi += previousPhiTower->dphi();
69 inputs.push_back(towers->at(accNextPhiIndex(*seedTower)));
70 inputs.push_back(towers->at(accPreviousPhiIndex(*seedTower)));
71 std::size_t nextEtaIndex = accNextEtaIndex(*seedTower);
72 if (nextEtaIndex != SIZE_MAX)
73 {
74 const xAOD::JGTower *nextTower = towers->at(nextEtaIndex);
75 dEta += nextTower->deta();
76 if (currentFPGA == gFEX::getFPGA(nextTower->eta()))
77 {
78 inputs.push_back(nextTower);
79 inputs.push_back(towers->at(accNextPhiIndex(*nextTower)));
80 inputs.push_back(towers->at(accPreviousPhiIndex(*nextTower)));
81 }
82 }
83 std::size_t previousEtaIndex = accPreviousEtaIndex(*seedTower);
84 if (previousEtaIndex != SIZE_MAX)
85 {
86 const xAOD::JGTower *previousTower = towers->at(previousEtaIndex);
87 dEta += previousTower->deta();
88 if (currentFPGA == gFEX::getFPGA(previousTower->eta()))
89 {
90 inputs.push_back(previousTower);
91 inputs.push_back(towers->at(accNextPhiIndex(*previousTower)));
92 inputs.push_back(towers->at(accPreviousPhiIndex(*previousTower)));
93 }
94 }
95 }
96 std::vector<ElementLink<xAOD::JGTowerContainer>> links;
97 for (const xAOD::JGTower *tower : inputs)
98 {
99 et += tower->et();
100 area += accArea(*tower);
101 links.emplace_back(m_towersKey.key(), tower->index());
102 }
103 xAOD::GBlock *block = new xAOD::GBlock();
104 outputGBlocks->push_back(block);
105 block->setEta(seedTower->eta());
106 block->setPhi(seedTower->phi());
107 block->setdEta(dEta);
108 block->setdPhi(dPhi);
109 block->setEt(et);
110 block->setArea(area);
111 block->setSeedTowerLink({m_towersKey.key(), seedTower->index()});
112 block->setTowerLinks(links);
113 }
114
115 auto gBlockHandle = SG::makeHandle(m_gBlocksKey, ctx);
116 ATH_CHECK(gBlockHandle.record(std::move(outputGBlocks), std::move(outputGBlocksAux)));
117 return StatusCode::SUCCESS;
118 }
119} // namespace LVL1
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
double area(double R)
Handle class for reading from StoreGate.
Handle class for recording to StoreGate.
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
An algorithm that can be simultaneously executed in multiple threads.
virtual StatusCode execute(const EventContext &ctx) const override
virtual StatusCode initialize() override
SG::ReadHandleKey< xAOD::JGTowerContainer > m_towersKey
SG::WriteHandleKey< xAOD::GBlockContainer > m_gBlocksKey
virtual ~GBlockBuilder() override
GBlockBuilder(const std::string &name, ISvcLocator *pSvcLocator)
SG::ConstAccessor< T, ALLOC > ConstAccessor
Definition AuxElement.h:569
void setEta(double)
void setArea(float)
Set the area.
void setTowerLinks(const std::vector< ElementLink< JGTowerContainer > > &links)
set the tower links
void setPhi(double)
void setSeedTowerLink(const ElementLink< JGTowerContainer > &link)
Set the seed link.
Definition GBlock_v1.cxx:95
void setdPhi(float)
void setEt(float)
void setdEta(float)
virtual double dphi() const final
The azimuthal angle ( ) of the particle.
virtual double deta() const final
The pseudorapidity ( ) of the particle.
virtual double eta() const final
The pseudorapidity ( ) of the particle.
FPGA getFPGA(float eta)
Get the FPGA code from the tower eta.
eFexTowerBuilder creates xAOD::eFexTowerContainer from supercells (LATOME) and triggerTowers (TREX) i...
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
JGTower_v1 JGTower
Define the latest version of the JGTower class.
Definition JGTower.h:15
GBlock_v1 GBlock
Define the latest version of the GBlock class.
Definition GBlock.h:15
Extra patterns decribing particle interation process.