diff --git a/Examples/Run/Alignment/Common/DetectorAlignment.cpp b/Examples/Run/Alignment/Common/DetectorAlignment.cpp index f6365a32825..fa90428b487 100644 --- a/Examples/Run/Alignment/Common/DetectorAlignment.cpp +++ b/Examples/Run/Alignment/Common/DetectorAlignment.cpp @@ -80,6 +80,9 @@ int runDetectorAlignment( if (vm.empty()) { return EXIT_FAILURE; } + +// feed the alignment group to config + cfg.alignmentGroups = alignmentAlgorithm.getAlignmentGroups(); Sequencer sequencer(Options::readSequencerConfig(vm)); diff --git a/Tests/UnitTests/Alignment/Kernel/AlignmentTests.cpp b/Tests/UnitTests/Alignment/Kernel/AlignmentTests.cpp index 3acf3133c3c..b2f23473712 100644 --- a/Tests/UnitTests/Alignment/Kernel/AlignmentTests.cpp +++ b/Tests/UnitTests/Alignment/Kernel/AlignmentTests.cpp @@ -370,6 +370,72 @@ BOOST_AUTO_TEST_CASE(ZeroFieldKalmanAlignment) { BOOST_CHECK_EQUAL(alignState.alignmentToChi2Derivative.size(), 30); BOOST_CHECK_EQUAL(alignState.alignmentToChi2SecondDerivative.rows(), 30); +// Unit tests that test makeAlignmentGroup functionality + +struct DetectorAlignment::Config { + std::string alignmentGroupsFile; +}; + +int DetectorAlignment::runDetectorAlignment( + int argc, char* argv[], + const std::shared_ptr& detector, + ActsAlignment::AlignedTransformUpdater alignedTransformUpdater, + const AlignedDetElementGetter& alignedDetElementsGetter) { + + +// separate function for reading and parsing JSON +std::vector readJsonFile(const std::string& filePath) { + std::vector alignmentParameters; + + if (!filePath.empty()) { + std::ifstream jsonFile(filePath); + if (!jsonFile.is_open()) { + std::cerr << " Unable to open an alignment group file" << std::endl; + return alignmentParameters; // Return an empty vector in case of failure + } + + // parsing the json file + nlohmann::json jsonData; + try { + jsonFile >> jsonData; + } catch (const nlohmann::json::parse_error& e) { + std::cerr << "Error parsing JSON: " << e.what() << std::endl; + return EXIT_FAILURE; + } + + // populate the alignmentParameters vector + for (const auto& alignmentData : jsonData) { + // create AlignmentParameters + AlignmentAlgorithm::AlignmentParameters alignmentPar; + + alignmentParameters.push_back(alignmentPar); + } + + jsonFile.close(); + + int DetectorAlignment::runDetectorAlignment( + int argc, char* argv[], + const std::shared_ptr& detector, + ActsAlignment::AlignedTransformUpdater alignedTransformUpdater, + const AlignedDetElementGetter& alignedDetElementsGetter) { + + std::string alignmentGroupsFile = vm["name-alignment-groups-file"].as(); + + // Unit test: Check if the alignmentGroupsFile is empty + if (alignmentGroupsFile.empty()) { + std::cout << "Unit Test: Alignment groups file is empty." << std::endl; + return EXIT_SUCCESS; + } + + // Separate function for reading and parsing JSON + //std::vector alignmentParameters = + // readJsonFile(alignmentGroupsFile); + + // makeAlignmentGroup creates alignment groups + alignmentAlgorithm.makeAlignmentGroup(alignmentParameters); + } + + // Test the align method std::vector> trajCollection; trajCollection.reserve(10); diff --git a/acts b/acts new file mode 160000 index 00000000000..825db48eaff --- /dev/null +++ b/acts @@ -0,0 +1 @@ +Subproject commit 825db48eaffae30bcba8c6eee1a9c3a37a09519e