1 #ifndef RECOTOOL_CBALGOCENTEROFMASS_CXX 2 #define RECOTOOL_CBALGOCENTEROFMASS_CXX 26 const ::cluster::ClusterParamsAlg &cluster2)
34 if ( (cluster1.GetHitVector().size() >
_minHits) and (cluster2.GetHitVector().size() <
_maxHits) )
36 else if ( (cluster2.GetHitVector().size() >
_minHits) and (cluster1.GetHitVector().size() <
_maxHits) )
57 std::vector<util::PxHit> hitss;
59 hitss = cluster1.GetHitVector();
60 hitssmall = hitss.size();
61 direc_angle = cluster2.GetParams().angle_2d;
62 opening_angle = cluster2.GetParams().opening_angle * (180./3.14);
63 length = cluster2.GetParams().length;
64 start_w = cluster2.GetParams().start_point.w;
65 start_t = cluster2.GetParams().start_point.t;
66 end_w = cluster2.GetParams().end_point.w;
67 end_t = cluster2.GetParams().end_point.t;
68 poly = cluster2.GetParams().PolyObject;
71 hitss = cluster2.GetHitVector();
72 hitssmall = hitss.size();
73 direc_angle = cluster1.GetParams().angle_2d;
74 opening_angle = cluster1.GetParams().opening_angle * (180./3.14);
75 length = cluster1.GetParams().length;
76 start_w = cluster1.GetParams().start_point.w;
77 start_t = cluster1.GetParams().start_point.t;
78 end_w = cluster1.GetParams().end_point.w;
79 end_t = cluster1.GetParams().end_point.t;
80 poly = cluster1.GetParams().PolyObject;
84 std::cout <<
"Big Cluster:" << std::endl;
85 std::cout <<
"\tOpening Angle: " << opening_angle << std::endl;
86 std::cout <<
"\tLength: " << length << std::endl;
87 std::cout <<
"\tStart Point: (" << start_w <<
", " << end_w <<
")" << std::endl;
88 std::cout <<
"\tDirection Angle: " << direc_angle << std::endl;
89 std::cout << std::endl;
92 for (
auto&
hit: hitss){
93 COM_t_s +=
hit.t *
hit.charge;
94 COM_w_s +=
hit.w *
hit.charge;
101 std::cout <<
"Small Cluster: " << std::endl;
102 std::cout <<
"N Hits: " << hitssmall << std::endl;
103 std::cout <<
"COM: (w,t) -> (" << COM_w_s <<
", " << COM_t_s <<
")" << std::endl;
104 std::cout << std::endl;
108 std::pair<float,float> COM_s;
109 COM_s = std::make_pair( COM_w_s, COM_t_s );
112 double COM_w_rot = (COM_w_s - start_w)*cos(direc_angle*3.14/180.) + (COM_t_s - start_t)*sin(direc_angle*3.14/180.);
113 double COM_t_rot = - (COM_w_s - start_w)*sin(direc_angle*3.14/180.) + (COM_t_s - start_t)*cos(direc_angle*3.14/180.);
117 if (
_verbose) { std::cout <<
"Polygon Overlap -> Merge!" << std::endl << std::endl;}
122 (COM_w_rot < length*
_lengthReach ) and ( COM_w_rot > 0 ) and
123 ( abs(COM_t_rot) < abs(COM_w_rot*sin(opening_angle*3.14/180.)) ) ){
124 if (
_verbose) { std::cout <<
"COM in Cone -> Merge! " << std::endl; }
130 if (
_verbose) { std::cout <<
"COM close to start-end -> Merge!" << std::endl; }
145 double start_x,
double start_y,
146 double end_x,
double end_y )
const {
154 double distance_squared = -1;
157 double length_squared = pow((end_x - start_x), 2) + pow((end_y - start_y), 2);
160 if(length_squared < 0.1) {
162 std::cout << std::endl;
163 std::cout << Form(
" Provided very short line segment: (%g,%g) => (%g,%g)",
164 start_x,start_y,end_x,end_y) << std::endl;
165 std::cout <<
" Likely this means one of two clusters have start & end point identical." << std::endl;
166 std::cout <<
" Check the cluster output!" << std::endl;
167 std::cout << std::endl;
168 std::cout << Form(
" At this time, the algorithm uses a point (%g,%g)",start_x,start_y) << std::endl;
169 std::cout <<
" to represent this cluster's location." << std::endl;
170 std::cout << std::endl;
173 return (pow((point_x - start_x),2) + pow((point_y - start_y),2));
177 double t = ( (point_x - start_x)*(end_x - start_x) + (point_y - start_y)*(end_y - start_y) ) / length_squared;
179 if(t<0.0) distance_squared = pow((point_x - start_x), 2) + pow((point_y - start_y), 2);
181 else if (t>1.0) distance_squared = pow((point_x - end_x), 2) + pow(point_y - end_y, 2);
183 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);
185 return distance_squared;
Detector simulation of raw signals on wires.
bool PointInside(const std::pair< float, float > &point) const
Class def header for a class CBAlgoCenterOfMass.