1 #ifndef RECOTOOL_CBALGOSHORTESTDIST_CXX 2 #define RECOTOOL_CBALGOSHORTESTDIST_CXX 33 const ::cluster::ClusterParamsAlg &cluster2)
41 double w_start1 = cluster1.GetParams().start_point.w;
42 double t_start1 = cluster1.GetParams().start_point.t;
43 double w_end1 = cluster1.GetParams().end_point.w;
44 double t_end1 = cluster1.GetParams().end_point.t;
46 double w_start2 = cluster2.GetParams().start_point.w;
47 double t_start2 = cluster2.GetParams().start_point.t;
48 double w_end2 = cluster2.GetParams().end_point.w;
49 double t_end2 = cluster2.GetParams().end_point.t;
52 std::cout <<
"Start point Cluster 1: (" << cluster1.GetParams().start_point.w <<
", " << cluster1.GetParams().start_point.t <<
")" << std::endl;
53 std::cout <<
"End point Cluster 2: (" << cluster1.GetParams().end_point.w <<
", " << cluster1.GetParams().end_point.t <<
")" << std::endl;
54 std::cout <<
"Start point Cluster 1: (" << cluster2.GetParams().start_point.w <<
", " << cluster2.GetParams().start_point.t <<
")" << std::endl;
55 std::cout <<
"End point Cluster 2: (" << cluster2.GetParams().end_point.w <<
", " << cluster2.GetParams().end_point.t <<
")" << std::endl;
77 shortest_distance2 = (shortest_distance2_tmp < shortest_distance2) ?
78 shortest_distance2_tmp : shortest_distance2;
85 shortest_distance2 = (shortest_distance2_tmp < shortest_distance2) ?
86 shortest_distance2_tmp : shortest_distance2;
93 shortest_distance2 = (shortest_distance2_tmp < shortest_distance2) ?
94 shortest_distance2_tmp : shortest_distance2;
100 if(compatible) std::cout<<Form(
" Compatible in distance (%g).\n",shortest_distance2);
101 else std::cout<<Form(
" NOT compatible in distance (%g).\n",shortest_distance2);
111 double start_x,
double start_y,
112 double end_x,
double end_y )
const {
120 double distance_squared = -1;
123 double length_squared = pow((end_x - start_x), 2) + pow((end_y - start_y), 2);
128 std::cout << std::endl;
129 std::cout << Form(
" Provided very short line segment: (%g,%g) => (%g,%g)",
130 start_x,start_y,end_x,end_y) << std::endl;
131 std::cout <<
" Likely this means one of two clusters have start & end point identical." << std::endl;
132 std::cout <<
" Check the cluster output!" << std::endl;
133 std::cout << std::endl;
134 std::cout << Form(
" At this time, the algorithm uses a point (%g,%g)",start_x,start_y) << std::endl;
135 std::cout <<
" to represent this cluster's location." << std::endl;
136 std::cout << std::endl;
138 return (pow((point_x - start_x),2) + pow((point_y - start_y),2));
142 double t = ( (point_x - start_x)*(end_x - start_x) + (point_y - start_y)*(end_y - start_y) ) / length_squared;
144 if(t<0.0) distance_squared = pow((point_x - start_x), 2) + pow((point_y - start_y), 2);
146 else if (t>1.0) distance_squared = pow((point_x - end_x), 2) + pow(point_y - end_y, 2);
148 else distance_squared = pow((point_x - (start_x + t*(end_x - start_x))), 2) + pow((point_y - (start_y + t*(end_y - start_y))),2);
150 return distance_squared;
Double_t TimeToCm() const
Double_t WireToCm() const
Class def header for a class CBAlgoShortestDist.