Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Clusterization.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file Clusterization.hpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2022 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
9 #pragma once
10 
11 #include <memory>
12 #include <vector>
13 
14 namespace Acts::Ccl {
15 
16 using Label = int;
17 constexpr Label NO_LABEL = 0;
18 
19 // When looking for a cell connected to a reference cluster, the code
20 // always loops backward, starting from the reference cell. Since
21 // the cells are globally sorted column-wise, the connection function
22 // can therefore tell when the search should be stopped.
23 enum class ConnectResult {
24  eNoConn, // No connections, keep looking
25  eNoConnStop, // No connections, stop looking
26  eConn // Found connection
27 };
28 
29 // Default connection type for 2-D grids: 4- or 8-cell connectivity
30 template <typename Cell>
31 struct Connect2D {
32  bool conn8;
33  Connect2D() : conn8{true} {}
34  explicit Connect2D(bool commonCorner) : conn8{commonCorner} {}
35  ConnectResult operator()(const Cell& ref, const Cell& iter) const;
36 };
37 
38 // Default connection type for 1-D grids: 2-cell connectivity
39 template <typename Cell>
40 struct Connect1D {
41  ConnectResult operator()(const Cell& ref, const Cell& iter) const;
42 };
43 
44 // Default connection type based on GridDim
45 template <typename Cell, size_t GridDim = 2>
47  static_assert(GridDim != 1 && GridDim != 2,
48  "Only grid dimensions of 1 or 2 are supported");
49 };
50 
51 template <typename Cell>
52 struct DefaultConnect<Cell, 2> : public Connect2D<Cell> {
53  explicit DefaultConnect(bool commonCorner) : Connect2D<Cell>(commonCorner) {}
55 };
56 
57 template <typename Cell>
58 struct DefaultConnect<Cell, 1> : public Connect1D<Cell> {};
59 
70 template <typename CellCollection, size_t GridDim = 2,
71  typename Connect =
73 void labelClusters(CellCollection& cells, Connect connect = Connect());
74 
83 template <typename CellCollection, typename ClusterCollection, size_t GridDim>
84 ClusterCollection mergeClusters(CellCollection& /*cells*/);
85 
88 template <typename CellCollection, typename ClusterCollection,
89  size_t GridDim = 2,
90  typename Connect =
92 ClusterCollection createClusters(CellCollection& cells,
93  Connect connect = Connect());
94 
95 } // namespace Acts::Ccl
96