File indexing completed on 2025-01-18 09:12:29
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include <boost/test/unit_test.hpp>
0010
0011 #include "Acts/Seeding/AtlasSeedFinder.hpp"
0012
0013 #include <algorithm>
0014
0015
0016
0017 struct SpacePoint {
0018 float x = 0;
0019 float y = 0;
0020 float z = 0;
0021 float r = 0;
0022 float covr = 0.03;
0023 float covz = 0.03;
0024 std::pair<int, int> m_clusterList = std::pair<int, int>(1, 1);
0025 void setClusterList(int first, int second) {
0026 m_clusterList = std::pair<int, int>(first, second);
0027 }
0028 const std::pair<int, int> clusterList() const { return m_clusterList; }
0029 int surface = 0;
0030 };
0031
0032
0033
0034 std::vector<Acts::Legacy::Seed<SpacePoint>> runSeeding(
0035 std::vector<SpacePoint*> spVec) {
0036 Acts::Legacy::AtlasSeedFinder<SpacePoint> seedMaker;
0037 seedMaker.newEvent(0, spVec.begin(), spVec.end());
0038 seedMaker.find3Sp();
0039 const Acts::Legacy::Seed<SpacePoint>* seed = seedMaker.next();
0040 std::vector<Acts::Legacy::Seed<SpacePoint>> seedVec;
0041 while (seed != nullptr) {
0042 auto spIter = seed->spacePoints().begin();
0043 spIter++;
0044 spIter++;
0045 seedVec.push_back(*seed);
0046 seed = seedMaker.next();
0047 }
0048 return seedVec;
0049 }
0050
0051
0052 class seedComparator {
0053 public:
0054 bool operator()(const Acts::Legacy::Seed<SpacePoint>& s1,
0055 const Acts::Legacy::Seed<SpacePoint>& s2) {
0056 auto sp1It = s1.spacePoints().begin();
0057 auto sp2It = s2.spacePoints().begin();
0058 for (int i = 0; i < 3; i++) {
0059 if ((*sp1It) != (*sp2It)) {
0060 return (*sp1It) < (*sp2It);
0061 }
0062 sp1It++;
0063 sp2It++;
0064 }
0065 return false;
0066 }
0067 };
0068
0069 BOOST_AUTO_TEST_CASE(number_of_seeds_correct_) {
0070
0071 std::vector<SpacePoint*> spVec;
0072 std::vector<int> layerVec{1, 2, 2, 3, 4, 11, 13, 14};
0073
0074 std::vector<float> xVec{-33.3403,
0075 -48.2369,
0076 -49.4129,
0077 -88.8567,
0078 -122.5566,
0079 -283.169,
0080 -412.277,
0081 -462.5564};
0082
0083 std::vector<float> yVec{2.7288,
0084 4.5193,
0085 4.6755,
0086 11.1935,
0087 18.7696,
0088 83.1666,
0089 179.1006,
0090 232.9765};
0091
0092 std::vector<float> zVec{-74.5553,
0093 -91.9763,
0094 -93.3541,
0095 -139.779,
0096 -179.889,
0097 -381.403,
0098 -568.641,
0099 -654.2494};
0100
0101
0102
0103
0104 for (unsigned int i = 0; i < layerVec.size(); i++) {
0105 SpacePoint* sp = new SpacePoint();
0106 sp->surface = layerVec.at(i);
0107 sp->x = xVec.at(i);
0108 sp->y = yVec.at(i);
0109 sp->z = zVec.at(i);
0110 sp->r = std::hypot(sp->x, sp->y);
0111 if (sp->r < 200.) {
0112 sp->setClusterList(1, 0);
0113 }
0114 spVec.push_back(sp);
0115 }
0116
0117
0118 Acts::Legacy::Seed<SpacePoint> s1(spVec.at(0), spVec.at(1), spVec.at(3), 0);
0119 Acts::Legacy::Seed<SpacePoint> s2(spVec.at(0), spVec.at(1), spVec.at(4), 0);
0120 Acts::Legacy::Seed<SpacePoint> s3(spVec.at(0), spVec.at(2), spVec.at(3), 0);
0121 Acts::Legacy::Seed<SpacePoint> s4(spVec.at(0), spVec.at(2), spVec.at(4), 0);
0122 Acts::Legacy::Seed<SpacePoint> s5(spVec.at(0), spVec.at(3), spVec.at(4), 0);
0123 Acts::Legacy::Seed<SpacePoint> s6(spVec.at(1), spVec.at(3), spVec.at(4), 0);
0124 Acts::Legacy::Seed<SpacePoint> s7(spVec.at(2), spVec.at(3), spVec.at(4), 0);
0125 Acts::Legacy::Seed<SpacePoint> s8(spVec.at(5), spVec.at(6), spVec.at(7), 0);
0126 std::vector<Acts::Legacy::Seed<SpacePoint>> refVec;
0127 refVec.push_back(s1);
0128 refVec.push_back(s2);
0129 refVec.push_back(s3);
0130 refVec.push_back(s4);
0131 refVec.push_back(s5);
0132 refVec.push_back(s6);
0133 refVec.push_back(s7);
0134 refVec.push_back(s8);
0135
0136 auto seedVec = runSeeding(spVec);
0137
0138
0139
0140 std::ranges::sort(refVec, seedComparator());
0141 std::ranges::sort(seedVec, seedComparator());
0142
0143
0144
0145 std::vector<Acts::Legacy::Seed<SpacePoint>> diff;
0146 std::set_difference(refVec.begin(), refVec.end(), seedVec.begin(),
0147 seedVec.end(), std::inserter(diff, diff.begin()),
0148 seedComparator());
0149 BOOST_CHECK(diff.empty());
0150 for (auto sp : spVec) {
0151 delete sp;
0152 }
0153 }