CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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

Definition at line 43 of file ThirdHitPredictionFromInvParabola.h.

Definition at line 41 of file ThirdHitPredictionFromInvParabola.h.

Definition at line 42 of file ThirdHitPredictionFromInvParabola.h.

Definition at line 40 of file ThirdHitPredictionFromInvParabola.h.

Definition at line 39 of file ThirdHitPredictionFromInvParabola.h.

Constructor & Destructor Documentation

ThirdHitPredictionFromInvParabola::ThirdHitPredictionFromInvParabola ( )
inline

Definition at line 45 of file ThirdHitPredictionFromInvParabola.h.

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

Definition at line 46 of file ThirdHitPredictionFromInvParabola.h.

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

48  init(x1, y1, x2, y2, ip, std::abs(curv));
49  }
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
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

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

Definition at line 92 of file ThirdHitPredictionFromInvParabola.h.

References c, overDu, pv, and u1u2.

Referenced by findPointAtCurve(), and predV().

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

Definition at line 97 of file ThirdHitPredictionFromInvParabola.h.

References c, dv, overDu, and su.

Referenced by findPointAtCurve(), and predV().

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

Definition at line 114 of file ThirdHitPredictionFromInvParabola.h.

References A, a, alpha, B, c, coeffA(), coeffB(), CommonMethods::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 }
Scalar coeffA(Scalar impactParameter) const
float alpha
Definition: AMPTWrapper.h:105
const edm::EventSetup & c
Definition: APVGainStruct.h:7
T sqrt(T t)
Definition: SSEVec.h:19
Scalar coeffB(Scalar impactParameter) const
double a
Definition: hdecay.h:119
Definition: APVGainStruct.h:7
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  }
T y() const
Definition: PV3DBase.h:60
void init(const GlobalPoint &P1, const GlobalPoint &P2, Scalar ip, Scalar curv)
T x() const
Definition: PV3DBase.h:59
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(), SiStripPI::max, SiStripPI::min, overDu, fireworks::p1, fireworks::p2, pv, su, theIpRangeMinus, theIpRangePlus, theRotation, transform(), u1u2, Basic2DVector< T >::x(), and Basic2DVector< T >::y().

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 }
const TString p2
Definition: fwPaths.cc:13
bool empty() const
const TString p1
Definition: fwPaths.cc:12
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
Scalar ipFromCurvature(Scalar curvature, bool pos) const
PixelRecoRange< T > intersection(const PixelRecoRange< T > &r) const
ThirdHitPredictionFromInvParabola::Scalar ThirdHitPredictionFromInvParabola::ipFromCurvature ( Scalar  curvature,
bool  pos 
) const
inlineprivate

Definition at line 102 of file ThirdHitPredictionFromInvParabola.h.

References overDu, pv, 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)
Range ThirdHitPredictionFromInvParabola::operator() ( Scalar  radius,
int  charge 
) const
inline

Definition at line 55 of file ThirdHitPredictionFromInvParabola.h.

References rangeRPhi().

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

Definition at line 57 of file ThirdHitPredictionFromInvParabola.h.

References rangeRPhi().

57 { return rangeRPhi(radius); }
Range rangeRPhi(Scalar radius, int charge) const
ThirdHitPredictionFromInvParabola::Scalar ThirdHitPredictionFromInvParabola::predV ( Scalar  u,
Scalar  ip 
) const
inlineprivate

Definition at line 109 of file ThirdHitPredictionFromInvParabola.h.

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

109  {
110  auto c = -(coeffA(ip) - coeffB(ip * u) - ip * u * u);
111  return c;
112 }
Scalar coeffA(Scalar impactParameter) const
const edm::EventSetup & c
Scalar coeffB(Scalar impactParameter) const
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 >::intersection(), PixelRecoRange< T >::max(), PixelRecoRange< T >::min(), diffTwoXMLs::r1, diffTwoXMLs::r2, TkRotation2D< T >::rotateBack(), std::swap(), theIpRangeMinus, theIpRangePlus, theRotation, and theTolerance.

Referenced by operator()().

71  {
72  bool pos = icharge > 0;
73 
74  RangeD ip = (pos) ? theIpRangePlus : theIpRangeMinus;
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 }
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
void findPointAtCurve(Scalar radius, Scalar ip, Scalar &u, Scalar &v) const
BasicVector rotateBack(const BasicVector &v) const
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 >::intersection(), PixelRecoRange< T >::max(), PixelRecoRange< T >::min(), diffTwoXMLs::r1, diffTwoXMLs::r2, std::swap(), theIpRangeMinus, theIpRangePlus, theRotation, theTolerance, x, TkRotation2D< T >::x(), mkfit::Config::xr, 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 }
T max() const
BasicVector x() const
T min() const
BasicVector y() const
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
void findPointAtCurve(Scalar radius, Scalar ip, Scalar &u, Scalar &v) const
constexpr float xr
Point2D ThirdHitPredictionFromInvParabola::transform ( Point2D const &  p) const
inlineprivate

Definition at line 76 of file ThirdHitPredictionFromInvParabola.h.

References Basic2DVector< T >::mag2(), TkRotation2D< T >::rotate(), and theRotation.

Referenced by init().

76 { return theRotation.rotate(p) / p.mag2(); }
BasicVector rotate(const BasicVector &v) const
Point2D ThirdHitPredictionFromInvParabola::transformBack ( Point2D const &  p) const
inlineprivate

Friends And Related Function Documentation

Member Data Documentation

Scalar ThirdHitPredictionFromInvParabola::dv
private

Definition at line 82 of file ThirdHitPredictionFromInvParabola.h.

Referenced by coeffB(), and init().

bool ThirdHitPredictionFromInvParabola::emptyM
private

Definition at line 89 of file ThirdHitPredictionFromInvParabola.h.

Referenced by init(), and rangeRPhi().

bool ThirdHitPredictionFromInvParabola::emptyP
private

Definition at line 89 of file ThirdHitPredictionFromInvParabola.h.

Referenced by init(), and rangeRPhi().

Scalar ThirdHitPredictionFromInvParabola::overDu
private

Definition at line 82 of file ThirdHitPredictionFromInvParabola.h.

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

Scalar ThirdHitPredictionFromInvParabola::pv
private

Definition at line 82 of file ThirdHitPredictionFromInvParabola.h.

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

Scalar ThirdHitPredictionFromInvParabola::su
private

Definition at line 82 of file ThirdHitPredictionFromInvParabola.h.

Referenced by coeffB(), and init().

RangeD ThirdHitPredictionFromInvParabola::theIpRangeMinus
private

Definition at line 87 of file ThirdHitPredictionFromInvParabola.h.

Referenced by init(), and rangeRPhi().

RangeD ThirdHitPredictionFromInvParabola::theIpRangePlus
private

Definition at line 87 of file ThirdHitPredictionFromInvParabola.h.

Referenced by init(), and rangeRPhi().

Rotation ThirdHitPredictionFromInvParabola::theRotation
private

Definition at line 81 of file ThirdHitPredictionFromInvParabola.h.

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

Scalar ThirdHitPredictionFromInvParabola::theTolerance
private

Definition at line 88 of file ThirdHitPredictionFromInvParabola.h.

Referenced by rangeRPhi().

Scalar ThirdHitPredictionFromInvParabola::u1u2
private

Definition at line 82 of file ThirdHitPredictionFromInvParabola.h.

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