27 using namespace ActsExamples;
28 using namespace Acts::UnitLiterals;
30 namespace ActsExamples {
42 throw std::invalid_argument(
"No geometry given");
45 throw std::invalid_argument(
"No magnetic field given");
65 std::vector<const SimSpacePoint *> indexToSpacepoint(2 * sps.size(),
nullptr);
66 std::vector<Acts::GeometryIdentifier> indexToGeoId(
69 for (
const auto &sp : sps) {
70 for (
const auto &sl : sp.sourceLinks()) {
71 const auto &isl = sl.template get<IndexSourceLink>();
72 indexToSpacepoint[isl.index()] = &sp;
73 indexToGeoId[isl.index()] = isl.geometryId();
78 seededTracks.reserve(prototracks.size());
81 seeds.reserve(prototracks.size());
84 parameters.reserve(prototracks.size());
88 std::vector<const SimSpacePoint *> tmpSps;
89 std::size_t skippedTracks = 0;
90 for (
auto &track : prototracks) {
91 ACTS_VERBOSE(
"Try to get seed from prototrack with " << track.size()
100 std::sort(track.begin(), track.end(), [&](
auto a,
auto b) {
101 if (indexToGeoId[
a].volume() != indexToGeoId[
b].volume()) {
102 return indexToGeoId[
a].volume() < indexToGeoId[
b].volume();
104 return indexToGeoId[
a].layer() < indexToGeoId[
b].layer();
109 track.begin(), track.end(), std::back_inserter(tmpTrack),
110 [&](
auto a,
auto b) {
111 return indexToGeoId[
a].volume() == indexToGeoId[
b].volume() &&
112 indexToGeoId[
a].layer() == indexToGeoId[
b].layer();
116 if (tmpTrack.size() < 3) {
118 "Cannot seed because less then three hits with unique (layer, "
126 std::transform(track.begin(), track.end(), std::back_inserter(tmpSps),
127 [&](
auto i) {
return indexToSpacepoint[
i]; });
128 tmpSps.erase(std::remove_if(tmpSps.begin(), tmpSps.end(),
129 [](
auto sp) {
return sp ==
nullptr; }),
132 if (tmpSps.size() < 3) {
139 [](
const auto &
a,
const auto &
b) {
return a->r() <
b->r(); });
143 const auto m = (tmpSps.back()->r() - tmpSps.front()->r()) /
144 (tmpSps.back()->z() - tmpSps.front()->z());
145 const auto t = tmpSps.front()->r() - m * tmpSps.front()->z();
146 const auto z_vertex = -
t /
m;
147 const auto s = tmpSps.size();
151 ?
SimSeed(*tmpSps[0], *tmpSps[1], *tmpSps[2], z_vertex)
152 :
SimSeed(*tmpSps[0], *tmpSps[
s / 2], *tmpSps[
s - 1], z_vertex);
155 const auto &bottomSP = seed.
sp().front();
156 const auto geoId = bottomSP->sourceLinks()
158 .template get<IndexSourceLink>()
163 {bottomSP->x(), bottomSP->y(), bottomSP->z()},
bCache);
166 return ProcessCode::ABORT;
177 seededTracks.push_back(track);
183 if (skippedTracks > 0) {
187 ACTS_DEBUG(
"Seeded " << seeds.size() <<
" out of " << prototracks.size()