LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
DBScan3DAlg.h
Go to the documentation of this file.
1 //
3 // The MIT License (MIT)
4 //
5 // Copyright (c) 2015 Gagarine Yaikhom
6 //
7 // Permission is hereby granted, free of charge, to any person obtaining a copy
8 // of this software and associated documentation files (the "Software"), to deal
9 // in the Software without restriction, including without limitation the rights
10 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 // copies of the Software, and to permit persons to whom the Software is
12 // furnished to do so, subject to the following conditions:
13 //
14 // The above copyright notice and this permission notice shall be included in all
15 // copies or substantial portions of the Software.
16 //
17 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 // SOFTWARE.
24 //
25 // https://github.com/gyaikhom/dbscan
26 //
27 // Modified by tjyang@fnal.gov
28 //
30 #ifndef DBSCAN3DALG_H
31 #define DBSCAN3DALG_H
32 
33 #define UNCLASSIFIED -1
34 #define NOISE -2
35 
36 #define CORE_POINT 1
37 #define NOT_CORE_POINT 0
38 
39 #define SUCCESS 0
40 #define FAILURE -3
41 
44 namespace fhicl {
45  class ParameterSet;
46 }
47 
48 #include <map>
49 #include <vector>
50 
52 
55 
56 typedef struct point_s point_t;
57 struct point_s {
59  unsigned int nbadchannels;
61 };
62 
63 typedef struct node_s node_t;
64 struct node_s {
65  unsigned int index;
67 };
68 
71  unsigned int num_members;
72  node_t *head, *tail;
73 };
74 
75 namespace cluster {
76 
77  //---------------------------------------------------------------
78  class DBScan3DAlg {
79  public:
80  DBScan3DAlg(fhicl::ParameterSet const& pset);
81 
82  std::vector<point_t> points;
83 
84  void init(const std::vector<art::Ptr<recob::SpacePoint>>& sps,
85  art::FindManyP<recob::Hit>& hitFromSp);
86  void dbscan();
87 
88  private:
89  double epsilon;
90  unsigned int minpts;
92  unsigned int neighbors;
93  std::map<geo::WireID, int> badchannelmap;
94 
95  node_t* create_node(unsigned int index);
96  int append_at_end(unsigned int index, epsilon_neighbours_t* en);
97  epsilon_neighbours_t* get_epsilon_neighbours(unsigned int index);
98  void destroy_epsilon_neighbours(epsilon_neighbours_t* en);
99  int expand(unsigned int index, unsigned int cluster_id);
100  int spread(unsigned int index, epsilon_neighbours_t* seeds, unsigned int cluster_id);
101  float dist(point_t* a, point_t* b) const;
102 
103  }; // class DBScan3DAlg
104 } // namespace
105 
106 #endif // ifndef DBSCAN3DALG_H
std::map< geo::WireID, int > badchannelmap
Definition: DBScan3DAlg.h:93
unsigned int minpts
Definition: DBScan3DAlg.h:90
art::Ptr< recob::SpacePoint > sp
Definition: DBScan3DAlg.h:58
unsigned int index
Definition: DBScan3DAlg.h:65
node_t * next
Definition: DBScan3DAlg.h:66
Declaration of signal hit object.
unsigned int num_members
Definition: DBScan3DAlg.h:71
Cluster finding and building.
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Definition: DumpUtils.h:289
int cluster_id
Definition: DBScan3DAlg.h:60
parameter set interface
Definition of data types for geometry description.
std::vector< TrajPoint > seeds
Definition: DataStructs.cxx:14
constexpr double dist(const TReal *x, const TReal *y, const unsigned int dimension)
unsigned int neighbors
Definition: DBScan3DAlg.h:92
std::vector< point_t > points
Definition: DBScan3DAlg.h:82
unsigned int nbadchannels
Definition: DBScan3DAlg.h:59