ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
Algorithms
StandaloneAnalysisAlgorithms
Root
PrintToolConfigAlg.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
//
6
// includes
7
//
8
9
#include <
StandaloneAnalysisAlgorithms/PrintToolConfigAlg.h
>
10
#include <
AsgTools/ToolStore.h
>
11
12
#include <filesystem>
13
#include <fstream>
14
#include <iostream>
15
16
namespace
CP
{
17
18
StatusCode
PrintToolConfigAlg::finalize
() {
19
// Log the current working directory
20
ANA_MSG_INFO
(
"The current filesystem path is: "
+
21
std::filesystem::current_path().generic_string());
22
23
// Log file where configuration will be dumped
24
ANA_MSG_INFO
(
"Dumping the tool configuration to: "
+
m_outputFileName
);
25
26
// Open the output file stream
27
std::ofstream configFileStream(
m_outputFileName
);
28
if
(!configFileStream) {
29
ANA_MSG_ERROR
(
"Failed to open file: "
+
m_outputFileName
);
30
return
StatusCode::FAILURE;
31
}
32
33
// Redirect std::cout to the file stream
34
std::streambuf* originalCoutBuf = std::cout.rdbuf(configFileStream.rdbuf());
35
36
try
{
37
asg::ToolStore::dumpToolConfig();
// Dump the configuration
38
}
catch
(
const
std::exception&
e
) {
39
ANA_MSG_ERROR
(
"Exception while dumping tool configuration: "
+
40
std::string(
e
.what()));
41
std::cout.rdbuf(
42
originalCoutBuf);
// Restore original buffer before returning
43
return
StatusCode::FAILURE;
44
}
45
46
// Restore original std::cout buffer
47
std::cout.rdbuf(originalCoutBuf);
48
49
// Close file stream (optional, as destructor will handle it)
50
configFileStream.close();
51
52
ANA_MSG_INFO
(
"Tool configuration dump complete"
);
53
54
return
StatusCode::SUCCESS;
55
}
56
57
}
// namespace CP
ANA_MSG_INFO
#define ANA_MSG_INFO(xmsg)
Macro printing info messages.
Definition
Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:288
ANA_MSG_ERROR
#define ANA_MSG_ERROR(xmsg)
Macro printing error messages.
Definition
Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:292
PrintToolConfigAlg.h
ToolStore.h
CP::PrintToolConfigAlg::m_outputFileName
Gaudi::Property< std::string > m_outputFileName
Definition
PrintToolConfigAlg.h:20
CP::PrintToolConfigAlg::finalize
StatusCode finalize() override
Definition
PrintToolConfigAlg.cxx:18
CP
Select isolated Photons, Electrons and Muons.
Definition
Control/xAODRootAccess/xAODRootAccess/TEvent.h:27
xAOD::e
setPy e
Definition
CompositeParticle_v1.cxx:166
Generated on
for ATLAS Offline Software by
1.17.0