ATLAS Offline Software
Loading...
Searching...
No Matches
GlobalSimulationAlg.cxx
Go to the documentation of this file.
1// Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
2
5
8
9#include <fstream>
10
11namespace GlobalSim {
12
14 ISvcLocator *pSvcLocator):
15 AthReentrantAlgorithm(name, pSvcLocator) {
16 }
17
19
20 ATH_MSG_INFO("number of TOB creators " << m_algTools.size());
21 ATH_MSG_INFO("number of TIP writers " << m_TIPwriters.size());
22
23 // If we only run TOB creators, then don't write the TIP word
24 // as this leads to SG clashes (or spurious stuff in SG)
25 CHECK(m_tipWordKey.initialize(!m_TIPwriters.empty()));
26
27 if (m_enableDumps) {
28 std::stringstream ss;
29 ss << "\nTOB creators (" << m_algTools.size() << ")\n";
30 for (const auto& tool : m_algTools) {
31 ss << tool->toString() << '\n';
32 ss << "=========\n";
33 }
34 ss << "\nTIP writers (" << m_TIPwriters.size() << ")\n";
35 for (const auto& tool : m_TIPwriters) {
36 ss << tool->toString() << '\n';
37 ss << "=========\n";
38 }
39
40 std::ofstream out(name() + "_init.log");
41 out << ss.str();
42 out.close();
43 }
44
45 // Test that TIPwriters don't clash
46 TIPword tip_test;
47 for (const auto& tool : m_TIPwriters) {
48 ATH_MSG_VERBOSE("Current TIP word: " << tip_test);
49 TIPword tip_tmp{tool->getFullTIPWord()};
50 ATH_MSG_VERBOSE("TIP writer " << tool.name() << " produces: " << tip_tmp);
51 if((tip_tmp & tip_test).any()) {
52 ATH_MSG_ERROR("TIP word clash from " << tool->toString());
53 return StatusCode::FAILURE;
54 }
55 tip_test |= tip_tmp;
56 }
57
58 return StatusCode::SUCCESS;
59 }
60
61
62
63 StatusCode GlobalSimulationAlg::execute(const EventContext& ctx) const {
64 ATH_MSG_DEBUG("Executing ...");
65
66
67 using TIPWord = std::bitset<ITIPWriterAlgTool::s_nbits_TIP>;
68
69 auto dc = std::unique_ptr<IDataCollector>(nullptr);
70 dc.reset(new BasicDataCollector());
71
72 for (const auto& tool : m_algTools) {
73 ATH_MSG_DEBUG("Running Algtool " << tool.name());
74 CHECK(tool -> run(dc, ctx));
75 }
76
77 if(!m_TIPwriters.empty()) {
78 auto tipword = std::make_unique<TIPWord>(); // all zeros
79 for (const auto& tool : m_TIPwriters) {
80 ATH_MSG_DEBUG("Collecting TIP bits " << tool.name());
81 CHECK(tool -> updateTIP(*tipword, dc, ctx));
82 }
83
84 if (m_enableDumps) {
85 std::stringstream ss;
86 ss << "\nRun " << ctx <<' ' << "TIP:\n" << *tipword << '\n';
87
88
89 std::ofstream out(name() + "_tip.log", std::ios_base::app);
90 out << ss.str();
91 out.close();
92 }
93
94 ATH_MSG_DEBUG("TIP " << *tipword);
95
96 // write out the selection result
98 CHECK(h_write.record(std::move(tipword)));
99 }
100
101 return StatusCode::SUCCESS;
102 }
103}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(x)
#define CHECK(...)
Evaluate an expression and check for errors.
static Double_t ss
Define macros for attributes used to control the static checker.
An algorithm that can be simultaneously executed in multiple threads.
virtual StatusCode initialize() override
ToolHandleArray< ITIPWriterAlgTool > m_TIPwriters
Gaudi::Property< bool > m_enableDumps
GlobalSimulationAlg(const std::string &name, ISvcLocator *pSvcLocator)
SG::WriteHandleKey< TIPword > m_tipWordKey
virtual StatusCode execute(const EventContext &ctx) const override
ToolHandleArray< IGlobalSimAlgTool > m_algTools
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
AlgTool to read in LArStripNeighborhoods, and run the BDT Algorithm.
std::bitset< ITIPWriterAlgTool::s_nbits_TIP > TIPword
int run(int argc, char *argv[])