ATLAS Offline Software
Loading...
Searching...
No Matches
Egamma1BDTAlgTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 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
14namespace GlobalSim {
15
17 const std::string& name,
18 const IInterface* parent) :
19 base_class(type, name, parent){
20 }
21
23
24 CHECK(m_nbhdTOBContainerReadKey.initialize());
25 CHECK(m_BDTResultKey.initialize());
26
27 return StatusCode::SUCCESS;
28 }
29
30 StatusCode
31 Egamma1BDTAlgTool::run(const EventContext& ctx) const {
32 ATH_MSG_DEBUG("run()");
33
34
35 // read in LArStrip neighborhood TOBs from the event store
36 auto in =
38 ctx);
39 CHECK(in.isValid());
40
41 ATH_MSG_DEBUG("read in " << (*in).size() << " neighborhoods");
42
44 CHECK(h_BDTResult.record(std::make_unique<IOBitwise::eEmEg1BDTTOBContainer>()));
45
46 for (const auto nbhdTOB : *in) {
47 auto c_phi = combine_phi(nbhdTOB);
48 if (c_phi.empty()) {continue;} // corner case: not all phi have len 17
49 auto input = digitizer::digitize10(c_phi);
50
51 assert(input.size() == n_features);
52 ap_int<10>* c_input = &input[0]; // vector->array
53
55
56 // the bdt variable is already set up
57 bdt.decision_function(c_input, scores);
58 if (msgLevel() <= MSG::DEBUG) {
59 std::stringstream ss;
60 ss << "BDT input: ";
61 for (const auto& i : input) {ss << i << ' ';}
62 ATH_MSG_DEBUG(ss.str());
63 }
64
65 if (msgLevel() <= MSG::DEBUG) {
66 std::stringstream ss;
67 ss << "C BDT output: ";
68 for (const auto& i : scores) {ss << i << ' ';}
69 ATH_MSG_DEBUG(ss.str());
70 }
71
72 //Extract the bits (one by one) from the ap_fixed<10,5> object -> Bitset<10>
73 std::bitset<IOBitwise::IeEmEg1BDTTOB::s_eGamma1BDT_width> result;
74 for (int i=0;i<scores[0].length();i++){
75 result[i] = scores[0][0];
76 }
77
78 h_BDTResult->push_back(std::make_unique<IOBitwise::eEmEg1BDTTOB>(*nbhdTOB, result));
79
80 }
81 return StatusCode::SUCCESS;
82 }
83
84
85 std::vector<double>
87 auto result = std::vector<double>();
88
89 const auto& phi_low = nbhdTOB->Neighbourhood().phi_low();
90 if (phi_low.size() != s_required_phi_len) {return result;}
91
92 const auto& phi_center = nbhdTOB->Neighbourhood().phi_center();
93 if (phi_center.size() != s_required_phi_len) {return result;}
94
95
96 const auto& phi_high = nbhdTOB->Neighbourhood().phi_high();
97 if (phi_high.size() != s_required_phi_len) {return result;}
98
100
101 constexpr int c{8};
102
103 result.at(0) = phi_center.at(c).m_e;
104
105 result.at(1) = std::max(phi_low.at(c).m_e, phi_high.at(c).m_e);
106
107 int ri{2};
108 for (int diff = 1; diff != 9; ++diff) {
109 result.at(ri) =
110 std::max({phi_center.at(c-diff).m_e,
111 phi_center.at(c+diff).m_e});
112
113 result.at(ri+1) =
114 std::max({phi_low.at(c-diff).m_e,
115 phi_low.at(c+diff).m_e,
116 phi_high.at(c-diff).m_e,
117 phi_high.at(c+diff).m_e});
118
119 ri += 2;
120 }
121
122 return result;
123 }
124
125 std::string Egamma1BDTAlgTool::toString() const {
126
127 std::stringstream ss;
128 ss << "Egamma1BDTAlgTool. name: " << name() << '\n'
130 << '\n';
131 return ss.str();
132 }
133
134}
135
#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
SG::ReadHandleKey< IOBitwise::eEmNbhoodTOBContainer > m_nbhdTOBContainerReadKey
virtual StatusCode run(const EventContext &ctx) const override
static constexpr int s_required_phi_len
virtual std::string toString() const override
SG::WriteHandleKey< IOBitwise::eEmEg1BDTTOBContainer > m_BDTResultKey
Class to hold an eFexRoI and LAr strip neighbourhood.
virtual const LArStripNeighborhood & Neighbourhood() const
Returns the LarStripNeighbourhood: 3*17 cells centred on the eFexROI.
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