LArSoft  v07_13_02
Liquid Argon Software toolkit - http://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 
42 #include "fhiclcpp/ParameterSet.h"
46 #include <map>
47 
48 namespace recob {
49  class SpacePoint;
50  class Hit;
51 }
52 
53 typedef struct point_s point_t;
54 struct point_s {
56  unsigned int nbadchannels;
58 };
59 
60 typedef struct node_s node_t;
61 struct node_s {
62  unsigned int index;
64 };
65 
68  unsigned int num_members;
69  node_t *head, *tail;
70 };
71 
72 namespace cluster{
73 
74 //---------------------------------------------------------------
75 class DBScan3DAlg {
76  public:
77 
78 
79  DBScan3DAlg(fhicl::ParameterSet const& pset);
80  virtual ~DBScan3DAlg();
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 
90  double epsilon;
91  unsigned int minpts;
93  unsigned int neighbors;
94  std::map<geo::WireID, int> badchannelmap;
95 
96  node_t *create_node(unsigned int index);
97  int append_at_end(unsigned int index,
99  epsilon_neighbours_t *get_epsilon_neighbours(unsigned int index);
100  void destroy_epsilon_neighbours(epsilon_neighbours_t *en);
101  int expand(unsigned int index,
102  unsigned int cluster_id);
103  int spread(unsigned int index,
105  unsigned int cluster_id);
106  float dist(point_t *a, point_t *b);
107 
108 
109  }; // class DBScan3DAlg
110 } // namespace
111 
112 #endif // ifndef DBSCAN3DALG_H
std::map< geo::WireID, int > badchannelmap
Definition: DBScan3DAlg.h:94
unsigned int minpts
Definition: DBScan3DAlg.h:91
art::Ptr< recob::SpacePoint > sp
Definition: DBScan3DAlg.h:55
Reconstruction base classes.
unsigned int index
Definition: DBScan3DAlg.h:62
node_t * next
Definition: DBScan3DAlg.h:63
unsigned int num_members
Definition: DBScan3DAlg.h:68
Cluster finding and building.
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Definition: DumpUtils.h:265
int cluster_id
Definition: DBScan3DAlg.h:57
std::vector< TrajPoint > seeds
Definition: DataStructs.cxx:11
unsigned int neighbors
Definition: DBScan3DAlg.h:93
std::vector< point_t > points
Definition: DBScan3DAlg.h:82
unsigned int nbadchannels
Definition: DBScan3DAlg.h:56
art framework interface to geometry description