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
23
24 CHECK(m_CommonTOBContainerKey.initialize());
25
26 // create the necessary selector objects
27 m_c_selector = std::make_unique<CommonSelector>(m_et_low_str,
33 );
34
35 return StatusCode::SUCCESS;
36 }
37
38
39 StatusCode
40 CommonMultAlgTool::countPassingTOBs(const EventContext& ctx,
41 const std::unique_ptr<IDataCollector>& dc,
42
43 unsigned int& N_pass_tobs) const {
44 auto tobs =
46 ctx);
47
48 CHECK(tobs.isValid());
49
50 if(dc){
51 std::stringstream ss;
52 ss << "number of tobs "<< tobs->size() << '\n';
53 dc->collect(*this, ss.str());
54 for (const GlobalSim::IOBitwise::CommonTOB* t : *tobs){
55 dc->collect(*this, t->to_string());
56 }
57 }
58
59 // check if any of the incoming tobs is selected.
60 N_pass_tobs = 0;
61 std::vector<bool> tob_pass(tobs->size(), false);
62 for (int tob_it = 0; const GlobalSim::IOBitwise::CommonTOB* t : *tobs){
63 if (m_c_selector->select(*t)) {
64 tob_pass[tob_it] = true;
65 if (++N_pass_tobs == m_maxtob){
66 break;
67 }
68 }
69 tob_it++;
70 }
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::CommonTOB* 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 CommonMultAlgTool::toString() const {
90 std::stringstream ss;
91 ss <<name () << ": " <<m_menu_name << ' '
92 << "CommonMultAlgTool read, select, count and report number of related CommonTOBS\n"
93 << m_c_selector->to_string() << '\n'
94 << m_TIP_position << ' ' << m_TIP_width;
95
96 return ss.str();
97 }
98
99}
#define ATH_CHECK
Evaluate an expression and check for errors.
#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
Gaudi::Property< bool > m_enableDump
std::unique_ptr< ICommonSelector > m_c_selector
virtual StatusCode initialize() override
Initialize function running before first event.
virtual StatusCode countPassingTOBs(const EventContext &, const std::unique_ptr< IDataCollector > &dc, unsigned int &N_pass_tobs) const override
Gaudi::Property< std::string > m_phi_high_str
virtual StatusCode initialize() override
Initialize function running before first event.
AlgTool to read in LArStripNeighborhoods, and run the BDT Algorithm.
Definition BitSpec.h:23