9#include "GaudiKernel/MsgStream.h"
12 double detectorsize_angle,
double threshold_histo,
13 int number_of_sectors) :
14 MuonHoughTransformer(
"MuonHoughTransformer_CurvedAtACylinder", nbins, nbins_angle, detectorsize, detectorsize_angle, threshold_histo, number_of_sectors) {
24 for (
int i = 0; i <
m_nbins / 2; i++) {
26 if (x0 > 15.) x0 = 15 + (x0 - 15) * 0.5;
28 double curvature = -3. * 3500. * 20.25 / (x0 - 19.75);
46 int sectorhit =
sector(hit);
48 bool isbarrel = hit->isBarrel();
50 for (
int i = 0; i <
m_nbins / 2; i++) {
52 const double ratio = hit->getMagneticTrackRatio() *
m_invcurvature[i];
53 if (!isbarrel && std::abs(ratio) > 0.5)
break;
59 const double weight_curvature =
67 if (thetas[0] > 0. && thetas[0] <
M_PI) {
70 const double weight_curvature_theta = weight_curvature * (0.5 + 0.5 * std::sin(thetas[0]));
72 fillHisto(i + 0.5, theta_in_grad, weight_curvature_theta, 2 * sectorhit);
78 if (thetas[1] > 0. && thetas[1] <
M_PI) {
81 const double weight_curvature_theta = weight_curvature * (0.5 + 0.5 * std::sin(thetas[1]));
82 fillHisto(-i - 0.5, theta_in_grad, weight_curvature_theta, 2 * sectorhit);
90 const int filled_binnumber = histo->fill(xbin, theta_in_grad, weight);
96 const double reduced_weight = 0.8 * weight;
98 m_histos.getHisto(
sector + 1)->fill(filled_binnumber, reduced_weight);
99 m_histos.getHisto(
sector - 1)->fill(filled_binnumber, reduced_weight);
101 m_histos.getHisto(
sector + 1)->fill(filled_binnumber, reduced_weight);
104 m_histos.getHisto(
sector - 1)->fill(filled_binnumber, reduced_weight);
105 m_histos.getHisto(0)->fill(filled_binnumber, reduced_weight);
111 const double fifth_weight = 0.2 * weight;
116 histo->fill(upperright, fifth_weight);
120 histo->fill(lowerleft, fifth_weight);
123 histo->fill(upperright, fifth_weight);
124 histo->fill(lowerleft, fifth_weight);
126 histo->fill(upperright - 2, -fifth_weight);
127 histo->fill(lowerleft + 2, -fifth_weight);
130 return filled_binnumber;
134 std::pair<double, double> coordsmaximum,
135 double max_residu_mm,
double ,
136 int maxsector)
const {
140 double etheta{0.}, sin_phi{0.}, cos_phi{0.}, sin_theta{0.}, cos_theta{0.}, ephi{0.};
142 double invcurvature{0.}, curvature{0.};
145 invcurvature = 1. / curvature;
148 int index =
static_cast<int>(std::floor(std::abs(coordsmaximum.first)));
154 curvature = 1. / invcurvature;
158 int sector_1 = maxsector / 2;
159 int sector_2 = sector_1 + 1;
160 int sector_3 = sector_1 - 1;
162 if (maxsector % 2 == 1) {
164 }
else if (sector_3 < 0) {
169 <<
" coordsmaximumfirst: " << coordsmaximum.first <<
" curvature: " << curvature
170 <<
" coordsmaximumsecond: " << coordsmaximum.second <<
" coordsmaximumsecondinrad: " <<
theta
171 <<
" MuonHoughTransformer_CurvedAtACylinder::size of event: " << event.size()
172 <<
" allowed sectors: " << sector_1 <<
" , " << sector_2 <<
" & " << sector_3 );
174 for (
unsigned int i = 0; i <
event.size(); i++) {
175 std::shared_ptr<MuonHoughHit> hit =
event.getHit(i);
176 int sectorhit =
sector(hit);
177 if (sectorhit == sector_1 || sectorhit == sector_2 || sectorhit == sector_3) {
181 double radius3d = std::min(15000.,std::max(5000.,hit->getAbs()));
182 double scale = radius3d / 5000.;
184 double residu_distance_mm = std::abs(sdis);
187 ATH_MSG_VERBOSE(
" hit position " << hit->getPosition() <<
" residu_distance: " << sdis
188 <<
" max_residu_mm*scale: " << max_residu_mm * scale);
190 if (std::abs(residu_distance_mm) < max_residu_mm * scale)
192 double phi = hit->getPhi();
199 ATH_MSG_VERBOSE(
"hit added to houghpattern! Sector number: " << sectorhit
200 <<
" associated earlier "<<event.getHit(i)->getAssociated());
201 houghpattern->addHit(event.getHit(i));
202 event.getHit(i)->setAssociated(
true);
204 sin_theta += sctheta.
sn;
205 cos_theta += sctheta.
cs;
211 etheta = std::atan2(sin_theta, cos_theta);
213 ephi = std::atan2(sin_phi, cos_phi);
214 houghpattern->setETheta(etheta);
215 houghpattern->setERTheta(0.);
216 houghpattern->setEPhi(ephi);
217 houghpattern->setECurvature(curvature);
219 ATH_MSG_VERBOSE(
" number of hits added to pattern: " << houghpattern->size());
Scalar phi() const
phi method
Scalar theta() const
theta method
#define ATH_MSG_VERBOSE(x)
Histogram class, similar to Root's TH2D.
static void thetasForCurvedHit(double ratio, MuonHoughHit *hit, double &theta1, double &theta2)
calculates theta at (x,y,z) for curved track model, for positive and negative curvature
static double thetaForCurvedHit(double invcurvature, MuonHoughHit *hit)
calculates theta at (x,y,z) for curved track model
static int sgn(double d)
sign (-1 or 1) of a double
static double signedDistanceCurvedToHit(double z0, double theta, double invcurvature, const Amg::Vector3D &hit)
calculates distance of point (x,y,z) to curved track with z0, theta and invcurvature for curved track...
singleton-like access to IMessageSvc via open function and helper
@ hough_curved_at_a_cylinder
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.