13 #include "Math/GenVector/DisplacementVector2D.h" 49 unsigned int view = h->View2D();
51 sum +=
OptFactor(view) * h->GetSigmaFactor()
82 TVector3 v3dStart(vStart->
Point3D());
83 TVector3 v3dStop(vStop->
Point3D());
85 double v0Norm = v0.Mod();
86 double v1Norm = v1.Mod();
88 TVector3 result(0, 0, 0);
91 double mag = v0Norm * v1Norm;
93 if (mag != 0.0) cosine = v0 * v1 / mag;
94 double b = v0Norm * cosine / v1Norm;
98 if (b > 0.0) result += (v3d * b);
125 TVector3 v3d(vStop->
Point3D());
128 double v0Norm = v0.Mod();
129 double v1Norm = v1.Mod();
132 double mag = v0Norm * v1Norm;
134 if (mag != 0.0) cosine = v0 * v1 / mag;
135 double b = v0Norm * cosine / v1Norm;
137 return vStart->
Point3D() + (v3d * b);
154 auto const& pointStart = vStart->
Point3D();
155 auto const& pointStop = vStop->
Point3D();
162 pma::Vector2D v1(projStop.X() - projStart.X(), projStop.Y() - projStart.Y());
165 pointStop.X() - pointStart.X(), pointStop.Y() - pointStart.Y(), pointStop.Z() - pointStart.Z());
167 double v0Norm = sqrt(v0.Mag2());
168 double v1Norm = sqrt(v1.Mag2());
171 double mag = v0Norm * v1Norm;
173 if (mag != 0.0) cosine = v0.Dot(v1) / mag;
174 double b = v0Norm * cosine / v1Norm;
181 h.
SetPoint3D(pointStart.X() + v3d.X(), pointStart.Y() + v3d.Y(), pointStart.Z() + v3d.Z());
186 0.5 * (projStart.X() + projStop.X()), 0.5 * (projStart.Y() + projStop.Y()), 0.0F);
188 h.
SetPoint3D(0.5 * (pointStart.X() + pointStop.X()),
189 0.5 * (pointStart.Y() + pointStop.Y()),
190 0.5 * (pointStart.Z() + pointStop.Z()));
199 mf::LogError(
"pma::Segment3D") <<
"Segment endpoints not set.";
206 pma::Vector3D v0(psrc.X() - p0.X(), psrc.Y() - p0.Y(), psrc.Z() - p0.Z());
207 pma::Vector3D v1(p1.X() - p0.X(), p1.Y() - p0.Y(), p1.Z() - p0.Z());
208 pma::Vector3D v2(psrc.X() - p1.X(), psrc.Y() - p1.Y(), psrc.Z() - p1.Z());
210 double v1Norm2 = v1.Mag2();
211 if (v1Norm2 >= 1.0
E-6)
213 double v0v1 = v0.Dot(v1);
214 double v2v1 = v2.Dot(v1);
215 double v0Norm2 = v0.Mag2();
216 double v2Norm2 = v2.Mag2();
219 if ((v0v1 > 0.0) && (v2v1 < 0.0)) {
220 double cosine01_square = 0.0;
221 double mag01_square = v0Norm2 * v1Norm2;
222 if (mag01_square != 0.0) cosine01_square = v0v1 * v0v1 / mag01_square;
224 result = (1.0 - cosine01_square) * v0Norm2;
229 result = 1.0001 * v0Norm2;
231 result = 1.0001 * v2Norm2;
241 double dx = 0.5 * (p0.X() + p1.X()) - psrc.X();
242 double dy = 0.5 * (p0.Y() + p1.Y()) - psrc.Y();
243 double dz = 0.5 * (p0.Z() + p1.Z()) - psrc.Z();
244 return dx * dx + dy * dy + dz * dz;
254 double v1Norm2 = v1.Mag2();
255 if (v1Norm2 >= 1.0
E-6)
257 double v0v1 = v0.Dot(v1);
258 double v2v1 = v2.Dot(v1);
259 double v0Norm2 = v0.Mag2();
260 double v2Norm2 = v2.Mag2();
263 if ((v0v1 > 0.0) && (v2v1 < 0.0)) {
264 double cosine01_square = 0.0;
265 double mag01_square = v0Norm2 * v1Norm2;
266 if (mag01_square != 0.0) cosine01_square = v0v1 * v0v1 / mag01_square;
268 result = (1.0 - cosine01_square) * v0Norm2;
273 result = 1.0001 * v0Norm2;
275 result = 1.0001 * v2Norm2;
284 double dx = 0.5 * (p0.X() + p1.X()) - psrc.X();
285 double dy = 0.5 * (p0.Y() + p1.Y()) - psrc.Y();
286 return dx * dx + dy * dy;
TVector3 const & Point3D() const
TVector2 const & Projection2D(unsigned int view) const
TVector2 const & Point2D() const noexcept
double Dist2(const TVector2 &v1, const TVector2 &v2)
Implementation of the Projection Matching Algorithm.
pma::SortedObjectBase * prev
::fhicl::TupleAs< Point(::geo::Length_t,::geo::Length_t,::geo::Length_t)> Point3D
Atom object for reading a 3D point or vector (centimeters).
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
double Length2(void) const override
recob::tracking::Vector_t Vector3D
int TPC(void) const
TPC index or -1 if out of any TPC.
TVector3 GetProjection(const TVector2 &p, unsigned int view) const
Get 3D projection of a 2D point from the view.
Implementation of the Projection Matching Algorithm.
void SetProjection(const TVector2 &p, float b)
std::vector< pma::Hit3D * > fAssignedHits
unsigned int View2D() const noexcept
int Cryo(void) const
Cryostat index or -1 if out of any cryostat.
Implementation of the Projection Matching Algorithm.
pma::Vector3D GetDirection3D(void) const override
Get 3D direction cosines of this segment.
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
void SetPoint3D(const TVector3 &p3d)
ROOT::Math::DisplacementVector2D< ROOT::Math::Cartesian2D< double > > Vector2D
pma::SortedObjectBase * next
double GetDistance2To(const TVector3 &p3d) const override
Distance [cm] from the 3D segment to the point 3D.
TVector3 GetUnconstrainedProj3D(const TVector2 &p2d, unsigned int view) const override
double SumDist2Hits(void) const override
void SetProjection(pma::Hit3D &h) const override
Set hit 3D position and its 2D projection to the vertex.
static float OptFactor(unsigned int view)
static double GetDist2(const TVector3 &psrc, const TVector3 &p0, const TVector3 &p1)