BOSS 7.0.7
BESIII Offline Software System
Loading...
Searching...
No Matches
VertexConstraints.cxx
Go to the documentation of this file.
3#include "VertexFit/BField.h"
4
5const double VertexConstraints :: Alpha = -0.00299792458;
6const int VertexConstraints::FixedVertex = 1;
7const int VertexConstraints::CommonVertex = 2;
8
10{
11 m_Ec.clear();
12 m_Dc.clear();
13 m_dc.clear();
14 m_VD.clear();
15 m_EVDE.clear();
16 m_lambda0.clear();
17 m_lambda.clear();
18 m_covax.clear();
19 m_ltrk.clear();
20 m_type = 0;
21}
22
24{
25 m_ltrk = tlis;
27}
28
30{
31 m_ltrk = tlis;
33}
34
35void VertexConstraints::UpdateConstraints(VertexParameter vpar, std::vector<WTrackParameter> wlis)
36{
37 m_Ec.clear();
38 m_Dc.clear();
39 m_dc.clear();
40 m_VD.clear();
41 m_EVDE.clear();
42 m_lambda0.clear();
43 m_lambda.clear();
44 m_covax.clear();
45
46 switch(m_type)
47 {
48 case FixedVertex:
49 {
50 WTrackParameter wtrk;
51 for (unsigned int i = 0; i < wlis.size(); i++)
52 {
53 wtrk = wlis[i];
54 HepLorentzVector p = wtrk.p();
55 HepPoint3D x = wtrk.x();
56 HepPoint3D delx = vpar.vx() - x;
57
58 double afield = VertexFitBField::instance()->getCBz(vpar.Vx(), wtrk.X());
59 double a = afield * (0.0+wtrk.charge());
60 double J = a * (delx.x()*p.px() + delx.y()*p.py())/p.perp2();
61
62 J = std::min(J, 1-1e-4);
63 J = std::max(J, -1+1e-4);
64 double Rx = delx.x() - 2*p.px() * (delx.x()*p.px() + delx.y()*p.py()) / p.perp2();
65 double Ry = delx.y() - 2*p.py() * (delx.x()*p.px() + delx.y()*p.py()) / p.perp2();
66 double S = 1.0/sqrt(1-J*J)/p.perp2();
67
68 // dc
69 HepVector dc(2, 0);
70 dc[0] = delx.y() * p.px() - delx.x() * p.py() - 0.5 * a * (delx.x() * delx.x() + delx.y() * delx.y());
71 dc[1] = delx.z() - p.pz()/a*asin(J);
72 m_dc.push_back(dc);
73 // Ec
74 HepMatrix Ec(2, 3, 0);
75 m_Ec.push_back(Ec);
76 // Dc
77 HepMatrix Dc(2, 6, 0);
78 Dc[0][0] = delx.y();
79 Dc[0][1] = -delx.x();
80 Dc[0][2] = 0;
81 Dc[0][3] = p.py() + a * delx.x();
82 Dc[0][4] = -p.px() + a * delx.y();
83 Dc[0][5] = 0;
84 Dc[1][0] = -p.pz() * S * Rx;
85 Dc[1][1] = -p.pz() * S * Ry;
86 Dc[1][2] = - asin(J) / a;
87 Dc[1][3] = p.px() * p.pz() * S;
88 Dc[1][4] = p.py() * p.pz() * S;
89 Dc[1][5] = -1.0;
90 m_Dc.push_back(Dc);
91 // VD
92 HepSymMatrix VD(2, 0);
93 // int ifail;
94 // VD = ((wtrk.Ew()).similarity(Dc)).inverse(ifail); // 2x2 matrix (Dc Ew Dc.T())
95 m_VD.push_back(VD);
96 // EVDE
97 HepSymMatrix EVDE(3, 0);
98 m_EVDE.push_back(EVDE);
99 // lambda0
100 HepVector lambda0(2, 0);
101 m_lambda0.push_back(lambda0);
102 // lambda
103 HepVector lambda(2, 0);
104 m_lambda.push_back(lambda);
105 // covax
106 HepMatrix covax(6, 3, 0);
107 m_covax.push_back(covax);
108 break;
109 }
110 }
111 case CommonVertex:
112 default:
113 {
114 WTrackParameter wtrk;
115 for (unsigned int i = 0; i < wlis.size(); i++)
116 {
117 wtrk = wlis[i];
118 HepLorentzVector p = wtrk.p();
119 HepPoint3D x = wtrk.x();
120 HepPoint3D delx = vpar.vx() - x;
121 if (wtrk.charge() == 0)
122 {
123 //dc
124 HepVector dc(2,0);
125 dc[0] = p.pz()*delx.x() - p.px()*delx.z();
126 dc[1] = p.pz()*delx.y() - p.py()*delx.z();
127 m_dc.push_back(dc);
128 //Ec
129 HepMatrix Ec(2,3,0);
130 Ec[0][0] = p.pz();
131 Ec[0][1] = 0;
132 Ec[0][2] = -p.px();
133 Ec[1][0] = 0;
134 Ec[1][1] = p.pz();
135 Ec[1][2] = -p.py();
136 m_Ec.push_back(Ec);
137 //Dc
138 HepMatrix Dc(2,6,0);
139 Dc[0][0] = -delx.z();
140 Dc[0][1] = 0;
141 Dc[0][2] = delx.x();
142 Dc[0][3] = -p.pz();
143 Dc[0][4] = 0;
144 Dc[0][5] = p.px();
145 Dc[1][0] = 0;
146 Dc[1][1] = -delx.z();
147 Dc[1][2] = delx.y();
148 Dc[1][3] = 0;
149 Dc[1][4] = -p.pz();
150 Dc[1][5] = p.py();
151 m_Dc.push_back(Dc);
152 }
153 else
154 {
155 double afield = VertexFitBField::instance()->getCBz(vpar.Vx(), wtrk.X());
156 double a = afield * (0.0+wtrk.charge());
157 double J = a * (delx.x()*p.px() + delx.y()*p.py())/p.perp2();
158 J = std::min(J, 1-1e-4);
159 J = std::max(J, -1+1e-4);
160 double Rx = delx.x() - 2*p.px() * (delx.x()*p.px() + delx.y()*p.py()) / p.perp2();
161 double Ry = delx.y() - 2*p.py() * (delx.x()*p.px() + delx.y()*p.py()) / p.perp2();
162 double S = 1.0/sqrt(1-J*J)/p.perp2();
163 // dc
164 HepVector dc(2, 0);
165 dc[0] = delx.y() * p.px() - delx.x() * p.py() - 0.5 * a * (delx.x() * delx.x() + delx.y() * delx.y());
166 dc[1] = delx.z() - p.pz()/a*asin(J);
167 m_dc.push_back(dc);
168 // Ec
169 HepMatrix Ec(2, 3, 0);
170 Ec[0][0] = -p.py()- a * delx.x();
171 Ec[0][1] = p.px() - a * delx.y();
172 Ec[0][2] = 0;
173 Ec[1][0] = -p.px() * p.pz() * S ;
174 Ec[1][1] = -p.py() * p.pz() * S ;
175 Ec[1][2] = 1.0;
176 m_Ec.push_back(Ec);
177 // Dc
178 HepMatrix Dc(2, 6, 0);
179 Dc[0][0] = delx.y();
180 Dc[0][1] = -delx.x();
181 Dc[0][2] = 0;
182 Dc[0][3] = p.py() + a * delx.x();
183 Dc[0][4] = -p.px() + a * delx.y();
184 Dc[0][5] = 0;
185 Dc[1][0] = -p.pz() * S * Rx;
186 Dc[1][1] = -p.pz() * S * Ry;
187 Dc[1][2] = - asin(J) / a;
188 Dc[1][3] = p.px() * p.pz() * S;
189 Dc[1][4] = p.py() * p.pz() * S;
190 Dc[1][5] = -1.0;
191 m_Dc.push_back(Dc);
192 }
193 // VD
194 HepSymMatrix VD(2, 0);
195 m_VD.push_back(VD);
196 // EVDE
197 HepSymMatrix EVDE(3, 0);
198 m_EVDE.push_back(EVDE);
199 // lambda0
200 HepVector lambda0(2, 0);
201 m_lambda0.push_back(lambda0);
202 // lambda
203 HepVector lambda(2, 0);
204 m_lambda.push_back(lambda);
205 // covax
206 HepMatrix covax(6, 3, 0);
207 m_covax.push_back(covax);
208 }
209 break;
210 }
211 }
212}
213
214
std::vector< HepMatrix > Dc() const
void FixedVertexConstraints(std::vector< int > tlis)
std::vector< HepSymMatrix > EVDE() const
void CommonVertexConstraints(std::vector< int > tlis)
int commonVertex() const
int fixedVertex() const
std::vector< HepSymMatrix > VD() const
void UpdateConstraints(VertexParameter vpar, std::vector< WTrackParameter > wlis)
std::vector< HepMatrix > covax() const
std::vector< HepMatrix > Ec() const
std::vector< HepVector > lambda0() const
std::vector< HepVector > dc() const
std::vector< HepVector > lambda() const
void setType(const int type)
double getCBz(const HepVector &vtx, const HepVector &trackPosition)
HepPoint3D vx() const
HepVector Vx() const
int charge() const
HepLorentzVector p() const
HepPoint3D x() const
HepVector X() const
double x[1000]