Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2026-04-07 08:08:13

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