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; |
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++)coval[it1][it2] = 0; |
for(int it2=0;it2<5;it2++)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; |
38 |
ygood[ip] = 0; |
ygood[ip] = 0; |
39 |
xm[ip] = 0; |
xm[ip] = 0; |
40 |
ym[ip] = 0; |
ym[ip] = 0; |
41 |
zm[ip] = 0; |
zm[ip] = 0; |
42 |
resx[ip] = 0; |
resx[ip] = 0; |
43 |
resy[ip] = 0; |
resy[ip] = 0; |
44 |
xv[ip] = 0; |
xv[ip] = 0; |
45 |
yv[ip] = 0; |
yv[ip] = 0; |
46 |
zv[ip] = 0; |
zv[ip] = 0; |
47 |
axv[ip] = 0; |
axv[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 |
// clx[ip] = 0; |
}; |
52 |
// cly[ip] = 0; |
clx = 0; |
53 |
}; |
cly = 0; |
54 |
clx = new TRefArray(6,0); |
// clx = new TRefArray(6,0); //forse causa memory leak??? |
55 |
cly = new TRefArray(6,0); |
// 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; |
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++)coval[it1][it2] = t.coval[it1][it2]; |
for(int it2=0;it2<5;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]; |
72 |
ygood[ip] = t.ygood[ip]; |
ygood[ip] = t.ygood[ip]; |
73 |
xm[ip] = t.xm[ip]; |
xm[ip] = t.xm[ip]; |
74 |
ym[ip] = t.ym[ip]; |
ym[ip] = t.ym[ip]; |
75 |
zm[ip] = t.zm[ip]; |
zm[ip] = t.zm[ip]; |
76 |
resx[ip] = t.resx[ip]; |
resx[ip] = t.resx[ip]; |
77 |
resy[ip] = t.resy[ip]; |
resy[ip] = t.resy[ip]; |
78 |
xv[ip] = t.xv[ip]; |
xv[ip] = t.xv[ip]; |
79 |
yv[ip] = t.yv[ip]; |
yv[ip] = t.yv[ip]; |
80 |
zv[ip] = t.zv[ip]; |
zv[ip] = t.zv[ip]; |
81 |
axv[ip] = t.axv[ip]; |
axv[ip] = t.axv[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 |
// clx[ip] = 0;//<<<<pointer |
}; |
86 |
// cly[ip] = 0;//<<<<pointer |
clx = 0; |
87 |
}; |
cly = 0; |
88 |
clx = new TRefArray(*(t.clx)); |
if(t.clx)clx = new TRefArray(*(t.clx)); |
89 |
cly = new TRefArray(*(t.cly)); |
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 |
|
// |
127 |
|
// |
128 |
|
//-------------------------------------- |
129 |
/** |
/** |
130 |
* Evaluates the trajectory in the apparatus associated to the track. |
* Evaluates the trajectory in the apparatus associated to the track. |
131 |
* 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. |
* 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. |
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++){ |
235 |
// |
// |
236 |
Float_t TrkTrack::GetDEDX(){ |
Float_t TrkTrack::GetDEDX(){ |
237 |
Float_t dedx=0; |
Float_t dedx=0; |
238 |
for(Int_t i=0; i<6; i++)dedx+=dedx_x[i]*xgood[i]+dedx_y[i]*ygood[i]; |
// for(Int_t i=0; i<6; i++)dedx+=dedx_x[i]*xgood[i]+dedx_y[i]*ygood[i]; |
239 |
|
for(Int_t i=0; i<6; i++)dedx+=dedx_x[i]*XGood(i)+dedx_y[i]*YGood(i); |
240 |
dedx = dedx/(this->GetNX()+this->GetNY()); |
dedx = dedx/(this->GetNX()+this->GetNY()); |
241 |
return dedx; |
return dedx; |
242 |
}; |
}; |
247 |
//-------------------------------------- |
//-------------------------------------- |
248 |
void TrkTrack::Dump(){ |
void TrkTrack::Dump(){ |
249 |
cout << endl << "========== Track " ; |
cout << endl << "========== Track " ; |
250 |
cout << endl << "seq. n. : "<< seqno; |
cout << endl << "seq. n. : "<< seqno; |
251 |
cout << endl << "image n. : "<< image; |
cout << endl << "image n. : "<< image; |
252 |
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] << " "; |
253 |
cout << endl << "chi^2 : "<< chi2; |
cout << endl << "chi^2 : "<< chi2; |
254 |
cout << endl << "n.step : "<< nstep; |
cout << endl << "n.step : "<< nstep; |
255 |
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) ; |
256 |
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) ; |
257 |
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] << " "; |
258 |
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] << " "; |
259 |
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] << " "; |
260 |
|
cout << endl << "xv : "; for(int i=0; i<6; i++)cout << xv[i] << " "; |
261 |
|
cout << endl << "yv : "; for(int i=0; i<6; i++)cout << yv[i] << " "; |
262 |
|
cout << endl << "zv : "; for(int i=0; i<6; i++)cout << zv[i] << " "; |
263 |
|
cout << endl << "resx : "; for(int i=0; i<6; i++)cout << resx[i] << " "; |
264 |
|
cout << endl << "resy : "; for(int i=0; i<6; i++)cout << resy[i] << " "; |
265 |
|
cout << endl << "coval : "; for(int i=0; i<5; i++)cout << coval[0][i]<<" "; |
266 |
|
cout << endl << " "; for(int i=0; i<5; i++)cout << coval[1][i]<<" "; |
267 |
|
cout << endl << " "; for(int i=0; i<5; i++)cout << coval[2][i]<<" "; |
268 |
|
cout << endl << " "; for(int i=0; i<5; i++)cout << coval[3][i]<<" "; |
269 |
|
cout << endl << " "; for(int i=0; i<5; i++)cout << coval[4][i]<<" "; |
270 |
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] << " "; |
271 |
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] << " "; |
272 |
|
cout << endl; |
273 |
|
} |
274 |
|
/** |
275 |
|
* Set the TrkTrack position measurements |
276 |
|
*/ |
277 |
|
void TrkTrack::SetMeasure(double *xmeas, double *ymeas, double *zmeas){ |
278 |
|
for(int i=0; i<6; i++) xm[i]=*xmeas++; |
279 |
|
for(int i=0; i<6; i++) ym[i]=*ymeas++; |
280 |
|
for(int i=0; i<6; i++) zm[i]=*zmeas++; |
281 |
|
} |
282 |
|
/** |
283 |
|
* Set the TrkTrack position resolution |
284 |
|
*/ |
285 |
|
void TrkTrack::SetResolution(double *rx, double *ry){ |
286 |
|
for(int i=0; i<6; i++) resx[i]=*rx++; |
287 |
|
for(int i=0; i<6; i++) resy[i]=*ry++; |
288 |
|
} |
289 |
|
/** |
290 |
|
* Set the TrkTrack good measurement |
291 |
|
*/ |
292 |
|
void TrkTrack::SetGood(int *xg, int *yg){ |
293 |
|
// NB! si perdera` l'informazione sul numero del cluster |
294 |
|
for(int i=0; i<6; i++) xgood[i]=*xg++; |
295 |
|
for(int i=0; i<6; i++) ygood[i]=*yg++; |
296 |
|
} |
297 |
|
|
298 |
|
/** |
299 |
|
* Load the magnetic field |
300 |
|
*/ |
301 |
|
void TrkTrack::LoadField(TString path){ |
302 |
|
|
303 |
|
// strcpy(path_.path,path.Data()); |
304 |
|
// path_.pathlen = path.Length(); |
305 |
|
// path_.error = 0; |
306 |
|
// readb_(); |
307 |
|
|
308 |
|
TrkParams::Set(path,1); |
309 |
|
TrkParams::Load(1); |
310 |
|
|
311 |
|
}; |
312 |
|
|
313 |
|
|
314 |
|
/** |
315 |
|
* Method to fill minimization-routine common |
316 |
|
*/ |
317 |
|
void TrkTrack::FillMiniStruct(cMini2track& track){ |
318 |
|
|
319 |
|
for(int i=0; i<6; i++){ |
320 |
|
|
321 |
|
// track.xgood[i]=xgood[i]; |
322 |
|
// track.ygood[i]=ygood[i]; |
323 |
|
track.xgood[i]=XGood(i); |
324 |
|
track.ygood[i]=YGood(i); |
325 |
|
|
326 |
|
track.xm[i]=xm[i]; |
327 |
|
track.ym[i]=ym[i]; |
328 |
|
track.zm[i]=zm[i]; |
329 |
|
|
330 |
|
// --- temporaneo ---------------------------- |
331 |
|
// andrebbe inserita la dimensione del sensore |
332 |
|
float segment = 100.; |
333 |
|
track.xm_a[i]=xm[i]; |
334 |
|
track.xm_b[i]=xm[i]; |
335 |
|
track.ym_a[i]=ym[i]; |
336 |
|
track.ym_b[i]=ym[i]; |
337 |
|
if( XGood(i) && !YGood(i) ){ |
338 |
|
track.ym_a[i] = track.ym_a[i]+segment; |
339 |
|
track.ym_b[i] = track.ym_b[i]-segment; |
340 |
|
}else if( !XGood(i) && YGood(i)){ |
341 |
|
track.xm_a[i] = track.xm_a[i]+segment; |
342 |
|
track.xm_b[i] = track.xm_b[i]-segment; |
343 |
|
} |
344 |
|
// --- temporaneo ---------------------------- |
345 |
|
|
346 |
|
track.resx[i]=resx[i]; |
347 |
|
track.resy[i]=resy[i]; |
348 |
|
} |
349 |
|
|
350 |
|
for(int i=0; i<5; i++) track.al[i]=al[i]; |
351 |
|
track.zini = 23.5; |
352 |
|
// ZINI = 23.5 !!! it should be the same parameter in all codes |
353 |
|
|
354 |
|
} |
355 |
|
/** |
356 |
|
* Method to set values from minimization-routine common |
357 |
|
*/ |
358 |
|
void TrkTrack::SetFromMiniStruct(cMini2track *track){ |
359 |
|
|
360 |
|
for(int i=0; i<5; i++) { |
361 |
|
al[i]=track->al[i]; |
362 |
|
for(int j=0; j<5; j++) coval[i][j]=track->cov[i][j]; |
363 |
|
} |
364 |
|
chi2 = track->chi2; |
365 |
|
nstep = track->nstep; |
366 |
|
for(int i=0; i<6; i++){ |
367 |
|
xv[i] = track->xv[i]; |
368 |
|
yv[i] = track->yv[i]; |
369 |
|
zv[i] = track->zv[i]; |
370 |
|
xm[i] = track->xm[i]; |
371 |
|
ym[i] = track->ym[i]; |
372 |
|
zm[i] = track->zm[i]; |
373 |
|
axv[i] = track->axv[i]; |
374 |
|
ayv[i] = track->ayv[i]; |
375 |
|
} |
376 |
|
|
377 |
|
} |
378 |
|
/** |
379 |
|
* Tracking method. It calls F77 mini routine. |
380 |
|
*/ |
381 |
|
void TrkTrack::Fit(double pfixed, int& fail, int iprint){ |
382 |
|
|
383 |
|
float al_ini[] = {0.,0.,0.,0.,0.}; |
384 |
|
|
385 |
|
extern cMini2track track_; |
386 |
|
fail = 0; |
387 |
|
FillMiniStruct(track_); |
388 |
|
|
389 |
|
// if fit variables have been reset, evaluate the initial guess |
390 |
|
if(al[0]==-9999.&&al[1]==-9999.&&al[2]==-9999.&&al[3]==-9999.&&al[4]==-9999.)guess_(); |
391 |
|
|
392 |
|
// --------------------- free momentum |
393 |
|
if(pfixed==0.) { |
394 |
|
track_.pfixed=0.; |
395 |
|
} |
396 |
|
// --------------------- fixed momentum |
397 |
|
if(pfixed!=0.) { |
398 |
|
al[4]=1./pfixed; |
399 |
|
track_.pfixed=pfixed; |
400 |
|
} |
401 |
|
|
402 |
|
// store temporarily the initial guess |
403 |
|
for(int i=0; i<5; i++) al_ini[i]=track_.al[i]; |
404 |
|
|
405 |
|
// ------------------------------------------ |
406 |
|
// call mini routine |
407 |
|
TrkParams::Load(1); |
408 |
|
if( !TrkParams::IsLoaded(1) ){ |
409 |
|
cout << "void TrkTrack::Fit(double pfixed, int& fail, int iprint) --- ERROR --- m.field not loaded"<<endl; |
410 |
|
return; |
411 |
|
} |
412 |
|
int istep=0; |
413 |
|
int ifail=0; |
414 |
|
mini2_(&istep,&ifail, &iprint); |
415 |
|
if(ifail!=0) { |
416 |
|
if(iprint)cout << "ERROR: ifail= " << ifail << endl; |
417 |
|
fail = 1; |
418 |
|
} |
419 |
|
// ------------------------------------------ |
420 |
|
|
421 |
|
SetFromMiniStruct(&track_); |
422 |
|
// cout << endl << "eta ===> " << track_.al[4] << endl; |
423 |
|
|
424 |
|
// for(int i=0; i<5; i++) al[i]=track_.al[i]; |
425 |
|
// chi2=track_.chi2; |
426 |
|
// nstep=track_.nstep; |
427 |
|
// for(int i=0; i<6; i++) xv[i]=track_.xv[i]; |
428 |
|
// for(int i=0; i<6; i++) yv[i]=track_.yv[i]; |
429 |
|
// for(int i=0; i<6; i++) zv[i]=track_.zv[i]; |
430 |
|
// for(int i=0; i<6; i++) axv[i]=track_.axv[i]; |
431 |
|
// for(int i=0; i<6; i++) ayv[i]=track_.ayv[i]; |
432 |
|
// for(int i=0; i<5; i++) { |
433 |
|
// for(int j=0; j<5; j++) coval[i][j]=track_.cov[i][j]; |
434 |
|
// } |
435 |
|
|
436 |
|
if(fail){ |
437 |
|
if(iprint)cout << " >>>> fit failed >>>> drawing initial par"<<endl; |
438 |
|
for(int i=0; i<5; i++) al[i]=al_ini[i]; |
439 |
|
} |
440 |
|
|
441 |
|
}; |
442 |
|
/* |
443 |
|
* Reset the fit parameters |
444 |
|
*/ |
445 |
|
void TrkTrack::FitReset(){ |
446 |
|
for(int i=0; i<5; i++) al[i]=-9999.; |
447 |
|
chi2=0.; |
448 |
|
nstep=0; |
449 |
|
for(int i=0; i<6; i++) xv[i]=0.; |
450 |
|
for(int i=0; i<6; i++) yv[i]=0.; |
451 |
|
for(int i=0; i<6; i++) zv[i]=0.; |
452 |
|
for(int i=0; i<6; i++) axv[i]=0.; |
453 |
|
for(int i=0; i<6; i++) ayv[i]=0.; |
454 |
|
for(int i=0; i<5; i++) { |
455 |
|
for(int j=0; j<5; j++) coval[i][j]=0.; |
456 |
|
} |
457 |
|
} |
458 |
|
/* |
459 |
|
* Set the tracking mode |
460 |
|
*/ |
461 |
|
void TrkTrack::SetTrackingMode(int trackmode){ |
462 |
|
extern cMini2track track_; |
463 |
|
track_.trackmode = trackmode; |
464 |
|
} |
465 |
|
/* |
466 |
|
* Set the factor scale for tracking precision |
467 |
|
*/ |
468 |
|
void TrkTrack::SetPrecisionFactor(double fact){ |
469 |
|
extern cMini2track track_; |
470 |
|
track_.fact = fact; |
471 |
|
} |
472 |
|
/* |
473 |
|
* Set the factor scale for tracking precision |
474 |
|
*/ |
475 |
|
void TrkTrack::SetStepMin(int istepmin){ |
476 |
|
extern cMini2track track_; |
477 |
|
track_.istepmin = istepmin; |
478 |
} |
} |
479 |
|
|
480 |
|
|
481 |
|
/* |
482 |
|
* Method to retrieve the X-view clusters associated to the track. |
483 |
|
* @param ip Tracker plane (0-5) |
484 |
|
*/ |
485 |
|
TrkCluster *TrkTrack::GetClusterX(int ip){ |
486 |
|
cout << " TrkCluster *TrkTrack::GetClusterX(int ip) -- momentaneamente fuori servizio --"<< endl; |
487 |
|
if(!clx)return NULL; |
488 |
|
TrkCluster *pt = (TrkCluster*)(clx->At(ip)); |
489 |
|
return pt; |
490 |
|
}; |
491 |
|
/* |
492 |
|
* Method to retrieve the Y-view clusters associated to the track. |
493 |
|
* @param ip Tracker plane (0-5) |
494 |
|
*/ |
495 |
|
TrkCluster *TrkTrack::GetClusterY(int ip){ |
496 |
|
cout << " TrkCluster *TrkTrack::GetClusterY(int ip) -- momentaneamente fuori servizio --"<< endl; |
497 |
|
if(!cly)return NULL; |
498 |
|
TrkCluster *pt = (TrkCluster*)(cly->At(ip)); |
499 |
|
return pt; |
500 |
|
}; |
501 |
|
|
502 |
|
|
503 |
//-------------------------------------- |
//-------------------------------------- |
504 |
// |
// |
505 |
// |
// |
506 |
//-------------------------------------- |
//-------------------------------------- |
507 |
void TrkTrack::Clear(){ |
void TrkTrack::Clear(){ |
508 |
seqno = -1; |
// cout << "TrkTrack::Clear()"<<endl; |
509 |
image = -1; |
seqno = -1; |
510 |
chi2 = 0; |
image = -1; |
511 |
nstep = 0; |
chi2 = 0; |
512 |
for(int it1=0;it1<5;it1++){ |
nstep = 0; |
513 |
al[it1] = 0; |
for(int it1=0;it1<5;it1++){ |
514 |
for(int it2=0;it2<5;it2++)coval[it1][it2] = 0; |
al[it1] = 0; |
515 |
}; |
for(int it2=0;it2<5;it2++)coval[it1][it2] = 0; |
516 |
for(int ip=0;ip<6;ip++){ |
}; |
517 |
xgood[ip] = 0; |
for(int ip=0;ip<6;ip++){ |
518 |
ygood[ip] = 0; |
xgood[ip] = 0; |
519 |
xm[ip] = 0; |
ygood[ip] = 0; |
520 |
ym[ip] = 0; |
xm[ip] = 0; |
521 |
zm[ip] = 0; |
ym[ip] = 0; |
522 |
resx[ip] = 0; |
zm[ip] = 0; |
523 |
resy[ip] = 0; |
resx[ip] = 0; |
524 |
xv[ip] = 0; |
resy[ip] = 0; |
525 |
yv[ip] = 0; |
xv[ip] = 0; |
526 |
zv[ip] = 0; |
yv[ip] = 0; |
527 |
axv[ip] = 0; |
zv[ip] = 0; |
528 |
ayv[ip] = 0; |
axv[ip] = 0; |
529 |
dedx_x[ip] = 0; |
ayv[ip] = 0; |
530 |
dedx_y[ip] = 0; |
dedx_x[ip] = 0; |
531 |
// clx[ip] = 0; |
dedx_y[ip] = 0; |
532 |
// cly[ip] = 0; |
|
533 |
}; |
}; |
534 |
clx->Clear(); |
if(clx)clx->Clear(); |
535 |
cly->Clear(); |
if(cly)cly->Clear(); |
536 |
|
}; |
537 |
|
//-------------------------------------- |
538 |
|
// |
539 |
|
// |
540 |
|
//-------------------------------------- |
541 |
|
void TrkTrack::Delete(){ |
542 |
|
// cout << "TrkTrack::Delete()"<<endl; |
543 |
|
// Clear(); |
544 |
|
if(clx)delete clx; |
545 |
|
if(cly)delete cly; |
546 |
}; |
}; |
547 |
//-------------------------------------- |
//-------------------------------------- |
548 |
// |
// |
554 |
// |
// |
555 |
//-------------------------------------- |
//-------------------------------------- |
556 |
TrkSinglet::TrkSinglet(){ |
TrkSinglet::TrkSinglet(){ |
557 |
|
// cout << "TrkSinglet::TrkSinglet() " << GetUniqueID()<<endl; |
558 |
plane = 0; |
plane = 0; |
559 |
coord[0] = 0; |
coord[0] = 0; |
560 |
coord[1] = 0; |
coord[1] = 0; |
561 |
sgnl = 0; |
sgnl = 0; |
562 |
cls = 0; |
// cls = 0; |
563 |
}; |
}; |
564 |
//-------------------------------------- |
//-------------------------------------- |
565 |
// |
// |
566 |
// |
// |
567 |
//-------------------------------------- |
//-------------------------------------- |
568 |
TrkSinglet::TrkSinglet(const TrkSinglet& s){ |
TrkSinglet::TrkSinglet(const TrkSinglet& s){ |
569 |
|
// cout << "TrkSinglet::TrkSinglet(const TrkSinglet& s) " << GetUniqueID()<<endl; |
570 |
plane = s.plane; |
plane = s.plane; |
571 |
coord[0] = s.coord[0]; |
coord[0] = s.coord[0]; |
572 |
coord[1] = s.coord[1]; |
coord[1] = s.coord[1]; |
573 |
sgnl = s.sgnl; |
sgnl = s.sgnl; |
574 |
// cls = 0;//<<<<pointer |
// cls = 0;//<<<<pointer |
575 |
cls = TRef(s.cls); |
cls = TRef(s.cls); |
576 |
}; |
}; |
577 |
//-------------------------------------- |
//-------------------------------------- |
578 |
// |
// |
589 |
// |
// |
590 |
// |
// |
591 |
//-------------------------------------- |
//-------------------------------------- |
592 |
|
void TrkSinglet::Clear(){ |
593 |
|
// cout << "TrkSinglet::Clear() " << GetUniqueID()<<endl; |
594 |
|
// cls=0; |
595 |
|
plane=-1; |
596 |
|
coord[0]=-999; |
597 |
|
coord[1]=-999; |
598 |
|
sgnl=0; |
599 |
|
|
600 |
|
} |
601 |
|
//-------------------------------------- |
602 |
|
// |
603 |
|
// |
604 |
|
//-------------------------------------- |
605 |
TrkLevel2::TrkLevel2(){ |
TrkLevel2::TrkLevel2(){ |
606 |
// good2 = -1; |
// cout <<"TrkLevel2::TrkLevel2()"<<endl; |
607 |
for(Int_t i=0; i<12 ; i++){ |
for(Int_t i=0; i<12 ; i++){ |
|
// crc[i] = -1; |
|
608 |
good[i] = -1; |
good[i] = -1; |
609 |
}; |
}; |
610 |
Track = new TClonesArray("TrkTrack"); |
// okkio!! memory-leak |
611 |
SingletX = new TClonesArray("TrkSinglet"); |
// Track = new TClonesArray("TrkTrack"); |
612 |
SingletY = new TClonesArray("TrkSinglet"); |
// SingletX = new TClonesArray("TrkSinglet"); |
613 |
|
// SingletY = new TClonesArray("TrkSinglet"); |
614 |
|
Track = 0; |
615 |
|
SingletX = 0; |
616 |
|
SingletY = 0; |
617 |
|
|
618 |
// PhysicalTrack = new TClonesArray("TrkTrack"); |
} |
619 |
//sostituire con TRefArray... appena ho capito come si usa |
//-------------------------------------- |
620 |
|
// |
621 |
|
// |
622 |
|
//-------------------------------------- |
623 |
|
void TrkLevel2::Set(){ |
624 |
|
if(!Track)Track = new TClonesArray("TrkTrack"); |
625 |
|
if(!SingletX)SingletX = new TClonesArray("TrkSinglet"); |
626 |
|
if(!SingletY)SingletY = new TClonesArray("TrkSinglet"); |
627 |
} |
} |
628 |
//-------------------------------------- |
//-------------------------------------- |
629 |
// |
// |
631 |
//-------------------------------------- |
//-------------------------------------- |
632 |
void TrkLevel2::Dump(){ |
void TrkLevel2::Dump(){ |
633 |
|
|
|
TClonesArray &t = *Track; |
|
|
TClonesArray &sx = *SingletX; |
|
|
TClonesArray &sy = *SingletY; |
|
634 |
// |
// |
635 |
cout << endl << endl << "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"; |
cout << endl << endl << "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"; |
636 |
cout << endl << "good : "; for(int i=0; i<12; i++) cout << good[i]<<" "; |
cout << endl << "good : "; for(int i=0; i<12; i++) cout << good[i]<<" "; |
637 |
cout << endl << "ntrk() : " << this->ntrk() ; |
cout << endl << "ntrk() : " << this->ntrk() ; |
638 |
cout << endl << "nclsx() : " << this->nclsx(); |
cout << endl << "nclsx() : " << this->nclsx(); |
639 |
cout << endl << "nclsy() : " << this->nclsy(); |
cout << endl << "nclsy() : " << this->nclsy(); |
640 |
for(int i=0; i<this->ntrk(); i++) ((TrkTrack *)t[i])->Dump(); |
// TClonesArray &t = *Track; |
641 |
for(int i=0; i<this->nclsx(); i++) ((TrkSinglet *)sx[i])->Dump(); |
// TClonesArray &sx = *SingletX; |
642 |
for(int i=0; i<this->nclsy(); i++) ((TrkSinglet *)sy[i])->Dump(); |
// TClonesArray &sy = *SingletY; |
643 |
|
// for(int i=0; i<ntrk(); i++) ((TrkTrack *)t[i])->Dump(); |
644 |
|
// for(int i=0; i<nclsx(); i++) ((TrkSinglet *)sx[i])->Dump(); |
645 |
|
// for(int i=0; i<nclsy(); i++) ((TrkSinglet *)sy[i])->Dump(); |
646 |
|
if(Track){ |
647 |
|
TClonesArray &t = *Track; |
648 |
|
for(int i=0; i<ntrk(); i++) ((TrkTrack *)t[i])->Dump(); |
649 |
|
} |
650 |
|
if(SingletX){ |
651 |
|
TClonesArray &sx = *SingletX; |
652 |
|
for(int i=0; i<nclsx(); i++) ((TrkSinglet *)sx[i])->Dump(); |
653 |
|
} |
654 |
|
if(SingletY){ |
655 |
|
TClonesArray &sy = *SingletY; |
656 |
|
for(int i=0; i<nclsy(); i++) ((TrkSinglet *)sy[i])->Dump(); |
657 |
|
} |
658 |
} |
} |
659 |
//-------------------------------------- |
//-------------------------------------- |
660 |
// |
// |
663 |
/** |
/** |
664 |
* 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). |
665 |
*/ |
*/ |
666 |
void TrkLevel2::SetFromLevel2Struct(cTrkLevel2 *l2){ |
// void TrkLevel2::SetFromLevel2Struct(cTrkLevel2 *l2){ |
|
|
|
|
// temporary objects: |
|
|
TrkSinglet* t_singlet = new TrkSinglet(); |
|
|
TrkTrack* t_track = new TrkTrack(); |
|
667 |
|
|
668 |
// **** general variables **** |
// // temporary objects: |
669 |
// good2 = l2->good2; |
// TrkSinglet* t_singlet = new TrkSinglet(); |
670 |
for(Int_t i=0; i<12 ; i++){ |
// TrkTrack* t_track = new TrkTrack(); |
671 |
// crc[i] = l2->crc[i]; |
|
672 |
good[i] = l2->good[i]; |
// // **** general variables **** |
673 |
}; |
// // good2 = l2->good2; |
674 |
// *** TRACKS *** |
// for(Int_t i=0; i<12 ; i++){ |
675 |
TClonesArray &t = *Track; |
// // crc[i] = l2->crc[i]; |
676 |
for(int i=0; i<l2->ntrk; i++){ |
// good[i] = l2->good[i]; |
677 |
t_track->seqno = i;// NBNBNBNB deve sempre essere = i |
// }; |
678 |
t_track->image = l2->image[i]-1; |
// // *** TRACKS *** |
679 |
// cout << "track "<<i<<t_track->seqno << t_track->image<<endl; |
// if(!Track) Track = new TClonesArray("TrkTrack"); |
680 |
t_track->chi2 = l2->chi2_nt[i]; |
// TClonesArray &t = *Track; |
681 |
t_track->nstep = l2->nstep_nt[i]; |
// for(int i=0; i<l2->ntrk; i++){ |
682 |
for(int it1=0;it1<5;it1++){ |
// t_track->seqno = i;// NBNBNBNB deve sempre essere = i |
683 |
t_track->al[it1] = l2->al_nt[i][it1]; |
// t_track->image = l2->image[i]-1; |
684 |
for(int it2=0;it2<5;it2++) |
// // cout << "track "<<i<<t_track->seqno << t_track->image<<endl; |
685 |
t_track->coval[it1][it2] = l2->coval[i][it2][it1]; |
// t_track->chi2 = l2->chi2_nt[i]; |
686 |
}; |
// t_track->nstep = l2->nstep_nt[i]; |
687 |
for(int ip=0;ip<6;ip++){ |
// for(int it1=0;it1<5;it1++){ |
688 |
t_track->xgood[ip] = l2->xgood_nt[i][ip]; |
// t_track->al[it1] = l2->al_nt[i][it1]; |
689 |
t_track->ygood[ip] = l2->ygood_nt[i][ip]; |
// for(int it2=0;it2<5;it2++) |
690 |
t_track->xm[ip] = l2->xm_nt[i][ip]; |
// t_track->coval[it1][it2] = l2->coval[i][it2][it1]; |
691 |
t_track->ym[ip] = l2->ym_nt[i][ip]; |
// }; |
692 |
t_track->zm[ip] = l2->zm_nt[i][ip]; |
// for(int ip=0;ip<6;ip++){ |
693 |
t_track->resx[ip] = l2->resx_nt[i][ip]; |
// t_track->xgood[ip] = l2->xgood_nt[i][ip]; |
694 |
t_track->resy[ip] = l2->resy_nt[i][ip]; |
// t_track->ygood[ip] = l2->ygood_nt[i][ip]; |
695 |
t_track->xv[ip] = l2->xv_nt[i][ip]; |
// t_track->xm[ip] = l2->xm_nt[i][ip]; |
696 |
t_track->yv[ip] = l2->yv_nt[i][ip]; |
// t_track->ym[ip] = l2->ym_nt[i][ip]; |
697 |
t_track->zv[ip] = l2->zv_nt[i][ip]; |
// t_track->zm[ip] = l2->zm_nt[i][ip]; |
698 |
t_track->axv[ip] = l2->axv_nt[i][ip]; |
// t_track->resx[ip] = l2->resx_nt[i][ip]; |
699 |
t_track->ayv[ip] = l2->ayv_nt[i][ip]; |
// t_track->resy[ip] = l2->resy_nt[i][ip]; |
700 |
t_track->dedx_x[ip] = l2->dedx_x[i][ip]; |
// t_track->xv[ip] = l2->xv_nt[i][ip]; |
701 |
t_track->dedx_y[ip] = l2->dedx_y[i][ip]; |
// t_track->yv[ip] = l2->yv_nt[i][ip]; |
702 |
// t_track->clx[ip] = 0; |
// t_track->zv[ip] = l2->zv_nt[i][ip]; |
703 |
// t_track->cly[ip] = 0; |
// t_track->axv[ip] = l2->axv_nt[i][ip]; |
704 |
}; |
// t_track->ayv[ip] = l2->ayv_nt[i][ip]; |
705 |
new(t[i]) TrkTrack(*t_track); |
// t_track->dedx_x[ip] = l2->dedx_x[i][ip]; |
706 |
t_track->Clear(); |
// t_track->dedx_y[ip] = l2->dedx_y[i][ip]; |
707 |
}; |
// // t_track->clx[ip] = 0; |
708 |
// *** SINGLETS *** |
// // t_track->cly[ip] = 0; |
709 |
TClonesArray &sx = *SingletX; |
// }; |
710 |
for(int i=0; i<l2->nclsx; i++){ |
// new(t[i]) TrkTrack(*t_track); |
711 |
t_singlet->plane = l2->planex[i]; |
// t_track->Clear(); |
712 |
t_singlet->coord[0] = l2->xs[i][0]; |
// }; |
713 |
t_singlet->coord[1] = l2->xs[i][1]; |
// // *** SINGLETS *** |
714 |
t_singlet->sgnl = l2->signlxs[i]; |
// if(!SingletX)SingletX = new TClonesArray("TrkSinglet"); |
715 |
// t_singlet->cls = 0; |
// TClonesArray &sx = *SingletX; |
716 |
new(sx[i]) TrkSinglet(*t_singlet); |
// for(int i=0; i<l2->nclsx; i++){ |
717 |
t_singlet->Clear(); |
// t_singlet->plane = l2->planex[i]; |
718 |
} |
// t_singlet->coord[0] = l2->xs[i][0]; |
719 |
TClonesArray &sy = *SingletY; |
// t_singlet->coord[1] = l2->xs[i][1]; |
720 |
for(int i=0; i<l2->nclsy; i++){ |
// t_singlet->sgnl = l2->signlxs[i]; |
721 |
t_singlet->plane = l2->planey[i]; |
// // t_singlet->cls = 0; |
722 |
t_singlet->coord[0] = l2->ys[i][0]; |
// new(sx[i]) TrkSinglet(*t_singlet); |
723 |
t_singlet->coord[1] = l2->ys[i][1]; |
// t_singlet->Clear(); |
724 |
t_singlet->sgnl = l2->signlys[i]; |
// } |
725 |
// t_singlet->cls = 0; |
// if(!SingletY)SingletY = new TClonesArray("TrkSinglet"); |
726 |
new(sy[i]) TrkSinglet(*t_singlet); |
// TClonesArray &sy = *SingletY; |
727 |
t_singlet->Clear(); |
// for(int i=0; i<l2->nclsy; i++){ |
728 |
}; |
// t_singlet->plane = l2->planey[i]; |
729 |
|
// t_singlet->coord[0] = l2->ys[i][0]; |
730 |
|
// t_singlet->coord[1] = l2->ys[i][1]; |
731 |
|
// t_singlet->sgnl = l2->signlys[i]; |
732 |
|
// // t_singlet->cls = 0; |
733 |
|
// new(sy[i]) TrkSinglet(*t_singlet); |
734 |
|
// t_singlet->Clear(); |
735 |
|
// }; |
736 |
|
|
737 |
delete t_track; |
// delete t_track; |
738 |
delete t_singlet; |
// delete t_singlet; |
739 |
} |
// } |
740 |
//-------------------------------------- |
//-------------------------------------- |
741 |
// |
// |
742 |
// |
// |
743 |
//-------------------------------------- |
//-------------------------------------- |
744 |
/** |
/** |
745 |
* 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). |
746 |
* Ref to Level1 data (clusters) is also set. |
* Ref to Level1 data (clusters) is also set. If l1==NULL no references are set. |
747 |
|
* (NB It make sense to set references only if events are stored in a tree that contains also the Level1 branch) |
748 |
*/ |
*/ |
749 |
void TrkLevel2::SetFromLevel2Struct(cTrkLevel2 *l2, TrkLevel1 *l1){ |
void TrkLevel2::SetFromLevel2Struct(cTrkLevel2 *l2, TrkLevel1 *l1){ |
750 |
|
|
751 |
|
// cout << "void TrkLevel2::SetFromLevel2Struct(cTrkLevel2 *l2, TrkLevel1 *l1)"<<endl; |
752 |
|
Clear(); |
753 |
// temporary objects: |
// temporary objects: |
754 |
TrkSinglet* t_singlet = new TrkSinglet(); |
TrkSinglet* t_singlet = new TrkSinglet(); |
755 |
TrkTrack* t_track = new TrkTrack(); |
TrkTrack* t_track = new TrkTrack(); |
756 |
// general variables |
|
757 |
// good2 = l2->good2; |
// ----------------- |
758 |
for(Int_t i=0; i<12 ; i++){ |
// general variables |
759 |
// crc[i] = l2->crc[i]; |
// ----------------- |
760 |
good[i] = l2->good[i]; |
for(Int_t i=0; i<12 ; i++){ |
761 |
}; |
good[i] = l2->good[i]; |
762 |
// *** TRACKS *** |
}; |
763 |
TClonesArray &t = *Track; |
// -------------- |
764 |
for(int i=0; i<l2->ntrk; i++){ |
// *** TRACKS *** |
765 |
t_track->seqno = i;// NBNBNBNB deve sempre essere = i |
// -------------- |
766 |
t_track->image = l2->image[i]-1; |
if(!Track) Track = new TClonesArray("TrkTrack"); |
767 |
// cout << "track "<<i<<t_track->seqno << t_track->image<<endl; |
TClonesArray &t = *Track; |
768 |
t_track->chi2 = l2->chi2_nt[i]; |
//----------------------------------------------------- |
769 |
t_track->nstep = l2->nstep_nt[i]; |
if( l1 && !t_track->clx )t_track->clx = new TRefArray(6,0); |
770 |
for(int it1=0;it1<5;it1++){ |
if( l1 && !t_track->cly )t_track->cly = new TRefArray(6,0); |
771 |
t_track->al[it1] = l2->al_nt[i][it1]; |
//----------------------------------------------------- |
772 |
for(int it2=0;it2<5;it2++) |
for(int i=0; i<l2->ntrk; i++){ |
773 |
t_track->coval[it1][it2] = l2->coval[i][it2][it1]; |
// cout <<" TRACK "<<i<<" ------------------ "<<endl; |
774 |
}; |
t_track->seqno = i;// NBNBNBNB deve sempre essere = i |
775 |
for(int ip=0;ip<6;ip++){ |
t_track->image = l2->image[i]-1; |
776 |
t_track->xgood[ip] = l2->xgood_nt[i][ip]; |
t_track->chi2 = l2->chi2_nt[i]; |
777 |
t_track->ygood[ip] = l2->ygood_nt[i][ip]; |
t_track->nstep = l2->nstep_nt[i]; |
778 |
t_track->xm[ip] = l2->xm_nt[i][ip]; |
for(int it1=0;it1<5;it1++){ |
779 |
t_track->ym[ip] = l2->ym_nt[i][ip]; |
t_track->al[it1] = l2->al_nt[i][it1]; |
780 |
t_track->zm[ip] = l2->zm_nt[i][ip]; |
for(int it2=0;it2<5;it2++) |
781 |
t_track->resx[ip] = l2->resx_nt[i][ip]; |
t_track->coval[it1][it2] = l2->coval[i][it2][it1]; |
|
t_track->resy[ip] = l2->resy_nt[i][ip]; |
|
|
t_track->xv[ip] = l2->xv_nt[i][ip]; |
|
|
t_track->yv[ip] = l2->yv_nt[i][ip]; |
|
|
t_track->zv[ip] = l2->zv_nt[i][ip]; |
|
|
t_track->axv[ip] = l2->axv_nt[i][ip]; |
|
|
t_track->ayv[ip] = l2->ayv_nt[i][ip]; |
|
|
t_track->dedx_x[ip] = l2->dedx_x[i][ip]; |
|
|
t_track->dedx_y[ip] = l2->dedx_y[i][ip]; |
|
|
// cout << "traccia "<<i<<" -- "<< ip << " "<< l2->cltrx[i][ip] <<" "<< l2->cltry[i][ip] <<" "<< t_track->xgood[ip] << t_track->ygood[ip]<<endl; |
|
|
//----------------------------------------------------- |
|
|
// t_track->clx[ip] = l1->GetCluster(l2->cltrx[i][ip]-1); |
|
|
// t_track->cly[ip] = l1->GetCluster(l2->cltry[i][ip]-1); |
|
|
if(t_track->xgood[ip])t_track->clx->AddAt(l1->GetCluster(l2->cltrx[i][ip]-1),ip); |
|
|
if(t_track->ygood[ip])t_track->cly->AddAt(l1->GetCluster(l2->cltry[i][ip]-1),ip); |
|
|
// 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; |
|
|
// 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; |
|
|
//----------------------------------------------------- |
|
|
}; |
|
|
new(t[i]) TrkTrack(*t_track); |
|
|
t_track->Clear(); |
|
782 |
}; |
}; |
783 |
// *** SINGLETS *** |
for(int ip=0;ip<6;ip++){ |
784 |
TClonesArray &sx = *SingletX; |
t_track->xgood[ip] = l2->cltrx[i][ip];//l2->xgood_nt[i][ip]; |
785 |
for(int i=0; i<l2->nclsx; i++){ |
t_track->ygood[ip] = l2->cltry[i][ip];//l2->ygood_nt[i][ip]; |
786 |
t_singlet->plane = l2->planex[i]; |
t_track->xm[ip] = l2->xm_nt[i][ip]; |
787 |
t_singlet->coord[0] = l2->xs[i][0]; |
t_track->ym[ip] = l2->ym_nt[i][ip]; |
788 |
t_singlet->coord[1] = l2->xs[i][1]; |
t_track->zm[ip] = l2->zm_nt[i][ip]; |
789 |
t_singlet->sgnl = l2->signlxs[i]; |
t_track->resx[ip] = l2->resx_nt[i][ip]; |
790 |
//----------------------------------------------------- |
t_track->resy[ip] = l2->resy_nt[i][ip]; |
791 |
// cout << "singolo x "<<i<<" -- "<< l2->clsx[i] <<endl; |
t_track->xv[ip] = l2->xv_nt[i][ip]; |
792 |
t_singlet->cls = l1->GetCluster(l2->clsx[i]-1); |
t_track->yv[ip] = l2->yv_nt[i][ip]; |
793 |
// cout<<" i "<<i<<" l2->clsx[i] "<<l2->clsx[i]<< " l1->GetCluster(l2->clsx[i]-1) "<<l1->GetCluster(l2->clsx[i]-1)<<endl; |
t_track->zv[ip] = l2->zv_nt[i][ip]; |
794 |
//----------------------------------------------------- |
t_track->axv[ip] = l2->axv_nt[i][ip]; |
795 |
new(sx[i]) TrkSinglet(*t_singlet); |
t_track->ayv[ip] = l2->ayv_nt[i][ip]; |
796 |
t_singlet->Clear(); |
t_track->dedx_x[ip] = l2->dedx_x[i][ip]; |
797 |
} |
t_track->dedx_y[ip] = l2->dedx_y[i][ip]; |
798 |
TClonesArray &sy = *SingletY; |
// cout << " ip "<<ip<<" l2->cltrx[i][ip] "<< l2->cltrx[i][ip]<<endl; |
799 |
for(int i=0; i<l2->nclsy; i++){ |
// cout << " ip "<<ip<<" l2->cltry[i][ip] "<< l2->cltry[i][ip]<<endl; |
800 |
t_singlet->plane = l2->planey[i]; |
//----------------------------------------------------- |
801 |
t_singlet->coord[0] = l2->ys[i][0]; |
//----------------------------------------------------- |
802 |
t_singlet->coord[1] = l2->ys[i][1]; |
// if(l1 && t_track->xgood[ip])t_track->clx->AddAt(l1->GetCluster(l2->cltrx[i][ip]-1),ip); |
803 |
t_singlet->sgnl = l2->signlys[i]; |
// if(l1 && t_track->ygood[ip])t_track->cly->AddAt(l1->GetCluster(l2->cltry[i][ip]-1),ip); |
804 |
//----------------------------------------------------- |
if(l2->xgood_nt[i][ip]){ |
805 |
// cout << "singolo y "<<i<<" -- "<< l2->clsy[i] <<endl; |
// cout << " ip "<<ip<<" l2->cltrx[i][ip] "<< l2->cltrx[i][ip]<<endl; |
806 |
t_singlet->cls = l1->GetCluster(l2->clsy[i]-1); |
// cout << " ip "<<ip<<" l2->cltrx[i][ip] "<< l2->cltrx[i][ip]<<" "; |
807 |
// cout<<" i "<<i<<" l2->clsy[i] "<<l2->clsy[i]<< " l1->GetCluster(l2->clsy[i]-1) "<<l1->GetCluster(l2->clsy[i]-1)<<endl; |
// if( l1->GetCluster(l2->cltrx[i][ip]-1)->TestBit(l1->GetCluster(l2->cltrx[i][ip]-1)->kIsReferenced) )cout << ">> is referenced "; |
808 |
//----------------------------------------------------- |
if(l1)t_track->clx->AddAt(l1->GetCluster(l2->cltrx[i][ip]-1),ip); |
809 |
new(sy[i]) TrkSinglet(*t_singlet); |
// cout << " --- "<<l1->GetCluster(l2->cltrx[i][ip]-1)->GetUniqueID()<<endl; |
810 |
t_singlet->Clear(); |
// t_track->xgood[ip] = l2->cltrx[i][ip]; // WORK-AROUND ***** |
811 |
|
}else{ |
812 |
|
if(l1)t_track->clx->RemoveAt(ip); |
813 |
|
} |
814 |
|
if(l2->ygood_nt[i][ip]){ |
815 |
|
// cout << " ip "<<ip<<" l2->cltry[i][ip] "<< l2->cltry[i][ip]<<endl; |
816 |
|
// cout << " ip "<<ip<<" l2->cltry[i][ip] "<< l2->cltry[i][ip]<<" "; |
817 |
|
// if( l1->GetCluster(l2->cltry[i][ip]-1)->TestBit(l1->GetCluster(l2->cltry[i][ip]-1)->kIsReferenced) )cout << ">> is referenced "; |
818 |
|
if(l1)t_track->cly->AddAt(l1->GetCluster(l2->cltry[i][ip]-1),ip); |
819 |
|
// cout << " --- "<<l1->GetCluster(l2->cltry[i][ip]-1)->GetUniqueID()<<endl; |
820 |
|
// t_track->ygood[ip] = l2->cltry[i][ip]; // WORK-AROUND ***** |
821 |
|
}else{ |
822 |
|
if(l1)t_track->cly->RemoveAt(ip); |
823 |
|
} |
824 |
|
//----------------------------------------------------- |
825 |
|
//----------------------------------------------------- |
826 |
}; |
}; |
827 |
|
new(t[i]) TrkTrack(*t_track); |
828 |
|
t_track->Clear(); |
829 |
|
}; |
830 |
|
// ---------------- |
831 |
|
// *** SINGLETS *** |
832 |
|
// ---------------- |
833 |
|
if(!SingletX)SingletX = new TClonesArray("TrkSinglet"); |
834 |
|
TClonesArray &sx = *SingletX; |
835 |
|
for(int i=0; i<l2->nclsx; i++){ |
836 |
|
t_singlet->plane = l2->planex[i]; |
837 |
|
t_singlet->coord[0] = l2->xs[i][0]; |
838 |
|
t_singlet->coord[1] = l2->xs[i][1]; |
839 |
|
t_singlet->sgnl = l2->signlxs[i]; |
840 |
|
//----------------------------------------------------- |
841 |
|
if(l1) t_singlet->cls = l1->GetCluster(l2->clsx[i]-1); |
842 |
|
//----------------------------------------------------- |
843 |
|
new(sx[i]) TrkSinglet(*t_singlet); |
844 |
|
t_singlet->Clear(); |
845 |
|
} |
846 |
|
if(!SingletY)SingletY = new TClonesArray("TrkSinglet"); |
847 |
|
TClonesArray &sy = *SingletY; |
848 |
|
for(int i=0; i<l2->nclsy; i++){ |
849 |
|
t_singlet->plane = l2->planey[i]; |
850 |
|
t_singlet->coord[0] = l2->ys[i][0]; |
851 |
|
t_singlet->coord[1] = l2->ys[i][1]; |
852 |
|
t_singlet->sgnl = l2->signlys[i]; |
853 |
|
//----------------------------------------------------- |
854 |
|
if(l1) t_singlet->cls = l1->GetCluster(l2->clsy[i]-1); |
855 |
|
//----------------------------------------------------- |
856 |
|
new(sy[i]) TrkSinglet(*t_singlet); |
857 |
|
t_singlet->Clear(); |
858 |
|
}; |
859 |
|
|
860 |
delete t_track; |
delete t_track; |
861 |
delete t_singlet; |
delete t_singlet; |
862 |
} |
} |
863 |
/** |
/** |
864 |
* 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). |
874 |
}; |
}; |
875 |
// *** TRACKS *** |
// *** TRACKS *** |
876 |
|
|
877 |
l2->ntrk = Track->GetEntries(); |
if(Track){ |
878 |
for(Int_t i=0;i<l2->ntrk;i++){ |
l2->ntrk = Track->GetEntries(); |
879 |
l2->image[i] = 1 + ((TrkTrack *)Track->At(i))->image; |
for(Int_t i=0;i<l2->ntrk;i++){ |
880 |
l2->chi2_nt[i] = ((TrkTrack *)Track->At(i))->chi2; |
l2->image[i] = 1 + ((TrkTrack *)Track->At(i))->image; |
881 |
l2->nstep_nt[i] = ((TrkTrack *)Track->At(i))->nstep; |
l2->chi2_nt[i] = ((TrkTrack *)Track->At(i))->chi2; |
882 |
for(int it1=0;it1<5;it1++){ |
l2->nstep_nt[i] = ((TrkTrack *)Track->At(i))->nstep; |
883 |
l2->al_nt[i][it1] = ((TrkTrack *)Track->At(i))->al[it1]; |
for(int it1=0;it1<5;it1++){ |
884 |
for(int it2=0;it2<5;it2++) |
l2->al_nt[i][it1] = ((TrkTrack *)Track->At(i))->al[it1]; |
885 |
l2->coval[i][it2][it1] = ((TrkTrack *)Track->At(i))->coval[it1][it2]; |
for(int it2=0;it2<5;it2++) |
886 |
}; |
l2->coval[i][it2][it1] = ((TrkTrack *)Track->At(i))->coval[it1][it2]; |
887 |
for(int ip=0;ip<6;ip++){ |
}; |
888 |
l2->xgood_nt[i][ip] = ((TrkTrack *)Track->At(i))->xgood[ip]; |
for(int ip=0;ip<6;ip++){ |
889 |
l2->ygood_nt[i][ip] = ((TrkTrack *)Track->At(i))->ygood[ip]; |
l2->xgood_nt[i][ip] = ((TrkTrack *)Track->At(i))->XGood(ip); |
890 |
l2->xm_nt[i][ip] = ((TrkTrack *)Track->At(i))->xm[ip]; |
l2->ygood_nt[i][ip] = ((TrkTrack *)Track->At(i))->YGood(ip); |
891 |
l2->ym_nt[i][ip] = ((TrkTrack *)Track->At(i))->ym[ip]; |
l2->xm_nt[i][ip] = ((TrkTrack *)Track->At(i))->xm[ip]; |
892 |
l2->zm_nt[i][ip] = ((TrkTrack *)Track->At(i))->zm[ip]; |
l2->ym_nt[i][ip] = ((TrkTrack *)Track->At(i))->ym[ip]; |
893 |
l2->resx_nt[i][ip] = ((TrkTrack *)Track->At(i))->resx[ip]; |
l2->zm_nt[i][ip] = ((TrkTrack *)Track->At(i))->zm[ip]; |
894 |
l2->resy_nt[i][ip] = ((TrkTrack *)Track->At(i))->resy[ip]; |
l2->resx_nt[i][ip] = ((TrkTrack *)Track->At(i))->resx[ip]; |
895 |
l2->xv_nt[i][ip] = ((TrkTrack *)Track->At(i))->xv[ip]; |
l2->resy_nt[i][ip] = ((TrkTrack *)Track->At(i))->resy[ip]; |
896 |
l2->yv_nt[i][ip] = ((TrkTrack *)Track->At(i))->yv[ip]; |
l2->xv_nt[i][ip] = ((TrkTrack *)Track->At(i))->xv[ip]; |
897 |
l2->zv_nt[i][ip] = ((TrkTrack *)Track->At(i))->zv[ip]; |
l2->yv_nt[i][ip] = ((TrkTrack *)Track->At(i))->yv[ip]; |
898 |
l2->axv_nt[i][ip] = ((TrkTrack *)Track->At(i))->axv[ip]; |
l2->zv_nt[i][ip] = ((TrkTrack *)Track->At(i))->zv[ip]; |
899 |
l2->ayv_nt[i][ip] = ((TrkTrack *)Track->At(i))->ayv[ip]; |
l2->axv_nt[i][ip] = ((TrkTrack *)Track->At(i))->axv[ip]; |
900 |
l2->dedx_x[i][ip] = ((TrkTrack *)Track->At(i))->dedx_x[ip]; |
l2->ayv_nt[i][ip] = ((TrkTrack *)Track->At(i))->ayv[ip]; |
901 |
l2->dedx_y[i][ip] = ((TrkTrack *)Track->At(i))->dedx_y[ip]; |
l2->dedx_x[i][ip] = ((TrkTrack *)Track->At(i))->dedx_x[ip]; |
902 |
}; |
l2->dedx_y[i][ip] = ((TrkTrack *)Track->At(i))->dedx_y[ip]; |
903 |
|
}; |
904 |
|
} |
905 |
} |
} |
|
|
|
906 |
// *** SINGLETS *** |
// *** SINGLETS *** |
907 |
l2->nclsx = SingletX->GetEntries(); |
if(SingletX){ |
908 |
for(Int_t i=0;i<l2->nclsx;i++){ |
l2->nclsx = SingletX->GetEntries(); |
909 |
l2->planex[i] = ((TrkSinglet *)SingletX->At(i))->plane; |
for(Int_t i=0;i<l2->nclsx;i++){ |
910 |
l2->xs[i][0] = ((TrkSinglet *)SingletX->At(i))->coord[0]; |
l2->planex[i] = ((TrkSinglet *)SingletX->At(i))->plane; |
911 |
l2->xs[i][1] = ((TrkSinglet *)SingletX->At(i))->coord[1]; |
l2->xs[i][0] = ((TrkSinglet *)SingletX->At(i))->coord[0]; |
912 |
l2->signlxs[i] = ((TrkSinglet *)SingletX->At(i))->sgnl; |
l2->xs[i][1] = ((TrkSinglet *)SingletX->At(i))->coord[1]; |
913 |
} |
l2->signlxs[i] = ((TrkSinglet *)SingletX->At(i))->sgnl; |
914 |
l2->nclsy = SingletY->GetEntries(); |
} |
915 |
for(Int_t i=0;i<l2->nclsy;i++){ |
} |
916 |
l2->planey[i] = ((TrkSinglet *)SingletY->At(i))->plane; |
|
917 |
l2->ys[i][0] = ((TrkSinglet *)SingletY->At(i))->coord[0]; |
if(SingletY){ |
918 |
l2->ys[i][1] = ((TrkSinglet *)SingletY->At(i))->coord[1]; |
l2->nclsy = SingletY->GetEntries(); |
919 |
l2->signlys[i] = ((TrkSinglet *)SingletY->At(i))->sgnl; |
for(Int_t i=0;i<l2->nclsy;i++){ |
920 |
|
l2->planey[i] = ((TrkSinglet *)SingletY->At(i))->plane; |
921 |
|
l2->ys[i][0] = ((TrkSinglet *)SingletY->At(i))->coord[0]; |
922 |
|
l2->ys[i][1] = ((TrkSinglet *)SingletY->At(i))->coord[1]; |
923 |
|
l2->signlys[i] = ((TrkSinglet *)SingletY->At(i))->sgnl; |
924 |
|
} |
925 |
} |
} |
926 |
} |
} |
927 |
//-------------------------------------- |
//-------------------------------------- |
929 |
// |
// |
930 |
//-------------------------------------- |
//-------------------------------------- |
931 |
void TrkLevel2::Clear(){ |
void TrkLevel2::Clear(){ |
|
// good2 = -1; |
|
932 |
for(Int_t i=0; i<12 ; i++){ |
for(Int_t i=0; i<12 ; i++){ |
933 |
// crc[i] = -1; |
good[i] = -1; |
934 |
good[i] = -1; |
}; |
935 |
}; |
// if(Track)Track->Clear("C"); |
936 |
/* Track->RemoveAll(); |
// if(SingletX)SingletX->Clear("C"); |
937 |
SingletX->RemoveAll(); |
// if(SingletY)SingletY->Clear("C"); |
938 |
SingletY->RemoveAll();*/ |
if(Track)Track->Delete(); |
939 |
// modify to avoid memory leakage |
if(SingletX)SingletX->Delete(); |
940 |
Track->Clear(); |
if(SingletY)SingletY->Delete(); |
941 |
SingletX->Clear(); |
} |
942 |
SingletY->Clear(); |
// //-------------------------------------- |
943 |
|
// // |
944 |
|
// // |
945 |
|
// //-------------------------------------- |
946 |
|
void TrkLevel2::Delete(){ |
947 |
|
|
948 |
|
// cout << "void TrkLevel2::Delete()"<<endl; |
949 |
|
Clear(); |
950 |
|
if(Track)delete Track; |
951 |
|
if(SingletX)delete SingletX; |
952 |
|
if(SingletY)delete SingletY; |
953 |
|
|
954 |
} |
} |
955 |
//-------------------------------------- |
//-------------------------------------- |
956 |
// |
// |
962 |
*/ |
*/ |
963 |
TRefArray *TrkLevel2::GetTracks_NFitSorted(){ |
TRefArray *TrkLevel2::GetTracks_NFitSorted(){ |
964 |
|
|
965 |
TRefArray *sorted = new TRefArray(); |
if(!Track)return 0; |
966 |
|
|
967 |
|
TRefArray *sorted = new TRefArray(); |
968 |
|
|
969 |
TClonesArray &t = *Track; |
TClonesArray &t = *Track; |
970 |
// TClonesArray &ts = *PhysicalTrack; |
// TClonesArray &ts = *PhysicalTrack; |
971 |
int N = ntrk(); |
int N = ntrk(); |
972 |
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; |
973 |
// int m[50]; for(int i=0; i<N; i++)m[i]=1; |
// int m[50]; for(int i=0; i<N; i++)m[i]=1; |
974 |
|
|
975 |
int indo=0; |
int indo=0; |
976 |
int indi=0; |
int indi=0; |
977 |
while(N != 0){ |
while(N > 0){ |
978 |
int nfit =0; |
// while(N != 0){ |
979 |
float chi2ref = numeric_limits<float>::max(); |
int nfit =0; |
980 |
|
float chi2ref = numeric_limits<float>::max(); |
|
// first loop to search maximum num. of fit points |
|
|
for(int i=0; i < ntrk(); i++){ |
|
|
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++){ |
|
|
Float_t chi2 = ((TrkTrack *)t[i])->chi2; |
|
|
if(chi2 < 0) chi2 = chi2*1000; |
|
|
if( chi2 < chi2ref |
|
|
&& ((TrkTrack *)t[i])->GetNtot() == nfit |
|
|
&& m[i]==1){ |
|
|
chi2ref = ((TrkTrack *)t[i])->chi2; |
|
|
indi = i; |
|
|
}; |
|
|
}; |
|
|
if( ((TrkTrack *)t[indi])->HasImage() ){ |
|
|
m[((TrkTrack *)t[indi])->image] = 0; |
|
|
N--; |
|
|
|
|
|
// cout << "i** "<< ((TrkTrack *)t[indi])->image << " " << nfiti <<" "<<chi2i<<endl; |
|
|
}; |
|
|
sorted->Add( (TrkTrack*)t[indi] ); |
|
981 |
|
|
982 |
m[indi] = 0; |
// first loop to search maximum num. of fit points |
983 |
// cout << "SORTED "<< indo << " "<< indi << " "<< N << endl; |
for(int i=0; i < ntrk(); i++){ |
984 |
N--; |
if( ((TrkTrack *)t[i])->GetNtot() >= nfit && m[i]==1){ |
985 |
indo++; |
nfit = ((TrkTrack *)t[i])->GetNtot(); |
986 |
|
} |
987 |
} |
} |
988 |
m.clear(); |
//second loop to search minimum chi2 among selected |
989 |
// cout << "GetTracks_NFitSorted(it): Done"<< endl; |
for(int i=0; i<ntrk(); i++){ |
990 |
|
Float_t chi2 = ((TrkTrack *)t[i])->chi2; |
991 |
|
if(chi2 < 0) chi2 = -chi2*1000; |
992 |
|
if( chi2 < chi2ref |
993 |
|
&& ((TrkTrack *)t[i])->GetNtot() == nfit |
994 |
|
&& m[i]==1){ |
995 |
|
chi2ref = ((TrkTrack *)t[i])->chi2; |
996 |
|
indi = i; |
997 |
|
}; |
998 |
|
}; |
999 |
|
if( ((TrkTrack *)t[indi])->HasImage() ){ |
1000 |
|
m[((TrkTrack *)t[indi])->image] = 0; |
1001 |
|
N--; |
1002 |
|
|
1003 |
|
// cout << "i** "<< ((TrkTrack *)t[indi])->image << " " << nfiti <<" "<<chi2i<<endl; |
1004 |
|
}; |
1005 |
|
sorted->Add( (TrkTrack*)t[indi] ); |
1006 |
|
|
1007 |
|
m[indi] = 0; |
1008 |
|
// cout << "SORTED "<< indo << " "<< indi << " "<< N << " "<<((TrkTrack *)t[indi])->image<<" "<<chi2ref<<endl; |
1009 |
|
N--; |
1010 |
|
indo++; |
1011 |
|
} |
1012 |
|
m.clear(); |
1013 |
|
// cout << "GetTracks_NFitSorted(it): Done"<< endl; |
1014 |
|
|
1015 |
return sorted; |
return sorted; |
1016 |
// return PhysicalTrack; |
// return PhysicalTrack; |
1017 |
} |
} |
1018 |
//-------------------------------------- |
//-------------------------------------- |
1031 |
cout << " Stored tracks ntrk() = "<< this->ntrk() << endl; |
cout << " Stored tracks ntrk() = "<< this->ntrk() << endl; |
1032 |
return 0; |
return 0; |
1033 |
} |
} |
1034 |
|
if(!Track){ |
1035 |
|
cout << "TrkTrack *TrkLevel2::GetStoredTrack(int is) >> (TClonesArray*) Track ==0 "<<endl; |
1036 |
|
}; |
1037 |
TClonesArray &t = *(Track); |
TClonesArray &t = *(Track); |
1038 |
TrkTrack *track = (TrkTrack*)t[is]; |
TrkTrack *track = (TrkTrack*)t[is]; |
1039 |
return track; |
return track; |
1053 |
cout << " Stored x-singlets nclsx() = "<< this->nclsx() << endl; |
cout << " Stored x-singlets nclsx() = "<< this->nclsx() << endl; |
1054 |
return 0; |
return 0; |
1055 |
} |
} |
1056 |
|
if(!SingletX)return 0; |
1057 |
TClonesArray &t = *(SingletX); |
TClonesArray &t = *(SingletX); |
1058 |
TrkSinglet *singlet = (TrkSinglet*)t[is]; |
TrkSinglet *singlet = (TrkSinglet*)t[is]; |
1059 |
return singlet; |
return singlet; |
1073 |
cout << " Stored y-singlets nclsy() = "<< this->nclsx() << endl; |
cout << " Stored y-singlets nclsy() = "<< this->nclsx() << endl; |
1074 |
return 0; |
return 0; |
1075 |
} |
} |
1076 |
|
if(!SingletY)return 0; |
1077 |
TClonesArray &t = *(SingletY); |
TClonesArray &t = *(SingletY); |
1078 |
TrkSinglet *singlet = (TrkSinglet*)t[is]; |
TrkSinglet *singlet = (TrkSinglet*)t[is]; |
1079 |
return singlet; |
return singlet; |
1096 |
} |
} |
1097 |
|
|
1098 |
TRefArray *sorted = GetTracks(); //TEMPORANEO |
TRefArray *sorted = GetTracks(); //TEMPORANEO |
1099 |
|
if(!sorted)return 0; |
1100 |
TrkTrack *track = (TrkTrack*)sorted->At(it); |
TrkTrack *track = (TrkTrack*)sorted->At(it); |
1101 |
sorted->Delete(); |
sorted->Clear(); |
1102 |
|
delete sorted; |
1103 |
return track; |
return track; |
1104 |
} |
} |
1105 |
/** |
/** |
1108 |
Int_t TrkLevel2::GetNTracks(){ |
Int_t TrkLevel2::GetNTracks(){ |
1109 |
|
|
1110 |
Float_t ntot=0; |
Float_t ntot=0; |
1111 |
|
if(!Track)return 0; |
1112 |
TClonesArray &t = *Track; |
TClonesArray &t = *Track; |
1113 |
for(int i=0; i<ntrk(); i++) { |
for(int i=0; i<ntrk(); i++) { |
1114 |
if( ((TrkTrack *)t[i])->GetImageSeqNo() == -1 ) ntot+=1.; |
if( ((TrkTrack *)t[i])->GetImageSeqNo() == -1 ) ntot+=1.; |
1115 |
else ntot+=0.5; |
else ntot+=0.5; |
1116 |
} |
} |
1127 |
*/ |
*/ |
1128 |
TrkTrack *TrkLevel2::GetTrackImage(int it){ |
TrkTrack *TrkLevel2::GetTrackImage(int it){ |
1129 |
|
|
1130 |
if(it >= this->GetNTracks()){ |
if(it >= this->GetNTracks()){ |
1131 |
cout << "** TrkLevel2 ** Track "<< it << "does not exits! " << endl; |
cout << "** TrkLevel2 ** Track "<< it << "does not exits! " << endl; |
1132 |
cout << " Physical tracks GetNTracks() = "<< this->ntrk() << endl; |
cout << " Physical tracks GetNTracks() = "<< this->ntrk() << endl; |
1133 |
return 0; |
return 0; |
1134 |
} |
} |
1135 |
|
|
1136 |
TRefArray* sorted = GetTracks(); //TEMPORANEO |
TRefArray* sorted = GetTracks(); //TEMPORANEO |
1137 |
TrkTrack *track = (TrkTrack*)sorted->At(it); |
if(!sorted)return 0; |
1138 |
|
TrkTrack *track = (TrkTrack*)sorted->At(it); |
1139 |
|
|
1140 |
if(!track->HasImage()){ |
if(!track->HasImage()){ |
1141 |
cout << "** TrkLevel2 ** Track "<< it << "does not have image! " << endl; |
cout << "** TrkLevel2 ** Track "<< it << "does not have image! " << endl; |
1142 |
return 0; |
return 0; |
1143 |
} |
} |
1144 |
TrkTrack *image = (TrkTrack*)(*Track)[track->image]; |
if(!Track)return 0; |
1145 |
|
TrkTrack *image = (TrkTrack*)(*Track)[track->image]; |
1146 |
|
|
1147 |
sorted->Delete(); |
sorted->Delete(); |
1148 |
|
delete sorted; |
1149 |
return image; |
|
1150 |
|
return image; |
1151 |
|
|
1152 |
} |
} |
1153 |
//-------------------------------------- |
//-------------------------------------- |
1158 |
* Loads the magnetic field. |
* Loads the magnetic field. |
1159 |
* @param s Path of the magnetic-field files. |
* @param s Path of the magnetic-field files. |
1160 |
*/ |
*/ |
1161 |
void TrkLevel2::LoadField(TString s){ |
void TrkLevel2::LoadField(TString path){ |
1162 |
readb_(s.Data()); |
// |
1163 |
|
// strcpy(path_.path,path.Data()); |
1164 |
|
// path_.pathlen = path.Length(); |
1165 |
|
// path_.error = 0; |
1166 |
|
// readb_(); |
1167 |
|
|
1168 |
|
TrkParams::Set(path,1); |
1169 |
|
TrkParams::Load(1); |
1170 |
|
|
1171 |
|
// |
1172 |
}; |
}; |
1173 |
|
/** |
1174 |
|
* Get BY (kGauss) |
1175 |
|
* @param v (x,y,z) coordinates in cm |
1176 |
|
*/ |
1177 |
|
float TrkLevel2::GetBX(float* v){ |
1178 |
|
float b[3]; |
1179 |
|
gufld_(v,b); |
1180 |
|
return b[0]/10.; |
1181 |
|
} |
1182 |
|
/** |
1183 |
|
* Get BY (kGauss) |
1184 |
|
* @param v (x,y,z) coordinates in cm |
1185 |
|
*/ |
1186 |
|
float TrkLevel2::GetBY(float* v){ |
1187 |
|
float b[3]; |
1188 |
|
gufld_(v,b); |
1189 |
|
return b[1]/10.; |
1190 |
|
} |
1191 |
|
/** |
1192 |
|
* Get BY (kGauss) |
1193 |
|
* @param v (x,y,z) coordinates in cm |
1194 |
|
*/ |
1195 |
|
float TrkLevel2::GetBZ(float* v){ |
1196 |
|
float b[3]; |
1197 |
|
gufld_(v,b); |
1198 |
|
return b[2]/10.; |
1199 |
|
} |
1200 |
//-------------------------------------- |
//-------------------------------------- |
1201 |
// |
// |
1202 |
// |
// |
1293 |
tl = new float[npoint]; |
tl = new float[npoint]; |
1294 |
int i=0; |
int i=0; |
1295 |
do{ |
do{ |
1296 |
x[i] = 0; |
x[i] = 0; |
1297 |
y[i] = 0; |
y[i] = 0; |
1298 |
z[i] = zin[i]; |
z[i] = zin[i]; |
1299 |
thx[i] = 0; |
thx[i] = 0; |
1300 |
thy[i] = 0; |
thy[i] = 0; |
1301 |
tl[i] = 0; |
tl[i] = 0; |
1302 |
i++; |
i++; |
1303 |
}while(zin[i-1] > zin[i] && i < npoint); |
}while(zin[i-1] > zin[i] && i < npoint); |
1304 |
npoint=i; |
npoint=i; |
1305 |
if(npoint != n)cout << "NB! Trajectory created with "<<npoint<<" points"<<endl; |
if(npoint != n)cout << "NB! Trajectory created with "<<npoint<<" points"<<endl; |
1306 |
} |
} |
1307 |
|
void Trajectory::Delete(){ |
1308 |
|
|
1309 |
|
if(x) delete [] x; |
1310 |
|
if(y) delete [] y; |
1311 |
|
if(z) delete [] z; |
1312 |
|
if(thx) delete [] thx; |
1313 |
|
if(thy) delete [] thy; |
1314 |
|
if(tl) delete [] tl; |
1315 |
|
|
1316 |
|
} |
1317 |
//-------------------------------------- |
//-------------------------------------- |
1318 |
// |
// |
1319 |
// |
// |
1352 |
|
|
1353 |
} |
} |
1354 |
|
|
1355 |
|
/** |
1356 |
|
* Evaluates the trajectory in the apparatus associated to the track. |
1357 |
|
* 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. |
1358 |
|
* @param t pointer to an object of the class Trajectory, |
1359 |
|
* which z coordinates should be previously initialized by calling the proper constructor ( Trajectory::Trajectory(int n, float* zin) ). |
1360 |
|
* @return error flag. |
1361 |
|
*/ |
1362 |
|
int Trajectory::DoTrack2(float* al){ |
1363 |
|
|
1364 |
|
double *dxout = new double[npoint]; |
1365 |
|
double *dyout = new double[npoint]; |
1366 |
|
double *dthxout = new double[npoint]; |
1367 |
|
double *dthyout = new double[npoint]; |
1368 |
|
double *dtlout = new double[npoint]; |
1369 |
|
double *dzin = new double[npoint]; |
1370 |
|
double dal[5]; |
1371 |
|
|
1372 |
|
int ifail = 0; |
1373 |
|
|
1374 |
|
for (int i=0; i<5; i++) dal[i] = (double)al[i]; |
1375 |
|
for (int i=0; i<npoint; i++) dzin[i] = (double)z[i]; |
1376 |
|
|
1377 |
|
TrkParams::Load(1); |
1378 |
|
if( !TrkParams::IsLoaded(1) ){ |
1379 |
|
cout << "int Trajectory::DoTrack2(float* al) --- ERROR --- m.field not loaded"<<endl; |
1380 |
|
return 0; |
1381 |
|
} |
1382 |
|
dotrack2_(&(npoint),dzin,dxout,dyout,dthxout,dthyout,dtlout,dal,&ifail); |
1383 |
|
|
1384 |
|
for (int i=0; i<npoint; i++){ |
1385 |
|
x[i] = (float)*dxout++; |
1386 |
|
y[i] = (float)*dyout++; |
1387 |
|
thx[i] = (float)*dthxout++; |
1388 |
|
thy[i] = (float)*dthyout++; |
1389 |
|
tl[i] = (float)*dtlout++; |
1390 |
|
} |
1391 |
|
|
1392 |
|
return ifail; |
1393 |
|
}; |
1394 |
|
|
1395 |
ClassImp(TrkLevel2); |
ClassImp(TrkLevel2); |
1396 |
ClassImp(TrkSinglet); |
ClassImp(TrkSinglet); |