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  return tob;
82 }
83 
85  for (int phi = 0; phi < 3; phi++) {
86  for (int eta = 0; eta < 3; eta++) {
87  // Coarse layers
88  m_bdtAlgoImpl->setPointerToSCell(eta, phi, 0, &m_em0cells[eta][phi]);
89  m_bdtAlgoImpl->setPointerToSCell(eta, phi, 3, &m_em3cells[eta][phi]);
90  m_bdtAlgoImpl->setPointerToSCell(eta, phi, 4, &m_hadcells[eta][phi]);
91  }
92  for (int eta = 0; eta < 12; eta++) {
93  // Fine layers
94  m_bdtAlgoImpl->setPointerToSCell(eta, phi, 1, &m_em1cells[eta][phi]);
95  m_bdtAlgoImpl->setPointerToSCell(eta, phi, 2, &m_em2cells[eta][phi]);
96  }
97  }
98 }
99 
101  for (int i = 0; i < 3; i++) {
102  m_bdtAlgoImpl->setPointerToFracMultipliersParam(i,
103  &(m_hadFracMultipliers[i]));
104  }
105 
106  for (int i = 0; i < 3; i++) {
107  m_bdtAlgoImpl->setPointerToBDTThresholdsParam(i, &(m_bdtThresholds[i]));
108  }
109 
110  m_bdtAlgoImpl->setPointerToMaxETParam(&m_maxEtThreshold);
111  m_bdtAlgoImpl->setPointerToETThresholdParam(&m_etThreshold);
112  m_bdtAlgoImpl->setPointerToBDTMinETParam(&m_bdtMinEtThreshold);
113 }
114 
115 // Calculate reconstructed ET value
116 unsigned int LVL1::eFEXtauBDTAlgo::getEt() const {
117  if (m_cellsSet == false) {
118  ATH_MSG_DEBUG("Layers not built, cannot accurately calculate Et.");
119  }
120 
121  return m_bdtAlgoImpl->getETEstimate();
122 }
123 
124 unsigned int LVL1::eFEXtauBDTAlgo::rHadCore() const {
125  if (m_cellsSet == false) {
126  ATH_MSG_DEBUG("Layers not built, cannot calculate rHad core value");
127  }
128 
129  return m_bdtAlgoImpl->getHADETEstimate();
130 }
131 
132 unsigned int LVL1::eFEXtauBDTAlgo::rHadEnv() const {
133  if (m_cellsSet == false) {
134  ATH_MSG_DEBUG("Layers not built, cannot calculate rHad environment value");
135  }
136 
137  return m_bdtAlgoImpl->getEMETEstimate();
138 }
139 
140 // Return the bitwise value of the given Et
141 // See eFEXtauBaseAlgo for a first attempt at this
143  if (m_cellsSet == false) {
144  ATH_MSG_DEBUG("Layers not built, cannot accurately calculate Et.");
145  }
146 
147  return m_bdtAlgoImpl->getET();
148 }
149 
150 unsigned int LVL1::eFEXtauBDTAlgo::getBDTScore() const {
151  return m_bdtAlgoImpl->getBDTScore();
152 }
153 
155  return m_bdtAlgoImpl->getBDTCondition();
156 }
157 
159  return m_bdtAlgoImpl->getFracCondition();
160 }
161 
162 bool LVL1::eFEXtauBDTAlgo::isBDT() const { return true; }
163 
165  const std::vector<unsigned int> &rHadThreshold,
166  const std::vector<unsigned int> &bdtThreshold, unsigned int etThreshold,
167  unsigned int maxEtThreshold, unsigned int bdtMinEtThreshold) {
168  for (int i = 0; i < 3; i++) {
169  m_hadFracMultipliers[i] = rHadThreshold[i];
170  m_bdtThresholds[i] = bdtThreshold[i];
171  }
172  m_etThreshold = etThreshold;
173  m_maxEtThreshold = maxEtThreshold;
174  m_bdtMinEtThreshold = bdtMinEtThreshold;
175 }
LVL1::eFEXtauBDTAlgo::isBDT
virtual bool isBDT() const override
Definition: eFEXtauBDTAlgo.cxx:162
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
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
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:154
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:150
LVL1::eFEXtauBDTAlgo::rHadCore
virtual unsigned int rHadCore() const override
Definition: eFEXtauBDTAlgo.cxx:124
LVL1::eFEXtauBDTAlgo::getEt
virtual unsigned int getEt() const override
Definition: eFEXtauBDTAlgo.cxx:116
LVL1::eFEXtauBDTAlgo::~eFEXtauBDTAlgo
virtual ~eFEXtauBDTAlgo()
Destructor.
Definition: eFEXtauBDTAlgo.cxx:27
LVL1::eFEXtauTOB::setEt
void setEt(unsigned int)
Definition: eFEXtauTOB.cxx:26
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:51
lumiFormat.i
int i
Definition: lumiFormat.py:85
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:76
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
LVL1::eFEXtauBDTAlgo::setThresholdPointers
void setThresholdPointers()
Definition: eFEXtauBDTAlgo.cxx:100
TrigConf::name
Definition: HLTChainList.h:35
PathResolver.h
LVL1::eFEXtauTOB::setRcoreCore
void setRcoreCore(unsigned int)
Definition: eFEXtauTOB.cxx:61
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:164
LVL1::eFEXtauBDTAlgo::setSCellPointers
void setSCellPointers()
Definition: eFEXtauBDTAlgo.cxx:84
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:132
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:158
LVL1::eFEXtauTOB::setBitwiseEt
void setBitwiseEt(unsigned int)
Definition: eFEXtauTOB.cxx:31
LVL1::eFEXtauTOB::setRcoreEnv
void setRcoreEnv(unsigned int)
Definition: eFEXtauTOB.cxx:66
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
LVL1::eFEXtauTOB::setIso
void setIso(unsigned int)
Definition: eFEXtauTOB.cxx:36
LVL1::eFEXtauBDTAlgo::getBitwiseEt
virtual unsigned int getBitwiseEt() const override
Definition: eFEXtauBDTAlgo.cxx:142
LVL1::eFEXtauTOB::setIsBDTAlgo
void setIsBDTAlgo(unsigned int)
Definition: eFEXtauTOB.cxx:86
calibdata.copy
bool copy
Definition: calibdata.py:27
LVL1::eFEXtauTOB::setRhadCore
void setRhadCore(unsigned int)
Definition: eFEXtauTOB.cxx:71
eTower.h
LVL1::eFEXtauTOB::setBDTScore
void setBDTScore(unsigned int)
Definition: eFEXtauTOB.cxx:81