4 |
*/ |
*/ |
5 |
#include <TrkLevel2.h> |
#include <TrkLevel2.h> |
6 |
#include <iostream> |
#include <iostream> |
7 |
|
#include <math.h> |
8 |
using namespace std; |
using namespace std; |
9 |
//...................................... |
//...................................... |
10 |
// F77 routines |
// F77 routines |
11 |
//...................................... |
//...................................... |
12 |
extern "C" { |
extern "C" { |
13 |
void dotrack_(int*, double*, double*, double*, double*, int*); |
void dotrack_(int*, double*, double*, double*, double*, int*); |
14 |
int readb_(const char*); |
void dotrack2_(int*, double*, double*, double*, double*,double*, double*, double*,int*); |
15 |
|
// int readb_(const char*); |
16 |
|
int readb_(); |
17 |
|
void mini2_(int*,int*,int*); |
18 |
|
void guess_(); |
19 |
} |
} |
20 |
//-------------------------------------- |
//-------------------------------------- |
21 |
// |
// |
22 |
// |
// |
23 |
//-------------------------------------- |
//-------------------------------------- |
24 |
TrkTrack::TrkTrack(){ |
TrkTrack::TrkTrack(){ |
25 |
image = 0; |
// cout << "TrkTrack::TrkTrack()" << endl; |
26 |
|
seqno = -1; |
27 |
|
image = -1; |
28 |
chi2 = 0; |
chi2 = 0; |
29 |
|
nstep = 0; |
30 |
for(int it1=0;it1<5;it1++){ |
for(int it1=0;it1<5;it1++){ |
31 |
al[it1] = 0; |
al[it1] = 0; |
32 |
for(int it2=0;it2<5;it2++) |
for(int it2=0;it2<5;it2++)coval[it1][it2] = 0; |
|
coval[it1][it2] = 0; |
|
33 |
}; |
}; |
34 |
for(int ip=0;ip<6;ip++){ |
for(int ip=0;ip<6;ip++){ |
35 |
xgood[ip] = 0; |
xgood[ip] = 0; |
46 |
ayv[ip] = 0; |
ayv[ip] = 0; |
47 |
dedx_x[ip] = 0; |
dedx_x[ip] = 0; |
48 |
dedx_y[ip] = 0; |
dedx_y[ip] = 0; |
49 |
}; |
}; |
50 |
|
clx = 0; |
51 |
|
cly = 0; |
52 |
}; |
}; |
53 |
//-------------------------------------- |
//-------------------------------------- |
54 |
// |
// |
55 |
// |
// |
56 |
//-------------------------------------- |
//-------------------------------------- |
57 |
TrkTrack::TrkTrack(const TrkTrack& t){ |
TrkTrack::TrkTrack(const TrkTrack& t){ |
58 |
|
seqno = t.seqno; |
59 |
image = t.image; |
image = t.image; |
60 |
chi2 = t.chi2; |
chi2 = t.chi2; |
61 |
|
nstep = t.nstep; |
62 |
for(int it1=0;it1<5;it1++){ |
for(int it1=0;it1<5;it1++){ |
63 |
al[it1] = t.al[it1]; |
al[it1] = t.al[it1]; |
64 |
for(int it2=0;it2<5;it2++) |
for(int it2=0;it2<5;it2++)coval[it1][it2] = t.coval[it1][it2]; |
|
coval[it1][it2] = t.coval[it1][it2]; |
|
65 |
}; |
}; |
66 |
for(int ip=0;ip<6;ip++){ |
for(int ip=0;ip<6;ip++){ |
67 |
xgood[ip] = t.xgood[ip]; |
xgood[ip] = t.xgood[ip]; |
78 |
ayv[ip] = t.ayv[ip]; |
ayv[ip] = t.ayv[ip]; |
79 |
dedx_x[ip] = t.dedx_x[ip]; |
dedx_x[ip] = t.dedx_x[ip]; |
80 |
dedx_y[ip] = t.dedx_y[ip]; |
dedx_y[ip] = t.dedx_y[ip]; |
81 |
}; |
}; |
82 |
|
clx = 0; |
83 |
|
cly = 0; |
84 |
|
if(t.clx)clx = new TRefArray(*(t.clx)); |
85 |
|
if(t.cly)cly = new TRefArray(*(t.cly)); |
86 |
|
|
87 |
|
}; |
88 |
|
//-------------------------------------- |
89 |
|
// |
90 |
|
// |
91 |
|
//-------------------------------------- |
92 |
|
void TrkTrack::Copy(TrkTrack& t){ |
93 |
|
|
94 |
|
t.seqno = seqno; |
95 |
|
t.image = image; |
96 |
|
t.chi2 = chi2; |
97 |
|
t.nstep = nstep; |
98 |
|
for(int it1=0;it1<5;it1++){ |
99 |
|
t.al[it1] = al[it1]; |
100 |
|
for(int it2=0;it2<5;it2++)t.coval[it1][it2] = coval[it1][it2]; |
101 |
|
}; |
102 |
|
for(int ip=0;ip<6;ip++){ |
103 |
|
t.xgood[ip] = xgood[ip]; |
104 |
|
t.ygood[ip] = ygood[ip]; |
105 |
|
t.xm[ip] = xm[ip]; |
106 |
|
t.ym[ip] = ym[ip]; |
107 |
|
t.zm[ip] = zm[ip]; |
108 |
|
t.resx[ip] = resx[ip]; |
109 |
|
t.resy[ip] = resy[ip]; |
110 |
|
t.xv[ip] = xv[ip]; |
111 |
|
t.yv[ip] = yv[ip]; |
112 |
|
t.zv[ip] = zv[ip]; |
113 |
|
t.axv[ip] = axv[ip]; |
114 |
|
t.ayv[ip] = ayv[ip]; |
115 |
|
t.dedx_x[ip] = dedx_x[ip]; |
116 |
|
t.dedx_y[ip] = dedx_y[ip]; |
117 |
|
|
118 |
|
}; |
119 |
|
|
120 |
}; |
}; |
121 |
//-------------------------------------- |
//-------------------------------------- |
122 |
// |
// |
158 |
// |
// |
159 |
// |
// |
160 |
//-------------------------------------- |
//-------------------------------------- |
161 |
|
/** |
162 |
|
* Evaluates the trajectory in the apparatus associated to the track. |
163 |
|
* It integrates the equations of motion in the magnetic field. The magnetic field should be previously loaded ( by calling TrkLevel2::LoadField() ), otherwise an error message is returned. |
164 |
|
* @param t pointer to an object of the class Trajectory, |
165 |
|
* which z coordinates should be previously initialized by calling the proper constructor ( Trajectory::Trajectory(int n, float* zin) ). |
166 |
|
* @return error flag. |
167 |
|
*/ |
168 |
|
int TrkTrack::DoTrack2(Trajectory* t){ |
169 |
|
|
170 |
|
double *dxout = new double[t->npoint]; |
171 |
|
double *dyout = new double[t->npoint]; |
172 |
|
double *dthxout = new double[t->npoint]; |
173 |
|
double *dthyout = new double[t->npoint]; |
174 |
|
double *dtlout = new double[t->npoint]; |
175 |
|
double *dzin = new double[t->npoint]; |
176 |
|
double dal[5]; |
177 |
|
|
178 |
|
int ifail = 0; |
179 |
|
|
180 |
|
for (int i=0; i<5; i++) dal[i] = (double)al[i]; |
181 |
|
for (int i=0; i<t->npoint; i++) dzin[i] = (double)t->z[i]; |
182 |
|
|
183 |
|
dotrack2_(&(t->npoint),dzin,dxout,dyout,dthxout,dthyout,dtlout,dal,&ifail); |
184 |
|
|
185 |
|
for (int i=0; i<t->npoint; i++){ |
186 |
|
t->x[i] = (float)*dxout++; |
187 |
|
t->y[i] = (float)*dyout++; |
188 |
|
t->thx[i] = (float)*dthxout++; |
189 |
|
t->thy[i] = (float)*dthyout++; |
190 |
|
t->tl[i] = (float)*dtlout++; |
191 |
|
} |
192 |
|
|
193 |
|
// delete [] dxout; |
194 |
|
// delete [] dyout; |
195 |
|
// delete [] dzin; |
196 |
|
|
197 |
|
return ifail; |
198 |
|
}; |
199 |
|
//-------------------------------------- |
200 |
|
// |
201 |
|
// |
202 |
|
//-------------------------------------- |
203 |
//float TrkTrack::BdL(){ |
//float TrkTrack::BdL(){ |
204 |
//}; |
//}; |
205 |
//-------------------------------------- |
//-------------------------------------- |
232 |
//-------------------------------------- |
//-------------------------------------- |
233 |
void TrkTrack::Dump(){ |
void TrkTrack::Dump(){ |
234 |
cout << endl << "========== Track " ; |
cout << endl << "========== Track " ; |
235 |
|
cout << endl << "seq. n. : "<< seqno; |
236 |
|
cout << endl << "image n. : "<< image; |
237 |
cout << endl << "al : "; for(int i=0; i<5; i++)cout << al[i] << " "; |
cout << endl << "al : "; for(int i=0; i<5; i++)cout << al[i] << " "; |
238 |
cout << endl << "chi^2 : "<< chi2; |
cout << endl << "chi^2 : "<< chi2; |
239 |
|
cout << endl << "n.step : "<< nstep; |
240 |
cout << endl << "xgood : "; for(int i=0; i<6; i++)cout << xgood[i] ; |
cout << endl << "xgood : "; for(int i=0; i<6; i++)cout << xgood[i] ; |
241 |
cout << endl << "ygood : "; for(int i=0; i<6; i++)cout << ygood[i] ; |
cout << endl << "ygood : "; for(int i=0; i<6; i++)cout << ygood[i] ; |
242 |
cout << endl << "xm : "; for(int i=0; i<6; i++)cout << xm[i] << " "; |
cout << endl << "xm : "; for(int i=0; i<6; i++)cout << xm[i] << " "; |
243 |
cout << endl << "ym : "; for(int i=0; i<6; i++)cout << ym[i] << " "; |
cout << endl << "ym : "; for(int i=0; i<6; i++)cout << ym[i] << " "; |
244 |
cout << endl << "zm : "; for(int i=0; i<6; i++)cout << zm[i] << " "; |
cout << endl << "zm : "; for(int i=0; i<6; i++)cout << zm[i] << " "; |
245 |
|
cout << endl << "xv : "; for(int i=0; i<6; i++)cout << xv[i] << " "; |
246 |
|
cout << endl << "yv : "; for(int i=0; i<6; i++)cout << yv[i] << " "; |
247 |
|
cout << endl << "zv : "; for(int i=0; i<6; i++)cout << zv[i] << " "; |
248 |
|
cout << endl << "resx : "; for(int i=0; i<6; i++)cout << resx[i] << " "; |
249 |
|
cout << endl << "resy : "; for(int i=0; i<6; i++)cout << resy[i] << " "; |
250 |
|
cout << endl << "coval : "; for(int i=0; i<5; i++)cout << coval[0][i]<<" "; |
251 |
|
cout << endl << " "; for(int i=0; i<5; i++)cout << coval[1][i]<<" "; |
252 |
|
cout << endl << " "; for(int i=0; i<5; i++)cout << coval[2][i]<<" "; |
253 |
|
cout << endl << " "; for(int i=0; i<5; i++)cout << coval[3][i]<<" "; |
254 |
|
cout << endl << " "; for(int i=0; i<5; i++)cout << coval[4][i]<<" "; |
255 |
cout << endl << "dedx_x : "; for(int i=0; i<6; i++)cout << dedx_x[i] << " "; |
cout << endl << "dedx_x : "; for(int i=0; i<6; i++)cout << dedx_x[i] << " "; |
256 |
cout << endl << "dedx_y : "; for(int i=0; i<6; i++)cout << dedx_y[i] << " "; |
cout << endl << "dedx_y : "; for(int i=0; i<6; i++)cout << dedx_y[i] << " "; |
257 |
|
cout << endl; |
258 |
} |
} |
259 |
|
/** |
260 |
|
* Set the TrkTrack position measurements |
261 |
|
*/ |
262 |
|
void TrkTrack::SetMeasure(double *xmeas, double *ymeas, double *zmeas){ |
263 |
|
for(int i=0; i<6; i++) xm[i]=*xmeas++; |
264 |
|
for(int i=0; i<6; i++) ym[i]=*ymeas++; |
265 |
|
for(int i=0; i<6; i++) zm[i]=*zmeas++; |
266 |
|
} |
267 |
|
/** |
268 |
|
* Set the TrkTrack position resolution |
269 |
|
*/ |
270 |
|
void TrkTrack::SetResolution(double *rx, double *ry){ |
271 |
|
for(int i=0; i<6; i++) resx[i]=*rx++; |
272 |
|
for(int i=0; i<6; i++) resy[i]=*ry++; |
273 |
|
} |
274 |
|
/** |
275 |
|
* Set the TrkTrack good measurement |
276 |
|
*/ |
277 |
|
void TrkTrack::SetGood(int *xg, int *yg){ |
278 |
|
for(int i=0; i<6; i++) xgood[i]=*xg++; |
279 |
|
for(int i=0; i<6; i++) ygood[i]=*yg++; |
280 |
|
} |
281 |
|
|
282 |
|
/** |
283 |
|
* Load the magnetic field |
284 |
|
*/ |
285 |
|
void TrkTrack::LoadField(TString path){ |
286 |
|
|
287 |
|
strcpy(path_.path,path.Data()); |
288 |
|
path_.pathlen = path.Length(); |
289 |
|
path_.error = 0; |
290 |
|
readb_(); |
291 |
|
|
292 |
|
}; |
293 |
|
|
294 |
|
/** |
295 |
|
* Method to fill minimization-routine common |
296 |
|
*/ |
297 |
|
void TrkTrack::FillMiniStruct(cMini2track& track){ |
298 |
|
|
299 |
|
for(int i=0; i<6; i++){ |
300 |
|
|
301 |
|
track.xgood[i]=xgood[i]; |
302 |
|
track.ygood[i]=ygood[i]; |
303 |
|
|
304 |
|
track.xm[i]=xm[i]; |
305 |
|
track.ym[i]=ym[i]; |
306 |
|
track.zm[i]=zm[i]; |
307 |
|
|
308 |
|
// --- temporaneo ---------------------------- |
309 |
|
// andrebbe inserita la dimensione del sensore |
310 |
|
float segment = 100.; |
311 |
|
track.xm_a[i]=xm[i]; |
312 |
|
track.xm_b[i]=xm[i]; |
313 |
|
track.ym_a[i]=ym[i]; |
314 |
|
track.ym_b[i]=ym[i]; |
315 |
|
if( xgood[i] && !ygood[i] ){ |
316 |
|
track.ym_a[i] = track.ym_a[i]+segment; |
317 |
|
track.ym_b[i] = track.ym_b[i]-segment; |
318 |
|
}else if( !xgood[i] && ygood[i]){ |
319 |
|
track.xm_a[i] = track.xm_a[i]+segment; |
320 |
|
track.xm_b[i] = track.xm_b[i]-segment; |
321 |
|
} |
322 |
|
// --- temporaneo ---------------------------- |
323 |
|
|
324 |
|
track.resx[i]=resx[i]; |
325 |
|
track.resy[i]=resy[i]; |
326 |
|
} |
327 |
|
|
328 |
|
for(int i=0; i<5; i++) track.al[i]=al[i]; |
329 |
|
track.zini = 23.5; |
330 |
|
// ZINI = 23.5 !!! it should be the same parameter in all codes |
331 |
|
|
332 |
|
} |
333 |
|
/** |
334 |
|
* Method to set values from minimization-routine common |
335 |
|
*/ |
336 |
|
void TrkTrack::SetFromMiniStruct(cMini2track *track){ |
337 |
|
|
338 |
|
for(int i=0; i<5; i++) { |
339 |
|
al[i]=track->al[i]; |
340 |
|
for(int j=0; j<5; j++) coval[i][j]=track->cov[i][j]; |
341 |
|
} |
342 |
|
chi2 = track->chi2; |
343 |
|
nstep = track->nstep; |
344 |
|
for(int i=0; i<6; i++){ |
345 |
|
xv[i] = track->xv[i]; |
346 |
|
yv[i] = track->yv[i]; |
347 |
|
zv[i] = track->zv[i]; |
348 |
|
xm[i] = track->xm[i]; |
349 |
|
ym[i] = track->ym[i]; |
350 |
|
zm[i] = track->zm[i]; |
351 |
|
axv[i] = track->axv[i]; |
352 |
|
ayv[i] = track->ayv[i]; |
353 |
|
} |
354 |
|
|
355 |
|
|
356 |
|
} |
357 |
|
/** |
358 |
|
* Tracking method. It calls F77 mini routine. |
359 |
|
*/ |
360 |
|
void TrkTrack::Fit(double pfixed, int& fail, int iprint){ |
361 |
|
|
362 |
|
float al_ini[] = {0.,0.,0.,0.,0.}; |
363 |
|
|
364 |
|
extern cMini2track track_; |
365 |
|
fail = 0; |
366 |
|
FillMiniStruct(track_); |
367 |
|
|
368 |
|
// if fit variables have been reset, evaluate the initial guess |
369 |
|
if(al[0]==-9999.&&al[1]==-9999.&&al[2]==-9999.&&al[3]==-9999.&&al[4]==-9999.)guess_(); |
370 |
|
|
371 |
|
// --------------------- free momentum |
372 |
|
if(pfixed==0.) { |
373 |
|
track_.pfixed=0.; |
374 |
|
} |
375 |
|
// --------------------- fixed momentum |
376 |
|
if(pfixed!=0.) { |
377 |
|
al[4]=1./pfixed; |
378 |
|
track_.pfixed=pfixed; |
379 |
|
} |
380 |
|
|
381 |
|
// store temporarily the initial guess |
382 |
|
for(int i=0; i<5; i++) al_ini[i]=track_.al[i]; |
383 |
|
|
384 |
|
// ------------------------------------------ |
385 |
|
// call mini routine |
386 |
|
int istep=0; |
387 |
|
int ifail=0; |
388 |
|
mini2_(&istep,&ifail, &iprint); |
389 |
|
if(ifail!=0) { |
390 |
|
if(iprint)cout << "ERROR: ifail= " << ifail << endl; |
391 |
|
fail = 1; |
392 |
|
} |
393 |
|
// ------------------------------------------ |
394 |
|
|
395 |
|
SetFromMiniStruct(&track_); |
396 |
|
// cout << endl << "eta ===> " << track_.al[4] << endl; |
397 |
|
|
398 |
|
// for(int i=0; i<5; i++) al[i]=track_.al[i]; |
399 |
|
// chi2=track_.chi2; |
400 |
|
// nstep=track_.nstep; |
401 |
|
// for(int i=0; i<6; i++) xv[i]=track_.xv[i]; |
402 |
|
// for(int i=0; i<6; i++) yv[i]=track_.yv[i]; |
403 |
|
// for(int i=0; i<6; i++) zv[i]=track_.zv[i]; |
404 |
|
// for(int i=0; i<6; i++) axv[i]=track_.axv[i]; |
405 |
|
// for(int i=0; i<6; i++) ayv[i]=track_.ayv[i]; |
406 |
|
// for(int i=0; i<5; i++) { |
407 |
|
// for(int j=0; j<5; j++) coval[i][j]=track_.cov[i][j]; |
408 |
|
// } |
409 |
|
|
410 |
|
if(fail){ |
411 |
|
if(iprint)cout << " >>>> fit failed >>>> drawing initial par"<<endl; |
412 |
|
for(int i=0; i<5; i++) al[i]=al_ini[i]; |
413 |
|
} |
414 |
|
|
415 |
|
}; |
416 |
|
/* |
417 |
|
* Reset the fit parameters |
418 |
|
*/ |
419 |
|
void TrkTrack::FitReset(){ |
420 |
|
for(int i=0; i<5; i++) al[i]=-9999.; |
421 |
|
chi2=0.; |
422 |
|
nstep=0; |
423 |
|
for(int i=0; i<6; i++) xv[i]=0.; |
424 |
|
for(int i=0; i<6; i++) yv[i]=0.; |
425 |
|
for(int i=0; i<6; i++) zv[i]=0.; |
426 |
|
for(int i=0; i<6; i++) axv[i]=0.; |
427 |
|
for(int i=0; i<6; i++) ayv[i]=0.; |
428 |
|
for(int i=0; i<5; i++) { |
429 |
|
for(int j=0; j<5; j++) coval[i][j]=0.; |
430 |
|
} |
431 |
|
} |
432 |
|
|
433 |
|
//-------------------------------------- |
434 |
|
// |
435 |
|
// |
436 |
|
//-------------------------------------- |
437 |
|
void TrkTrack::Clear(){ |
438 |
|
// cout << "TrkTrack::Clear()"<<endl; |
439 |
|
seqno = -1; |
440 |
|
image = -1; |
441 |
|
chi2 = 0; |
442 |
|
nstep = 0; |
443 |
|
for(int it1=0;it1<5;it1++){ |
444 |
|
al[it1] = 0; |
445 |
|
for(int it2=0;it2<5;it2++)coval[it1][it2] = 0; |
446 |
|
}; |
447 |
|
for(int ip=0;ip<6;ip++){ |
448 |
|
xgood[ip] = 0; |
449 |
|
ygood[ip] = 0; |
450 |
|
xm[ip] = 0; |
451 |
|
ym[ip] = 0; |
452 |
|
zm[ip] = 0; |
453 |
|
resx[ip] = 0; |
454 |
|
resy[ip] = 0; |
455 |
|
xv[ip] = 0; |
456 |
|
yv[ip] = 0; |
457 |
|
zv[ip] = 0; |
458 |
|
axv[ip] = 0; |
459 |
|
ayv[ip] = 0; |
460 |
|
dedx_x[ip] = 0; |
461 |
|
dedx_y[ip] = 0; |
462 |
|
|
463 |
|
}; |
464 |
|
if(clx)clx->Clear(); |
465 |
|
if(cly)cly->Clear(); |
466 |
|
}; |
467 |
|
//-------------------------------------- |
468 |
|
// |
469 |
|
// |
470 |
|
//-------------------------------------- |
471 |
|
void TrkTrack::Delete(){ |
472 |
|
// cout << "TrkTrack::Delete()"<<endl; |
473 |
|
// Clear(); |
474 |
|
if(clx)delete clx; |
475 |
|
if(cly)delete cly; |
476 |
|
}; |
477 |
|
//-------------------------------------- |
478 |
|
// |
479 |
|
// |
480 |
|
//-------------------------------------- |
481 |
|
|
482 |
//-------------------------------------- |
//-------------------------------------- |
483 |
// |
// |
484 |
// |
// |
485 |
//-------------------------------------- |
//-------------------------------------- |
486 |
TrkSinglet::TrkSinglet(){ |
TrkSinglet::TrkSinglet(){ |
487 |
|
// cout << "TrkSinglet::TrkSinglet() " << GetUniqueID()<<endl; |
488 |
plane = 0; |
plane = 0; |
489 |
coord[0] = 0; |
coord[0] = 0; |
490 |
coord[1] = 0; |
coord[1] = 0; |
491 |
sgnl = 0; |
sgnl = 0; |
492 |
|
// cls = 0; |
493 |
}; |
}; |
494 |
//-------------------------------------- |
//-------------------------------------- |
495 |
// |
// |
496 |
// |
// |
497 |
//-------------------------------------- |
//-------------------------------------- |
498 |
TrkSinglet::TrkSinglet(const TrkSinglet& s){ |
TrkSinglet::TrkSinglet(const TrkSinglet& s){ |
499 |
|
// cout << "TrkSinglet::TrkSinglet(const TrkSinglet& s) " << GetUniqueID()<<endl; |
500 |
plane = s.plane; |
plane = s.plane; |
501 |
coord[0] = s.coord[0]; |
coord[0] = s.coord[0]; |
502 |
coord[1] = s.coord[1]; |
coord[1] = s.coord[1]; |
503 |
sgnl = s.sgnl; |
sgnl = s.sgnl; |
504 |
|
// cls = 0;//<<<<pointer |
505 |
|
cls = TRef(s.cls); |
506 |
}; |
}; |
507 |
//-------------------------------------- |
//-------------------------------------- |
508 |
// |
// |
519 |
// |
// |
520 |
// |
// |
521 |
//-------------------------------------- |
//-------------------------------------- |
522 |
|
void TrkSinglet::Clear(){ |
523 |
|
// cout << "TrkSinglet::Clear() " << GetUniqueID()<<endl; |
524 |
|
// cls=0; |
525 |
|
plane=-1; |
526 |
|
coord[0]=-999; |
527 |
|
coord[1]=-999; |
528 |
|
sgnl=0; |
529 |
|
|
530 |
|
} |
531 |
|
//-------------------------------------- |
532 |
|
// |
533 |
|
// |
534 |
|
//-------------------------------------- |
535 |
TrkLevel2::TrkLevel2(){ |
TrkLevel2::TrkLevel2(){ |
536 |
good2 = -1; |
// cout <<"TrkLevel2::TrkLevel2()"<<endl; |
537 |
for(Int_t i=0; i<12 ; i++){ |
for(Int_t i=0; i<12 ; i++){ |
538 |
crc[i] = -1; |
good[i] = -1; |
539 |
}; |
}; |
540 |
Track = new TClonesArray("TrkTrack"); |
// Track = new TClonesArray("TrkTrack"); |
541 |
SingletX = new TClonesArray("TrkSinglet"); |
// SingletX = new TClonesArray("TrkSinglet"); |
542 |
SingletY = new TClonesArray("TrkSinglet"); |
// SingletY = new TClonesArray("TrkSinglet"); |
543 |
|
Track = 0; |
544 |
|
SingletX = 0; |
545 |
|
SingletY = 0; |
546 |
|
|
547 |
} |
} |
548 |
//-------------------------------------- |
//-------------------------------------- |
549 |
// |
// |
550 |
// |
// |
551 |
//-------------------------------------- |
//-------------------------------------- |
552 |
void TrkLevel2::Dump(){ |
void TrkLevel2::Dump(){ |
553 |
TClonesArray &t = *Track; |
|
554 |
TClonesArray &sx = *SingletX; |
// |
|
TClonesArray &sy = *SingletY; |
|
|
|
|
555 |
cout << endl << endl << "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"; |
cout << endl << endl << "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"; |
556 |
cout << endl << "good2 : " << good2; |
cout << endl << "good : "; for(int i=0; i<12; i++) cout << good[i]<<" "; |
|
cout << endl << "crc : "; for(int i=0; i<12; i++) cout << crc[i]; |
|
557 |
cout << endl << "ntrk() : " << this->ntrk() ; |
cout << endl << "ntrk() : " << this->ntrk() ; |
558 |
cout << endl << "nclsx() : " << this->nclsx(); |
cout << endl << "nclsx() : " << this->nclsx(); |
559 |
cout << endl << "nclsy() : " << this->nclsy(); |
cout << endl << "nclsy() : " << this->nclsy(); |
560 |
for(int i=0; i<this->ntrk(); i++) ((TrkTrack *)t[i])->Dump(); |
// TClonesArray &t = *Track; |
561 |
for(int i=0; i<this->nclsx(); i++) ((TrkSinglet *)sx[i])->Dump(); |
// TClonesArray &sx = *SingletX; |
562 |
for(int i=0; i<this->nclsy(); i++) ((TrkSinglet *)sy[i])->Dump(); |
// TClonesArray &sy = *SingletY; |
563 |
|
// for(int i=0; i<ntrk(); i++) ((TrkTrack *)t[i])->Dump(); |
564 |
|
// for(int i=0; i<nclsx(); i++) ((TrkSinglet *)sx[i])->Dump(); |
565 |
|
// for(int i=0; i<nclsy(); i++) ((TrkSinglet *)sy[i])->Dump(); |
566 |
|
if(Track){ |
567 |
|
TClonesArray &t = *Track; |
568 |
|
for(int i=0; i<ntrk(); i++) ((TrkTrack *)t[i])->Dump(); |
569 |
|
} |
570 |
|
if(SingletX){ |
571 |
|
TClonesArray &sx = *SingletX; |
572 |
|
for(int i=0; i<nclsx(); i++) ((TrkSinglet *)sx[i])->Dump(); |
573 |
|
} |
574 |
|
if(SingletY){ |
575 |
|
TClonesArray &sy = *SingletY; |
576 |
|
for(int i=0; i<nclsy(); i++) ((TrkSinglet *)sy[i])->Dump(); |
577 |
|
} |
578 |
} |
} |
579 |
//-------------------------------------- |
//-------------------------------------- |
580 |
// |
// |
583 |
/** |
/** |
584 |
* Fills a TrkLevel2 object with values from a struct cTrkLevel2 (to get data from F77 common). |
* Fills a TrkLevel2 object with values from a struct cTrkLevel2 (to get data from F77 common). |
585 |
*/ |
*/ |
586 |
void TrkLevel2::FillCommonVar(cTrkLevel2 *l2){ |
void TrkLevel2::SetFromLevel2Struct(cTrkLevel2 *l2){ |
587 |
// temporary objects: |
|
588 |
|
// temporary objects: |
589 |
TrkSinglet* t_singlet = new TrkSinglet(); |
TrkSinglet* t_singlet = new TrkSinglet(); |
590 |
TrkTrack* t_track = new TrkTrack(); |
TrkTrack* t_track = new TrkTrack(); |
591 |
// general variables |
|
592 |
good2 = l2->good2; |
// **** general variables **** |
593 |
|
// good2 = l2->good2; |
594 |
for(Int_t i=0; i<12 ; i++){ |
for(Int_t i=0; i<12 ; i++){ |
595 |
crc[i] = l2->crc[i]; |
// crc[i] = l2->crc[i]; |
596 |
}; |
good[i] = l2->good[i]; |
597 |
// *** TRACKS *** |
}; |
598 |
|
// *** TRACKS *** |
599 |
|
if(!Track) Track = new TClonesArray("TrkTrack"); |
600 |
TClonesArray &t = *Track; |
TClonesArray &t = *Track; |
601 |
for(int i=0; i<l2->ntrk; i++){ |
for(int i=0; i<l2->ntrk; i++){ |
602 |
|
t_track->seqno = i;// NBNBNBNB deve sempre essere = i |
603 |
t_track->image = l2->image[i]-1; |
t_track->image = l2->image[i]-1; |
604 |
|
// cout << "track "<<i<<t_track->seqno << t_track->image<<endl; |
605 |
t_track->chi2 = l2->chi2_nt[i]; |
t_track->chi2 = l2->chi2_nt[i]; |
606 |
|
t_track->nstep = l2->nstep_nt[i]; |
607 |
for(int it1=0;it1<5;it1++){ |
for(int it1=0;it1<5;it1++){ |
608 |
t_track->al[it1] = l2->al_nt[i][it1]; |
t_track->al[it1] = l2->al_nt[i][it1]; |
609 |
for(int it2=0;it2<5;it2++) |
for(int it2=0;it2<5;it2++) |
624 |
t_track->ayv[ip] = l2->ayv_nt[i][ip]; |
t_track->ayv[ip] = l2->ayv_nt[i][ip]; |
625 |
t_track->dedx_x[ip] = l2->dedx_x[i][ip]; |
t_track->dedx_x[ip] = l2->dedx_x[i][ip]; |
626 |
t_track->dedx_y[ip] = l2->dedx_y[i][ip]; |
t_track->dedx_y[ip] = l2->dedx_y[i][ip]; |
627 |
|
// t_track->clx[ip] = 0; |
628 |
|
// t_track->cly[ip] = 0; |
629 |
}; |
}; |
630 |
new(t[i]) TrkTrack(*t_track); |
new(t[i]) TrkTrack(*t_track); |
631 |
t_track->Clear(); |
t_track->Clear(); |
632 |
}; |
}; |
633 |
// *** SINGLETS *** |
// *** SINGLETS *** |
634 |
|
if(!SingletX)SingletX = new TClonesArray("TrkSinglet"); |
635 |
TClonesArray &sx = *SingletX; |
TClonesArray &sx = *SingletX; |
636 |
for(int i=0; i<l2->nclsx; i++){ |
for(int i=0; i<l2->nclsx; i++){ |
637 |
t_singlet->plane = l2->planex[i]; |
t_singlet->plane = l2->planex[i]; |
638 |
t_singlet->coord[0] = l2->xs[i][0]; |
t_singlet->coord[0] = l2->xs[i][0]; |
639 |
t_singlet->coord[1] = l2->xs[i][1]; |
t_singlet->coord[1] = l2->xs[i][1]; |
640 |
t_singlet->sgnl = l2->signlxs[i]; |
t_singlet->sgnl = l2->signlxs[i]; |
641 |
|
// t_singlet->cls = 0; |
642 |
new(sx[i]) TrkSinglet(*t_singlet); |
new(sx[i]) TrkSinglet(*t_singlet); |
643 |
t_singlet->Clear(); |
t_singlet->Clear(); |
644 |
} |
} |
645 |
|
if(!SingletY)SingletY = new TClonesArray("TrkSinglet"); |
646 |
TClonesArray &sy = *SingletY; |
TClonesArray &sy = *SingletY; |
647 |
for(int i=0; i<l2->nclsy; i++){ |
for(int i=0; i<l2->nclsy; i++){ |
648 |
t_singlet->plane = l2->planey[i]; |
t_singlet->plane = l2->planey[i]; |
649 |
t_singlet->coord[0] = l2->ys[i][0]; |
t_singlet->coord[0] = l2->ys[i][0]; |
650 |
t_singlet->coord[1] = l2->ys[i][1]; |
t_singlet->coord[1] = l2->ys[i][1]; |
651 |
t_singlet->sgnl = l2->signlys[i]; |
t_singlet->sgnl = l2->signlys[i]; |
652 |
|
// t_singlet->cls = 0; |
653 |
new(sy[i]) TrkSinglet(*t_singlet); |
new(sy[i]) TrkSinglet(*t_singlet); |
654 |
t_singlet->Clear(); |
t_singlet->Clear(); |
655 |
|
}; |
656 |
|
|
657 |
|
delete t_track; |
658 |
|
delete t_singlet; |
659 |
|
} |
660 |
|
//-------------------------------------- |
661 |
|
// |
662 |
|
// |
663 |
|
//-------------------------------------- |
664 |
|
/** |
665 |
|
* Fills a TrkLevel2 object with values from a struct cTrkLevel2 (to get data from F77 common). |
666 |
|
* Ref to Level1 data (clusters) is also set. |
667 |
|
*/ |
668 |
|
void TrkLevel2::SetFromLevel2Struct(cTrkLevel2 *l2, TrkLevel1 *l1){ |
669 |
|
|
670 |
|
// temporary objects: |
671 |
|
TrkSinglet* t_singlet = new TrkSinglet(); |
672 |
|
TrkTrack* t_track = new TrkTrack(); |
673 |
|
// general variables |
674 |
|
// good2 = l2->good2; |
675 |
|
for(Int_t i=0; i<12 ; i++){ |
676 |
|
// crc[i] = l2->crc[i]; |
677 |
|
good[i] = l2->good[i]; |
678 |
}; |
}; |
679 |
|
// *** TRACKS *** |
680 |
|
if(!Track) Track = new TClonesArray("TrkTrack"); |
681 |
|
TClonesArray &t = *Track; |
682 |
|
if(!t_track->clx)t_track->clx = new TRefArray(6,0); |
683 |
|
if(!t_track->cly)t_track->cly = new TRefArray(6,0); |
684 |
|
for(int i=0; i<l2->ntrk; i++){ |
685 |
|
t_track->seqno = i;// NBNBNBNB deve sempre essere = i |
686 |
|
t_track->image = l2->image[i]-1; |
687 |
|
// cout << "track "<<i<<t_track->seqno << t_track->image<<endl; |
688 |
|
t_track->chi2 = l2->chi2_nt[i]; |
689 |
|
t_track->nstep = l2->nstep_nt[i]; |
690 |
|
for(int it1=0;it1<5;it1++){ |
691 |
|
t_track->al[it1] = l2->al_nt[i][it1]; |
692 |
|
for(int it2=0;it2<5;it2++) |
693 |
|
t_track->coval[it1][it2] = l2->coval[i][it2][it1]; |
694 |
|
}; |
695 |
|
for(int ip=0;ip<6;ip++){ |
696 |
|
t_track->xgood[ip] = l2->xgood_nt[i][ip]; |
697 |
|
t_track->ygood[ip] = l2->ygood_nt[i][ip]; |
698 |
|
t_track->xm[ip] = l2->xm_nt[i][ip]; |
699 |
|
t_track->ym[ip] = l2->ym_nt[i][ip]; |
700 |
|
t_track->zm[ip] = l2->zm_nt[i][ip]; |
701 |
|
t_track->resx[ip] = l2->resx_nt[i][ip]; |
702 |
|
t_track->resy[ip] = l2->resy_nt[i][ip]; |
703 |
|
t_track->xv[ip] = l2->xv_nt[i][ip]; |
704 |
|
t_track->yv[ip] = l2->yv_nt[i][ip]; |
705 |
|
t_track->zv[ip] = l2->zv_nt[i][ip]; |
706 |
|
t_track->axv[ip] = l2->axv_nt[i][ip]; |
707 |
|
t_track->ayv[ip] = l2->ayv_nt[i][ip]; |
708 |
|
t_track->dedx_x[ip] = l2->dedx_x[i][ip]; |
709 |
|
t_track->dedx_y[ip] = l2->dedx_y[i][ip]; |
710 |
|
// cout << "traccia "<<i<<" -- "<< ip << " "<< l2->cltrx[i][ip] <<" "<< l2->cltry[i][ip] <<" "<< t_track->xgood[ip] << t_track->ygood[ip]<<endl; |
711 |
|
//----------------------------------------------------- |
712 |
|
//----------------------------------------------------- |
713 |
|
if(t_track->xgood[ip])t_track->clx->AddAt(l1->GetCluster(l2->cltrx[i][ip]-1),ip); |
714 |
|
if(t_track->ygood[ip])t_track->cly->AddAt(l1->GetCluster(l2->cltry[i][ip]-1),ip); |
715 |
|
// if(t_track->ygood[ip])cout<<" i "<<i<<" ip "<<ip<<" l2->cltry[i][ip] "<<l2->cltry[i][ip]<< " l1->GetCluster(l2->cltry[i][ip]-1) "<<l1->GetCluster(l2->cltry[i][ip]-1)<<endl; |
716 |
|
// if(t_track->xgood[ip])cout<<" i "<<i<<" ip "<<ip<<" l2->cltrx[i][ip] "<<l2->cltrx[i][ip]<< " l1->GetCluster(l2->cltrx[i][ip]-1) "<<l1->GetCluster(l2->cltrx[i][ip]-1)<<endl; |
717 |
|
//----------------------------------------------------- |
718 |
|
//----------------------------------------------------- |
719 |
|
}; |
720 |
|
new(t[i]) TrkTrack(*t_track); |
721 |
|
t_track->Clear(); |
722 |
|
}; |
723 |
|
// *** SINGLETS *** |
724 |
|
if(!SingletX)SingletX = new TClonesArray("TrkSinglet"); |
725 |
|
TClonesArray &sx = *SingletX; |
726 |
|
for(int i=0; i<l2->nclsx; i++){ |
727 |
|
t_singlet->plane = l2->planex[i]; |
728 |
|
t_singlet->coord[0] = l2->xs[i][0]; |
729 |
|
t_singlet->coord[1] = l2->xs[i][1]; |
730 |
|
t_singlet->sgnl = l2->signlxs[i]; |
731 |
|
//----------------------------------------------------- |
732 |
|
// cout << "singolo x "<<i<<" -- "<< l2->clsx[i] <<endl; |
733 |
|
t_singlet->cls = l1->GetCluster(l2->clsx[i]-1); |
734 |
|
// cout<<" i "<<i<<" l2->clsx[i] "<<l2->clsx[i]<< " l1->GetCluster(l2->clsx[i]-1) "<<l1->GetCluster(l2->clsx[i]-1)<<endl; |
735 |
|
//----------------------------------------------------- |
736 |
|
new(sx[i]) TrkSinglet(*t_singlet); |
737 |
|
t_singlet->Clear(); |
738 |
|
} |
739 |
|
if(!SingletY)SingletY = new TClonesArray("TrkSinglet"); |
740 |
|
TClonesArray &sy = *SingletY; |
741 |
|
for(int i=0; i<l2->nclsy; i++){ |
742 |
|
t_singlet->plane = l2->planey[i]; |
743 |
|
t_singlet->coord[0] = l2->ys[i][0]; |
744 |
|
t_singlet->coord[1] = l2->ys[i][1]; |
745 |
|
t_singlet->sgnl = l2->signlys[i]; |
746 |
|
//----------------------------------------------------- |
747 |
|
// cout << "singolo y "<<i<<" -- "<< l2->clsy[i] <<endl; |
748 |
|
t_singlet->cls = l1->GetCluster(l2->clsy[i]-1); |
749 |
|
// cout<<" i "<<i<<" l2->clsy[i] "<<l2->clsy[i]<< " l1->GetCluster(l2->clsy[i]-1) "<<l1->GetCluster(l2->clsy[i]-1)<<endl; |
750 |
|
//----------------------------------------------------- |
751 |
|
new(sy[i]) TrkSinglet(*t_singlet); |
752 |
|
t_singlet->Clear(); |
753 |
|
}; |
754 |
|
|
755 |
|
delete t_track; |
756 |
|
delete t_singlet; |
757 |
|
} |
758 |
|
/** |
759 |
|
* Fills a struct cTrkLevel2 with values from a TrkLevel2 object (to put data into a F77 common). |
760 |
|
*/ |
761 |
|
|
762 |
|
void TrkLevel2::GetLevel2Struct(cTrkLevel2 *l2) const { |
763 |
|
|
764 |
|
// general variables |
765 |
|
// l2->good2 = good2 ; |
766 |
|
for(Int_t i=0; i<12 ; i++){ |
767 |
|
// l2->crc[i] = crc[i]; |
768 |
|
l2->good[i] = good[i]; |
769 |
|
}; |
770 |
|
// *** TRACKS *** |
771 |
|
|
772 |
|
if(Track){ |
773 |
|
l2->ntrk = Track->GetEntries(); |
774 |
|
for(Int_t i=0;i<l2->ntrk;i++){ |
775 |
|
l2->image[i] = 1 + ((TrkTrack *)Track->At(i))->image; |
776 |
|
l2->chi2_nt[i] = ((TrkTrack *)Track->At(i))->chi2; |
777 |
|
l2->nstep_nt[i] = ((TrkTrack *)Track->At(i))->nstep; |
778 |
|
for(int it1=0;it1<5;it1++){ |
779 |
|
l2->al_nt[i][it1] = ((TrkTrack *)Track->At(i))->al[it1]; |
780 |
|
for(int it2=0;it2<5;it2++) |
781 |
|
l2->coval[i][it2][it1] = ((TrkTrack *)Track->At(i))->coval[it1][it2]; |
782 |
|
}; |
783 |
|
for(int ip=0;ip<6;ip++){ |
784 |
|
l2->xgood_nt[i][ip] = ((TrkTrack *)Track->At(i))->xgood[ip]; |
785 |
|
l2->ygood_nt[i][ip] = ((TrkTrack *)Track->At(i))->ygood[ip]; |
786 |
|
l2->xm_nt[i][ip] = ((TrkTrack *)Track->At(i))->xm[ip]; |
787 |
|
l2->ym_nt[i][ip] = ((TrkTrack *)Track->At(i))->ym[ip]; |
788 |
|
l2->zm_nt[i][ip] = ((TrkTrack *)Track->At(i))->zm[ip]; |
789 |
|
l2->resx_nt[i][ip] = ((TrkTrack *)Track->At(i))->resx[ip]; |
790 |
|
l2->resy_nt[i][ip] = ((TrkTrack *)Track->At(i))->resy[ip]; |
791 |
|
l2->xv_nt[i][ip] = ((TrkTrack *)Track->At(i))->xv[ip]; |
792 |
|
l2->yv_nt[i][ip] = ((TrkTrack *)Track->At(i))->yv[ip]; |
793 |
|
l2->zv_nt[i][ip] = ((TrkTrack *)Track->At(i))->zv[ip]; |
794 |
|
l2->axv_nt[i][ip] = ((TrkTrack *)Track->At(i))->axv[ip]; |
795 |
|
l2->ayv_nt[i][ip] = ((TrkTrack *)Track->At(i))->ayv[ip]; |
796 |
|
l2->dedx_x[i][ip] = ((TrkTrack *)Track->At(i))->dedx_x[ip]; |
797 |
|
l2->dedx_y[i][ip] = ((TrkTrack *)Track->At(i))->dedx_y[ip]; |
798 |
|
}; |
799 |
|
} |
800 |
|
} |
801 |
|
// *** SINGLETS *** |
802 |
|
if(SingletX){ |
803 |
|
l2->nclsx = SingletX->GetEntries(); |
804 |
|
for(Int_t i=0;i<l2->nclsx;i++){ |
805 |
|
l2->planex[i] = ((TrkSinglet *)SingletX->At(i))->plane; |
806 |
|
l2->xs[i][0] = ((TrkSinglet *)SingletX->At(i))->coord[0]; |
807 |
|
l2->xs[i][1] = ((TrkSinglet *)SingletX->At(i))->coord[1]; |
808 |
|
l2->signlxs[i] = ((TrkSinglet *)SingletX->At(i))->sgnl; |
809 |
|
} |
810 |
|
} |
811 |
|
|
812 |
|
if(SingletY){ |
813 |
|
l2->nclsy = SingletY->GetEntries(); |
814 |
|
for(Int_t i=0;i<l2->nclsy;i++){ |
815 |
|
l2->planey[i] = ((TrkSinglet *)SingletY->At(i))->plane; |
816 |
|
l2->ys[i][0] = ((TrkSinglet *)SingletY->At(i))->coord[0]; |
817 |
|
l2->ys[i][1] = ((TrkSinglet *)SingletY->At(i))->coord[1]; |
818 |
|
l2->signlys[i] = ((TrkSinglet *)SingletY->At(i))->sgnl; |
819 |
|
} |
820 |
|
} |
821 |
} |
} |
822 |
//-------------------------------------- |
//-------------------------------------- |
823 |
// |
// |
824 |
// |
// |
825 |
//-------------------------------------- |
//-------------------------------------- |
826 |
void TrkLevel2::Clear(){ |
void TrkLevel2::Clear(){ |
|
good2 = -1; |
|
827 |
for(Int_t i=0; i<12 ; i++){ |
for(Int_t i=0; i<12 ; i++){ |
828 |
crc[i] = -1; |
good[i] = -1; |
829 |
}; |
}; |
830 |
Track->RemoveAll(); |
// if(Track)Track->Clear("C"); |
831 |
SingletX->RemoveAll(); |
// if(SingletX)SingletX->Clear("C"); |
832 |
SingletY->RemoveAll(); |
// if(SingletY)SingletY->Clear("C"); |
833 |
|
if(Track)Track->Delete(); |
834 |
|
if(SingletX)SingletX->Delete(); |
835 |
|
if(SingletY)SingletY->Delete(); |
836 |
|
} |
837 |
|
// //-------------------------------------- |
838 |
|
// // |
839 |
|
// // |
840 |
|
// //-------------------------------------- |
841 |
|
void TrkLevel2::Delete(){ |
842 |
|
|
843 |
|
// cout << "void TrkLevel2::Delete()"<<endl; |
844 |
|
Clear(); |
845 |
|
if(Track)delete Track; |
846 |
|
if(SingletX)delete SingletX; |
847 |
|
if(SingletY)delete SingletY; |
848 |
|
|
849 |
} |
} |
850 |
//-------------------------------------- |
//-------------------------------------- |
851 |
// |
// |
855 |
* Sort physical tracks and stores them in a TObjectArray, ordering by increasing chi**2 value (in case of track image, it selects the one with lower chi**2). The total number of physical tracks is given by GetNTracks() and the it-th physical track can be retrieved by means of the method GetTrack(int it). |
* Sort physical tracks and stores them in a TObjectArray, ordering by increasing chi**2 value (in case of track image, it selects the one with lower chi**2). The total number of physical tracks is given by GetNTracks() and the it-th physical track can be retrieved by means of the method GetTrack(int it). |
856 |
* This method is overridden by PamLevel2::GetTracks(), where calorimeter and TOF information is used. |
* This method is overridden by PamLevel2::GetTracks(), where calorimeter and TOF information is used. |
857 |
*/ |
*/ |
858 |
TClonesArray *TrkLevel2::GetTracks(){ |
TRefArray *TrkLevel2::GetTracks_NFitSorted(){ |
859 |
|
|
860 |
TClonesArray *sorted = new TClonesArray("TrkTrack"); |
if(!Track)return 0; |
|
TClonesArray &t = *Track; |
|
|
TClonesArray &ts = *sorted; |
|
|
int N=this->ntrk(); |
|
|
vector<int> m(N); for(int i=0; i<N; i++)m[i]=1; |
|
861 |
|
|
862 |
|
TRefArray *sorted = new TRefArray(); |
863 |
|
|
864 |
|
TClonesArray &t = *Track; |
865 |
|
// TClonesArray &ts = *PhysicalTrack; |
866 |
|
int N = ntrk(); |
867 |
|
vector<int> m(N); for(int i=0; i<N; i++)m[i]=1; |
868 |
|
// int m[50]; for(int i=0; i<N; i++)m[i]=1; |
869 |
|
|
870 |
int indo=0; |
int indo=0; |
871 |
int indi=0; |
int indi=0; |
872 |
while(N != 0){ |
while(N != 0){ |
873 |
float chi2ref=1000000; |
int nfit =0; |
874 |
|
float chi2ref = numeric_limits<float>::max(); |
875 |
|
|
876 |
|
// first loop to search maximum num. of fit points |
877 |
|
for(int i=0; i < ntrk(); i++){ |
878 |
|
if( ((TrkTrack *)t[i])->GetNtot() >= nfit && m[i]==1){ |
879 |
|
nfit = ((TrkTrack *)t[i])->GetNtot(); |
880 |
|
} |
881 |
|
} |
882 |
|
//second loop to search minimum chi2 among selected |
883 |
for(int i=0; i<this->ntrk(); i++){ |
for(int i=0; i<this->ntrk(); i++){ |
884 |
if(((TrkTrack *)t[i])->chi2 < chi2ref && m[i]==1){ |
Float_t chi2 = ((TrkTrack *)t[i])->chi2; |
885 |
|
if(chi2 < 0) chi2 = chi2*1000; |
886 |
|
if( chi2 < chi2ref |
887 |
|
&& ((TrkTrack *)t[i])->GetNtot() == nfit |
888 |
|
&& m[i]==1){ |
889 |
chi2ref = ((TrkTrack *)t[i])->chi2; |
chi2ref = ((TrkTrack *)t[i])->chi2; |
890 |
indi = i; |
indi = i; |
891 |
} |
}; |
892 |
} |
}; |
893 |
if( ((TrkTrack *)t[indi])->image != -1 ){ |
if( ((TrkTrack *)t[indi])->HasImage() ){ |
894 |
m[((TrkTrack *)t[indi])->image] = 0; |
m[((TrkTrack *)t[indi])->image] = 0; |
895 |
N--; |
N--; |
896 |
} |
|
897 |
new(ts[indo]) TrkTrack(*(TrkTrack*)t[indi]); |
// cout << "i** "<< ((TrkTrack *)t[indi])->image << " " << nfiti <<" "<<chi2i<<endl; |
898 |
|
}; |
899 |
|
sorted->Add( (TrkTrack*)t[indi] ); |
900 |
|
|
901 |
m[indi] = 0; |
m[indi] = 0; |
902 |
|
// cout << "SORTED "<< indo << " "<< indi << " "<< N << endl; |
903 |
N--; |
N--; |
904 |
indo++; |
indo++; |
905 |
} |
} |
906 |
|
m.clear(); |
907 |
|
// cout << "GetTracks_NFitSorted(it): Done"<< endl; |
908 |
|
|
909 |
return sorted; |
return sorted; |
910 |
|
// return PhysicalTrack; |
911 |
} |
} |
912 |
//-------------------------------------- |
//-------------------------------------- |
913 |
// |
// |
925 |
cout << " Stored tracks ntrk() = "<< this->ntrk() << endl; |
cout << " Stored tracks ntrk() = "<< this->ntrk() << endl; |
926 |
return 0; |
return 0; |
927 |
} |
} |
928 |
|
if(!Track){ |
929 |
|
cout << "TrkTrack *TrkLevel2::GetStoredTrack(int is) >> (TClonesArray*) Track ==0 "<<endl; |
930 |
|
}; |
931 |
TClonesArray &t = *(Track); |
TClonesArray &t = *(Track); |
932 |
TrkTrack *track = (TrkTrack*)t[is]; |
TrkTrack *track = (TrkTrack*)t[is]; |
933 |
return track; |
return track; |
937 |
// |
// |
938 |
//-------------------------------------- |
//-------------------------------------- |
939 |
/** |
/** |
940 |
|
* Retrieves the is-th stored X singlet. |
941 |
|
* @param it Singlet number, ranging from 0 to nclsx(). |
942 |
|
*/ |
943 |
|
TrkSinglet *TrkLevel2::GetSingletX(int is){ |
944 |
|
|
945 |
|
if(is >= this->nclsx()){ |
946 |
|
cout << "** TrkLevel2 ** Singlet "<< is << "doen not exits! " << endl; |
947 |
|
cout << " Stored x-singlets nclsx() = "<< this->nclsx() << endl; |
948 |
|
return 0; |
949 |
|
} |
950 |
|
if(!SingletX)return 0; |
951 |
|
TClonesArray &t = *(SingletX); |
952 |
|
TrkSinglet *singlet = (TrkSinglet*)t[is]; |
953 |
|
return singlet; |
954 |
|
} |
955 |
|
//-------------------------------------- |
956 |
|
// |
957 |
|
// |
958 |
|
//-------------------------------------- |
959 |
|
/** |
960 |
|
* Retrieves the is-th stored Y singlet. |
961 |
|
* @param it Singlet number, ranging from 0 to nclsx(). |
962 |
|
*/ |
963 |
|
TrkSinglet *TrkLevel2::GetSingletY(int is){ |
964 |
|
|
965 |
|
if(is >= this->nclsy()){ |
966 |
|
cout << "** TrkLevel2 ** Singlet "<< is << "doen not exits! " << endl; |
967 |
|
cout << " Stored y-singlets nclsy() = "<< this->nclsx() << endl; |
968 |
|
return 0; |
969 |
|
} |
970 |
|
if(!SingletY)return 0; |
971 |
|
TClonesArray &t = *(SingletY); |
972 |
|
TrkSinglet *singlet = (TrkSinglet*)t[is]; |
973 |
|
return singlet; |
974 |
|
} |
975 |
|
//-------------------------------------- |
976 |
|
// |
977 |
|
// |
978 |
|
//-------------------------------------- |
979 |
|
/** |
980 |
* Retrieves the it-th "physical" track, sorted by the method GetNTracks(). |
* Retrieves the it-th "physical" track, sorted by the method GetNTracks(). |
981 |
* @param it Track number, ranging from 0 to GetNTracks(). |
* @param it Track number, ranging from 0 to GetNTracks(). |
982 |
*/ |
*/ |
983 |
|
|
984 |
TrkTrack *TrkLevel2::GetTrack(int it){ |
TrkTrack *TrkLevel2::GetTrack(int it){ |
985 |
|
|
986 |
if(it >= this->GetNTracks()){ |
if(it >= this->GetNTracks()){ |
987 |
cout << "** TrkLevel2 ** Track "<< it << "does not exits! " << endl; |
cout << "** TrkLevel2 ** Track "<< it << "does not exits! " << endl; |
988 |
cout << " Physical tracks GetNTracks() = "<< this->ntrk() << endl; |
cout << " Physical tracks GetNTracks() = "<< this->ntrk() << endl; |
989 |
return 0; |
return 0; |
990 |
} |
} |
991 |
TrkTrack *track = (TrkTrack*)(*(this->GetTracks()))[it]; |
|
992 |
return track; |
TRefArray *sorted = GetTracks(); //TEMPORANEO |
993 |
|
if(!sorted)return 0; |
994 |
|
TrkTrack *track = (TrkTrack*)sorted->At(it); |
995 |
|
sorted->Clear(); |
996 |
|
delete sorted; |
997 |
|
return track; |
998 |
} |
} |
999 |
|
/** |
1000 |
|
* Give the number of "physical" tracks, sorted by the method GetTracks(). |
1001 |
|
*/ |
1002 |
|
Int_t TrkLevel2::GetNTracks(){ |
1003 |
|
|
1004 |
|
Float_t ntot=0; |
1005 |
|
if(!Track)return 0; |
1006 |
|
TClonesArray &t = *Track; |
1007 |
|
for(int i=0; i<ntrk(); i++) { |
1008 |
|
if( ((TrkTrack *)t[i])->GetImageSeqNo() == -1 ) ntot+=1.; |
1009 |
|
else ntot+=0.5; |
1010 |
|
} |
1011 |
|
return (Int_t)ntot; |
1012 |
|
|
1013 |
|
}; |
1014 |
//-------------------------------------- |
//-------------------------------------- |
1015 |
// |
// |
1016 |
// |
// |
1026 |
cout << " Physical tracks GetNTracks() = "<< this->ntrk() << endl; |
cout << " Physical tracks GetNTracks() = "<< this->ntrk() << endl; |
1027 |
return 0; |
return 0; |
1028 |
} |
} |
1029 |
TrkTrack *track = (TrkTrack*)(*(this->GetTracks()))[it]; |
|
1030 |
|
TRefArray* sorted = GetTracks(); //TEMPORANEO |
1031 |
|
if(!sorted)return 0; |
1032 |
|
TrkTrack *track = (TrkTrack*)sorted->At(it); |
1033 |
|
|
1034 |
if(!track->HasImage()){ |
if(!track->HasImage()){ |
1035 |
cout << "** TrkLevel2 ** Track "<< it << "does not have image! " << endl; |
cout << "** TrkLevel2 ** Track "<< it << "does not have image! " << endl; |
1036 |
return 0; |
return 0; |
1037 |
} |
} |
1038 |
|
if(!Track)return 0; |
1039 |
TrkTrack *image = (TrkTrack*)(*Track)[track->image]; |
TrkTrack *image = (TrkTrack*)(*Track)[track->image]; |
1040 |
|
|
1041 |
|
sorted->Delete(); |
1042 |
|
delete sorted; |
1043 |
|
|
1044 |
return image; |
return image; |
1045 |
|
|
1046 |
} |
} |
1052 |
* Loads the magnetic field. |
* Loads the magnetic field. |
1053 |
* @param s Path of the magnetic-field files. |
* @param s Path of the magnetic-field files. |
1054 |
*/ |
*/ |
1055 |
void TrkLevel2::LoadField(TString s){ |
void TrkLevel2::LoadField(TString path){ |
1056 |
readb_(s.Data()); |
// |
1057 |
|
strcpy(path_.path,path.Data()); |
1058 |
|
path_.pathlen = path.Length(); |
1059 |
|
path_.error = 0; |
1060 |
|
readb_(); |
1061 |
|
// |
1062 |
}; |
}; |
1063 |
//-------------------------------------- |
//-------------------------------------- |
1064 |
// |
// |
1065 |
// |
// |
1066 |
//-------------------------------------- |
//-------------------------------------- |
1067 |
/** |
/** |
1068 |
|
* Get tracker-plane (mechanical) z-coordinate |
1069 |
|
* @param plane_id plane index (1=TOP,2,3,4,5,6=BOTTOM) |
1070 |
|
*/ |
1071 |
|
Float_t TrkLevel2::GetZTrk(Int_t plane_id){ |
1072 |
|
switch(plane_id){ |
1073 |
|
case 1: return ZTRK1; |
1074 |
|
case 2: return ZTRK2; |
1075 |
|
case 3: return ZTRK3; |
1076 |
|
case 4: return ZTRK4; |
1077 |
|
case 5: return ZTRK5; |
1078 |
|
case 6: return ZTRK6; |
1079 |
|
default: return 0.; |
1080 |
|
}; |
1081 |
|
}; |
1082 |
|
//-------------------------------------- |
1083 |
|
// |
1084 |
|
// |
1085 |
|
//-------------------------------------- |
1086 |
|
/** |
1087 |
|
* Trajectory default constructor. |
1088 |
|
* (By default is created with z-coordinates inside the tracking volume) |
1089 |
|
*/ |
1090 |
|
Trajectory::Trajectory(){ |
1091 |
|
npoint = 10; |
1092 |
|
x = new float[npoint]; |
1093 |
|
y = new float[npoint]; |
1094 |
|
z = new float[npoint]; |
1095 |
|
thx = new float[npoint]; |
1096 |
|
thy = new float[npoint]; |
1097 |
|
tl = new float[npoint]; |
1098 |
|
float dz = ((ZTRK1)-(ZTRK6))/(npoint-1); |
1099 |
|
for(int i=0; i<npoint; i++){ |
1100 |
|
x[i] = 0; |
1101 |
|
y[i] = 0; |
1102 |
|
z[i] = (ZTRK1) - i*dz; |
1103 |
|
thx[i] = 0; |
1104 |
|
thy[i] = 0; |
1105 |
|
tl[i] = 0; |
1106 |
|
} |
1107 |
|
} |
1108 |
|
//-------------------------------------- |
1109 |
|
// |
1110 |
|
// |
1111 |
|
//-------------------------------------- |
1112 |
|
/** |
1113 |
* Trajectory constructor. |
* Trajectory constructor. |
1114 |
|
* (By default is created with z-coordinates inside the tracking volume) |
1115 |
* \param n Number of points |
* \param n Number of points |
1116 |
*/ |
*/ |
1117 |
Trajectory::Trajectory(int n){ |
Trajectory::Trajectory(int n){ |
1118 |
|
if(n<=0){ |
1119 |
|
cout << "NB! Trajectory must have at least 1 point >>> created with 10 points" << endl; |
1120 |
|
n=10; |
1121 |
|
} |
1122 |
npoint = n; |
npoint = n; |
1123 |
x = new float[npoint]; |
x = new float[npoint]; |
1124 |
y = new float[npoint]; |
y = new float[npoint]; |
1125 |
z = new float[npoint]; |
z = new float[npoint]; |
1126 |
|
thx = new float[npoint]; |
1127 |
|
thy = new float[npoint]; |
1128 |
|
tl = new float[npoint]; |
1129 |
|
float dz = ((ZTRK1)-(ZTRK6))/(npoint-1); |
1130 |
for(int i=0; i<npoint; i++){ |
for(int i=0; i<npoint; i++){ |
1131 |
x[i] = 0; |
x[i] = 0; |
1132 |
y[i] = 0; |
y[i] = 0; |
1133 |
z[i] = 0; |
z[i] = (ZTRK1) - i*dz; |
1134 |
|
thx[i] = 0; |
1135 |
|
thy[i] = 0; |
1136 |
|
tl[i] = 0; |
1137 |
} |
} |
1138 |
} |
} |
1139 |
//-------------------------------------- |
//-------------------------------------- |
1146 |
* \param pz Pointer to float array, defining z coordinates |
* \param pz Pointer to float array, defining z coordinates |
1147 |
*/ |
*/ |
1148 |
Trajectory::Trajectory(int n, float* zin){ |
Trajectory::Trajectory(int n, float* zin){ |
1149 |
npoint = n; |
npoint = 10; |
1150 |
|
if(n>0)npoint = n; |
1151 |
x = new float[npoint]; |
x = new float[npoint]; |
1152 |
y = new float[npoint]; |
y = new float[npoint]; |
1153 |
z = new float[npoint]; |
z = new float[npoint]; |
1154 |
for(int i=0; i<npoint; i++){ |
thx = new float[npoint]; |
1155 |
|
thy = new float[npoint]; |
1156 |
|
tl = new float[npoint]; |
1157 |
|
int i=0; |
1158 |
|
do{ |
1159 |
x[i] = 0; |
x[i] = 0; |
1160 |
y[i] = 0; |
y[i] = 0; |
1161 |
z[i] = zin[i]; |
z[i] = zin[i]; |
1162 |
} |
thx[i] = 0; |
1163 |
|
thy[i] = 0; |
1164 |
|
tl[i] = 0; |
1165 |
|
i++; |
1166 |
|
}while(zin[i-1] > zin[i] && i < npoint); |
1167 |
|
npoint=i; |
1168 |
|
if(npoint != n)cout << "NB! Trajectory created with "<<npoint<<" points"<<endl; |
1169 |
|
} |
1170 |
|
void Trajectory::Delete(){ |
1171 |
|
|
1172 |
|
if(x) delete [] x; |
1173 |
|
if(y) delete [] y; |
1174 |
|
if(z) delete [] z; |
1175 |
|
if(thx) delete [] thx; |
1176 |
|
if(thy) delete [] thy; |
1177 |
|
if(tl) delete [] tl; |
1178 |
|
|
1179 |
} |
} |
1180 |
//-------------------------------------- |
//-------------------------------------- |
1181 |
// |
// |
1187 |
void Trajectory::Dump(){ |
void Trajectory::Dump(){ |
1188 |
cout <<endl<< "Trajectory ========== "<<endl; |
cout <<endl<< "Trajectory ========== "<<endl; |
1189 |
for (int i=0; i<npoint; i++){ |
for (int i=0; i<npoint; i++){ |
1190 |
cout << i <<" >> " << x[i] <<" "<< y[i] <<" "<< z[i] << endl;; |
cout << i <<" >> " << x[i] <<" "<< y[i] <<" "<< z[i] ; |
1191 |
|
cout <<" -- " << thx[i] <<" "<< thy[i] ; |
1192 |
|
cout <<" -- " << tl[i] << endl; |
1193 |
|
}; |
1194 |
|
} |
1195 |
|
//-------------------------------------- |
1196 |
|
// |
1197 |
|
// |
1198 |
|
//-------------------------------------- |
1199 |
|
/** |
1200 |
|
* Get trajectory length between two points |
1201 |
|
* @param ifirst first point (default 0) |
1202 |
|
* @param ilast last point (default npoint) |
1203 |
|
*/ |
1204 |
|
float Trajectory::GetLength(int ifirst, int ilast){ |
1205 |
|
if( ifirst<0 ) ifirst = 0; |
1206 |
|
if( ilast>=npoint) ilast = npoint-1; |
1207 |
|
float l=0; |
1208 |
|
for(int i=ifirst;i<=ilast;i++){ |
1209 |
|
l=l+tl[i]; |
1210 |
}; |
}; |
1211 |
|
if(z[ilast] > ZINI)l=l-tl[ilast]; |
1212 |
|
if(z[ifirst] < ZINI) l=l-tl[ifirst]; |
1213 |
|
|
1214 |
|
return l; |
1215 |
|
|
1216 |
} |
} |
1217 |
|
|
1218 |
|
/** |
1219 |
|
* Evaluates the trajectory in the apparatus associated to the track. |
1220 |
|
* It integrates the equations of motion in the magnetic field. The magnetic field should be previously loaded ( by calling TrkLevel2::LoadField() ), otherwise an error message is returned. |
1221 |
|
* @param t pointer to an object of the class Trajectory, |
1222 |
|
* which z coordinates should be previously initialized by calling the proper constructor ( Trajectory::Trajectory(int n, float* zin) ). |
1223 |
|
* @return error flag. |
1224 |
|
*/ |
1225 |
|
int Trajectory::DoTrack2(float* al){ |
1226 |
|
|
1227 |
|
double *dxout = new double[npoint]; |
1228 |
|
double *dyout = new double[npoint]; |
1229 |
|
double *dthxout = new double[npoint]; |
1230 |
|
double *dthyout = new double[npoint]; |
1231 |
|
double *dtlout = new double[npoint]; |
1232 |
|
double *dzin = new double[npoint]; |
1233 |
|
double dal[5]; |
1234 |
|
|
1235 |
|
int ifail = 0; |
1236 |
|
|
1237 |
|
for (int i=0; i<5; i++) dal[i] = (double)al[i]; |
1238 |
|
for (int i=0; i<npoint; i++) dzin[i] = (double)z[i]; |
1239 |
|
|
1240 |
|
dotrack2_(&(npoint),dzin,dxout,dyout,dthxout,dthyout,dtlout,dal,&ifail); |
1241 |
|
|
1242 |
|
for (int i=0; i<npoint; i++){ |
1243 |
|
x[i] = (float)*dxout++; |
1244 |
|
y[i] = (float)*dyout++; |
1245 |
|
thx[i] = (float)*dthxout++; |
1246 |
|
thy[i] = (float)*dthyout++; |
1247 |
|
tl[i] = (float)*dtlout++; |
1248 |
|
} |
1249 |
|
|
1250 |
|
return ifail; |
1251 |
|
}; |
1252 |
|
|
1253 |
ClassImp(TrkLevel2); |
ClassImp(TrkLevel2); |
1254 |
ClassImp(TrkSinglet); |
ClassImp(TrkSinglet); |
1255 |
ClassImp(TrkTrack); |
ClassImp(TrkTrack); |