10 #include "art/Framework/Services/Registry/ServiceHandle.h"
11 #include "cetlib/pow.h"
12 #include "fhiclcpp/ParameterSet.h"
19 : epsilon(pset.
get< float >(
"epsilon"))
20 , minpts(pset.
get<unsigned int>(
"minpts"))
21 , badchannelweight(pset.
get<double>(
"badchannelweight"))
22 , neighbors(pset.
get<unsigned int>(
"neighbors"))
32 if (badchannelmap.empty()){
38 unsigned int nbadchs = 0;
40 if (wid1==wid2)
continue;
44 badchannelmap[wid1] = nbadchs;
47 std::cout<<
"Done building bad channel map."<<std::endl;
51 for (
auto& spt : sps){
57 auto &hits = hitFromSp.at(spt.key());
58 for (
auto &
hit : hits){
61 points.push_back(point);
69 perror(
"Failed to allocate node.");
85 if (en->
head == NULL) {
101 perror(
"Failed to allocate epsilon neighbours.");
104 for (
unsigned int i = 0; i < points.size(); ++i) {
107 if (
dist(&points[index], &points[i]) > epsilon)
110 if (append_at_end(i, en) ==
FAILURE) {
111 destroy_epsilon_neighbours(en);
135 unsigned int i, cluster_id = 0;
136 for (i = 0; i < points.size(); ++i) {
145 unsigned int cluster_id)
149 get_epsilon_neighbours(index);
154 points[index].cluster_id =
NOISE;
156 points[index].cluster_id = cluster_id;
159 points[h->
index].cluster_id = cluster_id;
165 spread(h->
index, seeds, cluster_id);
171 destroy_epsilon_neighbours(seeds);
177 unsigned int cluster_id)
180 get_epsilon_neighbours(index);
187 d = &points[n->
index];
191 if (append_at_end(n->
index, seeds)
193 destroy_epsilon_neighbours(spread);
203 destroy_epsilon_neighbours(spread);
209 Double32_t
const* a_xyz = a->
sp->XYZ();
210 Double32_t
const* b_xyz = b->
sp->XYZ();
212 float const dx = a_xyz[0] - b_xyz[0];
213 float const dy = a_xyz[1] - b_xyz[1];
214 float const dz = a_xyz[2] - b_xyz[2];
215 float const dist = cet::sum_of_squares(dx, dy, dz) - cet::square(nbadchannels * badchannelweight);
217 return std::max(dist, 0.f);
Functions to help with numbers.
art::Ptr< recob::SpacePoint > sp
Declaration of signal hit object.
epsilon_neighbours_t * get_epsilon_neighbours(unsigned int index)
IteratorBox< plane_id_iterator,&GeometryCore::begin_plane_id,&GeometryCore::end_plane_id > IteratePlaneIDs() const
Enables ranged-for loops on all plane IDs of the detector.
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Access the description of detector geometry.
IteratorBox< wire_id_iterator,&GeometryCore::begin_wire_id,&GeometryCore::end_wire_id > IterateWireIDs() const
Enables ranged-for loops on all wire IDs of the detector.
void init(const std::vector< art::Ptr< recob::SpacePoint >> &sps, art::FindManyP< recob::Hit > &hitFromSp)
float dist(point_t *a, point_t *b) const
virtual bool IsGood(raw::ChannelID_t channel) const
Returns whether the specified channel is physical and good.
int expand(unsigned int index, unsigned int cluster_id)
Class providing information about the quality of channels.
Description of geometry of one entire detector.
constexpr auto absDiff(A const &a, B const &b)
Returns the absolute value of the difference between two values.
node_t * create_node(unsigned int index)
int append_at_end(unsigned int index, epsilon_neighbours_t *en)
std::vector< TrajPoint > seeds
raw::ChannelID_t PlaneWireToChannel(WireID const &wireid) const
Returns the ID of the TPC channel connected to the specified wire.
DBScan3DAlg(fhicl::ParameterSet const &pset)
constexpr double dist(const TReal *x, const TReal *y, const unsigned int dimension)
Interface for experiment-specific channel quality info provider.
int spread(unsigned int index, epsilon_neighbours_t *seeds, unsigned int cluster_id)
Interface for experiment-specific service for channel quality info.
unsigned int nbadchannels
art framework interface to geometry description
BEGIN_PROLOG could also be cout
void destroy_epsilon_neighbours(epsilon_neighbours_t *en)