48 unsigned int view = h->View2D();
50 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;
99 if (b > 0.0) result += (v3d * b);
101 else result = v3dStop;
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();
161 h.
Point2D().X() - projStart.X(),
162 h.
Point2D().Y() - projStart.Y());
165 projStop.X() - projStart.X(),
166 projStop.Y() - projStart.Y());
169 pointStop.X() - pointStart.X(),
170 pointStop.Y() - pointStart.Y(),
171 pointStop.Z() - pointStart.Z());
173 double v0Norm = sqrt(v0.Mag2());
174 double v1Norm = sqrt(v1.Mag2());
177 double mag = v0Norm * v1Norm;
179 if (mag != 0.0) cosine = v0.Dot(v1) / mag;
180 double b = v0Norm * cosine / v1Norm;
188 pointStart.X() + v3d.X(),
189 pointStart.Y() + v3d.Y(),
190 pointStart.Z() + v3d.Z());
195 0.5 * (projStart.X() + projStop.X()),
196 0.5 * (projStart.Y() + projStop.Y()), 0.0F);
199 0.5 * (pointStart.X() + pointStop.X()),
200 0.5 * (pointStart.Y() + pointStop.Y()),
201 0.5 * (pointStart.Z() + pointStop.Z()));
211 mf::LogError(
"pma::Segment3D") <<
"Segment endpoints not set.";
219 pma::Vector3D v0(psrc.X() - p0.X(), psrc.Y() - p0.Y(), psrc.Z() - p0.Z());
220 pma::Vector3D v1(p1.X() - p0.X(), p1.Y() - p0.Y(), p1.Z() - p0.Z());
221 pma::Vector3D v2(psrc.X() - p1.X(), psrc.Y() - p1.Y(), psrc.Z() - p1.Z());
223 double v1Norm2 = v1.Mag2();
224 if (v1Norm2 >= 1.0
E-6)
226 double v0v1 = v0.Dot(v1);
227 double v2v1 = v2.Dot(v1);
228 double v0Norm2 = v0.Mag2();
229 double v2Norm2 = v2.Mag2();
232 if ((v0v1 > 0.0) && (v2v1 < 0.0))
234 double cosine01_square = 0.0;
235 double mag01_square = v0Norm2 * v1Norm2;
236 if (mag01_square != 0.0) cosine01_square = v0v1 * v0v1 / mag01_square;
238 result = (1.0 - cosine01_square) * v0Norm2;
242 if (v0v1 <= 0.0) result = 1.0001 * v0Norm2;
243 else result = 1.0001 * v2Norm2;
246 if (result >= 0.0)
return result;
251 double dx = 0.5 * (p0.X() + p1.X()) - psrc.X();
252 double dy = 0.5 * (p0.Y() + p1.Y()) - psrc.Y();
253 double dz = 0.5 * (p0.Z() + p1.Z()) - psrc.Z();
254 return dx * dx + dy * dy + dz * dz;
264 double v1Norm2 = v1.Mag2();
265 if (v1Norm2 >= 1.0
E-6)
267 double v0v1 = v0.Dot(v1);
268 double v2v1 = v2.Dot(v1);
269 double v0Norm2 = v0.Mag2();
270 double v2Norm2 = v2.Mag2();
273 if ((v0v1 > 0.0) && (v2v1 < 0.0))
275 double cosine01_square = 0.0;
276 double mag01_square = v0Norm2 * v1Norm2;
277 if (mag01_square != 0.0) cosine01_square = v0v1 * v0v1 / mag01_square;
279 result = (1.0 - cosine01_square) * v0Norm2;
283 if (v0v1 <= 0.0) result = 1.0001 * v0Norm2;
284 else result = 1.0001 * v2Norm2;
286 if (result >= 0.0)
return result;
291 double dx = 0.5 * (p0.X() + p1.X()) - psrc.X();
292 double dy = 0.5 * (p0.Y() + p1.Y()) - psrc.Y();
293 return dx * dx + dy * dy;
TVector2 const & Projection2D(unsigned int view) const
unsigned int View2D(void) const
double Dist2(const TVector2 &v1, const TVector2 &v2)
TVector3 const & Point3D(void) const
Implementation of the Projection Matching Algorithm.
::fhicl::TupleAs< Point(::geo::Length_t,::geo::Length_t,::geo::Length_t)> Point3D
Atom object for reading a 3D point or vector (centimeters).
pma::SortedObjectBase * prev
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.
ROOT::Math::DisplacementVector2D< ROOT::Math::Cartesian2D< double > > Vector2D
std::vector< pma::Hit3D * > fAssignedHits
void SetProjection(const TVector2 &p, float b)
TVector2 const & Point2D(void) const
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)
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)