CMS 3D CMS Logo

ThirdHitPredictionFromInvLine.cc
Go to the documentation of this file.
2 
3 #include <cmath>
6 
9 
10 template <class T>
11 T sqr(T t) {
12  return t * t;
13 }
14 
18 
19 #include <iostream>
20 
21 using namespace std;
22 
24  const GlobalPoint &P2,
25  double errorRPhiP1,
26  double errorRPhiP2)
27  : nPoints(0),
28  theSum(0.),
29  theSumU(0.),
30  theSumUU(0.),
31  theSumV(0.),
32  theSumUV(0.),
33  theSumVV(0.),
34  hasParameters(false),
35  theCurvatureValue(0.),
36  theCurvatureError(0.),
37  theChi2(0.) {
38  GlobalVector aX = GlobalVector(P1.x(), P1.y(), 0.).unit();
39  GlobalVector aY(-aX.y(), aX.x(), 0.);
40  GlobalVector aZ(0., 0., 1.);
41  theRotation = Rotation(aX, aY, aZ);
42 
43  add(P1, errorRPhiP1);
44  add(P2, errorRPhiP2);
45 }
46 
48  double A = -(theSum * theSumUV - theSumU * theSumV) / (sqr(theSumU) - theSum * theSumUU);
49  double B = (theSumU * theSumUV - theSumUU * theSumV) / (sqr(theSumU) - theSum * theSumUU);
50  double delta = sqr(2. * A * B) - 4 * (1 + sqr(A)) * (sqr(B) - sqr(1 / radius));
51  double sqrtdelta = (delta > 0.) ? sqrt(delta) : 0.;
52  double u1 = (-2. * A * B + sqrtdelta) / 2. / (1 + sqr(A));
53  double v1 = A * u1 + B;
54  Point2D tmp = PointUV(u1, v1, &theRotation).unmap();
55  return GlobalPoint(tmp.x(), tmp.y(), 0.);
56 }
57 
58 void ThirdHitPredictionFromInvLine::add(const GlobalPoint &p, double errorRPhi) {
59  double weigth = sqr(sqr(p.perp()) / errorRPhi);
60  add(PointUV(Point2D(p.x(), p.y()), &theRotation), weigth);
61 }
62 
64  hasParameters = false;
65  nPoints++;
66  theSum += weigth;
67  theSumU += point.u() * weigth;
68  theSumUU += sqr(point.u()) * weigth;
69  theSumV += point.v() * weigth;
70  theSumUV += point.u() * point.v() * weigth;
71  theSumVV += sqr(point.v()) * weigth;
72  check();
73 }
74 
75 void ThirdHitPredictionFromInvLine::remove(const GlobalPoint &p, double errorRPhi) {
76  hasParameters = false;
77  PointUV point(Point2D(p.x(), p.y()), &theRotation);
78  double weigth = sqr(sqr(p.perp()) / errorRPhi);
79  nPoints--;
80  theSum -= weigth;
81  theSumU -= point.u() * weigth;
82  theSumUU -= sqr(point.u()) * weigth;
83  theSumV -= point.v() * weigth;
84  theSumUV -= point.u() * point.v() * weigth;
85  theSumVV -= sqr(point.v()) * weigth;
86  check();
87 }
88 
90  std::cout << " nPoints: " << nPoints << " theSumU: " << theSumU << " theSumUU: " << theSumUU
91  << " theSumV: " << theSumV << " theSumUV: " << theSumUV << std::endl;
92 }
93 
95  if (hasParameters)
96  return;
97 
98  long double D = theSumUU * theSum - theSumU * theSumU;
99  long double A = (theSumUV * theSum - theSumU * theSumV) / D;
100  long double B = (theSumUU * theSumV - theSumUV * theSumU) / D;
101  double rho = 2. * fabs(B) / sqrt(1 + sqr(A));
102  double sigmaA2 = theSum / D;
103  double sigmaB2 = theSumUU / D;
104 
105  hasParameters = true;
106  theCurvatureError = sqrt(sqr(rho / B) * sigmaB2 + sqr(rho / (1 + sqr(A))) * sigmaA2);
107  theCurvatureValue = 2. * fabs(B) / sqrt(1 + sqr(A));
108  theChi2 = theSumVV - 2 * A * theSumUV - 2 * B * theSumV + 2 * A * B * theSumU + B * B * theSum + A * A * theSumUU;
109 }
110 
111 /*
112 GlobalPoint ThirdHitPredictionFromInvLine::center() const
113 {
114  long double den = theSumU*theSumUV - theSumUU*theSumV;
115  double a = (theSum*theSumUV-theSumU*theSumV)/2./den;
116  double b = (sqr(theSumU)-theSum*theSumUU)/2./den;
117  Point3D tmp = theRotation.multiplyInverse( Point2D(a,b) );
118  return GlobalPoint(tmp.x(), tmp.y(), 0.);
119 }
120 */
void add(const GlobalPoint &p, double erroriRPhi=1.)
Basic2DVector< double > Point2D
Definition: APVGainStruct.h:7
void remove(const GlobalPoint &p, double erroriRPhi=1.)
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
GlobalPoint crossing(double radius) const
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60
T sqrt(T t)
Definition: SSEVec.h:19
PixelRecoRange< double > Ranged
DecomposeProduct< arg, typename Div::arg > D
Definition: Factorize.h:141
Basic3DVector< double > Point3D
Definition: APVGainStruct.h:7
Vector3DBase unit() const
Definition: Vector3DBase.h:54
ThirdHitPredictionFromInvLine(const GlobalPoint &P1, const GlobalPoint &P2, double errorRPhiP1=1., double errorRPhiP2=1.)
tmp
align.sh
Definition: createJobs.py:716
long double T
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
Definition: invegas.h:5
Global3DVector GlobalVector
Definition: GlobalVector.h:10