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 |
} |
} |
20 |
//-------------------------------------- |
//-------------------------------------- |
21 |
// |
// |
25 |
seqno = -1; |
seqno = -1; |
26 |
image = -1; |
image = -1; |
27 |
chi2 = 0; |
chi2 = 0; |
28 |
|
nstep = 0; |
29 |
for(int it1=0;it1<5;it1++){ |
for(int it1=0;it1<5;it1++){ |
30 |
al[it1] = 0; |
al[it1] = 0; |
31 |
for(int it2=0;it2<5;it2++) |
for(int it2=0;it2<5;it2++)coval[it1][it2] = 0; |
|
coval[it1][it2] = 0; |
|
32 |
}; |
}; |
33 |
for(int ip=0;ip<6;ip++){ |
for(int ip=0;ip<6;ip++){ |
34 |
xgood[ip] = 0; |
xgood[ip] = 0; |
35 |
ygood[ip] = 0; |
ygood[ip] = 0; |
36 |
xm[ip] = 0; |
xm[ip] = 0; |
37 |
ym[ip] = 0; |
ym[ip] = 0; |
38 |
zm[ip] = 0; |
zm[ip] = 0; |
39 |
resx[ip] = 0; |
resx[ip] = 0; |
40 |
resy[ip] = 0; |
resy[ip] = 0; |
41 |
xv[ip] = 0; |
xv[ip] = 0; |
42 |
yv[ip] = 0; |
yv[ip] = 0; |
43 |
zv[ip] = 0; |
zv[ip] = 0; |
44 |
axv[ip] = 0; |
axv[ip] = 0; |
45 |
ayv[ip] = 0; |
ayv[ip] = 0; |
46 |
dedx_x[ip] = 0; |
dedx_x[ip] = 0; |
47 |
dedx_y[ip] = 0; |
dedx_y[ip] = 0; |
48 |
}; |
// clx[ip] = 0; |
49 |
|
// cly[ip] = 0; |
50 |
|
}; |
51 |
|
clx = new TRefArray(6,0); |
52 |
|
cly = new TRefArray(6,0); |
53 |
}; |
}; |
54 |
//-------------------------------------- |
//-------------------------------------- |
55 |
// |
// |
59 |
seqno = t.seqno; |
seqno = t.seqno; |
60 |
image = t.image; |
image = t.image; |
61 |
chi2 = t.chi2; |
chi2 = t.chi2; |
62 |
|
nstep = t.nstep; |
63 |
for(int it1=0;it1<5;it1++){ |
for(int it1=0;it1<5;it1++){ |
64 |
al[it1] = t.al[it1]; |
al[it1] = t.al[it1]; |
65 |
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]; |
|
66 |
}; |
}; |
67 |
for(int ip=0;ip<6;ip++){ |
for(int ip=0;ip<6;ip++){ |
68 |
xgood[ip] = t.xgood[ip]; |
xgood[ip] = t.xgood[ip]; |
69 |
ygood[ip] = t.ygood[ip]; |
ygood[ip] = t.ygood[ip]; |
70 |
xm[ip] = t.xm[ip]; |
xm[ip] = t.xm[ip]; |
71 |
ym[ip] = t.ym[ip]; |
ym[ip] = t.ym[ip]; |
72 |
zm[ip] = t.zm[ip]; |
zm[ip] = t.zm[ip]; |
73 |
resx[ip] = t.resx[ip]; |
resx[ip] = t.resx[ip]; |
74 |
resy[ip] = t.resy[ip]; |
resy[ip] = t.resy[ip]; |
75 |
xv[ip] = t.xv[ip]; |
xv[ip] = t.xv[ip]; |
76 |
yv[ip] = t.yv[ip]; |
yv[ip] = t.yv[ip]; |
77 |
zv[ip] = t.zv[ip]; |
zv[ip] = t.zv[ip]; |
78 |
axv[ip] = t.axv[ip]; |
axv[ip] = t.axv[ip]; |
79 |
ayv[ip] = t.ayv[ip]; |
ayv[ip] = t.ayv[ip]; |
80 |
dedx_x[ip] = t.dedx_x[ip]; |
dedx_x[ip] = t.dedx_x[ip]; |
81 |
dedx_y[ip] = t.dedx_y[ip]; |
dedx_y[ip] = t.dedx_y[ip]; |
82 |
}; |
// clx[ip] = 0;//<<<<pointer |
83 |
|
// cly[ip] = 0;//<<<<pointer |
84 |
|
}; |
85 |
|
clx = new TRefArray(*(t.clx)); |
86 |
|
cly = new TRefArray(*(t.cly)); |
87 |
|
|
88 |
}; |
}; |
89 |
//-------------------------------------- |
//-------------------------------------- |
90 |
// |
// |
200 |
//-------------------------------------- |
//-------------------------------------- |
201 |
void TrkTrack::Dump(){ |
void TrkTrack::Dump(){ |
202 |
cout << endl << "========== Track " ; |
cout << endl << "========== Track " ; |
203 |
|
cout << endl << "seq. n. : "<< seqno; |
204 |
|
cout << endl << "image n. : "<< image; |
205 |
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] << " "; |
206 |
cout << endl << "chi^2 : "<< chi2; |
cout << endl << "chi^2 : "<< chi2; |
207 |
|
cout << endl << "n.step : "<< nstep; |
208 |
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] ; |
209 |
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] ; |
210 |
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] << " "; |
211 |
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] << " "; |
212 |
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] << " "; |
213 |
|
cout << endl << "xv : "; for(int i=0; i<6; i++)cout << xv[i] << " "; |
214 |
|
cout << endl << "yv : "; for(int i=0; i<6; i++)cout << yv[i] << " "; |
215 |
|
cout << endl << "zv : "; for(int i=0; i<6; i++)cout << zv[i] << " "; |
216 |
|
cout << endl << "resx : "; for(int i=0; i<6; i++)cout << resx[i] << " "; |
217 |
|
cout << endl << "resy : "; for(int i=0; i<6; i++)cout << resy[i] << " "; |
218 |
|
cout << endl << "coval : "; for(int i=0; i<5; i++)cout << coval[0][i]<<" "; |
219 |
|
cout << endl << " "; for(int i=0; i<5; i++)cout << coval[1][i]<<" "; |
220 |
|
cout << endl << " "; for(int i=0; i<5; i++)cout << coval[2][i]<<" "; |
221 |
|
cout << endl << " "; for(int i=0; i<5; i++)cout << coval[3][i]<<" "; |
222 |
|
cout << endl << " "; for(int i=0; i<5; i++)cout << coval[4][i]<<" "; |
223 |
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] << " "; |
224 |
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] << " "; |
225 |
|
cout << endl; |
226 |
|
} |
227 |
|
/** |
228 |
|
* Set the TrkTrack position measurements |
229 |
|
*/ |
230 |
|
void TrkTrack::SetMeasure(double *xmeas, double *ymeas, double *zmeas){ |
231 |
|
for(int i=0; i<6; i++) xm[i]=*xmeas++; |
232 |
|
for(int i=0; i<6; i++) ym[i]=*ymeas++; |
233 |
|
for(int i=0; i<6; i++) zm[i]=*zmeas++; |
234 |
|
} |
235 |
|
/** |
236 |
|
* Set the TrkTrack position resolution |
237 |
|
*/ |
238 |
|
void TrkTrack::SetResolution(double *rx, double *ry){ |
239 |
|
for(int i=0; i<6; i++) resx[i]=*rx++; |
240 |
|
for(int i=0; i<6; i++) resy[i]=*ry++; |
241 |
|
} |
242 |
|
/** |
243 |
|
* Set the TrkTrack good measurement |
244 |
|
*/ |
245 |
|
void TrkTrack::SetGood(int *xg, int *yg){ |
246 |
|
for(int i=0; i<6; i++) xgood[i]=*xg++; |
247 |
|
for(int i=0; i<6; i++) ygood[i]=*yg++; |
248 |
} |
} |
249 |
|
|
250 |
|
/** |
251 |
|
* Load the magnetic field |
252 |
|
*/ |
253 |
|
void TrkTrack::LoadField(TString path){ |
254 |
|
|
255 |
|
strcpy(path_.path,path.Data()); |
256 |
|
path_.pathlen = path.Length(); |
257 |
|
path_.error = 0; |
258 |
|
readb_(); |
259 |
|
|
260 |
|
}; |
261 |
|
|
262 |
|
/** |
263 |
|
* Method to fill minimization-routine common |
264 |
|
*/ |
265 |
|
void TrkTrack::FillMiniStruct(cMini2track& track){ |
266 |
|
|
267 |
|
for(int i=0; i<6; i++){ |
268 |
|
|
269 |
|
track.xgood[i]=xgood[i]; |
270 |
|
track.ygood[i]=ygood[i]; |
271 |
|
|
272 |
|
track.xm[i]=xm[i]; |
273 |
|
track.ym[i]=ym[i]; |
274 |
|
track.zm[i]=zm[i]; |
275 |
|
|
276 |
|
// --- temporaneo ---------------------------- |
277 |
|
// andrebbe inserita la dimensione del sensore |
278 |
|
float segment = 100.; |
279 |
|
track.xm_a[i]=xm[i]; |
280 |
|
track.xm_b[i]=xm[i]; |
281 |
|
track.ym_a[i]=ym[i]; |
282 |
|
track.ym_b[i]=ym[i]; |
283 |
|
if( xgood[i] && !ygood[i] ){ |
284 |
|
track.ym_a[i] = track.ym_a[i]+segment; |
285 |
|
track.ym_b[i] = track.ym_b[i]-segment; |
286 |
|
}else if( !xgood[i] && ygood[i]){ |
287 |
|
track.xm_a[i] = track.xm_a[i]+segment; |
288 |
|
track.xm_b[i] = track.xm_b[i]-segment; |
289 |
|
} |
290 |
|
// --- temporaneo ---------------------------- |
291 |
|
|
292 |
|
track.resx[i]=resx[i]; |
293 |
|
track.resy[i]=resy[i]; |
294 |
|
} |
295 |
|
|
296 |
|
for(int i=0; i<5; i++) track.al[i]=al[i]; |
297 |
|
track.zini = 23.5; |
298 |
|
// ZINI = 23.5 !!! it should be the same parameter in all codes |
299 |
|
|
300 |
|
} |
301 |
|
/** |
302 |
|
* Method to set values from minimization-routine common |
303 |
|
*/ |
304 |
|
void TrkTrack::SetFromMiniStruct(cMini2track *track){ |
305 |
|
|
306 |
|
for(int i=0; i<5; i++) { |
307 |
|
al[i]=track->al[i]; |
308 |
|
for(int j=0; j<5; j++) coval[i][j]=track->cov[i][j]; |
309 |
|
} |
310 |
|
chi2 = track->chi2; |
311 |
|
nstep = track->nstep; |
312 |
|
for(int i=0; i<6; i++){ |
313 |
|
xv[i] = track->xv[i]; |
314 |
|
yv[i] = track->yv[i]; |
315 |
|
zv[i] = track->zv[i]; |
316 |
|
xm[i] = track->xm[i]; |
317 |
|
ym[i] = track->ym[i]; |
318 |
|
zm[i] = track->zm[i]; |
319 |
|
axv[i] = track->axv[i]; |
320 |
|
ayv[i] = track->ayv[i]; |
321 |
|
} |
322 |
|
|
323 |
|
|
324 |
|
} |
325 |
|
/** |
326 |
|
* Tracking method. It calls F77 mini routine. |
327 |
|
*/ |
328 |
|
void TrkTrack::Fit(double pfixed, int& fail, int iprint){ |
329 |
|
|
330 |
|
float al_ini[] = {0.,0.,0.,0.,0.}; |
331 |
|
|
332 |
|
extern cMini2track track_; |
333 |
|
fail = 0; |
334 |
|
FillMiniStruct(track_); |
335 |
|
|
336 |
|
// if fit variables have been reset, evaluate the initial guess |
337 |
|
if(al[0]==-9999.&&al[1]==-9999.&&al[2]==-9999.&&al[3]==-9999.&&al[4]==-9999.)guess_(); |
338 |
|
|
339 |
|
// --------------------- free momentum |
340 |
|
if(pfixed==0.) { |
341 |
|
track_.pfixed=0.; |
342 |
|
} |
343 |
|
// --------------------- fixed momentum |
344 |
|
if(pfixed!=0.) { |
345 |
|
al[4]=1./pfixed; |
346 |
|
track_.pfixed=pfixed; |
347 |
|
} |
348 |
|
|
349 |
|
// store temporarily the initial guess |
350 |
|
for(int i=0; i<5; i++) al_ini[i]=track_.al[i]; |
351 |
|
|
352 |
|
// ------------------------------------------ |
353 |
|
// call mini routine |
354 |
|
int istep=0; |
355 |
|
int ifail=0; |
356 |
|
mini2_(&istep,&ifail, &iprint); |
357 |
|
if(ifail!=0) { |
358 |
|
if(iprint)cout << "ERROR: ifail= " << ifail << endl; |
359 |
|
fail = 1; |
360 |
|
} |
361 |
|
// ------------------------------------------ |
362 |
|
|
363 |
|
SetFromMiniStruct(&track_); |
364 |
|
// cout << endl << "eta ===> " << track_.al[4] << endl; |
365 |
|
|
366 |
|
// for(int i=0; i<5; i++) al[i]=track_.al[i]; |
367 |
|
// chi2=track_.chi2; |
368 |
|
// nstep=track_.nstep; |
369 |
|
// for(int i=0; i<6; i++) xv[i]=track_.xv[i]; |
370 |
|
// for(int i=0; i<6; i++) yv[i]=track_.yv[i]; |
371 |
|
// for(int i=0; i<6; i++) zv[i]=track_.zv[i]; |
372 |
|
// for(int i=0; i<6; i++) axv[i]=track_.axv[i]; |
373 |
|
// for(int i=0; i<6; i++) ayv[i]=track_.ayv[i]; |
374 |
|
// for(int i=0; i<5; i++) { |
375 |
|
// for(int j=0; j<5; j++) coval[i][j]=track_.cov[i][j]; |
376 |
|
// } |
377 |
|
|
378 |
|
if(fail){ |
379 |
|
if(iprint)cout << " >>>> fit failed >>>> drawing initial par"<<endl; |
380 |
|
for(int i=0; i<5; i++) al[i]=al_ini[i]; |
381 |
|
} |
382 |
|
|
383 |
|
}; |
384 |
|
/* |
385 |
|
* Reset the fit parameters |
386 |
|
*/ |
387 |
|
void TrkTrack::FitReset(){ |
388 |
|
for(int i=0; i<5; i++) al[i]=-9999.; |
389 |
|
chi2=0.; |
390 |
|
nstep=0; |
391 |
|
for(int i=0; i<6; i++) xv[i]=0.; |
392 |
|
for(int i=0; i<6; i++) yv[i]=0.; |
393 |
|
for(int i=0; i<6; i++) zv[i]=0.; |
394 |
|
for(int i=0; i<6; i++) axv[i]=0.; |
395 |
|
for(int i=0; i<6; i++) ayv[i]=0.; |
396 |
|
for(int i=0; i<5; i++) { |
397 |
|
for(int j=0; j<5; j++) coval[i][j]=0.; |
398 |
|
} |
399 |
|
} |
400 |
|
|
401 |
|
//-------------------------------------- |
402 |
|
// |
403 |
|
// |
404 |
|
//-------------------------------------- |
405 |
|
void TrkTrack::Clear(){ |
406 |
|
seqno = -1; |
407 |
|
image = -1; |
408 |
|
chi2 = 0; |
409 |
|
nstep = 0; |
410 |
|
for(int it1=0;it1<5;it1++){ |
411 |
|
al[it1] = 0; |
412 |
|
for(int it2=0;it2<5;it2++)coval[it1][it2] = 0; |
413 |
|
}; |
414 |
|
for(int ip=0;ip<6;ip++){ |
415 |
|
xgood[ip] = 0; |
416 |
|
ygood[ip] = 0; |
417 |
|
xm[ip] = 0; |
418 |
|
ym[ip] = 0; |
419 |
|
zm[ip] = 0; |
420 |
|
resx[ip] = 0; |
421 |
|
resy[ip] = 0; |
422 |
|
xv[ip] = 0; |
423 |
|
yv[ip] = 0; |
424 |
|
zv[ip] = 0; |
425 |
|
axv[ip] = 0; |
426 |
|
ayv[ip] = 0; |
427 |
|
dedx_x[ip] = 0; |
428 |
|
dedx_y[ip] = 0; |
429 |
|
// clx[ip] = 0; |
430 |
|
// cly[ip] = 0; |
431 |
|
}; |
432 |
|
clx->Clear(); |
433 |
|
cly->Clear(); |
434 |
|
}; |
435 |
|
//-------------------------------------- |
436 |
|
// |
437 |
|
// |
438 |
|
//-------------------------------------- |
439 |
|
void TrkTrack::Delete(){ |
440 |
|
Clear(); |
441 |
|
clx->Delete(); |
442 |
|
cly->Delete(); |
443 |
|
}; |
444 |
|
//-------------------------------------- |
445 |
|
// |
446 |
|
// |
447 |
|
//-------------------------------------- |
448 |
|
|
449 |
//-------------------------------------- |
//-------------------------------------- |
450 |
// |
// |
451 |
// |
// |
455 |
coord[0] = 0; |
coord[0] = 0; |
456 |
coord[1] = 0; |
coord[1] = 0; |
457 |
sgnl = 0; |
sgnl = 0; |
458 |
|
cls = 0; |
459 |
}; |
}; |
460 |
//-------------------------------------- |
//-------------------------------------- |
461 |
// |
// |
466 |
coord[0] = s.coord[0]; |
coord[0] = s.coord[0]; |
467 |
coord[1] = s.coord[1]; |
coord[1] = s.coord[1]; |
468 |
sgnl = s.sgnl; |
sgnl = s.sgnl; |
469 |
|
// cls = 0;//<<<<pointer |
470 |
|
cls = TRef(s.cls); |
471 |
}; |
}; |
472 |
//-------------------------------------- |
//-------------------------------------- |
473 |
// |
// |
485 |
// |
// |
486 |
//-------------------------------------- |
//-------------------------------------- |
487 |
TrkLevel2::TrkLevel2(){ |
TrkLevel2::TrkLevel2(){ |
488 |
good2 = -1; |
// good2 = -1; |
489 |
for(Int_t i=0; i<12 ; i++){ |
for(Int_t i=0; i<12 ; i++){ |
490 |
crc[i] = -1; |
// crc[i] = -1; |
491 |
}; |
good[i] = -1; |
492 |
|
}; |
493 |
Track = new TClonesArray("TrkTrack"); |
Track = new TClonesArray("TrkTrack"); |
494 |
SingletX = new TClonesArray("TrkSinglet"); |
SingletX = new TClonesArray("TrkSinglet"); |
495 |
SingletY = new TClonesArray("TrkSinglet"); |
SingletY = new TClonesArray("TrkSinglet"); |
502 |
// |
// |
503 |
//-------------------------------------- |
//-------------------------------------- |
504 |
void TrkLevel2::Dump(){ |
void TrkLevel2::Dump(){ |
505 |
|
|
506 |
TClonesArray &t = *Track; |
TClonesArray &t = *Track; |
507 |
TClonesArray &sx = *SingletX; |
TClonesArray &sx = *SingletX; |
508 |
TClonesArray &sy = *SingletY; |
TClonesArray &sy = *SingletY; |
509 |
|
// |
510 |
cout << endl << endl << "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"; |
cout << endl << endl << "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"; |
511 |
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]; |
|
512 |
cout << endl << "ntrk() : " << this->ntrk() ; |
cout << endl << "ntrk() : " << this->ntrk() ; |
513 |
cout << endl << "nclsx() : " << this->nclsx(); |
cout << endl << "nclsx() : " << this->nclsx(); |
514 |
cout << endl << "nclsy() : " << this->nclsy(); |
cout << endl << "nclsy() : " << this->nclsy(); |
524 |
* 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). |
525 |
*/ |
*/ |
526 |
void TrkLevel2::SetFromLevel2Struct(cTrkLevel2 *l2){ |
void TrkLevel2::SetFromLevel2Struct(cTrkLevel2 *l2){ |
527 |
// |
|
528 |
// Track = new TClonesArray("TrkTrack"); |
// temporary objects: |
|
// SingletX = new TClonesArray("TrkSinglet"); |
|
|
// SingletY = new TClonesArray("TrkSinglet"); |
|
|
// temporary objects: |
|
529 |
TrkSinglet* t_singlet = new TrkSinglet(); |
TrkSinglet* t_singlet = new TrkSinglet(); |
530 |
TrkTrack* t_track = new TrkTrack(); |
TrkTrack* t_track = new TrkTrack(); |
531 |
// general variables |
|
532 |
good2 = l2->good2; |
// **** general variables **** |
533 |
|
// good2 = l2->good2; |
534 |
for(Int_t i=0; i<12 ; i++){ |
for(Int_t i=0; i<12 ; i++){ |
535 |
crc[i] = l2->crc[i]; |
// crc[i] = l2->crc[i]; |
536 |
}; |
good[i] = l2->good[i]; |
537 |
// *** TRACKS *** |
}; |
538 |
|
// *** TRACKS *** |
539 |
TClonesArray &t = *Track; |
TClonesArray &t = *Track; |
540 |
for(int i=0; i<l2->ntrk; i++){ |
for(int i=0; i<l2->ntrk; i++){ |
541 |
t_track->seqno = i; |
t_track->seqno = i;// NBNBNBNB deve sempre essere = i |
542 |
t_track->image = l2->image[i]-1; |
t_track->image = l2->image[i]-1; |
543 |
// cout << "track "<<i<<t_track->seqno << t_track->image<<endl; |
// cout << "track "<<i<<t_track->seqno << t_track->image<<endl; |
544 |
t_track->chi2 = l2->chi2_nt[i]; |
t_track->chi2 = l2->chi2_nt[i]; |
545 |
for(int it1=0;it1<5;it1++){ |
t_track->nstep = l2->nstep_nt[i]; |
546 |
t_track->al[it1] = l2->al_nt[i][it1]; |
for(int it1=0;it1<5;it1++){ |
547 |
for(int it2=0;it2<5;it2++) |
t_track->al[it1] = l2->al_nt[i][it1]; |
548 |
t_track->coval[it1][it2] = l2->coval[i][it2][it1]; |
for(int it2=0;it2<5;it2++) |
549 |
}; |
t_track->coval[it1][it2] = l2->coval[i][it2][it1]; |
550 |
for(int ip=0;ip<6;ip++){ |
}; |
551 |
t_track->xgood[ip] = l2->xgood_nt[i][ip]; |
for(int ip=0;ip<6;ip++){ |
552 |
t_track->ygood[ip] = l2->ygood_nt[i][ip]; |
t_track->xgood[ip] = l2->xgood_nt[i][ip]; |
553 |
t_track->xm[ip] = l2->xm_nt[i][ip]; |
t_track->ygood[ip] = l2->ygood_nt[i][ip]; |
554 |
t_track->ym[ip] = l2->ym_nt[i][ip]; |
t_track->xm[ip] = l2->xm_nt[i][ip]; |
555 |
t_track->zm[ip] = l2->zm_nt[i][ip]; |
t_track->ym[ip] = l2->ym_nt[i][ip]; |
556 |
t_track->resx[ip] = l2->resx_nt[i][ip]; |
t_track->zm[ip] = l2->zm_nt[i][ip]; |
557 |
t_track->resy[ip] = l2->resy_nt[i][ip]; |
t_track->resx[ip] = l2->resx_nt[i][ip]; |
558 |
t_track->xv[ip] = l2->xv_nt[i][ip]; |
t_track->resy[ip] = l2->resy_nt[i][ip]; |
559 |
t_track->yv[ip] = l2->yv_nt[i][ip]; |
t_track->xv[ip] = l2->xv_nt[i][ip]; |
560 |
t_track->zv[ip] = l2->zv_nt[i][ip]; |
t_track->yv[ip] = l2->yv_nt[i][ip]; |
561 |
t_track->axv[ip] = l2->axv_nt[i][ip]; |
t_track->zv[ip] = l2->zv_nt[i][ip]; |
562 |
t_track->ayv[ip] = l2->ayv_nt[i][ip]; |
t_track->axv[ip] = l2->axv_nt[i][ip]; |
563 |
t_track->dedx_x[ip] = l2->dedx_x[i][ip]; |
t_track->ayv[ip] = l2->ayv_nt[i][ip]; |
564 |
t_track->dedx_y[ip] = l2->dedx_y[i][ip]; |
t_track->dedx_x[ip] = l2->dedx_x[i][ip]; |
565 |
}; |
t_track->dedx_y[ip] = l2->dedx_y[i][ip]; |
566 |
new(t[i]) TrkTrack(*t_track); |
// t_track->clx[ip] = 0; |
567 |
t_track->Clear(); |
// t_track->cly[ip] = 0; |
568 |
|
}; |
569 |
|
new(t[i]) TrkTrack(*t_track); |
570 |
|
t_track->Clear(); |
571 |
}; |
}; |
572 |
// *** SINGLETS *** |
// *** SINGLETS *** |
573 |
TClonesArray &sx = *SingletX; |
TClonesArray &sx = *SingletX; |
574 |
for(int i=0; i<l2->nclsx; i++){ |
for(int i=0; i<l2->nclsx; i++){ |
575 |
t_singlet->plane = l2->planex[i]; |
t_singlet->plane = l2->planex[i]; |
576 |
t_singlet->coord[0] = l2->xs[i][0]; |
t_singlet->coord[0] = l2->xs[i][0]; |
577 |
t_singlet->coord[1] = l2->xs[i][1]; |
t_singlet->coord[1] = l2->xs[i][1]; |
578 |
t_singlet->sgnl = l2->signlxs[i]; |
t_singlet->sgnl = l2->signlxs[i]; |
579 |
new(sx[i]) TrkSinglet(*t_singlet); |
// t_singlet->cls = 0; |
580 |
t_singlet->Clear(); |
new(sx[i]) TrkSinglet(*t_singlet); |
581 |
|
t_singlet->Clear(); |
582 |
} |
} |
583 |
TClonesArray &sy = *SingletY; |
TClonesArray &sy = *SingletY; |
584 |
for(int i=0; i<l2->nclsy; i++){ |
for(int i=0; i<l2->nclsy; i++){ |
585 |
t_singlet->plane = l2->planey[i]; |
t_singlet->plane = l2->planey[i]; |
586 |
t_singlet->coord[0] = l2->ys[i][0]; |
t_singlet->coord[0] = l2->ys[i][0]; |
587 |
t_singlet->coord[1] = l2->ys[i][1]; |
t_singlet->coord[1] = l2->ys[i][1]; |
588 |
t_singlet->sgnl = l2->signlys[i]; |
t_singlet->sgnl = l2->signlys[i]; |
589 |
new(sy[i]) TrkSinglet(*t_singlet); |
// t_singlet->cls = 0; |
590 |
t_singlet->Clear(); |
new(sy[i]) TrkSinglet(*t_singlet); |
591 |
|
t_singlet->Clear(); |
592 |
|
}; |
593 |
|
|
594 |
|
delete t_track; |
595 |
|
delete t_singlet; |
596 |
|
} |
597 |
|
//-------------------------------------- |
598 |
|
// |
599 |
|
// |
600 |
|
//-------------------------------------- |
601 |
|
/** |
602 |
|
* Fills a TrkLevel2 object with values from a struct cTrkLevel2 (to get data from F77 common). |
603 |
|
* Ref to Level1 data (clusters) is also set. |
604 |
|
*/ |
605 |
|
void TrkLevel2::SetFromLevel2Struct(cTrkLevel2 *l2, TrkLevel1 *l1){ |
606 |
|
|
607 |
|
// temporary objects: |
608 |
|
TrkSinglet* t_singlet = new TrkSinglet(); |
609 |
|
TrkTrack* t_track = new TrkTrack(); |
610 |
|
// general variables |
611 |
|
// good2 = l2->good2; |
612 |
|
for(Int_t i=0; i<12 ; i++){ |
613 |
|
// crc[i] = l2->crc[i]; |
614 |
|
good[i] = l2->good[i]; |
615 |
|
}; |
616 |
|
// *** TRACKS *** |
617 |
|
TClonesArray &t = *Track; |
618 |
|
for(int i=0; i<l2->ntrk; i++){ |
619 |
|
t_track->seqno = i;// NBNBNBNB deve sempre essere = i |
620 |
|
t_track->image = l2->image[i]-1; |
621 |
|
// cout << "track "<<i<<t_track->seqno << t_track->image<<endl; |
622 |
|
t_track->chi2 = l2->chi2_nt[i]; |
623 |
|
t_track->nstep = l2->nstep_nt[i]; |
624 |
|
for(int it1=0;it1<5;it1++){ |
625 |
|
t_track->al[it1] = l2->al_nt[i][it1]; |
626 |
|
for(int it2=0;it2<5;it2++) |
627 |
|
t_track->coval[it1][it2] = l2->coval[i][it2][it1]; |
628 |
|
}; |
629 |
|
for(int ip=0;ip<6;ip++){ |
630 |
|
t_track->xgood[ip] = l2->xgood_nt[i][ip]; |
631 |
|
t_track->ygood[ip] = l2->ygood_nt[i][ip]; |
632 |
|
t_track->xm[ip] = l2->xm_nt[i][ip]; |
633 |
|
t_track->ym[ip] = l2->ym_nt[i][ip]; |
634 |
|
t_track->zm[ip] = l2->zm_nt[i][ip]; |
635 |
|
t_track->resx[ip] = l2->resx_nt[i][ip]; |
636 |
|
t_track->resy[ip] = l2->resy_nt[i][ip]; |
637 |
|
t_track->xv[ip] = l2->xv_nt[i][ip]; |
638 |
|
t_track->yv[ip] = l2->yv_nt[i][ip]; |
639 |
|
t_track->zv[ip] = l2->zv_nt[i][ip]; |
640 |
|
t_track->axv[ip] = l2->axv_nt[i][ip]; |
641 |
|
t_track->ayv[ip] = l2->ayv_nt[i][ip]; |
642 |
|
t_track->dedx_x[ip] = l2->dedx_x[i][ip]; |
643 |
|
t_track->dedx_y[ip] = l2->dedx_y[i][ip]; |
644 |
|
// cout << "traccia "<<i<<" -- "<< ip << " "<< l2->cltrx[i][ip] <<" "<< l2->cltry[i][ip] <<" "<< t_track->xgood[ip] << t_track->ygood[ip]<<endl; |
645 |
|
//----------------------------------------------------- |
646 |
|
// t_track->clx[ip] = l1->GetCluster(l2->cltrx[i][ip]-1); |
647 |
|
// t_track->cly[ip] = l1->GetCluster(l2->cltry[i][ip]-1); |
648 |
|
if(t_track->xgood[ip])t_track->clx->AddAt(l1->GetCluster(l2->cltrx[i][ip]-1),ip); |
649 |
|
if(t_track->ygood[ip])t_track->cly->AddAt(l1->GetCluster(l2->cltry[i][ip]-1),ip); |
650 |
|
// 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; |
651 |
|
// 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; |
652 |
|
//----------------------------------------------------- |
653 |
|
}; |
654 |
|
new(t[i]) TrkTrack(*t_track); |
655 |
|
t_track->Clear(); |
656 |
|
}; |
657 |
|
// *** SINGLETS *** |
658 |
|
TClonesArray &sx = *SingletX; |
659 |
|
for(int i=0; i<l2->nclsx; i++){ |
660 |
|
t_singlet->plane = l2->planex[i]; |
661 |
|
t_singlet->coord[0] = l2->xs[i][0]; |
662 |
|
t_singlet->coord[1] = l2->xs[i][1]; |
663 |
|
t_singlet->sgnl = l2->signlxs[i]; |
664 |
|
//----------------------------------------------------- |
665 |
|
// cout << "singolo x "<<i<<" -- "<< l2->clsx[i] <<endl; |
666 |
|
t_singlet->cls = l1->GetCluster(l2->clsx[i]-1); |
667 |
|
// cout<<" i "<<i<<" l2->clsx[i] "<<l2->clsx[i]<< " l1->GetCluster(l2->clsx[i]-1) "<<l1->GetCluster(l2->clsx[i]-1)<<endl; |
668 |
|
//----------------------------------------------------- |
669 |
|
new(sx[i]) TrkSinglet(*t_singlet); |
670 |
|
t_singlet->Clear(); |
671 |
|
} |
672 |
|
TClonesArray &sy = *SingletY; |
673 |
|
for(int i=0; i<l2->nclsy; i++){ |
674 |
|
t_singlet->plane = l2->planey[i]; |
675 |
|
t_singlet->coord[0] = l2->ys[i][0]; |
676 |
|
t_singlet->coord[1] = l2->ys[i][1]; |
677 |
|
t_singlet->sgnl = l2->signlys[i]; |
678 |
|
//----------------------------------------------------- |
679 |
|
// cout << "singolo y "<<i<<" -- "<< l2->clsy[i] <<endl; |
680 |
|
t_singlet->cls = l1->GetCluster(l2->clsy[i]-1); |
681 |
|
// cout<<" i "<<i<<" l2->clsy[i] "<<l2->clsy[i]<< " l1->GetCluster(l2->clsy[i]-1) "<<l1->GetCluster(l2->clsy[i]-1)<<endl; |
682 |
|
//----------------------------------------------------- |
683 |
|
new(sy[i]) TrkSinglet(*t_singlet); |
684 |
|
t_singlet->Clear(); |
685 |
}; |
}; |
686 |
|
|
687 |
delete t_track; |
delete t_track; |
694 |
void TrkLevel2::GetLevel2Struct(cTrkLevel2 *l2) const { |
void TrkLevel2::GetLevel2Struct(cTrkLevel2 *l2) const { |
695 |
|
|
696 |
// general variables |
// general variables |
697 |
l2->good2 = good2 ; |
// l2->good2 = good2 ; |
698 |
for(Int_t i=0; i<12 ; i++){ |
for(Int_t i=0; i<12 ; i++){ |
699 |
l2->crc[i] = crc[i]; |
// l2->crc[i] = crc[i]; |
700 |
|
l2->good[i] = good[i]; |
701 |
}; |
}; |
702 |
// *** TRACKS *** |
// *** TRACKS *** |
703 |
|
|
705 |
for(Int_t i=0;i<l2->ntrk;i++){ |
for(Int_t i=0;i<l2->ntrk;i++){ |
706 |
l2->image[i] = 1 + ((TrkTrack *)Track->At(i))->image; |
l2->image[i] = 1 + ((TrkTrack *)Track->At(i))->image; |
707 |
l2->chi2_nt[i] = ((TrkTrack *)Track->At(i))->chi2; |
l2->chi2_nt[i] = ((TrkTrack *)Track->At(i))->chi2; |
708 |
for(int it1=0;it1<5;it1++){ |
l2->nstep_nt[i] = ((TrkTrack *)Track->At(i))->nstep; |
709 |
|
for(int it1=0;it1<5;it1++){ |
710 |
l2->al_nt[i][it1] = ((TrkTrack *)Track->At(i))->al[it1]; |
l2->al_nt[i][it1] = ((TrkTrack *)Track->At(i))->al[it1]; |
711 |
for(int it2=0;it2<5;it2++) |
for(int it2=0;it2<5;it2++) |
712 |
l2->coval[i][it2][it1] = ((TrkTrack *)Track->At(i))->coval[it1][it2]; |
l2->coval[i][it2][it1] = ((TrkTrack *)Track->At(i))->coval[it1][it2]; |
750 |
// |
// |
751 |
//-------------------------------------- |
//-------------------------------------- |
752 |
void TrkLevel2::Clear(){ |
void TrkLevel2::Clear(){ |
753 |
good2 = -1; |
// good2 = -1; |
754 |
for(Int_t i=0; i<12 ; i++){ |
for(Int_t i=0; i<12 ; i++){ |
755 |
crc[i] = -1; |
// crc[i] = -1; |
756 |
}; |
good[i] = -1; |
757 |
|
}; |
758 |
/* Track->RemoveAll(); |
/* Track->RemoveAll(); |
759 |
SingletX->RemoveAll(); |
SingletX->RemoveAll(); |
760 |
SingletY->RemoveAll();*/ |
SingletY->RemoveAll();*/ |
767 |
// |
// |
768 |
// |
// |
769 |
//-------------------------------------- |
//-------------------------------------- |
770 |
|
void TrkLevel2::Delete(){ |
771 |
|
|
772 |
|
Clear(); |
773 |
|
Track->Delete(); |
774 |
|
SingletX->Delete(); |
775 |
|
SingletY->Delete(); |
776 |
|
} |
777 |
|
//-------------------------------------- |
778 |
|
// |
779 |
|
// |
780 |
|
//-------------------------------------- |
781 |
/** |
/** |
782 |
* 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). |
783 |
* 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. |
784 |
*/ |
*/ |
|
// TClonesArray *TrkLevel2::GetTracks(){ |
|
|
// TClonesArray *sorted = GetTracks_NFitSorted(); |
|
|
// return sorted; |
|
|
// }; |
|
|
|
|
|
/*TClonesArray *TrkLevel2::GetTracks_Chi2Sorted(){ |
|
|
|
|
|
TClonesArray *sorted = new TClonesArray("TrkTrack"); |
|
|
TClonesArray &t = *Track; |
|
|
TClonesArray &ts = *sorted; |
|
|
int N=this->ntrk(); |
|
|
vector<int> m(N); for(int i=0; i<N; i++)m[i]=1; |
|
|
|
|
|
int indo=0; |
|
|
int indi=0; |
|
|
while(N != 0){ |
|
|
float chi2ref=1000000; |
|
|
for(int i=0; i<this->ntrk(); i++){ |
|
|
if(((TrkTrack *)t[i])->chi2 < chi2ref && m[i]==1){ |
|
|
chi2ref = ((TrkTrack *)t[i])->chi2; |
|
|
indi = i; |
|
|
} |
|
|
} |
|
|
if( ((TrkTrack *)t[indi])->image != -1 ){ |
|
|
m[((TrkTrack *)t[indi])->image] = 0; |
|
|
N--; |
|
|
} |
|
|
new(ts[indo]) TrkTrack(*(TrkTrack*)t[indi]); |
|
|
m[indi] = 0; |
|
|
N--; |
|
|
indo++; |
|
|
} |
|
|
return sorted; |
|
|
}*/ |
|
|
/*TClonesArray *TrkLevel2::GetTracks_NFitSorted(){ |
|
|
|
|
|
TClonesArray *sorted = new TClonesArray("TrkTrack"); |
|
|
TClonesArray &t = *Track; |
|
|
TClonesArray &ts = *sorted; |
|
|
// TClonesArray &ts = *PhysicalTrack; |
|
|
int N = ntrk(); |
|
|
vector<int> m(N); for(int i=0; i<N; i++)m[i]=1; |
|
|
// int m[50]; for(int i=0; i<N; i++)m[i]=1; |
|
|
|
|
|
int indo=0; |
|
|
int indi=0; |
|
|
while(N != 0){ |
|
|
int nfit =0; |
|
|
float chi2ref = numeric_limits<float>::max(); |
|
|
// first loop to search maximum num. of fit points |
|
|
for(int i=0; i < ntrk(); i++){ |
|
|
// if(N==ntrk())cout << "** "<<i<< " " << ((TrkTrack *)t[i])->GetImageSeqNo()<< " " <<((TrkTrack *)t[i])->GetNtot() << " " <<((TrkTrack *)t[i])->chi2 << endl; |
|
|
if( ((TrkTrack *)t[i])->GetNtot() >= nfit && m[i]==1){ |
|
|
nfit = ((TrkTrack *)t[i])->GetNtot(); |
|
|
} |
|
|
} |
|
|
//second loop to search minimum chi2 among selected |
|
|
for(int i=0; i<this->ntrk(); i++){ |
|
|
if( ((TrkTrack *)t[i])->chi2 < chi2ref |
|
|
&& ((TrkTrack *)t[i])->GetNtot()== nfit |
|
|
&& m[i]==1){ |
|
|
chi2ref = ((TrkTrack *)t[i])->chi2; |
|
|
indi = i; |
|
|
// cout << "2** "<<i<< " " << nfit <<" "<<chi2ref<<endl; |
|
|
} |
|
|
} |
|
|
if( ((TrkTrack *)t[indi])->HasImage() ){ |
|
|
m[((TrkTrack *)t[indi])->image] = 0; |
|
|
N--; |
|
|
|
|
|
// Int_t nfiti=((TrkTrack *)t[((TrkTrack *)t[indi])->image ])->GetNtot(); |
|
|
// Float_t chi2i=((TrkTrack *)t[((TrkTrack *)t[indi])->image ])->chi2; |
|
|
|
|
|
// cout << "i** "<< ((TrkTrack *)t[indi])->image << " " << nfiti <<" "<<chi2i<<endl; |
|
|
} |
|
|
new(ts[indo]) TrkTrack(*(TrkTrack*)t[indi]); |
|
|
m[indi] = 0; |
|
|
// cout << "SORTED "<< indo << " "<< indi << " "<< N << endl; |
|
|
N--; |
|
|
indo++; |
|
|
} |
|
|
m.clear(); |
|
|
return sorted; |
|
|
// return PhysicalTrack; |
|
|
}*/ |
|
|
//TClonesArray *TrkLevel2::GetTracks_NFitSorted(){ |
|
785 |
TRefArray *TrkLevel2::GetTracks_NFitSorted(){ |
TRefArray *TrkLevel2::GetTracks_NFitSorted(){ |
786 |
|
|
|
// cout << "GetTracks_NFitSorted(it): new TRefArray()"<< endl; |
|
|
// TClonesArray *sorted = new TClonesArray("TrkTrack"); |
|
|
// TClonesArray &ts = *sorted; |
|
787 |
TRefArray *sorted = new TRefArray(); |
TRefArray *sorted = new TRefArray(); |
788 |
|
|
789 |
TClonesArray &t = *Track; |
TClonesArray &t = *Track; |
797 |
while(N != 0){ |
while(N != 0){ |
798 |
int nfit =0; |
int nfit =0; |
799 |
float chi2ref = numeric_limits<float>::max(); |
float chi2ref = numeric_limits<float>::max(); |
800 |
|
|
801 |
// first loop to search maximum num. of fit points |
// first loop to search maximum num. of fit points |
802 |
for(int i=0; i < ntrk(); i++){ |
for(int i=0; i < ntrk(); i++){ |
|
// if(N==ntrk())cout << "** "<<i<< " " << ((TrkTrack *)t[i])->GetImageSeqNo()<< " " <<((TrkTrack *)t[i])->GetNtot() << " " <<((TrkTrack *)t[i])->chi2 << endl; |
|
803 |
if( ((TrkTrack *)t[i])->GetNtot() >= nfit && m[i]==1){ |
if( ((TrkTrack *)t[i])->GetNtot() >= nfit && m[i]==1){ |
804 |
nfit = ((TrkTrack *)t[i])->GetNtot(); |
nfit = ((TrkTrack *)t[i])->GetNtot(); |
805 |
} |
} |
806 |
} |
} |
807 |
//second loop to search minimum chi2 among selected |
//second loop to search minimum chi2 among selected |
808 |
for(int i=0; i<this->ntrk(); i++){ |
for(int i=0; i<this->ntrk(); i++){ |
809 |
if( ((TrkTrack *)t[i])->chi2 < chi2ref |
Float_t chi2 = ((TrkTrack *)t[i])->chi2; |
810 |
&& ((TrkTrack *)t[i])->GetNtot()== nfit |
if(chi2 < 0) chi2 = chi2*1000; |
811 |
&& m[i]==1){ |
if( chi2 < chi2ref |
812 |
|
&& ((TrkTrack *)t[i])->GetNtot() == nfit |
813 |
|
&& m[i]==1){ |
814 |
chi2ref = ((TrkTrack *)t[i])->chi2; |
chi2ref = ((TrkTrack *)t[i])->chi2; |
815 |
indi = i; |
indi = i; |
816 |
// cout << "2** "<<i<< " " << nfit <<" "<<chi2ref<<endl; |
}; |
817 |
} |
}; |
|
} |
|
818 |
if( ((TrkTrack *)t[indi])->HasImage() ){ |
if( ((TrkTrack *)t[indi])->HasImage() ){ |
819 |
m[((TrkTrack *)t[indi])->image] = 0; |
m[((TrkTrack *)t[indi])->image] = 0; |
820 |
N--; |
N--; |
821 |
|
|
|
// Int_t nfiti=((TrkTrack *)t[((TrkTrack *)t[indi])->image ])->GetNtot(); |
|
|
// Float_t chi2i=((TrkTrack *)t[((TrkTrack *)t[indi])->image ])->chi2; |
|
|
|
|
822 |
// cout << "i** "<< ((TrkTrack *)t[indi])->image << " " << nfiti <<" "<<chi2i<<endl; |
// cout << "i** "<< ((TrkTrack *)t[indi])->image << " " << nfiti <<" "<<chi2i<<endl; |
823 |
} |
}; |
|
// new(ts[indo]) TrkTrack(*(TrkTrack*)t[indi]); |
|
|
// cout << "GetTracks_NFitSorted(it): Add("<<indo<<")"<< endl; |
|
824 |
sorted->Add( (TrkTrack*)t[indi] ); |
sorted->Add( (TrkTrack*)t[indi] ); |
825 |
|
|
826 |
m[indi] = 0; |
m[indi] = 0; |
900 |
* Retrieves the it-th "physical" track, sorted by the method GetNTracks(). |
* Retrieves the it-th "physical" track, sorted by the method GetNTracks(). |
901 |
* @param it Track number, ranging from 0 to GetNTracks(). |
* @param it Track number, ranging from 0 to GetNTracks(). |
902 |
*/ |
*/ |
903 |
/*TrkTrack *TrkLevel2::GetTrack(int it){ |
|
|
|
|
|
if(it >= this->GetNTracks()){ |
|
|
cout << "** TrkLevel2 ** Track "<< it << "does not exits! " << endl; |
|
|
cout << " Physical tracks GetNTracks() = "<< this->ntrk() << endl; |
|
|
return 0; |
|
|
} |
|
|
TClonesArray* sorted = GetTracks(); |
|
|
TClonesArray &ts = *sorted; |
|
|
|
|
|
// TrkTrack *track = (TrkTrack*)ts[it]; |
|
|
TrkTrack *track = new TrkTrack( *(TrkTrack*)ts[it] ); //copia |
|
|
sorted->Delete("all");////TEMPORANEO |
|
|
return track; |
|
|
}*/ |
|
904 |
TrkTrack *TrkLevel2::GetTrack(int it){ |
TrkTrack *TrkLevel2::GetTrack(int it){ |
905 |
|
|
906 |
if(it >= this->GetNTracks()){ |
if(it >= this->GetNTracks()){ |
921 |
|
|
922 |
Float_t ntot=0; |
Float_t ntot=0; |
923 |
TClonesArray &t = *Track; |
TClonesArray &t = *Track; |
924 |
for(int i=0; i<ntrk(); i++) { |
for(int i=0; i<ntrk(); i++) { |
925 |
if( ((TrkTrack *)t[i])->GetImageSeqNo() == -1 ) ntot+=1.; |
if( ((TrkTrack *)t[i])->GetImageSeqNo() == -1 ) ntot+=1.; |
926 |
else ntot+=0.5; |
else ntot+=0.5; |
927 |
} |
} |
936 |
* Retrieves (if present) the image of the it-th "physical" track, sorted by the method GetNTracks(). |
* Retrieves (if present) the image of the it-th "physical" track, sorted by the method GetNTracks(). |
937 |
* @param it Track number, ranging from 0 to GetNTracks(). |
* @param it Track number, ranging from 0 to GetNTracks(). |
938 |
*/ |
*/ |
|
/*TrkTrack *TrkLevel2::GetTrackImage(int it){ |
|
|
|
|
|
if(it >= this->GetNTracks()){ |
|
|
cout << "** TrkLevel2 ** Track "<< it << "does not exits! " << endl; |
|
|
cout << " Physical tracks GetNTracks() = "<< this->ntrk() << endl; |
|
|
return 0; |
|
|
} |
|
|
|
|
|
TClonesArray* sorted = GetTracks(); |
|
|
TClonesArray &ts = *sorted; |
|
|
TrkTrack *track = (TrkTrack*)ts[it]; |
|
|
// TrkTrack *track = (TrkTrack*)(*(this->GetTracks()))[it]; |
|
|
|
|
|
if(!track->HasImage()){ |
|
|
cout << "** TrkLevel2 ** Track "<< it << "does not have image! " << endl; |
|
|
return 0; |
|
|
} |
|
|
TrkTrack *image = (TrkTrack*)(*Track)[track->image]; |
|
|
|
|
|
// GetTracks()->Delete(); ////TEMPORANEO |
|
|
sorted->Delete(); ////TEMPORANEO |
|
|
|
|
|
return image; |
|
|
|
|
|
}*/ |
|
939 |
TrkTrack *TrkLevel2::GetTrackImage(int it){ |
TrkTrack *TrkLevel2::GetTrackImage(int it){ |
940 |
|
|
941 |
if(it >= this->GetNTracks()){ |
if(it >= this->GetNTracks()){ |
966 |
* Loads the magnetic field. |
* Loads the magnetic field. |
967 |
* @param s Path of the magnetic-field files. |
* @param s Path of the magnetic-field files. |
968 |
*/ |
*/ |
969 |
void TrkLevel2::LoadField(TString s){ |
void TrkLevel2::LoadField(TString path){ |
970 |
readb_(s.Data()); |
// |
971 |
|
strcpy(path_.path,path.Data()); |
972 |
|
path_.pathlen = path.Length(); |
973 |
|
path_.error = 0; |
974 |
|
readb_(); |
975 |
|
// |
976 |
}; |
}; |
977 |
//-------------------------------------- |
//-------------------------------------- |
978 |
// |
// |
1070 |
tl = new float[npoint]; |
tl = new float[npoint]; |
1071 |
int i=0; |
int i=0; |
1072 |
do{ |
do{ |
1073 |
x[i] = 0; |
x[i] = 0; |
1074 |
y[i] = 0; |
y[i] = 0; |
1075 |
z[i] = zin[i]; |
z[i] = zin[i]; |
1076 |
thx[i] = 0; |
thx[i] = 0; |
1077 |
thy[i] = 0; |
thy[i] = 0; |
1078 |
tl[i] = 0; |
tl[i] = 0; |
1079 |
i++; |
i++; |
1080 |
}while(zin[i-1] > zin[i] && i < npoint); |
}while(zin[i-1] > zin[i] && i < npoint); |
1081 |
npoint=i; |
npoint=i; |
1082 |
if(npoint != n)cout << "NB! Trajectory created with "<<npoint<<" points"<<endl; |
if(npoint != n)cout << "NB! Trajectory created with "<<npoint<<" points"<<endl; |
1119 |
|
|
1120 |
} |
} |
1121 |
|
|
1122 |
|
/** |
1123 |
|
* Evaluates the trajectory in the apparatus associated to the track. |
1124 |
|
* 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. |
1125 |
|
* @param t pointer to an object of the class Trajectory, |
1126 |
|
* which z coordinates should be previously initialized by calling the proper constructor ( Trajectory::Trajectory(int n, float* zin) ). |
1127 |
|
* @return error flag. |
1128 |
|
*/ |
1129 |
|
int Trajectory::DoTrack2(float* al){ |
1130 |
|
|
1131 |
|
double *dxout = new double[npoint]; |
1132 |
|
double *dyout = new double[npoint]; |
1133 |
|
double *dthxout = new double[npoint]; |
1134 |
|
double *dthyout = new double[npoint]; |
1135 |
|
double *dtlout = new double[npoint]; |
1136 |
|
double *dzin = new double[npoint]; |
1137 |
|
double dal[5]; |
1138 |
|
|
1139 |
|
int ifail = 0; |
1140 |
|
|
1141 |
|
for (int i=0; i<5; i++) dal[i] = (double)al[i]; |
1142 |
|
for (int i=0; i<npoint; i++) dzin[i] = (double)z[i]; |
1143 |
|
|
1144 |
|
dotrack2_(&(npoint),dzin,dxout,dyout,dthxout,dthyout,dtlout,dal,&ifail); |
1145 |
|
|
1146 |
|
for (int i=0; i<npoint; i++){ |
1147 |
|
x[i] = (float)*dxout++; |
1148 |
|
y[i] = (float)*dyout++; |
1149 |
|
thx[i] = (float)*dthxout++; |
1150 |
|
thy[i] = (float)*dthyout++; |
1151 |
|
tl[i] = (float)*dtlout++; |
1152 |
|
} |
1153 |
|
|
1154 |
|
return ifail; |
1155 |
|
}; |
1156 |
|
|
1157 |
ClassImp(TrkLevel2); |
ClassImp(TrkLevel2); |
1158 |
ClassImp(TrkSinglet); |
ClassImp(TrkSinglet); |
1159 |
ClassImp(TrkTrack); |
ClassImp(TrkTrack); |