RecoEgamma
EgammaPhotonAlgos
src
ConversionFastHelix.cc
Go to the documentation of this file.
1
#include "
RecoEgamma/EgammaPhotonAlgos/interface/ConversionFastHelix.h
"
2
#include "
RecoTracker/TkSeedGenerator/interface/FastLine.h
"
3
#include "
TrackingTools/TrajectoryParametrization/interface/GlobalTrajectoryParameters.h
"
4
#include "
TrackingTools/TrajectoryParametrization/interface/CurvilinearTrajectoryError.h
"
5
#include "
TrackingTools/TrajectoryParametrization/interface/CartesianTrajectoryError.h
"
6
#include "
FWCore/Utilities/interface/isFinite.h
"
7
8
#include <cfloat>
9
10
ConversionFastHelix::ConversionFastHelix
(
const
GlobalPoint
& outerHit,
11
const
GlobalPoint
& middleHit,
12
const
GlobalPoint
& aVertex,
13
const
MagneticField
* field)
14
: theOuterHit(outerHit),
15
theMiddleHit(middleHit),
16
theVertex(aVertex),
17
theCircle(outerHit, middleHit, aVertex),
18
mField(field) {
19
validStateAtVertex
=
false
;
20
21
makeHelix
();
22
}
23
24
void
ConversionFastHelix::makeHelix
() {
25
if
(
theCircle
.
isValid
()) {
26
theHelix_
=
helixStateAtVertex
();
27
}
else
{
28
theHelix_
=
straightLineStateAtVertex
();
29
}
30
}
31
32
FreeTrajectoryState
ConversionFastHelix::stateAtVertex
() {
return
theHelix_
; }
33
34
FreeTrajectoryState
ConversionFastHelix::helixStateAtVertex
() {
35
GlobalPoint
pMid(
theMiddleHit
);
36
GlobalPoint
v
(
theVertex
);
37
FTS
atVertex;
38
39
double
dydx = 0.;
40
double
pt
= 0.,
px
= 0.,
py
= 0.;
41
42
//remember (radius rho in cm):
43
//rho =
44
//100. * pt *
45
//(10./(3.*MagneticField::inTesla(GlobalPoint(0., 0., 0.)).z()));
46
47
double
rho
=
theCircle
.
rho
();
48
pt
= 0.01 *
rho
* (0.3 *
mField
->
inTesla
(
GlobalPoint
(0, 0, 0)).
z
());
49
50
// (py/px)|x=v.x() = (dy/dx)|x=v.x()
51
//remember:
52
//y(x) = +-sqrt(rho^2 - (x-x0)^2) + y0
53
//y(x) = sqrt(rho^2 - (x-x0)^2) + y0 if y(x) >= y0
54
//y(x) = -sqrt(rho^2 - (x-x0)^2) + y0 if y(x) < y0
55
//=> (dy/dx) = -(x-x0)/sqrt(Q) if y(x) >= y0
56
// (dy/dx) = (x-x0)/sqrt(Q) if y(x) < y0
57
//with Q = rho^2 - (x-x0)^2
58
59
double
arg
=
rho
*
rho
- ((
v
.x() -
theCircle
.
x0
()) * (
v
.x() -
theCircle
.
x0
()));
60
61
if
(
arg
> 0) {
62
// double root = sqrt( rho*rho - ( (v.x()-theCircle.x0())*(v.x()-theCircle.x0()) ) );
63
double
root
=
sqrt
(
arg
);
64
65
if
((
v
.y() -
theCircle
.
y0
()) > 0.)
66
dydx = -(
v
.x() -
theCircle
.
x0
()) /
root
;
67
else
68
dydx = (
v
.x() -
theCircle
.
x0
()) /
root
;
69
70
px
=
pt
/
sqrt
(1. + dydx * dydx);
71
py
=
px
* dydx;
72
// check sign with scalar product
73
if
(
px
* (pMid.
x
() -
v
.x()) +
py
* (pMid.
y
() -
v
.y()) < 0.) {
74
px
*= -1.;
75
py
*= -1.;
76
}
77
78
//std::cout << " ConversionFastHelix:helixStateAtVertex rho " << rho << " pt " << pt << " v " << v << " theCircle.x0() " <<theCircle.x0() << " theCircle.y0() " << theCircle.y0() << " v.x()-theCircle.x0() " << v.x()-theCircle.x0() << " rho^2 " << rho*rho << " v.x()-theCircle.x0()^2 " << (v.x()-theCircle.x0())*(v.x()-theCircle.x0()) << " root " << root << " arg " << arg << " dydx " << dydx << std::endl;
79
//calculate z0, pz
80
//(z, R*phi) linear relation in a helix
81
//with R, phi defined as radius and angle w.r.t. centre of circle
82
//in transverse plane
83
//pz = pT*(dz/d(R*phi)))
84
85
FastLine
flfit(
theOuterHit
,
theMiddleHit
,
theCircle
.
rho
());
86
87
double
z_0 = 0;
88
89
//std::cout << " ConversionFastHelix:helixStateAtVertex flfit.n2() " << flfit.n2() << " flfit.c() " << flfit.c() << " flfit.n2() " << flfit.n2() << std::endl;
90
if
(flfit.n2() != 0 && !
edm::isNotFinite
(flfit.c()) && !
edm::isNotFinite
(flfit.n2())) {
91
// std::cout << " Accepted " << std::endl;
92
z_0 = -flfit.
c
() / flfit.n2();
93
double
dzdrphi = -flfit.n1() / flfit.n2();
94
double
pz =
pt
* dzdrphi;
95
96
//get sign of particle
97
98
GlobalVector
magvtx =
mField
->
inTesla
(
v
);
99
TrackCharge
q
= ((
theCircle
.
x0
() *
py
-
theCircle
.
y0
() *
px
) / (magvtx.
z
()) < 0.) ? -1 : 1;
100
101
AlgebraicSymMatrix55
C
=
AlgebraicMatrixID
();
102
//MP
103
104
atVertex =
FTS
(
GlobalTrajectoryParameters
(
GlobalPoint
(
v
.x(),
v
.y(), z_0),
GlobalVector
(
px
,
py
, pz),
q
,
mField
),
105
CurvilinearTrajectoryError
(
C
));
106
107
//std::cout << " ConversionFastHelix:helixStateAtVertex globalPoint " << GlobalPoint(v.x(), v.y(), z_0) << " GlobalVector " << GlobalVector(px, py, pz) << " q " << q << " MField " << mField->inTesla(v) << std::endl;
108
//std::cout << " ConversionFastHelix:helixStateAtVertex atVertex.transverseCurvature() " << atVertex.transverseCurvature() << std::endl;
109
if
(atVertex.
transverseCurvature
() != 0) {
110
validStateAtVertex
=
true
;
111
112
//std::cout << " ConversionFastHelix:helixStateAtVertex validHelixStateAtVertex status " << validStateAtVertex << std::endl;
113
return
atVertex;
114
}
else
115
return
atVertex;
116
}
else
{
117
//std::cout << " ConversionFastHelix:helixStateAtVertex not accepted validHelixStateAtVertex status " << validStateAtVertex << std::endl;
118
return
atVertex;
119
}
120
121
}
else
{
122
//std::cout << " ConversionFastHelix:helixStateAtVertex not accepted because arg <0 validHelixStateAtVertex status " << validStateAtVertex << std::endl;
123
return
atVertex;
124
}
125
}
126
127
FreeTrajectoryState
ConversionFastHelix::straightLineStateAtVertex
() {
128
FTS
atVertex;
129
130
//calculate FTS assuming straight line...
131
132
GlobalPoint
pMid(
theMiddleHit
);
133
GlobalPoint
v
(
theVertex
);
134
135
double
dydx = 0.;
136
double
pt
= 0.,
px
= 0.,
py
= 0.;
137
138
if
(fabs(
theCircle
.
n1
()) > 0. || fabs(
theCircle
.
n2
()) > 0.)
139
pt
= 1.e+4;
// 10 TeV //else no pt
140
if
(fabs(
theCircle
.
n2
()) > 0.) {
141
dydx = -
theCircle
.
n1
() /
theCircle
.
n2
();
//else px = 0
142
}
143
144
if
(
pt
== 0 && dydx == 0.) {
145
validStateAtVertex
=
false
;
146
return
atVertex;
147
}
148
px
=
pt
/
sqrt
(1. + dydx * dydx);
149
py
=
px
* dydx;
150
151
// check sign with scalar product
152
if
(
px
* (pMid.
x
() -
v
.x()) +
py
* (pMid.
y
() -
v
.y()) < 0.) {
153
px
*= -1.;
154
py
*= -1.;
155
}
156
157
//calculate z_0 and pz at vertex using weighted mean
158
//z = z(r) = z0 + (dz/dr)*r
159
//tan(theta) = dr/dz = (dz/dr)^-1
160
//theta = atan(1./dzdr)
161
//p = pt/sin(theta)
162
//pz = p*cos(theta) = pt/tan(theta)
163
164
FastLine
flfit(
theOuterHit
,
theMiddleHit
);
165
166
double
z_0 = 0;
167
if
(flfit.
n2
() != 0 && !
edm::isNotFinite
(flfit.
c
()) && !
edm::isNotFinite
(flfit.
n2
())) {
168
z_0 = -flfit.
c
() / flfit.
n2
();
169
170
double
dzdr = -flfit.
n1
() / flfit.
n2
();
171
double
pz =
pt
* dzdr;
172
173
TrackCharge
q
= 1;
174
175
atVertex =
FTS
(
GlobalPoint
(
v
.x(),
v
.y(), z_0),
GlobalVector
(
px
,
py
, pz),
q
,
mField
);
176
177
// std::cout << " ConversionFastHelix::straightLineStateAtVertex curvature " << atVertex.transverseCurvature() << " signedInverseMomentum " << atVertex.signedInverseMomentum() << std::endl;
178
if
(atVertex.
transverseCurvature
() == -0) {
179
return
atVertex;
180
}
else
{
181
validStateAtVertex
=
true
;
182
return
atVertex;
183
}
184
185
}
else
{
186
return
atVertex;
187
}
188
}
Vector3DBase
Definition:
Vector3DBase.h:8
MagneticField::inTesla
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
GlobalTrajectoryParameters.h
ConversionFastHelix::theMiddleHit
GlobalPoint theMiddleHit
Definition:
ConversionFastHelix.h:41
TrackCharge
int TrackCharge
Definition:
TrackCharge.h:4
edm::isNotFinite
constexpr bool isNotFinite(T x)
Definition:
isFinite.h:9
PV3DBase::x
T x() const
Definition:
PV3DBase.h:59
DiDispStaMuonMonitor_cfi.pt
pt
Definition:
DiDispStaMuonMonitor_cfi.py:39
multPhiCorr_741_25nsDY_cfi.py
py
Definition:
multPhiCorr_741_25nsDY_cfi.py:12
FastLine::c
double c() const
Definition:
FastLine.h:27
FastCircle::y0
double y0() const
Definition:
FastCircle.h:45
FastCircle::n1
double n1() const
Definition:
FastCircle.h:55
FastLine
Definition:
FastLine.h:15
GlobalVector
Global3DVector GlobalVector
Definition:
GlobalVector.h:10
findQualityFiles.v
v
Definition:
findQualityFiles.py:179
ConversionFastHelix::theCircle
FastCircle theCircle
Definition:
ConversionFastHelix.h:43
ConversionFastHelix::theHelix_
FTS theHelix_
Definition:
ConversionFastHelix.h:38
PV3DBase::z
T z() const
Definition:
PV3DBase.h:61
ConversionFastHelix::makeHelix
void makeHelix()
Definition:
ConversionFastHelix.cc:24
AlgebraicMatrixID
ROOT::Math::SMatrixIdentity AlgebraicMatrixID
Definition:
AlgebraicROOTObjects.h:72
ConversionFastHelix::mField
const MagneticField * mField
Definition:
ConversionFastHelix.h:44
ConversionFastHelix::validStateAtVertex
bool validStateAtVertex
Definition:
ConversionFastHelix.h:39
FastCircle::rho
double rho() const
Definition:
FastCircle.h:47
CurvilinearTrajectoryError
Definition:
CurvilinearTrajectoryError.h:27
CurvilinearTrajectoryError.h
mathSSE::sqrt
T sqrt(T t)
Definition:
SSEVec.h:19
CartesianTrajectoryError.h
GlobalTrajectoryParameters
Definition:
GlobalTrajectoryParameters.h:15
GlobalPoint
Global3DPoint GlobalPoint
Definition:
GlobalPoint.h:10
Point3DBase< float, GlobalTag >
ConversionFastHelix::FTS
FreeTrajectoryState FTS
Definition:
ConversionFastHelix.h:17
ConversionFastHelix::ConversionFastHelix
ConversionFastHelix(const GlobalPoint &outerHit, const GlobalPoint &middleHit, const GlobalPoint &aVertex, const MagneticField *field)
Definition:
ConversionFastHelix.cc:10
DDAxes::rho
FastLine.h
FastCircle::x0
double x0() const
Definition:
FastCircle.h:43
PV3DBase::y
T y() const
Definition:
PV3DBase.h:60
root
Definition:
RooFitFunction.h:10
submitPVResolutionJobs.q
q
Definition:
submitPVResolutionJobs.py:84
ConversionFastHelix::theOuterHit
GlobalPoint theOuterHit
Definition:
ConversionFastHelix.h:40
ConversionFastHelix::helixStateAtVertex
FTS helixStateAtVertex()
Definition:
ConversionFastHelix.cc:34
ConversionFastHelix::stateAtVertex
FTS stateAtVertex()
Definition:
ConversionFastHelix.cc:32
multPhiCorr_741_25nsDY_cfi.px
px
Definition:
multPhiCorr_741_25nsDY_cfi.py:10
ConversionFastHelix::straightLineStateAtVertex
FTS straightLineStateAtVertex()
Definition:
ConversionFastHelix.cc:127
isFinite.h
FreeTrajectoryState
Definition:
FreeTrajectoryState.h:27
gen::C
C
Definition:
PomwigHadronizer.cc:78
FastLine::n1
double n1() const
Definition:
FastLine.h:23
FastCircle::isValid
bool isValid() const
Definition:
FastCircle.h:49
funct::arg
A arg
Definition:
Factorize.h:31
ConversionFastHelix.h
ConversionFastHelix::theVertex
GlobalPoint theVertex
Definition:
ConversionFastHelix.h:42
FastLine::n2
double n2() const
Definition:
FastLine.h:25
MagneticField
Definition:
MagneticField.h:19
AlgebraicSymMatrix55
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
Definition:
AlgebraicROOTObjects.h:23
FastCircle::n2
double n2() const
Definition:
FastCircle.h:57
FreeTrajectoryState::transverseCurvature
double transverseCurvature() const
Definition:
FreeTrajectoryState.h:71
Generated for CMSSW Reference Manual by
1.8.16