|
| 1 | +// Copyright 2019-2026 CERN and copyright holders of ALICE O2. |
| 2 | +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. |
| 3 | +// All rights not expressly granted are reserved. |
| 4 | +// |
| 5 | +// This software is distributed under the terms of the GNU General Public |
| 6 | +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". |
| 7 | +// |
| 8 | +// In applying this license CERN does not waive the privileges and immunities |
| 9 | +// granted to it by virtue of its status as an Intergovernmental Organization |
| 10 | +// or submit itself to any jurisdiction. |
| 11 | +/// |
| 12 | +/// \file Fishbone.h |
| 13 | +/// \brief Helpers and bookkeeping for fishbone tracklet cleaning. |
| 14 | +/// |
| 15 | + |
| 16 | +#ifndef TRACKINGITSU_INCLUDE_FISHBONE_H_ |
| 17 | +#define TRACKINGITSU_INCLUDE_FISHBONE_H_ |
| 18 | + |
| 19 | +#include "ITStracking/LayerMask.h" |
| 20 | +#include "ITStracking/Cluster.h" |
| 21 | +#include "ITStracking/MathUtils.h" |
| 22 | +#include "ITStracking/Constants.h" |
| 23 | + |
| 24 | +namespace o2::its |
| 25 | +{ |
| 26 | + |
| 27 | +struct Fishbone { |
| 28 | + |
| 29 | + GPUhdi() static bool isLinkEnabled(LayerMask mask, int fromLayer, int toLayer) |
| 30 | + { |
| 31 | + return mask.has(fromLayer) && mask.has(toLayer); |
| 32 | + } |
| 33 | + |
| 34 | + GPUhdi() static float openingAngle2(const Cluster& a, const Cluster& b, const Cluster& c, const Cluster& d) |
| 35 | + { |
| 36 | + const float ux = b.xCoordinate - a.xCoordinate; |
| 37 | + const float uy = b.yCoordinate - a.yCoordinate; |
| 38 | + const float uz = b.zCoordinate - a.zCoordinate; |
| 39 | + const float vx = d.xCoordinate - c.xCoordinate; |
| 40 | + const float vy = d.yCoordinate - c.yCoordinate; |
| 41 | + const float vz = d.zCoordinate - c.zCoordinate; |
| 42 | + const float uLenSq = math_utils::SqSum(ux, uy, uz); |
| 43 | + const float vLenSq = math_utils::SqSum(vx, vy, vz); |
| 44 | + if (uLenSq <= constants::Tolerance || vLenSq <= constants::Tolerance) { |
| 45 | + return 0.0f; |
| 46 | + } |
| 47 | + const float cx = (uy * vz) - (uz * vy); |
| 48 | + const float cy = (uz * vx) - (ux * vz); |
| 49 | + const float cz = (ux * vy) - (uy * vx); |
| 50 | + const float crossSq = math_utils::SqSum(cx, cy, cz); |
| 51 | + return crossSq / (uLenSq * vLenSq); |
| 52 | + } |
| 53 | + |
| 54 | + GPUhdi() static float openingAngle(const Cluster& a, const Cluster& b, const Cluster& c, const Cluster& d) |
| 55 | + { |
| 56 | + return o2::gpu::CAMath::Sqrt(openingAngle2(a, b, c, d)); |
| 57 | + } |
| 58 | + |
| 59 | + struct FishboneClusterLink { |
| 60 | + int fromLayer{constants::UnusedIndex}; |
| 61 | + int survivorFromClusterId{constants::UnusedIndex}; |
| 62 | + int toLayer{constants::UnusedIndex}; |
| 63 | + int survivorToClusterId{constants::UnusedIndex}; |
| 64 | + int killedFromClusterId{constants::UnusedIndex}; |
| 65 | + }; |
| 66 | + |
| 67 | + struct FishboneCandidate { |
| 68 | + int trackletIndex{constants::UnusedIndex}; |
| 69 | + int firstClusterIndex{constants::UnusedIndex}; |
| 70 | + int secondClusterIndex{constants::UnusedIndex}; |
| 71 | + float length2{0.f}; |
| 72 | + }; |
| 73 | + |
| 74 | + struct FishboneGroup { |
| 75 | + int begin{0}; |
| 76 | + int end{0}; |
| 77 | + }; |
| 78 | + |
| 79 | + struct FishboneCandidateOrder { |
| 80 | + GPUhdi() bool operator()(const FishboneCandidate& left, const FishboneCandidate& right) const |
| 81 | + { |
| 82 | + if (left.secondClusterIndex != right.secondClusterIndex) { |
| 83 | + return left.secondClusterIndex < right.secondClusterIndex; |
| 84 | + } |
| 85 | + if (left.length2 != right.length2) { |
| 86 | + return left.length2 > right.length2; |
| 87 | + } |
| 88 | + return left.firstClusterIndex < right.firstClusterIndex; |
| 89 | + } |
| 90 | + }; |
| 91 | + |
| 92 | + struct FishboneLinkOrder { |
| 93 | + GPUhdi() bool operator()(const FishboneClusterLink& left, const FishboneClusterLink& right) const |
| 94 | + { |
| 95 | + if (left.survivorFromClusterId != right.survivorFromClusterId) { |
| 96 | + return left.survivorFromClusterId < right.survivorFromClusterId; |
| 97 | + } |
| 98 | + return left.survivorToClusterId < right.survivorToClusterId; |
| 99 | + } |
| 100 | + }; |
| 101 | +}; |
| 102 | + |
| 103 | +} // namespace o2::its |
| 104 | + |
| 105 | +#endif |
0 commit comments