All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 
42 #include "canvas/Persistency/Common/Ptr.h"
43 #include "canvas/Persistency/Common/FindManyP.h"
44 namespace fhicl { class ParameterSet; }
45 
46 #include <map>
47 #include <vector>
48 
50 
53 
54 typedef struct point_s point_t;
55 struct point_s {
56  art::Ptr<recob::SpacePoint> sp;
57  unsigned int nbadchannels;
59 };
60 
61 typedef struct node_s node_t;
62 struct node_s {
63  unsigned int index;
65 };
66 
69  unsigned int num_members;
71 };
72 
73 namespace cluster{
74 
75 //---------------------------------------------------------------
76 class DBScan3DAlg {
77  public:
78 
79 
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 
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);
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) const;
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:56
process_name cluster
Definition: cheaterreco.fcl:51
unsigned int index
Definition: DBScan3DAlg.h:63
node_t * next
Definition: DBScan3DAlg.h:64
Declaration of signal hit object.
epsilon_neighbours_t * get_epsilon_neighbours(unsigned int index)
Definition: DBScan3DAlg.cxx:96
unsigned int num_members
Definition: DBScan3DAlg.h:69
process_name gaushit a
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Definition: DumpUtils.h:265
int cluster_id
Definition: DBScan3DAlg.h:58
void init(const std::vector< art::Ptr< recob::SpacePoint >> &sps, art::FindManyP< recob::Hit > &hitFromSp)
Definition: DBScan3DAlg.cxx:29
float dist(point_t *a, point_t *b) const
int expand(unsigned int index, unsigned int cluster_id)
Definition of data types for geometry description.
node_t * create_node(unsigned int index)
Definition: DBScan3DAlg.cxx:65
int append_at_end(unsigned int index, epsilon_neighbours_t *en)
Definition: DBScan3DAlg.cxx:77
std::vector< TrajPoint > seeds
Definition: DataStructs.cxx:14
DBScan3DAlg(fhicl::ParameterSet const &pset)
Definition: DBScan3DAlg.cxx:18
unsigned int neighbors
Definition: DBScan3DAlg.h:93
std::vector< point_t > points
Definition: DBScan3DAlg.h:82
int spread(unsigned int index, epsilon_neighbours_t *seeds, unsigned int cluster_id)
unsigned int nbadchannels
Definition: DBScan3DAlg.h:57
void destroy_epsilon_neighbours(epsilon_neighbours_t *en)