EIC 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;
19  float y;
20  float z;
21  float r;
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;
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  int numSeeds = 0;
41  std::vector<Acts::Legacy::Seed<SpacePoint>> seedVec;
42  while (seed != 0) {
43  numSeeds++;
44  auto spIter = seed->spacePoints().begin();
45  spIter++;
46  spIter++;
47  seedVec.push_back(*seed);
48  seed = seedMaker.next();
49  }
50  return seedVec;
51 }
52 
53 // used to sort seeds, ignores z
55  public:
58  auto sp1It = s1.spacePoints().begin();
59  auto sp2It = s2.spacePoints().begin();
60  for (int i = 0; i < 3; i++) {
61  if ((*sp1It) != (*sp2It)) {
62  return (*sp1It) < (*sp2It);
63  }
64  sp1It++;
65  sp2It++;
66  }
67  return false;
68  }
69 };
70 
71 BOOST_AUTO_TEST_CASE(number_of_seeds_correct_) {
72  // single particle event with 405MeV (just above default pT-cut)
73  std::vector<SpacePoint*> spVec;
74  std::vector<int> layerVec{1, 2, 2, 3, 4, 11, 13, 14};
75  // clang-format off
76  std::vector<float> xVec{-33.3403,
77  -48.2369,
78  -49.4129,
79  -88.8567,
80  -122.5566,
81  -283.169,
82  -412.277,
83  -462.5564};
84 
85  std::vector<float> yVec{2.7288,
86  4.5193,
87  4.6755,
88  11.1935,
89  18.7696,
90  83.1666,
91  179.1006,
92  232.9765};
93 
94  std::vector<float> zVec{-74.5553,
95  -91.9763,
96  -93.3541,
97  -139.779,
98  -179.889,
99  -381.403,
100  -568.641,
101  -654.2494};
102  // clang-format on
103 
104  // creating space points and setting clusterList to pixel for
105  // the detector region of the pixel detector
106  for (unsigned int i = 0; i < layerVec.size(); i++) {
107  SpacePoint* sp = new SpacePoint();
108  sp->surface = layerVec.at(i);
109  sp->x = xVec.at(i);
110  sp->y = yVec.at(i);
111  sp->z = zVec.at(i);
112  sp->r = std::sqrt(sp->x * sp->x + sp->y * sp->y);
113  if (sp->r < 200.) {
114  sp->setClusterList(1, 0);
115  }
116  spVec.push_back(sp);
117  }
118  // create seeds (without z component) that are found by the ATLAS seed finder
119  // as reference
120  Acts::Legacy::Seed<SpacePoint> s1(spVec.at(0), spVec.at(1), spVec.at(3), 0);
121  Acts::Legacy::Seed<SpacePoint> s2(spVec.at(0), spVec.at(1), spVec.at(4), 0);
122  Acts::Legacy::Seed<SpacePoint> s3(spVec.at(0), spVec.at(2), spVec.at(3), 0);
123  Acts::Legacy::Seed<SpacePoint> s4(spVec.at(0), spVec.at(2), spVec.at(4), 0);
124  Acts::Legacy::Seed<SpacePoint> s5(spVec.at(0), spVec.at(3), spVec.at(4), 0);
125  Acts::Legacy::Seed<SpacePoint> s6(spVec.at(1), spVec.at(3), spVec.at(4), 0);
126  Acts::Legacy::Seed<SpacePoint> s7(spVec.at(2), spVec.at(3), spVec.at(4), 0);
127  Acts::Legacy::Seed<SpacePoint> s8(spVec.at(5), spVec.at(6), spVec.at(7), 0);
128  std::vector<Acts::Legacy::Seed<SpacePoint>> refVec;
129  refVec.push_back(s1);
130  refVec.push_back(s2);
131  refVec.push_back(s3);
132  refVec.push_back(s4);
133  refVec.push_back(s5);
134  refVec.push_back(s6);
135  refVec.push_back(s7);
136  refVec.push_back(s8);
137 
138  auto seedVec = runSeeding(spVec);
139 
140  // sorting required for set_difference call. sorting assumes space points
141  // inside seed are already sorted.
142  std::sort(refVec.begin(), refVec.end(), seedComparator());
143  std::sort(seedVec.begin(), seedVec.end(), seedComparator());
144 
145  // difference between reference and result shows if results exactly the same
146  // (i.e. difference is 0)
147  std::vector<Acts::Legacy::Seed<SpacePoint>> diff;
148  std::set_difference(refVec.begin(), refVec.end(), seedVec.begin(),
149  seedVec.end(), std::inserter(diff, diff.begin()),
150  seedComparator());
151  BOOST_CHECK(diff.empty());
152  for (auto sp : spVec) {
153  delete sp;
154  }
155 }