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 if(m_enableDumps){
71 dc.reset(new BasicDataCollector());
72 }
73
74 for (const auto& tool : m_algTools) {
75 ATH_MSG_DEBUG("Running Algtool " << tool.name());
76 CHECK(tool -> run(dc, ctx));
77 }
78
79 if(m_TIPwriters.empty()) {return StatusCode::SUCCESS;}
80
81 auto tipword = std::make_unique<TIPWord>(); // all zeros
82 for (const auto& tool : m_TIPwriters) {
83 ATH_MSG_DEBUG("Collecting TIP bits " << tool.name());
84 CHECK(tool -> updateTIP(*tipword, dc, ctx));
85 }
86
87 if (m_enableDumps) {
88
89 {
90 std::stringstream ss;
91 ss << "\nRun " << ctx <<' ' << "TIP:\n" << *tipword << '\n';
92
93 std::ofstream out(name() + "_tip.log", std::ios_base::app);
94 out << ss.str();
95 out.close();
96 }
97
98 {
99 std::stringstream ss;
100 ss << name() << "_datacol_"<< ctx.eventID().event_number()<<".log";
101 std::ofstream out(ss.str());
102 out << dc->to_string();
103 out.close();
104 }
105 }
106
107 ATH_MSG_DEBUG("TIP " << *tipword);
108
109 // write out the selection result
111 CHECK(h_write.record(std::move(tipword)));
112
113 return StatusCode::SUCCESS;
114 }
115}
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_ERROR(x,...)
#define ATH_MSG_VERBOSE(x,...)
#define ATH_MSG_INFO(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.
Definition BitSpec.h:23
std::bitset< ITIPWriterAlgTool::s_nbits_TIP > TIPword
int run(int argc, char *argv[])