Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ModuleClustersTests.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file ModuleClustersTests.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2023 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
9 #include <boost/test/unit_test.hpp>
10 
14 
15 using namespace Acts;
16 using namespace ActsFatras;
17 using namespace ActsExamples;
18 
19 namespace {
20 
21 DigitizedParameters makeDigitizationParameters(const Vector2 &position,
22  const Vector2 &variance,
23  const BinUtility &binUtility) {
24  auto [binX, binY, _] =
25  binUtility.binTriple((Vector3() << position, 0).finished());
29  double activation = 1;
30  Cluster::Cell cell = {bin, segment, activation};
31 
32  Cluster cluster;
33  cluster.sizeLoc0 = 1;
34  cluster.sizeLoc1 = 1;
35  cluster.channels = {cell};
36 
37  DigitizedParameters params;
38  params.indices = {eBoundLoc0, eBoundLoc1};
39  params.values = {position.x(), position.y()};
40  params.variances = {variance.x(), variance.y()};
41  params.cluster = {cluster};
42 
43  return params;
44 }
45 
46 auto testDigitizedParametersWithTwoClusters(bool merge, const Vector2 &firstHit,
47  const Vector2 &secondHit) {
48  BinUtility binUtility;
49  binUtility +=
51  binUtility +=
53  std::vector<Acts::BoundIndices> boundIndices = {eBoundLoc0, eBoundLoc1};
54  double nsigma = 1;
55  bool commonCorner = true;
56 
57  ModuleClusters moduleClusters(binUtility, boundIndices, merge, nsigma,
58  commonCorner);
59 
60  moduleClusters.add(makeDigitizationParameters(firstHit, {1, 1}, binUtility),
61  0);
62  moduleClusters.add(makeDigitizationParameters(secondHit, {1, 1}, binUtility),
63  1);
64 
65  return moduleClusters.digitizedParameters();
66 }
67 
68 } // namespace
69 
70 BOOST_AUTO_TEST_SUITE(DigitizationModuleClustersTests)
71 
72 BOOST_AUTO_TEST_CASE(digitizedParameters_merging) {
73  // overlapping hits are expected to be merged if turned on
74  {
75  auto result = testDigitizedParametersWithTwoClusters(true, {0, 0}, {0, 0});
76  BOOST_CHECK_EQUAL(result.size(), 1);
77 
78  result = testDigitizedParametersWithTwoClusters(false, {0, 0}, {0, 0});
79  BOOST_CHECK_EQUAL(result.size(), 2);
80  }
81 
82  // non overlapping hits are not expected to be merged
83  {
84  auto result = testDigitizedParametersWithTwoClusters(true, {0, 0}, {5, 0});
85  BOOST_CHECK_EQUAL(result.size(), 2);
86 
87  result = testDigitizedParametersWithTwoClusters(false, {0, 0}, {5, 0});
88  BOOST_CHECK_EQUAL(result.size(), 2);
89  }
90 }
91 
92 BOOST_AUTO_TEST_SUITE_END()