DUNE-DAQ
DUNE Trigger and Data Acquisition software
Toggle main menu visibility
Loading...
Searching...
No Matches
dunedaq
sourcecode
triggeralgs
src
dbscan
Hit.cpp
Go to the documentation of this file.
1
#include "
triggeralgs/dbscan/Hit.hpp
"
2
3
#include <algorithm>
4
5
namespace
triggeralgs
{
6
namespace
dbscan
{
7
8
//======================================================================
9
HitSet::HitSet
()
10
{
11
hits
.reserve(10);
12
}
13
14
//======================================================================
15
void
16
HitSet::insert
(
Hit
* h)
17
{
18
// We're typically inserting hits at or near the end, so do a
19
// linear scan instead of full binary search. This turns out to be much
20
// faster in our case
21
auto
it =
hits
.rbegin();
22
while
(it !=
hits
.rend() && (*it)->time >= h->
time
) {
23
// Don't insert the hit if we already have it
24
if
(*it == h) {
25
return
;
26
}
27
++it;
28
}
29
30
if
(it ==
hits
.rend() || *it != h) {
31
hits
.insert(it.base(), h);
32
}
33
}
34
35
//======================================================================
36
Hit::Hit
(
float
_time,
int
_chan,
const
triggeralgs::TriggerPrimitive
* _prim)
37
{
38
reset
(_time, _chan, _prim);
39
}
40
41
//======================================================================
42
43
void
44
Hit::reset
(
float
_time,
int
_chan,
const
triggeralgs::TriggerPrimitive
* _prim)
45
{
46
time
=_time;
47
chan
=_chan;
48
cluster
=
kUndefined
;
49
connectedness
=
Connectedness::kUndefined
;
50
neighbours
.clear();
51
if
(_prim){
52
primitive
=*_prim;
53
}
54
}
55
56
//======================================================================
57
58
// Return true if hit was indeed a neighbour
59
bool
60
Hit::add_potential_neighbour
(
Hit
* other,
float
eps,
int
minPts)
61
{
62
if
(other !=
this
&&
euclidean_distance_sqr
(*
this
, *other) < eps*eps) {
63
neighbours
.insert(other);
64
if
(
neighbours
.size() + 1 >= minPts) {
65
connectedness
=
Connectedness::kCore
;
66
}
67
// Neighbourliness is symmetric
68
other->
neighbours
.
insert
(
this
);
69
if
(other->
neighbours
.
size
() + 1 >= minPts) {
70
other->
connectedness
=
Connectedness::kCore
;
71
}
72
return
true
;
73
}
74
return
false
;
75
}
76
77
}
78
}
79
// Local Variables:
80
// mode: c++
81
// c-basic-offset: 4
82
// c-file-style: "linux"
83
// End:
Hit.hpp
triggeralgs::dbscan::HitSet::insert
void insert(Hit *h)
Definition
Hit.cpp:16
triggeralgs::dbscan::HitSet::hits
std::vector< Hit * > hits
Definition
Hit.hpp:69
triggeralgs::dbscan::HitSet::HitSet
HitSet()
Definition
Hit.cpp:9
triggeralgs::dbscan::HitSet::size
size_t size() const
Definition
Hit.hpp:67
triggeralgs::dbscan
Definition
dbscan.hpp:14
triggeralgs::dbscan::kUndefined
const int kUndefined
Definition
Hit.hpp:15
triggeralgs::dbscan::Connectedness::kUndefined
@ kUndefined
Definition
Hit.hpp:23
triggeralgs::dbscan::Connectedness::kCore
@ kCore
Definition
Hit.hpp:25
triggeralgs::dbscan::euclidean_distance_sqr
float euclidean_distance_sqr(const Hit &p, const Hit &q)
Definition
Hit.hpp:113
triggeralgs
Definition
AbstractFactory.hpp:18
triggeralgs::TriggerPrimitive
dunedaq::trgdataformats::TriggerPrimitive TriggerPrimitive
Definition
TriggerPrimitive.hpp:22
triggeralgs::dbscan::Hit
Definition
Hit.hpp:74
triggeralgs::dbscan::Hit::add_potential_neighbour
bool add_potential_neighbour(Hit *other, float eps, int minPts)
Definition
Hit.cpp:60
triggeralgs::dbscan::Hit::cluster
int cluster
Definition
Hit.hpp:83
triggeralgs::dbscan::Hit::neighbours
HitSet neighbours
Definition
Hit.hpp:85
triggeralgs::dbscan::Hit::primitive
triggeralgs::TriggerPrimitive primitive
Definition
Hit.hpp:86
triggeralgs::dbscan::Hit::time
float time
Definition
Hit.hpp:82
triggeralgs::dbscan::Hit::Hit
Hit(float _time, int _chan, const triggeralgs::TriggerPrimitive *_prim=nullptr)
Definition
Hit.cpp:36
triggeralgs::dbscan::Hit::reset
void reset(float _time, int _chan, const triggeralgs::TriggerPrimitive *_prim=nullptr)
Definition
Hit.cpp:44
triggeralgs::dbscan::Hit::connectedness
Connectedness connectedness
Definition
Hit.hpp:84
triggeralgs::dbscan::Hit::chan
int chan
Definition
Hit.hpp:83
Generated on
for DUNE-DAQ by
1.17.0