ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Trigger
TrigT1
Global
GlobalSimulation
src
GlobalSimComponents
GlobalSimulationAlg.cxx
Go to the documentation of this file.
1
// Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
2
3
#include "
GlobalSimulationAlg.h
"
4
#include "
TrigConfData/L1Menu.h
"
5
6
#include "
../Utilities/BasicDataCollector.h
"
7
#include "
CxxUtils/checker_macros.h
"
8
9
#include <fstream>
10
11
namespace
GlobalSim
{
12
13
GlobalSimulationAlg::GlobalSimulationAlg
(
const
std::string& name,
14
ISvcLocator *pSvcLocator):
15
AthReentrantAlgorithm
(name, pSvcLocator) {
16
}
17
18
StatusCode
GlobalSimulationAlg::initialize
() {
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
110
SG::WriteHandle<TIPWord>
h_write(
m_tipWordKey
, ctx);
111
CHECK
(h_write.
record
(std::move(tipword)));
112
113
return
StatusCode::SUCCESS;
114
}
115
}
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x,...)
Definition
AthMsgStreamMacros.h:43
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x,...)
Definition
AthMsgStreamMacros.h:47
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x,...)
Definition
AthMsgStreamMacros.h:42
ATH_MSG_INFO
#define ATH_MSG_INFO(x,...)
Definition
AthMsgStreamMacros.h:45
BasicDataCollector.h
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition
Control/AthenaKernel/AthenaKernel/errorcheck.h:422
GlobalSimulationAlg.h
L1Menu.h
ss
static Double_t ss
Definition
LArPhysWaveHECTool.cxx:37
checker_macros.h
Define macros for attributes used to control the static checker.
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition
AthReentrantAlgorithm.h:74
GlobalSim::BasicDataCollector
Definition
BasicDataCollector.h:15
GlobalSim::GlobalSimulationAlg::initialize
virtual StatusCode initialize() override
Definition
GlobalSimulationAlg.cxx:18
GlobalSim::GlobalSimulationAlg::m_TIPwriters
ToolHandleArray< ITIPWriterAlgTool > m_TIPwriters
Definition
GlobalSimulationAlg.h:55
GlobalSim::GlobalSimulationAlg::m_enableDumps
Gaudi::Property< bool > m_enableDumps
Definition
GlobalSimulationAlg.h:62
GlobalSim::GlobalSimulationAlg::GlobalSimulationAlg
GlobalSimulationAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition
GlobalSimulationAlg.cxx:13
GlobalSim::GlobalSimulationAlg::m_tipWordKey
SG::WriteHandleKey< TIPword > m_tipWordKey
Definition
GlobalSimulationAlg.h:38
GlobalSim::GlobalSimulationAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition
GlobalSimulationAlg.cxx:63
GlobalSim::GlobalSimulationAlg::m_algTools
ToolHandleArray< IGlobalSimAlgTool > m_algTools
Definition
GlobalSimulationAlg.h:49
SG::WriteHandle
Definition
StoreGate/StoreGate/WriteHandle.h:73
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
GlobalSim
AlgTool to read in LArStripNeighborhoods, and run the BDT Algorithm.
Definition
BitSpec.h:23
GlobalSim::TIPword
std::bitset< ITIPWriterAlgTool::s_nbits_TIP > TIPword
Definition
ITIPWriterAlgTool.h:40
run
int run(int argc, char *argv[])
Definition
ttree2hdf5.cxx:28
Generated on
for ATLAS Offline Software by
1.17.0