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 37 of file ThirdHitPredictionFromInvParabola.h.

Member Typedef Documentation

Definition at line 47 of file ThirdHitPredictionFromInvParabola.h.

Definition at line 45 of file ThirdHitPredictionFromInvParabola.h.

Definition at line 46 of file ThirdHitPredictionFromInvParabola.h.

Definition at line 44 of file ThirdHitPredictionFromInvParabola.h.

Definition at line 43 of file ThirdHitPredictionFromInvParabola.h.

Constructor & Destructor Documentation

ThirdHitPredictionFromInvParabola::ThirdHitPredictionFromInvParabola ( )
inline

Definition at line 49 of file ThirdHitPredictionFromInvParabola.h.

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

Definition at line 50 of file ThirdHitPredictionFromInvParabola.h.

References funct::abs(), StGenEvtProducer_cfi::init, and RecoTauCleanerPlugins::tolerance.

52  {
53  init(x1,y1,x2,y2,ip,std::abs(curv));
54  }
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 27 of file ThirdHitPredictionFromInvParabola.cc.

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

30 {
31  init(P1,P2,ip,std::abs(curv));
32 }
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 141 of file ThirdHitPredictionFromInvParabola.h.

References patCaloMETCorrections_cff::A, a, alpha, EnergyCorrector::c, delta, alignCSCRings::r, mathSSE::sqrt(), and findQualityFiles::v.

Referenced by rangeRPhi().

143 {
144  //
145  // assume u=(1-alpha^2/2)/r v=alpha/r
146  // solve qudratic equation neglecting aplha^4 term
147  //
148  Scalar A = coeffA(ip);
149  Scalar B = coeffB(ip);
150 
151  // Scalar overR = 1./r;
152  Scalar ipOverR = ip/r; // *overR;
153 
154  Scalar a = 0.5*B+ipOverR;
155  Scalar c = -B+A*r-ipOverR;
156 
157  Scalar delta = 1-4*a*c;
158  // Scalar sqrtdelta = (delta > 0) ? std::sqrt(delta) : 0.;
159  Scalar sqrtdelta = std::sqrt(delta);
160  // Scalar alpha = (-1+sqrtdelta)/(2*a);
161  Scalar alpha = (-2*c)/(1+sqrtdelta);
162 
163  v = alpha; // *overR
164  Scalar d2 = 1. - v*v; // overR*overR - v*v
165  // u = (d2 > 0) ? std::sqrt(d2) : 0.;
166  u = std::sqrt(d2);
167 
168  // u,v not rotated! not multiplied by 1/r
169 }
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:18
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 72 of file ThirdHitPredictionFromInvParabola.h.

References PixelRecoUtilities::curvature(), StGenEvtProducer_cfi::init, PV3DBase< T, PVType, FrameType >::x(), and PV3DBase< T, PVType, FrameType >::y().

Referenced by ThirdHitPredictionFromInvParabola().

72  {
73  init( P1.x(), P1.y(), P2.x(),P2.y(),ip,curv);
74  }
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 35 of file ThirdHitPredictionFromInvParabola.cc.

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

35  {
36 // GlobalVector aX = GlobalVector( P2.x()-P1.x(), P2.y()-P1.y(), 0.).unit();
37 
38  Point2D p1(x1,y1);
39  Point2D p2(x2,y2);
41  p1 = transform(p1); // (1./P1.xy().mag(),0);
42  p2 = transform(p2);
43 
44 
45  u1u2 = p1.x()*p2.x();
46  overDu = 1./(p2.x() - p1.x());
47  pv = p1.y()*p2.x() - p2.y()*p1.x();
48  dv = p2.y() - p1.y();
49  su = p2.x() + p1.x();
50 
51  ip = std::abs(ip);
52  RangeD ipRange(-ip, ip);
53 
54 
55  Scalar ipIntyPlus = ipFromCurvature(0.,true);
56  Scalar ipCurvPlus = ipFromCurvature(curv, true);
57  Scalar ipCurvMinus = ipFromCurvature(curv, false);
58 
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 
69 }
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 125 of file ThirdHitPredictionFromInvParabola.h.

References predV(), and MetAnalyzer::pv().

Referenced by coeffB(), and init().

126 {
127  Scalar overU1u2 = 1./u1u2;
128  Scalar inInf = -pv*overDu*overU1u2;
129  return (pos? inInf : -inInf) -curvature*overU1u2*0.5;
130 }
T curvature(T InversePt, const edm::EventSetup &iSetup)
Range ThirdHitPredictionFromInvParabola::operator() ( Scalar  radius,
int  charge 
) const
inline
Range ThirdHitPredictionFromInvParabola::operator() ( Scalar  radius) const
inline

Definition at line 62 of file ThirdHitPredictionFromInvParabola.h.

References ALCARECOTkAlJpsiMuMu_cff::charge, and TCMET_cfi::radius.

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

Definition at line 134 of file ThirdHitPredictionFromInvParabola.h.

References EnergyCorrector::c.

Referenced by ipFromCurvature().

135 {
136  auto c = -( coeffA(ip) - coeffB(ip*u) - ip*u*u);
137  return c;
138 }
Scalar coeffA(Scalar impactParameter) const
Scalar coeffB(Scalar impactParameter) const
ThirdHitPredictionFromInvParabola::Range ThirdHitPredictionFromInvParabola::rangeRPhi ( Scalar  radius,
int  charge 
) const

Definition at line 74 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.

75 {
76  bool pos = icharge>0;
77 
78  RangeD ip = (pos) ? theIpRangePlus : theIpRangeMinus;
79 
80 
81  // it will vectorize with gcc 4.7 (with -O3 -fno-math-errno)
82  // change sign as intersect assume -ip for negative charge...
83  Scalar ipv[2]={(pos)? ip.min() : -ip.min() ,(pos)? ip.max() : -ip.max()};
84  Scalar u[2], v[2];
85  for (int i=0; i!=2; ++i)
86  findPointAtCurve(radius,ipv[i],u[i],v[i]);
87 
88  //
89  Scalar phi1 = f_phi(theRotation.rotateBack(Point2D(u[0],v[0])));
90  Scalar phi2 = phi1+(v[1]-v[0]);
91 
92  if (phi2<phi1) std::swap(phi1, phi2);
93 
94  if (ip.empty()) {
97  return r1.intersection(r2); // this range can be empty
98  }
99 
100  return Range(radius*phi1-theTolerance, radius*phi2+theTolerance);
101 
102 }
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 106 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(), y, and TkRotation2D< T >::y().

107 {
108 
109  auto getRange = [&](Scalar phi1, Scalar phi2, bool empty)->RangeD {
110 
111  if (phi2<phi1) std::swap(phi1, phi2);
112  if (empty) {
115  return r1.intersection(r2);
116  }
117 
118  return RangeD(radius*phi1-theTolerance, radius*phi2+theTolerance);
119  };
120 
121 
122  // it will vectorize with gcc 4.7 (with -O3 -fno-math-errno)
123  // change sign as intersect assume -ip for negative charge...
125  Scalar u[4], v[4];
126  for (int i=0; i<4; ++i)
127  findPointAtCurve(radius,ipv[i],u[i],v[i]);
128 
129  //
130  auto xr = theRotation.x();
131  auto yr = theRotation.y();
132 
133  Scalar phi1[2],phi2[2];
134  for (int i=0; i<2; ++i) {
135  auto x = xr[0]*u[i] + yr[0]*v[i];
136  auto y = xr[1]*u[i] + yr[1]*v[i];
137  phi1[i] = f_atan2f(y,x);
138  phi2[i] = phi1[i]+(v[i+2]-v[i]);
139  }
140 
141  return getRange(phi1[1],phi2[1],emptyM).sum(getRange(phi1[0],phi2[0],emptyP));
142 }
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
Point2D ThirdHitPredictionFromInvParabola::transform ( Point2D const &  p) const
inlineprivate

Definition at line 86 of file ThirdHitPredictionFromInvParabola.h.

References Basic2DVector< T >::mag2().

Referenced by init().

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

Definition at line 90 of file ThirdHitPredictionFromInvParabola.h.

References Basic2DVector< T >::mag2().

90  {
91  return theRotation.rotateBack(p)/p.mag2();
92  }
BasicVector rotateBack(const BasicVector &v) const

Friends And Related Function Documentation

Member Data Documentation

Scalar ThirdHitPredictionFromInvParabola::dv
private

Definition at line 97 of file ThirdHitPredictionFromInvParabola.h.

Referenced by init().

bool ThirdHitPredictionFromInvParabola::emptyM
private

Definition at line 104 of file ThirdHitPredictionFromInvParabola.h.

Referenced by init(), and rangeRPhi().

bool ThirdHitPredictionFromInvParabola::emptyP
private

Definition at line 104 of file ThirdHitPredictionFromInvParabola.h.

Referenced by init(), and rangeRPhi().

Scalar ThirdHitPredictionFromInvParabola::overDu
private

Definition at line 97 of file ThirdHitPredictionFromInvParabola.h.

Referenced by init().

Scalar ThirdHitPredictionFromInvParabola::pv
private

Definition at line 97 of file ThirdHitPredictionFromInvParabola.h.

Referenced by init().

Scalar ThirdHitPredictionFromInvParabola::su
private

Definition at line 97 of file ThirdHitPredictionFromInvParabola.h.

Referenced by init().

RangeD ThirdHitPredictionFromInvParabola::theIpRangeMinus
private

Definition at line 102 of file ThirdHitPredictionFromInvParabola.h.

Referenced by init(), and rangeRPhi().

RangeD ThirdHitPredictionFromInvParabola::theIpRangePlus
private

Definition at line 102 of file ThirdHitPredictionFromInvParabola.h.

Referenced by init(), and rangeRPhi().

Rotation ThirdHitPredictionFromInvParabola::theRotation
private

Definition at line 96 of file ThirdHitPredictionFromInvParabola.h.

Referenced by init(), and rangeRPhi().

Scalar ThirdHitPredictionFromInvParabola::theTolerance
private

Definition at line 103 of file ThirdHitPredictionFromInvParabola.h.

Referenced by rangeRPhi().

Scalar ThirdHitPredictionFromInvParabola::u1u2
private

Definition at line 97 of file ThirdHitPredictionFromInvParabola.h.

Referenced by init().