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
7
8#include <fstream>
9
10namespace GlobalSim {
11
13 ISvcLocator *pSvcLocator):
14 AthReentrantAlgorithm(name, pSvcLocator) {
15 }
16
18
19 ATH_MSG_INFO("number of TOB creators " << m_algTools.size());
20 ATH_MSG_INFO("number of TIP writers " << m_TIPwriters.size());
21
22 CHECK(m_tipWordKey.initialize());
23
24 if (m_enableDumps) {
25 std::stringstream ss;
26 ss << "\nTOB creators (" << m_algTools.size() << ")\n";
27 for (const auto& tool : m_algTools) {
28 ss << tool->toString() << '\n';
29 ss << "=========\n";
30 }
31 ss << "\nTIP writers (" << m_TIPwriters.size() << ")\n";
32 for (const auto& tool : m_TIPwriters) {
33 ss << tool->toString() << '\n';
34 ss << "=========\n";
35 }
36
37 std::ofstream out(name() + "_init.log");
38 out << ss.str();
39 out.close();
40 }
41
42 // Test that TIPwriters don't clash
43 TIPword tip_test;
44 for (const auto& tool : m_TIPwriters) {
45 ATH_MSG_VERBOSE("Current TIP word: " << tip_test);
46 TIPword tip_tmp{tool->getFullTIPWord()};
47 ATH_MSG_VERBOSE("TIP writer " << tool.name() << " produces: " << tip_tmp);
48 if((tip_tmp & tip_test).any()) {
49 ATH_MSG_ERROR("TIP word clash from " << tool->toString());
50 return StatusCode::FAILURE;
51 }
52 tip_test |= tip_tmp;
53 }
54
55 return StatusCode::SUCCESS;
56 }
57
58
59
60 StatusCode GlobalSimulationAlg::execute(const EventContext& ctx) const {
61 ATH_MSG_DEBUG("Executing ...");
62
63 if (m_enableDumps) {
64 ATH_MSG_INFO ("Dumping StoreGate\n" << evtStore()->dump());
65 }
66
67 using TIPWord = std::bitset<ITIPWriterAlgTool::s_nbits_TIP>;
68
69 for (const auto& tool : m_algTools) {
70 ATH_MSG_DEBUG("Running Algtool " << tool.name());
71 CHECK(tool -> run(ctx));
72 }
73
74 auto tipword = std::make_unique<TIPWord>(); // all zeros
75 for (const auto& tool : m_TIPwriters) {
76 ATH_MSG_DEBUG("Collecting TIP bits " << tool.name());
77 CHECK(tool -> updateTIP(*tipword, ctx));
78 }
79
80 if (m_enableDumps) {
81 std::stringstream ss;
82 ss << "\nRun " << ctx <<' ' << "TIP:\n" << *tipword << '\n';
83
84
85 std::ofstream out(name() + "_tip.log", std::ios_base::app);
86 out << ss.str();
87 out.close();
88 }
89
90 ATH_MSG_DEBUG("TIP " << *tipword);
91
92 // write out the selection result
94 CHECK(h_write.record(std::move(tipword)));
95
96 return StatusCode::SUCCESS;
97 }
98}
#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.
ServiceHandle< StoreGateSvc > & evtStore()
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 eRatio Algorithm.
std::bitset< ITIPWriterAlgTool::s_nbits_TIP > TIPword
-event-from-file
int run(int argc, char *argv[])