24 const ::cluster::ClusterParamsAlg &cluster2)
32 if ( (cluster1.GetHitVector().size() >
_maxHits) or (cluster2.GetHitVector().size() >
_maxHits) )
55 std::vector<util::PxHit> hits1;
56 hits1 = cluster1.GetHitVector();
57 Nhits1 = hits1.size();
58 poly1 = cluster1.GetParams().PolyObject;
59 start_w_1 = cluster1.GetParams().start_point.w;
60 start_t_1 = cluster1.GetParams().start_point.t;
61 end_w_1 = cluster1.GetParams().end_point.w;
62 end_t_1 = cluster1.GetParams().end_point.t;
65 std::vector<util::PxHit> hits2;
66 hits2 = cluster2.GetHitVector();
67 Nhits2 = hits2.size();
68 poly2 = cluster2.GetParams().PolyObject;
69 start_w_2 = cluster2.GetParams().start_point.w;
70 start_t_2 = cluster2.GetParams().start_point.t;
71 end_w_2 = cluster2.GetParams().end_point.w;
72 end_t_2 = cluster2.GetParams().end_point.t;
75 for (
auto&
hit: hits1){
76 COM_t_1 +=
hit.t *
hit.charge;
77 COM_w_1 +=
hit.w *
hit.charge;
84 for (
auto&
hit: hits2){
85 COM_t_2 +=
hit.t *
hit.charge;
86 COM_w_2 +=
hit.w *
hit.charge;
94 std::cout <<
"N Hits: " << Nhits1 << std::endl;
95 std::cout <<
"COM: (w,t) -> (" << COM_w_1 <<
", " << COM_t_1 <<
")" << std::endl;
97 std::cout <<
"N Hits: " << Nhits2 << std::endl;
98 std::cout <<
"COM: (w,t) -> (" << COM_w_2 <<
", " << COM_t_2 <<
")" << std::endl;
103 std::pair<float,float> COM_1;
104 COM_1 = std::make_pair( COM_w_1, COM_t_1 );
105 std::pair<float,float> COM_2;
106 COM_2 = std::make_pair( COM_w_2, COM_t_2 );
111 if (
_verbose) {
std::cout <<
"Polygon Overlap -> Merge!" << std::endl << std::endl;}
116 double distCOMs = ( COM_w_1-COM_w_2 )*( COM_w_1-COM_w_2 ) +
117 ( COM_t_1-COM_t_2 )*( COM_t_1-COM_t_2 );
119 if (
_verbose) {
std::cout <<
"COMs close to each other -> Merge!" << std::endl << std::endl;}
142 double start_x,
double start_y,
143 double end_x,
double end_y )
const {
151 double distance_squared = -1;
154 double length_squared = pow((end_x - start_x), 2) + pow((end_y - start_y), 2);
157 if(length_squared < 0.1) {
160 std::cout << Form(
" Provided very short line segment: (%g,%g) => (%g,%g)",
161 start_x,start_y,end_x,end_y) << std::endl;
162 std::cout <<
" Likely this means one of two clusters have start & end point identical." << std::endl;
163 std::cout <<
" Check the cluster output!" << std::endl;
165 std::cout << Form(
" At this time, the algorithm uses a point (%g,%g)",start_x,start_y) << std::endl;
166 std::cout <<
" to represent this cluster's location." << std::endl;
170 return (pow((point_x - start_x),2) + pow((point_y - start_y),2));
174 double t = ( (point_x - start_x)*(end_x - start_x) + (point_y - start_y)*(end_y - start_y) ) / length_squared;
176 if(t<0.0) distance_squared = pow((point_x - start_x), 2) + pow((point_y - start_y), 2);
178 else if (t>1.0) distance_squared = pow((point_x - end_x), 2) + pow(point_y - end_y, 2);
180 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);
182 return distance_squared;
return match has_match and(match.match_pdg==11 or match.match_pdg==-11)
Class def header for a class CBAlgoCenterOfMassSmall.
bool PointInside(const std::pair< float, float > &point) const
BEGIN_PROLOG could also be cout