ATLAS Offline Software
eFEXtauBDTAlgo.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 // eFEXtauBDTAlgo - description
7 // --------------------
8 // begin : 05 06 2020
9 // email : david.reikher@cern.ch
10 //*************************************************************************
11 
12 #include <iostream>
13 
16 #include "L1CaloFEXSim/eTower.h"
18 #include <stdio.h> /* defines FILENAME_MAX */
19 
20 // default constructor for persistency
22  const std::string &name,
23  const IInterface *parent)
25 
28 
30  ATH_CHECK(m_eTowerContainerKey.initialize());
31  std::string configPath = PathResolver::find_file(
32  m_bdtJsonConfigPath, "DATAPATH", PathResolver::RecursiveSearch);
33  ATH_MSG_INFO("Using BDT config file " << configPath);
34  if (configPath.size() == 0) {
35  ATH_MSG_ERROR("Cannot locate BDT config file " << m_bdtJsonConfigPath);
36  return StatusCode::FAILURE;
37  }
38 
39  m_bdtAlgoImpl = std::make_unique<eFEXtauBDT>(this, configPath);
40 
41  try {
42  setSCellPointers();
43  setThresholdPointers();
44  m_bdtAlgoImpl->initBDTVars();
45  m_bdtAlgoImpl->initETPointers();
46  m_bdtAlgoImpl->initEMETPointers();
47  m_bdtAlgoImpl->initHADETPointers();
48  m_bdtAlgoImpl->initTowersPointers();
49  } catch (const std::domain_error &ex) {
50  ATH_MSG_ERROR(ex.what());
51  return StatusCode::FAILURE;
52  }
53 
54  ATH_MSG_INFO("tau Algorithm version: BDT");
55  return StatusCode::SUCCESS;
56 }
57 
58 void LVL1::eFEXtauBDTAlgo::setup(int inputTable[3][3], int efex_id, int fpga_id,
59  int central_eta) {
60 
61  std::copy(&inputTable[0][0], &inputTable[0][0] + 9, &m_eFexalgoTowerID[0][0]);
62 
63  buildLayers(efex_id, fpga_id, central_eta);
64 }
65 
66 void LVL1::eFEXtauBDTAlgo::compute() { m_bdtAlgoImpl->next(); }
67 
68 std::unique_ptr<LVL1::eFEXtauTOB> LVL1::eFEXtauBDTAlgo::getTauTOB() const {
69  std::unique_ptr<eFEXtauTOB> tob = std::make_unique<eFEXtauTOB>();
70  unsigned int et = getEt();
71  tob->setEt(et);
72  tob->setRcoreCore(rCoreCore());
73  tob->setRcoreEnv(rCoreEnv());
74  tob->setRhadCore(rHadCore());
75  tob->setRhadEnv(rHadEnv());
76  tob->setBitwiseEt(getBitwiseEt());
77  tob->setIso(getRealRCore());
78  tob->setSeedUnD(0);
79  tob->setBDTScore(m_bdtAlgoImpl->getBDTScore());
80  tob->setIsBDTAlgo(1);
81  setSCellEncoder(tob.get());
82  return tob;
83 }
84 
86  for (int phi = 0; phi < 3; phi++) {
87  for (int eta = 0; eta < 3; eta++) {
88  // Coarse layers
89  m_bdtAlgoImpl->setPointerToSCell(eta, phi, 0, &m_em0cells[eta][phi]);
90  m_bdtAlgoImpl->setPointerToSCell(eta, phi, 3, &m_em3cells[eta][phi]);
91  m_bdtAlgoImpl->setPointerToSCell(eta, phi, 4, &m_hadcells[eta][phi]);
92  }
93  for (int eta = 0; eta < 12; eta++) {
94  // Fine layers
95  m_bdtAlgoImpl->setPointerToSCell(eta, phi, 1, &m_em1cells[eta][phi]);
96  m_bdtAlgoImpl->setPointerToSCell(eta, phi, 2, &m_em2cells[eta][phi]);
97  }
98  }
99 }
100 
102  for (int i = 0; i < 3; i++) {
103  m_bdtAlgoImpl->setPointerToFracMultipliersParam(i,
104  &(m_hadFracMultipliers[i]));
105  }
106 
107  for (int i = 0; i < 3; i++) {
108  m_bdtAlgoImpl->setPointerToBDTThresholdsParam(i, &(m_bdtThresholds[i]));
109  }
110 
111  m_bdtAlgoImpl->setPointerToMaxETParam(&m_maxEtThreshold);
112  m_bdtAlgoImpl->setPointerToETThresholdParam(&m_etThreshold);
113  m_bdtAlgoImpl->setPointerToBDTMinETParam(&m_bdtMinEtThreshold);
114 }
115 
116 // Calculate reconstructed ET value
117 unsigned int LVL1::eFEXtauBDTAlgo::getEt() const {
118  if (m_cellsSet == false) {
119  ATH_MSG_DEBUG("Layers not built, cannot accurately calculate Et.");
120  }
121 
122  return m_bdtAlgoImpl->getETEstimate();
123 }
124 
125 unsigned int LVL1::eFEXtauBDTAlgo::rHadCore() const {
126  if (m_cellsSet == false) {
127  ATH_MSG_DEBUG("Layers not built, cannot calculate rHad core value");
128  }
129 
130  return m_bdtAlgoImpl->getHADETEstimate();
131 }
132 
133 unsigned int LVL1::eFEXtauBDTAlgo::rHadEnv() const {
134  if (m_cellsSet == false) {
135  ATH_MSG_DEBUG("Layers not built, cannot calculate rHad environment value");
136  }
137 
138  return m_bdtAlgoImpl->getEMETEstimate();
139 }
140 
141 // Return the bitwise value of the given Et
142 // See eFEXtauBaseAlgo for a first attempt at this
144  if (m_cellsSet == false) {
145  ATH_MSG_DEBUG("Layers not built, cannot accurately calculate Et.");
146  }
147 
148  return m_bdtAlgoImpl->getET();
149 }
150 
151 unsigned int LVL1::eFEXtauBDTAlgo::getBDTScore() const {
152  return m_bdtAlgoImpl->getBDTScore();
153 }
154 
156  return m_bdtAlgoImpl->getBDTCondition();
157 }
158 
160  return m_bdtAlgoImpl->getFracCondition();
161 }
162 
163 bool LVL1::eFEXtauBDTAlgo::isBDT() const { return true; }
164 
166  const std::vector<unsigned int> &rHadThreshold,
167  const std::vector<unsigned int> &bdtThreshold, unsigned int etThreshold,
168  unsigned int maxEtThreshold, unsigned int bdtMinEtThreshold) {
169  for (int i = 0; i < 3; i++) {
170  m_hadFracMultipliers[i] = rHadThreshold[i];
171  m_bdtThresholds[i] = bdtThreshold[i];
172  }
173  m_etThreshold = etThreshold;
174  m_maxEtThreshold = maxEtThreshold;
175  m_bdtMinEtThreshold = bdtMinEtThreshold;
176 }
LVL1::eFEXtauBDTAlgo::isBDT
virtual bool isBDT() const override
Definition: eFEXtauBDTAlgo.cxx:163
LVL1::eFEXtauBDTAlgo::compute
virtual void compute() override
Definition: eFEXtauBDTAlgo.cxx:66
et
Extra patterns decribing particle interation process.
PathResolver::RecursiveSearch
@ RecursiveSearch
Definition: PathResolver.h:28
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:64
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
PathResolver::find_file
static std::string find_file(const std::string &logical_file_name, const std::string &search_path, SearchType search_type=LocalSearch)
Definition: PathResolver.cxx:251
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:79
LVL1::eFEXtauBDTAlgo::setup
virtual void setup(int inputTable[3][3], int efex_id, int fpga_id, int central_eta) override
Definition: eFEXtauBDTAlgo.cxx:58
eFEXtauTOB.h
LVL1::eFEXtauBDTAlgo::getBDTCondition
virtual unsigned int getBDTCondition() const override
Definition: eFEXtauBDTAlgo.cxx:155
LVL1::eFEXtauBDTAlgo::getTauTOB
virtual std::unique_ptr< eFEXtauTOB > getTauTOB() const override
Definition: eFEXtauBDTAlgo.cxx:68
LVL1::eFEXtauBDTAlgo::getBDTScore
virtual unsigned int getBDTScore() const override
Definition: eFEXtauBDTAlgo.cxx:151
LVL1::eFEXtauBDTAlgo::rHadCore
virtual unsigned int rHadCore() const override
Definition: eFEXtauBDTAlgo.cxx:125
LVL1::eFEXtauBDTAlgo::getEt
virtual unsigned int getEt() const override
Definition: eFEXtauBDTAlgo.cxx:117
LVL1::eFEXtauBDTAlgo::~eFEXtauBDTAlgo
virtual ~eFEXtauBDTAlgo()
Destructor.
Definition: eFEXtauBDTAlgo.cxx:27
LVL1::eFEXtauTOB::setEt
void setEt(unsigned int)
Definition: eFEXtauTOB.cxx:44
eFEXtauBDTAlgo.h
LVL1::eFEXtauAlgoBase
The eFEXtauBDTAlgo class calculates the tau BDT TOB variables.
Definition: eFEXtauAlgoBase.h:28
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
LVL1::eFEXtauTOB::setSeedUnD
void setSeedUnD(bool)
Definition: eFEXtauTOB.cxx:69
lumiFormat.i
int i
Definition: lumiFormat.py:92
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::setRhadEnv
void setRhadEnv(unsigned int)
Definition: eFEXtauTOB.cxx:94
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
LVL1::eFEXtauBDTAlgo::setThresholdPointers
void setThresholdPointers()
Definition: eFEXtauBDTAlgo.cxx:101
TrigConf::name
Definition: HLTChainList.h:35
PathResolver.h
LVL1::eFEXtauTOB::setRcoreCore
void setRcoreCore(unsigned int)
Definition: eFEXtauTOB.cxx:79
LVL1::eFEXtauBDTAlgo::setThresholds
virtual void setThresholds(const std::vector< unsigned int > &rHadThreshold, const std::vector< unsigned int > &bdtThreshold, unsigned int etThreshold, unsigned int etThresholdForRHad, unsigned int bdtMinEtThreshold) override
Definition: eFEXtauBDTAlgo.cxx:165
LVL1::eFEXtauBDTAlgo::setSCellPointers
void setSCellPointers()
Definition: eFEXtauBDTAlgo.cxx:85
LVL1::eFEXtauBDTAlgo::eFEXtauBDTAlgo
eFEXtauBDTAlgo(const std::string &type, const std::string &name, const IInterface *parent)
Constructors.
Definition: eFEXtauBDTAlgo.cxx:21
LVL1::eFEXtauBDTAlgo::rHadEnv
virtual unsigned int rHadEnv() const override
Definition: eFEXtauBDTAlgo.cxx:133
LVL1::eFEXtauBDTAlgo::initialize
virtual StatusCode initialize() override
standard Athena-Algorithm method
Definition: eFEXtauBDTAlgo.cxx:29
LVL1::eFEXtauBDTAlgo::getBDTHadFracCondition
virtual unsigned int getBDTHadFracCondition() const override
Definition: eFEXtauBDTAlgo.cxx:159
LVL1::eFEXtauTOB::setBitwiseEt
void setBitwiseEt(unsigned int)
Definition: eFEXtauTOB.cxx:49
LVL1::eFEXtauTOB::setRcoreEnv
void setRcoreEnv(unsigned int)
Definition: eFEXtauTOB.cxx:84
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
LVL1::eFEXtauTOB::setIso
void setIso(unsigned int)
Definition: eFEXtauTOB.cxx:54
LVL1::eFEXtauBDTAlgo::getBitwiseEt
virtual unsigned int getBitwiseEt() const override
Definition: eFEXtauBDTAlgo.cxx:143
LVL1::eFEXtauTOB::setIsBDTAlgo
void setIsBDTAlgo(unsigned int)
Definition: eFEXtauTOB.cxx:104
calibdata.copy
bool copy
Definition: calibdata.py:27
LVL1::eFEXtauTOB::setRhadCore
void setRhadCore(unsigned int)
Definition: eFEXtauTOB.cxx:89
eTower.h
LVL1::eFEXtauTOB::setBDTScore
void setBDTScore(unsigned int)
Definition: eFEXtauTOB.cxx:99