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 */
Vector3DBase
Definition: Vector3DBase.h:8
ThirdHitPredictionFromInvLine::MappedPoint
Definition: ThirdHitPredictionFromInvLine.h:55
ThirdHitPredictionFromInvLine::ThirdHitPredictionFromInvLine
ThirdHitPredictionFromInvLine(const GlobalPoint &P1, const GlobalPoint &P2, double errorRPhiP1=1., double errorRPhiP2=1.)
Definition: ThirdHitPredictionFromInvLine.cc:23
ThirdHitPredictionFromInvLine::theSumUV
long double theSumUV
Definition: ThirdHitPredictionFromInvLine.h:86
ThirdHitPredictionFromInvLine::add
void add(const GlobalPoint &p, double erroriRPhi=1.)
Definition: ThirdHitPredictionFromInvLine.cc:58
funct::false
false
Definition: Factorize.h:29
ThirdHitPredictionFromInvLine::theCurvatureValue
double theCurvatureValue
Definition: ThirdHitPredictionFromInvLine.h:88
PV3DBase::x
T x() const
Definition: PV3DBase.h:59
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
gather_cfg.cout
cout
Definition: gather_cfg.py:144
sqr
T sqr(T t)
Definition: ThirdHitPredictionFromInvLine.cc:11
ThirdHitPredictionFromInvLine::theCurvatureError
double theCurvatureError
Definition: ThirdHitPredictionFromInvLine.h:88
ThirdHitPredictionFromInvLine::theRotation
Rotation theRotation
Definition: ThirdHitPredictionFromInvLine.h:84
GlobalVector
Global3DVector GlobalVector
Definition: GlobalVector.h:10
createJobs.tmp
tmp
align.sh
Definition: createJobs.py:716
ThirdHitPredictionFromInvLine::print
void print() const
Definition: ThirdHitPredictionFromInvLine.cc:89
ThirdHitPredictionFromInvLine::crossing
GlobalPoint crossing(double radius) const
Definition: ThirdHitPredictionFromInvLine.cc:47
Vector3DBase::unit
Vector3DBase unit() const
Definition: Vector3DBase.h:54
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
Point2D
Basic2DVector< double > Point2D
Definition: ThirdHitPredictionFromInvLine.cc:16
ThirdHitPredictionFromInvLine::theSumV
long double theSumV
Definition: ThirdHitPredictionFromInvLine.h:86
GlobalPoint
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
PixelRecoUtilities.h
Point3DBase< float, GlobalTag >
ThirdHitPredictionFromInvLine::theSum
long double theSum
Definition: ThirdHitPredictionFromInvLine.h:86
DDAxes::rho
Basic2DVector< double >
PixelRecoRange
Definition: InnerDeltaPhi.h:15
Point3D
Basic3DVector< double > Point3D
Definition: ThirdHitPredictionFromInvLine.cc:15
dumpMFGeometry_cfg.delta
delta
Definition: dumpMFGeometry_cfg.py:25
ThirdHitPredictionFromInvLine::theChi2
double theChi2
Definition: ThirdHitPredictionFromInvLine.h:88
PV3DBase::y
T y() const
Definition: PV3DBase.h:60
testProducerWithPsetDescEmpty_cfi.u1
u1
Definition: testProducerWithPsetDescEmpty_cfi.py:49
ThirdHitPredictionFromInvLine.h
TtFullHadDaughter::B
static const std::string B
Definition: TtFullHadronicEvent.h:9
funct::D
DecomposeProduct< arg, typename Div::arg > D
Definition: Factorize.h:141
std
Definition: JetResolutionObject.h:76
ThirdHitPredictionFromInvLine::check
void check()
Definition: ThirdHitPredictionFromInvLine.cc:94
ThirdHitPredictionFromInvLine::nPoints
int nPoints
Definition: ThirdHitPredictionFromInvLine.h:85
ThirdHitPredictionFromInvLine::theSumVV
long double theSumVV
Definition: ThirdHitPredictionFromInvLine.h:86
T
long double T
Definition: Basic3DVectorLD.h:48
CosmicsPD_Skims.radius
radius
Definition: CosmicsPD_Skims.py:135
GlobalVector.h
ThirdHitPredictionFromInvLine::PointUV
MappedPoint< double > PointUV
Definition: ThirdHitPredictionFromInvLine.h:79
Ranged
PixelRecoRange< double > Ranged
Definition: ThirdHitPredictionFromInvLine.cc:17
ThirdHitPredictionFromInvLine::Rotation
TkRotation< double > Rotation
Definition: ThirdHitPredictionFromInvLine.h:20
point
*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
ThirdHitPredictionFromInvLine::theSumU
long double theSumU
Definition: ThirdHitPredictionFromInvLine.h:86
submitPVValidationJobs.t
string t
Definition: submitPVValidationJobs.py:644
A
GlobalPoint.h
ThirdHitPredictionFromInvLine::remove
void remove(const GlobalPoint &p, double erroriRPhi=1.)
Definition: ThirdHitPredictionFromInvLine.cc:75
Basic3DVector
Definition: extBasic3DVector.h:30
ThirdHitPredictionFromInvLine::theSumUU
long double theSumUU
Definition: ThirdHitPredictionFromInvLine.h:86
PixelRecoRange.h
ThirdHitPredictionFromInvLine::hasParameters
bool hasParameters
Definition: ThirdHitPredictionFromInvLine.h:87