CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Member Functions | Private Attributes | Friends
ThirdHitPredictionFromInvParabola Class Reference

#include <ThirdHitPredictionFromInvParabola.h>

Public Types

typedef Basic2DVector< ScalarPoint2D
 
typedef PixelRecoRange< float > Range
 
typedef PixelRecoRange< ScalarRangeD
 
typedef TkRotation2D< ScalarRotation
 
using Scalar = double
 

Public Member Functions

void init (const GlobalPoint &P1, const GlobalPoint &P2, Scalar ip, Scalar curv)
 
void init (Scalar x1, Scalar y1, Scalar x2, Scalar y2, Scalar ip, Scalar curv)
 
Range operator() (Scalar radius, int charge) const
 
Range operator() (Scalar radius) const
 
Range rangeRPhi (Scalar radius, int charge) const
 
Range rangeRPhi (Scalar radius) const
 
 ThirdHitPredictionFromInvParabola ()
 
 ThirdHitPredictionFromInvParabola (Scalar x1, Scalar y1, Scalar x2, Scalar y2, Scalar ip, Scalar curv, Scalar tolerance)
 
 ThirdHitPredictionFromInvParabola (const GlobalPoint &P1, const GlobalPoint &P2, Scalar ip, Scalar curv, Scalar tolerance)
 

Private Member Functions

Scalar coeffA (Scalar impactParameter) const
 
Scalar coeffB (Scalar impactParameter) const
 
void findPointAtCurve (Scalar radius, Scalar ip, Scalar &u, Scalar &v) const
 
Scalar ipFromCurvature (Scalar curvature, bool pos) const
 
Scalar predV (Scalar u, Scalar ip) const
 
Point2D transform (Point2D const &p) const
 
Point2D transformBack (Point2D const &p) const
 

Private Attributes

Scalar dv
 
bool emptyM
 
bool emptyP
 
Scalar overDu
 
Scalar pv
 
Scalar su
 
RangeD theIpRangeMinus
 
RangeD theIpRangePlus
 
Rotation theRotation
 
Scalar theTolerance
 
Scalar u1u2
 

Friends

int test::PixelTriplets_InvPrbl_prec::test ()
 
int test::PixelTriplets_InvPrbl_t::test ()
 

Detailed Description

Definition at line 33 of file ThirdHitPredictionFromInvParabola.h.

Member Typedef Documentation

◆ Point2D

Definition at line 43 of file ThirdHitPredictionFromInvParabola.h.

◆ Range

Definition at line 41 of file ThirdHitPredictionFromInvParabola.h.

◆ RangeD

Definition at line 42 of file ThirdHitPredictionFromInvParabola.h.

◆ Rotation

Definition at line 40 of file ThirdHitPredictionFromInvParabola.h.

◆ Scalar

Definition at line 39 of file ThirdHitPredictionFromInvParabola.h.

Constructor & Destructor Documentation

◆ ThirdHitPredictionFromInvParabola() [1/3]

ThirdHitPredictionFromInvParabola::ThirdHitPredictionFromInvParabola ( )
inline

Definition at line 45 of file ThirdHitPredictionFromInvParabola.h.

45 {}

◆ ThirdHitPredictionFromInvParabola() [2/3]

ThirdHitPredictionFromInvParabola::ThirdHitPredictionFromInvParabola ( Scalar  x1,
Scalar  y1,
Scalar  x2,
Scalar  y2,
Scalar  ip,
Scalar  curv,
Scalar  tolerance 
)
inline

◆ ThirdHitPredictionFromInvParabola() [3/3]

ThirdHitPredictionFromInvParabola::ThirdHitPredictionFromInvParabola ( const GlobalPoint P1,
const GlobalPoint P2,
Scalar  ip,
Scalar  curv,
Scalar  tolerance 
)

Definition at line 32 of file ThirdHitPredictionFromInvParabola.cc.

References funct::abs(), and init().

35  init(P1, P2, ip, std::abs(curv));
36 }
const double tolerance
void init(const GlobalPoint &P1, const GlobalPoint &P2, Scalar ip, Scalar curv)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22

Member Function Documentation

◆ coeffA()

ThirdHitPredictionFromInvParabola::Scalar ThirdHitPredictionFromInvParabola::coeffA ( Scalar  impactParameter) const
inlineprivate

Definition at line 92 of file ThirdHitPredictionFromInvParabola.h.

References DummyCfis::c, overDu, and u1u2.

Referenced by findPointAtCurve(), and predV().

◆ coeffB()

ThirdHitPredictionFromInvParabola::Scalar ThirdHitPredictionFromInvParabola::coeffB ( Scalar  impactParameter) const
inlineprivate

◆ findPointAtCurve()

void ThirdHitPredictionFromInvParabola::findPointAtCurve ( Scalar  radius,
Scalar  ip,
Scalar u,
Scalar v 
) const
inlineprivate

Definition at line 114 of file ThirdHitPredictionFromInvParabola.h.

References A, a, isotrackApplyRegressor::alpha, B, DummyCfis::c, coeffA(), coeffB(), dumpMFGeometry_cfg::delta, alignCSCRings::r, mathSSE::sqrt(), and findQualityFiles::v.

Referenced by rangeRPhi().

114  {
115  //
116  // assume u=(1-alpha^2/2)/r v=alpha/r
117  // solve qudratic equation neglecting aplha^4 term
118  //
119  Scalar A = coeffA(ip);
120  Scalar B = coeffB(ip);
121 
122  // Scalar overR = 1./r;
123  Scalar ipOverR = ip / r; // *overR;
124 
125  Scalar a = 0.5 * B + ipOverR;
126  Scalar c = -B + A * r - ipOverR;
127 
128  Scalar delta = 1 - 4 * a * c;
129  // Scalar sqrtdelta = (delta > 0) ? std::sqrt(delta) : 0.;
130  Scalar sqrtdelta = std::sqrt(delta);
131  // Scalar alpha = (-1+sqrtdelta)/(2*a);
132  Scalar alpha = (-2 * c) / (1 + sqrtdelta);
133 
134  v = alpha; // *overR
135  Scalar d2 = 1. - v * v; // overR*overR - v*v
136  // u = (d2 > 0) ? std::sqrt(d2) : 0.;
137  u = std::sqrt(d2);
138 
139  // u,v not rotated! not multiplied by 1/r
140 }
Definition: APVGainStruct.h:7
Scalar coeffB(Scalar impactParameter) const
Scalar coeffA(Scalar impactParameter) const
T sqrt(T t)
Definition: SSEVec.h:23
double a
Definition: hdecay.h:121
Definition: APVGainStruct.h:7

◆ init() [1/2]

void ThirdHitPredictionFromInvParabola::init ( const GlobalPoint P1,
const GlobalPoint P2,
Scalar  ip,
Scalar  curv 
)
inline

Definition at line 65 of file ThirdHitPredictionFromInvParabola.h.

References PV3DBase< T, PVType, FrameType >::x(), and PV3DBase< T, PVType, FrameType >::y().

Referenced by ThirdHitPredictionFromInvParabola().

65  {
66  init(P1.x(), P1.y(), P2.x(), P2.y(), ip, curv);
67  }
void init(const GlobalPoint &P1, const GlobalPoint &P2, Scalar ip, Scalar curv)
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60

◆ init() [2/2]

void ThirdHitPredictionFromInvParabola::init ( Scalar  x1,
Scalar  y1,
Scalar  x2,
Scalar  y2,
Scalar  ip,
Scalar  curv 
)

Definition at line 38 of file ThirdHitPredictionFromInvParabola.cc.

References funct::abs(), dv, PixelRecoRange< T >::empty(), emptyM, emptyP, PixelRecoRange< T >::intersection(), ipFromCurvature(), WZElectronSkims53X_cff::max, SiStripPI::min, overDu, LaserDQM_cfg::p1, SiStripOfflineCRack_cfg::p2, su, theIpRangeMinus, theIpRangePlus, theRotation, transform(), u1u2, testProducerWithPsetDescEmpty_cfi::x1, testProducerWithPsetDescEmpty_cfi::x2, testProducerWithPsetDescEmpty_cfi::y1, and testProducerWithPsetDescEmpty_cfi::y2.

38  {
39  // GlobalVector aX = GlobalVector( P2.x()-P1.x(), P2.y()-P1.y(), 0.).unit();
40 
41  Point2D p1(x1, y1);
42  Point2D p2(x2, y2);
44  p1 = transform(p1); // (1./P1.xy().mag(),0);
45  p2 = transform(p2);
46 
47  u1u2 = p1.x() * p2.x();
48  overDu = 1. / (p2.x() - p1.x());
49  pv = p1.y() * p2.x() - p2.y() * p1.x();
50  dv = p2.y() - p1.y();
51  su = p2.x() + p1.x();
52 
53  ip = std::abs(ip);
54  RangeD ipRange(-ip, ip);
55 
56  Scalar ipIntyPlus = ipFromCurvature(0., true);
57  Scalar ipCurvPlus = ipFromCurvature(curv, true);
58  Scalar ipCurvMinus = ipFromCurvature(curv, false);
59 
60  RangeD ipRangePlus(std::min(ipIntyPlus, ipCurvPlus), std::max(ipIntyPlus, ipCurvPlus));
61  RangeD ipRangeMinus(std::min(-ipIntyPlus, ipCurvMinus), std::max(-ipIntyPlus, ipCurvMinus));
62 
63  theIpRangePlus = ipRangePlus.intersection(ipRange);
64  theIpRangeMinus = ipRangeMinus.intersection(ipRange);
65 
68 }
Scalar ipFromCurvature(Scalar curvature, bool pos) const
bool empty() const
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
PixelRecoRange< T > intersection(const PixelRecoRange< T > &r) const

◆ ipFromCurvature()

ThirdHitPredictionFromInvParabola::Scalar ThirdHitPredictionFromInvParabola::ipFromCurvature ( Scalar  curvature,
bool  pos 
) const
inlineprivate

Definition at line 102 of file ThirdHitPredictionFromInvParabola.h.

References PixelRecoUtilities::curvature(), overDu, and u1u2.

Referenced by init().

103  {
104  Scalar overU1u2 = 1. / u1u2;
105  Scalar inInf = -pv * overDu * overU1u2;
106  return (pos ? inInf : -inInf) - curvature * overU1u2 * 0.5;
107 }
T curvature(T InversePt, const MagneticField &field)

◆ operator()() [1/2]

Range ThirdHitPredictionFromInvParabola::operator() ( Scalar  radius,
int  charge 
) const
inline

◆ operator()() [2/2]

Range ThirdHitPredictionFromInvParabola::operator() ( Scalar  radius) const
inline

Definition at line 57 of file ThirdHitPredictionFromInvParabola.h.

References CosmicsPD_Skims::radius, and rangeRPhi().

57 { return rangeRPhi(radius); }
Range rangeRPhi(Scalar radius, int charge) const

◆ predV()

ThirdHitPredictionFromInvParabola::Scalar ThirdHitPredictionFromInvParabola::predV ( Scalar  u,
Scalar  ip 
) const
inlineprivate

Definition at line 109 of file ThirdHitPredictionFromInvParabola.h.

References DummyCfis::c, coeffA(), and coeffB().

109  {
110  auto c = -(coeffA(ip) - coeffB(ip * u) - ip * u * u);
111  return c;
112 }
Scalar coeffB(Scalar impactParameter) const
Scalar coeffA(Scalar impactParameter) const

◆ rangeRPhi() [1/2]

ThirdHitPredictionFromInvParabola::Range ThirdHitPredictionFromInvParabola::rangeRPhi ( Scalar  radius,
int  charge 
) const

Definition at line 70 of file ThirdHitPredictionFromInvParabola.cc.

References PixelRecoRange< T >::empty(), findPointAtCurve(), mps_fire::i, PixelRecoRange< T >::max(), PixelRecoRange< T >::min(), diffTwoXMLs::r1, diffTwoXMLs::r2, CosmicsPD_Skims::radius, TkRotation2D< T >::rotateBack(), edm::swap(), theIpRangeMinus, theIpRangePlus, theRotation, theTolerance, and findQualityFiles::v.

Referenced by operator()().

71  {
72  bool pos = icharge > 0;
73 
75 
76  // it will vectorize with gcc 4.7 (with -O3 -fno-math-errno)
77  // change sign as intersect assume -ip for negative charge...
78  Scalar ipv[2] = {(pos) ? ip.min() : -ip.min(), (pos) ? ip.max() : -ip.max()};
79  Scalar u[2], v[2];
80  for (int i = 0; i != 2; ++i)
81  findPointAtCurve(radius, ipv[i], u[i], v[i]);
82 
83  //
84  Scalar phi1 = f_phi(theRotation.rotateBack(Point2D(u[0], v[0])));
85  Scalar phi2 = phi1 + (v[1] - v[0]);
86 
87  if (phi2 < phi1)
88  std::swap(phi1, phi2);
89 
90  if (ip.empty()) {
91  Range r1(phi1 * radius - theTolerance, phi1 * radius + theTolerance);
92  Range r2(phi2 * radius - theTolerance, phi2 * radius + theTolerance);
93  return r1.intersection(r2); // this range can be empty
94  }
95 
96  return Range(radius * phi1 - theTolerance, radius * phi2 + theTolerance);
97 }
BasicVector rotateBack(const BasicVector &v) const
void swap(Association< C > &lhs, Association< C > &rhs)
Definition: Association.h:112
void findPointAtCurve(Scalar radius, Scalar ip, Scalar &u, Scalar &v) const

◆ rangeRPhi() [2/2]

ThirdHitPredictionFromInvParabola::Range ThirdHitPredictionFromInvParabola::rangeRPhi ( Scalar  radius) const

Definition at line 99 of file ThirdHitPredictionFromInvParabola.cc.

References relativeConstraints::empty, emptyM, emptyP, findPointAtCurve(), mps_fire::i, PixelRecoRange< T >::max(), PixelRecoRange< T >::min(), diffTwoXMLs::r1, diffTwoXMLs::r2, CosmicsPD_Skims::radius, edm::swap(), theIpRangeMinus, theIpRangePlus, theRotation, theTolerance, findQualityFiles::v, x, TkRotation2D< T >::x(), y, and TkRotation2D< T >::y().

99  {
100  auto getRange = [&](Scalar phi1, Scalar phi2, bool empty) -> RangeD {
101  if (phi2 < phi1)
102  std::swap(phi1, phi2);
103  if (empty) {
104  RangeD r1(phi1 * radius - theTolerance, phi1 * radius + theTolerance);
105  RangeD r2(phi2 * radius - theTolerance, phi2 * radius + theTolerance);
106  return r1.intersection(r2);
107  }
108 
109  return RangeD(radius * phi1 - theTolerance, radius * phi2 + theTolerance);
110  };
111 
112  // it will vectorize with gcc 4.7 (with -O3 -fno-math-errno)
113  // change sign as intersect assume -ip for negative charge...
115  Scalar u[4], v[4];
116  for (int i = 0; i < 4; ++i)
117  findPointAtCurve(radius, ipv[i], u[i], v[i]);
118 
119  //
120  auto xr = theRotation.x();
121  auto yr = theRotation.y();
122 
123  Scalar phi1[2], phi2[2];
124  for (int i = 0; i < 2; ++i) {
125  auto x = xr[0] * u[i] + yr[0] * v[i];
126  auto y = xr[1] * u[i] + yr[1] * v[i];
127  phi1[i] = f_atan2f(y, x);
128  phi2[i] = phi1[i] + (v[i + 2] - v[i]);
129  }
130 
131  return getRange(phi1[1], phi2[1], emptyM).sum(getRange(phi1[0], phi2[0], emptyP));
132 }
BasicVector x() const
void swap(Association< C > &lhs, Association< C > &rhs)
Definition: Association.h:112
BasicVector y() const
void findPointAtCurve(Scalar radius, Scalar ip, Scalar &u, Scalar &v) const

◆ transform()

Point2D ThirdHitPredictionFromInvParabola::transform ( Point2D const &  p) const
inlineprivate

◆ transformBack()

Point2D ThirdHitPredictionFromInvParabola::transformBack ( Point2D const &  p) const
inlineprivate

Friends And Related Function Documentation

◆ test::PixelTriplets_InvPrbl_prec::test

◆ test::PixelTriplets_InvPrbl_t::test

Member Data Documentation

◆ dv

Scalar ThirdHitPredictionFromInvParabola::dv
private

Definition at line 82 of file ThirdHitPredictionFromInvParabola.h.

Referenced by coeffB(), and init().

◆ emptyM

bool ThirdHitPredictionFromInvParabola::emptyM
private

Definition at line 89 of file ThirdHitPredictionFromInvParabola.h.

Referenced by init(), and rangeRPhi().

◆ emptyP

bool ThirdHitPredictionFromInvParabola::emptyP
private

Definition at line 89 of file ThirdHitPredictionFromInvParabola.h.

Referenced by init(), and rangeRPhi().

◆ overDu

Scalar ThirdHitPredictionFromInvParabola::overDu
private

Definition at line 82 of file ThirdHitPredictionFromInvParabola.h.

Referenced by coeffA(), coeffB(), init(), and ipFromCurvature().

◆ pv

Scalar ThirdHitPredictionFromInvParabola::pv
private

Definition at line 82 of file ThirdHitPredictionFromInvParabola.h.

◆ su

Scalar ThirdHitPredictionFromInvParabola::su
private

Definition at line 82 of file ThirdHitPredictionFromInvParabola.h.

Referenced by coeffB(), and init().

◆ theIpRangeMinus

RangeD ThirdHitPredictionFromInvParabola::theIpRangeMinus
private

Definition at line 87 of file ThirdHitPredictionFromInvParabola.h.

Referenced by init(), and rangeRPhi().

◆ theIpRangePlus

RangeD ThirdHitPredictionFromInvParabola::theIpRangePlus
private

Definition at line 87 of file ThirdHitPredictionFromInvParabola.h.

Referenced by init(), and rangeRPhi().

◆ theRotation

Rotation ThirdHitPredictionFromInvParabola::theRotation
private

Definition at line 81 of file ThirdHitPredictionFromInvParabola.h.

Referenced by init(), rangeRPhi(), transform(), and transformBack().

◆ theTolerance

Scalar ThirdHitPredictionFromInvParabola::theTolerance
private

Definition at line 88 of file ThirdHitPredictionFromInvParabola.h.

Referenced by rangeRPhi().

◆ u1u2

Scalar ThirdHitPredictionFromInvParabola::u1u2
private

Definition at line 82 of file ThirdHitPredictionFromInvParabola.h.

Referenced by coeffA(), init(), and ipFromCurvature().