ATLAS Offline Software
Loading...
Searching...
No Matches
Egamma1BDTAlgTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include "Egamma1BDTAlgTool.h"
6#include "../Utilities/dump.h"
11
12#include "../IO/eEmEg1BDTTOB.h"
13
14
15namespace GlobalSim {
16
18
20 const std::string& name,
21 const IInterface* parent) :
22 base_class(type, name, parent){
23 }
24
26
27 CHECK(m_nbhdTOBContainerReadKey.initialize());
28 CHECK(m_BDTResultKey.initialize());
29
30 return StatusCode::SUCCESS;
31 }
32
33 StatusCode
34 Egamma1BDTAlgTool::run(const EventContext& ctx) const {
35 ATH_MSG_DEBUG("run()");
36
37
38 // read in LArStrip neighborhood TOBs from the event store
39 auto in =
41 ctx);
42 CHECK(in.isValid());
43
44 ATH_MSG_DEBUG("read in " << (*in).size() << " neighborhoods");
45
47 CHECK(h_BDTResult.record(std::make_unique<eEmEg1BDTTOBContainer>()));
48
49 for (const auto nbhdTOB : *in) {
50 auto c_phi = combine_phi(nbhdTOB);
51 if (c_phi.empty()) {continue;} // corner case: not all phi have len 17
52 auto input = digitizer::digitize10(c_phi);
53
54 assert(input.size() == n_features);
55 ap_int<10>* c_input = &input[0]; // vector->array
56
58
59 // the bdt variable is already set up
60 bdt.decision_function(c_input, scores);
61 if (msgLevel() <= MSG::DEBUG) {
62 std::stringstream ss;
63 ss << "BDT input: ";
64 for (const auto& i : input) {ss << i << ' ';}
65 ATH_MSG_DEBUG(ss.str());
66 }
67
68 if (msgLevel() <= MSG::DEBUG) {
69 std::stringstream ss;
70 ss << "C BDT output: ";
71 for (const auto& i : scores) {ss << i << ' ';}
72 ATH_MSG_DEBUG(ss.str());
73 }
74
75 //Extract the bits (one by one) from the ap_fixed<10,5> object -> Bitset<10>
76 std::bitset<eEmEg1BDTTOB::s_eGamma1BDT_width> result;
77 for (int i=0;i<scores[0].length();i++){
78 result[i] = scores[0][0];
79 }
80
81 h_BDTResult->push_back(std::make_unique<IOBitwise::eEmEg1BDTTOB>(*nbhdTOB, result));
82
83 }
84 return StatusCode::SUCCESS;
85 }
86
87
88 std::vector<double>
90 auto result = std::vector<double>();
91
92 const auto& phi_low = nbhdTOB->Neighbourhood().phi_low();
93 if (phi_low.size() != s_required_phi_len) {return result;}
94
95 const auto& phi_center = nbhdTOB->Neighbourhood().phi_center();
96 if (phi_center.size() != s_required_phi_len) {return result;}
97
98
99 const auto& phi_high = nbhdTOB->Neighbourhood().phi_high();
100 if (phi_high.size() != s_required_phi_len) {return result;}
101
103
104 constexpr int c{8};
105
106 result.at(0) = phi_center.at(c).m_e;
107
108 result.at(1) = std::max(phi_low.at(c).m_e, phi_high.at(c).m_e);
109
110 int ri{2};
111 for (int diff = 1; diff != 9; ++diff) {
112 result.at(ri) =
113 std::max({phi_center.at(c-diff).m_e,
114 phi_center.at(c+diff).m_e});
115
116 result.at(ri+1) =
117 std::max({phi_low.at(c-diff).m_e,
118 phi_low.at(c+diff).m_e,
119 phi_high.at(c-diff).m_e,
120 phi_high.at(c+diff).m_e});
121
122 ri += 2;
123 }
124
125 return result;
126 }
127
128 std::string Egamma1BDTAlgTool::toString() const {
129
130 std::stringstream ss;
131 ss << "Egamma1BDTAlgTool. name: " << name() << '\n'
133 << '\n';
134 return ss.str();
135 }
136
137}
138
#define ATH_MSG_DEBUG(x)
#define CHECK(...)
Evaluate an expression and check for errors.
static Double_t ss
Header file to be included by clients of the Monitored infrastructure.
void diff(const Jet &rJet1, const Jet &rJet2, std::map< std::string, double > varDiff)
Difference between jets - Non-Class function required by trigger.
Definition Jet.cxx:631
static constexpr int s_combination_len
Egamma1BDTAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
std::vector< double > combine_phi(const IOBitwise::eEmNbhoodTOB *) const
StatusCode initialize() override
virtual StatusCode run(const EventContext &ctx) const override
SG::ReadHandleKey< eEmNbhoodTOBContainer > m_nbhdTOBContainerReadKey
static constexpr int s_required_phi_len
SG::WriteHandleKey< eEmEg1BDTTOBContainer > m_BDTResultKey
virtual std::string toString() const override
virtual const LArStripNeighborhood & Neighbourhood() const
const StripDataVector & phi_low() const
Returns a vector of strip cell e/eta/phi data for the low phi row of the neighborhood.
const StripDataVector & phi_center() const
Returns a vector of strip cell e/eta/phi data for the central phi row of the neighborhood.
const StripDataVector & phi_high() const
Returns a vector of strip cell e/eta/phi data for the central high row of the neighborhood.
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
AlgTool that to test whether expected the TIP values generated by data supplied by eEmMultTestBench c...
static const BDT::BDT< n_trees, n_classes, input_arr_t, score_t, threshold_t > bdt
Definition parameters.h:25
static const int n_features
Definition parameters.h:15
ap_fixed< 10, 5 > score_t
Definition parameters.h:21
static const int n_classes
Definition parameters.h:16
static std::vector< ap_int< 10 > > digitize10(const std::vector< double > &v)
Definition Digitizer.h:28