64 {
65
66 _debug = 0;
67
68
70
71 double kap = 0.5 *
par.omega();
75 double radius = slayer->
rEnd();
77 if (_debug >0){
79 std::cout <<
"delPhi "<<slayer->
delPhi()
81 <<" dPhiZ "<<dPhiZ
82 <<
" zEnd() "<<slayer->
zEnd()
83 <<
" phiAx "<<segStuff.
phiAx
84 <<" phiSeg "<<phiSeg
85 <<
" phiDiff "<<phiSeg - segStuff.
phiAx<< std::endl;
86 }
87 bool lStraight = false;
88 if (fabs(kap)<1.e-9) lStraight = true;
89
91 double zApprox = phiDiff.
rad() * -dPhiZ;
92 if (_debug >0){
93 std::cout<<"zApp "<<zApprox<<std::endl;
94 }
95 double delRad = slayer->
stDip() *
96 (1. - zApprox * zApprox * segStuff.
wirLen2inv);
97 radius -= delRad;
98 double delPhiArg;
99 if (lStraight) {
100 delPhiArg = delRad * d0 / (radius*radius);
101 }else {
102 delPhiArg = -delRad * kap;
103 }
104
105
106
108 int hitFit=0;
109 bool szFaild = false;
110 double arcTemp=0;
111
112 for (
int ihit = 0; ihit < parentSeg->
nHit(); ihit++){
113
114
116
117
118
119 if (szCode > 0){
120 span.sigma[hitFit] = 1;
121 arcTemp += span.x[hitFit];
122 hitFit ++;
123 }else{
124 szFaild = true;
125 if (_debug >0){
127 std::cout<<"MdcSegInfoSterO hit "<<ihit<<" z calc faild"<<std::endl;
128 }
129 }
130 }
131 if (hitFit >0) span.fit(hitFit);
132
133
134
135 segStuff.
phiAx += delPhiArg +
137 phiDiff = phiSeg - segStuff.
phiAx;
138 double z = phiDiff.
rad() * -dPhiZ;
139 if (_debug >0){
140 std::cout<<"z "<<z<<std::endl;
141 }
143 if (lStraight) {
144
145 double arg = radius*radius - d0*d0;
146 if (
arg <= 0.0)
return 1;
147 double rD0Root = sqrt(
arg);
148 double rD0Rinv = 1. / rD0Root;
149 double rinv = 1./radius;
150
151 double slope = parentSeg->
slope();
152 ct = dPhiZ * (rD0Root * slope + d0 * rinv) * rinv;
153
155 if (
arc == 0.0)
return 1;
157
158 if (_debug>0){
159 std::cout <<
"in MdcSegInfoSterO : z0 "<<
z0 <<
" "<<
_errmat[0]
162 <<endl;
163 }
164
165 double dctdm = dPhiZ * rD0Root * rinv;
166 double dctdD = -dPhiZ * rinv * (slope * d0 * rD0Rinv - rinv);
167 double dzdm = -
arc * dPhiZ * rD0Root * rinv;
168 double dzdphi = dPhiZ;
169 double dzdphi0 = -dPhiZ;
170 double dzdD = -dPhiZ +
ct * d0 * rD0Rinv -
arc * dctdD;
171
172 const double *inErr = parentSeg->
errmat();
173
174 const HepMatrix trackErr =
par.covariance();
175 _errmat[0] = dzdm * dzdm * inErr[2] +
176 2 * dzdm * dzdphi * inErr[1] +
177 dzdphi * dzdphi * inErr[0] +
178 dzdD * dzdD * trackErr(1,1) +
179 dzdphi0 * dzdphi0 * trackErr(2,2) +
180 2 * dzdD * dzdphi0 * trackErr(1,2);
182
183
184 _errmat[2] = dctdm * dctdm * inErr[2] +
185 dctdD * dctdD * trackErr(1,1);
187
188
189 _errmat[1] = dzdm * dctdm * inErr[2] +
190 dzdphi * dctdm * inErr[1] +
191 dzdD * dctdD * trackErr(1,1) +
192 dzdphi0 * dctdD * trackErr(1,2);
193 }
194 else {
195
196
197 double arg = 1. - kap*kap * radius*radius;
198 if (
arg < 0.0)
return 1;
199 double rKapRoot = sqrt(
arg);
200 double rKapRinv = 1. / rKapRoot;
201 double ctFactor = -rKapRoot * -dPhiZ;
202 double slopeAx = kap * rKapRinv;
203 double slope = parentSeg->
slope();
204
205
206
207
208
209
210
211 if (szFaild){
212
213 ct = (slopeAx - slope) * ctFactor;
215 if (
arc == 0.0)
return 1;
217 }else{
218
219 if (!szFaild){
220 arc = arcTemp/hitFit;
223 }else{
227 }
228 }
229 if (_debug >0){
230 std::cout<<
"--slayer NO. "<<slayer->
index()<<std::endl;
231 std::cout<<"ori ct "<<(slopeAx - slope) * ctFactor
234 std::cout<<"fix ct "<<span.slope<<" z0 "<<span.intercept
235 <<" arc "<<arcTemp/hitFit<<std::endl;
236 std::cout<<"-------- "<<std::endl;
237 }
238
239 double dctdm = dPhiZ * rKapRoot;
240 double dctdkap = -dPhiZ * ( 1 + radius * radius * kap * rKapRinv * slope);
241 double dzdm =
arc * -dPhiZ * rKapRoot;
242 double dzdphi = dPhiZ;
243 double dzdkap = dPhiZ * radius * rKapRinv -
arc * dctdkap -
244 ct * ( radius * rKapRinv / kap -
arc / kap);
245 double dzdphi0 = -dPhiZ ;
246
247 const double *inErr = parentSeg->
errmat();
248
249 const HepMatrix trackErr =
par.covariance();
250 _errmat[0] = dzdm * dzdm * inErr[2] +
251 2 * dzdm * dzdphi * inErr[1] +
252 dzdphi * dzdphi * inErr[0] +
253 dzdkap * dzdkap * trackErr(3,3) +
254 dzdphi0 * dzdphi0 * trackErr(2,2) +
255 2 * dzdkap * dzdphi0 * trackErr(2,3);
256
257
258
259
260
261
262
263
264
265
266
267
268
270
271
272 _errmat[2] = dctdm * dctdm * inErr[2] +
273 dctdkap * dctdkap * trackErr(3,3);
275
276
277 _errmat[1] = dzdm * dctdm * inErr[2] +
278 dzdphi * dctdm * inErr[1] +
279 dzdkap * dctdkap * trackErr(3,3) +
280 dzdphi0 * dctdkap * trackErr(2,3);
281
282 }
283
284
285
289
291 if (error) {
292 std::cout << " ErrMsg(warning)" << "Failed to invert matrix -- MdcSegInfo::calcStereo" <<
294 }
295 return 0;
296
297}
double arg(const EvtComplex &c)
int mdcTwoInv(double matrix[3], double invmat[3])
const MdcHit * mdcHit() const
void print(std::ostream &o) const
int zPosition(MdcHitUse &hitUse, const TrkRecoTrk &track, MdcLine *span, int hitFit, double t0) const
const MdcSuperLayer * superlayer() const
const double * errmat() const
MdcHitUse * hit(int i) const
double delPhiinv(void) const
double delPhi(void) const
static double fltToRad(const TrkExchangePar &hel, double rad)