17 const double hitz = hit->getHitz();
21 const int sectorhit =
sector(hit);
22 const double perp = hit->getRadius();
23 const double radius = hit->getAbs();
27 for (
double rz0 = histo->getXmin() +
m_stepsize / 2.; rz0 < histo->getXmax(); rz0 +=
m_stepsize) {
28 if (std::abs(rz0) > radius)
continue;
30 double height = std::sqrt(radius * radius - rz0 * rz0);
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;
39 if (dotprod >= 0) {
fillHisto(rz0, theta_in_grad, weight, sectorhit); }
43 const double radius = hit->getRadius();
46 double theta_in_rad =
M_PI *
theta / 180.;
47 double rz0 = hitz * std::sin(theta_in_rad) - radius * std::cos(theta_in_rad);
50 dotprod = radius * std::sin(theta_in_rad) + hitz * std::cos(theta_in_rad);
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.;
69 m_histos.getHisto(
sector + 1)->fill(rz0, theta_in_grad, third_weight);
70 m_histos.getHisto(
sector - 1)->fill(rz0, theta_in_grad, third_weight);
72 m_histos.getHisto(
sector + 1)->fill(rz0, theta_in_grad, third_weight);
75 m_histos.getHisto(
sector - 1)->fill(rz0, theta_in_grad, third_weight);
76 m_histos.getHisto(0)->fill(rz0, theta_in_grad, third_weight);
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;
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.};
120 double coordsmaximumsecondinrad =
m_muonhoughmathutils.angleFromGradToRadial(coordsmaximum.second);
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);
132 int sectorhit =
sector(event.getHit(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);
142 dotprod = radius * std::sin(coordsmaximumsecondinrad) + hitz * std::cos(coordsmaximumsecondinrad);
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 );
181 houghpattern->addHit(event.getHit(i));
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 "
189 << atan2(std::hypot(event.getHitx(i) ,event.getHity(i)), event.getHitz(i))
190 <<
" theta all " << coordsmaximumsecondinrad);
191 sin_theta += std::sin(
theta);
192 cos_theta += std::cos(
theta);
194 phi = std::atan2(hity, hitx);
196 sin_phi += std::sin(
phi);
197 cos_phi += std::cos(
phi);
205 etheta = std::atan2(sin_theta, cos_theta);
206 ephi = std::atan2(sin_phi, cos_phi);
207 houghpattern->setEPhi(ephi);
209 eradius = eradius / (houghpattern->size() + 0.0001);
211 ATH_MSG_VERBOSE(
"Etheta : " << etheta <<
" Size houghpattern " << houghpattern->size() <<
" ephi "
213 houghpattern->setETheta(etheta);
214 houghpattern->setERTheta(eradius);
215 houghpattern->setECurvature(1.);
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);
225 houghpattern->setERTheta(rz0);