TrdMCClusterR Fit Classifier
Classes | Functions
Line Namespace Reference

Classes

struct  FitLine2D
 
struct  FitLine3DMinuit
 
struct  FitLine3D
 
struct  Line3DParametricForm
 

Functions

Line3DParametricForm Getline3DParametricForm (const double &m1, const double &b1, const double &m2, const double &b2, const double &m3, const double &b3, const int &trkID, const int &g3PID, bool debugMode)
 
double distanceFromLine3D (double *coords, double *params)
 

Function Documentation

◆ distanceFromLine3D()

double Line::distanceFromLine3D ( double *  coords,
double *  params 
)

3D line function

Summary: This function takes a point in 3D space and a set of parameters defining a line. It returns the squared distance between the point and the line in 3D. This is the function that the fitting procedure will try to minimize to find the best-fit line through the data points.

Math details: calculates the squared distance from a given point (x,y,z) to a 3D line defined by a point on the line (px, py, pz) and a direction vector (vx, vy, vz).

Function Parameters: coords: An array of 3 elements representing the coordinates (x,y,z) of the point. params: An array of 6 elements representing the parameters of the line. The first three elements are the coordinates of a point on the line (px, py, pz) and the next three elements are the components of the direction vector (vx, vy, vz).

Assign the input arrays to more descriptive variables for better readability.

Extract coordinates

Extract parameters

x position of a point on the line

y position of a point on the line

z position of a point on the line

x component of the line's direction

y component of the line's direction

z component of the line's direction

Compute the squared distance from the point (x,y,z) to the line

Step 1: Calculating the Projection of the Point onto the Line: The scalar u represents how far along the direction of the line, starting from the point (px, py, pz), our projected point is.

This is determined by taking the dot product of the difference vector (from the point on the line to the data point) with the direction vector, andd then dividing by the squared magnitude of the direction vector.

Step 2: Calculating the Coordinates of the Projected Point on the Line: Using the scalar u, we find the coordinates of the projected point on the line. The differences dx, dy, and dz are then the distances in the x, y, and z directions, respectively, from the original point to its projection on the line.

Step 3: Returning the Squared Distance: Finally, we compute and return the squared distance from the point (x,y,z) to the line. The squared distance is used because it's computationally simpler and serves the purpose of the fitting procedure, which aims to minimize this distance for all data points.

Here is the caller graph for this function:

◆ Getline3DParametricForm()

Line3DParametricForm Line::Getline3DParametricForm ( const double &  m1,
const double &  b1,
const double &  m2,
const double &  b2,
const double &  m3,
const double &  b3,
const int &  trkID,
const int &  g3PID,
bool  debugMode 
)

Function to get the parametric form of the line First find a point on the line. Get an std::vector<double> of size 3 with the solution

Method 1

Method 2

return empty vector if no solution found

Extract values from the tuple

Second, determine the direction ratios

Print the parametric form of the line

Parameters
m2XZ projection: z = m1*x + b1
m3YZ projection: z = m2*y + b2
trkIDXY projection: y = m3*x + b3
Here is the call graph for this function:
Here is the caller graph for this function: