4 |
*/ |
*/ |
5 |
#include <TrkLevel2.h> |
#include <TrkLevel2.h> |
6 |
#include <iostream> |
#include <iostream> |
7 |
|
#include <math.h> |
8 |
using namespace std; |
using namespace std; |
9 |
//...................................... |
//...................................... |
10 |
// F77 routines |
// F77 routines |
11 |
//...................................... |
//...................................... |
12 |
extern "C" { |
extern "C" { |
13 |
void dotrack_(int*, double*, double*, double*, double*, int*); |
void dotrack_(int*, double*, double*, double*, double*, int*); |
14 |
int readb_(const char*); |
void dotrack2_(int*, double*, double*, double*, double*,double*, double*, double*,int*); |
15 |
|
// int readb_(const char*); |
16 |
|
// int readb_(); |
17 |
|
void mini2_(int*,int*,int*); |
18 |
|
void guess_(); |
19 |
|
void gufld_(float*, float*); |
20 |
} |
} |
21 |
|
|
22 |
//-------------------------------------- |
//-------------------------------------- |
23 |
// |
// |
24 |
// |
// |
25 |
//-------------------------------------- |
//-------------------------------------- |
26 |
TrkTrack::TrkTrack(){ |
TrkTrack::TrkTrack(){ |
27 |
image = 0; |
// cout << "TrkTrack::TrkTrack()" << endl; |
28 |
|
seqno = -1; |
29 |
|
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); |
55 |
|
// cly = new TRefArray(6,0); |
56 |
}; |
}; |
57 |
//-------------------------------------- |
//-------------------------------------- |
58 |
// |
// |
59 |
// |
// |
60 |
//-------------------------------------- |
//-------------------------------------- |
61 |
TrkTrack::TrkTrack(const TrkTrack& t){ |
TrkTrack::TrkTrack(const TrkTrack& t){ |
62 |
|
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++){ |
167 |
// |
// |
168 |
// |
// |
169 |
//-------------------------------------- |
//-------------------------------------- |
170 |
|
/** |
171 |
|
* Evaluates the trajectory in the apparatus associated to the track. |
172 |
|
* 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. |
173 |
|
* @param t pointer to an object of the class Trajectory, |
174 |
|
* which z coordinates should be previously initialized by calling the proper constructor ( Trajectory::Trajectory(int n, float* zin) ). |
175 |
|
* @return error flag. |
176 |
|
*/ |
177 |
|
int TrkTrack::DoTrack2(Trajectory* t){ |
178 |
|
|
179 |
|
double *dxout = new double[t->npoint]; |
180 |
|
double *dyout = new double[t->npoint]; |
181 |
|
double *dthxout = new double[t->npoint]; |
182 |
|
double *dthyout = new double[t->npoint]; |
183 |
|
double *dtlout = new double[t->npoint]; |
184 |
|
double *dzin = new double[t->npoint]; |
185 |
|
double dal[5]; |
186 |
|
|
187 |
|
int ifail = 0; |
188 |
|
|
189 |
|
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]; |
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); |
198 |
|
|
199 |
|
for (int i=0; i<t->npoint; i++){ |
200 |
|
t->x[i] = (float)*dxout++; |
201 |
|
t->y[i] = (float)*dyout++; |
202 |
|
t->thx[i] = (float)*dthxout++; |
203 |
|
t->thy[i] = (float)*dthyout++; |
204 |
|
t->tl[i] = (float)*dtlout++; |
205 |
|
} |
206 |
|
|
207 |
|
// delete [] dxout; |
208 |
|
// delete [] dyout; |
209 |
|
// delete [] dzin; |
210 |
|
|
211 |
|
return ifail; |
212 |
|
}; |
213 |
|
//-------------------------------------- |
214 |
|
// |
215 |
|
// |
216 |
|
//-------------------------------------- |
217 |
//float TrkTrack::BdL(){ |
//float TrkTrack::BdL(){ |
218 |
//}; |
//}; |
219 |
//-------------------------------------- |
//-------------------------------------- |
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 |
|
|
308 |
|
}; |
309 |
|
|
310 |
|
|
311 |
|
/** |
312 |
|
* Method to fill minimization-routine common |
313 |
|
*/ |
314 |
|
void TrkTrack::FillMiniStruct(cMini2track& track){ |
315 |
|
|
316 |
|
for(int i=0; i<6; i++){ |
317 |
|
|
318 |
|
track.xgood[i]=xgood[i]; |
319 |
|
track.ygood[i]=ygood[i]; |
320 |
|
|
321 |
|
track.xm[i]=xm[i]; |
322 |
|
track.ym[i]=ym[i]; |
323 |
|
track.zm[i]=zm[i]; |
324 |
|
|
325 |
|
// --- temporaneo ---------------------------- |
326 |
|
// andrebbe inserita la dimensione del sensore |
327 |
|
float segment = 100.; |
328 |
|
track.xm_a[i]=xm[i]; |
329 |
|
track.xm_b[i]=xm[i]; |
330 |
|
track.ym_a[i]=ym[i]; |
331 |
|
track.ym_b[i]=ym[i]; |
332 |
|
if( xgood[i] && !ygood[i] ){ |
333 |
|
track.ym_a[i] = track.ym_a[i]+segment; |
334 |
|
track.ym_b[i] = track.ym_b[i]-segment; |
335 |
|
}else if( !xgood[i] && ygood[i]){ |
336 |
|
track.xm_a[i] = track.xm_a[i]+segment; |
337 |
|
track.xm_b[i] = track.xm_b[i]-segment; |
338 |
|
} |
339 |
|
// --- temporaneo ---------------------------- |
340 |
|
|
341 |
|
track.resx[i]=resx[i]; |
342 |
|
track.resy[i]=resy[i]; |
343 |
|
} |
344 |
|
|
345 |
|
for(int i=0; i<5; i++) track.al[i]=al[i]; |
346 |
|
track.zini = 23.5; |
347 |
|
// ZINI = 23.5 !!! it should be the same parameter in all codes |
348 |
|
|
349 |
|
} |
350 |
|
/** |
351 |
|
* Method to set values from minimization-routine common |
352 |
|
*/ |
353 |
|
void TrkTrack::SetFromMiniStruct(cMini2track *track){ |
354 |
|
|
355 |
|
for(int i=0; i<5; i++) { |
356 |
|
al[i]=track->al[i]; |
357 |
|
for(int j=0; j<5; j++) coval[i][j]=track->cov[i][j]; |
358 |
|
} |
359 |
|
chi2 = track->chi2; |
360 |
|
nstep = track->nstep; |
361 |
|
for(int i=0; i<6; i++){ |
362 |
|
xv[i] = track->xv[i]; |
363 |
|
yv[i] = track->yv[i]; |
364 |
|
zv[i] = track->zv[i]; |
365 |
|
xm[i] = track->xm[i]; |
366 |
|
ym[i] = track->ym[i]; |
367 |
|
zm[i] = track->zm[i]; |
368 |
|
axv[i] = track->axv[i]; |
369 |
|
ayv[i] = track->ayv[i]; |
370 |
|
} |
371 |
|
|
372 |
|
} |
373 |
|
/** |
374 |
|
* Tracking method. It calls F77 mini routine. |
375 |
|
*/ |
376 |
|
void TrkTrack::Fit(double pfixed, int& fail, int iprint){ |
377 |
|
|
378 |
|
float al_ini[] = {0.,0.,0.,0.,0.}; |
379 |
|
|
380 |
|
extern cMini2track track_; |
381 |
|
fail = 0; |
382 |
|
FillMiniStruct(track_); |
383 |
|
|
384 |
|
// if fit variables have been reset, evaluate the initial guess |
385 |
|
if(al[0]==-9999.&&al[1]==-9999.&&al[2]==-9999.&&al[3]==-9999.&&al[4]==-9999.)guess_(); |
386 |
|
|
387 |
|
// --------------------- free momentum |
388 |
|
if(pfixed==0.) { |
389 |
|
track_.pfixed=0.; |
390 |
|
} |
391 |
|
// --------------------- fixed momentum |
392 |
|
if(pfixed!=0.) { |
393 |
|
al[4]=1./pfixed; |
394 |
|
track_.pfixed=pfixed; |
395 |
|
} |
396 |
|
|
397 |
|
// store temporarily the initial guess |
398 |
|
for(int i=0; i<5; i++) al_ini[i]=track_.al[i]; |
399 |
|
|
400 |
|
// ------------------------------------------ |
401 |
|
// call mini routine |
402 |
|
TrkParams::Load(1); |
403 |
|
if( !TrkParams::IsLoaded(1) ){ |
404 |
|
cout << "void TrkTrack::Fit(double pfixed, int& fail, int iprint) --- ERROR --- m.field not loaded"<<endl; |
405 |
|
return; |
406 |
|
} |
407 |
|
int istep=0; |
408 |
|
int ifail=0; |
409 |
|
mini2_(&istep,&ifail, &iprint); |
410 |
|
if(ifail!=0) { |
411 |
|
if(iprint)cout << "ERROR: ifail= " << ifail << endl; |
412 |
|
fail = 1; |
413 |
|
} |
414 |
|
// ------------------------------------------ |
415 |
|
|
416 |
|
SetFromMiniStruct(&track_); |
417 |
|
// cout << endl << "eta ===> " << track_.al[4] << endl; |
418 |
|
|
419 |
|
// for(int i=0; i<5; i++) al[i]=track_.al[i]; |
420 |
|
// chi2=track_.chi2; |
421 |
|
// nstep=track_.nstep; |
422 |
|
// for(int i=0; i<6; i++) xv[i]=track_.xv[i]; |
423 |
|
// for(int i=0; i<6; i++) yv[i]=track_.yv[i]; |
424 |
|
// for(int i=0; i<6; i++) zv[i]=track_.zv[i]; |
425 |
|
// for(int i=0; i<6; i++) axv[i]=track_.axv[i]; |
426 |
|
// for(int i=0; i<6; i++) ayv[i]=track_.ayv[i]; |
427 |
|
// for(int i=0; i<5; i++) { |
428 |
|
// for(int j=0; j<5; j++) coval[i][j]=track_.cov[i][j]; |
429 |
|
// } |
430 |
|
|
431 |
|
if(fail){ |
432 |
|
if(iprint)cout << " >>>> fit failed >>>> drawing initial par"<<endl; |
433 |
|
for(int i=0; i<5; i++) al[i]=al_ini[i]; |
434 |
|
} |
435 |
|
|
436 |
|
}; |
437 |
|
/* |
438 |
|
* Reset the fit parameters |
439 |
|
*/ |
440 |
|
void TrkTrack::FitReset(){ |
441 |
|
for(int i=0; i<5; i++) al[i]=-9999.; |
442 |
|
chi2=0.; |
443 |
|
nstep=0; |
444 |
|
for(int i=0; i<6; i++) xv[i]=0.; |
445 |
|
for(int i=0; i<6; i++) yv[i]=0.; |
446 |
|
for(int i=0; i<6; i++) zv[i]=0.; |
447 |
|
for(int i=0; i<6; i++) axv[i]=0.; |
448 |
|
for(int i=0; i<6; i++) ayv[i]=0.; |
449 |
|
for(int i=0; i<5; i++) { |
450 |
|
for(int j=0; j<5; j++) coval[i][j]=0.; |
451 |
|
} |
452 |
|
} |
453 |
|
void TrkTrack::SetTrackingMode(int trackmode){ |
454 |
|
extern cMini2track track_; |
455 |
|
track_.trackmode = trackmode; |
456 |
|
} |
457 |
|
|
458 |
|
//-------------------------------------- |
459 |
|
// |
460 |
|
// |
461 |
|
//-------------------------------------- |
462 |
|
void TrkTrack::Clear(){ |
463 |
|
// cout << "TrkTrack::Clear()"<<endl; |
464 |
|
seqno = -1; |
465 |
|
image = -1; |
466 |
|
chi2 = 0; |
467 |
|
nstep = 0; |
468 |
|
for(int it1=0;it1<5;it1++){ |
469 |
|
al[it1] = 0; |
470 |
|
for(int it2=0;it2<5;it2++)coval[it1][it2] = 0; |
471 |
|
}; |
472 |
|
for(int ip=0;ip<6;ip++){ |
473 |
|
xgood[ip] = 0; |
474 |
|
ygood[ip] = 0; |
475 |
|
xm[ip] = 0; |
476 |
|
ym[ip] = 0; |
477 |
|
zm[ip] = 0; |
478 |
|
resx[ip] = 0; |
479 |
|
resy[ip] = 0; |
480 |
|
xv[ip] = 0; |
481 |
|
yv[ip] = 0; |
482 |
|
zv[ip] = 0; |
483 |
|
axv[ip] = 0; |
484 |
|
ayv[ip] = 0; |
485 |
|
dedx_x[ip] = 0; |
486 |
|
dedx_y[ip] = 0; |
487 |
|
|
488 |
|
}; |
489 |
|
if(clx)clx->Clear(); |
490 |
|
if(cly)cly->Clear(); |
491 |
|
}; |
492 |
|
//-------------------------------------- |
493 |
|
// |
494 |
|
// |
495 |
|
//-------------------------------------- |
496 |
|
void TrkTrack::Delete(){ |
497 |
|
// cout << "TrkTrack::Delete()"<<endl; |
498 |
|
// Clear(); |
499 |
|
if(clx)delete clx; |
500 |
|
if(cly)delete cly; |
501 |
|
}; |
502 |
|
//-------------------------------------- |
503 |
|
// |
504 |
|
// |
505 |
|
//-------------------------------------- |
506 |
|
|
507 |
//-------------------------------------- |
//-------------------------------------- |
508 |
// |
// |
509 |
// |
// |
510 |
//-------------------------------------- |
//-------------------------------------- |
511 |
TrkSinglet::TrkSinglet(){ |
TrkSinglet::TrkSinglet(){ |
512 |
|
// cout << "TrkSinglet::TrkSinglet() " << GetUniqueID()<<endl; |
513 |
plane = 0; |
plane = 0; |
514 |
coord[0] = 0; |
coord[0] = 0; |
515 |
coord[1] = 0; |
coord[1] = 0; |
516 |
sgnl = 0; |
sgnl = 0; |
517 |
|
// cls = 0; |
518 |
}; |
}; |
519 |
//-------------------------------------- |
//-------------------------------------- |
520 |
// |
// |
521 |
// |
// |
522 |
//-------------------------------------- |
//-------------------------------------- |
523 |
TrkSinglet::TrkSinglet(const TrkSinglet& s){ |
TrkSinglet::TrkSinglet(const TrkSinglet& s){ |
524 |
|
// cout << "TrkSinglet::TrkSinglet(const TrkSinglet& s) " << GetUniqueID()<<endl; |
525 |
plane = s.plane; |
plane = s.plane; |
526 |
coord[0] = s.coord[0]; |
coord[0] = s.coord[0]; |
527 |
coord[1] = s.coord[1]; |
coord[1] = s.coord[1]; |
528 |
sgnl = s.sgnl; |
sgnl = s.sgnl; |
529 |
|
// cls = 0;//<<<<pointer |
530 |
|
cls = TRef(s.cls); |
531 |
}; |
}; |
532 |
//-------------------------------------- |
//-------------------------------------- |
533 |
// |
// |
544 |
// |
// |
545 |
// |
// |
546 |
//-------------------------------------- |
//-------------------------------------- |
547 |
|
void TrkSinglet::Clear(){ |
548 |
|
// cout << "TrkSinglet::Clear() " << GetUniqueID()<<endl; |
549 |
|
// cls=0; |
550 |
|
plane=-1; |
551 |
|
coord[0]=-999; |
552 |
|
coord[1]=-999; |
553 |
|
sgnl=0; |
554 |
|
|
555 |
|
} |
556 |
|
//-------------------------------------- |
557 |
|
// |
558 |
|
// |
559 |
|
//-------------------------------------- |
560 |
TrkLevel2::TrkLevel2(){ |
TrkLevel2::TrkLevel2(){ |
561 |
good2 = -1; |
// cout <<"TrkLevel2::TrkLevel2()"<<endl; |
562 |
for(Int_t i=0; i<12 ; i++){ |
for(Int_t i=0; i<12 ; i++){ |
563 |
crc[i] = -1; |
good[i] = -1; |
564 |
}; |
}; |
565 |
Track = new TClonesArray("TrkTrack"); |
// okkio!! memory-leak |
566 |
SingletX = new TClonesArray("TrkSinglet"); |
// Track = new TClonesArray("TrkTrack"); |
567 |
SingletY = new TClonesArray("TrkSinglet"); |
// SingletX = new TClonesArray("TrkSinglet"); |
568 |
|
// SingletY = new TClonesArray("TrkSinglet"); |
569 |
|
Track = 0; |
570 |
|
SingletX = 0; |
571 |
|
SingletY = 0; |
572 |
|
|
573 |
|
} |
574 |
|
//-------------------------------------- |
575 |
|
// |
576 |
|
// |
577 |
|
//-------------------------------------- |
578 |
|
void TrkLevel2::Set(){ |
579 |
|
if(!Track)Track = new TClonesArray("TrkTrack"); |
580 |
|
if(!SingletX)SingletX = new TClonesArray("TrkSinglet"); |
581 |
|
if(!SingletY)SingletY = new TClonesArray("TrkSinglet"); |
582 |
} |
} |
583 |
//-------------------------------------- |
//-------------------------------------- |
584 |
// |
// |
585 |
// |
// |
586 |
//-------------------------------------- |
//-------------------------------------- |
587 |
void TrkLevel2::Dump(){ |
void TrkLevel2::Dump(){ |
588 |
TClonesArray &t = *Track; |
|
589 |
TClonesArray &sx = *SingletX; |
// |
|
TClonesArray &sy = *SingletY; |
|
|
|
|
590 |
cout << endl << endl << "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"; |
cout << endl << endl << "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"; |
591 |
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]; |
|
592 |
cout << endl << "ntrk() : " << this->ntrk() ; |
cout << endl << "ntrk() : " << this->ntrk() ; |
593 |
cout << endl << "nclsx() : " << this->nclsx(); |
cout << endl << "nclsx() : " << this->nclsx(); |
594 |
cout << endl << "nclsy() : " << this->nclsy(); |
cout << endl << "nclsy() : " << this->nclsy(); |
595 |
for(int i=0; i<this->ntrk(); i++) ((TrkTrack *)t[i])->Dump(); |
// TClonesArray &t = *Track; |
596 |
for(int i=0; i<this->nclsx(); i++) ((TrkSinglet *)sx[i])->Dump(); |
// TClonesArray &sx = *SingletX; |
597 |
for(int i=0; i<this->nclsy(); i++) ((TrkSinglet *)sy[i])->Dump(); |
// TClonesArray &sy = *SingletY; |
598 |
|
// for(int i=0; i<ntrk(); i++) ((TrkTrack *)t[i])->Dump(); |
599 |
|
// for(int i=0; i<nclsx(); i++) ((TrkSinglet *)sx[i])->Dump(); |
600 |
|
// for(int i=0; i<nclsy(); i++) ((TrkSinglet *)sy[i])->Dump(); |
601 |
|
if(Track){ |
602 |
|
TClonesArray &t = *Track; |
603 |
|
for(int i=0; i<ntrk(); i++) ((TrkTrack *)t[i])->Dump(); |
604 |
|
} |
605 |
|
if(SingletX){ |
606 |
|
TClonesArray &sx = *SingletX; |
607 |
|
for(int i=0; i<nclsx(); i++) ((TrkSinglet *)sx[i])->Dump(); |
608 |
|
} |
609 |
|
if(SingletY){ |
610 |
|
TClonesArray &sy = *SingletY; |
611 |
|
for(int i=0; i<nclsy(); i++) ((TrkSinglet *)sy[i])->Dump(); |
612 |
|
} |
613 |
} |
} |
614 |
//-------------------------------------- |
//-------------------------------------- |
615 |
// |
// |
618 |
/** |
/** |
619 |
* 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). |
620 |
*/ |
*/ |
621 |
void TrkLevel2::FillCommonVar(cTrkLevel2 *l2){ |
// void TrkLevel2::SetFromLevel2Struct(cTrkLevel2 *l2){ |
622 |
|
|
623 |
|
// // temporary objects: |
624 |
|
// TrkSinglet* t_singlet = new TrkSinglet(); |
625 |
|
// TrkTrack* t_track = new TrkTrack(); |
626 |
|
|
627 |
|
// // **** general variables **** |
628 |
|
// // good2 = l2->good2; |
629 |
|
// for(Int_t i=0; i<12 ; i++){ |
630 |
|
// // crc[i] = l2->crc[i]; |
631 |
|
// good[i] = l2->good[i]; |
632 |
|
// }; |
633 |
|
// // *** TRACKS *** |
634 |
|
// if(!Track) Track = new TClonesArray("TrkTrack"); |
635 |
|
// TClonesArray &t = *Track; |
636 |
|
// for(int i=0; i<l2->ntrk; i++){ |
637 |
|
// t_track->seqno = i;// NBNBNBNB deve sempre essere = i |
638 |
|
// t_track->image = l2->image[i]-1; |
639 |
|
// // cout << "track "<<i<<t_track->seqno << t_track->image<<endl; |
640 |
|
// t_track->chi2 = l2->chi2_nt[i]; |
641 |
|
// t_track->nstep = l2->nstep_nt[i]; |
642 |
|
// for(int it1=0;it1<5;it1++){ |
643 |
|
// t_track->al[it1] = l2->al_nt[i][it1]; |
644 |
|
// for(int it2=0;it2<5;it2++) |
645 |
|
// t_track->coval[it1][it2] = l2->coval[i][it2][it1]; |
646 |
|
// }; |
647 |
|
// for(int ip=0;ip<6;ip++){ |
648 |
|
// t_track->xgood[ip] = l2->xgood_nt[i][ip]; |
649 |
|
// t_track->ygood[ip] = l2->ygood_nt[i][ip]; |
650 |
|
// t_track->xm[ip] = l2->xm_nt[i][ip]; |
651 |
|
// t_track->ym[ip] = l2->ym_nt[i][ip]; |
652 |
|
// t_track->zm[ip] = l2->zm_nt[i][ip]; |
653 |
|
// t_track->resx[ip] = l2->resx_nt[i][ip]; |
654 |
|
// t_track->resy[ip] = l2->resy_nt[i][ip]; |
655 |
|
// t_track->xv[ip] = l2->xv_nt[i][ip]; |
656 |
|
// t_track->yv[ip] = l2->yv_nt[i][ip]; |
657 |
|
// t_track->zv[ip] = l2->zv_nt[i][ip]; |
658 |
|
// t_track->axv[ip] = l2->axv_nt[i][ip]; |
659 |
|
// t_track->ayv[ip] = l2->ayv_nt[i][ip]; |
660 |
|
// t_track->dedx_x[ip] = l2->dedx_x[i][ip]; |
661 |
|
// t_track->dedx_y[ip] = l2->dedx_y[i][ip]; |
662 |
|
// // t_track->clx[ip] = 0; |
663 |
|
// // t_track->cly[ip] = 0; |
664 |
|
// }; |
665 |
|
// new(t[i]) TrkTrack(*t_track); |
666 |
|
// t_track->Clear(); |
667 |
|
// }; |
668 |
|
// // *** SINGLETS *** |
669 |
|
// if(!SingletX)SingletX = new TClonesArray("TrkSinglet"); |
670 |
|
// TClonesArray &sx = *SingletX; |
671 |
|
// for(int i=0; i<l2->nclsx; i++){ |
672 |
|
// t_singlet->plane = l2->planex[i]; |
673 |
|
// t_singlet->coord[0] = l2->xs[i][0]; |
674 |
|
// t_singlet->coord[1] = l2->xs[i][1]; |
675 |
|
// t_singlet->sgnl = l2->signlxs[i]; |
676 |
|
// // t_singlet->cls = 0; |
677 |
|
// new(sx[i]) TrkSinglet(*t_singlet); |
678 |
|
// t_singlet->Clear(); |
679 |
|
// } |
680 |
|
// if(!SingletY)SingletY = new TClonesArray("TrkSinglet"); |
681 |
|
// TClonesArray &sy = *SingletY; |
682 |
|
// for(int i=0; i<l2->nclsy; i++){ |
683 |
|
// t_singlet->plane = l2->planey[i]; |
684 |
|
// t_singlet->coord[0] = l2->ys[i][0]; |
685 |
|
// t_singlet->coord[1] = l2->ys[i][1]; |
686 |
|
// t_singlet->sgnl = l2->signlys[i]; |
687 |
|
// // t_singlet->cls = 0; |
688 |
|
// new(sy[i]) TrkSinglet(*t_singlet); |
689 |
|
// t_singlet->Clear(); |
690 |
|
// }; |
691 |
|
|
692 |
|
// delete t_track; |
693 |
|
// delete t_singlet; |
694 |
|
// } |
695 |
|
//-------------------------------------- |
696 |
|
// |
697 |
|
// |
698 |
|
//-------------------------------------- |
699 |
|
/** |
700 |
|
* Fills a TrkLevel2 object with values from a struct cTrkLevel2 (to get data from F77 common). |
701 |
|
* Ref to Level1 data (clusters) is also set. |
702 |
|
*/ |
703 |
|
void TrkLevel2::SetFromLevel2Struct(cTrkLevel2 *l2, TrkLevel1 *l1){ |
704 |
|
|
705 |
// temporary objects: |
// temporary objects: |
706 |
TrkSinglet* t_singlet = new TrkSinglet(); |
TrkSinglet* t_singlet = new TrkSinglet(); |
707 |
TrkTrack* t_track = new TrkTrack(); |
TrkTrack* t_track = new TrkTrack(); |
708 |
|
// general variables |
709 |
|
// good2 = l2->good2; |
710 |
|
for(Int_t i=0; i<12 ; i++){ |
711 |
|
// crc[i] = l2->crc[i]; |
712 |
|
good[i] = l2->good[i]; |
713 |
|
}; |
714 |
|
// *** TRACKS *** |
715 |
|
if(!Track) Track = new TClonesArray("TrkTrack"); |
716 |
|
TClonesArray &t = *Track; |
717 |
|
//----------------------------------------------------- |
718 |
|
if(l1 && !t_track->clx)t_track->clx = new TRefArray(6,0); |
719 |
|
if(l1 && !t_track->cly)t_track->cly = new TRefArray(6,0); |
720 |
|
//----------------------------------------------------- |
721 |
|
for(int i=0; i<l2->ntrk; i++){ |
722 |
|
t_track->seqno = i;// NBNBNBNB deve sempre essere = i |
723 |
|
t_track->image = l2->image[i]-1; |
724 |
|
// cout << "track "<<i<<t_track->seqno << t_track->image<<endl; |
725 |
|
t_track->chi2 = l2->chi2_nt[i]; |
726 |
|
t_track->nstep = l2->nstep_nt[i]; |
727 |
|
for(int it1=0;it1<5;it1++){ |
728 |
|
t_track->al[it1] = l2->al_nt[i][it1]; |
729 |
|
for(int it2=0;it2<5;it2++) |
730 |
|
t_track->coval[it1][it2] = l2->coval[i][it2][it1]; |
731 |
|
}; |
732 |
|
for(int ip=0;ip<6;ip++){ |
733 |
|
t_track->xgood[ip] = l2->xgood_nt[i][ip]; |
734 |
|
t_track->ygood[ip] = l2->ygood_nt[i][ip]; |
735 |
|
t_track->xm[ip] = l2->xm_nt[i][ip]; |
736 |
|
t_track->ym[ip] = l2->ym_nt[i][ip]; |
737 |
|
t_track->zm[ip] = l2->zm_nt[i][ip]; |
738 |
|
t_track->resx[ip] = l2->resx_nt[i][ip]; |
739 |
|
t_track->resy[ip] = l2->resy_nt[i][ip]; |
740 |
|
t_track->xv[ip] = l2->xv_nt[i][ip]; |
741 |
|
t_track->yv[ip] = l2->yv_nt[i][ip]; |
742 |
|
t_track->zv[ip] = l2->zv_nt[i][ip]; |
743 |
|
t_track->axv[ip] = l2->axv_nt[i][ip]; |
744 |
|
t_track->ayv[ip] = l2->ayv_nt[i][ip]; |
745 |
|
t_track->dedx_x[ip] = l2->dedx_x[i][ip]; |
746 |
|
t_track->dedx_y[ip] = l2->dedx_y[i][ip]; |
747 |
|
//----------------------------------------------------- |
748 |
|
//----------------------------------------------------- |
749 |
|
if(l1 && t_track->xgood[ip])t_track->clx->AddAt(l1->GetCluster(l2->cltrx[i][ip]-1),ip); |
750 |
|
if(l1 && t_track->ygood[ip])t_track->cly->AddAt(l1->GetCluster(l2->cltry[i][ip]-1),ip); |
751 |
|
//----------------------------------------------------- |
752 |
|
//----------------------------------------------------- |
753 |
|
}; |
754 |
|
new(t[i]) TrkTrack(*t_track); |
755 |
|
t_track->Clear(); |
756 |
|
}; |
757 |
|
// *** SINGLETS *** |
758 |
|
if(!SingletX)SingletX = new TClonesArray("TrkSinglet"); |
759 |
|
TClonesArray &sx = *SingletX; |
760 |
|
for(int i=0; i<l2->nclsx; i++){ |
761 |
|
t_singlet->plane = l2->planex[i]; |
762 |
|
t_singlet->coord[0] = l2->xs[i][0]; |
763 |
|
t_singlet->coord[1] = l2->xs[i][1]; |
764 |
|
t_singlet->sgnl = l2->signlxs[i]; |
765 |
|
//----------------------------------------------------- |
766 |
|
if(l1) t_singlet->cls = l1->GetCluster(l2->clsx[i]-1); |
767 |
|
//----------------------------------------------------- |
768 |
|
new(sx[i]) TrkSinglet(*t_singlet); |
769 |
|
t_singlet->Clear(); |
770 |
|
} |
771 |
|
if(!SingletY)SingletY = new TClonesArray("TrkSinglet"); |
772 |
|
TClonesArray &sy = *SingletY; |
773 |
|
for(int i=0; i<l2->nclsy; i++){ |
774 |
|
t_singlet->plane = l2->planey[i]; |
775 |
|
t_singlet->coord[0] = l2->ys[i][0]; |
776 |
|
t_singlet->coord[1] = l2->ys[i][1]; |
777 |
|
t_singlet->sgnl = l2->signlys[i]; |
778 |
|
//----------------------------------------------------- |
779 |
|
if(l1) t_singlet->cls = l1->GetCluster(l2->clsy[i]-1); |
780 |
|
//----------------------------------------------------- |
781 |
|
new(sy[i]) TrkSinglet(*t_singlet); |
782 |
|
t_singlet->Clear(); |
783 |
|
}; |
784 |
|
|
785 |
|
delete t_track; |
786 |
|
delete t_singlet; |
787 |
|
} |
788 |
|
/** |
789 |
|
* Fills a struct cTrkLevel2 with values from a TrkLevel2 object (to put data into a F77 common). |
790 |
|
*/ |
791 |
|
|
792 |
|
void TrkLevel2::GetLevel2Struct(cTrkLevel2 *l2) const { |
793 |
|
|
794 |
// general variables |
// general variables |
795 |
good2 = l2->good2; |
// l2->good2 = good2 ; |
796 |
for(Int_t i=0; i<12 ; i++){ |
for(Int_t i=0; i<12 ; i++){ |
797 |
crc[i] = l2->crc[i]; |
// l2->crc[i] = crc[i]; |
798 |
|
l2->good[i] = good[i]; |
799 |
}; |
}; |
800 |
// *** TRACKS *** |
// *** TRACKS *** |
801 |
TClonesArray &t = *Track; |
|
802 |
for(int i=0; i<l2->ntrk; i++){ |
if(Track){ |
803 |
t_track->image = l2->image[i]-1; |
l2->ntrk = Track->GetEntries(); |
804 |
t_track->chi2 = l2->chi2_nt[i]; |
for(Int_t i=0;i<l2->ntrk;i++){ |
805 |
for(int it1=0;it1<5;it1++){ |
l2->image[i] = 1 + ((TrkTrack *)Track->At(i))->image; |
806 |
t_track->al[it1] = l2->al_nt[i][it1]; |
l2->chi2_nt[i] = ((TrkTrack *)Track->At(i))->chi2; |
807 |
for(int it2=0;it2<5;it2++) |
l2->nstep_nt[i] = ((TrkTrack *)Track->At(i))->nstep; |
808 |
t_track->coval[it1][it2] = l2->coval[i][it2][it1]; |
for(int it1=0;it1<5;it1++){ |
809 |
}; |
l2->al_nt[i][it1] = ((TrkTrack *)Track->At(i))->al[it1]; |
810 |
for(int ip=0;ip<6;ip++){ |
for(int it2=0;it2<5;it2++) |
811 |
t_track->xgood[ip] = l2->xgood_nt[i][ip]; |
l2->coval[i][it2][it1] = ((TrkTrack *)Track->At(i))->coval[it1][it2]; |
812 |
t_track->ygood[ip] = l2->ygood_nt[i][ip]; |
}; |
813 |
t_track->xm[ip] = l2->xm_nt[i][ip]; |
for(int ip=0;ip<6;ip++){ |
814 |
t_track->ym[ip] = l2->ym_nt[i][ip]; |
l2->xgood_nt[i][ip] = ((TrkTrack *)Track->At(i))->xgood[ip]; |
815 |
t_track->zm[ip] = l2->zm_nt[i][ip]; |
l2->ygood_nt[i][ip] = ((TrkTrack *)Track->At(i))->ygood[ip]; |
816 |
t_track->resx[ip] = l2->resx_nt[i][ip]; |
l2->xm_nt[i][ip] = ((TrkTrack *)Track->At(i))->xm[ip]; |
817 |
t_track->resy[ip] = l2->resy_nt[i][ip]; |
l2->ym_nt[i][ip] = ((TrkTrack *)Track->At(i))->ym[ip]; |
818 |
t_track->xv[ip] = l2->xv_nt[i][ip]; |
l2->zm_nt[i][ip] = ((TrkTrack *)Track->At(i))->zm[ip]; |
819 |
t_track->yv[ip] = l2->yv_nt[i][ip]; |
l2->resx_nt[i][ip] = ((TrkTrack *)Track->At(i))->resx[ip]; |
820 |
t_track->zv[ip] = l2->zv_nt[i][ip]; |
l2->resy_nt[i][ip] = ((TrkTrack *)Track->At(i))->resy[ip]; |
821 |
t_track->axv[ip] = l2->axv_nt[i][ip]; |
l2->xv_nt[i][ip] = ((TrkTrack *)Track->At(i))->xv[ip]; |
822 |
t_track->ayv[ip] = l2->ayv_nt[i][ip]; |
l2->yv_nt[i][ip] = ((TrkTrack *)Track->At(i))->yv[ip]; |
823 |
t_track->dedx_x[ip] = l2->dedx_x[i][ip]; |
l2->zv_nt[i][ip] = ((TrkTrack *)Track->At(i))->zv[ip]; |
824 |
t_track->dedx_y[ip] = l2->dedx_y[i][ip]; |
l2->axv_nt[i][ip] = ((TrkTrack *)Track->At(i))->axv[ip]; |
825 |
}; |
l2->ayv_nt[i][ip] = ((TrkTrack *)Track->At(i))->ayv[ip]; |
826 |
new(t[i]) TrkTrack(*t_track); |
l2->dedx_x[i][ip] = ((TrkTrack *)Track->At(i))->dedx_x[ip]; |
827 |
t_track->Clear(); |
l2->dedx_y[i][ip] = ((TrkTrack *)Track->At(i))->dedx_y[ip]; |
828 |
}; |
}; |
829 |
// *** SINGLETS *** |
} |
830 |
TClonesArray &sx = *SingletX; |
} |
831 |
for(int i=0; i<l2->nclsx; i++){ |
// *** SINGLETS *** |
832 |
t_singlet->plane = l2->planex[i]; |
if(SingletX){ |
833 |
t_singlet->coord[0] = l2->xs[i][0]; |
l2->nclsx = SingletX->GetEntries(); |
834 |
t_singlet->coord[1] = l2->xs[i][1]; |
for(Int_t i=0;i<l2->nclsx;i++){ |
835 |
t_singlet->sgnl = l2->signlxs[i]; |
l2->planex[i] = ((TrkSinglet *)SingletX->At(i))->plane; |
836 |
new(sx[i]) TrkSinglet(*t_singlet); |
l2->xs[i][0] = ((TrkSinglet *)SingletX->At(i))->coord[0]; |
837 |
t_singlet->Clear(); |
l2->xs[i][1] = ((TrkSinglet *)SingletX->At(i))->coord[1]; |
838 |
} |
l2->signlxs[i] = ((TrkSinglet *)SingletX->At(i))->sgnl; |
839 |
TClonesArray &sy = *SingletY; |
} |
840 |
for(int i=0; i<l2->nclsy; i++){ |
} |
841 |
t_singlet->plane = l2->planey[i]; |
|
842 |
t_singlet->coord[0] = l2->ys[i][0]; |
if(SingletY){ |
843 |
t_singlet->coord[1] = l2->ys[i][1]; |
l2->nclsy = SingletY->GetEntries(); |
844 |
t_singlet->sgnl = l2->signlys[i]; |
for(Int_t i=0;i<l2->nclsy;i++){ |
845 |
new(sy[i]) TrkSinglet(*t_singlet); |
l2->planey[i] = ((TrkSinglet *)SingletY->At(i))->plane; |
846 |
t_singlet->Clear(); |
l2->ys[i][0] = ((TrkSinglet *)SingletY->At(i))->coord[0]; |
847 |
}; |
l2->ys[i][1] = ((TrkSinglet *)SingletY->At(i))->coord[1]; |
848 |
|
l2->signlys[i] = ((TrkSinglet *)SingletY->At(i))->sgnl; |
849 |
|
} |
850 |
|
} |
851 |
} |
} |
852 |
//-------------------------------------- |
//-------------------------------------- |
853 |
// |
// |
854 |
// |
// |
855 |
//-------------------------------------- |
//-------------------------------------- |
856 |
void TrkLevel2::Clear(){ |
void TrkLevel2::Clear(){ |
|
good2 = -1; |
|
857 |
for(Int_t i=0; i<12 ; i++){ |
for(Int_t i=0; i<12 ; i++){ |
858 |
crc[i] = -1; |
good[i] = -1; |
859 |
}; |
}; |
860 |
Track->RemoveAll(); |
// if(Track)Track->Clear("C"); |
861 |
SingletX->RemoveAll(); |
// if(SingletX)SingletX->Clear("C"); |
862 |
SingletY->RemoveAll(); |
// if(SingletY)SingletY->Clear("C"); |
863 |
|
if(Track)Track->Delete(); |
864 |
|
if(SingletX)SingletX->Delete(); |
865 |
|
if(SingletY)SingletY->Delete(); |
866 |
|
} |
867 |
|
// //-------------------------------------- |
868 |
|
// // |
869 |
|
// // |
870 |
|
// //-------------------------------------- |
871 |
|
void TrkLevel2::Delete(){ |
872 |
|
|
873 |
|
// cout << "void TrkLevel2::Delete()"<<endl; |
874 |
|
Clear(); |
875 |
|
if(Track)delete Track; |
876 |
|
if(SingletX)delete SingletX; |
877 |
|
if(SingletY)delete SingletY; |
878 |
|
|
879 |
} |
} |
880 |
//-------------------------------------- |
//-------------------------------------- |
881 |
// |
// |
885 |
* 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). |
886 |
* 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. |
887 |
*/ |
*/ |
888 |
TClonesArray *TrkLevel2::GetTracks(){ |
TRefArray *TrkLevel2::GetTracks_NFitSorted(){ |
889 |
|
|
890 |
TClonesArray *sorted = new TClonesArray("TrkTrack"); |
if(!Track)return 0; |
|
TClonesArray &t = *Track; |
|
|
TClonesArray &ts = *sorted; |
|
|
int N=this->ntrk(); |
|
|
vector<int> m(N); for(int i=0; i<N; i++)m[i]=1; |
|
891 |
|
|
892 |
|
TRefArray *sorted = new TRefArray(); |
893 |
|
|
894 |
|
TClonesArray &t = *Track; |
895 |
|
// TClonesArray &ts = *PhysicalTrack; |
896 |
|
int N = ntrk(); |
897 |
|
vector<int> m(N); for(int i=0; i<N; i++)m[i]=1; |
898 |
|
// int m[50]; for(int i=0; i<N; i++)m[i]=1; |
899 |
|
|
900 |
int indo=0; |
int indo=0; |
901 |
int indi=0; |
int indi=0; |
902 |
while(N != 0){ |
while(N > 0){ |
903 |
float chi2ref=1000000; |
// while(N != 0){ |
904 |
for(int i=0; i<this->ntrk(); i++){ |
int nfit =0; |
905 |
if(((TrkTrack *)t[i])->chi2 < chi2ref && m[i]==1){ |
float chi2ref = numeric_limits<float>::max(); |
906 |
chi2ref = ((TrkTrack *)t[i])->chi2; |
|
907 |
indi = i; |
// first loop to search maximum num. of fit points |
908 |
|
for(int i=0; i < ntrk(); i++){ |
909 |
|
if( ((TrkTrack *)t[i])->GetNtot() >= nfit && m[i]==1){ |
910 |
|
nfit = ((TrkTrack *)t[i])->GetNtot(); |
911 |
} |
} |
912 |
} |
} |
913 |
if( ((TrkTrack *)t[indi])->image != -1 ){ |
//second loop to search minimum chi2 among selected |
914 |
|
for(int i=0; i<ntrk(); i++){ |
915 |
|
Float_t chi2 = ((TrkTrack *)t[i])->chi2; |
916 |
|
if(chi2 < 0) chi2 = -chi2*1000; |
917 |
|
if( chi2 < chi2ref |
918 |
|
&& ((TrkTrack *)t[i])->GetNtot() == nfit |
919 |
|
&& m[i]==1){ |
920 |
|
chi2ref = ((TrkTrack *)t[i])->chi2; |
921 |
|
indi = i; |
922 |
|
}; |
923 |
|
}; |
924 |
|
if( ((TrkTrack *)t[indi])->HasImage() ){ |
925 |
m[((TrkTrack *)t[indi])->image] = 0; |
m[((TrkTrack *)t[indi])->image] = 0; |
926 |
N--; |
N--; |
927 |
} |
|
928 |
new(ts[indo]) TrkTrack(*(TrkTrack*)t[indi]); |
// cout << "i** "<< ((TrkTrack *)t[indi])->image << " " << nfiti <<" "<<chi2i<<endl; |
929 |
|
}; |
930 |
|
sorted->Add( (TrkTrack*)t[indi] ); |
931 |
|
|
932 |
m[indi] = 0; |
m[indi] = 0; |
933 |
|
// cout << "SORTED "<< indo << " "<< indi << " "<< N << " "<<((TrkTrack *)t[indi])->image<<" "<<chi2ref<<endl; |
934 |
N--; |
N--; |
935 |
indo++; |
indo++; |
936 |
} |
} |
937 |
|
m.clear(); |
938 |
|
// cout << "GetTracks_NFitSorted(it): Done"<< endl; |
939 |
|
|
940 |
return sorted; |
return sorted; |
941 |
|
// return PhysicalTrack; |
942 |
} |
} |
943 |
//-------------------------------------- |
//-------------------------------------- |
944 |
// |
// |
956 |
cout << " Stored tracks ntrk() = "<< this->ntrk() << endl; |
cout << " Stored tracks ntrk() = "<< this->ntrk() << endl; |
957 |
return 0; |
return 0; |
958 |
} |
} |
959 |
|
if(!Track){ |
960 |
|
cout << "TrkTrack *TrkLevel2::GetStoredTrack(int is) >> (TClonesArray*) Track ==0 "<<endl; |
961 |
|
}; |
962 |
TClonesArray &t = *(Track); |
TClonesArray &t = *(Track); |
963 |
TrkTrack *track = (TrkTrack*)t[is]; |
TrkTrack *track = (TrkTrack*)t[is]; |
964 |
return track; |
return track; |
968 |
// |
// |
969 |
//-------------------------------------- |
//-------------------------------------- |
970 |
/** |
/** |
971 |
|
* Retrieves the is-th stored X singlet. |
972 |
|
* @param it Singlet number, ranging from 0 to nclsx(). |
973 |
|
*/ |
974 |
|
TrkSinglet *TrkLevel2::GetSingletX(int is){ |
975 |
|
|
976 |
|
if(is >= this->nclsx()){ |
977 |
|
cout << "** TrkLevel2 ** Singlet "<< is << "doen not exits! " << endl; |
978 |
|
cout << " Stored x-singlets nclsx() = "<< this->nclsx() << endl; |
979 |
|
return 0; |
980 |
|
} |
981 |
|
if(!SingletX)return 0; |
982 |
|
TClonesArray &t = *(SingletX); |
983 |
|
TrkSinglet *singlet = (TrkSinglet*)t[is]; |
984 |
|
return singlet; |
985 |
|
} |
986 |
|
//-------------------------------------- |
987 |
|
// |
988 |
|
// |
989 |
|
//-------------------------------------- |
990 |
|
/** |
991 |
|
* Retrieves the is-th stored Y singlet. |
992 |
|
* @param it Singlet number, ranging from 0 to nclsx(). |
993 |
|
*/ |
994 |
|
TrkSinglet *TrkLevel2::GetSingletY(int is){ |
995 |
|
|
996 |
|
if(is >= this->nclsy()){ |
997 |
|
cout << "** TrkLevel2 ** Singlet "<< is << "doen not exits! " << endl; |
998 |
|
cout << " Stored y-singlets nclsy() = "<< this->nclsx() << endl; |
999 |
|
return 0; |
1000 |
|
} |
1001 |
|
if(!SingletY)return 0; |
1002 |
|
TClonesArray &t = *(SingletY); |
1003 |
|
TrkSinglet *singlet = (TrkSinglet*)t[is]; |
1004 |
|
return singlet; |
1005 |
|
} |
1006 |
|
//-------------------------------------- |
1007 |
|
// |
1008 |
|
// |
1009 |
|
//-------------------------------------- |
1010 |
|
/** |
1011 |
* Retrieves the it-th "physical" track, sorted by the method GetNTracks(). |
* Retrieves the it-th "physical" track, sorted by the method GetNTracks(). |
1012 |
* @param it Track number, ranging from 0 to GetNTracks(). |
* @param it Track number, ranging from 0 to GetNTracks(). |
1013 |
*/ |
*/ |
1014 |
|
|
1015 |
TrkTrack *TrkLevel2::GetTrack(int it){ |
TrkTrack *TrkLevel2::GetTrack(int it){ |
1016 |
|
|
1017 |
if(it >= this->GetNTracks()){ |
if(it >= this->GetNTracks()){ |
1018 |
cout << "** TrkLevel2 ** Track "<< it << "does not exits! " << endl; |
cout << "** TrkLevel2 ** Track "<< it << "does not exits! " << endl; |
1019 |
cout << " Physical tracks GetNTracks() = "<< this->ntrk() << endl; |
cout << " Physical tracks GetNTracks() = "<< this->ntrk() << endl; |
1020 |
return 0; |
return 0; |
1021 |
} |
} |
1022 |
TrkTrack *track = (TrkTrack*)(*(this->GetTracks()))[it]; |
|
1023 |
return track; |
TRefArray *sorted = GetTracks(); //TEMPORANEO |
1024 |
|
if(!sorted)return 0; |
1025 |
|
TrkTrack *track = (TrkTrack*)sorted->At(it); |
1026 |
|
sorted->Clear(); |
1027 |
|
delete sorted; |
1028 |
|
return track; |
1029 |
} |
} |
1030 |
|
/** |
1031 |
|
* Give the number of "physical" tracks, sorted by the method GetTracks(). |
1032 |
|
*/ |
1033 |
|
Int_t TrkLevel2::GetNTracks(){ |
1034 |
|
|
1035 |
|
Float_t ntot=0; |
1036 |
|
if(!Track)return 0; |
1037 |
|
TClonesArray &t = *Track; |
1038 |
|
for(int i=0; i<ntrk(); i++) { |
1039 |
|
if( ((TrkTrack *)t[i])->GetImageSeqNo() == -1 ) ntot+=1.; |
1040 |
|
else ntot+=0.5; |
1041 |
|
} |
1042 |
|
return (Int_t)ntot; |
1043 |
|
|
1044 |
|
}; |
1045 |
//-------------------------------------- |
//-------------------------------------- |
1046 |
// |
// |
1047 |
// |
// |
1057 |
cout << " Physical tracks GetNTracks() = "<< this->ntrk() << endl; |
cout << " Physical tracks GetNTracks() = "<< this->ntrk() << endl; |
1058 |
return 0; |
return 0; |
1059 |
} |
} |
1060 |
TrkTrack *track = (TrkTrack*)(*(this->GetTracks()))[it]; |
|
1061 |
|
TRefArray* sorted = GetTracks(); //TEMPORANEO |
1062 |
|
if(!sorted)return 0; |
1063 |
|
TrkTrack *track = (TrkTrack*)sorted->At(it); |
1064 |
|
|
1065 |
if(!track->HasImage()){ |
if(!track->HasImage()){ |
1066 |
cout << "** TrkLevel2 ** Track "<< it << "does not have image! " << endl; |
cout << "** TrkLevel2 ** Track "<< it << "does not have image! " << endl; |
1067 |
return 0; |
return 0; |
1068 |
} |
} |
1069 |
|
if(!Track)return 0; |
1070 |
TrkTrack *image = (TrkTrack*)(*Track)[track->image]; |
TrkTrack *image = (TrkTrack*)(*Track)[track->image]; |
1071 |
|
|
1072 |
|
sorted->Delete(); |
1073 |
|
delete sorted; |
1074 |
|
|
1075 |
return image; |
return image; |
1076 |
|
|
1077 |
} |
} |
1083 |
* Loads the magnetic field. |
* Loads the magnetic field. |
1084 |
* @param s Path of the magnetic-field files. |
* @param s Path of the magnetic-field files. |
1085 |
*/ |
*/ |
1086 |
void TrkLevel2::LoadField(TString s){ |
void TrkLevel2::LoadField(TString path){ |
1087 |
readb_(s.Data()); |
// |
1088 |
|
// strcpy(path_.path,path.Data()); |
1089 |
|
// path_.pathlen = path.Length(); |
1090 |
|
// path_.error = 0; |
1091 |
|
// readb_(); |
1092 |
|
|
1093 |
|
TrkParams::Set(path,1); |
1094 |
|
|
1095 |
|
// |
1096 |
}; |
}; |
1097 |
|
/** |
1098 |
|
* Get BY (kGauss) |
1099 |
|
* @param v (x,y,z) coordinates in cm |
1100 |
|
*/ |
1101 |
|
float TrkLevel2::GetBX(float* v){ |
1102 |
|
float b[3]; |
1103 |
|
gufld_(v,b); |
1104 |
|
return b[0]/10.; |
1105 |
|
} |
1106 |
|
/** |
1107 |
|
* Get BY (kGauss) |
1108 |
|
* @param v (x,y,z) coordinates in cm |
1109 |
|
*/ |
1110 |
|
float TrkLevel2::GetBY(float* v){ |
1111 |
|
float b[3]; |
1112 |
|
gufld_(v,b); |
1113 |
|
return b[1]/10.; |
1114 |
|
} |
1115 |
|
/** |
1116 |
|
* Get BY (kGauss) |
1117 |
|
* @param v (x,y,z) coordinates in cm |
1118 |
|
*/ |
1119 |
|
float TrkLevel2::GetBZ(float* v){ |
1120 |
|
float b[3]; |
1121 |
|
gufld_(v,b); |
1122 |
|
return b[2]/10.; |
1123 |
|
} |
1124 |
|
//-------------------------------------- |
1125 |
|
// |
1126 |
|
// |
1127 |
|
//-------------------------------------- |
1128 |
|
/** |
1129 |
|
* Get tracker-plane (mechanical) z-coordinate |
1130 |
|
* @param plane_id plane index (1=TOP,2,3,4,5,6=BOTTOM) |
1131 |
|
*/ |
1132 |
|
Float_t TrkLevel2::GetZTrk(Int_t plane_id){ |
1133 |
|
switch(plane_id){ |
1134 |
|
case 1: return ZTRK1; |
1135 |
|
case 2: return ZTRK2; |
1136 |
|
case 3: return ZTRK3; |
1137 |
|
case 4: return ZTRK4; |
1138 |
|
case 5: return ZTRK5; |
1139 |
|
case 6: return ZTRK6; |
1140 |
|
default: return 0.; |
1141 |
|
}; |
1142 |
|
}; |
1143 |
|
//-------------------------------------- |
1144 |
|
// |
1145 |
|
// |
1146 |
|
//-------------------------------------- |
1147 |
|
/** |
1148 |
|
* Trajectory default constructor. |
1149 |
|
* (By default is created with z-coordinates inside the tracking volume) |
1150 |
|
*/ |
1151 |
|
Trajectory::Trajectory(){ |
1152 |
|
npoint = 10; |
1153 |
|
x = new float[npoint]; |
1154 |
|
y = new float[npoint]; |
1155 |
|
z = new float[npoint]; |
1156 |
|
thx = new float[npoint]; |
1157 |
|
thy = new float[npoint]; |
1158 |
|
tl = new float[npoint]; |
1159 |
|
float dz = ((ZTRK1)-(ZTRK6))/(npoint-1); |
1160 |
|
for(int i=0; i<npoint; i++){ |
1161 |
|
x[i] = 0; |
1162 |
|
y[i] = 0; |
1163 |
|
z[i] = (ZTRK1) - i*dz; |
1164 |
|
thx[i] = 0; |
1165 |
|
thy[i] = 0; |
1166 |
|
tl[i] = 0; |
1167 |
|
} |
1168 |
|
} |
1169 |
//-------------------------------------- |
//-------------------------------------- |
1170 |
// |
// |
1171 |
// |
// |
1172 |
//-------------------------------------- |
//-------------------------------------- |
1173 |
/** |
/** |
1174 |
* Trajectory constructor. |
* Trajectory constructor. |
1175 |
|
* (By default is created with z-coordinates inside the tracking volume) |
1176 |
* \param n Number of points |
* \param n Number of points |
1177 |
*/ |
*/ |
1178 |
Trajectory::Trajectory(int n){ |
Trajectory::Trajectory(int n){ |
1179 |
|
if(n<=0){ |
1180 |
|
cout << "NB! Trajectory must have at least 1 point >>> created with 10 points" << endl; |
1181 |
|
n=10; |
1182 |
|
} |
1183 |
npoint = n; |
npoint = n; |
1184 |
x = new float[npoint]; |
x = new float[npoint]; |
1185 |
y = new float[npoint]; |
y = new float[npoint]; |
1186 |
z = new float[npoint]; |
z = new float[npoint]; |
1187 |
|
thx = new float[npoint]; |
1188 |
|
thy = new float[npoint]; |
1189 |
|
tl = new float[npoint]; |
1190 |
|
float dz = ((ZTRK1)-(ZTRK6))/(npoint-1); |
1191 |
for(int i=0; i<npoint; i++){ |
for(int i=0; i<npoint; i++){ |
1192 |
x[i] = 0; |
x[i] = 0; |
1193 |
y[i] = 0; |
y[i] = 0; |
1194 |
z[i] = 0; |
z[i] = (ZTRK1) - i*dz; |
1195 |
|
thx[i] = 0; |
1196 |
|
thy[i] = 0; |
1197 |
|
tl[i] = 0; |
1198 |
} |
} |
1199 |
} |
} |
1200 |
//-------------------------------------- |
//-------------------------------------- |
1207 |
* \param pz Pointer to float array, defining z coordinates |
* \param pz Pointer to float array, defining z coordinates |
1208 |
*/ |
*/ |
1209 |
Trajectory::Trajectory(int n, float* zin){ |
Trajectory::Trajectory(int n, float* zin){ |
1210 |
npoint = n; |
npoint = 10; |
1211 |
|
if(n>0)npoint = n; |
1212 |
x = new float[npoint]; |
x = new float[npoint]; |
1213 |
y = new float[npoint]; |
y = new float[npoint]; |
1214 |
z = new float[npoint]; |
z = new float[npoint]; |
1215 |
for(int i=0; i<npoint; i++){ |
thx = new float[npoint]; |
1216 |
|
thy = new float[npoint]; |
1217 |
|
tl = new float[npoint]; |
1218 |
|
int i=0; |
1219 |
|
do{ |
1220 |
x[i] = 0; |
x[i] = 0; |
1221 |
y[i] = 0; |
y[i] = 0; |
1222 |
z[i] = zin[i]; |
z[i] = zin[i]; |
1223 |
} |
thx[i] = 0; |
1224 |
|
thy[i] = 0; |
1225 |
|
tl[i] = 0; |
1226 |
|
i++; |
1227 |
|
}while(zin[i-1] > zin[i] && i < npoint); |
1228 |
|
npoint=i; |
1229 |
|
if(npoint != n)cout << "NB! Trajectory created with "<<npoint<<" points"<<endl; |
1230 |
|
} |
1231 |
|
void Trajectory::Delete(){ |
1232 |
|
|
1233 |
|
if(x) delete [] x; |
1234 |
|
if(y) delete [] y; |
1235 |
|
if(z) delete [] z; |
1236 |
|
if(thx) delete [] thx; |
1237 |
|
if(thy) delete [] thy; |
1238 |
|
if(tl) delete [] tl; |
1239 |
|
|
1240 |
} |
} |
1241 |
//-------------------------------------- |
//-------------------------------------- |
1242 |
// |
// |
1248 |
void Trajectory::Dump(){ |
void Trajectory::Dump(){ |
1249 |
cout <<endl<< "Trajectory ========== "<<endl; |
cout <<endl<< "Trajectory ========== "<<endl; |
1250 |
for (int i=0; i<npoint; i++){ |
for (int i=0; i<npoint; i++){ |
1251 |
cout << i <<" >> " << x[i] <<" "<< y[i] <<" "<< z[i] << endl;; |
cout << i <<" >> " << x[i] <<" "<< y[i] <<" "<< z[i] ; |
1252 |
|
cout <<" -- " << thx[i] <<" "<< thy[i] ; |
1253 |
|
cout <<" -- " << tl[i] << endl; |
1254 |
}; |
}; |
1255 |
} |
} |
1256 |
|
//-------------------------------------- |
1257 |
|
// |
1258 |
|
// |
1259 |
|
//-------------------------------------- |
1260 |
|
/** |
1261 |
|
* Get trajectory length between two points |
1262 |
|
* @param ifirst first point (default 0) |
1263 |
|
* @param ilast last point (default npoint) |
1264 |
|
*/ |
1265 |
|
float Trajectory::GetLength(int ifirst, int ilast){ |
1266 |
|
if( ifirst<0 ) ifirst = 0; |
1267 |
|
if( ilast>=npoint) ilast = npoint-1; |
1268 |
|
float l=0; |
1269 |
|
for(int i=ifirst;i<=ilast;i++){ |
1270 |
|
l=l+tl[i]; |
1271 |
|
}; |
1272 |
|
if(z[ilast] > ZINI)l=l-tl[ilast]; |
1273 |
|
if(z[ifirst] < ZINI) l=l-tl[ifirst]; |
1274 |
|
|
1275 |
|
return l; |
1276 |
|
|
1277 |
|
} |
1278 |
|
|
1279 |
|
/** |
1280 |
|
* Evaluates the trajectory in the apparatus associated to the track. |
1281 |
|
* 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. |
1282 |
|
* @param t pointer to an object of the class Trajectory, |
1283 |
|
* which z coordinates should be previously initialized by calling the proper constructor ( Trajectory::Trajectory(int n, float* zin) ). |
1284 |
|
* @return error flag. |
1285 |
|
*/ |
1286 |
|
int Trajectory::DoTrack2(float* al){ |
1287 |
|
|
1288 |
|
double *dxout = new double[npoint]; |
1289 |
|
double *dyout = new double[npoint]; |
1290 |
|
double *dthxout = new double[npoint]; |
1291 |
|
double *dthyout = new double[npoint]; |
1292 |
|
double *dtlout = new double[npoint]; |
1293 |
|
double *dzin = new double[npoint]; |
1294 |
|
double dal[5]; |
1295 |
|
|
1296 |
|
int ifail = 0; |
1297 |
|
|
1298 |
|
for (int i=0; i<5; i++) dal[i] = (double)al[i]; |
1299 |
|
for (int i=0; i<npoint; i++) dzin[i] = (double)z[i]; |
1300 |
|
|
1301 |
|
TrkParams::Load(1); |
1302 |
|
if( !TrkParams::IsLoaded(1) ){ |
1303 |
|
cout << "int Trajectory::DoTrack2(float* al) --- ERROR --- m.field not loaded"<<endl; |
1304 |
|
return 0; |
1305 |
|
} |
1306 |
|
dotrack2_(&(npoint),dzin,dxout,dyout,dthxout,dthyout,dtlout,dal,&ifail); |
1307 |
|
|
1308 |
|
for (int i=0; i<npoint; i++){ |
1309 |
|
x[i] = (float)*dxout++; |
1310 |
|
y[i] = (float)*dyout++; |
1311 |
|
thx[i] = (float)*dthxout++; |
1312 |
|
thy[i] = (float)*dthyout++; |
1313 |
|
tl[i] = (float)*dtlout++; |
1314 |
|
} |
1315 |
|
|
1316 |
|
return ifail; |
1317 |
|
}; |
1318 |
|
|
1319 |
ClassImp(TrkLevel2); |
ClassImp(TrkLevel2); |
1320 |
ClassImp(TrkSinglet); |
ClassImp(TrkSinglet); |