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) << 
"Pos Z" << 
' ' 
  141                 << std::setw(9) << 
"phid" << 
' ' 
  142                 << std::setw(9) << 
"eta";
 
  146                   << std::setw(10) << 
"Trk loc0" << 
' ' 
  147                   << std::setw(10) << 
"loc1" 
  149                   << std::setw(9) << 
"Trk R" << 
' ' 
  150                   << std::setw(9) << 
"phid" << 
' ' 
  151                   << std::setw(9) << 
"eta" << 
' ' 
  152                   << std::setw(10) << 
"g2l loc0" << 
' ' 
  153                   << std::setw(10) << 
"loc1";
 
  156       static std::atomic<int> kilroy = 0;
 
  159         std::cout << 
"R (mm) and phi (degrees). Estimated local coordinate indicated by \"*\" (from SP), \"o\" (from module center), or \"#\" (globalToLocal(center) failure).";
 
  161           std::cout << 
" Athena/ACTS comparison only shown if different.";
 
  167       std::cout << std::setw(22) << 
"GeometryId/meas/stats" << 
' ' 
  169                 << std::setw(10) << 
"loc0" << 
' ' 
  170                 << std::setw(10) << 
"loc1" << 
' ' 
  171                 << std::setw(9) << 
"Pos R" << 
' ' 
  172         << std::setw(9) << 
"Pos Z" << 
' ' 
  173                 << std::setw(9) << 
"phid" << 
' ' 
  174                 << std::setw(9) << 
"eta" << 
' ' 
  175                 << std::setw(9) << 
"q*pT" << 
' ' 
  176                 << std::setw(9) << 
"phid" << 
' ' 
  177                 << std::setw(9) << 
"eta" << 
' ' 
  178                 << std::setw(6) << 
"TrkLen" << 
' ' 
  179                 << std::setw(7) << 
"chi2" << 
' ' 
  180                 << std::setw(6) << 
"Flags" << 
'\n';
 
  185   printVec3(
const Acts::Vector3 &
p)
 
  187     std::cout << std::fixed << 
' ' 
  188               << std::setw(9) << std::setprecision(3) << 
p.head<2>().
norm() << 
' ' 
  189           << std::setw(9) << std::setprecision(3) << 
p[2] << 
' ' 
  191               << std::setw(9) << std::setprecision(5) << std::atanh(
p[2] / 
p.norm())
 
  192               << std::defaultfloat << std::setprecision(-1);
 
  196   printVec3(
const Acts::Vector3 &
p, 
const Acts::Vector3 &
cmp, 
int precision = 3)
 
  204       std::cout << std::setw(30) << 
"";
 
  209   printVec2(
const Acts::Vector2 &
p, 
const char *estimated = 
nullptr)
 
  211     const char e0 = estimated ? estimated[0] : 
' ';
 
  212     const char *
e1 = estimated ? estimated + 1 : 
"";
 
  213     std::cout << std::fixed << 
' ' 
  214               << std::setw(10) << std::setprecision(4) << 
p[0] << 
e0 
  215               << std::setw(10) << std::setprecision(4) << 
p[1] << 
e1 
  216               << std::defaultfloat << std::setprecision(-1);
 
  220   printVec2(
const Acts::Vector2 &
p, 
const Acts::Vector2 &
cmp, 
const char *estimated = 
nullptr, 
int precision = 4)
 
  224       printVec2(
p, estimated);
 
  228       std::cout << std::setw(22 + (estimated ? 1 : 0)) << 
"";
 
  233   printMeasurement(
const Acts::GeometryContext &tgContext,
 
  234                    const Acts::Surface *surface,
 
  235                    const std::tuple<Acts::Vector2, Amg::Vector2D, int, int> &locData,
 
  236                    bool compareMeasurementTransforms = 
false)
 
  238     auto &[loc, locTrk, measInd, est] = locData;
 
  239     int flag = est < 0 ? est : 2 * est + measInd;
 
  240     int flagTrk = est < 0 ? est : 2 * est;
 
  242     static const std::map<int, const char *> estimated_flags{{-1, 
"  "},
 
  249     printVec2(loc, estimated_flags.at(
flag));
 
  257       if (compareMeasurementTransforms)
 
  260             acts_detector_element = 
dynamic_cast<const ActsDetectorElement *
>(surface->associatedDetectorElement());
 
  261         if (acts_detector_element) {
 
  266            printVec2(locTrk, (measInd == 1 ? loc.reverse() : loc), estimated_flags.at(flagTrk));
 
  271                  printVec3(globTrk, glob);
 
  276                        std::cout << 
" ** " << 
res.error() << 
" **";
 
  280                        printVec2(
res.value(), loc);
 
  287     std::cout << std::defaultfloat << std::setprecision(-1);
 
  290   static std::tuple<Acts::Vector2, Amg::Vector2D, int, int>
 
  291   localPositionStrip2D(
const Acts::GeometryContext &tgContext,
 
  293                        const Acts::Surface *surface,
 
  296     auto *disc = 
dynamic_cast<const Acts::DiscSurface *
>(surface);
 
  313         if (
auto *annulus = 
dynamic_cast<const Acts::AnnulusBounds *
>(&surface->bounds()))
 
  315           loc[0] = 0.5 * (annulus->rMin() + annulus->rMax());
 
  330     const int measInd = disc ? 1 : 0;
 
  334       Amg::Vector2D locTrk{disc->localPolarToCartesian(loc).reverse()};
 
  335       locTrk[0] = -locTrk[0];
 
  336       return {loc, locTrk, measInd, est};
 
  340       return {loc, loc, measInd, est};
 
  352     std::cout << std::setw(5) << (measurement->
index() + 
offset) << 
' ' 
  355     const Acts::Surface *surface_ptr = 
m_surfAcc.
get(measurement);
 
  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() << 
' ' 
  418               << std::setw(9) << std::setprecision(3) << 
p[Acts::eFreePos2] << 
' ' 
  420               << std::setw(9) << std::setprecision(5) << std::atanh(
p[Acts::eFreePos2] / 
p.segment<3>(Acts::eFreePos0).norm()) << 
' ' 
  421               << std::setw(9) << std::setprecision(3) << 
p.segment<2>(Acts::eFreeDir0).
norm() / 
p[Acts::eFreeQOverP] << 
' ' 
  423               << std::setw(9) << std::setprecision(5) << std::atanh(
p[Acts::eFreeDir2])
 
  424               << std::defaultfloat << std::setprecision(-1);
 
  441     return StatusCode::SUCCESS;
 
  447                    const Acts::BoundTrackParameters &initialParameters,
 
  455     std::ostringstream 
os;
 
  457     for (
const auto *sp : seed.sp())
 
  472     std::cout << std::setw(5) << iseed << 
' ' 
  474               << std::setw(4) << (!isKF ? 
"seed" : 
"KF") << 
' ' 
  475               << std::setw(21) << 
actsSurfaceName(initialParameters.referenceSurface()) << 
' ' 
  478     printParameters(initialParameters.referenceSurface(), tgContext, initialParameters.parameters());
 
  485                                            const std::vector<const xAOD::UncalibratedMeasurementContainer *> &clusterContainers,                      
 
  486                                            const std::vector<size_t> &offsets)
 const {
 
  495     for (std::size_t icontainer = 0; icontainer < clusterContainers.size(); ++icontainer)
 
  497       for (
const auto *measurement : *clusterContainers[icontainer])
 
  500                                               measToSp[icontainer], offsets[icontainer]);
 
  506   std::vector<std::vector<TrackStatePrinterTool::small_vector<const xAOD::SpacePoint *>>>
 
  508                     const std::vector<const xAOD::UncalibratedMeasurementContainer *> &clusterContainers,
 
  509                     const std::vector<size_t> &offsets)
 const 
  511     std::vector<std::vector<TrackStatePrinterTool::small_vector<const xAOD::SpacePoint *>>> measToSp{clusterContainers.size()};
 
  512     for (std::size_t icontainer = 0; icontainer < clusterContainers.size(); ++icontainer)
 
  514       measToSp[icontainer].resize(clusterContainers[icontainer]->
size());
 
  519       ATH_MSG_DEBUG(
"Retrieving from input SpacePoint collection '" << spacePointKey.key() << 
"' ...");
 
  523         ATH_MSG_ERROR(
"Error retrieving from input SpacePoint collection '" << spacePointKey.key() << 
"'");
 
  527       for (
const auto *sp : *handle)
 
  533           for (std::size_t icontainer = 0; icontainer < clusterContainers.size(); ++icontainer)
 
  536             if (!(meas && meas->index() < clusterContainers[icontainer]->size() && meas == clusterContainers[icontainer]->at(meas->index())))
 
  542                            << (meas->index() + offsets[icontainer])
 
  543                            << 
" used by SpacePoints at (" 
  546                            << measSp[0]->globalPosition()[0] << 
',' << measSp[0]->globalPosition()[1] << 
',' << measSp[0]->globalPosition()[2]
 
  549             measSp.push_back(sp);