1 |
/** |
2 |
* \file ExtTrack.cpp |
3 |
* \author Elena Vannuccini |
4 |
*/ |
5 |
#include <ExtTrack.h> |
6 |
#include <iostream> |
7 |
#include <math.h> |
8 |
using namespace std; |
9 |
|
10 |
ExtTrack::ExtTrack(int dim){ |
11 |
|
12 |
//cout << " ExtTrack::ExtTrack("<<dim<<")"<<endl; |
13 |
xgood = NULL; |
14 |
ygood = NULL; |
15 |
multmaxx = NULL; |
16 |
multmaxy = NULL; |
17 |
xm = NULL; |
18 |
ym = NULL; |
19 |
zm = NULL; |
20 |
xma = NULL; |
21 |
yma = NULL; |
22 |
zma = NULL; |
23 |
xmb = NULL; |
24 |
ymb = NULL; |
25 |
zmb = NULL; |
26 |
resx = NULL; |
27 |
resy = NULL; |
28 |
xv = NULL; |
29 |
yv = NULL; |
30 |
zv = NULL; |
31 |
axv = NULL; |
32 |
ayv = NULL; |
33 |
dedx_x = NULL; |
34 |
dedx_y = NULL; |
35 |
|
36 |
// xGF = new float[TrkParams::nGF]; |
37 |
// yGF = new float[TrkParams::nGF]; |
38 |
// init vectors |
39 |
SetDimension(dim);//allocate vectors |
40 |
// init fit variables |
41 |
Reset(); |
42 |
// set fit parameters (default) |
43 |
SetZ0(23.5); |
44 |
SetMiniDefault(); |
45 |
}; |
46 |
//-------------------------------------- |
47 |
// |
48 |
// |
49 |
//-------------------------------------- |
50 |
ExtTrack::ExtTrack( const ExtTrack& t ){ |
51 |
//cout << " ExtTrack::ExtTrack( const ExtTrack& t ) "<<this<<endl; |
52 |
|
53 |
// -------------------- |
54 |
// initialize pointers |
55 |
// -------------------- |
56 |
|
57 |
xgood = NULL; |
58 |
ygood = NULL; |
59 |
multmaxx = NULL; |
60 |
multmaxy = NULL; |
61 |
xm = NULL; |
62 |
ym = NULL; |
63 |
zm = NULL; |
64 |
xma = NULL; |
65 |
yma = NULL; |
66 |
zma = NULL; |
67 |
xmb = NULL; |
68 |
ymb = NULL; |
69 |
zmb = NULL; |
70 |
resx = NULL; |
71 |
resy = NULL; |
72 |
xv = NULL; |
73 |
yv = NULL; |
74 |
zv = NULL; |
75 |
axv = NULL; |
76 |
ayv = NULL; |
77 |
dedx_x = NULL; |
78 |
dedx_y = NULL; |
79 |
|
80 |
// xGF = new float[TrkParams::nGF]; |
81 |
// yGF = new float[TrkParams::nGF]; |
82 |
|
83 |
SetDimension(t.nplanes);//allocate vectors |
84 |
|
85 |
// -------------------- |
86 |
// copy values |
87 |
// -------------------- |
88 |
zini = t.zini; |
89 |
chi2 = t.chi2; |
90 |
nstep = t.nstep; |
91 |
for(int it1=0;it1<5;it1++){ |
92 |
al[it1] = t.al[it1]; |
93 |
for(int it2=0;it2<5;it2++)coval[it1][it2] = t.coval[it1][it2]; |
94 |
}; |
95 |
|
96 |
|
97 |
for(int ip=0;ip<nplanes;ip++){ |
98 |
xgood[ip] = t.xgood[ip]; |
99 |
ygood[ip] = t.ygood[ip]; |
100 |
multmaxx[ip] = t.multmaxx[ip]; |
101 |
multmaxy[ip] = t.multmaxy[ip]; |
102 |
xm[ip] = t.xm[ip]; |
103 |
ym[ip] = t.ym[ip]; |
104 |
zm[ip] = t.zm[ip]; |
105 |
xma[ip] = t.xma[ip]; |
106 |
yma[ip] = t.yma[ip]; |
107 |
zma[ip] = t.zma[ip]; |
108 |
xmb[ip] = t.xmb[ip]; |
109 |
ymb[ip] = t.ymb[ip]; |
110 |
zmb[ip] = t.zmb[ip]; |
111 |
resx[ip] = t.resx[ip]; |
112 |
resy[ip] = t.resy[ip]; |
113 |
xv[ip] = t.xv[ip]; |
114 |
yv[ip] = t.yv[ip]; |
115 |
zv[ip] = t.zv[ip]; |
116 |
axv[ip] = t.axv[ip]; |
117 |
ayv[ip] = t.ayv[ip]; |
118 |
dedx_x[ip] = t.dedx_x[ip]; |
119 |
dedx_y[ip] = t.dedx_y[ip]; |
120 |
}; |
121 |
|
122 |
int ngf = TrkParams::nGF; |
123 |
for(int i=0; i<ngf; i++){ |
124 |
xGF[i] = t.xGF[i]; |
125 |
yGF[i] = t.yGF[i]; |
126 |
} |
127 |
|
128 |
}; |
129 |
//-------------------------------------- |
130 |
// |
131 |
// |
132 |
//-------------------------------------- |
133 |
void ExtTrack::Copy( ExtTrack& t ){ |
134 |
|
135 |
// cout << " ExtTrack::Copy( ExtTrack& t ) "<<endl; |
136 |
|
137 |
t.Reset();//reset variables |
138 |
t.Clear();//deallocate vectors |
139 |
t.SetDimension(nplanes);//allocate vectors |
140 |
|
141 |
t.zini = zini; |
142 |
t.chi2 = chi2; |
143 |
t.nstep = nstep; |
144 |
for(int it1=0;it1<5;it1++){ |
145 |
t.al[it1] = al[it1]; |
146 |
for(int it2=0;it2<5;it2++)t.coval[it1][it2] = coval[it1][it2]; |
147 |
}; |
148 |
// cout << "ExtTrack::Copy()........nplanes "<<nplanes<<endl; |
149 |
for(int ip=0;ip<nplanes;ip++){ |
150 |
t.xgood[ip] = xgood[ip]; |
151 |
t.ygood[ip] = ygood[ip]; |
152 |
t.multmaxx[ip] = multmaxx[ip]; |
153 |
t.multmaxy[ip] = multmaxy[ip]; |
154 |
t.xm[ip] = xm[ip]; |
155 |
t.ym[ip] = ym[ip]; |
156 |
t.zm[ip] = zm[ip]; |
157 |
t.xma[ip] = xma[ip]; |
158 |
t.yma[ip] = yma[ip]; |
159 |
t.zma[ip] = zma[ip]; |
160 |
t.xmb[ip] = xmb[ip]; |
161 |
t.ymb[ip] = ymb[ip]; |
162 |
t.zmb[ip] = zmb[ip]; |
163 |
t.resx[ip] = resx[ip]; |
164 |
t.resy[ip] = resy[ip]; |
165 |
t.xv[ip] = xv[ip]; |
166 |
t.yv[ip] = yv[ip]; |
167 |
t.zv[ip] = zv[ip]; |
168 |
t.axv[ip] = axv[ip]; |
169 |
t.ayv[ip] = ayv[ip]; |
170 |
t.dedx_x[ip] = dedx_x[ip]; |
171 |
t.dedx_y[ip] = dedx_y[ip]; |
172 |
}; |
173 |
int ngf = TrkParams::nGF; |
174 |
for(int i=0; i<ngf; i++){ |
175 |
t.xGF[i] = xGF[i]; |
176 |
t.yGF[i] = yGF[i]; |
177 |
} |
178 |
|
179 |
}; |
180 |
//-------------------------------------- |
181 |
// |
182 |
// |
183 |
//-------------------------------------- |
184 |
void ExtTrack::Set( TrkTrack& t , int index){ |
185 |
|
186 |
// cout << "Set("<< &t <<", "<<index<<")"<<endl; |
187 |
if(index < 0 ){ //NON FUNZIONA |
188 |
cout << "Clear() "<<endl; |
189 |
Reset();//reset variables |
190 |
Clear();//deallocate vectors |
191 |
cout << "SetDimension("<<t.GetNhit()<<")"<<endl; |
192 |
SetDimension(t.GetNhit()); //allocate vectors |
193 |
// }else{ |
194 |
// SetDimension(6+index); |
195 |
} |
196 |
// default fit settings (the same as TrkTrack) |
197 |
SetMiniDefault(); |
198 |
SetZ0(23.5); |
199 |
// |
200 |
int ipp; |
201 |
if(index<0) ipp = 0; |
202 |
else ipp = index; |
203 |
// |
204 |
// cout << "Assign... nplanes = "<<nplanes<<endl; |
205 |
for(int ip=0;ip<6;ip++){ |
206 |
|
207 |
if(ipp>=nplanes){ |
208 |
cout << "void ExtTrack::Set( TrkTrack& , "<<index<<") -- ipp="<<ipp<<" exceed vector dimention "<<nplanes<<endl; |
209 |
continue; |
210 |
} |
211 |
|
212 |
if( t.XGood(ip) || t.YGood(ip) || !(index<0) ){ |
213 |
|
214 |
// cout << "ipp "<<ipp<<" ip "<<ip<<endl; |
215 |
|
216 |
|
217 |
xgood[ipp] = t.XGood(ip); //NB! |
218 |
ygood[ipp] = t.YGood(ip); //NB! |
219 |
multmaxx[ipp] = t.multmaxx[ip]; |
220 |
multmaxy[ipp] = t.multmaxy[ip]; |
221 |
xm[ipp] = t.xm[ip]; |
222 |
ym[ipp] = t.ym[ip]; |
223 |
zm[ipp] = t.zm[ip]; |
224 |
|
225 |
float dummy = -100.; |
226 |
xma[ipp] = dummy; |
227 |
yma[ipp] = dummy; |
228 |
zma[ipp] = zm[ipp]; |
229 |
xmb[ipp] = dummy; |
230 |
ymb[ipp] = dummy; |
231 |
zmb[ipp] = zm[ipp]; |
232 |
|
233 |
if( t.XGood(ip)*t.YGood(ip) ){ //double hit |
234 |
xma[ipp] = t.xm[ip]; |
235 |
yma[ipp] = t.ym[ip]; |
236 |
zma[ipp] = t.zm[ip]; |
237 |
xmb[ipp] = t.xm[ip]; |
238 |
ymb[ipp] = t.ym[ip]; |
239 |
zmb[ipp] = t.zm[ip]; |
240 |
} else if (t.XGood(ip) || t.YGood(ip) ){ //single hit |
241 |
TrkParams::Load(5); |
242 |
if( !TrkParams::IsLoaded(5) ){ |
243 |
cout << "void ExtTrack::FillMiniStruct(TrkTrack&) ---ERROR--- trk align.param. not loaded "<<endl; |
244 |
return; |
245 |
} |
246 |
double segment = 7.;// 2.;//cm //Elena 10th |
247 |
int is = (int)t.GetSensor(ip); if(ip==5)is=1-is; |
248 |
int ippp = 5-ip; |
249 |
int il = (int)t.GetLadder(ip); |
250 |
// NB: i parametri di allineamento hanno una notazione particolare!!! |
251 |
// sensor = 0 (hybrid side), 1 |
252 |
// ladder = 0-2 (increasing x) |
253 |
// plane = 0-5 (from bottom to top!!!) |
254 |
double omega = 0.; |
255 |
double beta = 0.; |
256 |
double gamma = 0.; |
257 |
if( |
258 |
(is < 0 || is > 1 || ip < 0 || ippp > 5 || il < 0 || il > 2) && |
259 |
true){ |
260 |
cout << " void ExtTrack::FillMiniStruct(TrkTrack&) --- WARNING ---trk sensor not defined, cannot read alignment parameters "<<endl; |
261 |
cout << " is ip il = "<<is<<" "<<ippp<<" "<<il<<endl; |
262 |
}else{ |
263 |
omega = alignparameters_.omega[is][il][ippp]; |
264 |
beta = alignparameters_.beta[is][il][ippp]; |
265 |
gamma = alignparameters_.gamma[is][il][ippp]; |
266 |
} |
267 |
if( t.XGood(ip) && !t.YGood(ip) ){ |
268 |
xma[ipp] = t.xm[ip] - omega * segment; |
269 |
yma[ipp] = t.ym[ip] + segment; |
270 |
zma[ipp] = t.zm[ip] + beta * segment;//not used yet |
271 |
xmb[ipp] = t.xm[ip] + omega * segment; |
272 |
ymb[ipp] = t.ym[ip] - segment; |
273 |
zmb[ipp] = t.zm[ip] - beta * segment;//not used yet |
274 |
}else if( !t.XGood(ip) && t.YGood(ip) ){ |
275 |
xma[ipp] = t.xm[ip] + segment; |
276 |
yma[ipp] = t.ym[ip] + omega * segment; |
277 |
zma[ipp] = t.zm[ip] - gamma * segment;//not used yet |
278 |
xmb[ipp] = t.xm[ip] - segment; |
279 |
ymb[ipp] = t.ym[ip] - omega * segment; |
280 |
zmb[ipp] = t.zm[ip] + gamma * segment;//not used yet |
281 |
} |
282 |
} |
283 |
|
284 |
// tailx[ipp] = t.tailx[ip]; |
285 |
// taily[ipp] = t.taily[ip]; |
286 |
resx[ipp] = t.resx[ip]; |
287 |
resy[ipp] = t.resy[ip]; |
288 |
xv[ipp] = t.xv[ip]; |
289 |
yv[ipp] = t.yv[ip]; |
290 |
zv[ipp] = t.zv[ip]; |
291 |
axv[ipp] = t.axv[ip]; |
292 |
ayv[ipp] = t.ayv[ip]; |
293 |
dedx_x[ipp] = t.dedx_x[ip]; |
294 |
dedx_y[ipp] = t.dedx_y[ip]; |
295 |
|
296 |
ipp++; |
297 |
|
298 |
} |
299 |
};//endl loop on planes |
300 |
|
301 |
chi2 = t.chi2; |
302 |
nstep = t.nstep; |
303 |
for(int it1=0;it1<5;it1++){ |
304 |
al[it1] = t.al[it1]; |
305 |
for(int it2=0;it2<5;it2++)coval[it1][it2] = t.coval[it1][it2]; |
306 |
}; |
307 |
|
308 |
}; |
309 |
//-------------------------------------- |
310 |
// |
311 |
// |
312 |
//-------------------------------------- |
313 |
void ExtTrack::SetMiniDefault(){ |
314 |
// cout << " ExtTrack::SetMiniDefault()"<<endl; |
315 |
exttrack_.trackmode = TrkParams::init__mini_trackmode; |
316 |
exttrack_.fact = TrkParams::init__mini_fact; |
317 |
exttrack_.istepmin = TrkParams::init__mini_istepmin; |
318 |
TrkParams::SetDeltaB(); |
319 |
TrkParams::SetDLT(); |
320 |
} |
321 |
//-------------------------------------- |
322 |
// |
323 |
// |
324 |
//-------------------------------------- |
325 |
void ExtTrack::SetDimension(int dim){ |
326 |
|
327 |
//cout << " ExtTrack::SetDimension("<<dim<<")"<<endl;; |
328 |
if(dim<=0){ |
329 |
nplanes = 0; |
330 |
if(dim<0)cout << "void ExtTrack::SetDimension("<<dim<<") --- invalid dimension "<<endl; |
331 |
return; |
332 |
} |
333 |
|
334 |
// Clear(); |
335 |
|
336 |
nplanes = dim; |
337 |
|
338 |
xgood = new int[nplanes]; |
339 |
ygood = new int[nplanes]; |
340 |
multmaxx = new int[nplanes]; |
341 |
multmaxy = new int[nplanes]; |
342 |
xm = new float[nplanes]; |
343 |
ym = new float[nplanes]; |
344 |
zm = new float[nplanes]; |
345 |
xma = new float[nplanes]; |
346 |
yma = new float[nplanes]; |
347 |
zma = new float[nplanes]; |
348 |
xmb = new float[nplanes]; |
349 |
ymb = new float[nplanes]; |
350 |
zmb = new float[nplanes]; |
351 |
resx = new float[nplanes]; |
352 |
resy = new float[nplanes]; |
353 |
xv = new float[nplanes]; |
354 |
yv = new float[nplanes]; |
355 |
zv = new float[nplanes]; |
356 |
axv = new float[nplanes]; |
357 |
ayv = new float[nplanes]; |
358 |
dedx_x = new float[nplanes]; |
359 |
dedx_y = new float[nplanes]; |
360 |
|
361 |
|
362 |
} |
363 |
//-------------------------------------- |
364 |
// |
365 |
// |
366 |
//-------------------------------------- |
367 |
bool ExtTrack::SetZ(int ip,float zmeas){ |
368 |
if(ip<0 || ip>=nplanes){ |
369 |
cout << " ExtTrack::SetZ("<<ip<<",...) ---> exceed vector dimension = "<<nplanes<<endl; |
370 |
return false; |
371 |
} |
372 |
zm[ip] = zmeas; |
373 |
zma[ip] = zmeas; |
374 |
zmb[ip] = zmeas; |
375 |
return true; |
376 |
|
377 |
}; |
378 |
|
379 |
bool ExtTrack::ResetXY(int ip){ |
380 |
|
381 |
// cout << " ExtTrack::ResetXY("<<ip<<") "<<endl; |
382 |
|
383 |
if(ip<0 || ip>=nplanes){ |
384 |
cout << " ExtTrack::ResetXY("<<ip<<",...) ---> exceed vector dimension = "<<nplanes<<endl; |
385 |
return false; |
386 |
} |
387 |
xm[ip] = -100.; |
388 |
ym[ip] = -100.; |
389 |
xma[ip] = -100.; |
390 |
yma[ip] = -100.; |
391 |
xmb[ip] = -100.; |
392 |
ymb[ip] = -100.; |
393 |
resx[ip] = 1000.; |
394 |
resy[ip] = 1000.; |
395 |
dedx_x[ip] = 0.; |
396 |
dedx_y[ip] = 0.; |
397 |
xgood[ip] = 0; |
398 |
ygood[ip] = 0; |
399 |
multmaxx[ip] = 0; |
400 |
multmaxy[ip] = 0; |
401 |
|
402 |
return true; |
403 |
|
404 |
}; |
405 |
|
406 |
bool ExtTrack::SetXY(int ip,float xmeas, float ymeas, float rx, float ry){ |
407 |
|
408 |
if(ip<0 || ip>=nplanes){ |
409 |
cout << " ExtTrack::SetXY("<<ip<<",...) ---> exceed vector dimension = "<<nplanes<<endl; |
410 |
return false; |
411 |
} |
412 |
|
413 |
xm[ip] = xmeas; |
414 |
ym[ip] = ymeas; |
415 |
xma[ip] = xmeas; |
416 |
yma[ip] = ymeas; |
417 |
xmb[ip] = xmeas; |
418 |
ymb[ip] = ymeas; |
419 |
resx[ip] = rx; |
420 |
resy[ip] = ry; |
421 |
// dedx_x[ip] = dedxx; |
422 |
// dedx_y[ip] = dedxy; |
423 |
xgood[ip] = 1; |
424 |
ygood[ip] = 1; |
425 |
|
426 |
return true; |
427 |
|
428 |
}; |
429 |
bool ExtTrack::SetX(int ip,float xa, float xb, float ya, float yb,float res ){ |
430 |
|
431 |
// cout << " ExtTrack::SetX("<<ip<<",...) -- nplanes"<<nplanes<<endl; |
432 |
|
433 |
if(ip<0 || ip>=nplanes){ |
434 |
cout << " ExtTrack::SetX("<<ip<<",...) ---> exceed vector dimension = "<<nplanes<<endl; |
435 |
return false; |
436 |
} |
437 |
xm[ip] = -100.; |
438 |
ym[ip] = -100.; |
439 |
xma[ip] = xa; |
440 |
yma[ip] = ya; |
441 |
xmb[ip] = xb; |
442 |
ymb[ip] = yb; |
443 |
resx[ip] = res; |
444 |
resy[ip] = 1000.; |
445 |
xgood[ip] = 1; |
446 |
ygood[ip] = 0; |
447 |
// dedx_x[ip] = dedx; |
448 |
// dedx_y[ip] = 0.; |
449 |
return true; |
450 |
}; |
451 |
bool ExtTrack::SetY(int ip,float xa, float xb, float ya, float yb,float res ){ |
452 |
|
453 |
// cout << " ExtTrack::SetY("<<ip<<",...) -- nplanes"<<nplanes<<endl; |
454 |
|
455 |
if(ip<0 || ip>=nplanes){ |
456 |
cout << " ExtTrack::SetX("<<ip<<",...) ---> exceed vector dimension = "<<nplanes<<endl; |
457 |
return false; |
458 |
} |
459 |
xm[ip] = -100.; |
460 |
ym[ip] = -100.; |
461 |
xma[ip] = xa; |
462 |
yma[ip] = ya; |
463 |
xmb[ip] = xb; |
464 |
ymb[ip] = yb; |
465 |
resx[ip] = 1000.; |
466 |
resy[ip] = res; |
467 |
xgood[ip] = 0; |
468 |
ygood[ip] = 1; |
469 |
// dedx_x[ip] = 0.; |
470 |
// dedx_y[ip] = dedx; |
471 |
return true; |
472 |
}; |
473 |
|
474 |
bool ExtTrack::SetXGood(int ip,int icl_piu_uno, int il, int is ){ |
475 |
|
476 |
// cout << " ExtTrack::SetXGood("<<ip<<",...) -- nplanes"<<nplanes<<endl; |
477 |
|
478 |
if(ip<0 || ip>=nplanes){ |
479 |
cout << " ExtTrack::SetXGood("<<ip<<",...) ---> exceed vector dimension = "<<nplanes<<endl; |
480 |
return false; |
481 |
} |
482 |
xgood[ip]=(il+1)*100000000+(is+1)*10000000+icl_piu_uno; |
483 |
return true; |
484 |
}; |
485 |
bool ExtTrack::SetYGood(int ip,int icl_piu_uno, int il, int is ){ |
486 |
if(ip<0 || ip>=nplanes){ |
487 |
cout << " ExtTrack::SetYGood("<<ip<<",...) -- nplanes"<<nplanes<<endl; |
488 |
cout << " ExtTrack::SetYGood("<<ip<<",...) ---> exceed vector dimension = "<<nplanes<<endl; |
489 |
return false; |
490 |
} |
491 |
ygood[ip]=(il+1)*100000000+(is+1)*10000000+icl_piu_uno; |
492 |
return true; |
493 |
}; |
494 |
|
495 |
//-------------------------------------- |
496 |
// |
497 |
// |
498 |
//-------------------------------------- |
499 |
void ExtTrack::Clear(Option_t* option){ |
500 |
|
501 |
// cout << " ExtTrack::Clear("<<option<<") "<<this<<endl; |
502 |
|
503 |
|
504 |
// cout << " xgood "<<xgood<<endl; |
505 |
|
506 |
// if(nplanes>0){ |
507 |
if(xgood) delete [] xgood; |
508 |
if(ygood) delete [] ygood; |
509 |
if(multmaxx) delete [] multmaxx; |
510 |
if(multmaxy) delete [] multmaxy; |
511 |
if(xm) delete [] xm; |
512 |
if(ym) delete [] ym; |
513 |
if(zm) delete [] zm; |
514 |
if(xma) delete [] xma; |
515 |
if(yma) delete [] yma; |
516 |
if(zma) delete [] zma; |
517 |
if(xmb) delete [] xmb; |
518 |
if(ymb) delete [] ymb; |
519 |
if(zmb) delete [] zmb; |
520 |
if(resx) delete [] resx; |
521 |
if(resy) delete [] resy; |
522 |
if(xv) delete [] xv; |
523 |
if(yv) delete [] yv; |
524 |
if(zv) delete [] zv; |
525 |
if(axv) delete [] axv; |
526 |
if(ayv) delete [] ayv; |
527 |
if(dedx_x)delete [] dedx_x; |
528 |
if(dedx_y)delete [] dedx_y; |
529 |
//} |
530 |
|
531 |
xgood = NULL; |
532 |
ygood = NULL; |
533 |
multmaxx = NULL; |
534 |
multmaxy = NULL; |
535 |
xm = NULL; |
536 |
ym = NULL; |
537 |
zm = NULL; |
538 |
xma = NULL; |
539 |
yma = NULL; |
540 |
zma = NULL; |
541 |
xmb = NULL; |
542 |
ymb = NULL; |
543 |
zmb = NULL; |
544 |
resx = NULL; |
545 |
resy = NULL; |
546 |
xv = NULL; |
547 |
yv = NULL; |
548 |
zv = NULL; |
549 |
axv = NULL; |
550 |
ayv = NULL; |
551 |
dedx_x = NULL; |
552 |
dedx_y = NULL; |
553 |
|
554 |
nplanes = 0; |
555 |
|
556 |
// Reset(); |
557 |
|
558 |
}; |
559 |
|
560 |
void ExtTrack::Delete(){ |
561 |
Clear(); |
562 |
// delete [] xGF; |
563 |
// delete [] yGF; |
564 |
} |
565 |
|
566 |
//-------------------------------------- |
567 |
// |
568 |
// |
569 |
//-------------------------------------- |
570 |
|
571 |
// /** |
572 |
// * Set the position measurements |
573 |
// */ |
574 |
// void ExtTrack::SetMeasure(Double_t *xmeas, Double_t *ymeas, Double_t *zmeas){ |
575 |
// for(int i=0; i<nplanes; i++) xm[i]= (xmeas? *xmeas++ : 0.); |
576 |
// for(int i=0; i<nplanes; i++) ym[i]= (ymeas? *ymeas++ : 0.); |
577 |
// for(int i=0; i<nplanes; i++) zm[i]= (ymeas? *zmeas++ : 0.); |
578 |
// } |
579 |
// /** |
580 |
// * Set the TrkTrack position resolution |
581 |
// */ |
582 |
// void ExtTrack::SetResolution(Double_t *rx, Double_t *ry){ |
583 |
// for(int i=0; i<nplanes; i++) resx[i]= (rx? *rx++ : 0.); |
584 |
// for(int i=0; i<nplanes; i++) resy[i]= (ry? *ry++ : 0.); |
585 |
// } |
586 |
// /** |
587 |
// * Set the TrkTrack good measurement |
588 |
// */ |
589 |
// void ExtTrack::SetGood(int *xg, int *yg){ |
590 |
|
591 |
// for(int i=0; i<nplanes; i++) xgood[i]=(xg? *xg++ : 0 ); |
592 |
// for(int i=0; i<nplanes; i++) ygood[i]=(yg? *yg++ : 0 ); |
593 |
// } |
594 |
|
595 |
//-------------------------------------- |
596 |
// |
597 |
// |
598 |
//-------------------------------------- |
599 |
void ExtTrack::Dump(){ |
600 |
cout << endl << "========== Track " ; |
601 |
cout << endl << "zini : "<< zini; |
602 |
cout << endl << "al : "; for(int i=0; i<5; i++)cout << al[i] << " "; |
603 |
cout << endl << "chi^2 : "<< chi2; |
604 |
cout << endl << "n.step : "<< nstep; |
605 |
cout << endl << "xgood : "; for(int i=0; i<nplanes; i++)cout << XGood(i) ; |
606 |
cout << endl << "ygood : "; for(int i=0; i<nplanes; i++)cout << YGood(i) ; |
607 |
cout << endl << "xm : "; for(int i=0; i<nplanes; i++)cout << xm[i] << " "; |
608 |
cout << endl << "ym : "; for(int i=0; i<nplanes; i++)cout << ym[i] << " "; |
609 |
cout << endl << "zm : "; for(int i=0; i<nplanes; i++)cout << zm[i] << " "; |
610 |
cout << endl << "xma : "; for(int i=0; i<nplanes; i++)cout << xma[i] << " "; |
611 |
cout << endl << "yma : "; for(int i=0; i<nplanes; i++)cout << yma[i] << " "; |
612 |
cout << endl << "zma : "; for(int i=0; i<nplanes; i++)cout << zma[i] << " "; |
613 |
cout << endl << "xmb : "; for(int i=0; i<nplanes; i++)cout << xmb[i] << " "; |
614 |
cout << endl << "ymb : "; for(int i=0; i<nplanes; i++)cout << ymb[i] << " "; |
615 |
cout << endl << "zmb : "; for(int i=0; i<nplanes; i++)cout << zmb[i] << " "; |
616 |
cout << endl << "xv : "; for(int i=0; i<nplanes; i++)cout << xv[i] << " "; |
617 |
cout << endl << "yv : "; for(int i=0; i<nplanes; i++)cout << yv[i] << " "; |
618 |
cout << endl << "zv : "; for(int i=0; i<nplanes; i++)cout << zv[i] << " "; |
619 |
cout << endl << "resx : "; for(int i=0; i<nplanes; i++)cout << resx[i] << " "; |
620 |
cout << endl << "resy : "; for(int i=0; i<nplanes; i++)cout << resy[i] << " "; |
621 |
cout << endl << "coval : "; for(int i=0; i<5; i++)cout << coval[0][i]<<" "; |
622 |
cout << endl << " "; for(int i=0; i<5; i++)cout << coval[1][i]<<" "; |
623 |
cout << endl << " "; for(int i=0; i<5; i++)cout << coval[2][i]<<" "; |
624 |
cout << endl << " "; for(int i=0; i<5; i++)cout << coval[3][i]<<" "; |
625 |
cout << endl << " "; for(int i=0; i<5; i++)cout << coval[4][i]<<" "; |
626 |
cout << endl << "MDR : "<< (coval[4][4]>0. ? 1./sqrt(coval[4][4]) : 0. ) ; |
627 |
cout << endl << "dedx_x : "; for(int i=0; i<nplanes; i++)cout << dedx_x[i] << " "; |
628 |
cout << endl << "dedx_y : "; for(int i=0; i<nplanes; i++)cout << dedx_y[i] << " "; |
629 |
|
630 |
cout << endl << "================="; |
631 |
cout << endl; |
632 |
} |
633 |
/** |
634 |
* Reset the fit parameters |
635 |
*/ |
636 |
void ExtTrack::ResetFit(){ |
637 |
|
638 |
// cout << " ExtTrack::ResetFit() "<<endl; |
639 |
for(int i=0; i<5; i++) al[i]=-9999.; |
640 |
chi2=0.; |
641 |
nstep=0; |
642 |
|
643 |
for(int i=0; i<5; i++) { |
644 |
for(int j=0; j<5; j++) coval[i][j]=0.; |
645 |
} |
646 |
|
647 |
for(int i=0; i<nplanes; i++){ |
648 |
xv[i] = 0.; |
649 |
yv[i] = 0.; |
650 |
zv[i] = 0.; |
651 |
axv[i] = 0.; |
652 |
ayv[i] = 0.; |
653 |
} |
654 |
|
655 |
int ngf = TrkParams::nGF; |
656 |
for(int i=0; i<ngf; i++){ |
657 |
xGF[i] = 0.; |
658 |
yGF[i] = 0.; |
659 |
} |
660 |
|
661 |
|
662 |
} |
663 |
/** |
664 |
* Reset x/y measured coordinates (NB it does not reset z coordinates) |
665 |
*/ |
666 |
void ExtTrack::ResetXY(){ |
667 |
|
668 |
for(int i=0; i<nplanes; i++)ResetXY(i); |
669 |
|
670 |
|
671 |
} |
672 |
/** |
673 |
* \brief Tracking method. It calls F77 mini routine. |
674 |
* |
675 |
* @see void TrkTrack::Fit(double, int&, int, int) |
676 |
*/ |
677 |
void ExtTrack::Fit(double pfixed, int& fail, int iprint){ |
678 |
|
679 |
TrkParams::Load(1); |
680 |
if( !TrkParams::IsLoaded(1) ){ |
681 |
cout << "void ExtTrack::Fit(double,int&,int,int) ---ERROR--- m.field not loaded "<<endl; |
682 |
return; |
683 |
} |
684 |
|
685 |
float al_ini[] = {0.,0.,0.,0.,0.}; |
686 |
|
687 |
fail = 0; |
688 |
|
689 |
FillMiniStruct(); //fill F77 common |
690 |
|
691 |
|
692 |
// if fit variables have been reset, evaluate the initial guess |
693 |
if(al[0]==-9999.&&al[1]==-9999.&&al[2]==-9999.&&al[3]==-9999.&&al[4]==-9999.){ |
694 |
if(iprint==2)cout << "calling guessext_()"<<endl; |
695 |
guessext_(); |
696 |
} |
697 |
// --------------------- free momentum |
698 |
if(pfixed==0.) { |
699 |
exttrack_.pfixed=0.; |
700 |
} |
701 |
// --------------------- fixed momentum |
702 |
if(pfixed!=0.) { |
703 |
al[4]=1./pfixed; |
704 |
exttrack_.pfixed=pfixed; |
705 |
} |
706 |
|
707 |
// store temporarily the initial guess |
708 |
for(int i=0; i<5; i++) al_ini[i]=exttrack_.al[i]; |
709 |
|
710 |
if(iprint==2){ |
711 |
cout<<endl<<" init. guess: "; |
712 |
for(int i=0; i<5; i++)cout << al_ini[i]<<" "; |
713 |
cout<<endl; |
714 |
} |
715 |
// ------------------------------------------ |
716 |
// call mini routine |
717 |
// ------------------------------------------ |
718 |
int istep=0; |
719 |
int ifail=0; |
720 |
if(iprint==2)cout << "calling miniext_("<<istep<<","<<ifail<<", "<<iprint<<")"<<endl; |
721 |
miniext_(&istep,&ifail, &iprint); |
722 |
if(ifail!=0) { |
723 |
if(iprint)cout << "ERROR: ifail= " << ifail << endl; |
724 |
fail = 1; |
725 |
} |
726 |
if(chi2!=chi2){ |
727 |
if(iprint)cout << "ERROR: chi2= " << chi2 << endl; |
728 |
ResetFit(); |
729 |
fail = 1; |
730 |
} |
731 |
// ------------------------------------------ |
732 |
|
733 |
SetFromMiniStruct(); //copy content of F77 common into the ExtTrack object |
734 |
|
735 |
if(fail){ |
736 |
if(iprint)cout << " >>>> fit failed "<<endl; |
737 |
for(int i=0; i<5; i++) al[i]=al_ini[i]; |
738 |
} |
739 |
}; |
740 |
|
741 |
/** |
742 |
* Method to fill minimization-routine common |
743 |
* NB (zini=23.5 is implicitelly set) |
744 |
*/ |
745 |
void ExtTrack::FillMiniStruct(cMiniExtTrack& track){ |
746 |
|
747 |
track.nplanes = nplanes; |
748 |
for(int i=0; i<nplanes; i++){ |
749 |
|
750 |
track.xgood[i] = (double) XGood(i); |
751 |
track.ygood[i] = (double) YGood(i); |
752 |
|
753 |
track.xm[i] = (double) xm[i]; |
754 |
track.ym[i] = (double) ym[i]; |
755 |
track.zm[i] = (double) zm[i]; |
756 |
|
757 |
|
758 |
track.xm_a[i] = (double) xma[i]; |
759 |
track.xm_b[i] = (double) xmb[i]; |
760 |
track.ym_a[i] = (double) yma[i]; |
761 |
track.ym_b[i] = (double) ymb[i]; |
762 |
track.zm_a[i] = (double) zma[i]; |
763 |
track.zm_b[i] = (double) zmb[i]; |
764 |
|
765 |
track.resx[i] = (double) resx[i]; |
766 |
track.resy[i] = (double) resy[i]; |
767 |
} |
768 |
|
769 |
for(int i=0; i<5; i++) track.al[i] = (double) al[i]; |
770 |
|
771 |
track.zini = (double) zini; |
772 |
|
773 |
|
774 |
} |
775 |
/** |
776 |
* Method to set values from minimization-routine common |
777 |
*/ |
778 |
void ExtTrack::SetFromMiniStruct(cMiniExtTrack *track){ |
779 |
|
780 |
for(int i=0; i<5; i++) { |
781 |
al[i] = (float) (track->al[i]); |
782 |
for(int j=0; j<5; j++) coval[i][j] = (float) (track->cov[i][j]); |
783 |
} |
784 |
chi2 = (float) (track->chi2); |
785 |
nstep = (float) (track->nstep); |
786 |
for(int i=0; i<nplanes; i++){ |
787 |
xv[i] = (float) (track->xv[i]); |
788 |
yv[i] = (float) (track->yv[i]); |
789 |
zv[i] = (float) (track->zv[i]); |
790 |
xm[i] = (float) (track->xm[i]); |
791 |
ym[i] = (float) (track->ym[i]); |
792 |
zm[i] = (float) (track->zm[i]); |
793 |
xma[i] = (float) (track->xm_a[i]); |
794 |
yma[i] = (float) (track->ym_a[i]); |
795 |
zma[i] = (float) (track->zm_a[i]); |
796 |
xmb[i] = (float) (track->xm_b[i]); |
797 |
ymb[i] = (float) (track->ym_b[i]); |
798 |
zmb[i] = (float) (track->zm_b[i]); |
799 |
axv[i] = (float) (track->axv[i]); |
800 |
ayv[i] = (float) (track->ayv[i]); |
801 |
} |
802 |
zini = (float) (track->zini); |
803 |
} |
804 |
/** |
805 |
* Method to retrieve ID (0,1,...) of x-cluster (if any) associated to this track. |
806 |
* If no cluster is associated, ID=-1. |
807 |
* |
808 |
*/ |
809 |
int ExtTrack::GetClusterX_ID(int ip){ |
810 |
return ((int)fabs(xgood[ip]))%10000000-1; |
811 |
}; |
812 |
/** |
813 |
* Method to retrieve ID (0-xxx) of y-cluster (if any) associated to this track. |
814 |
* |
815 |
*/ |
816 |
int ExtTrack::GetClusterY_ID(int ip){ |
817 |
return ((int)fabs(ygood[ip]))%10000000-1; |
818 |
}; |
819 |
|
820 |
/** |
821 |
* Method to retrieve the dE/dx measured on a tracker view. |
822 |
* @param ip plane (0-5) |
823 |
* @param iv view (0=x 1=y) |
824 |
*/ |
825 |
Float_t ExtTrack::GetDEDX(int ip, int iv){ |
826 |
if(iv==0 && ip>=0 && ip<6)return fabs(dedx_x[ip]); |
827 |
else if(iv==1 && ip>=0 && ip<6)return fabs(dedx_y[ip]); |
828 |
else { |
829 |
cout << "TrkTrack::GetDEDX(int ip, int iv) -- wrong input parameters "<<ip<<iv<<endl; |
830 |
return 0.; |
831 |
} |
832 |
} |
833 |
/** |
834 |
* Method to evaluate the dE/dx measured on a tracker plane. |
835 |
* The two measurements on x- and y-view are averaged. |
836 |
* @param ip plane (0-5) |
837 |
*/ |
838 |
Float_t ExtTrack::GetDEDX(int ip){ |
839 |
if( (Int_t)XGood(ip)+(Int_t)YGood(ip) == 0 ) return 0; |
840 |
return (GetDEDX(ip,0)+GetDEDX(ip,1))/((Int_t)XGood(ip)+(Int_t)YGood(ip)); |
841 |
}; |
842 |
|
843 |
/** |
844 |
* Method to evaluate the dE/dx averaged over all planes. |
845 |
*/ |
846 |
Float_t ExtTrack::GetDEDX(){ |
847 |
Float_t dedx=0; |
848 |
for(Int_t ip=0; ip<6; ip++)dedx+=GetDEDX(ip,0)*XGood(ip)+GetDEDX(ip,1)*YGood(ip); |
849 |
dedx = dedx/(GetNX()+GetNY()); |
850 |
return dedx; |
851 |
}; |
852 |
|
853 |
/** |
854 |
* Method to retrieve the ladder, if assigned |
855 |
*/ |
856 |
int ExtTrack::GetLadder(int ip){ |
857 |
if(XGood(ip))return (int)fabs(xgood[ip]/100000000)-1; |
858 |
if(YGood(ip))return (int)fabs(ygood[ip]/100000000)-1; |
859 |
return -1; |
860 |
}; |
861 |
/** |
862 |
* Method to retrieve the sensor, if assigned |
863 |
*/ |
864 |
int ExtTrack::GetSensor(int ip){ |
865 |
if(XGood(ip))return (int)((int)fabs(xgood[ip]/10000000)%10)-1; |
866 |
if(YGood(ip))return (int)((int)fabs(ygood[ip]/10000000)%10)-1; |
867 |
return -1; |
868 |
}; |
869 |
/** |
870 |
* |
871 |
*/ |
872 |
Int_t ExtTrack::GetClusterX_Multiplicity(int ip){ |
873 |
if(ip<0 || ip>=nplanes){ |
874 |
cout << " ExtTrack::GetClusterX_Multiplicity("<<ip<<",...) ---> exceed vector dimension = "<<nplanes<<endl; |
875 |
return -1; |
876 |
} |
877 |
return (Int_t)(multmaxx[ip]/10000); |
878 |
} |
879 |
/** |
880 |
* |
881 |
*/ |
882 |
|
883 |
Int_t ExtTrack::GetClusterY_Multiplicity(int ip){ |
884 |
if(ip<0 || ip>=nplanes){ |
885 |
cout << " ExtTrack::GetClusterY_Multiplicity("<<ip<<",...) ---> exceed vector dimension = "<<nplanes<<endl; |
886 |
return -1; |
887 |
} |
888 |
return (Int_t)(multmaxy[ip]/10000); |
889 |
} |
890 |
/** |
891 |
* |
892 |
*/ |
893 |
|
894 |
Int_t ExtTrack::GetClusterX_MaxStrip(int ip){ |
895 |
if(ip<0 || ip>=nplanes){ |
896 |
cout << " ExtTrack::GetClusterX_MaxStrip("<<ip<<",...) ---> exceed vector dimension = "<<nplanes<<endl; |
897 |
return -1; |
898 |
} |
899 |
return (Int_t)(multmaxx[ip]%10000); |
900 |
} |
901 |
/** |
902 |
* |
903 |
*/ |
904 |
|
905 |
Int_t ExtTrack::GetClusterY_MaxStrip(int ip){ |
906 |
if(ip<0 || ip>=nplanes){ |
907 |
cout << " ExtTrack::GetClusterY_MaxStrip("<<ip<<",...) ---> exceed vector dimension = "<<nplanes<<endl; |
908 |
return -1; |
909 |
} |
910 |
return (Int_t)(multmaxy[ip]%10000); |
911 |
} |
912 |
Float_t ExtTrack::GetRigidity(){ |
913 |
Float_t rig=0; |
914 |
if(chi2>0)rig=1./al[4]; |
915 |
if(rig<0) rig=-rig; |
916 |
return rig; |
917 |
}; |
918 |
// |
919 |
Float_t ExtTrack::GetDeflection(){ |
920 |
Float_t def=0; |
921 |
if(chi2>0)def=al[4]; |
922 |
return def; |
923 |
}; |
924 |
ClassImp(ExtTrack); |