Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:13:04

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/Utilities/BinUtility.hpp"
0012 #include "Acts/Utilities/BinningData.hpp"
0013 #include "ActsExamples/Digitization/ModuleClusters.hpp"
0014 #include "ActsFatras/Digitization/Segmentizer.hpp"
0015 
0016 using namespace Acts;
0017 using namespace ActsFatras;
0018 using namespace ActsExamples;
0019 
0020 namespace {
0021 
0022 DigitizedParameters makeDigitizationParameters(const Vector2 &position,
0023                                                const Vector2 &variance,
0024                                                const BinUtility &binUtility) {
0025   auto [binX, binY, _] =
0026       binUtility.binTriple((Vector3() << position, 0).finished());
0027   Segmentizer::Bin2D bin = {static_cast<Segmentizer::Bin2D::value_type>(binX),
0028                             static_cast<Segmentizer::Bin2D::value_type>(binY)};
0029   Segmentizer::Segment2D segment = {position, position};
0030   double activation = 1;
0031   Cluster::Cell cell = {bin, segment, activation};
0032 
0033   Cluster cluster;
0034   cluster.sizeLoc0 = 1;
0035   cluster.sizeLoc1 = 1;
0036   cluster.channels = {cell};
0037 
0038   DigitizedParameters params;
0039   params.indices = {eBoundLoc0, eBoundLoc1};
0040   params.values = {position.x(), position.y()};
0041   params.variances = {variance.x(), variance.y()};
0042   params.cluster = {cluster};
0043 
0044   return params;
0045 }
0046 
0047 auto testDigitizedParametersWithTwoClusters(bool merge, const Vector2 &firstHit,
0048                                             const Vector2 &secondHit) {
0049   BinUtility binUtility;
0050   binUtility += BinUtility(BinningData(
0051       BinningOption::open, AxisDirection::AxisX, 20, -10.0f, 10.0f));
0052   binUtility += BinUtility(BinningData(
0053       BinningOption::open, AxisDirection::AxisY, 20, -10.0f, 10.0f));
0054   std::vector<Acts::BoundIndices> boundIndices = {eBoundLoc0, eBoundLoc1};
0055   double nsigma = 1;
0056   bool commonCorner = true;
0057 
0058   ModuleClusters moduleClusters(binUtility, boundIndices, merge, nsigma,
0059                                 commonCorner);
0060 
0061   moduleClusters.add(makeDigitizationParameters(firstHit, {1, 1}, binUtility),
0062                      0);
0063   moduleClusters.add(makeDigitizationParameters(secondHit, {1, 1}, binUtility),
0064                      1);
0065 
0066   return moduleClusters.digitizedParameters();
0067 }
0068 
0069 }  // namespace
0070 
0071 BOOST_AUTO_TEST_SUITE(DigitizationModuleClustersTests)
0072 
0073 BOOST_AUTO_TEST_CASE(digitizedParameters_merging) {
0074   // overlapping hits are expected to be merged if turned on
0075   {
0076     auto result = testDigitizedParametersWithTwoClusters(true, {0, 0}, {0, 0});
0077     BOOST_CHECK_EQUAL(result.size(), 1);
0078 
0079     result = testDigitizedParametersWithTwoClusters(false, {0, 0}, {0, 0});
0080     BOOST_CHECK_EQUAL(result.size(), 2);
0081   }
0082 
0083   // non overlapping hits are not expected to be merged
0084   {
0085     auto result = testDigitizedParametersWithTwoClusters(true, {0, 0}, {5, 0});
0086     BOOST_CHECK_EQUAL(result.size(), 2);
0087 
0088     result = testDigitizedParametersWithTwoClusters(false, {0, 0}, {5, 0});
0089     BOOST_CHECK_EQUAL(result.size(), 2);
0090   }
0091 }
0092 
0093 BOOST_AUTO_TEST_SUITE_END()