ATLAS Offline Software
Loading...
Searching...
No Matches
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
10#include <AsgTools/ToolStore.h>
11
12#include <filesystem>
13#include <fstream>
14#include <iostream>
15
16namespace CP {
17
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
#define ANA_MSG_INFO(xmsg)
Macro printing info messages.
#define ANA_MSG_ERROR(xmsg)
Macro printing error messages.
Gaudi::Property< std::string > m_outputFileName
StatusCode finalize() override
Select isolated Photons, Electrons and Muons.