8 double threshold_histo,
int number_of_sectors) :
9 MuonHoughTransformer(
"MuonHoughTransformer_rz",
nbins, nbins_angle, detectorsize, detectorsize_angle, threshold_histo, number_of_sectors),
10 m_use_residu_grad(false) {
17 const double hitz = hit->
getHitz();
21 const int sectorhit =
sector(hit);
28 if (std::abs(rz0) >
radius)
continue;
31 double theta = std::atan2(
perp, hitz) + std::atan2(rz0, height);
32 double theta_in_grad = (
theta /
M_PI) * 180.;
36 if (theta_in_grad > 180.)
continue;
37 if (theta_in_grad < 0.)
continue;
46 double theta_in_rad =
M_PI *
theta / 180.;
59 double binwidthx =
histo->getBinWidthX();
60 double binwidthy =
histo->getBinWidthY();
62 int filled_binnumber =
histo->fill(rz0, theta_in_grad,
weight);
67 double third_weight =
weight / 3.;
80 double half_weight = 0.5 *
weight;
82 if (theta_in_grad - binwidthy < 0) {
83 histo->fill(rz0 + binwidthx, theta_in_grad + binwidthy, half_weight);
86 }
else if (theta_in_grad + binwidthy > 180.) {
87 histo->fill(rz0 - binwidthx, theta_in_grad - binwidthy, half_weight);
90 histo->fill(rz0 + binwidthx, theta_in_grad + binwidthy, half_weight);
91 histo->fill(rz0 - binwidthx, theta_in_grad - binwidthy, half_weight);
93 histo->fill(rz0 - binwidthx, theta_in_grad + binwidthy, -half_weight);
94 histo->fill(rz0 + binwidthx, theta_in_grad - binwidthy, -half_weight);
97 return filled_binnumber;
105 double r = std::sqrt(hitx * hitx + hity * hity);
113 std::pair<double, double> coordsmaximum,
double maximum_residu_mm,
114 double maximum_residu_angle,
int maxsector)
const {
116 std::unique_ptr<MuonHoughPattern> houghpattern = std::make_unique<MuonHoughPattern>(
MuonHough::hough_rz);
118 double theta{0.}, residu_distance{0.}, maximum_residu{0.};
119 double eradius{0.}, etheta{0.}, sin_theta{0.}, cos_theta{0.}, sin_phi{0.}, cos_phi{0.},
phi{0.}, ephi{0.};
121 double rz0 = coordsmaximum.first;
123 ATH_MSG_VERBOSE(
"MuonHoughTransformer_rz::hookAssociateHitsToMaximum() -- sector: " << maxsector
124 <<
"coordsmaximumfirst: " << rz0 <<
"coordsmaximumsecond: " << coordsmaximum.second
125 <<
" coordsmaximumsecondinrad: " << coordsmaximumsecondinrad
126 <<
" size of event: " <<
event.size());
128 for (
unsigned int i = 0;
i <
event.size();
i++) {
130 double hitx =
event.getHitx(
i);
131 double hity =
event.getHity(
i);
133 int maxsecmax = maxsector + 1;
134 int maxsecmin = maxsector - 1;
138 if (sectorhit == maxsector || sectorhit == maxsecmin || sectorhit == maxsecmax) {
139 double hitz =
event.getHitz(
i);
140 double radius = std::hypot(hitx, hity);
149 double radius3 = std::hypot(hitx, hity, hitz);
151 if (std::abs(rz0) < radius3) {
152 height = std::sqrt(radius3 * radius3 - rz0 * rz0);
154 height = std::sqrt(rz0 * rz0 - radius3 * radius3);
157 theta = std::atan2(
radius, hitz) + std::atan2(rz0, height);
159 <<
" std::atan2(radius,hitz): " << std::atan2(
radius, hitz)
160 <<
" +std::atan2(rz0,height): " << std::atan2(rz0, height) <<
" rz0: ");
162 double residu_distance_grad = std::abs(
std::sin(
theta - coordsmaximumsecondinrad));
163 residu_distance = residu_distance_grad;
164 maximum_residu = maximum_residu_angle;
166 residu_distance = residu_distance_mm;
167 maximum_residu = maximum_residu_mm;
170 ATH_MSG_VERBOSE(
"hitx: " << hitx <<
" hity: " << hity <<
" hitz: " << hitz
171 <<
", residu_distance: " << residu_distance);
173 if (std::abs(
theta * 180. /
M_PI - coordsmaximum.second) < 1.1) inmax =
true;
175 if (std::abs(residu_distance) < maximum_residu)
177 ATH_MSG_VERBOSE(
" hit added to houghpattern! -- sector number hit " << sectorhit <<
" max " << maxsector
178 <<
" detector: " <<
event.getHit(
i)->getWhichDetector() <<
179 (inmax ?
" MuonHoughTransformer_rz:: in maximum " :
" OUTSIDE maximum" )<<
" theta hit " <<
theta * 180. /
M_PI <<
" max Hough theta "
180 << coordsmaximum.second );
183 event.getHit(
i)->setAssociated(
true);
185 double rz0hit = residu_distance_mm + rz0;
187 ATH_MSG_VERBOSE(__FILE__<<
":"<<__LINE__<<
" calculateAngle: " <<
theta <<
" calculateradius: " << rz0hit
188 <<
" R Z hit added to hough pattern theta hit "
190 <<
" theta all " << coordsmaximumsecondinrad);
194 phi = std::atan2(hity, hitx);
205 etheta = std::atan2(sin_theta, cos_theta);
206 ephi = std::atan2(sin_phi, cos_phi);
209 eradius = eradius / (houghpattern->
size() + 0.0001);
211 ATH_MSG_VERBOSE(
"Etheta : " << etheta <<
" Size houghpattern " << houghpattern->
size() <<
" ephi "
217 if (houghpattern->
empty()) {
221 else if (std::abs(eradius - rz0) > 500. ||
std::sin(etheta - coordsmaximumsecondinrad) > 0.05) {
222 ATH_MSG_VERBOSE(
"WARNING Eradius or Etheta calc. WRONG -- rz0: " << rz0
223 <<
" etheta: " << coordsmaximumsecondinrad<<
" eradius: " << eradius <<
" etheta: " << etheta );
224 houghpattern->
setETheta(coordsmaximumsecondinrad);
241 if (!m_add_weight_angle) {
242 return weightHoughTransform(
r0);
244 if (m_add_weight_radius) {
245 double theta_rad = m_muonhoughmathutils.angleFromGradToRadial(
theta);
247 float r_theta_weight = std::abs(
std::sin(theta_rad)) / (1. + std::abs((
r0 / 6000.)));
249 return r_theta_weight;