3 using namespace sbnpca;
6 float costh = (A[0] * B[0] + A[1] * B[1]) \
7 / (sqrt(A[0]*A[0] + A[1] * A[1]) * sqrt(B[0]*B[0] + B[1] * B[1]));
16 float wire_distance_cm = wire_distance * geo->
WirePitch();
23 return {wire_distance_cm, time_distance_cm};
28 std::array<float, 2> vecA =
HitVector(A, geo, dprop);
29 std::array<float, 2> vecB =
HitVector(B, geo, dprop);
31 return {vecA[0] - vecB[0], vecA[1] - vecB[1]};
35 std::array<float, 2> vec =
HitVector(A, B, geo, dprop);
36 return sqrt(vec[0]*vec[0] + vec[1]*vec[1]);
43 std::vector<art::Ptr<recob::Hit>> retlo;
44 std::vector<art::Ptr<recob::Hit>> rethi;
46 bool lo_complete =
false;
48 for (
int j = ihit-1; j >= 0; j--) {
49 if (
HitDistance(*hits[j], *hits[ihit], geo, dprop) > distance) {
53 retlo.push_back(hits[j]);
56 bool hi_complete =
false;
58 for (
unsigned j = ihit+1; j < hits.size(); j++) {
63 rethi.push_back(hits[j]);
66 return {retlo, rethi, lo_complete && hi_complete};
78 if (hits.size() == 0)
return {-100., -100.};
86 if (hits.size() < 2)
return {-100., -100.};
88 std::array<float, 2> sum {};
89 for (
const art::Ptr<recob::Hit> &
h: hits) {
90 std::array<float, 2> vec =
HitVector(*
h, geo, dprop);
91 sum[0] += vec[0] - center[0];
92 sum[1] += vec[1] - center[1];
94 sum[0] = sum[0] / hits.size();
95 sum[1] = sum[1] / hits.size();
97 std::array<std::array<float, 2>, 2> scatter {};
98 for (
const art::Ptr<recob::Hit> &
h: hits) {
99 std::array<float, 2> vec =
HitVector(*
h, geo, dprop);
100 vec[0] -= sum[0] - center[0];
101 vec[1] -= sum[1] - center[1];
103 scatter[0][0] += vec[0] * vec[0];
104 scatter[0][1] += vec[0] * vec[1];
105 scatter[1][0] += vec[1] * vec[0];
106 scatter[1][1] += vec[1] * vec[1];
110 float trace = scatter[0][0] + scatter[1][1];
111 float det = scatter[0][0] * scatter[1][1] - scatter[0][1] * scatter[1][0];
114 float eigenP = (1. / 2.) * (trace + sqrt(trace*trace - 4 * det));
118 std::array<float, 2> ret {scatter[0][1], eigenP - scatter[0][0]};
122 if (sum[0] * ret[0] + sum[1] * ret[1] < 0.) {
134 std::array<float, 2> sum {};
135 for (
const art::Ptr<recob::Hit> &
h: hits) {
136 std::array<float, 2> vec =
HitVector(*
h, *center, geo, dprop);
140 sum[0] = sum[0] / hits.size();
141 sum[1] = sum[1] / hits.size();
143 std::array<std::array<float, 2>, 2> scatter {};
144 for (
const art::Ptr<recob::Hit> &
h: hits) {
145 std::array<float, 2> vec =
HitVector(*
h, *center, geo, dprop);
149 scatter[0][0] += vec[0] * vec[0];
150 scatter[0][1] += vec[0] * vec[1];
151 scatter[1][0] += vec[1] * vec[0];
152 scatter[1][1] += vec[1] * vec[1];
156 float trace = scatter[0][0] + scatter[1][1];
157 float det = scatter[0][0] * scatter[1][1] - scatter[0][1] * scatter[1][0];
159 float eigenP = (1. / 2.) * (trace + sqrt(trace*trace - 4 * det));
160 float eigenM = (1. / 2.) * (trace - sqrt(trace*trace - 4 * det));
162 return {eigenP, eigenM};
169 float vert_time_coord = vert.
position().X();
171 return {vert_wire_coord, vert_time_coord};
178 float vert_time_coord = vert.
position().X();
181 return sqrt((vert_wire_coord - hit_wire_coord) * (vert_wire_coord - hit_wire_coord) +
182 (vert_time_coord - hit_time_coord) * (vert_time_coord - hit_time_coord));
geo::Length_t WireCoordinate(double YPos, double ZPos, geo::PlaneID const &planeid) const
Returns the index of the nearest wire to the specified position.
float Vert2HitDistance(const recob::Hit &hit, const recob::Vertex &vert, const geo::GeometryCore *geo, const detinfo::DetectorPropertiesData &dprop)
std::array< float, 2 > HitPCAVec(const std::vector< art::Ptr< recob::Hit >> &hits, const recob::Hit ¢er, const geo::GeometryCore *geo, const detinfo::DetectorPropertiesData &dprop)
geo::WireID WireID() const
The data type to uniquely identify a Plane.
WireID_t Wire
Index of the wire within its plane.
Definition of vertex object for LArSoft.
geo::Length_t WirePitch(geo::PlaneID const &planeid) const
Returns the distance between two consecutive wires.
M::value_type trace(const M &m)
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
double distance(geo::Point_t const &point, CathodeDesc_t const &cathode)
Returns the distance of a point from the cathode.
IDparameter< geo::WireID > WireID
Member type of validated geo::WireID parameter.
std::tuple< std::vector< art::Ptr< recob::Hit > >, std::vector< art::Ptr< recob::Hit > >, bool > GetNearestHits(const std::vector< art::Ptr< recob::Hit >> &hits, int ihit, float distance, const geo::GeometryCore *geo, const detinfo::DetectorPropertiesData &dprop)
float VecAngle(std::array< float, 2 > A, std::array< float, 2 > B)
float HitDistance(const recob::Hit &A, const recob::Hit &B, const geo::GeometryCore *geo, const detinfo::DetectorPropertiesData &dprop)
Description of geometry of one entire detector.
double ConvertTicksToX(double ticks, int p, int t, int c) const
float PeakTime() const
Time of the signal peak, in tick units.
std::array< float, 2 > Vert2HitCoord(const recob::Vertex &vert, const geo::PlaneID &planeID, const geo::GeometryCore *geo, const detinfo::DetectorPropertiesData &dprop)
2D representation of charge deposited in the TDC/wire plane
const Point_t & position() const
Return vertex 3D position.
std::array< float, 2 > HitPCAEigen(const std::vector< art::Ptr< recob::Hit >> &hits, const art::Ptr< recob::Hit > ¢er, const geo::GeometryCore *geo, const detinfo::DetectorPropertiesData &dprop)
std::array< float, 2 > HitVector(const recob::Hit &A, const geo::GeometryCore *geo, const detinfo::DetectorPropertiesData &dprop)