LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
DBScanAlg.h
Go to the documentation of this file.
1 // \fileDBScanAlg.h
3 // kinga.partyka@yale.edu
5 #ifndef DBSCANALG_H
6 #define DBSCANALG_H
7 
8 #include <vector>
9 #include <cmath>
10 #include <iostream>
11 #include <stdint.h>
12 
13 #include "fhiclcpp/ParameterSet.h"
18 
19 class TH1F;
20 
21 namespace recob { class Hit; }
22 
23 // RStarTree related infrastructure
24 //
25 // Our core objects have a physical extent (I.e. there are not
26 // points), but a R*-tree should be able to deal with that.
27 class dbsPoint; // forward declaration
28 typedef RStarTree< uint32_t, 2, 32, 64 > RTree; // payload is just an index
30 
31 namespace cluster{
32 
33  //---------------------------------------------------------------
34  class DBScanAlg {
35  public:
36 
37 
38  DBScanAlg(fhicl::ParameterSet const& pset);
39  virtual ~DBScanAlg();
40 
41  void reconfigure(fhicl::ParameterSet const& p);
42  void InitScan(const std::vector< art::Ptr<recob::Hit> >& allhits,
43  std::set<uint32_t> badChannels,
44  const std::vector<geo::WireID> & wireids = std::vector< geo::WireID>()); //wireids is optional
45  double getSimilarity(const std::vector<double> v1,
46  const std::vector<double> v2);
47  std::vector<unsigned int> findNeighbors( unsigned int pid,
48  double threshold,
49  double threshold2);
50  void computeSimilarity();
51  void run_cluster();
52  double getSimilarity2(const std::vector<double> v1,
53  const std::vector<double> v2);
54  void computeSimilarity2();
55  double getWidthFactor(const std::vector<double> v1,
56  const std::vector<double> v2);
57  void computeWidthFactor();
58 
59 
60  std::vector<std::vector<unsigned int> > fclusters;
61  std::vector<std::vector<double> > fps;
62  std::vector<unsigned int> fpointId_to_clusterId;
63  std::vector<std::vector<double> > fsim;
64  std::vector<std::vector<double> > fsim2;
65  std::vector<std::vector<double> > fsim3;
66  double fMaxWidth;
67 
69  std::vector< dbsPoint > fRect;
70 
71  private:
72 
73  // eps radius
74  // Two points are neighbors if the distance
75  // between them does not exceed threshold value.
76  double fEps;
77  double fEps2;
78  //minimum number of points
79  unsigned int fMinPts;
80  // Which clustering to run
81  unsigned int fClusterMethod;
82  unsigned int fDistanceMetric;
83 
84  // noise vector
85  std::vector<bool> fnoise;
86  std::vector<bool> fvisited;
87  std::vector<double> fWirePitch;
88  std::set<uint32_t> fBadChannels;
89  std::vector<uint32_t> fBadWireSum;
90 
92  // Three differnt version of the clustering code
93  void run_dbscan_cluster();
94  void run_FN_cluster();
95  void run_FN_naive_cluster();
96 
97  // Helper routined for run_dbscan_cluster() names and
98  // responsibilities taken directly from the paper
99  bool ExpandCluster(unsigned int point /* to be added */,
100  unsigned int clusterID /* which is being expanded */);
101  std::set<unsigned int> RegionQuery(unsigned int point);
102  // Helper for the accelerated run_FN_cluster()
103  std::vector<unsigned int> RegionQuery_vector(unsigned int point);
104 
105 
106  }; // class DBScanAlg
107 } // namespace
108 
109 #endif // ifndef DBSCANALG_H
Reconstruction base classes.
std::vector< uint32_t > fBadWireSum
Definition: DBScanAlg.h:89
Implementation of an RTree with an R* index.
Definition: RStarTree.h:87
std::vector< std::vector< double > > fps
the collection of points we are working on
Definition: DBScanAlg.h:61
Cluster finding and building.
std::vector< std::vector< double > > fsim3
Definition: DBScanAlg.h:65
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Definition: DumpUtils.h:265
std::vector< unsigned int > fpointId_to_clusterId
mapping point_id -> clusterId
Definition: DBScanAlg.h:62
RTree::BoundingBox BoundingBox
Definition: DBScanAlg.h:29
std::vector< std::vector< double > > fsim
Definition: DBScanAlg.h:63
unsigned int fClusterMethod
Which clustering method to use.
Definition: DBScanAlg.h:81
std::vector< bool > fvisited
Definition: DBScanAlg.h:86
std::vector< dbsPoint > fRect
Definition: DBScanAlg.h:69
std::vector< double > fWirePitch
the pitch of the wires in each plane
Definition: DBScanAlg.h:87
unsigned int fMinPts
Definition: DBScanAlg.h:79
std::vector< std::vector< unsigned int > > fclusters
collection of something
Definition: DBScanAlg.h:60
RStarTree< uint32_t, 2, 32, 64 > RTree
Definition: DBScanAlg.h:27
std::set< uint32_t > fBadChannels
set of bad channels in this detector
Definition: DBScanAlg.h:88
std::vector< std::vector< double > > fsim2
Definition: DBScanAlg.h:64
art framework interface to geometry description
std::vector< bool > fnoise
Definition: DBScanAlg.h:85
unsigned int fDistanceMetric
Which distance metric to use.
Definition: DBScanAlg.h:82