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
52 const std::unique_ptr<IDataCollector>& dc,
53 unsigned int& N_pass_tobs) const {
54 auto tobs =
56 ctx);
57
58 CHECK(tobs.isValid());
59
60 if(dc){
61 std::stringstream ss;
62 ss << "nummber of tobs "<< tobs->size() << '\n';
63 dc->collect(*this, ss.str());
64
65 for(const GlobalSim::IOBitwise::eEmEg1BDTTOB* t : *tobs){
66 dc->collect(*this, t->to_string());
67 }
68 }
69
70 // check if any of the incoming tobs is selected.
71
72 std::vector<bool> tob_pass(tobs->size(), false);
73 for (int tob_it = 0; const GlobalSim::IOBitwise::eEmEg1BDTTOB* t : *tobs){
74 if (m_c_selector->select(*t) and m_bdt_selector->select(*t)) {
75 tob_pass[tob_it] = true;
76 if (++N_pass_tobs == m_maxtob){
77 break;
78 }
79 }
80 tob_it++;
81 }
82
83 ATH_MSG_DEBUG("no of passing TOBS" << N_pass_tobs);
84
85 if (m_enableDump) {
86 std::stringstream ss;
87 ss << "\nRun " << ctx << '\n';
88 std::size_t ind{0};
89 for (const GlobalSim::IOBitwise::eEmEg1BDTTOB* tob : *tobs) {
90 ss << tob->to_string() << ' ' << std::boolalpha << " pass " << tob_pass[ind++] << '\n';
91 }
92 ss << "tob count " << N_pass_tobs << '\n';
93
94 std::ofstream out(name() + ".log", std::ios_base::app);
95 out << ss.str();
96 out.close();
97 }
98
99 return StatusCode::SUCCESS;
100 }
101
102 std::string eEmEg1BDTMultAlgTool::toString() const {
103 std::stringstream ss;
104 ss <<name () << ": " <<m_menu_name << ' '
105 << "eEmEg1BDTMultAlgTool read, select, count and report number of related eEmEg1BDTTOBS\n"
106 << m_c_selector->to_string() << '\n'
107 << m_bdt_selector->to_string() << '\n'
108 << m_TIP_position << ' ' << m_TIP_width;
109
110 return ss.str();
111 }
112
113}
#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
Gaudi::Property< std::string > m_menu_name
virtual std::string toString() const override
virtual StatusCode countPassingTOBs(const EventContext &, const std::unique_ptr< IDataCollector > &dc, unsigned int &N_pass_tobs) 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.