13 #include "Acts/Definitions/Units.hpp"
14 #include "Acts/Definitions/Common.hpp"
15 #include "Acts/Definitions/Algebra.hpp"
16 #include "Acts/Surfaces/Surface.hpp"
17 #include "Acts/Surfaces/AnnulusBounds.hpp"
18 #include "Acts/Surfaces/SurfaceBounds.hpp"
19 #include "Acts/Surfaces/DiscSurface.hpp"
20 #include "Acts/EventData/TransformationHelpers.hpp"
41 static constexpr std::array<std::tuple<bool, Acts::TrackStateFlag, char>, 6> trackStateNames{{
42 {
false, Acts::TrackStateFlag::ParameterFlag,
'-'},
43 {
true, Acts::TrackStateFlag::MeasurementFlag,
'M'},
44 {
true, Acts::TrackStateFlag::OutlierFlag,
'O'},
45 {
true, Acts::TrackStateFlag::HoleFlag,
'H'},
46 {
true, Acts::TrackStateFlag::MaterialFlag,
'm'},
47 {
true, Acts::TrackStateFlag::SharedHitFlag,
'S'},
50 for (
const auto &[
b,
f,
c] : trackStateNames)
52 if (trackStateType.test(
f) ==
b)
61 std::string
name = surface.name();
62 if (
name.compare(0, 6,
"Acts::") == 0)
66 if (
name.size() > 7 &&
name.compare(
name.size() - 7, 7,
"Surface") == 0)
70 static const std::map<Acts::SurfaceBounds::BoundsType, const char *> boundsNames{{
71 {Acts::SurfaceBounds::BoundsType::eCone,
"Cone"},
72 {Acts::SurfaceBounds::BoundsType::eCylinder,
"Cylinder"},
73 {Acts::SurfaceBounds::BoundsType::eDiamond,
"Diamond"},
74 {Acts::SurfaceBounds::BoundsType::eDisc,
"Disc"},
75 {Acts::SurfaceBounds::BoundsType::eEllipse,
"Ellipse"},
76 {Acts::SurfaceBounds::BoundsType::eLine,
"Line"},
77 {Acts::SurfaceBounds::BoundsType::eRectangle,
"Rectangle"},
78 {Acts::SurfaceBounds::BoundsType::eTrapezoid,
"Trapezoid"},
79 {Acts::SurfaceBounds::BoundsType::eTriangle,
"Triangle"},
80 {Acts::SurfaceBounds::BoundsType::eDiscTrapezoid,
"DiscTrapezoid"},
81 {Acts::SurfaceBounds::BoundsType::eConvexPolygon,
"ConvexPolygon"},
82 {Acts::SurfaceBounds::BoundsType::eAnnulus,
"Annulus"},
83 {Acts::SurfaceBounds::BoundsType::eBoundless,
"Boundless"},
84 {Acts::SurfaceBounds::BoundsType::eOther,
"Other"},
86 if (
auto it = boundsNames.find(surface.bounds().type());
87 it != boundsNames.end() &&
it->second !=
name)
100 auto name = idHelper->show_to_string(detElem.
identify());
103 return name.substr(1,
name.size() - 2);
115 std::cout << std::left
116 << std::setw(5) <<
"Index" <<
' '
117 << std::setw(4) <<
"Type" <<
' '
118 << std::setw(21) <<
"SurfaceBounds" <<
' ';
121 std::cout << std::setw(22) <<
"GeometryId" <<
' '
122 << std::setw(20) <<
"ATLAS ID" <<
' '
124 << std::setw(10) <<
"loc0" <<
' '
125 << std::setw(10) <<
"loc1"
127 << std::setw(9) <<
"R" <<
' '
128 << std::setw(9) <<
"phid" <<
' '
129 << std::setw(9) <<
"eta";
133 << std::setw(10) <<
"Trk loc0" <<
' '
134 << std::setw(10) <<
"loc1"
136 << std::setw(9) <<
"Trk R" <<
' '
137 << std::setw(9) <<
"phid" <<
' '
138 << std::setw(9) <<
"eta" <<
' '
139 << std::setw(10) <<
"g2l loc0" <<
' '
140 << std::setw(10) <<
"loc1";
143 static std::atomic<int> kilroy = 0;
146 std::cout <<
"R (mm) and phi (degrees). Estimated local coordinate indicated by \"*\" (from SP), \"o\" (from module center), or \"#\" (globalToLocal(center) failure).";
148 std::cout <<
" Athena/ACTS comparison only shown if different.";
154 std::cout << std::setw(22) <<
"GeometryId/meas/stats" <<
' '
156 << std::setw(10) <<
"loc0" <<
' '
157 << std::setw(10) <<
"loc1" <<
' '
158 << std::setw(9) <<
"Pos R" <<
' '
159 << std::setw(9) <<
"phid" <<
' '
160 << std::setw(9) <<
"eta" <<
' '
161 << std::setw(9) <<
"q*pT" <<
' '
162 << std::setw(9) <<
"phid" <<
' '
163 << std::setw(9) <<
"eta" <<
' '
164 << std::setw(6) <<
"TrkLen" <<
' '
165 << std::setw(7) <<
"chi2" <<
' '
166 << std::setw(6) <<
"Flags" <<
'\n';
171 printVec3(
const Acts::Vector3 &
p)
173 std::cout << std::fixed <<
' '
174 << std::setw(9) << std::setprecision(3) <<
p.head<2>().
norm() <<
' '
176 << std::setw(9) << std::setprecision(5) << std::atanh(
p[2] /
p.norm())
177 << std::defaultfloat << std::setprecision(-1);
181 printVec3(
const Acts::Vector3 &
p,
const Acts::Vector3 &
cmp,
int precision = 3)
189 std::cout << std::setw(30) <<
"";
194 printVec2(
const Acts::Vector2 &
p,
const char *estimated =
nullptr)
196 const char e0 = estimated ? estimated[0] :
' ';
197 const char *
e1 = estimated ? estimated + 1 :
"";
198 std::cout << std::fixed <<
' '
199 << std::setw(10) << std::setprecision(4) <<
p[0] <<
e0
200 << std::setw(10) << std::setprecision(4) <<
p[1] <<
e1
201 << std::defaultfloat << std::setprecision(-1);
205 printVec2(
const Acts::Vector2 &
p,
const Acts::Vector2 &
cmp,
const char *estimated =
nullptr,
int precision = 4)
209 printVec2(
p, estimated);
213 std::cout << std::setw(22 + (estimated ? 1 : 0)) <<
"";
218 printMeasurement(
const Acts::GeometryContext &tgContext,
219 const Acts::Surface *surface,
221 const std::tuple<Acts::Vector2, Amg::Vector2D, int, int> &locData,
222 bool compareMeasurementTransforms =
false)
224 auto &[loc, locTrk, measInd, est] = locData;
225 int flag = est < 0 ? est : 2 * est + measInd;
226 int flagTrk = est < 0 ? est : 2 * est;
228 static const std::map<int, const char *> estimated_flags{{-1,
" "},
235 printVec2(loc, estimated_flags.at(
flag));
243 if (compareMeasurementTransforms)
247 printVec2(locTrk, (measInd == 1 ? loc.reverse() : loc), estimated_flags.at(flagTrk));
252 printVec3(globTrk, glob);
257 std::cout <<
" ** " <<
res.error() <<
" **";
261 printVec2(
res.value(), loc);
266 std::cout << std::defaultfloat << std::setprecision(-1);
269 static std::tuple<Acts::Vector2, Amg::Vector2D, int, int>
270 localPositionStrip2D(
const Acts::GeometryContext &tgContext,
272 const Acts::Surface *surface,
275 auto *disc =
dynamic_cast<const Acts::DiscSurface *
>(surface);
292 if (
auto *annulus =
dynamic_cast<const Acts::AnnulusBounds *
>(&surface->bounds()))
294 loc[0] = 0.5 * (annulus->rMin() + annulus->rMax());
309 const int measInd = disc ? 1 : 0;
313 Amg::Vector2D locTrk{disc->localPolarToCartesian(loc).reverse()};
314 locTrk[0] = -locTrk[0];
315 return {loc, locTrk, measInd, est};
319 return {loc, loc, measInd, est};
330 if (!measurement || !detectorElements)
333 std::cout << std::setw(5) << (measurement->
index() +
offset) <<
' '
337 const Acts::Surface *surface_ptr =
nullptr;
340 std::cout << std::setw(20 + 22 + 20 + 2) <<
"** no DetElem **";
345 std::cout << std::left;
347 << std::setw(22) <<
to_string(surface_ptr->geometryId()) <<
' ';
348 std::cout << std::setw(20) << atlasSurfaceName(*detElem);
349 std::cout << std::right;
354 const auto loc = measurement->
localPosition<2>().cast<double>();
362 printMeasurement(tgContext, surface_ptr, detElem,
363 localPositionStrip2D(tgContext, *measurement, surface_ptr,
nullptr),
369 for (
auto *sp : spvec)
375 << std::setw(76) <<
to_string(
"** Spacepoint ", isp,
" **")
378 printMeasurement(tgContext, surface_ptr, detElem,
379 localPositionStrip2D(tgContext, *measurement, surface_ptr, sp),
389 auto p = Acts::transformBoundToFreeParameters(surface, tgContext,
bound);
390 std::cout << std::fixed
391 << std::setw(10) << std::setprecision(4) <<
bound[Acts::eBoundLoc0] <<
' '
392 << std::setw(10) << std::setprecision(4) <<
bound[Acts::eBoundLoc1] <<
' '
393 << std::setw(9) << std::setprecision(3) <<
p.segment<2>(Acts::eFreePos0).
norm() <<
' '
395 << std::setw(9) << std::setprecision(5) << std::atanh(
p[Acts::eFreePos2] /
p.segment<3>(Acts::eFreePos0).norm()) <<
' '
396 << std::setw(9) << std::setprecision(3) <<
p.segment<2>(Acts::eFreeDir0).
norm() /
p[Acts::eFreeQOverP] <<
' '
398 << std::setw(9) << std::setprecision(5) << std::atanh(
p[Acts::eFreeDir2])
399 << std::defaultfloat << std::setprecision(-1);
407 const std::string &
name,
423 return StatusCode::SUCCESS;
429 const Acts::BoundTrackParameters &initialParameters,
430 size_t measurementOffset,
437 std::ostringstream
os;
439 for (
const auto *sp : seed.sp())
444 std::size_t
index =
el->index();
451 os << measurementOffset +
index;
455 std::cout << std::setw(5) << iseed <<
' '
457 << std::setw(4) << (!isKF ?
"seed" :
"KF") <<
' '
458 << std::setw(21) <<
actsSurfaceName(initialParameters.referenceSurface()) <<
' '
461 printParameters(initialParameters.referenceSurface(), tgContext, initialParameters.parameters());
468 const std::vector<const xAOD::UncalibratedMeasurementContainer *> &clusterContainers,
469 const std::vector<const InDetDD::SiDetectorElementCollection *> &detectorElementCollections,
470 const std::vector<size_t> &offsets)
const
480 for (std::size_t icontainer = 0; icontainer < clusterContainers.size(); ++icontainer)
482 for (
const auto *measurement : *clusterContainers[icontainer])
490 std::vector<std::vector<TrackStatePrinter::small_vector<const xAOD::SpacePoint *>>>
492 const std::vector<const xAOD::UncalibratedMeasurementContainer *> &clusterContainers,
493 const std::vector<size_t> &offsets)
const
495 std::vector<std::vector<TrackStatePrinter::small_vector<const xAOD::SpacePoint *>>> measToSp{clusterContainers.size()};
496 for (std::size_t icontainer = 0; icontainer < clusterContainers.size(); ++icontainer)
498 measToSp[icontainer].resize(clusterContainers[icontainer]->
size());
503 ATH_MSG_DEBUG(
"Retrieving from input SpacePoint collection '" << spacePointKey.key() <<
"' ...");
507 ATH_MSG_ERROR(
"Error retrieving from input SpacePoint collection '" << spacePointKey.key() <<
"'");
511 for (
const auto *sp : *handle)
517 for (std::size_t icontainer = 0; icontainer < clusterContainers.size(); ++icontainer)
520 if (!(meas && meas->index() < clusterContainers[icontainer]->size() && meas == clusterContainers[icontainer]->at(meas->index())))
526 << (meas->index() + offsets[icontainer])
527 <<
" used by SpacePoints at ("
530 << measSp[0]->globalPosition()[0] <<
',' << measSp[0]->globalPosition()[1] <<
',' << measSp[0]->globalPosition()[2]
533 measSp.push_back(sp);