ATLAS Offline Software
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"
6 #include "StoreGate/ReadHandle.h"
10 #include "GTowerHelpers.h"
11 #include <memory>
12 
13 namespace
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 
22 namespace 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
xAOD::JGTower_v1
Description of JGTower_v1.
Definition: JGTower_v1.h:46
LVL1::gFEX::getFPGA
FPGA getFPGA(float eta)
Get the FPGA code from the tower eta.
Definition: GTowerHelpers.cxx:15
et
Extra patterns decribing particle interation process.
LVL1::GBlockBuilder::~GBlockBuilder
virtual ~GBlockBuilder() override
Definition: GBlockBuilder.cxx:32
xAOD::GBlock_v1::setArea
void setArea(float)
Set the area.
LVL1::GBlockBuilder::GBlockBuilder
GBlockBuilder(const std::string &name, ISvcLocator *pSvcLocator)
Definition: GBlockBuilder.cxx:24
AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
xAOD::GBlock_v1
Definition: GBlock_v1.h:17
xAOD::GBlock_v1::setdPhi
void setdPhi(float)
xAOD::GBlock_v1::setSeedTowerLink
void setSeedTowerLink(const ElementLink< JGTowerContainer > &link)
Set the seed link.
Definition: GBlock_v1.cxx:95
xAOD::JGTower_v1::eta
virtual double eta() const final
The pseudorapidity ( ) of the particle.
Definition: JGTower_v1.cxx:60
SG::ConstAccessor
Helper class to provide constant type-safe access to aux data.
Definition: ConstAccessor.h:54
GTowerHelpers.h
xAOD::GBlock_v1::setEt
void setEt(float)
GBlockBuilder.h
LVL1
eFexTowerBuilder creates xAOD::eFexTowerContainer from supercells (LATOME) and triggerTowers (TREX) i...
Definition: ICMMCPHitsCnvTool.h:18
postInclude.inputs
inputs
Definition: postInclude.SortInput.py:15
xAOD::GBlock
GBlock_v1 GBlock
Define the latest version of the GBlock class.
Definition: GBlock.h:15
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition: ReadCondHandle.h:270
WriteHandle.h
Handle class for recording to StoreGate.
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
LVL1::GBlockBuilder::m_gBlocksKey
SG::WriteHandleKey< xAOD::GBlockContainer > m_gBlocksKey
Definition: GBlockBuilder.h:27
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
DMTest::links
links
Definition: CLinks_v1.cxx:22
xAOD::JGTower_v1::dphi
virtual double dphi() const final
The azimuthal angle ( ) of the particle.
Definition: JGTower_v1.cxx:97
TauGNNUtils::Variables::Track::dPhi
bool dPhi(const xAOD::TauJet &tau, const xAOD::TauTrack &track, double &out)
Definition: TauGNNUtils.cxx:530
LVL1::GBlockBuilder::m_towersKey
SG::ReadHandleKey< xAOD::JGTowerContainer > m_towersKey
Definition: GBlockBuilder.h:26
xAOD::GBlock_v1::setdEta
void setdEta(float)
xAOD::GBlock_v1::setTowerLinks
void setTowerLinks(const std::vector< ElementLink< JGTowerContainer >> &links)
set the tower links
Definition: GBlock_v1.cxx:101
xAOD::JGTower_v1::deta
virtual double deta() const final
The pseudorapidity ( ) of the particle.
Definition: JGTower_v1.cxx:85
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
TrigConf::name
Definition: HLTChainList.h:35
LVL1::GBlockBuilder::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition: GBlockBuilder.cxx:41
xAOD::GBlock_v1::setPhi
void setPhi(double)
GBlock.h
GBlockAuxContainer.h
RunTileMonitoring.towers
towers
Definition: RunTileMonitoring.py:133
LVL1::GBlockBuilder::m_forwardEta
float m_forwardEta
Definition: GBlockBuilder.h:28
LVL1::GBlockBuilder::initialize
virtual StatusCode initialize() override
Definition: GBlockBuilder.cxx:34
LVL1::gFEX::FPGA
FPGA
Definition: GTowerHelpers.h:17
area
double area(double R)
Definition: ConvertStaveServices.cxx:42
ReadHandle.h
Handle class for reading from StoreGate.
TauGNNUtils::Variables::Track::dEta
bool dEta(const xAOD::TauJet &tau, const xAOD::TauTrack &track, double &out)
Definition: TauGNNUtils.cxx:525
xAOD::GBlock_v1::setEta
void setEta(double)