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 |
12 |
extern "C" { |
extern "C" { |
13 |
void dotrack_(int*, double*, double*, double*, double*, int*); |
void dotrack_(int*, double*, double*, double*, double*, int*); |
14 |
void dotrack2_(int*, double*, double*, double*, double*,double*, double*, double*,int*); |
void dotrack2_(int*, double*, double*, double*, double*,double*, double*, double*,int*); |
15 |
int readb_(const char*); |
// int readb_(const char*); |
16 |
|
// int readb_(); |
17 |
|
void mini2_(int*,int*,int*); |
18 |
|
void guess_(); |
19 |
|
void gufld_(float*, float*); |
20 |
} |
} |
21 |
|
|
22 |
//-------------------------------------- |
//-------------------------------------- |
23 |
// |
// |
24 |
// |
// |
25 |
//-------------------------------------- |
//-------------------------------------- |
26 |
TrkTrack::TrkTrack(){ |
TrkTrack::TrkTrack(){ |
27 |
|
// cout << "TrkTrack::TrkTrack()" << endl; |
28 |
seqno = -1; |
seqno = -1; |
29 |
image = -1; |
image = -1; |
30 |
chi2 = 0; |
chi2 = 0; |
31 |
|
nstep = 0; |
32 |
for(int it1=0;it1<5;it1++){ |
for(int it1=0;it1<5;it1++){ |
33 |
al[it1] = 0; |
al[it1] = 0; |
34 |
for(int it2=0;it2<5;it2++) |
for(int it2=0;it2<5;it2++)coval[it1][it2] = 0; |
|
coval[it1][it2] = 0; |
|
35 |
}; |
}; |
36 |
for(int ip=0;ip<6;ip++){ |
for(int ip=0;ip<6;ip++){ |
37 |
xgood[ip] = 0; |
xgood[ip] = 0; |
48 |
ayv[ip] = 0; |
ayv[ip] = 0; |
49 |
dedx_x[ip] = 0; |
dedx_x[ip] = 0; |
50 |
dedx_y[ip] = 0; |
dedx_y[ip] = 0; |
51 |
}; |
}; |
52 |
|
clx = 0; |
53 |
|
cly = 0; |
54 |
|
// clx = new TRefArray(6,0); //forse causa memory leak??? |
55 |
|
// cly = new TRefArray(6,0); //forse causa memory leak??? |
56 |
}; |
}; |
57 |
//-------------------------------------- |
//-------------------------------------- |
58 |
// |
// |
62 |
seqno = t.seqno; |
seqno = t.seqno; |
63 |
image = t.image; |
image = t.image; |
64 |
chi2 = t.chi2; |
chi2 = t.chi2; |
65 |
|
nstep = t.nstep; |
66 |
for(int it1=0;it1<5;it1++){ |
for(int it1=0;it1<5;it1++){ |
67 |
al[it1] = t.al[it1]; |
al[it1] = t.al[it1]; |
68 |
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]; |
|
69 |
}; |
}; |
70 |
for(int ip=0;ip<6;ip++){ |
for(int ip=0;ip<6;ip++){ |
71 |
xgood[ip] = t.xgood[ip]; |
xgood[ip] = t.xgood[ip]; |
82 |
ayv[ip] = t.ayv[ip]; |
ayv[ip] = t.ayv[ip]; |
83 |
dedx_x[ip] = t.dedx_x[ip]; |
dedx_x[ip] = t.dedx_x[ip]; |
84 |
dedx_y[ip] = t.dedx_y[ip]; |
dedx_y[ip] = t.dedx_y[ip]; |
85 |
}; |
}; |
86 |
|
clx = 0; |
87 |
|
cly = 0; |
88 |
|
if(t.clx)clx = new TRefArray(*(t.clx)); |
89 |
|
if(t.cly)cly = new TRefArray(*(t.cly)); |
90 |
|
|
91 |
|
}; |
92 |
|
//-------------------------------------- |
93 |
|
// |
94 |
|
// |
95 |
|
//-------------------------------------- |
96 |
|
void TrkTrack::Copy(TrkTrack& t){ |
97 |
|
|
98 |
|
t.seqno = seqno; |
99 |
|
t.image = image; |
100 |
|
t.chi2 = chi2; |
101 |
|
t.nstep = nstep; |
102 |
|
for(int it1=0;it1<5;it1++){ |
103 |
|
t.al[it1] = al[it1]; |
104 |
|
for(int it2=0;it2<5;it2++)t.coval[it1][it2] = coval[it1][it2]; |
105 |
|
}; |
106 |
|
for(int ip=0;ip<6;ip++){ |
107 |
|
t.xgood[ip] = xgood[ip]; |
108 |
|
t.ygood[ip] = ygood[ip]; |
109 |
|
t.xm[ip] = xm[ip]; |
110 |
|
t.ym[ip] = ym[ip]; |
111 |
|
t.zm[ip] = zm[ip]; |
112 |
|
t.resx[ip] = resx[ip]; |
113 |
|
t.resy[ip] = resy[ip]; |
114 |
|
t.xv[ip] = xv[ip]; |
115 |
|
t.yv[ip] = yv[ip]; |
116 |
|
t.zv[ip] = zv[ip]; |
117 |
|
t.axv[ip] = axv[ip]; |
118 |
|
t.ayv[ip] = ayv[ip]; |
119 |
|
t.dedx_x[ip] = dedx_x[ip]; |
120 |
|
t.dedx_y[ip] = dedx_y[ip]; |
121 |
|
|
122 |
|
}; |
123 |
|
|
124 |
}; |
}; |
125 |
//-------------------------------------- |
//-------------------------------------- |
126 |
// |
// |
145 |
for (int i=0; i<5; i++) dal[i] = (double)al[i]; |
for (int i=0; i<5; i++) dal[i] = (double)al[i]; |
146 |
for (int i=0; i<t->npoint; i++) dzin[i] = (double)t->z[i]; |
for (int i=0; i<t->npoint; i++) dzin[i] = (double)t->z[i]; |
147 |
|
|
148 |
|
TrkParams::Load(1); |
149 |
|
if( !TrkParams::IsLoaded(1) ){ |
150 |
|
cout << "int TrkTrack::DoTrack(Trajectory* t) --- ERROR --- m.field not loaded"<<endl; |
151 |
|
return 0; |
152 |
|
} |
153 |
dotrack_(&(t->npoint),dzin,dxout,dyout,dal,&ifail); |
dotrack_(&(t->npoint),dzin,dxout,dyout,dal,&ifail); |
154 |
|
|
155 |
for (int i=0; i<t->npoint; i++){ |
for (int i=0; i<t->npoint; i++){ |
189 |
for (int i=0; i<5; i++) dal[i] = (double)al[i]; |
for (int i=0; i<5; i++) dal[i] = (double)al[i]; |
190 |
for (int i=0; i<t->npoint; i++) dzin[i] = (double)t->z[i]; |
for (int i=0; i<t->npoint; i++) dzin[i] = (double)t->z[i]; |
191 |
|
|
192 |
|
TrkParams::Load(1); |
193 |
|
if( !TrkParams::IsLoaded(1) ){ |
194 |
|
cout << "int TrkTrack::DoTrack2(Trajectory* t) --- ERROR --- m.field not loaded"<<endl; |
195 |
|
return 0; |
196 |
|
} |
197 |
dotrack2_(&(t->npoint),dzin,dxout,dyout,dthxout,dthyout,dtlout,dal,&ifail); |
dotrack2_(&(t->npoint),dzin,dxout,dyout,dthxout,dthyout,dtlout,dal,&ifail); |
198 |
|
|
199 |
for (int i=0; i<t->npoint; i++){ |
for (int i=0; i<t->npoint; i++){ |
246 |
//-------------------------------------- |
//-------------------------------------- |
247 |
void TrkTrack::Dump(){ |
void TrkTrack::Dump(){ |
248 |
cout << endl << "========== Track " ; |
cout << endl << "========== Track " ; |
249 |
|
cout << endl << "seq. n. : "<< seqno; |
250 |
|
cout << endl << "image n. : "<< image; |
251 |
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] << " "; |
252 |
cout << endl << "chi^2 : "<< chi2; |
cout << endl << "chi^2 : "<< chi2; |
253 |
|
cout << endl << "n.step : "<< nstep; |
254 |
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] ; |
255 |
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] ; |
256 |
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] << " "; |
257 |
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] << " "; |
258 |
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] << " "; |
259 |
|
cout << endl << "xv : "; for(int i=0; i<6; i++)cout << xv[i] << " "; |
260 |
|
cout << endl << "yv : "; for(int i=0; i<6; i++)cout << yv[i] << " "; |
261 |
|
cout << endl << "zv : "; for(int i=0; i<6; i++)cout << zv[i] << " "; |
262 |
|
cout << endl << "resx : "; for(int i=0; i<6; i++)cout << resx[i] << " "; |
263 |
|
cout << endl << "resy : "; for(int i=0; i<6; i++)cout << resy[i] << " "; |
264 |
|
cout << endl << "coval : "; for(int i=0; i<5; i++)cout << coval[0][i]<<" "; |
265 |
|
cout << endl << " "; for(int i=0; i<5; i++)cout << coval[1][i]<<" "; |
266 |
|
cout << endl << " "; for(int i=0; i<5; i++)cout << coval[2][i]<<" "; |
267 |
|
cout << endl << " "; for(int i=0; i<5; i++)cout << coval[3][i]<<" "; |
268 |
|
cout << endl << " "; for(int i=0; i<5; i++)cout << coval[4][i]<<" "; |
269 |
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] << " "; |
270 |
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] << " "; |
271 |
|
cout << endl; |
272 |
|
} |
273 |
|
/** |
274 |
|
* Set the TrkTrack position measurements |
275 |
|
*/ |
276 |
|
void TrkTrack::SetMeasure(double *xmeas, double *ymeas, double *zmeas){ |
277 |
|
for(int i=0; i<6; i++) xm[i]=*xmeas++; |
278 |
|
for(int i=0; i<6; i++) ym[i]=*ymeas++; |
279 |
|
for(int i=0; i<6; i++) zm[i]=*zmeas++; |
280 |
|
} |
281 |
|
/** |
282 |
|
* Set the TrkTrack position resolution |
283 |
|
*/ |
284 |
|
void TrkTrack::SetResolution(double *rx, double *ry){ |
285 |
|
for(int i=0; i<6; i++) resx[i]=*rx++; |
286 |
|
for(int i=0; i<6; i++) resy[i]=*ry++; |
287 |
|
} |
288 |
|
/** |
289 |
|
* Set the TrkTrack good measurement |
290 |
|
*/ |
291 |
|
void TrkTrack::SetGood(int *xg, int *yg){ |
292 |
|
for(int i=0; i<6; i++) xgood[i]=*xg++; |
293 |
|
for(int i=0; i<6; i++) ygood[i]=*yg++; |
294 |
|
} |
295 |
|
|
296 |
|
/** |
297 |
|
* Load the magnetic field |
298 |
|
*/ |
299 |
|
void TrkTrack::LoadField(TString path){ |
300 |
|
|
301 |
|
// strcpy(path_.path,path.Data()); |
302 |
|
// path_.pathlen = path.Length(); |
303 |
|
// path_.error = 0; |
304 |
|
// readb_(); |
305 |
|
|
306 |
|
TrkParams::Set(path,1); |
307 |
|
TrkParams::Load(1); |
308 |
|
|
309 |
|
}; |
310 |
|
|
311 |
|
|
312 |
|
/** |
313 |
|
* Method to fill minimization-routine common |
314 |
|
*/ |
315 |
|
void TrkTrack::FillMiniStruct(cMini2track& track){ |
316 |
|
|
317 |
|
for(int i=0; i<6; i++){ |
318 |
|
|
319 |
|
track.xgood[i]=xgood[i]; |
320 |
|
track.ygood[i]=ygood[i]; |
321 |
|
|
322 |
|
track.xm[i]=xm[i]; |
323 |
|
track.ym[i]=ym[i]; |
324 |
|
track.zm[i]=zm[i]; |
325 |
|
|
326 |
|
// --- temporaneo ---------------------------- |
327 |
|
// andrebbe inserita la dimensione del sensore |
328 |
|
float segment = 100.; |
329 |
|
track.xm_a[i]=xm[i]; |
330 |
|
track.xm_b[i]=xm[i]; |
331 |
|
track.ym_a[i]=ym[i]; |
332 |
|
track.ym_b[i]=ym[i]; |
333 |
|
if( xgood[i] && !ygood[i] ){ |
334 |
|
track.ym_a[i] = track.ym_a[i]+segment; |
335 |
|
track.ym_b[i] = track.ym_b[i]-segment; |
336 |
|
}else if( !xgood[i] && ygood[i]){ |
337 |
|
track.xm_a[i] = track.xm_a[i]+segment; |
338 |
|
track.xm_b[i] = track.xm_b[i]-segment; |
339 |
|
} |
340 |
|
// --- temporaneo ---------------------------- |
341 |
|
|
342 |
|
track.resx[i]=resx[i]; |
343 |
|
track.resy[i]=resy[i]; |
344 |
|
} |
345 |
|
|
346 |
|
for(int i=0; i<5; i++) track.al[i]=al[i]; |
347 |
|
track.zini = 23.5; |
348 |
|
// ZINI = 23.5 !!! it should be the same parameter in all codes |
349 |
|
|
350 |
|
} |
351 |
|
/** |
352 |
|
* Method to set values from minimization-routine common |
353 |
|
*/ |
354 |
|
void TrkTrack::SetFromMiniStruct(cMini2track *track){ |
355 |
|
|
356 |
|
for(int i=0; i<5; i++) { |
357 |
|
al[i]=track->al[i]; |
358 |
|
for(int j=0; j<5; j++) coval[i][j]=track->cov[i][j]; |
359 |
|
} |
360 |
|
chi2 = track->chi2; |
361 |
|
nstep = track->nstep; |
362 |
|
for(int i=0; i<6; i++){ |
363 |
|
xv[i] = track->xv[i]; |
364 |
|
yv[i] = track->yv[i]; |
365 |
|
zv[i] = track->zv[i]; |
366 |
|
xm[i] = track->xm[i]; |
367 |
|
ym[i] = track->ym[i]; |
368 |
|
zm[i] = track->zm[i]; |
369 |
|
axv[i] = track->axv[i]; |
370 |
|
ayv[i] = track->ayv[i]; |
371 |
|
} |
372 |
|
|
373 |
|
} |
374 |
|
/** |
375 |
|
* Tracking method. It calls F77 mini routine. |
376 |
|
*/ |
377 |
|
void TrkTrack::Fit(double pfixed, int& fail, int iprint){ |
378 |
|
|
379 |
|
float al_ini[] = {0.,0.,0.,0.,0.}; |
380 |
|
|
381 |
|
extern cMini2track track_; |
382 |
|
fail = 0; |
383 |
|
FillMiniStruct(track_); |
384 |
|
|
385 |
|
// if fit variables have been reset, evaluate the initial guess |
386 |
|
if(al[0]==-9999.&&al[1]==-9999.&&al[2]==-9999.&&al[3]==-9999.&&al[4]==-9999.)guess_(); |
387 |
|
|
388 |
|
// --------------------- free momentum |
389 |
|
if(pfixed==0.) { |
390 |
|
track_.pfixed=0.; |
391 |
|
} |
392 |
|
// --------------------- fixed momentum |
393 |
|
if(pfixed!=0.) { |
394 |
|
al[4]=1./pfixed; |
395 |
|
track_.pfixed=pfixed; |
396 |
|
} |
397 |
|
|
398 |
|
// store temporarily the initial guess |
399 |
|
for(int i=0; i<5; i++) al_ini[i]=track_.al[i]; |
400 |
|
|
401 |
|
// ------------------------------------------ |
402 |
|
// call mini routine |
403 |
|
TrkParams::Load(1); |
404 |
|
if( !TrkParams::IsLoaded(1) ){ |
405 |
|
cout << "void TrkTrack::Fit(double pfixed, int& fail, int iprint) --- ERROR --- m.field not loaded"<<endl; |
406 |
|
return; |
407 |
|
} |
408 |
|
int istep=0; |
409 |
|
int ifail=0; |
410 |
|
mini2_(&istep,&ifail, &iprint); |
411 |
|
if(ifail!=0) { |
412 |
|
if(iprint)cout << "ERROR: ifail= " << ifail << endl; |
413 |
|
fail = 1; |
414 |
|
} |
415 |
|
// ------------------------------------------ |
416 |
|
|
417 |
|
SetFromMiniStruct(&track_); |
418 |
|
// cout << endl << "eta ===> " << track_.al[4] << endl; |
419 |
|
|
420 |
|
// for(int i=0; i<5; i++) al[i]=track_.al[i]; |
421 |
|
// chi2=track_.chi2; |
422 |
|
// nstep=track_.nstep; |
423 |
|
// for(int i=0; i<6; i++) xv[i]=track_.xv[i]; |
424 |
|
// for(int i=0; i<6; i++) yv[i]=track_.yv[i]; |
425 |
|
// for(int i=0; i<6; i++) zv[i]=track_.zv[i]; |
426 |
|
// for(int i=0; i<6; i++) axv[i]=track_.axv[i]; |
427 |
|
// for(int i=0; i<6; i++) ayv[i]=track_.ayv[i]; |
428 |
|
// for(int i=0; i<5; i++) { |
429 |
|
// for(int j=0; j<5; j++) coval[i][j]=track_.cov[i][j]; |
430 |
|
// } |
431 |
|
|
432 |
|
if(fail){ |
433 |
|
if(iprint)cout << " >>>> fit failed >>>> drawing initial par"<<endl; |
434 |
|
for(int i=0; i<5; i++) al[i]=al_ini[i]; |
435 |
|
} |
436 |
|
|
437 |
|
}; |
438 |
|
/* |
439 |
|
* Reset the fit parameters |
440 |
|
*/ |
441 |
|
void TrkTrack::FitReset(){ |
442 |
|
for(int i=0; i<5; i++) al[i]=-9999.; |
443 |
|
chi2=0.; |
444 |
|
nstep=0; |
445 |
|
for(int i=0; i<6; i++) xv[i]=0.; |
446 |
|
for(int i=0; i<6; i++) yv[i]=0.; |
447 |
|
for(int i=0; i<6; i++) zv[i]=0.; |
448 |
|
for(int i=0; i<6; i++) axv[i]=0.; |
449 |
|
for(int i=0; i<6; i++) ayv[i]=0.; |
450 |
|
for(int i=0; i<5; i++) { |
451 |
|
for(int j=0; j<5; j++) coval[i][j]=0.; |
452 |
|
} |
453 |
|
} |
454 |
|
void TrkTrack::SetTrackingMode(int trackmode){ |
455 |
|
extern cMini2track track_; |
456 |
|
track_.trackmode = trackmode; |
457 |
} |
} |
458 |
|
|
459 |
|
|
460 |
|
/* |
461 |
|
* Method to retrieve the X-view clusters associated to the track. |
462 |
|
* @param ip Tracker plane (0-5) |
463 |
|
*/ |
464 |
|
TrkCluster *TrkTrack::GetClusterX(int ip){ |
465 |
|
cout << " TrkCluster *TrkTrack::GetClusterX(int ip) -- momentaneamente fuori servizio --"<< endl; |
466 |
|
if(!clx)return NULL; |
467 |
|
TrkCluster *pt = (TrkCluster*)(clx->At(ip)); |
468 |
|
return pt; |
469 |
|
}; |
470 |
|
/* |
471 |
|
* Method to retrieve the Y-view clusters associated to the track. |
472 |
|
* @param ip Tracker plane (0-5) |
473 |
|
*/ |
474 |
|
TrkCluster *TrkTrack::GetClusterY(int ip){ |
475 |
|
cout << " TrkCluster *TrkTrack::GetClusterY(int ip) -- momentaneamente fuori servizio --"<< endl; |
476 |
|
if(!cly)return NULL; |
477 |
|
TrkCluster *pt = (TrkCluster*)(cly->At(ip)); |
478 |
|
return pt; |
479 |
|
}; |
480 |
|
|
481 |
|
|
482 |
|
//-------------------------------------- |
483 |
|
// |
484 |
|
// |
485 |
|
//-------------------------------------- |
486 |
|
void TrkTrack::Clear(){ |
487 |
|
// cout << "TrkTrack::Clear()"<<endl; |
488 |
|
seqno = -1; |
489 |
|
image = -1; |
490 |
|
chi2 = 0; |
491 |
|
nstep = 0; |
492 |
|
for(int it1=0;it1<5;it1++){ |
493 |
|
al[it1] = 0; |
494 |
|
for(int it2=0;it2<5;it2++)coval[it1][it2] = 0; |
495 |
|
}; |
496 |
|
for(int ip=0;ip<6;ip++){ |
497 |
|
xgood[ip] = 0; |
498 |
|
ygood[ip] = 0; |
499 |
|
xm[ip] = 0; |
500 |
|
ym[ip] = 0; |
501 |
|
zm[ip] = 0; |
502 |
|
resx[ip] = 0; |
503 |
|
resy[ip] = 0; |
504 |
|
xv[ip] = 0; |
505 |
|
yv[ip] = 0; |
506 |
|
zv[ip] = 0; |
507 |
|
axv[ip] = 0; |
508 |
|
ayv[ip] = 0; |
509 |
|
dedx_x[ip] = 0; |
510 |
|
dedx_y[ip] = 0; |
511 |
|
|
512 |
|
}; |
513 |
|
if(clx)clx->Clear(); |
514 |
|
if(cly)cly->Clear(); |
515 |
|
}; |
516 |
|
//-------------------------------------- |
517 |
|
// |
518 |
|
// |
519 |
|
//-------------------------------------- |
520 |
|
void TrkTrack::Delete(){ |
521 |
|
// cout << "TrkTrack::Delete()"<<endl; |
522 |
|
// Clear(); |
523 |
|
if(clx)delete clx; |
524 |
|
if(cly)delete cly; |
525 |
|
}; |
526 |
|
//-------------------------------------- |
527 |
|
// |
528 |
|
// |
529 |
|
//-------------------------------------- |
530 |
|
|
531 |
//-------------------------------------- |
//-------------------------------------- |
532 |
// |
// |
533 |
// |
// |
534 |
//-------------------------------------- |
//-------------------------------------- |
535 |
TrkSinglet::TrkSinglet(){ |
TrkSinglet::TrkSinglet(){ |
536 |
|
// cout << "TrkSinglet::TrkSinglet() " << GetUniqueID()<<endl; |
537 |
plane = 0; |
plane = 0; |
538 |
coord[0] = 0; |
coord[0] = 0; |
539 |
coord[1] = 0; |
coord[1] = 0; |
540 |
sgnl = 0; |
sgnl = 0; |
541 |
|
// cls = 0; |
542 |
}; |
}; |
543 |
//-------------------------------------- |
//-------------------------------------- |
544 |
// |
// |
545 |
// |
// |
546 |
//-------------------------------------- |
//-------------------------------------- |
547 |
TrkSinglet::TrkSinglet(const TrkSinglet& s){ |
TrkSinglet::TrkSinglet(const TrkSinglet& s){ |
548 |
|
// cout << "TrkSinglet::TrkSinglet(const TrkSinglet& s) " << GetUniqueID()<<endl; |
549 |
plane = s.plane; |
plane = s.plane; |
550 |
coord[0] = s.coord[0]; |
coord[0] = s.coord[0]; |
551 |
coord[1] = s.coord[1]; |
coord[1] = s.coord[1]; |
552 |
sgnl = s.sgnl; |
sgnl = s.sgnl; |
553 |
|
// cls = 0;//<<<<pointer |
554 |
|
cls = TRef(s.cls); |
555 |
}; |
}; |
556 |
//-------------------------------------- |
//-------------------------------------- |
557 |
// |
// |
568 |
// |
// |
569 |
// |
// |
570 |
//-------------------------------------- |
//-------------------------------------- |
571 |
|
void TrkSinglet::Clear(){ |
572 |
|
// cout << "TrkSinglet::Clear() " << GetUniqueID()<<endl; |
573 |
|
// cls=0; |
574 |
|
plane=-1; |
575 |
|
coord[0]=-999; |
576 |
|
coord[1]=-999; |
577 |
|
sgnl=0; |
578 |
|
|
579 |
|
} |
580 |
|
//-------------------------------------- |
581 |
|
// |
582 |
|
// |
583 |
|
//-------------------------------------- |
584 |
TrkLevel2::TrkLevel2(){ |
TrkLevel2::TrkLevel2(){ |
585 |
good2 = -1; |
// cout <<"TrkLevel2::TrkLevel2()"<<endl; |
586 |
for(Int_t i=0; i<12 ; i++){ |
for(Int_t i=0; i<12 ; i++){ |
587 |
crc[i] = -1; |
good[i] = -1; |
588 |
}; |
}; |
589 |
Track = new TClonesArray("TrkTrack"); |
// okkio!! memory-leak |
590 |
SingletX = new TClonesArray("TrkSinglet"); |
// Track = new TClonesArray("TrkTrack"); |
591 |
SingletY = new TClonesArray("TrkSinglet"); |
// SingletX = new TClonesArray("TrkSinglet"); |
592 |
|
// SingletY = new TClonesArray("TrkSinglet"); |
593 |
|
Track = 0; |
594 |
|
SingletX = 0; |
595 |
|
SingletY = 0; |
596 |
|
|
597 |
// PhysicalTrack = new TClonesArray("TrkTrack"); |
} |
598 |
//sostituire con TRefArray... appena ho capito come si usa |
//-------------------------------------- |
599 |
|
// |
600 |
|
// |
601 |
|
//-------------------------------------- |
602 |
|
void TrkLevel2::Set(){ |
603 |
|
if(!Track)Track = new TClonesArray("TrkTrack"); |
604 |
|
if(!SingletX)SingletX = new TClonesArray("TrkSinglet"); |
605 |
|
if(!SingletY)SingletY = new TClonesArray("TrkSinglet"); |
606 |
} |
} |
607 |
//-------------------------------------- |
//-------------------------------------- |
608 |
// |
// |
609 |
// |
// |
610 |
//-------------------------------------- |
//-------------------------------------- |
611 |
void TrkLevel2::Dump(){ |
void TrkLevel2::Dump(){ |
612 |
TClonesArray &t = *Track; |
|
613 |
TClonesArray &sx = *SingletX; |
// |
|
TClonesArray &sy = *SingletY; |
|
|
|
|
614 |
cout << endl << endl << "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"; |
cout << endl << endl << "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"; |
615 |
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]; |
|
616 |
cout << endl << "ntrk() : " << this->ntrk() ; |
cout << endl << "ntrk() : " << this->ntrk() ; |
617 |
cout << endl << "nclsx() : " << this->nclsx(); |
cout << endl << "nclsx() : " << this->nclsx(); |
618 |
cout << endl << "nclsy() : " << this->nclsy(); |
cout << endl << "nclsy() : " << this->nclsy(); |
619 |
for(int i=0; i<this->ntrk(); i++) ((TrkTrack *)t[i])->Dump(); |
// TClonesArray &t = *Track; |
620 |
for(int i=0; i<this->nclsx(); i++) ((TrkSinglet *)sx[i])->Dump(); |
// TClonesArray &sx = *SingletX; |
621 |
for(int i=0; i<this->nclsy(); i++) ((TrkSinglet *)sy[i])->Dump(); |
// TClonesArray &sy = *SingletY; |
622 |
|
// for(int i=0; i<ntrk(); i++) ((TrkTrack *)t[i])->Dump(); |
623 |
|
// for(int i=0; i<nclsx(); i++) ((TrkSinglet *)sx[i])->Dump(); |
624 |
|
// for(int i=0; i<nclsy(); i++) ((TrkSinglet *)sy[i])->Dump(); |
625 |
|
if(Track){ |
626 |
|
TClonesArray &t = *Track; |
627 |
|
for(int i=0; i<ntrk(); i++) ((TrkTrack *)t[i])->Dump(); |
628 |
|
} |
629 |
|
if(SingletX){ |
630 |
|
TClonesArray &sx = *SingletX; |
631 |
|
for(int i=0; i<nclsx(); i++) ((TrkSinglet *)sx[i])->Dump(); |
632 |
|
} |
633 |
|
if(SingletY){ |
634 |
|
TClonesArray &sy = *SingletY; |
635 |
|
for(int i=0; i<nclsy(); i++) ((TrkSinglet *)sy[i])->Dump(); |
636 |
|
} |
637 |
} |
} |
638 |
//-------------------------------------- |
//-------------------------------------- |
639 |
// |
// |
642 |
/** |
/** |
643 |
* 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). |
644 |
*/ |
*/ |
645 |
void TrkLevel2::SetFromLevel2Struct(cTrkLevel2 *l2){ |
// void TrkLevel2::SetFromLevel2Struct(cTrkLevel2 *l2){ |
646 |
// |
|
647 |
// Track = new TClonesArray("TrkTrack"); |
// // temporary objects: |
648 |
// SingletX = new TClonesArray("TrkSinglet"); |
// TrkSinglet* t_singlet = new TrkSinglet(); |
649 |
// SingletY = new TClonesArray("TrkSinglet"); |
// TrkTrack* t_track = new TrkTrack(); |
650 |
|
|
651 |
|
// // **** general variables **** |
652 |
|
// // good2 = l2->good2; |
653 |
|
// for(Int_t i=0; i<12 ; i++){ |
654 |
|
// // crc[i] = l2->crc[i]; |
655 |
|
// good[i] = l2->good[i]; |
656 |
|
// }; |
657 |
|
// // *** TRACKS *** |
658 |
|
// if(!Track) Track = new TClonesArray("TrkTrack"); |
659 |
|
// TClonesArray &t = *Track; |
660 |
|
// for(int i=0; i<l2->ntrk; i++){ |
661 |
|
// t_track->seqno = i;// NBNBNBNB deve sempre essere = i |
662 |
|
// t_track->image = l2->image[i]-1; |
663 |
|
// // cout << "track "<<i<<t_track->seqno << t_track->image<<endl; |
664 |
|
// t_track->chi2 = l2->chi2_nt[i]; |
665 |
|
// t_track->nstep = l2->nstep_nt[i]; |
666 |
|
// for(int it1=0;it1<5;it1++){ |
667 |
|
// t_track->al[it1] = l2->al_nt[i][it1]; |
668 |
|
// for(int it2=0;it2<5;it2++) |
669 |
|
// t_track->coval[it1][it2] = l2->coval[i][it2][it1]; |
670 |
|
// }; |
671 |
|
// for(int ip=0;ip<6;ip++){ |
672 |
|
// t_track->xgood[ip] = l2->xgood_nt[i][ip]; |
673 |
|
// t_track->ygood[ip] = l2->ygood_nt[i][ip]; |
674 |
|
// t_track->xm[ip] = l2->xm_nt[i][ip]; |
675 |
|
// t_track->ym[ip] = l2->ym_nt[i][ip]; |
676 |
|
// t_track->zm[ip] = l2->zm_nt[i][ip]; |
677 |
|
// t_track->resx[ip] = l2->resx_nt[i][ip]; |
678 |
|
// t_track->resy[ip] = l2->resy_nt[i][ip]; |
679 |
|
// t_track->xv[ip] = l2->xv_nt[i][ip]; |
680 |
|
// t_track->yv[ip] = l2->yv_nt[i][ip]; |
681 |
|
// t_track->zv[ip] = l2->zv_nt[i][ip]; |
682 |
|
// t_track->axv[ip] = l2->axv_nt[i][ip]; |
683 |
|
// t_track->ayv[ip] = l2->ayv_nt[i][ip]; |
684 |
|
// t_track->dedx_x[ip] = l2->dedx_x[i][ip]; |
685 |
|
// t_track->dedx_y[ip] = l2->dedx_y[i][ip]; |
686 |
|
// // t_track->clx[ip] = 0; |
687 |
|
// // t_track->cly[ip] = 0; |
688 |
|
// }; |
689 |
|
// new(t[i]) TrkTrack(*t_track); |
690 |
|
// t_track->Clear(); |
691 |
|
// }; |
692 |
|
// // *** SINGLETS *** |
693 |
|
// if(!SingletX)SingletX = new TClonesArray("TrkSinglet"); |
694 |
|
// TClonesArray &sx = *SingletX; |
695 |
|
// for(int i=0; i<l2->nclsx; i++){ |
696 |
|
// t_singlet->plane = l2->planex[i]; |
697 |
|
// t_singlet->coord[0] = l2->xs[i][0]; |
698 |
|
// t_singlet->coord[1] = l2->xs[i][1]; |
699 |
|
// t_singlet->sgnl = l2->signlxs[i]; |
700 |
|
// // t_singlet->cls = 0; |
701 |
|
// new(sx[i]) TrkSinglet(*t_singlet); |
702 |
|
// t_singlet->Clear(); |
703 |
|
// } |
704 |
|
// if(!SingletY)SingletY = new TClonesArray("TrkSinglet"); |
705 |
|
// TClonesArray &sy = *SingletY; |
706 |
|
// for(int i=0; i<l2->nclsy; i++){ |
707 |
|
// t_singlet->plane = l2->planey[i]; |
708 |
|
// t_singlet->coord[0] = l2->ys[i][0]; |
709 |
|
// t_singlet->coord[1] = l2->ys[i][1]; |
710 |
|
// t_singlet->sgnl = l2->signlys[i]; |
711 |
|
// // t_singlet->cls = 0; |
712 |
|
// new(sy[i]) TrkSinglet(*t_singlet); |
713 |
|
// t_singlet->Clear(); |
714 |
|
// }; |
715 |
|
|
716 |
|
// delete t_track; |
717 |
|
// delete t_singlet; |
718 |
|
// } |
719 |
|
//-------------------------------------- |
720 |
|
// |
721 |
|
// |
722 |
|
//-------------------------------------- |
723 |
|
/** |
724 |
|
* Fills a TrkLevel2 object with values from a struct cTrkLevel2 (to get data from F77 common). |
725 |
|
* Ref to Level1 data (clusters) is also set. If l1==NULL no references are set. |
726 |
|
* (NB It make sense to set references only if events are stored in a tree that contains also the Level1 branch) |
727 |
|
*/ |
728 |
|
void TrkLevel2::SetFromLevel2Struct(cTrkLevel2 *l2, TrkLevel1 *l1){ |
729 |
|
|
730 |
|
// cout << "void TrkLevel2::SetFromLevel2Struct(cTrkLevel2 *l2, TrkLevel1 *l1)"<<endl; |
731 |
|
Clear(); |
732 |
// temporary objects: |
// temporary objects: |
733 |
TrkSinglet* t_singlet = new TrkSinglet(); |
TrkSinglet* t_singlet = new TrkSinglet(); |
734 |
TrkTrack* t_track = new TrkTrack(); |
TrkTrack* t_track = new TrkTrack(); |
735 |
|
|
736 |
|
// ----------------- |
737 |
// general variables |
// general variables |
738 |
good2 = l2->good2; |
// ----------------- |
739 |
for(Int_t i=0; i<12 ; i++){ |
for(Int_t i=0; i<12 ; i++){ |
740 |
crc[i] = l2->crc[i]; |
good[i] = l2->good[i]; |
741 |
}; |
}; |
742 |
|
// -------------- |
743 |
// *** TRACKS *** |
// *** TRACKS *** |
744 |
|
// -------------- |
745 |
|
if(!Track) Track = new TClonesArray("TrkTrack"); |
746 |
TClonesArray &t = *Track; |
TClonesArray &t = *Track; |
747 |
|
//----------------------------------------------------- |
748 |
|
if( l1 && !t_track->clx )t_track->clx = new TRefArray(6,0); |
749 |
|
if( l1 && !t_track->cly )t_track->cly = new TRefArray(6,0); |
750 |
|
//----------------------------------------------------- |
751 |
for(int i=0; i<l2->ntrk; i++){ |
for(int i=0; i<l2->ntrk; i++){ |
752 |
t_track->seqno = i; |
// cout <<" TRACK "<<i<<" ------------------ "<<endl; |
753 |
|
t_track->seqno = i;// NBNBNBNB deve sempre essere = i |
754 |
t_track->image = l2->image[i]-1; |
t_track->image = l2->image[i]-1; |
|
// cout << "track "<<i<<t_track->seqno << t_track->image<<endl; |
|
755 |
t_track->chi2 = l2->chi2_nt[i]; |
t_track->chi2 = l2->chi2_nt[i]; |
756 |
|
t_track->nstep = l2->nstep_nt[i]; |
757 |
for(int it1=0;it1<5;it1++){ |
for(int it1=0;it1<5;it1++){ |
758 |
t_track->al[it1] = l2->al_nt[i][it1]; |
t_track->al[it1] = l2->al_nt[i][it1]; |
759 |
for(int it2=0;it2<5;it2++) |
for(int it2=0;it2<5;it2++) |
760 |
t_track->coval[it1][it2] = l2->coval[i][it2][it1]; |
t_track->coval[it1][it2] = l2->coval[i][it2][it1]; |
761 |
}; |
}; |
762 |
for(int ip=0;ip<6;ip++){ |
for(int ip=0;ip<6;ip++){ |
763 |
t_track->xgood[ip] = l2->xgood_nt[i][ip]; |
t_track->xgood[ip] = l2->cltrx[i][ip];//l2->xgood_nt[i][ip]; |
764 |
t_track->ygood[ip] = l2->ygood_nt[i][ip]; |
t_track->ygood[ip] = l2->cltry[i][ip];//l2->ygood_nt[i][ip]; |
765 |
t_track->xm[ip] = l2->xm_nt[i][ip]; |
t_track->xm[ip] = l2->xm_nt[i][ip]; |
766 |
t_track->ym[ip] = l2->ym_nt[i][ip]; |
t_track->ym[ip] = l2->ym_nt[i][ip]; |
767 |
t_track->zm[ip] = l2->zm_nt[i][ip]; |
t_track->zm[ip] = l2->zm_nt[i][ip]; |
774 |
t_track->ayv[ip] = l2->ayv_nt[i][ip]; |
t_track->ayv[ip] = l2->ayv_nt[i][ip]; |
775 |
t_track->dedx_x[ip] = l2->dedx_x[i][ip]; |
t_track->dedx_x[ip] = l2->dedx_x[i][ip]; |
776 |
t_track->dedx_y[ip] = l2->dedx_y[i][ip]; |
t_track->dedx_y[ip] = l2->dedx_y[i][ip]; |
777 |
|
// cout << " ip "<<ip<<" l2->cltrx[i][ip] "<< l2->cltrx[i][ip]<<endl; |
778 |
|
// cout << " ip "<<ip<<" l2->cltry[i][ip] "<< l2->cltry[i][ip]<<endl; |
779 |
|
//----------------------------------------------------- |
780 |
|
//----------------------------------------------------- |
781 |
|
// if(l1 && t_track->xgood[ip])t_track->clx->AddAt(l1->GetCluster(l2->cltrx[i][ip]-1),ip); |
782 |
|
// if(l1 && t_track->ygood[ip])t_track->cly->AddAt(l1->GetCluster(l2->cltry[i][ip]-1),ip); |
783 |
|
if(l2->xgood_nt[i][ip]){ |
784 |
|
// cout << " ip "<<ip<<" l2->cltrx[i][ip] "<< l2->cltrx[i][ip]<<endl; |
785 |
|
// cout << " ip "<<ip<<" l2->cltrx[i][ip] "<< l2->cltrx[i][ip]<<" "; |
786 |
|
// if( l1->GetCluster(l2->cltrx[i][ip]-1)->TestBit(l1->GetCluster(l2->cltrx[i][ip]-1)->kIsReferenced) )cout << ">> is referenced "; |
787 |
|
if(l1)t_track->clx->AddAt(l1->GetCluster(l2->cltrx[i][ip]-1),ip); |
788 |
|
// cout << " --- "<<l1->GetCluster(l2->cltrx[i][ip]-1)->GetUniqueID()<<endl; |
789 |
|
// t_track->xgood[ip] = l2->cltrx[i][ip]; // WORK-AROUND ***** |
790 |
|
}else{ |
791 |
|
if(l1)t_track->clx->RemoveAt(ip); |
792 |
|
} |
793 |
|
if(l2->ygood_nt[i][ip]){ |
794 |
|
// cout << " ip "<<ip<<" l2->cltry[i][ip] "<< l2->cltry[i][ip]<<endl; |
795 |
|
// cout << " ip "<<ip<<" l2->cltry[i][ip] "<< l2->cltry[i][ip]<<" "; |
796 |
|
// if( l1->GetCluster(l2->cltry[i][ip]-1)->TestBit(l1->GetCluster(l2->cltry[i][ip]-1)->kIsReferenced) )cout << ">> is referenced "; |
797 |
|
if(l1)t_track->cly->AddAt(l1->GetCluster(l2->cltry[i][ip]-1),ip); |
798 |
|
// cout << " --- "<<l1->GetCluster(l2->cltry[i][ip]-1)->GetUniqueID()<<endl; |
799 |
|
// t_track->ygood[ip] = l2->cltry[i][ip]; // WORK-AROUND ***** |
800 |
|
}else{ |
801 |
|
if(l1)t_track->cly->RemoveAt(ip); |
802 |
|
} |
803 |
|
//----------------------------------------------------- |
804 |
|
//----------------------------------------------------- |
805 |
}; |
}; |
806 |
new(t[i]) TrkTrack(*t_track); |
new(t[i]) TrkTrack(*t_track); |
807 |
t_track->Clear(); |
t_track->Clear(); |
808 |
}; |
}; |
809 |
|
// ---------------- |
810 |
// *** SINGLETS *** |
// *** SINGLETS *** |
811 |
|
// ---------------- |
812 |
|
if(!SingletX)SingletX = new TClonesArray("TrkSinglet"); |
813 |
TClonesArray &sx = *SingletX; |
TClonesArray &sx = *SingletX; |
814 |
for(int i=0; i<l2->nclsx; i++){ |
for(int i=0; i<l2->nclsx; i++){ |
815 |
t_singlet->plane = l2->planex[i]; |
t_singlet->plane = l2->planex[i]; |
816 |
t_singlet->coord[0] = l2->xs[i][0]; |
t_singlet->coord[0] = l2->xs[i][0]; |
817 |
t_singlet->coord[1] = l2->xs[i][1]; |
t_singlet->coord[1] = l2->xs[i][1]; |
818 |
t_singlet->sgnl = l2->signlxs[i]; |
t_singlet->sgnl = l2->signlxs[i]; |
819 |
|
//----------------------------------------------------- |
820 |
|
if(l1) t_singlet->cls = l1->GetCluster(l2->clsx[i]-1); |
821 |
|
//----------------------------------------------------- |
822 |
new(sx[i]) TrkSinglet(*t_singlet); |
new(sx[i]) TrkSinglet(*t_singlet); |
823 |
t_singlet->Clear(); |
t_singlet->Clear(); |
824 |
} |
} |
825 |
|
if(!SingletY)SingletY = new TClonesArray("TrkSinglet"); |
826 |
TClonesArray &sy = *SingletY; |
TClonesArray &sy = *SingletY; |
827 |
for(int i=0; i<l2->nclsy; i++){ |
for(int i=0; i<l2->nclsy; i++){ |
828 |
t_singlet->plane = l2->planey[i]; |
t_singlet->plane = l2->planey[i]; |
829 |
t_singlet->coord[0] = l2->ys[i][0]; |
t_singlet->coord[0] = l2->ys[i][0]; |
830 |
t_singlet->coord[1] = l2->ys[i][1]; |
t_singlet->coord[1] = l2->ys[i][1]; |
831 |
t_singlet->sgnl = l2->signlys[i]; |
t_singlet->sgnl = l2->signlys[i]; |
832 |
|
//----------------------------------------------------- |
833 |
|
if(l1) t_singlet->cls = l1->GetCluster(l2->clsy[i]-1); |
834 |
|
//----------------------------------------------------- |
835 |
new(sy[i]) TrkSinglet(*t_singlet); |
new(sy[i]) TrkSinglet(*t_singlet); |
836 |
t_singlet->Clear(); |
t_singlet->Clear(); |
837 |
}; |
}; |
838 |
|
|
839 |
delete t_track; |
delete t_track; |
840 |
delete t_singlet; |
delete t_singlet; |
841 |
} |
} |
842 |
/** |
/** |
843 |
* Fills a struct cTrkLevel2 with values from a TrkLevel2 object (to put data into a F77 common). |
* Fills a struct cTrkLevel2 with values from a TrkLevel2 object (to put data into a F77 common). |
846 |
void TrkLevel2::GetLevel2Struct(cTrkLevel2 *l2) const { |
void TrkLevel2::GetLevel2Struct(cTrkLevel2 *l2) const { |
847 |
|
|
848 |
// general variables |
// general variables |
849 |
l2->good2 = good2 ; |
// l2->good2 = good2 ; |
850 |
for(Int_t i=0; i<12 ; i++){ |
for(Int_t i=0; i<12 ; i++){ |
851 |
l2->crc[i] = crc[i]; |
// l2->crc[i] = crc[i]; |
852 |
|
l2->good[i] = good[i]; |
853 |
}; |
}; |
854 |
// *** TRACKS *** |
// *** TRACKS *** |
855 |
|
|
856 |
l2->ntrk = Track->GetEntries(); |
if(Track){ |
857 |
for(Int_t i=0;i<l2->ntrk;i++){ |
l2->ntrk = Track->GetEntries(); |
858 |
l2->image[i] = 1 + ((TrkTrack *)Track->At(i))->image; |
for(Int_t i=0;i<l2->ntrk;i++){ |
859 |
l2->chi2_nt[i] = ((TrkTrack *)Track->At(i))->chi2; |
l2->image[i] = 1 + ((TrkTrack *)Track->At(i))->image; |
860 |
for(int it1=0;it1<5;it1++){ |
l2->chi2_nt[i] = ((TrkTrack *)Track->At(i))->chi2; |
861 |
l2->al_nt[i][it1] = ((TrkTrack *)Track->At(i))->al[it1]; |
l2->nstep_nt[i] = ((TrkTrack *)Track->At(i))->nstep; |
862 |
for(int it2=0;it2<5;it2++) |
for(int it1=0;it1<5;it1++){ |
863 |
l2->coval[i][it2][it1] = ((TrkTrack *)Track->At(i))->coval[it1][it2]; |
l2->al_nt[i][it1] = ((TrkTrack *)Track->At(i))->al[it1]; |
864 |
}; |
for(int it2=0;it2<5;it2++) |
865 |
for(int ip=0;ip<6;ip++){ |
l2->coval[i][it2][it1] = ((TrkTrack *)Track->At(i))->coval[it1][it2]; |
866 |
l2->xgood_nt[i][ip] = ((TrkTrack *)Track->At(i))->xgood[ip]; |
}; |
867 |
l2->ygood_nt[i][ip] = ((TrkTrack *)Track->At(i))->ygood[ip]; |
for(int ip=0;ip<6;ip++){ |
868 |
l2->xm_nt[i][ip] = ((TrkTrack *)Track->At(i))->xm[ip]; |
l2->xgood_nt[i][ip] = ((TrkTrack *)Track->At(i))->xgood[ip]; |
869 |
l2->ym_nt[i][ip] = ((TrkTrack *)Track->At(i))->ym[ip]; |
l2->ygood_nt[i][ip] = ((TrkTrack *)Track->At(i))->ygood[ip]; |
870 |
l2->zm_nt[i][ip] = ((TrkTrack *)Track->At(i))->zm[ip]; |
l2->xm_nt[i][ip] = ((TrkTrack *)Track->At(i))->xm[ip]; |
871 |
l2->resx_nt[i][ip] = ((TrkTrack *)Track->At(i))->resx[ip]; |
l2->ym_nt[i][ip] = ((TrkTrack *)Track->At(i))->ym[ip]; |
872 |
l2->resy_nt[i][ip] = ((TrkTrack *)Track->At(i))->resy[ip]; |
l2->zm_nt[i][ip] = ((TrkTrack *)Track->At(i))->zm[ip]; |
873 |
l2->xv_nt[i][ip] = ((TrkTrack *)Track->At(i))->xv[ip]; |
l2->resx_nt[i][ip] = ((TrkTrack *)Track->At(i))->resx[ip]; |
874 |
l2->yv_nt[i][ip] = ((TrkTrack *)Track->At(i))->yv[ip]; |
l2->resy_nt[i][ip] = ((TrkTrack *)Track->At(i))->resy[ip]; |
875 |
l2->zv_nt[i][ip] = ((TrkTrack *)Track->At(i))->zv[ip]; |
l2->xv_nt[i][ip] = ((TrkTrack *)Track->At(i))->xv[ip]; |
876 |
l2->axv_nt[i][ip] = ((TrkTrack *)Track->At(i))->axv[ip]; |
l2->yv_nt[i][ip] = ((TrkTrack *)Track->At(i))->yv[ip]; |
877 |
l2->ayv_nt[i][ip] = ((TrkTrack *)Track->At(i))->ayv[ip]; |
l2->zv_nt[i][ip] = ((TrkTrack *)Track->At(i))->zv[ip]; |
878 |
l2->dedx_x[i][ip] = ((TrkTrack *)Track->At(i))->dedx_x[ip]; |
l2->axv_nt[i][ip] = ((TrkTrack *)Track->At(i))->axv[ip]; |
879 |
l2->dedx_y[i][ip] = ((TrkTrack *)Track->At(i))->dedx_y[ip]; |
l2->ayv_nt[i][ip] = ((TrkTrack *)Track->At(i))->ayv[ip]; |
880 |
}; |
l2->dedx_x[i][ip] = ((TrkTrack *)Track->At(i))->dedx_x[ip]; |
881 |
|
l2->dedx_y[i][ip] = ((TrkTrack *)Track->At(i))->dedx_y[ip]; |
882 |
|
}; |
883 |
|
} |
884 |
} |
} |
|
|
|
885 |
// *** SINGLETS *** |
// *** SINGLETS *** |
886 |
l2->nclsx = SingletX->GetEntries(); |
if(SingletX){ |
887 |
for(Int_t i=0;i<l2->nclsx;i++){ |
l2->nclsx = SingletX->GetEntries(); |
888 |
l2->planex[i] = ((TrkSinglet *)SingletX->At(i))->plane; |
for(Int_t i=0;i<l2->nclsx;i++){ |
889 |
l2->xs[i][0] = ((TrkSinglet *)SingletX->At(i))->coord[0]; |
l2->planex[i] = ((TrkSinglet *)SingletX->At(i))->plane; |
890 |
l2->xs[i][1] = ((TrkSinglet *)SingletX->At(i))->coord[1]; |
l2->xs[i][0] = ((TrkSinglet *)SingletX->At(i))->coord[0]; |
891 |
l2->signlxs[i] = ((TrkSinglet *)SingletX->At(i))->sgnl; |
l2->xs[i][1] = ((TrkSinglet *)SingletX->At(i))->coord[1]; |
892 |
} |
l2->signlxs[i] = ((TrkSinglet *)SingletX->At(i))->sgnl; |
893 |
l2->nclsy = SingletY->GetEntries(); |
} |
894 |
for(Int_t i=0;i<l2->nclsy;i++){ |
} |
895 |
l2->planey[i] = ((TrkSinglet *)SingletY->At(i))->plane; |
|
896 |
l2->ys[i][0] = ((TrkSinglet *)SingletY->At(i))->coord[0]; |
if(SingletY){ |
897 |
l2->ys[i][1] = ((TrkSinglet *)SingletY->At(i))->coord[1]; |
l2->nclsy = SingletY->GetEntries(); |
898 |
l2->signlys[i] = ((TrkSinglet *)SingletY->At(i))->sgnl; |
for(Int_t i=0;i<l2->nclsy;i++){ |
899 |
|
l2->planey[i] = ((TrkSinglet *)SingletY->At(i))->plane; |
900 |
|
l2->ys[i][0] = ((TrkSinglet *)SingletY->At(i))->coord[0]; |
901 |
|
l2->ys[i][1] = ((TrkSinglet *)SingletY->At(i))->coord[1]; |
902 |
|
l2->signlys[i] = ((TrkSinglet *)SingletY->At(i))->sgnl; |
903 |
|
} |
904 |
} |
} |
905 |
} |
} |
906 |
//-------------------------------------- |
//-------------------------------------- |
908 |
// |
// |
909 |
//-------------------------------------- |
//-------------------------------------- |
910 |
void TrkLevel2::Clear(){ |
void TrkLevel2::Clear(){ |
|
good2 = -1; |
|
911 |
for(Int_t i=0; i<12 ; i++){ |
for(Int_t i=0; i<12 ; i++){ |
912 |
crc[i] = -1; |
good[i] = -1; |
913 |
}; |
}; |
914 |
/* Track->RemoveAll(); |
// if(Track)Track->Clear("C"); |
915 |
SingletX->RemoveAll(); |
// if(SingletX)SingletX->Clear("C"); |
916 |
SingletY->RemoveAll();*/ |
// if(SingletY)SingletY->Clear("C"); |
917 |
// modify to avoid memory leakage |
if(Track)Track->Delete(); |
918 |
Track->Clear(); |
if(SingletX)SingletX->Delete(); |
919 |
SingletX->Clear(); |
if(SingletY)SingletY->Delete(); |
920 |
SingletY->Clear(); |
} |
921 |
|
// //-------------------------------------- |
922 |
|
// // |
923 |
|
// // |
924 |
|
// //-------------------------------------- |
925 |
|
void TrkLevel2::Delete(){ |
926 |
|
|
927 |
|
// cout << "void TrkLevel2::Delete()"<<endl; |
928 |
|
Clear(); |
929 |
|
if(Track)delete Track; |
930 |
|
if(SingletX)delete SingletX; |
931 |
|
if(SingletY)delete SingletY; |
932 |
|
|
933 |
} |
} |
934 |
//-------------------------------------- |
//-------------------------------------- |
935 |
// |
// |
939 |
* 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). |
940 |
* 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. |
941 |
*/ |
*/ |
942 |
// TClonesArray *TrkLevel2::GetTracks(){ |
TRefArray *TrkLevel2::GetTracks_NFitSorted(){ |
|
// TClonesArray *sorted = GetTracks_NFitSorted(); |
|
|
// return sorted; |
|
|
// }; |
|
943 |
|
|
944 |
/*TClonesArray *TrkLevel2::GetTracks_Chi2Sorted(){ |
if(!Track)return 0; |
945 |
|
|
946 |
TClonesArray *sorted = new TClonesArray("TrkTrack"); |
TRefArray *sorted = new TRefArray(); |
947 |
TClonesArray &t = *Track; |
|
948 |
TClonesArray &ts = *sorted; |
TClonesArray &t = *Track; |
949 |
int N=this->ntrk(); |
// TClonesArray &ts = *PhysicalTrack; |
950 |
|
int N = ntrk(); |
951 |
vector<int> m(N); for(int i=0; i<N; i++)m[i]=1; |
vector<int> m(N); for(int i=0; i<N; i++)m[i]=1; |
952 |
|
// int m[50]; for(int i=0; i<N; i++)m[i]=1; |
953 |
|
|
954 |
int indo=0; |
int indo=0; |
955 |
int indi=0; |
int indi=0; |
956 |
while(N != 0){ |
while(N > 0){ |
957 |
float chi2ref=1000000; |
// while(N != 0){ |
958 |
for(int i=0; i<this->ntrk(); i++){ |
int nfit =0; |
959 |
if(((TrkTrack *)t[i])->chi2 < chi2ref && m[i]==1){ |
float chi2ref = numeric_limits<float>::max(); |
960 |
chi2ref = ((TrkTrack *)t[i])->chi2; |
|
961 |
indi = i; |
// first loop to search maximum num. of fit points |
962 |
|
for(int i=0; i < ntrk(); i++){ |
963 |
|
if( ((TrkTrack *)t[i])->GetNtot() >= nfit && m[i]==1){ |
964 |
|
nfit = ((TrkTrack *)t[i])->GetNtot(); |
965 |
} |
} |
966 |
} |
} |
967 |
if( ((TrkTrack *)t[indi])->image != -1 ){ |
//second loop to search minimum chi2 among selected |
968 |
|
for(int i=0; i<ntrk(); i++){ |
969 |
|
Float_t chi2 = ((TrkTrack *)t[i])->chi2; |
970 |
|
if(chi2 < 0) chi2 = -chi2*1000; |
971 |
|
if( chi2 < chi2ref |
972 |
|
&& ((TrkTrack *)t[i])->GetNtot() == nfit |
973 |
|
&& m[i]==1){ |
974 |
|
chi2ref = ((TrkTrack *)t[i])->chi2; |
975 |
|
indi = i; |
976 |
|
}; |
977 |
|
}; |
978 |
|
if( ((TrkTrack *)t[indi])->HasImage() ){ |
979 |
m[((TrkTrack *)t[indi])->image] = 0; |
m[((TrkTrack *)t[indi])->image] = 0; |
980 |
N--; |
N--; |
981 |
} |
|
982 |
new(ts[indo]) TrkTrack(*(TrkTrack*)t[indi]); |
// cout << "i** "<< ((TrkTrack *)t[indi])->image << " " << nfiti <<" "<<chi2i<<endl; |
983 |
|
}; |
984 |
|
sorted->Add( (TrkTrack*)t[indi] ); |
985 |
|
|
986 |
m[indi] = 0; |
m[indi] = 0; |
987 |
|
// cout << "SORTED "<< indo << " "<< indi << " "<< N << " "<<((TrkTrack *)t[indi])->image<<" "<<chi2ref<<endl; |
988 |
N--; |
N--; |
989 |
indo++; |
indo++; |
990 |
} |
} |
991 |
return sorted; |
m.clear(); |
992 |
}*/ |
// cout << "GetTracks_NFitSorted(it): Done"<< endl; |
|
/*TClonesArray *TrkLevel2::GetTracks_NFitSorted(){ |
|
993 |
|
|
|
TClonesArray *sorted = new TClonesArray("TrkTrack"); |
|
|
TClonesArray &t = *Track; |
|
|
TClonesArray &ts = *sorted; |
|
|
// TClonesArray &ts = *PhysicalTrack; |
|
|
int N = ntrk(); |
|
|
vector<int> m(N); for(int i=0; i<N; i++)m[i]=1; |
|
|
// int m[50]; for(int i=0; i<N; i++)m[i]=1; |
|
|
|
|
|
int indo=0; |
|
|
int indi=0; |
|
|
while(N != 0){ |
|
|
int nfit =0; |
|
|
float chi2ref = numeric_limits<float>::max(); |
|
|
// first loop to search maximum num. of fit points |
|
|
for(int i=0; i < ntrk(); i++){ |
|
|
// if(N==ntrk())cout << "** "<<i<< " " << ((TrkTrack *)t[i])->GetImageSeqNo()<< " " <<((TrkTrack *)t[i])->GetNtot() << " " <<((TrkTrack *)t[i])->chi2 << endl; |
|
|
if( ((TrkTrack *)t[i])->GetNtot() >= nfit && m[i]==1){ |
|
|
nfit = ((TrkTrack *)t[i])->GetNtot(); |
|
|
} |
|
|
} |
|
|
//second loop to search minimum chi2 among selected |
|
|
for(int i=0; i<this->ntrk(); i++){ |
|
|
if( ((TrkTrack *)t[i])->chi2 < chi2ref |
|
|
&& ((TrkTrack *)t[i])->GetNtot()== nfit |
|
|
&& m[i]==1){ |
|
|
chi2ref = ((TrkTrack *)t[i])->chi2; |
|
|
indi = i; |
|
|
// cout << "2** "<<i<< " " << nfit <<" "<<chi2ref<<endl; |
|
|
} |
|
|
} |
|
|
if( ((TrkTrack *)t[indi])->HasImage() ){ |
|
|
m[((TrkTrack *)t[indi])->image] = 0; |
|
|
N--; |
|
|
|
|
|
// Int_t nfiti=((TrkTrack *)t[((TrkTrack *)t[indi])->image ])->GetNtot(); |
|
|
// Float_t chi2i=((TrkTrack *)t[((TrkTrack *)t[indi])->image ])->chi2; |
|
|
|
|
|
// cout << "i** "<< ((TrkTrack *)t[indi])->image << " " << nfiti <<" "<<chi2i<<endl; |
|
|
} |
|
|
new(ts[indo]) TrkTrack(*(TrkTrack*)t[indi]); |
|
|
m[indi] = 0; |
|
|
// cout << "SORTED "<< indo << " "<< indi << " "<< N << endl; |
|
|
N--; |
|
|
indo++; |
|
|
} |
|
|
m.clear(); |
|
994 |
return sorted; |
return sorted; |
995 |
// return PhysicalTrack; |
// return PhysicalTrack; |
|
}*/ |
|
|
//TClonesArray *TrkLevel2::GetTracks_NFitSorted(){ |
|
|
TRefArray *TrkLevel2::GetTracks_NFitSorted(){ |
|
|
|
|
|
// cout << "GetTracks_NFitSorted(it): new TRefArray()"<< endl; |
|
|
// TClonesArray *sorted = new TClonesArray("TrkTrack"); |
|
|
// TClonesArray &ts = *sorted; |
|
|
TRefArray *sorted = new TRefArray(); |
|
|
|
|
|
TClonesArray &t = *Track; |
|
|
// TClonesArray &ts = *PhysicalTrack; |
|
|
int N = ntrk(); |
|
|
vector<int> m(N); for(int i=0; i<N; i++)m[i]=1; |
|
|
// int m[50]; for(int i=0; i<N; i++)m[i]=1; |
|
|
|
|
|
int indo=0; |
|
|
int indi=0; |
|
|
while(N != 0){ |
|
|
int nfit =0; |
|
|
float chi2ref = numeric_limits<float>::max(); |
|
|
// first loop to search maximum num. of fit points |
|
|
for(int i=0; i < ntrk(); i++){ |
|
|
// if(N==ntrk())cout << "** "<<i<< " " << ((TrkTrack *)t[i])->GetImageSeqNo()<< " " <<((TrkTrack *)t[i])->GetNtot() << " " <<((TrkTrack *)t[i])->chi2 << endl; |
|
|
if( ((TrkTrack *)t[i])->GetNtot() >= nfit && m[i]==1){ |
|
|
nfit = ((TrkTrack *)t[i])->GetNtot(); |
|
|
} |
|
|
} |
|
|
//second loop to search minimum chi2 among selected |
|
|
for(int i=0; i<this->ntrk(); i++){ |
|
|
if( ((TrkTrack *)t[i])->chi2 < chi2ref |
|
|
&& ((TrkTrack *)t[i])->GetNtot()== nfit |
|
|
&& m[i]==1){ |
|
|
chi2ref = ((TrkTrack *)t[i])->chi2; |
|
|
indi = i; |
|
|
// cout << "2** "<<i<< " " << nfit <<" "<<chi2ref<<endl; |
|
|
} |
|
|
} |
|
|
if( ((TrkTrack *)t[indi])->HasImage() ){ |
|
|
m[((TrkTrack *)t[indi])->image] = 0; |
|
|
N--; |
|
|
|
|
|
// Int_t nfiti=((TrkTrack *)t[((TrkTrack *)t[indi])->image ])->GetNtot(); |
|
|
// Float_t chi2i=((TrkTrack *)t[((TrkTrack *)t[indi])->image ])->chi2; |
|
|
|
|
|
// cout << "i** "<< ((TrkTrack *)t[indi])->image << " " << nfiti <<" "<<chi2i<<endl; |
|
|
} |
|
|
// new(ts[indo]) TrkTrack(*(TrkTrack*)t[indi]); |
|
|
// cout << "GetTracks_NFitSorted(it): Add("<<indo<<")"<< endl; |
|
|
sorted->Add( (TrkTrack*)t[indi] ); |
|
|
|
|
|
m[indi] = 0; |
|
|
// cout << "SORTED "<< indo << " "<< indi << " "<< N << endl; |
|
|
N--; |
|
|
indo++; |
|
|
} |
|
|
m.clear(); |
|
|
// cout << "GetTracks_NFitSorted(it): Done"<< endl; |
|
|
|
|
|
return sorted; |
|
|
// return PhysicalTrack; |
|
996 |
} |
} |
997 |
//-------------------------------------- |
//-------------------------------------- |
998 |
// |
// |
1010 |
cout << " Stored tracks ntrk() = "<< this->ntrk() << endl; |
cout << " Stored tracks ntrk() = "<< this->ntrk() << endl; |
1011 |
return 0; |
return 0; |
1012 |
} |
} |
1013 |
|
if(!Track){ |
1014 |
|
cout << "TrkTrack *TrkLevel2::GetStoredTrack(int is) >> (TClonesArray*) Track ==0 "<<endl; |
1015 |
|
}; |
1016 |
TClonesArray &t = *(Track); |
TClonesArray &t = *(Track); |
1017 |
TrkTrack *track = (TrkTrack*)t[is]; |
TrkTrack *track = (TrkTrack*)t[is]; |
1018 |
return track; |
return track; |
1032 |
cout << " Stored x-singlets nclsx() = "<< this->nclsx() << endl; |
cout << " Stored x-singlets nclsx() = "<< this->nclsx() << endl; |
1033 |
return 0; |
return 0; |
1034 |
} |
} |
1035 |
|
if(!SingletX)return 0; |
1036 |
TClonesArray &t = *(SingletX); |
TClonesArray &t = *(SingletX); |
1037 |
TrkSinglet *singlet = (TrkSinglet*)t[is]; |
TrkSinglet *singlet = (TrkSinglet*)t[is]; |
1038 |
return singlet; |
return singlet; |
1052 |
cout << " Stored y-singlets nclsy() = "<< this->nclsx() << endl; |
cout << " Stored y-singlets nclsy() = "<< this->nclsx() << endl; |
1053 |
return 0; |
return 0; |
1054 |
} |
} |
1055 |
|
if(!SingletY)return 0; |
1056 |
TClonesArray &t = *(SingletY); |
TClonesArray &t = *(SingletY); |
1057 |
TrkSinglet *singlet = (TrkSinglet*)t[is]; |
TrkSinglet *singlet = (TrkSinglet*)t[is]; |
1058 |
return singlet; |
return singlet; |
1065 |
* Retrieves the it-th "physical" track, sorted by the method GetNTracks(). |
* Retrieves the it-th "physical" track, sorted by the method GetNTracks(). |
1066 |
* @param it Track number, ranging from 0 to GetNTracks(). |
* @param it Track number, ranging from 0 to GetNTracks(). |
1067 |
*/ |
*/ |
1068 |
/*TrkTrack *TrkLevel2::GetTrack(int it){ |
|
|
|
|
|
if(it >= this->GetNTracks()){ |
|
|
cout << "** TrkLevel2 ** Track "<< it << "does not exits! " << endl; |
|
|
cout << " Physical tracks GetNTracks() = "<< this->ntrk() << endl; |
|
|
return 0; |
|
|
} |
|
|
TClonesArray* sorted = GetTracks(); |
|
|
TClonesArray &ts = *sorted; |
|
|
|
|
|
// TrkTrack *track = (TrkTrack*)ts[it]; |
|
|
TrkTrack *track = new TrkTrack( *(TrkTrack*)ts[it] ); //copia |
|
|
sorted->Delete("all");////TEMPORANEO |
|
|
return track; |
|
|
}*/ |
|
1069 |
TrkTrack *TrkLevel2::GetTrack(int it){ |
TrkTrack *TrkLevel2::GetTrack(int it){ |
1070 |
|
|
1071 |
if(it >= this->GetNTracks()){ |
if(it >= this->GetNTracks()){ |
1075 |
} |
} |
1076 |
|
|
1077 |
TRefArray *sorted = GetTracks(); //TEMPORANEO |
TRefArray *sorted = GetTracks(); //TEMPORANEO |
1078 |
|
if(!sorted)return 0; |
1079 |
TrkTrack *track = (TrkTrack*)sorted->At(it); |
TrkTrack *track = (TrkTrack*)sorted->At(it); |
1080 |
sorted->Delete(); |
sorted->Clear(); |
1081 |
|
delete sorted; |
1082 |
return track; |
return track; |
1083 |
} |
} |
1084 |
/** |
/** |
1087 |
Int_t TrkLevel2::GetNTracks(){ |
Int_t TrkLevel2::GetNTracks(){ |
1088 |
|
|
1089 |
Float_t ntot=0; |
Float_t ntot=0; |
1090 |
|
if(!Track)return 0; |
1091 |
TClonesArray &t = *Track; |
TClonesArray &t = *Track; |
1092 |
for(int i=0; i<ntrk(); i++) { |
for(int i=0; i<ntrk(); i++) { |
1093 |
if( ((TrkTrack *)t[i])->GetImageSeqNo() == -1 ) ntot+=1.; |
if( ((TrkTrack *)t[i])->GetImageSeqNo() == -1 ) ntot+=1.; |
1094 |
else ntot+=0.5; |
else ntot+=0.5; |
1095 |
} |
} |
1104 |
* Retrieves (if present) the image of the it-th "physical" track, sorted by the method GetNTracks(). |
* Retrieves (if present) the image of the it-th "physical" track, sorted by the method GetNTracks(). |
1105 |
* @param it Track number, ranging from 0 to GetNTracks(). |
* @param it Track number, ranging from 0 to GetNTracks(). |
1106 |
*/ |
*/ |
1107 |
/*TrkTrack *TrkLevel2::GetTrackImage(int it){ |
TrkTrack *TrkLevel2::GetTrackImage(int it){ |
1108 |
|
|
1109 |
if(it >= this->GetNTracks()){ |
if(it >= this->GetNTracks()){ |
1110 |
cout << "** TrkLevel2 ** Track "<< it << "does not exits! " << endl; |
cout << "** TrkLevel2 ** Track "<< it << "does not exits! " << endl; |
1112 |
return 0; |
return 0; |
1113 |
} |
} |
1114 |
|
|
1115 |
TClonesArray* sorted = GetTracks(); |
TRefArray* sorted = GetTracks(); //TEMPORANEO |
1116 |
TClonesArray &ts = *sorted; |
if(!sorted)return 0; |
1117 |
TrkTrack *track = (TrkTrack*)ts[it]; |
TrkTrack *track = (TrkTrack*)sorted->At(it); |
1118 |
// TrkTrack *track = (TrkTrack*)(*(this->GetTracks()))[it]; |
|
1119 |
|
if(!track->HasImage()){ |
|
if(!track->HasImage()){ |
|
1120 |
cout << "** TrkLevel2 ** Track "<< it << "does not have image! " << endl; |
cout << "** TrkLevel2 ** Track "<< it << "does not have image! " << endl; |
1121 |
return 0; |
return 0; |
1122 |
} |
} |
1123 |
|
if(!Track)return 0; |
1124 |
TrkTrack *image = (TrkTrack*)(*Track)[track->image]; |
TrkTrack *image = (TrkTrack*)(*Track)[track->image]; |
1125 |
|
|
1126 |
// GetTracks()->Delete(); ////TEMPORANEO |
sorted->Delete(); |
1127 |
sorted->Delete(); ////TEMPORANEO |
delete sorted; |
|
|
|
|
return image; |
|
|
|
|
|
}*/ |
|
|
TrkTrack *TrkLevel2::GetTrackImage(int it){ |
|
|
|
|
|
if(it >= this->GetNTracks()){ |
|
|
cout << "** TrkLevel2 ** Track "<< it << "does not exits! " << endl; |
|
|
cout << " Physical tracks GetNTracks() = "<< this->ntrk() << endl; |
|
|
return 0; |
|
|
} |
|
|
|
|
|
TRefArray* sorted = GetTracks(); //TEMPORANEO |
|
|
TrkTrack *track = (TrkTrack*)sorted->At(it); |
|
|
|
|
|
if(!track->HasImage()){ |
|
|
cout << "** TrkLevel2 ** Track "<< it << "does not have image! " << endl; |
|
|
return 0; |
|
|
} |
|
|
TrkTrack *image = (TrkTrack*)(*Track)[track->image]; |
|
1128 |
|
|
1129 |
sorted->Delete(); |
return image; |
|
|
|
|
return image; |
|
1130 |
|
|
1131 |
} |
} |
1132 |
//-------------------------------------- |
//-------------------------------------- |
1137 |
* Loads the magnetic field. |
* Loads the magnetic field. |
1138 |
* @param s Path of the magnetic-field files. |
* @param s Path of the magnetic-field files. |
1139 |
*/ |
*/ |
1140 |
void TrkLevel2::LoadField(TString s){ |
void TrkLevel2::LoadField(TString path){ |
1141 |
readb_(s.Data()); |
// |
1142 |
|
// strcpy(path_.path,path.Data()); |
1143 |
|
// path_.pathlen = path.Length(); |
1144 |
|
// path_.error = 0; |
1145 |
|
// readb_(); |
1146 |
|
|
1147 |
|
TrkParams::Set(path,1); |
1148 |
|
TrkParams::Load(1); |
1149 |
|
|
1150 |
|
// |
1151 |
}; |
}; |
1152 |
|
/** |
1153 |
|
* Get BY (kGauss) |
1154 |
|
* @param v (x,y,z) coordinates in cm |
1155 |
|
*/ |
1156 |
|
float TrkLevel2::GetBX(float* v){ |
1157 |
|
float b[3]; |
1158 |
|
gufld_(v,b); |
1159 |
|
return b[0]/10.; |
1160 |
|
} |
1161 |
|
/** |
1162 |
|
* Get BY (kGauss) |
1163 |
|
* @param v (x,y,z) coordinates in cm |
1164 |
|
*/ |
1165 |
|
float TrkLevel2::GetBY(float* v){ |
1166 |
|
float b[3]; |
1167 |
|
gufld_(v,b); |
1168 |
|
return b[1]/10.; |
1169 |
|
} |
1170 |
|
/** |
1171 |
|
* Get BY (kGauss) |
1172 |
|
* @param v (x,y,z) coordinates in cm |
1173 |
|
*/ |
1174 |
|
float TrkLevel2::GetBZ(float* v){ |
1175 |
|
float b[3]; |
1176 |
|
gufld_(v,b); |
1177 |
|
return b[2]/10.; |
1178 |
|
} |
1179 |
//-------------------------------------- |
//-------------------------------------- |
1180 |
// |
// |
1181 |
// |
// |
1283 |
npoint=i; |
npoint=i; |
1284 |
if(npoint != n)cout << "NB! Trajectory created with "<<npoint<<" points"<<endl; |
if(npoint != n)cout << "NB! Trajectory created with "<<npoint<<" points"<<endl; |
1285 |
} |
} |
1286 |
|
void Trajectory::Delete(){ |
1287 |
|
|
1288 |
|
if(x) delete [] x; |
1289 |
|
if(y) delete [] y; |
1290 |
|
if(z) delete [] z; |
1291 |
|
if(thx) delete [] thx; |
1292 |
|
if(thy) delete [] thy; |
1293 |
|
if(tl) delete [] tl; |
1294 |
|
|
1295 |
|
} |
1296 |
//-------------------------------------- |
//-------------------------------------- |
1297 |
// |
// |
1298 |
// |
// |
1331 |
|
|
1332 |
} |
} |
1333 |
|
|
1334 |
|
/** |
1335 |
|
* Evaluates the trajectory in the apparatus associated to the track. |
1336 |
|
* 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. |
1337 |
|
* @param t pointer to an object of the class Trajectory, |
1338 |
|
* which z coordinates should be previously initialized by calling the proper constructor ( Trajectory::Trajectory(int n, float* zin) ). |
1339 |
|
* @return error flag. |
1340 |
|
*/ |
1341 |
|
int Trajectory::DoTrack2(float* al){ |
1342 |
|
|
1343 |
|
double *dxout = new double[npoint]; |
1344 |
|
double *dyout = new double[npoint]; |
1345 |
|
double *dthxout = new double[npoint]; |
1346 |
|
double *dthyout = new double[npoint]; |
1347 |
|
double *dtlout = new double[npoint]; |
1348 |
|
double *dzin = new double[npoint]; |
1349 |
|
double dal[5]; |
1350 |
|
|
1351 |
|
int ifail = 0; |
1352 |
|
|
1353 |
|
for (int i=0; i<5; i++) dal[i] = (double)al[i]; |
1354 |
|
for (int i=0; i<npoint; i++) dzin[i] = (double)z[i]; |
1355 |
|
|
1356 |
|
TrkParams::Load(1); |
1357 |
|
if( !TrkParams::IsLoaded(1) ){ |
1358 |
|
cout << "int Trajectory::DoTrack2(float* al) --- ERROR --- m.field not loaded"<<endl; |
1359 |
|
return 0; |
1360 |
|
} |
1361 |
|
dotrack2_(&(npoint),dzin,dxout,dyout,dthxout,dthyout,dtlout,dal,&ifail); |
1362 |
|
|
1363 |
|
for (int i=0; i<npoint; i++){ |
1364 |
|
x[i] = (float)*dxout++; |
1365 |
|
y[i] = (float)*dyout++; |
1366 |
|
thx[i] = (float)*dthxout++; |
1367 |
|
thy[i] = (float)*dthyout++; |
1368 |
|
tl[i] = (float)*dtlout++; |
1369 |
|
} |
1370 |
|
|
1371 |
|
return ifail; |
1372 |
|
}; |
1373 |
|
|
1374 |
ClassImp(TrkLevel2); |
ClassImp(TrkLevel2); |
1375 |
ClassImp(TrkSinglet); |
ClassImp(TrkSinglet); |
1376 |
ClassImp(TrkTrack); |
ClassImp(TrkTrack); |