ATLAS Offline Software
Classes | Public Member Functions | Private Attributes | List of all members
FPGATrackSimGenScanKeyLyrHelper Class Reference

#include <FPGATrackSimGenScanBinning.h>

Collaboration diagram for FPGATrackSimGenScanKeyLyrHelper:

Classes

struct  KeyLyrPars
 
struct  rotatedConfig
 

Public Member Functions

 FPGATrackSimGenScanKeyLyrHelper (double r1, double r2)
 
std::pair< double, double > getXY (double r, double phi) const
 
std::pair< double, double > getRotationAngles (const std::pair< double, double > &xy1, const std::pair< double, double > &xy2) const
 
std::pair< double, double > rotateXY (const std::pair< double, double > &xy, const std::pair< double, double > &ang) const
 
rotatedConfig getRotatedConfig (const KeyLyrPars &keypars) const
 
std::pair< double, double > getRotatedHit (const std::pair< double, double > &rotang, const FPGATrackSimHit *hit) const
 
KeyLyrPars trackParsToKeyPars (const FPGATrackSimTrackPars &pars) const
 
FPGATrackSimTrackPars keyParsToTrackPars (const KeyLyrPars &keypars) const
 
double zExpected (KeyLyrPars keypars, double r) const
 
double xExpected (KeyLyrPars keypars, const FPGATrackSimHit *hit) const
 
double xmForHit (KeyLyrPars keypars, const FPGATrackSimHit *hit) const
 
double deltaX (KeyLyrPars keypars, const FPGATrackSimHit *hit) const
 
double R1 () const
 
double R2 () const
 

Private Attributes

double m_R1
 
double m_R2
 

Detailed Description

Definition at line 313 of file FPGATrackSimGenScanBinning.h.

Constructor & Destructor Documentation

◆ FPGATrackSimGenScanKeyLyrHelper()

FPGATrackSimGenScanKeyLyrHelper::FPGATrackSimGenScanKeyLyrHelper ( double  r1,
double  r2 
)
inline

Definition at line 316 of file FPGATrackSimGenScanBinning.h.

316 : m_R1(r1), m_R2(r2) {}

Member Function Documentation

◆ deltaX()

double FPGATrackSimGenScanKeyLyrHelper::deltaX ( KeyLyrPars  keypars,
const FPGATrackSimHit hit 
) const

Definition at line 363 of file FPGATrackSimGenScanBinning.cxx.

364 {
365  auto rotated_coords = getRotatedConfig(keypars);
366 
367  auto rotang = rotated_coords.rotang;
368 
369  auto xyhp = getRotatedHit(rotang, hit);
370 
371  double xh = xyhp.first-rotated_coords.xy1p.first;
372 
373  return xh - xExpected(keypars,hit);
374 }

◆ getRotatedConfig()

FPGATrackSimGenScanKeyLyrHelper::rotatedConfig FPGATrackSimGenScanKeyLyrHelper::getRotatedConfig ( const KeyLyrPars keypars) const

Definition at line 239 of file FPGATrackSimGenScanBinning.cxx.

240 {
241  rotatedConfig result;
242 
243  auto xy1 = getXY(m_R1, keypars.phi1);
244  auto xy2 = getXY(m_R2, keypars.phi2);
245 
246  result.rotang = getRotationAngles(xy1, xy2);
247  result.xy1p = rotateXY(xy1, result.rotang);
248  result.xy2p = rotateXY(xy2, result.rotang);
249  result.y = result.xy2p.second - result.xy1p.second;
250 
251  return result;
252 }

◆ getRotatedHit()

std::pair< double, double > FPGATrackSimGenScanKeyLyrHelper::getRotatedHit ( const std::pair< double, double > &  rotang,
const FPGATrackSimHit hit 
) const

Definition at line 254 of file FPGATrackSimGenScanBinning.cxx.

255 {
256  auto xyh = getXY(hit->getR(), hit->getGPhi());
257  return rotateXY(xyh, rotang);
258 }

◆ getRotationAngles()

std::pair< double, double > FPGATrackSimGenScanKeyLyrHelper::getRotationAngles ( const std::pair< double, double > &  xy1,
const std::pair< double, double > &  xy2 
) const

Definition at line 223 of file FPGATrackSimGenScanBinning.cxx.

224 {
225  double dr12x = xy2.first - xy1.first;
226  double dr12y = xy2.second - xy1.second;
227  double dr12mag = std::hypot(dr12x, dr12y);
228  double cos_rot = dr12y / dr12mag;
229  double sin_rot = -dr12x / dr12mag;
230  return std::pair<double, double>(cos_rot, sin_rot);
231 }

◆ getXY()

std::pair< double, double > FPGATrackSimGenScanKeyLyrHelper::getXY ( double  r,
double  phi 
) const

Definition at line 218 of file FPGATrackSimGenScanBinning.cxx.

219 {
220  return std::pair<double, double>(r * cos(phi), r * sin(phi));
221 }

◆ keyParsToTrackPars()

FPGATrackSimTrackPars FPGATrackSimGenScanKeyLyrHelper::keyParsToTrackPars ( const KeyLyrPars keypars) const

Definition at line 286 of file FPGATrackSimGenScanBinning.cxx.

287 {
288 
290  pars[FPGATrackSimTrackPars::IZ0] = (keypars.z1 * m_R2 - keypars.z2 * m_R1) / (m_R2 - m_R1);
292 
293  // This is the exact math which is a bit messy
294  // if you want the math contact lipeles@sas.upenn.edu
295 
296  double xm = keypars.xm;
297 
298  auto rotated_coords = getRotatedConfig(keypars);
299  auto xy1p = rotated_coords.xy1p;
300  auto rotang = rotated_coords.rotang;
301  auto y = rotated_coords.y;
302 
303  // reverse rotation
304  auto revang = rotang;
305  revang.second = -rotang.second;
306 
307  if (xm != 0)
308  {
309  double Rinv = 2 * xm / (xm * xm + (y / 2) * (y / 2));
310  double d = (y * y / 4.0 - xm * xm) / (2.0 * xm);
311  double sign = (xm > 0) - (xm < 0);
312 
314 
315  std::pair<double, double> xycp(-d + xy1p.first, y / 2.0 + xy1p.second);
316 
317  pars[FPGATrackSimTrackPars::ID0] = -1 * sign * (std::abs(1 / Rinv) - std::hypot(xycp.first, xycp.second));
318 
319  auto xyc = rotateXY(xycp, revang);
320 
321  pars[FPGATrackSimTrackPars::IPHI] = atan2(sign * -xyc.first, sign * xyc.second);
322  }
323  else
324  {
326  pars[FPGATrackSimTrackPars::ID0] = -1 * xy1p.first;
327  pars[FPGATrackSimTrackPars::IPHI] = atan2(rotang.first, -rotang.second);
328  }
329 
330  return pars;
331 }

◆ R1()

double FPGATrackSimGenScanKeyLyrHelper::R1 ( ) const
inline

Definition at line 366 of file FPGATrackSimGenScanBinning.h.

366 {return m_R1;}

◆ R2()

double FPGATrackSimGenScanKeyLyrHelper::R2 ( ) const
inline

Definition at line 367 of file FPGATrackSimGenScanBinning.h.

367 {return m_R2;}

◆ rotateXY()

std::pair< double, double > FPGATrackSimGenScanKeyLyrHelper::rotateXY ( const std::pair< double, double > &  xy,
const std::pair< double, double > &  ang 
) const

Definition at line 233 of file FPGATrackSimGenScanBinning.cxx.

234 {
235  return std::pair<double, double>(xy.first * ang.first + xy.second * ang.second,
236  -xy.first * ang.second + xy.second * ang.first);
237 }

◆ trackParsToKeyPars()

FPGATrackSimGenScanKeyLyrHelper::KeyLyrPars FPGATrackSimGenScanKeyLyrHelper::trackParsToKeyPars ( const FPGATrackSimTrackPars pars) const

Definition at line 260 of file FPGATrackSimGenScanBinning.cxx.

261 {
262  KeyLyrPars retv;
267 
269  if (Rinv != 0)
270  {
271  double R = 1 / Rinv;
272  auto xy1 = getXY(m_R1, retv.phi1);
273  auto xy2 = getXY(m_R2, retv.phi2);
274  double ysqr = (xy2.first - xy1.first) * (xy2.first - xy1.first) + (xy2.second - xy1.second) * (xy2.second - xy1.second);
275  double sign = (R > 0) - (R < 0);
276  retv.xm = -1 * sign * (std::abs(R) - sqrt(R * R - ysqr / 4.0));
277  }
278  else
279  {
280  retv.xm = 0;
281  }
282 
283  return retv;
284 }

◆ xExpected()

double FPGATrackSimGenScanKeyLyrHelper::xExpected ( KeyLyrPars  keypars,
const FPGATrackSimHit hit 
) const

Definition at line 377 of file FPGATrackSimGenScanBinning.cxx.

378 {
379  auto rotated_coords = getRotatedConfig(keypars);
380 
381  auto rotang = rotated_coords.rotang;
382  auto y = rotated_coords.y;
383 
384  auto xyhp = getRotatedHit(rotang, hit);
385 
386  double yh = xyhp.second-rotated_coords.xy1p.second;
387 
388  return keypars.xm * (keypars.xm * keypars.xm + yh * (y - yh)) / (keypars.xm * keypars.xm + (y / 2) * (y / 2));
389 }

◆ xmForHit()

double FPGATrackSimGenScanKeyLyrHelper::xmForHit ( KeyLyrPars  keypars,
const FPGATrackSimHit hit 
) const

Definition at line 339 of file FPGATrackSimGenScanBinning.cxx.

340 {
341  auto rotated_coords = getRotatedConfig(keypars);
342  auto xy1p = rotated_coords.xy1p;
343  auto rotang = rotated_coords.rotang;
344  auto y = rotated_coords.y;
345 
346  auto xyhp = getRotatedHit(rotang, hit);
347  double xh = xyhp.first - xy1p.first;
348  double yh = xyhp.second - xy1p.second;
349 
350  // use taylor expanded xm calculation
351  double sign = ((yh > 0) && (yh < y)) ? 1 : -1;
352  if ((std::abs(yh) < std::abs(xh)) || (std::abs(y - yh) < std::abs(xh)))
353  {
354  return ((xh > 0) ? 1 : -1) * 100000;
355  }
356 
357  double xm_taylor = sign * y * y / (y * y - 4 * xh * xh - 4 * (yh - y / 2.0) * (yh - y / 2.0)) * xh;
358 
359  return xm_taylor;
360 }

◆ zExpected()

double FPGATrackSimGenScanKeyLyrHelper::zExpected ( KeyLyrPars  keypars,
double  r 
) const

Definition at line 333 of file FPGATrackSimGenScanBinning.cxx.

334 {
335  return (keypars.z2 - keypars.z1) / (m_R2 - m_R1) * (r - m_R1) + keypars.z1;
336 }

Member Data Documentation

◆ m_R1

double FPGATrackSimGenScanKeyLyrHelper::m_R1
private

Definition at line 370 of file FPGATrackSimGenScanBinning.h.

◆ m_R2

double FPGATrackSimGenScanKeyLyrHelper::m_R2
private

Definition at line 371 of file FPGATrackSimGenScanBinning.h.


The documentation for this class was generated from the following files:
make_hlt_rep.pars
pars
Definition: make_hlt_rep.py:90
FPGATrackSimGenScanGeomHelpers::phiFromPars
static double phiFromPars(double r, const FPGATrackSimTrackPars &pars)
Definition: FPGATrackSimGenScanBinning.cxx:197
FPGATrackSimTrackPars::IHIP
@ IHIP
Definition: FPGATrackSimTrackPars.h:49
beamspotman.r
def r
Definition: beamspotman.py:676
FPGATrackSimTrackPars::ID0
@ ID0
Definition: FPGATrackSimTrackPars.h:49
get_generator_info.result
result
Definition: get_generator_info.py:21
FPGATrackSimGenScanKeyLyrHelper::rotateXY
std::pair< double, double > rotateXY(const std::pair< double, double > &xy, const std::pair< double, double > &ang) const
Definition: FPGATrackSimGenScanBinning.cxx:233
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:67
FPGATrackSimGenScanGeomHelpers::CurvatureConstant
static constexpr double CurvatureConstant
Definition: FPGATrackSimGenScanBinning.h:221
FPGATrackSimGenScanKeyLyrHelper::getXY
std::pair< double, double > getXY(double r, double phi) const
Definition: FPGATrackSimGenScanBinning.cxx:218
FPGATrackSimTrackPars
Definition: FPGATrackSimTrackPars.h:22
hist_file_dump.d
d
Definition: hist_file_dump.py:137
FPGATrackSimTrackPars::IZ0
@ IZ0
Definition: FPGATrackSimTrackPars.h:49
FPGATrackSimGenScanKeyLyrHelper::m_R2
double m_R2
Definition: FPGATrackSimGenScanBinning.h:371
drawFromPickle.cos
cos
Definition: drawFromPickle.py:36
FPGATrackSimHit::getGPhi
float getGPhi() const
Definition: FPGATrackSimHit.h:134
FPGATrackSimGenScanKeyLyrHelper::xExpected
double xExpected(KeyLyrPars keypars, const FPGATrackSimHit *hit) const
Definition: FPGATrackSimGenScanBinning.cxx:377
FPGATrackSimGenScanKeyLyrHelper::getRotatedHit
std::pair< double, double > getRotatedHit(const std::pair< double, double > &rotang, const FPGATrackSimHit *hit) const
Definition: FPGATrackSimGenScanBinning.cxx:254
sign
int sign(int a)
Definition: TRT_StrawNeighbourSvc.h:107
AnalysisUtils::Delta::R
double R(const INavigable4Momentum *p1, const double v_eta, const double v_phi)
Definition: AnalysisMisc.h:49
FPGATrackSimGenScanKeyLyrHelper::getRotationAngles
std::pair< double, double > getRotationAngles(const std::pair< double, double > &xy1, const std::pair< double, double > &xy2) const
Definition: FPGATrackSimGenScanBinning.cxx:223
FPGATrackSimGenScanKeyLyrHelper::getRotatedConfig
rotatedConfig getRotatedConfig(const KeyLyrPars &keypars) const
Definition: FPGATrackSimGenScanBinning.cxx:239
FPGATrackSimTrackPars::IPHI
@ IPHI
Definition: FPGATrackSimTrackPars.h:49
FPGATrackSimHit::getR
float getR() const
Definition: FPGATrackSimHit.h:133
y
#define y
drawFromPickle.sin
sin
Definition: drawFromPickle.py:36
FPGATrackSimGenScanKeyLyrHelper::m_R1
double m_R1
Definition: FPGATrackSimGenScanBinning.h:370
FPGATrackSimGenScanGeomHelpers::EtaFromTheta
static double EtaFromTheta(double theta)
Definition: FPGATrackSimGenScanBinning.cxx:181
FPGATrackSimGenScanGeomHelpers::zFromPars
static double zFromPars(double r, const FPGATrackSimTrackPars &pars)
Definition: FPGATrackSimGenScanBinning.cxx:186
FPGATrackSimTrackPars::IETA
@ IETA
Definition: FPGATrackSimTrackPars.h:49