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#include <sstream>
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
23
25
26 CHECK(m_eEmTOBContainerKey.initialize());
27
28 // create the necessary selector objects
29 m_c_selector = std::make_unique<CommonSelector>(m_et_low_str,
35 );
36
37 try {
38 m_e_selector = std::make_unique<eEmSelector>(std::stoul(m_rhad_str),
40 std::stoul(m_reta_str),
42 std::stoul(m_wstot_str),
44 );
45 } catch (const std::exception& e) {
46
47 ATH_MSG_ERROR("Error initialising eEMSelector " << e.what());
48 return StatusCode::FAILURE;
49 }
50
51 return StatusCode::SUCCESS;
52 }
53
54
55 StatusCode
56 eEmMultAlgTool::countPassingTOBs(const EventContext& ctx,
57 const std::unique_ptr<IDataCollector>& dc,
58 unsigned int& N_pass_tobs) const {
59
60 auto tobs =
62 ctx);
63
64 CHECK(tobs.isValid());
65
66 // check if any of the incoming tobs is selected.
67
68 if(dc){
69 std::stringstream ss;
70 ss << "nummber of tobs "<< tobs->size() << '\n';
71 dc->collect(*this, ss.str());
72 for (const GlobalSim::IOBitwise::eEmTOB* t : *tobs){
73 dc->collect(*this, t->to_string());
74 }
75 }
76
77 std::vector<bool> tob_pass(tobs->size(), false);
78 for (uint tob_it = 0; const GlobalSim::IOBitwise::eEmTOB* t : *tobs){
79 if (m_c_selector->select(*t) and m_e_selector->select(*t)) {
80 tob_pass[tob_it] = true;
81 if (++N_pass_tobs == m_maxtob){
82 break;
83 }
84 }
85 tob_it++;
86 }
87
88 ATH_MSG_DEBUG("no of passing TOBS" << N_pass_tobs);
89
90 if (m_enableDump) {
91 std::stringstream ss;
92 ss << "\nRun " << ctx << '\n';
93 std::size_t ind{0};
94 for (const GlobalSim::IOBitwise::eEmTOB* tob : *tobs) {
95 ss << tob->to_string() << ' ' << std::boolalpha << " pass " << tob_pass[ind++] << '\n';
96 }
97 ss << "tob count " << N_pass_tobs << '\n';
98
99 std::ofstream out(name() + ".log", std::ios_base::app);
100 out << ss.str();
101 out.close();
102 }
103
104 return StatusCode::SUCCESS;
105 }
106
107 std::string eEmMultAlgTool::toString() const {
108 std::stringstream ss;
109 ss <<name () << ": " <<m_menu_name << ' '
110 << "eEmMultAlgTool read, select, count and report number of related eEmTOBS\n"
111 << m_c_selector->to_string() << '\n'
112 << m_e_selector->to_string() << '\n'
113 << m_TIP_position << ' ' << m_TIP_width;
114
115 return ss.str();
116 }
117
118 }
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_ERROR(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
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
virtual StatusCode countPassingTOBs(const EventContext &, const std::unique_ptr< IDataCollector > &dc, unsigned int &N_pass_tobs) const override
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 BDT Algorithm.
Definition BitSpec.h:23