Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ATLSeedingIntegrationTest.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file ATLSeedingIntegrationTest.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2018 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 
12 
13 #include <algorithm>
14 
15 // space point structure with the bare minimum and reasonable default
16 // covariances. clusterList default is SCT (strip detector)
17 struct SpacePoint {
18  float x = 0;
19  float y = 0;
20  float z = 0;
21  float r = 0;
22  float covr = 0.03;
23  float covz = 0.03;
24  std::pair<int, int> m_clusterList = std::pair<int, int>(1, 1);
25  void setClusterList(int first, int second) {
26  m_clusterList = std::pair<int, int>(first, second);
27  }
28  const std::pair<int, int> clusterList() const { return m_clusterList; }
29  int surface = 0;
30 };
31 
32 // call sequence to create seeds. Seeds are copied as the
33 // call to next() overwrites the previous seed object
34 std::vector<Acts::Legacy::Seed<SpacePoint>> runSeeding(
35  std::vector<SpacePoint*> spVec) {
37  seedMaker.newEvent(0, spVec.begin(), spVec.end());
38  seedMaker.find3Sp();
39  const Acts::Legacy::Seed<SpacePoint>* seed = seedMaker.next();
40  std::vector<Acts::Legacy::Seed<SpacePoint>> seedVec;
41  while (seed != nullptr) {
42  auto spIter = seed->spacePoints().begin();
43  spIter++;
44  spIter++;
45  seedVec.push_back(*seed);
46  seed = seedMaker.next();
47  }
48  return seedVec;
49 }
50 
51 // used to sort seeds, ignores z
53  public:
56  auto sp1It = s1.spacePoints().begin();
57  auto sp2It = s2.spacePoints().begin();
58  for (int i = 0; i < 3; i++) {
59  if ((*sp1It) != (*sp2It)) {
60  return (*sp1It) < (*sp2It);
61  }
62  sp1It++;
63  sp2It++;
64  }
65  return false;
66  }
67 };
68 
69 BOOST_AUTO_TEST_CASE(number_of_seeds_correct_) {
70  // single particle event with 405MeV (just above default pT-cut)
71  std::vector<SpacePoint*> spVec;
72  std::vector<int> layerVec{1, 2, 2, 3, 4, 11, 13, 14};
73  // clang-format off
74  std::vector<float> xVec{-33.3403,
75  -48.2369,
76  -49.4129,
77  -88.8567,
78  -122.5566,
79  -283.169,
80  -412.277,
81  -462.5564};
82 
83  std::vector<float> yVec{2.7288,
84  4.5193,
85  4.6755,
86  11.1935,
87  18.7696,
88  83.1666,
89  179.1006,
90  232.9765};
91 
92  std::vector<float> zVec{-74.5553,
93  -91.9763,
94  -93.3541,
95  -139.779,
96  -179.889,
97  -381.403,
98  -568.641,
99  -654.2494};
100  // clang-format on
101 
102  // creating space points and setting clusterList to pixel for
103  // the detector region of the pixel detector
104  for (unsigned int i = 0; i < layerVec.size(); i++) {
105  SpacePoint* sp = new SpacePoint();
106  sp->surface = layerVec.at(i);
107  sp->x = xVec.at(i);
108  sp->y = yVec.at(i);
109  sp->z = zVec.at(i);
110  sp->r = std::hypot(sp->x, sp->y);
111  if (sp->r < 200.) {
112  sp->setClusterList(1, 0);
113  }
114  spVec.push_back(sp);
115  }
116  // create seeds (without z component) that are found by the ATLAS seed finder
117  // as reference
118  Acts::Legacy::Seed<SpacePoint> s1(spVec.at(0), spVec.at(1), spVec.at(3), 0);
119  Acts::Legacy::Seed<SpacePoint> s2(spVec.at(0), spVec.at(1), spVec.at(4), 0);
120  Acts::Legacy::Seed<SpacePoint> s3(spVec.at(0), spVec.at(2), spVec.at(3), 0);
121  Acts::Legacy::Seed<SpacePoint> s4(spVec.at(0), spVec.at(2), spVec.at(4), 0);
122  Acts::Legacy::Seed<SpacePoint> s5(spVec.at(0), spVec.at(3), spVec.at(4), 0);
123  Acts::Legacy::Seed<SpacePoint> s6(spVec.at(1), spVec.at(3), spVec.at(4), 0);
124  Acts::Legacy::Seed<SpacePoint> s7(spVec.at(2), spVec.at(3), spVec.at(4), 0);
125  Acts::Legacy::Seed<SpacePoint> s8(spVec.at(5), spVec.at(6), spVec.at(7), 0);
126  std::vector<Acts::Legacy::Seed<SpacePoint>> refVec;
127  refVec.push_back(s1);
128  refVec.push_back(s2);
129  refVec.push_back(s3);
130  refVec.push_back(s4);
131  refVec.push_back(s5);
132  refVec.push_back(s6);
133  refVec.push_back(s7);
134  refVec.push_back(s8);
135 
136  auto seedVec = runSeeding(spVec);
137 
138  // sorting required for set_difference call. sorting assumes space points
139  // inside seed are already sorted.
140  std::sort(refVec.begin(), refVec.end(), seedComparator());
141  std::sort(seedVec.begin(), seedVec.end(), seedComparator());
142 
143  // difference between reference and result shows if results exactly the same
144  // (i.e. difference is 0)
145  std::vector<Acts::Legacy::Seed<SpacePoint>> diff;
146  std::set_difference(refVec.begin(), refVec.end(), seedVec.begin(),
147  seedVec.end(), std::inserter(diff, diff.begin()),
148  seedComparator());
149  BOOST_CHECK(diff.empty());
150  for (auto sp : spVec) {
151  delete sp;
152  }
153 }