ATLAS Offline Software
Loading...
Searching...
No Matches
CommonMultAlgTool.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
8#include <fstream>
9
10namespace GlobalSim {
11
13 const std::string& name,
14 const IInterface* parent) :
15 base_class(type, name, parent) {
16 }
17
18
19 // Initialize function running before first event
21
22 CHECK(m_CommonTOBContainerKey.initialize());
23
24 if (m_TIP_width < 0) {
25 ATH_MSG_ERROR("number of bits to write to TIP is negative");
26 return StatusCode::FAILURE;
27 }
28
29 int max_tip_pos = s_nbits_TIP - m_TIP_width;
30
32 ATH_MSG_ERROR("TIP word out of bounds " << m_TIP_position);
33 return StatusCode::FAILURE;
34 }
35
36 // create the necessary selector objects
37 m_c_selector = std::make_unique<CommonSelector>(m_et_low_str,
43 );
44
45 if (m_TIP_width == 0){
46 m_maxtob = 0;
47 } else {
48 ulong maxtob = 1;
49 for (ulong i = m_TIP_width; i != 0; --i) { maxtob *= 2;}
50 m_maxtob = maxtob - 1;
51 }
52
53 return StatusCode::SUCCESS;
54 }
55
56
57 StatusCode CommonMultAlgTool::updateTIP(std::bitset<s_nbits_TIP>& word,
58 const EventContext& ctx) const {
59 auto tobs =
61 ctx);
62
63 CHECK(tobs.isValid());
64
65 // check if any of the incoming tobs is selected.
66
67 ulong tob_count{0};
68 std::vector<bool> tob_pass(tobs->size(), false);
69 for (int tob_it = 0; const GlobalSim::IOBitwise::CommonTOB* t : *tobs){
70 if (m_c_selector->select(*t)) {
71 tob_pass[tob_it] = true;
72 if (++tob_count == m_maxtob){
73 break;
74 }
75 }
76 tob_it++;
77 }
78
79 ATH_MSG_DEBUG("no of passing TOBS" << tob_count);
80
81
82 auto count_bits = std::bitset<s_nbits_TIP>(tob_count);
83
84 int p0{0};
85 int p1{m_TIP_position};
86
87 const int& mxb = m_TIP_width;
88
89 for (; p0 != mxb; ++p0, ++p1) {
90 if (count_bits.test(p0)) {word.set(p1);}
91 }
92
93 ATH_MSG_DEBUG("TIP word " << word);
94
95
96 if (m_enableDump) {
97 std::stringstream ss;
98 ss << "\nRun " << ctx <<' ' << "TIP:\n" << word << '\n';
99 std::size_t ind{0};
100 for (const GlobalSim::IOBitwise::CommonTOB* tob : *tobs) {
101 ss << tob->to_string() << ' ' << std::boolalpha << " pass " << tob_pass[ind++] << '\n';
102 }
103 ss << "tob count " << tob_count << '\n';
104
105 std::ofstream out(name() + ".log", std::ios_base::app);
106 out << ss.str();
107 out.close();
108 }
109
110
111 return StatusCode::SUCCESS;
112 }
113
114 std::string CommonMultAlgTool::toString() const {
115 std::stringstream ss;
116 ss <<name () << ": " <<m_menu_name << ' '
117 << "CommonMultAlgTool read, select, count and report number of related CommonTOBS\n"
118 << m_c_selector->to_string() << '\n'
119 << m_TIP_position << ' ' << m_TIP_width;
120
121 return ss.str();
122 }
123
124}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
#define CHECK(...)
Evaluate an expression and check for errors.
static Double_t ss
SG::ReadHandleKey< IOBitwise::CommonTOBContainer > m_CommonTOBContainerKey
Gaudi::Property< std::string > m_et_high_str
Gaudi::Property< std::string > m_eta_low_str
Gaudi::Property< std::string > m_menu_name
Gaudi::Property< std::string > m_et_low_str
Gaudi::Property< std::string > m_phi_low_str
virtual std::string toString() const override
CommonMultAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Gaudi::Property< std::string > m_eta_high_str
virtual StatusCode updateTIP(std::bitset< s_nbits_TIP > &, const EventContext &) const override
Gaudi::Property< int > m_TIP_position
Gaudi::Property< bool > m_enableDump
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< int > m_TIP_width
AlgTool to read in LArStripNeighborhoods, and run the eRatio Algorithm.