1 #ifndef CBALGOSHORTESTDISTSMALLCLUSTER_CXX 2 #define CBALGOSHORTESTDISTSMALLCLUSTER_CXX 31 const ::cluster::ClusterParamsAlg &cluster2)
45 double w_start1 = cluster1.GetParams().start_point.w;
46 double t_start1 = cluster1.GetParams().start_point.t;
47 double w_end1 = cluster1.GetParams().end_point.w;
48 double t_end1 = cluster1.GetParams().end_point.t;
50 double w_start2 = cluster2.GetParams().start_point.w;
51 double t_start2 = cluster2.GetParams().start_point.t;
52 double w_end2 = cluster2.GetParams().end_point.w;
53 double t_end2 = cluster2.GetParams().end_point.t;
56 std::cout <<
"Start point Cluster 1: (" << cluster1.GetParams().start_point.w <<
", " << cluster1.GetParams().start_point.t <<
")" << std::endl;
57 std::cout <<
"End point Cluster 2: (" << cluster1.GetParams().end_point.w <<
", " << cluster1.GetParams().end_point.t <<
")" << std::endl;
58 std::cout <<
"Start point Cluster 1: (" << cluster2.GetParams().start_point.w <<
", " << cluster2.GetParams().start_point.t <<
")" << std::endl;
59 std::cout <<
"End point Cluster 2: (" << cluster2.GetParams().end_point.w <<
", " << cluster2.GetParams().end_point.t <<
")" << std::endl;
81 shortest_distance2 = (shortest_distance2_tmp < shortest_distance2) ?
82 shortest_distance2_tmp : shortest_distance2;
89 shortest_distance2 = (shortest_distance2_tmp < shortest_distance2) ?
90 shortest_distance2_tmp : shortest_distance2;
97 shortest_distance2 = (shortest_distance2_tmp < shortest_distance2) ?
98 shortest_distance2_tmp : shortest_distance2;
104 if(compatible) std::cout<<Form(
" Compatible in distance (%g).\n",shortest_distance2);
105 else std::cout<<Form(
" NOT compatible in distance (%g).\n",shortest_distance2);
115 double start_x,
double start_y,
116 double end_x,
double end_y )
const {
124 double distance_squared = -1;
127 double length_squared = pow((end_x - start_x), 2) + pow((end_y - start_y), 2);
132 std::cout << std::endl;
133 std::cout << Form(
" Provided very short line segment: (%g,%g) => (%g,%g)",
134 start_x,start_y,end_x,end_y) << std::endl;
135 std::cout <<
" Likely this means one of two clusters have start & end point identical." << std::endl;
136 std::cout <<
" Check the cluster output!" << std::endl;
137 std::cout << std::endl;
138 std::cout << Form(
" At this time, the algorithm uses a point (%g,%g)",start_x,start_y) << std::endl;
139 std::cout <<
" to represent this cluster's location." << std::endl;
140 std::cout << std::endl;
142 return (pow((point_x - start_x),2) + pow((point_y - start_y),2));
146 double t = ( (point_x - start_x)*(end_x - start_x) + (point_y - start_y)*(end_y - start_y) ) / length_squared;
148 if(t<0.0) distance_squared = pow((point_x - start_x), 2) + pow((point_y - start_y), 2);
150 else if (t>1.0) distance_squared = pow((point_x - end_x), 2) + pow(point_y - end_y, 2);
152 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);
154 return distance_squared;
Class def header for a class CBAlgoShortestDistSmallCluster.
Double_t TimeToCm() const
Double_t WireToCm() const