ATLAS Offline Software
eFEXBDT.h
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 // eFEXBDT .h
7 // -------------------
8 // begin : 14 07 2022
9 // email : david.reikher@cern.ch
10 // **************************************************************************
11 
12 #include "L1CaloFEXSim/conifer.h"
13 #include "nlohmann/json.hpp"
14 #include <fstream>
15 
16 struct BDTVariable {
17  std::string m_name;
18  std::vector<std::vector<int>> m_scells;
19 
20 public:
21  friend void from_json(const nlohmann::json &j, BDTVariable &o) {
22  j.at("name").get_to(o.m_name);
23  j.at("scells").get_to(o.m_scells);
24  }
25 };
26 
27 class eFEXBDT {
28 
29 private:
30  std::vector<BDTVariable> m_variables;
31  std::vector<std::vector<int>> m_et_scells;
32  std::vector<std::vector<int>> m_em_et_scells;
33  std::vector<std::vector<int>> m_had_et_scells;
34  std::vector<std::vector<std::vector<int>>> m_towers_scells;
37 
38 public:
39  // Define how to read this class to/from JSON
40  friend void from_json(const nlohmann::json &j, eFEXBDT &o) {
41  j.at("variables").get_to(o.m_variables);
42  j.at("et_scells").get_to(o.m_et_scells);
43  j.at("em_et_scells").get_to(o.m_em_et_scells);
44  j.at("had_et_scells").get_to(o.m_had_et_scells);
45  j.at("towers_scells").get_to(o.m_towers_scells);
46  j.at("score_precision").get_to(o.m_score_precision);
47  j.at("bdt").get_to(o.m_bdt);
48  }
49 
50  eFEXBDT(std::string filename) {
51  /* Construct the BDT from conifer cpp backend JSON file */
52  std::ifstream ifs(filename);
54  from_json(j, *this);
55  m_bdt.init();
56  }
57 
58  const std::vector<BDTVariable> &getVariables() const { return m_variables; }
59 
60  const std::vector<std::vector<int>> &getETSCells() const {
61  return m_et_scells;
62  }
63 
64  const std::vector<std::vector<int>> &getEMETSCells() const {
65  return m_em_et_scells;
66  }
67 
68  const std::vector<std::vector<int>> &getHADETSCells() const {
69  return m_had_et_scells;
70  }
71 
73  return m_bdt;
74  }
75 
76  const std::vector<std::vector<int>> &getTowerSCells(int towerIndex) const {
77  return m_towers_scells[towerIndex];
78  }
79 
80  int getNTowers() const { return m_towers_scells.size(); }
81 
82  int getScorePrecision() const { return m_score_precision; }
83 };
eFEXBDT::getBDT
const conifer::BDT< unsigned int, unsigned int > & getBDT() const
Definition: eFEXBDT.h:72
json
nlohmann::json json
Definition: HistogramDef.cxx:9
eFEXBDT::m_towers_scells
std::vector< std::vector< std::vector< int > > > m_towers_scells
Definition: eFEXBDT.h:34
eFEXBDT::getVariables
const std::vector< BDTVariable > & getVariables() const
Definition: eFEXBDT.h:58
parse
std::map< std::string, std::string > parse(const std::string &list)
Definition: egammaLayerRecalibTool.cxx:1054
eFEXBDT::m_bdt
conifer::BDT< unsigned int, unsigned int > m_bdt
Definition: eFEXBDT.h:35
eFEXBDT::m_score_precision
int m_score_precision
Definition: eFEXBDT.h:36
BDTVariable::from_json
friend void from_json(const nlohmann::json &j, BDTVariable &o)
Definition: eFEXBDT.h:21
conifer::BDT< unsigned int, unsigned int >
eFEXBDT::getETSCells
const std::vector< std::vector< int > > & getETSCells() const
Definition: eFEXBDT.h:60
conifer::BDT::init
void init()
Definition: conifer.h:102
eFEXBDT
Definition: eFEXBDT.h:27
eFEXBDT::m_had_et_scells
std::vector< std::vector< int > > m_had_et_scells
Definition: eFEXBDT.h:33
eFEXBDT::getEMETSCells
const std::vector< std::vector< int > > & getEMETSCells() const
Definition: eFEXBDT.h:64
BDTVariable::m_scells
std::vector< std::vector< int > > m_scells
Definition: eFEXBDT.h:18
eFEXBDT::m_variables
std::vector< BDTVariable > m_variables
Definition: eFEXBDT.h:30
eFEXBDT::from_json
friend void from_json(const nlohmann::json &j, eFEXBDT &o)
Definition: eFEXBDT.h:40
eFEXBDT::getNTowers
int getNTowers() const
Definition: eFEXBDT.h:80
eFEXBDT::getScorePrecision
int getScorePrecision() const
Definition: eFEXBDT.h:82
BDTVariable::m_name
std::string m_name
Definition: eFEXBDT.h:17
eFEXBDT::getTowerSCells
const std::vector< std::vector< int > > & getTowerSCells(int towerIndex) const
Definition: eFEXBDT.h:76
CaloCellTimeCorrFiller.filename
filename
Definition: CaloCellTimeCorrFiller.py:24
conifer.h
eFEXBDT::eFEXBDT
eFEXBDT(std::string filename)
Definition: eFEXBDT.h:50
eFEXBDT::m_em_et_scells
std::vector< std::vector< int > > m_em_et_scells
Definition: eFEXBDT.h:32
eFEXBDT::m_et_scells
std::vector< std::vector< int > > m_et_scells
Definition: eFEXBDT.h:31
eFEXBDT::getHADETSCells
const std::vector< std::vector< int > > & getHADETSCells() const
Definition: eFEXBDT.h:68
BDTVariable
Definition: eFEXBDT.h:16