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
23 CHECK(m_eEmTOBContainerKey.initialize());
24
25 if (m_TIP_width < 0) {
26 ATH_MSG_ERROR("number of bits to write to TIP is negative");
27 return StatusCode::FAILURE;
28 }
29
30 int max_tip_pos = s_nbits_TIP - m_TIP_width;
31
33 ATH_MSG_ERROR("TIP word out of bounds " << m_TIP_position);
34 return StatusCode::FAILURE;
35 }
36
37 // create the necessary selector objects
38 m_c_selector = std::make_unique<CommonSelector>(m_et_low_str,
44 );
45
46 try {
47 m_e_selector = std::make_unique<eEmSelector>(std::stoul(m_rhad_str),
49 std::stoul(m_reta_str),
51 std::stoul(m_wstot_str),
53 );
54 } catch (const std::exception& e) {
55
56 ATH_MSG_ERROR("Error initialising eEMSelector " << e.what());
57 return StatusCode::FAILURE;
58 }
59
60
61
62 if (m_TIP_width == 0){
63 m_maxtob = 0;
64 } else {
65 ulong maxtob = 1;
66 for (ulong i = m_TIP_width; i != 0; --i) { maxtob *= 2;}
67 m_maxtob = maxtob - 1;
68 }
69
70 return StatusCode::SUCCESS;
71 }
72
73
74 StatusCode eEmMultAlgTool::updateTIP(std::bitset<s_nbits_TIP>& word,
75 const EventContext& ctx) const {
76 auto tobs =
78 ctx);
79
80 CHECK(tobs.isValid());
81
82 // check if any of the incoming tobs is selected.
83
84 ulong tob_count{0};
85 std::vector<bool> tob_pass(tobs->size(), false);
86 for (uint tob_it = 0; const GlobalSim::IOBitwise::eEmTOB* t : *tobs){
87 if (m_c_selector->select(*t) and m_e_selector->select(*t)) {
88 tob_pass[tob_it] = true;
89 if (++tob_count == m_maxtob){
90 break;
91 }
92 }
93 tob_it++;
94 }
95
96
97
98 ATH_MSG_DEBUG("no of passing TOBS" << tob_count);
99
100 auto count_bits = std::bitset<s_nbits_TIP>(tob_count);
101
102 int p0{0};
103 int p1{m_TIP_position};
104
105 const int& mxb = m_TIP_width;
106
107 for (; p0 != mxb; ++p0, ++p1) {
108 if (count_bits.test(p0)) {word.set(p1);}
109 }
110
111 ATH_MSG_DEBUG("TIP word " << word);
112
113
114 if (m_enableDump) {
115 std::stringstream ss;
116 ss << "\nRun " << ctx <<' ' << "TIP:\n" << word << '\n';
117 std::size_t ind{0};
118 for (const GlobalSim::IOBitwise::eEmTOB* tob : *tobs) {
119 ss << tob->to_string() << ' ' << std::boolalpha << " pass " << tob_pass[ind++] << '\n';
120 }
121 ss << "tob count " << tob_count << '\n';
122
123 std::ofstream out(name() + ".log", std::ios_base::app);
124 out << ss.str();
125 out.close();
126 }
127
128
129 return StatusCode::SUCCESS;
130 }
131
132 std::string eEmMultAlgTool::toString() const {
133 std::stringstream ss;
134 ss <<name () << ": " <<m_menu_name << ' '
135 << "eEmMultAlgTool read, select, count and report number of related eEmTOBS\n"
136 << m_c_selector->to_string() << '\n'
137 << m_e_selector->to_string() << '\n'
138 << m_TIP_position << ' ' << m_TIP_width;
139
140 return ss.str();
141 }
142
143}
#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
Gaudi::Property< std::string > m_reta_str
virtual StatusCode updateTIP(std::bitset< s_nbits_TIP > &, const EventContext &) const override
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< int > m_TIP_width
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
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< int > m_TIP_position
Gaudi::Property< std::string > m_reta_op
Gaudi::Property< std::string > m_wstot_str
AlgTool to read in LArStripNeighborhoods, and run the eRatio Algorithm.