File indexing completed on 2026-10-20 08:42:21
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include <boost/test/tools/old/interface.hpp>
0010 #include <boost/test/unit_test.hpp>
0011
0012 #include "Acts/Utilities/Logger.hpp"
0013 #include "ActsPlugins/Mille/MillePedeError.hpp"
0014 #include "ActsPlugins/Mille/MillePedeResultReader.hpp"
0015
0016 #include <format>
0017 #include <fstream>
0018
0019 using namespace ActsPlugins;
0020
0021 BOOST_AUTO_TEST_SUITE(MillePedeResultReaderSimpleFile)
0022
0023 bool operator==(const MillePedeParameterResult &r1,
0024 const MillePedeParameterResult &r2) {
0025 return (r1.label == r2.label && r1.val == r2.val && r1.start == r2.start &&
0026 r1.delta == r2.delta && r1.sigma == r2.sigma &&
0027 r1.nRecords == r2.nRecords);
0028 }
0029
0030 std::ostream &operator<<(std::ostream &str, const MillePedeParameterResult &p) {
0031 str << std::format(
0032 " [ Label {}, Val {}, Start {}, Delta {}, Sigma {}, NRecords {} ]",
0033 p.label, p.val, p.start, p.delta, p.sigma, p.nRecords);
0034 return str;
0035 }
0036
0037
0038 BOOST_AUTO_TEST_CASE(ReadSimpleFile) {
0039 auto logger = Acts::getDefaultLogger("ReadSimpleFile", Acts::Logging::INFO);
0040 std::filesystem::path dummyFileName("testResult.txt");
0041 std::ofstream dummyResultFile(dummyFileName);
0042 dummyResultFile << " # this is a comment line and will be ignored."
0043 << std::endl;
0044
0045 std::vector<MillePedeParameterResult> dummyResults{
0046 {1, 0.01, 0.00, 0.01, 0.001, 144},
0047 {41, -0.07, 0.00, -0.07, 0.001, 86},
0048 {99, -0.015, 10.00, -0.0, 0.0031, 1446},
0049 };
0050 for (const auto &[label, val, start, delta, sigma, nRec] : dummyResults) {
0051 dummyResultFile << label << " " << val << " " << start << " " << delta
0052 << " " << sigma << " " << nRec << std::endl;
0053 }
0054 dummyResultFile.close();
0055 auto res = ActsPlugins::readMillePedeResult(dummyFileName, *logger);
0056 BOOST_CHECK(res.ok());
0057 BOOST_CHECK_EQUAL(res->size(), dummyResults.size());
0058 for (std::size_t i = 0; i < res->size(); ++i) {
0059 BOOST_CHECK(res->at(i) == dummyResults[i]);
0060 }
0061 }
0062
0063 BOOST_AUTO_TEST_CASE(ReadInvalidFile) {
0064
0065
0066
0067
0068 Acts::Logging::ScopedFailureThreshold threshold{Acts::Logging::Level::MAX};
0069 auto logger = Acts::getDefaultLogger("ReadSimpleFile", Acts::Logging::INFO);
0070
0071 auto res = readMillePedeResult("/this/does/hopefully/not/exist?", *logger);
0072 BOOST_CHECK(!res.ok());
0073 BOOST_CHECK_EQUAL(res.error(), MillePedeError::SolutionNotReadable);
0074 }
0075
0076 BOOST_AUTO_TEST_SUITE_END()