ATLAS Offline Software
Loading...
Searching...
No Matches
GlobalSim::Egamma1BDTAlgTool Class Reference

#include <Egamma1BDTAlgTool.h>

Inheritance diagram for GlobalSim::Egamma1BDTAlgTool:
Collaboration diagram for GlobalSim::Egamma1BDTAlgTool:

Public Member Functions

 Egamma1BDTAlgTool (const std::string &type, const std::string &name, const IInterface *parent)
virtual ~Egamma1BDTAlgTool ()=default
StatusCode initialize () override
virtual StatusCode run (const EventContext &ctx) const override
virtual std::string toString () const override

Private Types

using eEmEg1BDTTOBContainer = GlobalSim::IOBitwise::eEmEg1BDTTOBContainer
using eEmNbhoodTOBContainer = GlobalSim::IOBitwise::eEmNbhoodTOBContainer

Private Member Functions

std::vector< double > combine_phi (const IOBitwise::eEmNbhoodTOB *) const

Private Attributes

Gaudi::Property< bool > m_enableDump
SG::WriteHandleKey< eEmEg1BDTTOBContainerm_BDTResultKey
SG::ReadHandleKey< eEmNbhoodTOBContainerm_nbhdTOBContainerReadKey

Static Private Attributes

static constexpr int s_required_phi_len = 17
static constexpr int s_combination_len = 18

Detailed Description

Definition at line 31 of file Egamma1BDTAlgTool.h.

Member Typedef Documentation

◆ eEmEg1BDTTOBContainer

◆ eEmNbhoodTOBContainer

Constructor & Destructor Documentation

◆ Egamma1BDTAlgTool()

GlobalSim::Egamma1BDTAlgTool::Egamma1BDTAlgTool ( const std::string & type,
const std::string & name,
const IInterface * parent )

Definition at line 19 of file Egamma1BDTAlgTool.cxx.

21 :
22 base_class(type, name, parent){
23 }

◆ ~Egamma1BDTAlgTool()

virtual GlobalSim::Egamma1BDTAlgTool::~Egamma1BDTAlgTool ( )
virtualdefault

Member Function Documentation

◆ combine_phi()

std::vector< double > GlobalSim::Egamma1BDTAlgTool::combine_phi ( const IOBitwise::eEmNbhoodTOB * nbhdTOB) const
private

Definition at line 89 of file Egamma1BDTAlgTool.cxx.

89 {
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 }
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
static constexpr int s_required_phi_len

◆ initialize()

StatusCode GlobalSim::Egamma1BDTAlgTool::initialize ( )
override

Definition at line 25 of file Egamma1BDTAlgTool.cxx.

25 {
26
27 CHECK(m_nbhdTOBContainerReadKey.initialize());
28 CHECK(m_BDTResultKey.initialize());
29
30 return StatusCode::SUCCESS;
31 }
#define CHECK(...)
Evaluate an expression and check for errors.
SG::ReadHandleKey< eEmNbhoodTOBContainer > m_nbhdTOBContainerReadKey
SG::WriteHandleKey< eEmEg1BDTTOBContainer > m_BDTResultKey

◆ run()

StatusCode GlobalSim::Egamma1BDTAlgTool::run ( const EventContext & ctx) const
overridevirtual

Definition at line 34 of file Egamma1BDTAlgTool.cxx.

34 {
35 ATH_MSG_DEBUG("run()");
36
37
38 // read in LArStrip neighborhood TOBs from the event store
39 auto in =
40 SG::ReadHandle<IOBitwise::eEmNbhoodTOBContainer>(m_nbhdTOBContainerReadKey,
41 ctx);
42 CHECK(in.isValid());
43
44 ATH_MSG_DEBUG("read in " << (*in).size() << " neighborhoods");
45
46 SG::WriteHandle<eEmEg1BDTTOBContainer> h_BDTResult(m_BDTResultKey, ctx);
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 }
#define ATH_MSG_DEBUG(x)
static Double_t ss
std::vector< double > combine_phi(const IOBitwise::eEmNbhoodTOB *) const
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

◆ toString()

std::string GlobalSim::Egamma1BDTAlgTool::toString ( ) const
overridevirtual

Definition at line 128 of file Egamma1BDTAlgTool.cxx.

128 {
129
130 std::stringstream ss;
131 ss << "Egamma1BDTAlgTool. name: " << name() << '\n'
133 << '\n';
134 return ss.str();
135 }

Member Data Documentation

◆ m_BDTResultKey

SG::WriteHandleKey<eEmEg1BDTTOBContainer> GlobalSim::Egamma1BDTAlgTool::m_BDTResultKey
private
Initial value:
{
this,
"BDTResultKey",
"BDTResult"}

Definition at line 59 of file Egamma1BDTAlgTool.h.

59 {
60 this,
61 "BDTResultKey",
62 "BDTResult"};

◆ m_enableDump

Gaudi::Property<bool> GlobalSim::Egamma1BDTAlgTool::m_enableDump
private
Initial value:
{this,
"enableDump",
{false},
"flag to enable dumps"}

Definition at line 53 of file Egamma1BDTAlgTool.h.

53 {this,
54 "enableDump",
55 {false},
56 "flag to enable dumps"};

◆ m_nbhdTOBContainerReadKey

SG::ReadHandleKey<eEmNbhoodTOBContainer> GlobalSim::Egamma1BDTAlgTool::m_nbhdTOBContainerReadKey
private
Initial value:
{
this,
"LArNeighborhoodTOBContainerReadKey",
"stripNeighborhoodTOBContainer",
"key to read inLArNeighborhoodTOBsReadKeys"}

Definition at line 66 of file Egamma1BDTAlgTool.h.

66 {
67 this,
68 "LArNeighborhoodTOBContainerReadKey",
69 "stripNeighborhoodTOBContainer",
70 "key to read inLArNeighborhoodTOBsReadKeys"};

◆ s_combination_len

int GlobalSim::Egamma1BDTAlgTool::s_combination_len = 18
inlinestaticconstexprprivate

Definition at line 81 of file Egamma1BDTAlgTool.h.

◆ s_required_phi_len

int GlobalSim::Egamma1BDTAlgTool::s_required_phi_len = 17
inlinestaticconstexprprivate

Definition at line 77 of file Egamma1BDTAlgTool.h.


The documentation for this class was generated from the following files: