DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
Hit.cpp
Go to the documentation of this file.
2
3#include <algorithm>
4
5namespace triggeralgs {
6namespace dbscan {
7
8//======================================================================
10{
11 hits.reserve(10);
12}
13
14//======================================================================
15void
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//======================================================================
36Hit::Hit(float _time, int _chan, const triggeralgs::TriggerPrimitive* _prim)
37{
38 reset(_time, _chan, _prim);
39}
40
41//======================================================================
42
43void
44Hit::reset(float _time, int _chan, const triggeralgs::TriggerPrimitive* _prim)
45{
46 time=_time;
47 chan=_chan;
51 if(_prim){
52 primitive=*_prim;
53 }
54}
55
56//======================================================================
57
58// Return true if hit was indeed a neighbour
59bool
60Hit::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) {
66 }
67 // Neighbourliness is symmetric
68 other->neighbours.insert(this);
69 if (other->neighbours.size() + 1 >= minPts) {
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:
void insert(Hit *h)
Definition Hit.cpp:16
std::vector< Hit * > hits
Definition Hit.hpp:69
size_t size() const
Definition Hit.hpp:67
const int kUndefined
Definition Hit.hpp:15
float euclidean_distance_sqr(const Hit &p, const Hit &q)
Definition Hit.hpp:113
A single energy deposition on a TPC or PDS channel.
bool add_potential_neighbour(Hit *other, float eps, int minPts)
Definition Hit.cpp:60
triggeralgs::TriggerPrimitive primitive
Definition Hit.hpp:86
Hit(float _time, int _chan, const triggeralgs::TriggerPrimitive *_prim=nullptr)
Definition Hit.cpp:36
void reset(float _time, int _chan, const triggeralgs::TriggerPrimitive *_prim=nullptr)
Definition Hit.cpp:44
Connectedness connectedness
Definition Hit.hpp:84