10 double threshold_histo,
int number_of_sectors) :
11 MuonHoughTransformer(
"MuonHoughTransformer_rzcosmics", nbins, nbins_angle, detectorsize, detectorsize_angle,
12 threshold_histo, number_of_sectors) {
42 const double invradius = 1. / hit->getRadius();
43 const double hitx = hit->getHitx();
44 const double hity = hit->getHity();
45 const double hitz = hit->getHitz();
49 const double dotprod = rphi * invradius;
64 int filled_binnumber = histo->fill(rz0, theta_in_grad, weight);
67 double half_weight = 0.5 * weight;
85 return filled_binnumber;
89 std::pair<double, double> coordsmaximum,
90 double maximum_residu_mm,
double ,
91 int maxsector)
const {
95 double eradius{0.}, er0{0.};
97 const double rz0 = coordsmaximum.first;
99 const double phimax =
m_phisec[maxsector];
101 ATH_MSG_VERBOSE(
"hookAssociateHitsToMaximum() -- sector: " << maxsector <<
" phimax: " << phimax
102 <<
" coordsmaximumfirst: " << rz0 <<
" coordsmaximumsecond: " << coordsmaximum.second
103 <<
" coordsmaximumsecondinrad: " <<
theta <<
", size of event: " << event.size());
104 for (
unsigned int i = 0; i <
event.size(); i++) {
105 const double hitx =
event.getHitx(i);
106 const double hity =
event.getHity(i);
109 const double hitz =
event.getHitz(i);
114 ATH_MSG_VERBOSE(
"MuonHoughTransformer_rzcosmics() -- hitx: " << hitx <<
" hity: " << hity <<
" hitz: " << hitz
115 <<
" perp: " <<
perp <<
", residu_distance: " << residu_distance );
117 if (std::abs(residu_distance) < maximum_residu_mm)
119 ATH_MSG_VERBOSE(
"hit added to houghpattern! detector: " << event.getHit(i)->getWhichDetector()
120 <<
" already associated "<< event.getHit(i)->getAssociated());
121 houghpattern->addHit(event.getHit(i));
122 event.getHit(i)->setAssociated(
true);
124 double rz0hit = residu_distance + rz0;
133 eradius = eradius / (houghpattern->size() + 1e-7);
134 er0 = er0 / (houghpattern->size() + 1e-7);
136 houghpattern->setEPhi(phimax);
137 houghpattern->setERPhi(er0);
138 houghpattern->setETheta(
theta);
139 houghpattern->setERTheta(eradius);
140 houghpattern->setECurvature(1.);
142 if (houghpattern->empty()) {
146 else if (std::abs(eradius - rz0) > 500.) {
147 ATH_MSG_VERBOSE(
"Eradius or Etheta calc. WRONG -- rz0: " << rz0 <<
" theta: "
148 <<
theta<<
", eradius: " << eradius);
150 houghpattern->setERTheta(rz0);
155 ATH_MSG_VERBOSE(
"updateParameterstheta new phi: " << houghpattern->getEPhi()
156 <<
" old phi: " << phimax <<
", new r0: " << houghpattern->getERPhi()
157 <<
" old r0: " << er0 <<
" new theta: " << houghpattern->getETheta()
158 <<
" old theta: " <<
theta <<
" new z0: " << houghpattern->getERTheta()
159 <<
" old z0: " << eradius );
172 double dotprod)
const
177 double dotprod_part = 0.5 + 0.5 * dotprod * dotprod;
178 double sintheta_part = 0.9 + 0.1 * sintheta * sintheta;
179 double sinphi_part = 0.75 + 0.25 * sinphi * sinphi;
180 float r_theta_weight = dotprod_part * sintheta_part * sinphi_part;
192 const unsigned int size = houghpattern->
size();
194 if (size <= 1)
return;
197 const double cosphi = std::cos(
phi);
198 const double sinphi = std::sin(
phi);
200 double sum_radii = 0.;
203 for (
unsigned int i = 0; i < size; i++) {
204 sum_radii += houghpattern->
getHitx(i) * cosphi + houghpattern->
getHity(i) * sinphi;
205 sum_z += houghpattern->
getHitz(i);
208 const double av_radii = sum_radii / (size + 0.);
209 const double av_z = sum_z / (size + 0.);
213 for (
unsigned int i = 0; i < size; i++) {
214 double radius = houghpattern->
getHitx(i) * cosphi + houghpattern->
getHity(i) * sinphi;
215 double hitz = houghpattern->
getHitz(i);
216 double r_offset = radius - av_radii;
217 double z_offset = hitz - av_z;
218 double weight = r_offset * r_offset + z_offset * z_offset;
220 if (r_offset * radius + z_offset * hitz < 0) {
sign = -1; }
221 sumr += weight *
sign * r_offset;
222 sumz += weight *
sign * z_offset;
225 if (std::abs(sumr) < 0.000001 || std::abs(sumz) < 0.000001) {
return; }
227 double theta = std::atan2(sumr, sumz);
232 double offset = 0.02;
233 if (
theta < offset) {
241 const double rz0 = av_z * std::sin(
theta) - av_radii * std::cos(
theta);
Scalar perp() const
perp method - perpendicular length
Scalar phi() const
phi method
Scalar theta() const
theta method
#define ATH_MSG_VERBOSE(x)
Histogram class, similar to Root's TH2D.
unsigned int size() const
returns size of hitcontainer
double getHitx(unsigned int hitno) const
returns x position of hit hitno
double getHity(unsigned int hitno) const
returns y position of hit hitno
double getHitz(unsigned int hitno) const
returns z position of hit hitno
static double signedDistanceToLine(double x0, double y0, double r0, double phi)
distance from (x0,y0) to the line (r0,phi), phi in rad
double getEPhi() const
returns phi of pattern
void setETheta(double etheta)
set theta of pattern
void setERTheta(double ertheta)
set z0 of pattern
constexpr double degree_rad_conversion_factor
Helper to simultaneously calculate sin and cos of the same angle.
Helper to simultaneously calculate sin and cos of the same angle.