18 std::uint8_t stationBit) {
19 if (stationBit == 0x1U) {
23 if (stationBit == 0x2U) {
31std::size_t countBits(std::uint8_t value) {
53 const std::uint8_t commonMask =
static_cast<std::uint8_t
>(
54 first.positionStationMask &
second.positionStationMask);
55 if (countBits(commonMask) <
config.minCommonStations)
return false;
57 bool differentChamber{
false};
58 for (
const std::uint8_t stationBit : {0x1U, 0x2U, 0x4U}) {
59 if ((commonMask & stationBit) != 0U &&
60 !sameChamber(first, second, stationBit)) {
61 differentChamber =
true;
65 return differentChamber;
70 explicit DisjointSet(std::size_t
size) : m_parent(
size), m_size(
size, 1U) {
71 std::iota(m_parent.begin(), m_parent.end(), 0U);
74 std::size_t
find(std::size_t value) {
75 if (m_parent[value] != value) m_parent[
value] =
find(m_parent[value]);
76 return m_parent[
value];
79 void join(std::size_t first, std::size_t second) {
82 if (first == second)
return;
83 if (m_size[first] < m_size[second])
std::swap(first, second);
89 std::vector<std::size_t> m_parent;
90 std::vector<std::size_t> m_size;
105 candidate.overlapGroupId = 0U;
106 candidate.overlapMultiplicity = 1U;
107 candidate.inChamberOverlap =
false;
109 if (candidates.size() < 2U)
return;
111 DisjointSet groups(candidates.size());
112 for (std::size_t first = 0U; first < candidates.size(); ++first) {
113 for (std::size_t second = first + 1U; second < candidates.size(); ++second) {
114 if (isOverlapPair(candidates[first], candidates[second],
m_config)) {
115 groups.join(first, second);
120 std::vector<std::size_t> roots(candidates.size());
121 std::vector<std::size_t> multiplicities(candidates.size(), 0U);
124 ++multiplicities[roots[
index]];
127 std::vector<std::uint16_t> groupIds(candidates.size(), 0U);
128 std::uint16_t nextGroupId{1U};
130 const std::size_t root = roots[
index];
131 if (multiplicities[root] < 2U)
continue;
132 if (groupIds[root] == 0U) {
133 groupIds[root] = nextGroupId++;
141 std::min<std::size_t>(multiplicities[root], 0xffU));
size_t size() const
Number of registered mappings.
FloatingOverlapClassificationConfig m_config
FloatingOverlapClassification(FloatingOverlapClassificationConfig config=FloatingOverlapClassificationConfig{})
void classify(TgcSLCandidateContainer &candidates, FloatingOverlapClassificationStatistics &statistics) const
std::string find(const std::string &s)
return a remapped string
int count(std::string s, const std::string ®x)
count how many occurances of a regx are in a string
std::vector< TgcSLCandidate > TgcSLCandidateContainer
Event-local candidate collection.
std::string join(const std::vector< std::string > &v, const char c=',')
void swap(ElementLinkVector< DOBJ > &lhs, ElementLinkVector< DOBJ > &rhs)
double deltaPhi(double phiA, double phiB)
delta Phi in range [-pi,pi[
std::size_t maxMultiplicity
Event-local candidate used by the TGC simulation tools.
std::uint8_t overlapMultiplicity
Number of candidates in the classified overlap group.
bool inChamberOverlap
True when the candidate has a nearby partner from a different chamber path.
std::uint16_t overlapGroupId
Event-local overlap group. Zero means no classified overlap partner.