CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ThirdHitPredictionFromInvLine.cc
Go to the documentation of this file.
2 
3 #include <cmath>
6 
9 
10 template <class T> T sqr( T t) {return t*t;}
11 
15 
16 #include <iostream>
17 
18 using namespace std;
19 
21  const GlobalPoint & P1, const GlobalPoint & P2,
22  double errorRPhiP1, double errorRPhiP2)
23  : nPoints(0), theSum(0.), theSumU(0.), theSumUU(0.), theSumV(0.), theSumUV(0.), theSumVV(0.),
24  hasParameters(false), theCurvatureValue(0.), theCurvatureError(0.), theChi2(0.)
25 {
26  GlobalVector aX = GlobalVector( P1.x(), P1.y(), 0.).unit();
27  GlobalVector aY( -aX.y(), aX.x(), 0.);
28  GlobalVector aZ( 0., 0., 1.);
29  theRotation = Rotation(aX,aY,aZ);
30 
31  add(P1, errorRPhiP1);
32  add(P2, errorRPhiP2);
33 
34 }
35 
37 {
40  double delta = sqr(2.*A*B) - 4*(1+sqr(A))*(sqr(B)-sqr(1/radius));
41  double sqrtdelta = (delta > 0.) ? sqrt(delta) : 0.;
42  double u1 = (-2.*A*B + sqrtdelta)/2./(1+sqr(A));
43  double v1 = A*u1+B;
44  Point2D tmp = PointUV(u1,v1, &theRotation).unmap();
45  return GlobalPoint(tmp.x(), tmp.y(), 0.);
46 }
47 
48 
49 void ThirdHitPredictionFromInvLine::add(const GlobalPoint &p, double errorRPhi)
50 {
51  double weigth = sqr(sqr(p.perp())/errorRPhi);
52  add(PointUV(Point2D(p.x(),p.y()), &theRotation), weigth);
53 }
54 
56 {
57  hasParameters = false;
58  nPoints++;
59  theSum += weigth;
60  theSumU += point.u()*weigth;
61  theSumUU += sqr(point.u())*weigth;
62  theSumV += point.v()*weigth;
63  theSumUV += point.u()*point.v()*weigth;
64  theSumVV += sqr(point.v())*weigth;
65 }
66 
67 void ThirdHitPredictionFromInvLine::remove(const GlobalPoint &p, double errorRPhi)
68 {
69  hasParameters = false;
70  PointUV point(Point2D(p.x(),p.y()), &theRotation);
71  double weigth = sqr(sqr(p.perp())/errorRPhi);
72  nPoints--;
73  theSum -= weigth;
74  theSumU -= point.u()*weigth;
75  theSumUU -= sqr(point.u())*weigth;
76  theSumV -= point.v()*weigth;
77  theSumUV -= point.u()*point.v()*weigth;
78  theSumVV -= sqr(point.v())*weigth;
79 }
80 
82 {
83  std::cout <<" nPoints: " << nPoints <<" theSumU: "<< theSumU <<" theSumUU: "<<theSumUU
84  <<" theSumV: "<< theSumV <<" theSumUV: "<<theSumUV<<std::endl;
85 }
86 
88 {
89  if (hasParameters) return;
90 
91  long double D = theSumUU*theSum - theSumU*theSumU;
92  long double A = (theSumUV*theSum-theSumU*theSumV)/D;
93  long double B = (theSumUU*theSumV-theSumUV*theSumU)/D;
94  double rho = 2.*fabs(B)/sqrt(1+sqr(A));
95  double sigmaA2 = theSum/D;
96  double sigmaB2 = theSumUU/D;
97 
98  hasParameters = true;
99  theCurvatureError = sqrt( sqr(rho/B)*sigmaB2+ sqr(rho/(1+sqr(A)))*sigmaA2);
100  theCurvatureValue = 2.*fabs(B)/sqrt(1+sqr(A));
101  theChi2 = theSumVV - 2*A*theSumUV - 2*B*theSumV + 2*A*B*theSumU + B*B*theSum + A*A*theSumUU;
102 }
103 
104 /*
105 GlobalPoint ThirdHitPredictionFromInvLine::center() const
106 {
107  long double den = theSumU*theSumUV - theSumUU*theSumV;
108  double a = (theSum*theSumUV-theSumU*theSumV)/2./den;
109  double b = (sqr(theSumU)-theSum*theSumUU)/2./den;
110  Point3D tmp = theRotation.multiplyInverse( Point2D(a,b) );
111  return GlobalPoint(tmp.x(), tmp.y(), 0.);
112 }
113 */
dbl * delta
Definition: mlp_gen.cc:36
void add(const GlobalPoint &p, double erroriRPhi=1.)
T perp() const
Definition: PV3DBase.h:71
void remove(const GlobalPoint &p, double erroriRPhi=1.)
double_binary B
Definition: DDStreamer.cc:234
Definition: DDAxes.h:10
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
T y() const
Definition: PV3DBase.h:62
Basic2DVector< double > Point2D
Basic3DVector< double > Point3D
T sqrt(T t)
Definition: SSEVec.h:46
T y() const
Cartesian y coordinate.
PixelRecoRange< double > Ranged
Vector3DBase unit() const
Definition: Vector3DBase.h:57
DecomposeProduct< arg, typename Div::arg > D
Definition: Factorize.h:150
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
Square< F >::type sqr(const F &f)
Definition: Square.h:13
tuple cout
Definition: gather_cfg.py:121
ThirdHitPredictionFromInvLine(const GlobalPoint &P1, const GlobalPoint &P2, double errorRPhiP1=1., double errorRPhiP2=1.)
long double T
T x() const
Definition: PV3DBase.h:61
T x() const
Cartesian x coordinate.
*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
GlobalPoint crossing(double radius) const