ATLAS Offline Software
eFEXtauAlgoBase.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 //***********************************************************************************
6 // eFEXtauAlgoBase.cxx
7 // -------------------
8 // begin : 08 05 2023
9 // email : david.reikher@cern.ch,
10 // nicholas.andrew.luongo@cern.ch
11 // *********************************************************************************/
12 
15 
17  const std::string &name,
18  const IInterface *parent)
19  : AthAlgTool(type, name, parent) {
20  declareInterface<IeFEXtauAlgo>(this);
21 }
22 
24 
26 
28  m_eTowerContainerKey /*,ctx*/);
29  if (!eTowerContainer.isValid()) {
30  ATH_MSG_FATAL("Could not retrieve eTowerContainer "
31  << m_eTowerContainerKey.key());
32  return StatusCode::FAILURE;
33  }
34  return StatusCode::SUCCESS;
35 }
36 
37 // Build arrays holding cell ETs for each layer plus entire tower
38 void LVL1::eFEXtauAlgoBase::buildLayers(int efex_id, int fpga_id,
39  int central_eta) {
40 
42  m_eTowerContainerKey /*,ctx*/);
43 
44  for (unsigned int ieta = 0; ieta < 3; ieta++) {
45  for (unsigned int iphi = 0; iphi < 3; iphi++) {
46  if (((efex_id % 3 == 0) && (fpga_id == 0) && (central_eta == 0) &&
47  (ieta == 0)) ||
48  ((efex_id % 3 == 2) && (fpga_id == 3) && (central_eta == 5) &&
49  (ieta == 2))) {
50  m_twrcells[ieta][iphi] = 0;
51  m_em0cells[ieta][iphi] = 0;
52  m_em3cells[ieta][iphi] = 0;
53  m_hadcells[ieta][iphi] = 0;
54  for (unsigned int i = 0; i < 4; i++) {
55  m_em1cells[4 * ieta + i][iphi] = 0;
56  m_em2cells[4 * ieta + i][iphi] = 0;
57  }
58  } else {
59  const LVL1::eTower *tmpTower =
60  eTowerContainer->findTower(m_eFexalgoTowerID[iphi][ieta]);
61  m_twrcells[ieta][iphi] = tmpTower->getTotalET();
62  m_em0cells[ieta][iphi] = tmpTower->getLayerTotalET(0);
63  m_em3cells[ieta][iphi] = tmpTower->getLayerTotalET(3);
64  m_hadcells[ieta][iphi] = tmpTower->getLayerTotalET(4);
65  for (unsigned int i = 0; i < 4; i++) {
66  m_em1cells[4 * ieta + i][iphi] = tmpTower->getET(1, i);
67  m_em2cells[4 * ieta + i][iphi] = tmpTower->getET(2, i);
68  }
69  }
70  }
71  }
72  m_cellsSet = true;
73 }
74 
75 // Utility function to calculate and return jet discriminant sums for specified
76 // location Intended to allow xAOD TOBs to be decorated with this information
77 void LVL1::eFEXtauAlgoBase::getSums(unsigned int /*seed*/, bool /*UnD*/,
78  std::vector<unsigned int> &RcoreSums,
79  std::vector<unsigned int> &RemSums) {
80  // Set seed parameters to supplied values
81 
82  // Now just call the 2 discriminant calculation methods
83  getRCore(RcoreSums);
84  getRHad(RemSums);
85 }
86 
87 // Calculate the hadronic fraction isolation variable
88 void LVL1::eFEXtauAlgoBase::getRHad(std::vector<unsigned int> &rHadVec) const {
89  unsigned int core = rHadCore();
90  unsigned int env = rHadEnv();
91 
92  rHadVec.push_back(core);
93  rHadVec.push_back(env);
94 }
95 
96 // Calculate float isolation variable
98  unsigned int core = rCoreCore();
99  unsigned int env = rCoreEnv();
100 
101  unsigned int num = core;
102  unsigned int denom = core + env;
103 
104  float out = denom ? static_cast<float>(num) / static_cast<float>(denom) : 0;
105 
106  return out;
107 }
108 
110  unsigned int core = rHadCore();
111  unsigned int env = rHadEnv();
112 
113  unsigned int num = core;
114  unsigned int denom = core + env;
115 
116  float out = denom ? static_cast<float>(num) / static_cast<float>(denom) : 0;
117 
118  return out;
119 }
120 
122  std::vector<unsigned int> &rCoreVec) const {
123  unsigned int core = rCoreCore();
124  unsigned int env = rCoreEnv();
125 
126  rCoreVec.push_back(core);
127  rCoreVec.push_back(env);
128 }
129 
130 // Check if central tower qualifies as a seed tower for the tau algorithm
132  // Need layer cell ET arrays to be built
133  if (m_cellsSet == false) {
135  "Layers not built, cannot accurately determine if a seed tower.");
136  }
137 
138  bool out = true;
139 
140  // Get central tower ET
141  unsigned int centralET = m_twrcells[1][1];
142 
143  // Loop over all cells and check that the central tower is a local maximum
144  for (unsigned int beta = 0; beta < 3; beta++) {
145  for (unsigned int bphi = 0; bphi < 3; bphi++) {
146  // Don't need to compare central cell with itself
147  if ((beta == 1) && (bphi == 1)) {
148  continue;
149  }
150 
151  // Cells to the up and right must have strictly lesser ET
152  if (beta == 2 || (beta == 1 && bphi == 2)) {
153  if (centralET <= m_twrcells[beta][bphi]) {
154  out = false;
155  }
156  }
157  // Cells down and to the left must have lesser or equal ET. If strictly
158  // lesser would create zero TOB if two adjacent cells had equal energy
159  else if (beta == 0 || (beta == 1 && bphi == 0)) {
160  if (centralET < m_twrcells[beta][bphi]) {
161  out = false;
162  }
163  }
164  }
165  }
166 
167  return out;
168 }
169 
171  if (!m_dumpSCells) {
172  tob->setSuperCellEncoder(nullptr);
173  return;
174  }
175 
176  std::unique_ptr<SCellEncoder> scellEncoder = std::make_unique<SCellEncoder>();
177  scellEncoder->setSuperCells(m_em0cells, m_em1cells, m_em2cells, m_em3cells,
178  m_hadcells);
179  tob->setSuperCellEncoder(std::move(scellEncoder));
180 }
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
LVL1::eTower::getTotalET
int getTotalET() const
Get ET sum of all cells in the eTower in MeV.
Definition: eTower.cxx:194
LVL1::eTower
The eTower class is an interface object for eFEX trigger algorithms The purposes are twofold:
Definition: eTower.h:38
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
LVL1::eFEXtauAlgoBase::safetyTest
virtual StatusCode safetyTest() override
Definition: eFEXtauAlgoBase.cxx:25
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
LVL1::SCellEncoder::setSuperCells
void setSuperCells(const unsigned int layer0[][3], const unsigned int layer1[][3], const unsigned int layer2[][3], const unsigned int layer3[][3], const unsigned int layer4[][3])
Definition: SCellEncoder.cxx:13
LVL1::eFEXtauAlgoBase::setSCellEncoder
void setSCellEncoder(LVL1::eFEXtauTOB *tob) const
Definition: eFEXtauAlgoBase.cxx:170
lumiFormat.i
int i
Definition: lumiFormat.py:92
LVL1::eFEXtauAlgoBase::getRealRCore
virtual float getRealRCore() const override
Definition: eFEXtauAlgoBase.cxx:97
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
test_pyathena.parent
parent
Definition: test_pyathena.py:15
LVL1::eFEXtauTOB::setSuperCellEncoder
void setSuperCellEncoder(std::unique_ptr< SCellEncoder > scell_encoder)
Definition: eFEXtauTOB.cxx:121
LVL1::eFEXtauAlgoBase::getRealRHad
virtual float getRealRHad() const override
Definition: eFEXtauAlgoBase.cxx:109
LVL1::eTower::getET
int getET(unsigned int layer, int cell=0) const
Get ET of a specified cell in MeV.
Definition: eTower.cxx:172
LVL1::eTowerContainer
Definition: eTowerContainer.h:35
compute_lumi.denom
denom
Definition: compute_lumi.py:76
TrigConf::name
Definition: HLTChainList.h:35
LVL1::eTower::getLayerTotalET
int getLayerTotalET(unsigned int layer) const
Get total ET sum of all cells in a given layer in MeV.
Definition: eTower.cxx:249
trigbs_pickEvents.num
num
Definition: trigbs_pickEvents.py:76
LVL1::eFEXtauAlgoBase::getSums
virtual void getSums(unsigned int seed, bool UnD, std::vector< unsigned int > &RcoreSums, std::vector< unsigned int > &Remums) override
Definition: eFEXtauAlgoBase.cxx:77
LVL1::eFEXtauTOB
Definition: eFEXtauTOB.h:19
LVL1::eFEXtauAlgoBase::isCentralTowerSeed
virtual bool isCentralTowerSeed() const override
Definition: eFEXtauAlgoBase.cxx:131
LVL1::eFEXtauAlgoBase::~eFEXtauAlgoBase
virtual ~eFEXtauAlgoBase()
Destructor.
Definition: eFEXtauAlgoBase.cxx:23
LVL1::eFEXtauAlgoBase::getRCore
virtual void getRCore(std::vector< unsigned int > &rCoreVec) const override
Definition: eFEXtauAlgoBase.cxx:121
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
SCellEncoder.h
eFEXtauAlgoBase.h
LVL1::eFEXtauAlgoBase::buildLayers
void buildLayers(int efex_id, int fpga_id, int central_eta)
Definition: eFEXtauAlgoBase.cxx:38
LVL1::eFEXtauAlgoBase::getRHad
virtual void getRHad(std::vector< unsigned int > &rHadVec) const override
Definition: eFEXtauAlgoBase.cxx:88
AthAlgTool
Definition: AthAlgTool.h:26
LVL1::eTowerContainer::findTower
const LVL1::eTower * findTower(int towerID) const
fast find method given identifier.
Definition: eTowerContainer.cxx:29
MuonParameters::beta
@ beta
Definition: MuonParamDefs.h:144
python.DataFormatRates.env
env
Definition: DataFormatRates.py:32
LVL1::eFEXtauAlgoBase::eFEXtauAlgoBase
eFEXtauAlgoBase(const std::string &type, const std::string &name, const IInterface *parent)
Constructors.
Definition: eFEXtauAlgoBase.cxx:16