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 
14 
16  const std::string &name,
17  const IInterface *parent)
18  : AthAlgTool(type, name, parent) {
19  declareInterface<IeFEXtauAlgo>(this);
20 }
21 
23 
25 
27  m_eTowerContainerKey /*,ctx*/);
28  if (!eTowerContainer.isValid()) {
29  ATH_MSG_FATAL("Could not retrieve eTowerContainer "
30  << m_eTowerContainerKey.key());
31  return StatusCode::FAILURE;
32  }
33  return StatusCode::SUCCESS;
34 }
35 
36 // Build arrays holding cell ETs for each layer plus entire tower
37 void LVL1::eFEXtauAlgoBase::buildLayers(int efex_id, int fpga_id,
38  int central_eta) {
39 
41  m_eTowerContainerKey /*,ctx*/);
42 
43  for (unsigned int ieta = 0; ieta < 3; ieta++) {
44  for (unsigned int iphi = 0; iphi < 3; iphi++) {
45  if (((efex_id % 3 == 0) && (fpga_id == 0) && (central_eta == 0) &&
46  (ieta == 0)) ||
47  ((efex_id % 3 == 2) && (fpga_id == 3) && (central_eta == 5) &&
48  (ieta == 2))) {
49  m_twrcells[ieta][iphi] = 0;
50  m_em0cells[ieta][iphi] = 0;
51  m_em3cells[ieta][iphi] = 0;
52  m_hadcells[ieta][iphi] = 0;
53  for (unsigned int i = 0; i < 4; i++) {
54  m_em1cells[4 * ieta + i][iphi] = 0;
55  m_em2cells[4 * ieta + i][iphi] = 0;
56  }
57  } else {
58  const LVL1::eTower *tmpTower =
59  eTowerContainer->findTower(m_eFexalgoTowerID[iphi][ieta]);
60  m_twrcells[ieta][iphi] = tmpTower->getTotalET();
61  m_em0cells[ieta][iphi] = tmpTower->getLayerTotalET(0);
62  m_em3cells[ieta][iphi] = tmpTower->getLayerTotalET(3);
63  m_hadcells[ieta][iphi] = tmpTower->getLayerTotalET(4);
64  for (unsigned int i = 0; i < 4; i++) {
65  m_em1cells[4 * ieta + i][iphi] = tmpTower->getET(1, i);
66  m_em2cells[4 * ieta + i][iphi] = tmpTower->getET(2, i);
67  }
68  }
69  }
70  }
71  m_cellsSet = true;
72 }
73 
74 // Utility function to calculate and return jet discriminant sums for specified
75 // location Intended to allow xAOD TOBs to be decorated with this information
76 void LVL1::eFEXtauAlgoBase::getSums(unsigned int /*seed*/, bool /*UnD*/,
77  std::vector<unsigned int> &RcoreSums,
78  std::vector<unsigned int> &RemSums) {
79  // Set seed parameters to supplied values
80 
81  // Now just call the 2 discriminant calculation methods
82  getRCore(RcoreSums);
83  getRHad(RemSums);
84 }
85 
86 // Calculate the hadronic fraction isolation variable
87 void LVL1::eFEXtauAlgoBase::getRHad(std::vector<unsigned int> &rHadVec) const {
88  unsigned int core = rHadCore();
89  unsigned int env = rHadEnv();
90 
91  rHadVec.push_back(core);
92  rHadVec.push_back(env);
93 }
94 
95 // Calculate float isolation variable
97  unsigned int core = rCoreCore();
98  unsigned int env = rCoreEnv();
99 
100  unsigned int num = core;
101  unsigned int denom = core + env;
102 
103  float out = denom ? static_cast<float>(num) / static_cast<float>(denom) : 0;
104 
105  return out;
106 }
107 
109  unsigned int core = rHadCore();
110  unsigned int env = rHadEnv();
111 
112  unsigned int num = core;
113  unsigned int denom = core + env;
114 
115  float out = denom ? static_cast<float>(num) / static_cast<float>(denom) : 0;
116 
117  return out;
118 }
119 
121  std::vector<unsigned int> &rCoreVec) const {
122  unsigned int core = rCoreCore();
123  unsigned int env = rCoreEnv();
124 
125  rCoreVec.push_back(core);
126  rCoreVec.push_back(env);
127 }
128 
129 // Check if central tower qualifies as a seed tower for the tau algorithm
131  // Need layer cell ET arrays to be built
132  if (m_cellsSet == false) {
134  "Layers not built, cannot accurately determine if a seed tower.");
135  }
136 
137  bool out = true;
138 
139  // Get central tower ET
140  unsigned int centralET = m_twrcells[1][1];
141 
142  // Loop over all cells and check that the central tower is a local maximum
143  for (unsigned int beta = 0; beta < 3; beta++) {
144  for (unsigned int bphi = 0; bphi < 3; bphi++) {
145  // Don't need to compare central cell with itself
146  if ((beta == 1) && (bphi == 1)) {
147  continue;
148  }
149 
150  // Cells to the up and right must have strictly lesser ET
151  if (beta == 2 || (beta == 1 && bphi == 2)) {
152  if (centralET <= m_twrcells[beta][bphi]) {
153  out = false;
154  }
155  }
156  // Cells down and to the left must have lesser or equal ET. If strictly
157  // lesser would create zero TOB if two adjacent cells had equal energy
158  else if (beta == 0 || (beta == 1 && bphi == 0)) {
159  if (centralET < m_twrcells[beta][bphi]) {
160  out = false;
161  }
162  }
163  }
164  }
165 
166  return out;
167 }
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:24
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
lumiFormat.i
int i
Definition: lumiFormat.py:85
LVL1::eFEXtauAlgoBase::getRealRCore
virtual float getRealRCore() const override
Definition: eFEXtauAlgoBase.cxx:96
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::eFEXtauAlgoBase::getRealRHad
virtual float getRealRHad() const override
Definition: eFEXtauAlgoBase.cxx:108
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:76
LVL1::eFEXtauAlgoBase::isCentralTowerSeed
virtual bool isCentralTowerSeed() const override
Definition: eFEXtauAlgoBase.cxx:130
LVL1::eFEXtauAlgoBase::~eFEXtauAlgoBase
virtual ~eFEXtauAlgoBase()
Destructor.
Definition: eFEXtauAlgoBase.cxx:22
LVL1::eFEXtauAlgoBase::getRCore
virtual void getRCore(std::vector< unsigned int > &rCoreVec) const override
Definition: eFEXtauAlgoBase.cxx:120
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
eFEXtauAlgoBase.h
LVL1::eFEXtauAlgoBase::buildLayers
void buildLayers(int efex_id, int fpga_id, int central_eta)
Definition: eFEXtauAlgoBase.cxx:37
LVL1::eFEXtauAlgoBase::getRHad
virtual void getRHad(std::vector< unsigned int > &rHadVec) const override
Definition: eFEXtauAlgoBase.cxx:87
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:15