9 double threshold_histo,
int number_of_sectors) :
10 MuonHoughTransformer(
"MuonHoughTransformer_xyz", nbins, nbins_angle, detectorsize, detectorsize_angle, threshold_histo, number_of_sectors) {
16 double radius = hit->getRadius();
17 double hitx = hit->getHitx();
18 double hity = hit->getHity();
19 int sectorhit =
sector(hit);
24 for (
double r0 = endpoints.first; r0 < endpoints.second; r0 +=
m_stepsize) {
27 dotprod = scphi.
apply(hity, hitx);
30 fillHisto(r0, phi_in_grad, weight, sectorhit);
40 double r0 = scphi.
apply(hitx, -hity);
50 const int filled_binnumber = histo->fill(r0,
phi, weight);
53 bool butterfly =
true;
57 double third_weight = weight / 3.;
59 m_histos.getHisto(
sector + 1)->fill(filled_binnumber, third_weight);
60 m_histos.getHisto(
sector - 1)->fill(filled_binnumber, third_weight);
62 m_histos.getHisto(
sector + 1)->fill(filled_binnumber, third_weight);
65 m_histos.getHisto(
sector - 1)->fill(filled_binnumber, third_weight);
69 double half_weight = 0.5 * weight;
71 histo->fill(filled_binnumber - 1, half_weight);
72 histo->fill(filled_binnumber + 1, half_weight);
79 histo->fill(upperright, half_weight);
82 histo->fill(upperright - 2, -half_weight);
85 histo->fill(lowerleft, half_weight);
88 histo->fill(lowerleft + 2, -half_weight);
92 histo->fill(lowerleft, half_weight);
93 histo->fill(upperright, half_weight);
95 histo->fill(lowerleft + 2, -half_weight);
96 histo->fill(upperright - 2, -half_weight);
100 return filled_binnumber;
105 double height_squared = hitx * hitx + hity * hity - r0 * r0;
106 if (height_squared >= 0) {
107 double height = std::sqrt(height_squared);
108 phi = std::atan2(hity, hitx) + std::atan2(r0, height);
112 phi = std::atan2(hity, hitx);
122 std::pair<double, double> coordsmaximum,
double max_residu_mm,
123 double ,
int max_sector)
const {
125 ATH_MSG_DEBUG(
"MuonHoughTransformer_xyz::hookAssociateHitsToMaximum (start)");
128 double ephi{0.}, eradius{0.}, sin_phi{0.}, cos_phi{0.};
129 double dotprod{0.}, etheta{0.}, residu_distance{0.};
131 ATH_MSG_DEBUG(
"MuonHoughTransformer_xyz::size_event: " << event.size() );
132 ATH_MSG_DEBUG(
"MuonHoughTransformer_xyz::found_maximum: r: " << coordsmaximum.first <<
" phi: " << coordsmaximum.second
133 <<
" sector: " << max_sector);
140 int max_secmax = max_sector + 1;
141 int max_secmin = max_sector - 1;
142 if (max_secmin < 0) max_secmin = max_sector;
145 for (
unsigned int i = 0; i <
event.size(); i++) {
146 double hitx =
event.getHitx(i);
147 double hity =
event.getHity(i);
148 double hitz =
event.getHitz(i);
150 double radiushit = std::sqrt(hitx * hitx + hity * hity);
151 int sectorhit =
sector(event.getHit(i));
153 if (sectorhit == max_sector || sectorhit == max_secmin || sectorhit == max_secmax) {
161 residu_distance = -coordsmaximum.first +
165 <<
" hity: " <<
getHitPos(event, i).second <<
" dotprod: " << dotprod <<
" sector: "
166 << sectorhit<<
",residu_distance: " << residu_distance);
168 if (std::abs(residu_distance) < max_residu_mm) {
169 houghpattern->addHit(event.getHit(i));
171 ATH_MSG_VERBOSE(
"MuonHoughTransformer_xyz::hit added to houghpattern!");
174 event.getHit(i)->setAssociated(
true);
178 double thetah = std::atan2(radiushit, hitz);
179 ATH_MSG_VERBOSE(
" X Y hit added to hough pattern phi hit " << std::atan2(event.getHity(i), event.getHitx(i))
180 <<
" phi_calc: " <<
phi <<
" phi all " << phimax <<
" theta hit " << thetah );
197 eradius = eradius / (houghpattern->size() + 0.0001);
198 etheta = etheta / (houghpattern->size() + 0.0001);
199 ephi = std::atan2(sin_phi, cos_phi);
201 ATH_MSG_VERBOSE(
"ephi: " << ephi <<
" eradius: " << eradius <<
" etheta " << etheta);
204 houghpattern->setEPhi(ephi);
206 houghpattern->setEPhi(phimax);
209 houghpattern->setERPhi(coordsmaximum.first);
210 houghpattern->setETheta(etheta);
212 if (!houghpattern->empty() && std::abs(std::sin(houghpattern->getEPhi() - phimax)) > 0.05) {
213 ATH_MSG_WARNING(
"MuonHoughTransformer_xyz:: Ephi calculation went wrong -- histo radius: "
214 << coordsmaximum.first <<
" phi: " << phimax <<
", ephi: " << ephi);
216 houghpattern->setERPhi(coordsmaximum.first);
220 houghpattern->updateParametersRPhi(
true);
222 ATH_MSG_VERBOSE(
"updateParameterstheta new phi (phi flipped Pi for cosmics): " << houghpattern->getEPhi()
223 <<
" old phi: " << phimax <<
" new r0: " << houghpattern->getERPhi()
224 <<
" old r0: " << coordsmaximum.first);
239 double radius = hit->getRadius();
240 double hitz = hit->getHitz();
245 double theta = std::atan2(radius, hitz);
Scalar phi() const
phi method
Scalar theta() const
theta method
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
Histogram class, similar to Root's TH2D.
static double signedDistanceOfLineToOrigin2D(double x, double y, double phi)
signed distance of line with point (x,y) and angle phi to origin
static double angleFromMinusPiToPi(double angle)
computes angle in rad between -Pi and Pi
constexpr double degree_rad_conversion_factor
constexpr double rad_degree_conversion_factor
Helper to simultaneously calculate sin and cos of the same angle.
Helper to simultaneously calculate sin and cos of the same angle.
double apply(double a, double b) const