ATLAS Offline Software
Loading...
Searching...
No Matches
eEmMultAlgTool.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 "./eEmMultAlgTool.h"
6#include "./CommonSelector.h"
7#include "./eEmSelector.h"
8
9#include <fstream>
10
11namespace GlobalSim {
12
14 const std::string& name,
15 const IInterface* parent) :
16 base_class(type, name, parent) {
17 }
18
19
20 // Initialize function running before first event
22
24
25 CHECK(m_eEmTOBContainerKey.initialize());
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_e_selector = std::make_unique<eEmSelector>(std::stoul(m_rhad_str),
39 std::stoul(m_reta_str),
41 std::stoul(m_wstot_str),
43 );
44 } catch (const std::exception& e) {
45
46 ATH_MSG_ERROR("Error initialising eEMSelector " << e.what());
47 return StatusCode::FAILURE;
48 }
49
50 return StatusCode::SUCCESS;
51 }
52
53
54 StatusCode eEmMultAlgTool::countPassingTOBs(const EventContext& ctx, unsigned int& N_pass_tobs) const {
55
56 auto tobs =
58 ctx);
59
60 CHECK(tobs.isValid());
61
62 // check if any of the incoming tobs is selected.
63
64 std::vector<bool> tob_pass(tobs->size(), false);
65 for (uint tob_it = 0; const GlobalSim::IOBitwise::eEmTOB* t : *tobs){
66 if (m_c_selector->select(*t) and m_e_selector->select(*t)) {
67 tob_pass[tob_it] = true;
68 if (++N_pass_tobs == m_maxtob){
69 break;
70 }
71 }
72 tob_it++;
73 }
74
75 ATH_MSG_DEBUG("no of passing TOBS" << N_pass_tobs);
76
77 if (m_enableDump) {
78 std::stringstream ss;
79 ss << "\nRun " << ctx << '\n';
80 std::size_t ind{0};
81 for (const GlobalSim::IOBitwise::eEmTOB* tob : *tobs) {
82 ss << tob->to_string() << ' ' << std::boolalpha << " pass " << tob_pass[ind++] << '\n';
83 }
84 ss << "tob count " << N_pass_tobs << '\n';
85
86 std::ofstream out(name() + ".log", std::ios_base::app);
87 out << ss.str();
88 out.close();
89 }
90
91 return StatusCode::SUCCESS;
92 }
93
94 std::string eEmMultAlgTool::toString() const {
95 std::stringstream ss;
96 ss <<name () << ": " <<m_menu_name << ' '
97 << "eEmMultAlgTool read, select, count and report number of related eEmTOBS\n"
98 << m_c_selector->to_string() << '\n'
99 << m_e_selector->to_string() << '\n'
100 << m_TIP_position << ' ' << m_TIP_width;
101
102 return ss.str();
103 }
104
105}
#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.
unsigned int uint
static Double_t ss
virtual StatusCode initialize() override
Initialize function running before first event.
Gaudi::Property< std::string > m_reta_str
Gaudi::Property< std::string > m_rhad_op
Gaudi::Property< bool > m_enableDump
Gaudi::Property< std::string > m_et_high_str
Gaudi::Property< std::string > m_rhad_str
std::unique_ptr< IeEmSelector > m_e_selector
Gaudi::Property< std::string > m_eta_high_str
Gaudi::Property< std::string > m_wstot_op
SG::ReadHandleKey< IOBitwise::eEmTOBContainer > m_eEmTOBContainerKey
eEmMultAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Gaudi::Property< std::string > m_eta_low_str
Gaudi::Property< std::string > m_et_low_str
Gaudi::Property< std::string > m_phi_low_str
virtual std::string toString() const override
virtual StatusCode countPassingTOBs(const EventContext &, unsigned int &N_pass_tobs) const override
std::unique_ptr< ICommonSelector > m_c_selector
virtual StatusCode initialize() override
Initialize function running before first event.
Gaudi::Property< std::string > m_phi_high_str
Gaudi::Property< std::string > m_menu_name
Gaudi::Property< std::string > m_reta_op
Gaudi::Property< std::string > m_wstot_str
AlgTool to read in LArStripNeighborhoods, and run the eRatio Algorithm.