DBScan3DAlg.h
Go to the documentation of this file.
1 /////////////////////////////////////////////////////////////////
2 //
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 //
29 ////////////////////////////////////////////////////////////////////
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 
43 #include "canvas/Persistency/Common/FindManyP.h"
44 namespace fhicl { class ParameterSet; }
45 
46 #include <map>
47 
49 
50 namespace recob {
51  class SpacePoint;
52  class Hit;
53 }
54 
55 typedef struct point_s point_t;
56 struct point_s {
58  unsigned int nbadchannels;
60 };
61 
62 typedef struct node_s node_t;
63 struct node_s {
64  unsigned int index;
66 };
67 
70  unsigned int num_members;
71  node_t *head, *tail;
72 };
73 
74 namespace cluster{
75 
76 //---------------------------------------------------------------
77 class DBScan3DAlg {
78  public:
79 
80 
81  DBScan3DAlg(fhicl::ParameterSet const& pset);
82 
83  std::vector<point_t> points;
84 
86  art::FindManyP<recob::Hit>& hitFromSp);
87  void dbscan();
88 
89  private:
90 
91  double epsilon;
92  unsigned int minpts;
94  unsigned int neighbors;
95  std::map<geo::WireID, int> badchannelmap;
96 
97  node_t *create_node(unsigned int index);
98  int append_at_end(unsigned int index,
100  epsilon_neighbours_t *get_epsilon_neighbours(unsigned int index);
101  void destroy_epsilon_neighbours(epsilon_neighbours_t *en);
102  int expand(unsigned int index,
103  unsigned int cluster_id);
104  int spread(unsigned int index,
106  unsigned int cluster_id);
107  float dist(point_t *a, point_t *b) const;
108 
109 
110  }; // class DBScan3DAlg
111 } // namespace
112 
113 #endif // ifndef DBSCAN3DALG_H
std::map< geo::WireID, int > badchannelmap
Definition: DBScan3DAlg.h:95
unsigned int minpts
Definition: DBScan3DAlg.h:92
art::Ptr< recob::SpacePoint > sp
Definition: DBScan3DAlg.h:57
Reconstruction base classes.
unsigned int index
Definition: DBScan3DAlg.h:64
node_t * next
Definition: DBScan3DAlg.h:65
struct vector vector
unsigned int num_members
Definition: DBScan3DAlg.h:70
Cluster finding and building.
init
Definition: train.py:42
int cluster_id
Definition: DBScan3DAlg.h:59
const double a
Definition of data types for geometry description.
std::vector< TrajPoint > seeds
Definition: DataStructs.cxx:13
constexpr double dist(const TReal *x, const TReal *y, const unsigned int dimension)
static bool * b
Definition: config.cpp:1043
unsigned int neighbors
Definition: DBScan3DAlg.h:94
std::vector< point_t > points
Definition: DBScan3DAlg.h:83
unsigned int nbadchannels
Definition: DBScan3DAlg.h:58