CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Private Member Functions | Private Attributes
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
 

Detailed Description

Definition at line 27 of file ThirdHitPredictionFromInvParabola.h.

Member Typedef Documentation

Definition at line 34 of file ThirdHitPredictionFromInvParabola.h.

Definition at line 32 of file ThirdHitPredictionFromInvParabola.h.

Definition at line 33 of file ThirdHitPredictionFromInvParabola.h.

Definition at line 31 of file ThirdHitPredictionFromInvParabola.h.

Definition at line 30 of file ThirdHitPredictionFromInvParabola.h.

Constructor & Destructor Documentation

ThirdHitPredictionFromInvParabola::ThirdHitPredictionFromInvParabola ( )
inline

Definition at line 36 of file ThirdHitPredictionFromInvParabola.h.

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

Definition at line 37 of file ThirdHitPredictionFromInvParabola.h.

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

38  : theTolerance(tolerance)
39  {
40  init(x1,y1,x2,y2,ip,std::abs(curv));
41  }
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 20 of file ThirdHitPredictionFromInvParabola.cc.

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

22  : theTolerance(tolerance)
23 {
24  init(P1,P2,ip,std::abs(curv));
25 }
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
ThirdHitPredictionFromInvParabola::Scalar ThirdHitPredictionFromInvParabola::coeffB ( Scalar  impactParameter) const
inlineprivate
void ThirdHitPredictionFromInvParabola::findPointAtCurve ( Scalar  radius,
Scalar  ip,
Scalar u,
Scalar v 
) const
inlineprivate

Definition at line 128 of file ThirdHitPredictionFromInvParabola.h.

References funct::A, a, alpha, trackerHits::c, coeffA(), coeffB(), delta, alignCSCRings::r, mathSSE::sqrt(), and findQualityFiles::v.

Referenced by rangeRPhi().

130 {
131  //
132  // assume u=(1-alpha^2/2)/r v=alpha/r
133  // solve qudratic equation neglecting aplha^4 term
134  //
135  Scalar A = coeffA(ip);
136  Scalar B = coeffB(ip);
137 
138  // Scalar overR = 1./r;
139  Scalar ipOverR = ip/r; // *overR;
140 
141  Scalar a = 0.5*B+ipOverR;
142  Scalar c = -B+A*r-ipOverR;
143 
144  Scalar delta = 1-4*a*c;
145  // Scalar sqrtdelta = (delta > 0) ? std::sqrt(delta) : 0.;
146  Scalar sqrtdelta = std::sqrt(delta);
147  // Scalar alpha = (-1+sqrtdelta)/(2*a);
148  Scalar alpha = (-2*c)/(1+sqrtdelta);
149 
150  v = alpha; // *overR
151  Scalar d2 = 1. - v*v; // overR*overR - v*v
152  // u = (d2 > 0) ? std::sqrt(d2) : 0.;
153  u = std::sqrt(d2);
154 
155  // u,v not rotated! not multiplied by 1/r
156 }
Scalar coeffA(Scalar impactParameter) const
dbl * delta
Definition: mlp_gen.cc:36
float alpha
Definition: AMPTWrapper.h:95
T sqrt(T t)
Definition: SSEVec.h:48
Scalar coeffB(Scalar impactParameter) const
double a
Definition: hdecay.h:121
void ThirdHitPredictionFromInvParabola::init ( const GlobalPoint P1,
const GlobalPoint P2,
Scalar  ip,
Scalar  curv 
)
inline

Definition at line 59 of file ThirdHitPredictionFromInvParabola.h.

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

Referenced by ThirdHitPredictionFromInvParabola().

59  {
60  init( P1.x(), P1.y(), P2.x(),P2.y(),ip,curv);
61  }
T y() const
Definition: PV3DBase.h:63
void init(const GlobalPoint &P1, const GlobalPoint &P2, Scalar ip, Scalar curv)
T x() const
Definition: PV3DBase.h:62
void ThirdHitPredictionFromInvParabola::init ( Scalar  x1,
Scalar  y1,
Scalar  x2,
Scalar  y2,
Scalar  ip,
Scalar  curv 
)

Definition at line 28 of file ThirdHitPredictionFromInvParabola.cc.

References funct::abs(), dv, PixelRecoRange< T >::empty(), emptyM, emptyP, PixelRecoRange< T >::intersection(), ipFromCurvature(), bookConverter::max, min(), overDu, p1, p2, pv, su, theIpRangeMinus, theIpRangePlus, theRotation, transform(), u1u2, Basic2DVector< T >::x(), and Basic2DVector< T >::y().

28  {
29 // GlobalVector aX = GlobalVector( P2.x()-P1.x(), P2.y()-P1.y(), 0.).unit();
30 
31  Point2D p1(x1,y1);
32  Point2D p2(x2,y2);
34  p1 = transform(p1); // (1./P1.xy().mag(),0);
35  p2 = transform(p2);
36 
37 
38  u1u2 = p1.x()*p2.x();
39  overDu = 1./(p2.x() - p1.x());
40  pv = p1.y()*p2.x() - p2.y()*p1.x();
41  dv = p2.y() - p1.y();
42  su = p2.x() + p1.x();
43 
44  ip = std::abs(ip);
45  RangeD ipRange(-ip, ip);
46 
47 
48  Scalar ipIntyPlus = ipFromCurvature(0.,true);
49  Scalar ipCurvPlus = ipFromCurvature(curv, true);
50  Scalar ipCurvMinus = ipFromCurvature(curv, false);
51 
52 
53  RangeD ipRangePlus(std::min(ipIntyPlus, ipCurvPlus),std::max(ipIntyPlus, ipCurvPlus));
54  RangeD ipRangeMinus(std::min(-ipIntyPlus, ipCurvMinus),std::max(-ipIntyPlus, ipCurvMinus));
55 
56  theIpRangePlus = ipRangePlus.intersection(ipRange);
57  theIpRangeMinus = ipRangeMinus.intersection(ipRange);
58 
61 
62 }
bool empty() const
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
T min(T a, T b)
Definition: MathUtil.h:58
double p2[4]
Definition: TauolaWrapper.h:90
Scalar ipFromCurvature(Scalar curvature, bool pos) const
double p1[4]
Definition: TauolaWrapper.h:89
PixelRecoRange< T > intersection(const PixelRecoRange< T > &r) const
ThirdHitPredictionFromInvParabola::Scalar ThirdHitPredictionFromInvParabola::ipFromCurvature ( Scalar  curvature,
bool  pos 
) const
inlineprivate

Definition at line 112 of file ThirdHitPredictionFromInvParabola.h.

References overDu, pv, and u1u2.

Referenced by init().

113 {
114  Scalar overU1u2 = 1./u1u2;
115  Scalar inInf = -pv*overDu*overU1u2;
116  return (pos? inInf : -inInf) -curvature*overU1u2*0.5;
117 }
T curvature(T InversePt, const edm::EventSetup &iSetup)
Range ThirdHitPredictionFromInvParabola::operator() ( Scalar  radius,
int  charge 
) const
inline

Definition at line 47 of file ThirdHitPredictionFromInvParabola.h.

References rangeRPhi().

47 { return rangeRPhi(radius,charge); }
double charge(const std::vector< uint8_t > &Ampls)
Range rangeRPhi(Scalar radius, int charge) const
Range ThirdHitPredictionFromInvParabola::operator() ( Scalar  radius) const
inline

Definition at line 49 of file ThirdHitPredictionFromInvParabola.h.

References rangeRPhi().

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

Definition at line 121 of file ThirdHitPredictionFromInvParabola.h.

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

122 {
123  auto c = -( coeffA(ip) - coeffB(ip*u) - ip*u*u);
124  return c;
125 }
Scalar coeffA(Scalar impactParameter) const
Scalar coeffB(Scalar impactParameter) const
ThirdHitPredictionFromInvParabola::Range ThirdHitPredictionFromInvParabola::rangeRPhi ( Scalar  radius,
int  charge 
) const

Definition at line 67 of file ThirdHitPredictionFromInvParabola.cc.

References Basic2DVector< T >::barePhi(), PixelRecoRange< T >::empty(), findPointAtCurve(), i, PixelRecoRange< T >::intersection(), PixelRecoRange< T >::max(), PixelRecoRange< T >::min(), diffTwoXMLs::r1, diffTwoXMLs::r2, TkRotation2D< T >::rotateBack(), std::swap(), theIpRangeMinus, theIpRangePlus, theRotation, theTolerance, and findQualityFiles::v.

Referenced by operator()().

68 {
69  bool pos = icharge>0;
70 
71  RangeD ip = (pos) ? theIpRangePlus : theIpRangeMinus;
72 
73 
74  // it will vectorize with gcc 4.7 (with -O3 -fno-math-errno)
75  // change sign as intersect assume -ip for negative charge...
76  Scalar ipv[2]={(pos)? ip.min() : -ip.min() ,(pos)? ip.max() : -ip.max()};
77  Scalar u[2], v[2];
78  for (int i=0; i!=2; ++i)
79  findPointAtCurve(radius,ipv[i],u[i],v[i]);
80 
81  //
82  Scalar phi1 = theRotation.rotateBack(Point2D(u[0],v[0])).barePhi();
83  Scalar phi2 = phi1+(v[1]-v[0]);
84 
85  if (ip.empty()) {
88  return r1.intersection(r2);
89  }
90 
91  if (phi2<phi1) std::swap(phi1, phi2);
92  return Range(radius*phi1-theTolerance, radius*phi2+theTolerance);
93 
94 
95 }
int i
Definition: DBlmapReader.cc:9
T barePhi() const
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 148 of file ThirdHitPredictionFromInvParabola.cc.

References relativeConstraints::empty, emptyM, emptyP, findPointAtCurve(), helper::getRange(), i, PixelRecoRange< T >::intersection(), PixelRecoRange< T >::max(), bookConverter::max, PixelRecoRange< T >::min(), min(), diffTwoXMLs::r1, diffTwoXMLs::r2, theIpRangeMinus, theIpRangePlus, theRotation, theTolerance, findQualityFiles::v, TkRotation2D< T >::x(), and TkRotation2D< T >::y().

149 {
150 
151  auto getRange = [&](Scalar phi1, Scalar phi2, bool empty)->RangeD {
152 
153  if (empty) {
156  return r1.intersection(r2);
157  }
158 
159  return RangeD(radius*std::min(phi1,phi2)-theTolerance, radius*std::max(phi1,phi2)+theTolerance);
160  };
161 
162 
163  // it will vectorize with gcc 4.7 (with -O3 -fno-math-errno)
164  // change sign as intersect assume -ip for negative charge...
166  Scalar u[4], v[4];
167  for (int i=0; i<4; ++i)
168  findPointAtCurve(radius,ipv[i],u[i],v[i]);
169 
170  //
171  auto xr = theRotation.x();
172  auto yr = theRotation.y();
173 
174  Scalar phi1[2],phi2[2];
175  for (int i=0; i<2; ++i) {
176  auto x = xr[0]*u[i] + yr[0]*v[i];
177  auto y = xr[1]*u[i] + yr[1]*v[i];
178  phi1[i] = atan2_fast(y,x);
179  phi2[i] = phi1[i]+(v[i+2]-v[i]);
180  }
181 
182 
183  return getRange(phi1[1],phi2[1],emptyM).sum(getRange(phi1[0],phi2[0],emptyP));
184 
185  /*
186  Scalar phi1P = theRotation.rotateBack(Point2D(u[0],v[0])).barePhi();
187  Scalar phi2P= phi1P+(v[2]-v[0]);
188 
189  Scalar phi1M = theRotation.rotateBack(Point2D(u[1],v[1])).barePhi();
190  Scalar phi2M = phi1M+(v[3]-v[1]);
191 
192 
193  return getRange(phi1M,phi2M,emptyM).sum(getRange(phi1P,phi2P,emptyP));
194 
195  */
196 
197 }
int i
Definition: DBlmapReader.cc:9
T max() const
BasicVector x() const
T min() const
BasicVector y() const
T min(T a, T b)
Definition: MathUtil.h:58
std::pair< typename T::DetSet::const_iterator, typename T::DetSet::const_iterator > getRange(const T &detset, const DetId &id)
void findPointAtCurve(Scalar radius, Scalar ip, Scalar &u, Scalar &v) const
Definition: DDAxes.h:10
Point2D ThirdHitPredictionFromInvParabola::transform ( Point2D const &  p) const
inlineprivate

Definition at line 73 of file ThirdHitPredictionFromInvParabola.h.

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

Referenced by init().

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

Member Data Documentation

Scalar ThirdHitPredictionFromInvParabola::dv
private

Definition at line 84 of file ThirdHitPredictionFromInvParabola.h.

Referenced by coeffB(), and init().

bool ThirdHitPredictionFromInvParabola::emptyM
private

Definition at line 91 of file ThirdHitPredictionFromInvParabola.h.

Referenced by init(), and rangeRPhi().

bool ThirdHitPredictionFromInvParabola::emptyP
private

Definition at line 91 of file ThirdHitPredictionFromInvParabola.h.

Referenced by init(), and rangeRPhi().

Scalar ThirdHitPredictionFromInvParabola::overDu
private

Definition at line 84 of file ThirdHitPredictionFromInvParabola.h.

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

Scalar ThirdHitPredictionFromInvParabola::pv
private

Definition at line 84 of file ThirdHitPredictionFromInvParabola.h.

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

Scalar ThirdHitPredictionFromInvParabola::su
private

Definition at line 84 of file ThirdHitPredictionFromInvParabola.h.

Referenced by coeffB(), and init().

RangeD ThirdHitPredictionFromInvParabola::theIpRangeMinus
private

Definition at line 89 of file ThirdHitPredictionFromInvParabola.h.

Referenced by init(), and rangeRPhi().

RangeD ThirdHitPredictionFromInvParabola::theIpRangePlus
private

Definition at line 89 of file ThirdHitPredictionFromInvParabola.h.

Referenced by init(), and rangeRPhi().

Rotation ThirdHitPredictionFromInvParabola::theRotation
private

Definition at line 83 of file ThirdHitPredictionFromInvParabola.h.

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

Scalar ThirdHitPredictionFromInvParabola::theTolerance
private

Definition at line 90 of file ThirdHitPredictionFromInvParabola.h.

Referenced by rangeRPhi().

Scalar ThirdHitPredictionFromInvParabola::u1u2
private

Definition at line 84 of file ThirdHitPredictionFromInvParabola.h.

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