Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:12:31

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
0008 
0009 #include <boost/test/unit_test.hpp>
0010 
0011 #include "Acts/Detector/Blueprint.hpp"
0012 #include "Acts/Detector/detail/BlueprintDrawer.hpp"
0013 
0014 #include <fstream>
0015 
0016 namespace Acts::Experimental {
0017 class IInternalStructureBuilder {};
0018 }  // namespace Acts::Experimental
0019 
0020 BOOST_AUTO_TEST_SUITE(Experimental)
0021 
0022 BOOST_AUTO_TEST_CASE(BlueprintTest) {
0023   std::vector<double> bValues = {0., 10., 100.};
0024 
0025   // Create  root node
0026   std::vector<Acts::AxisDirection> binning = {Acts::AxisDirection::AxisR};
0027   auto root = std::make_unique<Acts::Experimental::Blueprint::Node>(
0028       "detector", Acts::Transform3::Identity(), Acts::VolumeBounds::eOther,
0029       bValues, binning);
0030   // Check the root node
0031   BOOST_CHECK(root->isRoot());
0032   BOOST_CHECK_EQUAL(root->parent, nullptr);
0033   BOOST_CHECK(root->children.empty());
0034   BOOST_CHECK_EQUAL(root->name, "detector");
0035 
0036   auto leaf0 = std::make_unique<Acts::Experimental::Blueprint::Node>(
0037       "volume_0", Acts::Transform3::Identity(), Acts::VolumeBounds::eOther,
0038       bValues);
0039   BOOST_CHECK(leaf0->isLeaf());
0040 
0041   auto branch = std::make_unique<Acts::Experimental::Blueprint::Node>(
0042       "container_0", Acts::Transform3::Identity(), Acts::VolumeBounds::eOther,
0043       bValues, binning);
0044 
0045   auto leaf1 = std::make_unique<Acts::Experimental::Blueprint::Node>(
0046       "volume_1", Acts::Transform3::Identity(), Acts::VolumeBounds::eOther,
0047       bValues);
0048 
0049   auto leaf2 = std::make_unique<Acts::Experimental::Blueprint::Node>(
0050       "volume_2", Acts::Transform3::Identity(), Acts::VolumeBounds::eOther,
0051       bValues,
0052       std::make_shared<Acts::Experimental::IInternalStructureBuilder>());
0053 
0054   // Keep around the pointers of the branch & leaves
0055   auto* leaf0Ptr = leaf0.get();
0056   auto* leaf1Ptr = leaf1.get();
0057   auto* leaf2Ptr = leaf2.get();
0058   auto* branchPtr = branch.get();
0059 
0060   branch->add(std::move(leaf1));
0061   branch->add(std::move(leaf2));
0062 
0063   // Branch has two children
0064   BOOST_CHECK_EQUAL(branch->children.size(), 2u);
0065 
0066   // Parent of the leaves is the branch
0067   BOOST_CHECK_EQUAL(leaf1Ptr->parent, branchPtr);
0068   BOOST_CHECK_EQUAL(leaf2Ptr->parent, branchPtr);
0069 
0070   root->add(std::move(branch));
0071 
0072   // Root stays root
0073   BOOST_CHECK(root->isRoot());
0074   // Parent of the branch is the root
0075   BOOST_CHECK_EQUAL(branchPtr->parent, root.get());
0076 
0077   root->add(std::move(leaf0));
0078 
0079   // Parent of the leaf is the root
0080   BOOST_CHECK_EQUAL(leaf0Ptr->parent, root.get());
0081 
0082   std::ofstream fs("blueprint.dot");
0083   Acts::Experimental::detail::BlueprintDrawer::dotStream(fs, *root);
0084   fs.close();
0085 }
0086 
0087 BOOST_AUTO_TEST_SUITE_END()