|
21 | 21 | #include <oneapi/tbb/blocked_range.h> |
22 | 22 | #include <oneapi/tbb/enumerable_thread_specific.h> |
23 | 23 |
|
| 24 | +#include "ITStracking/Definitions.h" |
| 25 | +#ifdef ITS_ALLOW_DEBUG_TREES |
| 26 | +#include "CommonUtils/TreeStreamRedirector.h" |
| 27 | +#endif |
24 | 28 | #include "DetectorsBase/Propagator.h" |
25 | 29 | #include "GPUCommonMath.h" |
26 | 30 | #include "ITStracking/BoundedAllocator.h" |
@@ -149,9 +153,19 @@ void TrackerTraits<NLayers>::computeLayerTracklets(const int iteration, int iVer |
149 | 153 | continue; |
150 | 154 | } |
151 | 155 | const float deltaZ = o2::gpu::CAMath::Abs((tanLambda * (nextCluster.radius - currentCluster.radius)) + currentCluster.zCoordinate - nextCluster.zCoordinate); |
| 156 | + const bool accepted = deltaZ / sigmaZ < mTrkParams[iteration].NSigmaCut && |
| 157 | + math_utils::isPhiDifferenceBelow(currentCluster.phi, nextCluster.phi, phiCut); |
| 158 | + |
| 159 | +#ifdef ITS_ALLOW_DEBUG_TREES |
| 160 | + if constexpr (decltype(Tag)::value == PassMode::OnePass::value) { |
| 161 | + if (mTimeFrame->isDebugFlag(DebugTrackletCandidates)) { |
| 162 | + dumpTrackletCandidate(iteration, transitionId, transition.fromLayer, transition.toLayer, pivotROF, targetROF, |
| 163 | + currentCluster, nextCluster, pv, sigmaZ, phiCut, deltaZ, accepted); |
| 164 | + } |
| 165 | + } |
| 166 | +#endif |
152 | 167 |
|
153 | | - if (deltaZ / sigmaZ < mTrkParams[iteration].NSigmaCut && |
154 | | - math_utils::isPhiDifferenceBelow(currentCluster.phi, nextCluster.phi, phiCut)) { |
| 168 | + if (accepted) { |
155 | 169 | const float phi{o2::gpu::CAMath::ATan2(currentCluster.yCoordinate - nextCluster.yCoordinate, currentCluster.xCoordinate - nextCluster.xCoordinate)}; |
156 | 170 | const float tanL = (currentCluster.zCoordinate - nextCluster.zCoordinate) / (currentCluster.radius - nextCluster.radius); |
157 | 171 | if constexpr (decltype(Tag)::value == PassMode::OnePass::value) { |
@@ -212,6 +226,14 @@ void TrackerTraits<NLayers>::computeLayerTracklets(const int iteration, int iVer |
212 | 226 | std::sort(trkl.begin(), trkl.end()); |
213 | 227 | trkl.erase(std::unique(trkl.begin(), trkl.end()), trkl.end()); |
214 | 228 | trkl.shrink_to_fit(); |
| 229 | +#ifdef ITS_ALLOW_DEBUG_TREES |
| 230 | + if (mTimeFrame->isDebugFlag(DebugTracklets)) { |
| 231 | + const auto& transition = topology.getTransition(transitionId); |
| 232 | + for (const auto& tkl : trkl) { |
| 233 | + dumpTracklet(iteration, transitionId, transition.fromLayer, transition.toLayer, tkl); |
| 234 | + } |
| 235 | + } |
| 236 | +#endif |
215 | 237 | auto& lut{mTimeFrame->getTrackletsLookupTable()[transitionId]}; |
216 | 238 | if (!trkl.empty()) { |
217 | 239 | for (const auto& tkl : trkl) { |
@@ -903,18 +925,129 @@ void TrackerTraits<NLayers>::setBz(float bz) |
903 | 925 | template <int NLayers> |
904 | 926 | void TrackerTraits<NLayers>::setNThreads(int n, std::shared_ptr<tbb::task_arena>& arena) |
905 | 927 | { |
906 | | -#if defined(OPTIMISATION_OUTPUT) |
907 | | - mTaskArena = std::make_shared<tbb::task_arena>(1); |
908 | | -#else |
| 928 | +#ifdef ITS_ALLOW_DEBUG_TREES |
| 929 | + if (mTimeFrame->getDebugFlags() != 0) { |
| 930 | + mTaskArena = std::make_shared<tbb::task_arena>(1); |
| 931 | + LOGP(info, "Forcing ITS tracker to 1 thread for debug tree output."); |
| 932 | + return; |
| 933 | + } |
| 934 | +#endif |
909 | 935 | if (arena == nullptr) { |
910 | 936 | mTaskArena = std::make_shared<tbb::task_arena>(std::abs(n)); |
911 | 937 | LOGP(info, "Setting tracker with {} threads.", n); |
912 | 938 | } else { |
913 | 939 | mTaskArena = arena; |
914 | 940 | } |
915 | | -#endif |
916 | 941 | } |
917 | 942 |
|
| 943 | +#ifdef ITS_ALLOW_DEBUG_TREES |
| 944 | +template <int NLayers> |
| 945 | +void TrackerTraits<NLayers>::dumpTracklet(int iteration, int transitionId, int fromLayer, int toLayer, const Tracklet& tracklet) |
| 946 | +{ |
| 947 | + auto* dbgOut = mTimeFrame->getDBGOut(); |
| 948 | + if (dbgOut == nullptr || !mTimeFrame->isDebugFlag(DebugTracklets)) { |
| 949 | + return; |
| 950 | + } |
| 951 | + |
| 952 | + static LogLogThrottler logger; |
| 953 | + if (logger.needToLog(iteration, transitionId)) { |
| 954 | + LOGP(info, "debugTree: LayerTracklets:{}:{} dumped entries {}", iteration, transitionId, logger.evCount); |
| 955 | + } |
| 956 | + |
| 957 | + MCCompLabel label; |
| 958 | + if (mTimeFrame->hasMCinformation()) { |
| 959 | + const int currentId = mTimeFrame->getClusters()[fromLayer][tracklet.firstClusterIndex].clusterId; |
| 960 | + const int nextId = mTimeFrame->getClusters()[toLayer][tracklet.secondClusterIndex].clusterId; |
| 961 | + for (const auto& lab1 : mTimeFrame->getClusterLabels(fromLayer, currentId)) { |
| 962 | + for (const auto& lab2 : mTimeFrame->getClusterLabels(toLayer, nextId)) { |
| 963 | + if (lab1 == lab2 && lab1.isValid()) { |
| 964 | + label = lab1; |
| 965 | + break; |
| 966 | + } |
| 967 | + } |
| 968 | + if (label.isValid()) { |
| 969 | + break; |
| 970 | + } |
| 971 | + } |
| 972 | + } |
| 973 | + |
| 974 | + const float tglTracklet = tracklet.tanLambda; |
| 975 | + const float etaTracklet = std::asinh(tglTracklet); |
| 976 | + const bool accepted = true; |
| 977 | + |
| 978 | + (*dbgOut) << "tracklets" |
| 979 | + << "iter=" << iteration |
| 980 | + << "transition=" << transitionId |
| 981 | + << "fromLayer=" << fromLayer |
| 982 | + << "toLayer=" << toLayer |
| 983 | + << "lbl=" << label |
| 984 | + << "tglTracklet=" << tglTracklet |
| 985 | + << "etaTracklet=" << etaTracklet |
| 986 | + << "acc=" << accepted |
| 987 | + << "\n"; |
| 988 | +} |
| 989 | + |
| 990 | +template <int NLayers> |
| 991 | +void TrackerTraits<NLayers>::dumpTrackletCandidate(int iteration, int transitionId, int fromLayer, int toLayer, int pivotROF, int targetROF, |
| 992 | + const Cluster& currentCluster, const Cluster& nextCluster, const Vertex& pv, |
| 993 | + float sigmaZ, float phiCut, float deltaZ, bool accepted) |
| 994 | +{ |
| 995 | + auto* dbgOut = mTimeFrame->getDBGOut(); |
| 996 | + if (dbgOut == nullptr || !mTimeFrame->isDebugFlag(DebugTrackletCandidates)) { |
| 997 | + return; |
| 998 | + } |
| 999 | + |
| 1000 | + static LogLogThrottler logger; |
| 1001 | + if (logger.needToLog(iteration, transitionId)) { |
| 1002 | + LOGP(info, "debugTree: LayerTrackletCandidates:{}:{} dumped entries {}", iteration, transitionId, logger.evCount); |
| 1003 | + } |
| 1004 | + |
| 1005 | + MCCompLabel label; |
| 1006 | + if (mTimeFrame->hasMCinformation()) { |
| 1007 | + const int currentId = currentCluster.clusterId; |
| 1008 | + const int nextId = nextCluster.clusterId; |
| 1009 | + for (const auto& lab1 : mTimeFrame->getClusterLabels(fromLayer, currentId)) { |
| 1010 | + for (const auto& lab2 : mTimeFrame->getClusterLabels(toLayer, nextId)) { |
| 1011 | + if (lab1 == lab2 && lab1.isValid()) { |
| 1012 | + label = lab1; |
| 1013 | + break; |
| 1014 | + } |
| 1015 | + } |
| 1016 | + if (label.isValid()) { |
| 1017 | + break; |
| 1018 | + } |
| 1019 | + } |
| 1020 | + } |
| 1021 | + |
| 1022 | + const float tglTracklet = (currentCluster.zCoordinate - nextCluster.zCoordinate) / (currentCluster.radius - nextCluster.radius); |
| 1023 | + const float etaTracklet = std::asinh(tglTracklet); |
| 1024 | + const float deltaPhiRaw = o2::gpu::CAMath::Abs(currentCluster.phi - nextCluster.phi); |
| 1025 | + const float deltaPhi = o2::gpu::CAMath::Min(deltaPhiRaw, o2::gpu::CAMath::Abs(deltaPhiRaw - o2::constants::math::TwoPI)); |
| 1026 | + const float zTrackletAtPvR = currentCluster.zCoordinate + tglTracklet * (pv.getR() - currentCluster.radius); |
| 1027 | + const float deltaZTrackletPv = zTrackletAtPvR - pv.getZ(); |
| 1028 | + |
| 1029 | + (*dbgOut) << "trackletCandidates" |
| 1030 | + << "iter=" << iteration |
| 1031 | + << "transition=" << transitionId |
| 1032 | + << "fromLayer=" << fromLayer |
| 1033 | + << "toLayer=" << toLayer |
| 1034 | + << "pivotROF=" << pivotROF |
| 1035 | + << "targetROF=" << targetROF |
| 1036 | + << "lbl=" << label |
| 1037 | + << "pvZ=" << pv.getZ() |
| 1038 | + << "sigZ=" << sigmaZ |
| 1039 | + << "delZ=" << deltaZ |
| 1040 | + << "sigPhi=" << phiCut |
| 1041 | + << "delPhi=" << deltaPhi |
| 1042 | + << "tglTracklet=" << tglTracklet |
| 1043 | + << "etaTracklet=" << etaTracklet |
| 1044 | + << "zTrackletAtPvR=" << zTrackletAtPvR |
| 1045 | + << "deltaZTrackletPv=" << deltaZTrackletPv |
| 1046 | + << "acc=" << accepted |
| 1047 | + << "\n"; |
| 1048 | +} |
| 1049 | +#endif |
| 1050 | + |
918 | 1051 | template class TrackerTraits<7>; |
919 | 1052 | template void TrackerTraits<7>::processNeighbours<CellSeed>(int, int, int, const bounded_vector<CellSeed>&, const bounded_vector<int>&, const bounded_vector<int>&, bounded_vector<TrackSeed<7>>&, bounded_vector<int>&, bounded_vector<int>&); |
920 | 1053 | template void TrackerTraits<7>::processNeighbours<TrackSeed<7>>(int, int, int, const bounded_vector<TrackSeed<7>>&, const bounded_vector<int>&, const bounded_vector<int>&, bounded_vector<TrackSeed<7>>&, bounded_vector<int>&, bounded_vector<int>&); |
|
0 commit comments