14 #include "Acts/Definitions/Units.hpp"
15 #include "Acts/Definitions/Common.hpp"
16 #include "Acts/Definitions/Algebra.hpp"
17 #include "Acts/Surfaces/Surface.hpp"
18 #include "Acts/Surfaces/AnnulusBounds.hpp"
19 #include "Acts/Surfaces/SurfaceBounds.hpp"
20 #include "Acts/Surfaces/DiscSurface.hpp"
21 #include "Acts/EventData/TransformationHelpers.hpp"
44 static constexpr std::array<std::tuple<bool, Acts::TrackStateFlag, char>, 6> trackStateNames{{
45 {
false, Acts::TrackStateFlag::ParameterFlag,
'-'},
46 {
true, Acts::TrackStateFlag::MeasurementFlag,
'M'},
47 {
true, Acts::TrackStateFlag::OutlierFlag,
'O'},
48 {
true, Acts::TrackStateFlag::HoleFlag,
'H'},
49 {
true, Acts::TrackStateFlag::MaterialFlag,
'm'},
50 {
true, Acts::TrackStateFlag::SharedHitFlag,
'S'},
53 for (
const auto &[
b,
f,
c] : trackStateNames)
55 if (trackStateType.test(
f) ==
b)
64 std::string
name = surface.name();
65 if (
name.compare(0, 6,
"Acts::") == 0)
69 if (
name.size() > 7 &&
name.compare(
name.size() - 7, 7,
"Surface") == 0)
73 static const std::map<Acts::SurfaceBounds::BoundsType, const char *> boundsNames{{
74 {Acts::SurfaceBounds::BoundsType::eCone,
"Cone"},
75 {Acts::SurfaceBounds::BoundsType::eCylinder,
"Cylinder"},
76 {Acts::SurfaceBounds::BoundsType::eDiamond,
"Diamond"},
77 {Acts::SurfaceBounds::BoundsType::eDisc,
"Disc"},
78 {Acts::SurfaceBounds::BoundsType::eEllipse,
"Ellipse"},
79 {Acts::SurfaceBounds::BoundsType::eLine,
"Line"},
80 {Acts::SurfaceBounds::BoundsType::eRectangle,
"Rectangle"},
81 {Acts::SurfaceBounds::BoundsType::eTrapezoid,
"Trapezoid"},
82 {Acts::SurfaceBounds::BoundsType::eTriangle,
"Triangle"},
83 {Acts::SurfaceBounds::BoundsType::eDiscTrapezoid,
"DiscTrapezoid"},
84 {Acts::SurfaceBounds::BoundsType::eConvexPolygon,
"ConvexPolygon"},
85 {Acts::SurfaceBounds::BoundsType::eAnnulus,
"Annulus"},
86 {Acts::SurfaceBounds::BoundsType::eBoundless,
"Boundless"},
87 {Acts::SurfaceBounds::BoundsType::eOther,
"Other"},
89 if (
auto it = boundsNames.find(surface.bounds().type());
90 it != boundsNames.end() &&
it->second !=
name)
99 atlasSurfaceName(
const Acts::Surface *measurement_surface)
101 if (measurement_surface) {
103 acts_detector_element =
dynamic_cast<const ActsDetectorElement *
>(measurement_surface->associatedDetectorElement());
104 if (acts_detector_element) {
109 auto name = idHelper->show_to_string(detElem->
identify());
112 return name.substr(1,
name.size() - 2);
127 std::cout << std::left
128 << std::setw(5) <<
"Index" <<
' '
129 << std::setw(4) <<
"Type" <<
' '
130 << std::setw(21) <<
"SurfaceBounds" <<
' ';
133 std::cout << std::setw(22) <<
"GeometryId" <<
' '
134 << std::setw(20) <<
"ATLAS ID" <<
' '
136 << std::setw(10) <<
"loc0" <<
' '
137 << std::setw(10) <<
"loc1"
139 << std::setw(9) <<
"R" <<
' '
140 << std::setw(9) <<
"phid" <<
' '
141 << std::setw(9) <<
"eta";
145 << std::setw(10) <<
"Trk loc0" <<
' '
146 << std::setw(10) <<
"loc1"
148 << std::setw(9) <<
"Trk R" <<
' '
149 << std::setw(9) <<
"phid" <<
' '
150 << std::setw(9) <<
"eta" <<
' '
151 << std::setw(10) <<
"g2l loc0" <<
' '
152 << std::setw(10) <<
"loc1";
155 static std::atomic<int> kilroy = 0;
158 std::cout <<
"R (mm) and phi (degrees). Estimated local coordinate indicated by \"*\" (from SP), \"o\" (from module center), or \"#\" (globalToLocal(center) failure).";
160 std::cout <<
" Athena/ACTS comparison only shown if different.";
166 std::cout << std::setw(22) <<
"GeometryId/meas/stats" <<
' '
168 << std::setw(10) <<
"loc0" <<
' '
169 << std::setw(10) <<
"loc1" <<
' '
170 << std::setw(9) <<
"Pos R" <<
' '
171 << std::setw(9) <<
"phid" <<
' '
172 << std::setw(9) <<
"eta" <<
' '
173 << std::setw(9) <<
"q*pT" <<
' '
174 << std::setw(9) <<
"phid" <<
' '
175 << std::setw(9) <<
"eta" <<
' '
176 << std::setw(6) <<
"TrkLen" <<
' '
177 << std::setw(7) <<
"chi2" <<
' '
178 << std::setw(6) <<
"Flags" <<
'\n';
183 printVec3(
const Acts::Vector3 &
p)
185 std::cout << std::fixed <<
' '
186 << std::setw(9) << std::setprecision(3) <<
p.head<2>().
norm() <<
' '
188 << std::setw(9) << std::setprecision(5) << std::atanh(
p[2] /
p.norm())
189 << std::defaultfloat << std::setprecision(-1);
193 printVec3(
const Acts::Vector3 &
p,
const Acts::Vector3 &
cmp,
int precision = 3)
201 std::cout << std::setw(30) <<
"";
206 printVec2(
const Acts::Vector2 &
p,
const char *estimated =
nullptr)
208 const char e0 = estimated ? estimated[0] :
' ';
209 const char *
e1 = estimated ? estimated + 1 :
"";
210 std::cout << std::fixed <<
' '
211 << std::setw(10) << std::setprecision(4) <<
p[0] <<
e0
212 << std::setw(10) << std::setprecision(4) <<
p[1] <<
e1
213 << std::defaultfloat << std::setprecision(-1);
217 printVec2(
const Acts::Vector2 &
p,
const Acts::Vector2 &
cmp,
const char *estimated =
nullptr,
int precision = 4)
221 printVec2(
p, estimated);
225 std::cout << std::setw(22 + (estimated ? 1 : 0)) <<
"";
230 printMeasurement(
const Acts::GeometryContext &tgContext,
231 const Acts::Surface *surface,
232 const std::tuple<Acts::Vector2, Amg::Vector2D, int, int> &locData,
233 bool compareMeasurementTransforms =
false)
235 auto &[loc, locTrk, measInd, est] = locData;
236 int flag = est < 0 ? est : 2 * est + measInd;
237 int flagTrk = est < 0 ? est : 2 * est;
239 static const std::map<int, const char *> estimated_flags{{-1,
" "},
246 printVec2(loc, estimated_flags.at(
flag));
254 if (compareMeasurementTransforms)
257 acts_detector_element =
dynamic_cast<const ActsDetectorElement *
>(surface->associatedDetectorElement());
258 if (acts_detector_element) {
263 printVec2(locTrk, (measInd == 1 ? loc.reverse() : loc), estimated_flags.at(flagTrk));
268 printVec3(globTrk, glob);
273 std::cout <<
" ** " <<
res.error() <<
" **";
277 printVec2(
res.value(), loc);
284 std::cout << std::defaultfloat << std::setprecision(-1);
287 static std::tuple<Acts::Vector2, Amg::Vector2D, int, int>
288 localPositionStrip2D(
const Acts::GeometryContext &tgContext,
290 const Acts::Surface *surface,
293 auto *disc =
dynamic_cast<const Acts::DiscSurface *
>(surface);
310 if (
auto *annulus =
dynamic_cast<const Acts::AnnulusBounds *
>(&surface->bounds()))
312 loc[0] = 0.5 * (annulus->rMin() + annulus->rMax());
327 const int measInd = disc ? 1 : 0;
331 Amg::Vector2D locTrk{disc->localPolarToCartesian(loc).reverse()};
332 locTrk[0] = -locTrk[0];
333 return {loc, locTrk, measInd, est};
337 return {loc, loc, measInd, est};
343 const Acts::TrackingGeometry &tracking_geometry,
352 std::cout << std::setw(5) << (measurement->
index() +
offset) <<
' '
358 std::cout << std::setw(20 + 22 + 20 + 2) <<
"** no surface for measurement **";
362 std::cout << std::left;
364 << std::setw(22) <<
to_string(surface_ptr->geometryId()) <<
' ';
365 std::cout << std::setw(20) << atlasSurfaceName(surface_ptr);
366 std::cout << std::right;
371 const auto loc = measurement->
localPosition<2>().cast<double>();
379 printMeasurement(tgContext, surface_ptr,
380 localPositionStrip2D(tgContext, *measurement, surface_ptr,
nullptr),
386 for (
auto *sp : spvec)
392 << std::setw(76) <<
to_string(
"** Spacepoint ", isp,
" **")
395 printMeasurement(tgContext, surface_ptr,
396 localPositionStrip2D(tgContext, *measurement, surface_ptr, sp),
402 const auto loc3D = measurement->
localPosition<3>().cast<double>();
403 const std::tuple<Acts::Vector2, Amg::Vector2D, int, int> locTup = {Acts::Vector2{loc3D.head<2>()},
Amg::Vector2D{loc3D.head<2>()}, -1, -1};
410 const Acts::GeometryContext &tgContext,
411 const Acts::BoundVector &bound)
413 auto p = Acts::transformBoundToFreeParameters(surface, tgContext, bound);
414 std::cout << std::fixed
415 << std::setw(10) << std::setprecision(4) << bound[Acts::eBoundLoc0] <<
' '
416 << std::setw(10) << std::setprecision(4) << bound[Acts::eBoundLoc1] <<
' '
417 << std::setw(9) << std::setprecision(3) <<
p.segment<2>(Acts::eFreePos0).
norm() <<
' '
419 << std::setw(9) << std::setprecision(5) << std::atanh(
p[Acts::eFreePos2] /
p.segment<3>(Acts::eFreePos0).norm()) <<
' '
420 << std::setw(9) << std::setprecision(3) <<
p.segment<2>(Acts::eFreeDir0).
norm() /
p[Acts::eFreeQOverP] <<
' '
422 << std::setw(9) << std::setprecision(5) << std::atanh(
p[Acts::eFreeDir2])
423 << std::defaultfloat << std::setprecision(-1);
431 const std::string &
name,
446 return StatusCode::SUCCESS;
452 const Acts::BoundTrackParameters &initialParameters,
453 const std::vector<std::pair<const xAOD::UncalibratedMeasurementContainer *, size_t>> &
offset,
460 std::ostringstream
os;
462 for (
const auto *sp : seed.sp())
473 os <<
el->index() + containerOffset(
el->container(),
offset);
477 std::cout << std::setw(5) << iseed <<
' '
479 << std::setw(4) << (!isKF ?
"seed" :
"KF") <<
' '
480 << std::setw(21) <<
actsSurfaceName(initialParameters.referenceSurface()) <<
' '
483 printParameters(initialParameters.referenceSurface(), tgContext, initialParameters.parameters());
490 const std::vector<const xAOD::UncalibratedMeasurementContainer *> &clusterContainers,
492 const std::vector<size_t> &offsets)
const
494 const Acts::TrackingGeometry *
496 if (!acts_tracking_geometry) {
507 for (std::size_t icontainer = 0; icontainer < clusterContainers.size(); ++icontainer)
509 for (
const auto *measurement : *clusterContainers[icontainer])
512 *acts_tracking_geometry,
513 detectorElementToGeometryIdMap,
515 measToSp[icontainer],
516 offsets[icontainer]);
522 std::vector<std::vector<TrackStatePrinterTool::small_vector<const xAOD::SpacePoint *>>>
524 const std::vector<const xAOD::UncalibratedMeasurementContainer *> &clusterContainers,
525 const std::vector<size_t> &offsets)
const
527 std::vector<std::vector<TrackStatePrinterTool::small_vector<const xAOD::SpacePoint *>>> measToSp{clusterContainers.size()};
528 for (std::size_t icontainer = 0; icontainer < clusterContainers.size(); ++icontainer)
530 measToSp[icontainer].resize(clusterContainers[icontainer]->
size());
535 ATH_MSG_DEBUG(
"Retrieving from input SpacePoint collection '" << spacePointKey.key() <<
"' ...");
539 ATH_MSG_ERROR(
"Error retrieving from input SpacePoint collection '" << spacePointKey.key() <<
"'");
543 for (
const auto *sp : *handle)
549 for (std::size_t icontainer = 0; icontainer < clusterContainers.size(); ++icontainer)
552 if (!(meas && meas->index() < clusterContainers[icontainer]->size() && meas == clusterContainers[icontainer]->at(meas->index())))
558 << (meas->index() + offsets[icontainer])
559 <<
" used by SpacePoints at ("
562 << measSp[0]->globalPosition()[0] <<
',' << measSp[0]->globalPosition()[1] <<
',' << measSp[0]->globalPosition()[2]
565 measSp.push_back(sp);