ATLAS Offline Software
Loading...
Searching...
No Matches
eEmEg1BDTMultAlgTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
6#include "./CommonSelector.h"
7#include "./eEmSelector.h"
9
10#include <fstream>
11
12namespace GlobalSim {
13
15 const std::string& name,
16 const IInterface* parent) :
17 base_class(type, name, parent) {
18 }
19
20
21 // Initialize function running before first event
24
26
27 // create the necessary selector objects
28 m_c_selector = std::make_unique<CommonSelector>(m_et_low_str,
34 );
35
36 try {
37 m_bdt_selector = std::make_unique<eEmEg1BDTSelector>(std::stoul(m_Eg1BDT_str),
39 );
40 } catch (const std::exception& e) {
41
42 ATH_MSG_ERROR("Error initialising eEmEg1BDTSelector " << e.what());
43 return StatusCode::FAILURE;
44 }
45
46 return StatusCode::SUCCESS;
47 }
48
49
50 StatusCode eEmEg1BDTMultAlgTool::countPassingTOBs(const EventContext& ctx, unsigned int& N_pass_tobs) const {
51 auto tobs =
53 ctx);
54
55 CHECK(tobs.isValid());
56
57 // check if any of the incoming tobs is selected.
58
59 std::vector<bool> tob_pass(tobs->size(), false);
60 for (int tob_it = 0; const GlobalSim::IOBitwise::eEmEg1BDTTOB* t : *tobs){
61 if (m_c_selector->select(*t) and m_bdt_selector->select(*t)) {
62 tob_pass[tob_it] = true;
63 if (++N_pass_tobs == m_maxtob){
64 break;
65 }
66 }
67 tob_it++;
68 }
69
70 ATH_MSG_DEBUG("no of passing TOBS" << N_pass_tobs);
71
72 if (m_enableDump) {
73 std::stringstream ss;
74 ss << "\nRun " << ctx << '\n';
75 std::size_t ind{0};
76 for (const GlobalSim::IOBitwise::eEmEg1BDTTOB* tob : *tobs) {
77 ss << tob->to_string() << ' ' << std::boolalpha << " pass " << tob_pass[ind++] << '\n';
78 }
79 ss << "tob count " << N_pass_tobs << '\n';
80
81 std::ofstream out(name() + ".log", std::ios_base::app);
82 out << ss.str();
83 out.close();
84 }
85
86 return StatusCode::SUCCESS;
87 }
88
89 std::string eEmEg1BDTMultAlgTool::toString() const {
90 std::stringstream ss;
91 ss <<name () << ": " <<m_menu_name << ' '
92 << "eEmEg1BDTMultAlgTool read, select, count and report number of related eEmEg1BDTTOBS\n"
93 << m_c_selector->to_string() << '\n'
94 << m_bdt_selector->to_string() << '\n'
95 << m_TIP_position << ' ' << m_TIP_width;
96
97 return ss.str();
98 }
99
100}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
#define CHECK(...)
Evaluate an expression and check for errors.
static Double_t ss
virtual StatusCode initialize() override
Initialize function running before first event.
Gaudi::Property< std::string > m_phi_low_str
Gaudi::Property< std::string > m_eta_high_str
Gaudi::Property< std::string > m_et_low_str
std::unique_ptr< ICommonSelector > m_c_selector
Gaudi::Property< std::string > m_Eg1BDT_str
Gaudi::Property< std::string > m_Eg1BDT_op
Gaudi::Property< std::string > m_phi_high_str
virtual StatusCode countPassingTOBs(const EventContext &, unsigned int &N_pass_tobs) const override
Gaudi::Property< std::string > m_menu_name
virtual std::string toString() const override
Gaudi::Property< std::string > m_eta_low_str
SG::ReadHandleKey< IOBitwise::eEmEg1BDTTOBContainer > m_eEmEg1BDTTOBContainerKey
Gaudi::Property< std::string > m_et_high_str
eEmEg1BDTMultAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
std::unique_ptr< IeEmEg1BDTSelector > m_bdt_selector
virtual StatusCode initialize() override
Initialize function running before first event.
AlgTool to read in LArStripNeighborhoods, and run the BDT Algorithm.