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 |
void mini2_(int*,int*,int*); |
// int readb_(); |
17 |
void guess_(); |
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; |
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 |
// |
// |
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 |
}; |
}; |
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] << " "; |
290 |
* Set the TrkTrack good measurement |
* Set the TrkTrack good measurement |
291 |
*/ |
*/ |
292 |
void TrkTrack::SetGood(int *xg, int *yg){ |
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++; |
for(int i=0; i<6; i++) xgood[i]=*xg++; |
295 |
for(int i=0; i<6; i++) ygood[i]=*yg++; |
for(int i=0; i<6; i++) ygood[i]=*yg++; |
296 |
} |
} |
298 |
/** |
/** |
299 |
* Load the magnetic field |
* Load the magnetic field |
300 |
*/ |
*/ |
301 |
void TrkTrack::LoadField(TString s){ |
void TrkTrack::LoadField(TString path){ |
302 |
readb_(s.Data()); |
|
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. |
* Tracking method. It calls F77 mini routine. |
380 |
*/ |
*/ |
384 |
|
|
385 |
extern cMini2track track_; |
extern cMini2track track_; |
386 |
fail = 0; |
fail = 0; |
387 |
// extern cMini2fitinfo fit_info_; |
FillMiniStruct(track_); |
|
// extern void mini_2_(int*,int*); |
|
|
// track_.xm[0]=1.0; |
|
|
|
|
|
cout << "fitting routine "<<endl; |
|
|
|
|
|
for(int i=0; i<6; i++) track_.xm[i]=xm[i]; |
|
|
for(int i=0; i<6; i++) track_.ym[i]=ym[i]; |
|
|
for(int i=0; i<6; i++) track_.zm[i]=zm[i]; |
|
|
for(int i=0; i<6; i++) track_.resx[i]=resx[i]; |
|
|
for(int i=0; i<6; i++) track_.resy[i]=resy[i]; |
|
|
for(int i=0; i<6; i++) track_.xgood[i]=xgood[i]; |
|
|
for(int i=0; i<6; i++) track_.ygood[i]=ygood[i]; |
|
|
|
|
|
// initial guess of "al" with linear fit |
|
|
// if(al[0]==-9999.&&al[1]==-9999.&&al[2]==-9999.&&al[3]==-9999.&&al[4]==-9999.){ |
|
|
|
|
|
// cout << "initial guess "<<endl; |
|
|
|
|
|
// double szz=0., szx=0., szy=0., ssx=0., ssy=0., sz=0., s1=0.; |
|
|
// double det, ax, ay, bx, by; |
|
|
// for(int i=0; i<NPLANE; i++) { |
|
|
// szz=szz+zm[i]*zm[i]; |
|
|
// szx=szx+zm[i]*xm[i]; |
|
|
// szy=szy+zm[i]*ym[i]; |
|
|
// ssx=ssx+xm[i]; |
|
|
// ssy=ssy+ym[i]; |
|
|
// sz=sz+zm[i]; |
|
|
// s1=s1+1.; |
|
|
// } |
|
|
// det=szz*s1-sz*sz; |
|
|
// ax=(szx*s1-sz*ssx)/det; |
|
|
// bx=(szz*ssx-szx*sz)/det; |
|
|
// ay=(szy*s1-sz*ssy)/det; |
|
|
// by=(szz*ssy-szy*sz)/det; |
|
|
// al[0]=ax*23.5+bx; // ZINI = 23.5 !!! it should be the same parameter in all codes |
|
|
// al[1]=ay*23.5+by; // " |
|
|
// al[2]= sqrt(pow(ax,2)+pow(ay,2))/ sqrt(pow(ax,2)+pow(ay,2)+1.); |
|
|
// al[3]=0.; |
|
|
// if( (ax!=0.)||(ay!=0.) ) { |
|
|
// al[3]= asin(ay/ sqrt(pow(ax,2)+pow(ay,2))); |
|
|
// if(ax<0.) al[3]=acos(-1.)-al[3]; |
|
|
// } |
|
|
// al[4]=0.; |
|
388 |
|
|
389 |
// } |
// if fit variables have been reset, evaluate the initial guess |
|
// end guess |
|
|
for(int i=0; i<5; i++) track_.al[i]=al[i]; |
|
|
track_.zini = 23.5; // ZINI = 23.5 !!! it should be the same parameter in all codes |
|
|
|
|
|
// elena ----- |
|
390 |
if(al[0]==-9999.&&al[1]==-9999.&&al[2]==-9999.&&al[3]==-9999.&&al[4]==-9999.)guess_(); |
if(al[0]==-9999.&&al[1]==-9999.&&al[2]==-9999.&&al[3]==-9999.&&al[4]==-9999.)guess_(); |
|
// elena ----- |
|
391 |
|
|
392 |
|
// --------------------- free momentum |
393 |
if(pfixed==0.) { |
if(pfixed==0.) { |
394 |
// al[4]=0.; // free momentum |
track_.pfixed=0.; |
|
track_.pfixed=0.; // " |
|
395 |
} |
} |
396 |
|
// --------------------- fixed momentum |
397 |
if(pfixed!=0.) { |
if(pfixed!=0.) { |
398 |
al[4]=1./pfixed; // to fix the momentum |
al[4]=1./pfixed; |
399 |
track_.pfixed=pfixed; // " |
track_.pfixed=pfixed; |
400 |
} |
} |
401 |
|
|
402 |
// store temporarily the initial guess |
// store temporarily the initial guess |
403 |
for(int i=0; i<5; i++) al_ini[i]=track_.al[i]; |
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; |
int istep=0; |
413 |
int ifail=0; |
int ifail=0; |
414 |
mini2_(&istep,&ifail, &iprint); |
mini2_(&istep,&ifail, &iprint); |
415 |
if(ifail!=0) { |
if(ifail!=0) { |
416 |
if(iprint==1)cout << "ERROR: ifail= " << ifail << endl; |
if(iprint)cout << "ERROR: ifail= " << ifail << endl; |
417 |
fail = 1; |
fail = 1; |
|
// return; |
|
418 |
} |
} |
419 |
|
// ------------------------------------------ |
420 |
|
|
421 |
|
SetFromMiniStruct(&track_); |
422 |
// cout << endl << "eta ===> " << track_.al[4] << endl; |
// cout << endl << "eta ===> " << track_.al[4] << endl; |
423 |
|
|
424 |
for(int i=0; i<5; i++) al[i]=track_.al[i]; |
// for(int i=0; i<5; i++) al[i]=track_.al[i]; |
425 |
chi2=track_.chi2; |
// chi2=track_.chi2; |
426 |
nstep=track_.nstep; |
// nstep=track_.nstep; |
427 |
for(int i=0; i<6; i++) xv[i]=track_.xv[i]; |
// 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]; |
// 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]; |
// 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]; |
// 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]; |
// for(int i=0; i<6; i++) ayv[i]=track_.ayv[i]; |
432 |
for(int i=0; i<5; i++) { |
// for(int i=0; i<5; i++) { |
433 |
for(int j=0; j<5; j++) coval[i][j]=track_.cov[i][j]; |
// for(int j=0; j<5; j++) coval[i][j]=track_.cov[i][j]; |
434 |
} |
// } |
435 |
|
|
436 |
if(fail){ |
if(fail){ |
437 |
cout << " >>>> fit failed >>>> drawing initial par"<<endl; |
if(iprint)cout << " >>>> fit failed >>>> drawing initial par"<<endl; |
438 |
for(int i=0; i<5; i++) al[i]=al_ini[i]; |
for(int i=0; i<5; i++) al[i]=al_ini[i]; |
439 |
} |
} |
440 |
|
|
441 |
}; |
}; |
455 |
for(int j=0; j<5; j++) coval[i][j]=0.; |
for(int j=0; j<5; j++) coval[i][j]=0.; |
456 |
} |
} |
457 |
} |
} |
458 |
|
void TrkTrack::SetTrackingMode(int trackmode){ |
459 |
|
extern cMini2track track_; |
460 |
|
track_.trackmode = trackmode; |
461 |
|
} |
462 |
|
|
463 |
|
|
464 |
|
/* |
465 |
|
* Method to retrieve the X-view clusters associated to the track. |
466 |
|
* @param ip Tracker plane (0-5) |
467 |
|
*/ |
468 |
|
TrkCluster *TrkTrack::GetClusterX(int ip){ |
469 |
|
cout << " TrkCluster *TrkTrack::GetClusterX(int ip) -- momentaneamente fuori servizio --"<< endl; |
470 |
|
if(!clx)return NULL; |
471 |
|
TrkCluster *pt = (TrkCluster*)(clx->At(ip)); |
472 |
|
return pt; |
473 |
|
}; |
474 |
|
/* |
475 |
|
* Method to retrieve the Y-view clusters associated to the track. |
476 |
|
* @param ip Tracker plane (0-5) |
477 |
|
*/ |
478 |
|
TrkCluster *TrkTrack::GetClusterY(int ip){ |
479 |
|
cout << " TrkCluster *TrkTrack::GetClusterY(int ip) -- momentaneamente fuori servizio --"<< endl; |
480 |
|
if(!cly)return NULL; |
481 |
|
TrkCluster *pt = (TrkCluster*)(cly->At(ip)); |
482 |
|
return pt; |
483 |
|
}; |
484 |
|
|
485 |
|
|
486 |
//-------------------------------------- |
//-------------------------------------- |
487 |
// |
// |
488 |
// |
// |
489 |
//-------------------------------------- |
//-------------------------------------- |
490 |
void TrkTrack::Clear(){ |
void TrkTrack::Clear(){ |
491 |
seqno = -1; |
// cout << "TrkTrack::Clear()"<<endl; |
492 |
image = -1; |
seqno = -1; |
493 |
chi2 = 0; |
image = -1; |
494 |
nstep = 0; |
chi2 = 0; |
495 |
for(int it1=0;it1<5;it1++){ |
nstep = 0; |
496 |
al[it1] = 0; |
for(int it1=0;it1<5;it1++){ |
497 |
for(int it2=0;it2<5;it2++)coval[it1][it2] = 0; |
al[it1] = 0; |
498 |
}; |
for(int it2=0;it2<5;it2++)coval[it1][it2] = 0; |
499 |
for(int ip=0;ip<6;ip++){ |
}; |
500 |
xgood[ip] = 0; |
for(int ip=0;ip<6;ip++){ |
501 |
ygood[ip] = 0; |
xgood[ip] = 0; |
502 |
xm[ip] = 0; |
ygood[ip] = 0; |
503 |
ym[ip] = 0; |
xm[ip] = 0; |
504 |
zm[ip] = 0; |
ym[ip] = 0; |
505 |
resx[ip] = 0; |
zm[ip] = 0; |
506 |
resy[ip] = 0; |
resx[ip] = 0; |
507 |
xv[ip] = 0; |
resy[ip] = 0; |
508 |
yv[ip] = 0; |
xv[ip] = 0; |
509 |
zv[ip] = 0; |
yv[ip] = 0; |
510 |
axv[ip] = 0; |
zv[ip] = 0; |
511 |
ayv[ip] = 0; |
axv[ip] = 0; |
512 |
dedx_x[ip] = 0; |
ayv[ip] = 0; |
513 |
dedx_y[ip] = 0; |
dedx_x[ip] = 0; |
514 |
// clx[ip] = 0; |
dedx_y[ip] = 0; |
515 |
// cly[ip] = 0; |
|
516 |
}; |
}; |
517 |
clx->Clear(); |
if(clx)clx->Clear(); |
518 |
cly->Clear(); |
if(cly)cly->Clear(); |
519 |
}; |
}; |
520 |
//-------------------------------------- |
//-------------------------------------- |
521 |
// |
// |
522 |
// |
// |
523 |
//-------------------------------------- |
//-------------------------------------- |
524 |
void TrkTrack::Delete(){ |
void TrkTrack::Delete(){ |
525 |
Clear(); |
// cout << "TrkTrack::Delete()"<<endl; |
526 |
clx->Delete(); |
// Clear(); |
527 |
cly->Delete(); |
if(clx)delete clx; |
528 |
|
if(cly)delete cly; |
529 |
}; |
}; |
530 |
//-------------------------------------- |
//-------------------------------------- |
531 |
// |
// |
532 |
// |
// |
533 |
//-------------------------------------- |
//-------------------------------------- |
537 |
// |
// |
538 |
//-------------------------------------- |
//-------------------------------------- |
539 |
TrkSinglet::TrkSinglet(){ |
TrkSinglet::TrkSinglet(){ |
540 |
|
// cout << "TrkSinglet::TrkSinglet() " << GetUniqueID()<<endl; |
541 |
plane = 0; |
plane = 0; |
542 |
coord[0] = 0; |
coord[0] = 0; |
543 |
coord[1] = 0; |
coord[1] = 0; |
544 |
sgnl = 0; |
sgnl = 0; |
545 |
cls = 0; |
// cls = 0; |
546 |
}; |
}; |
547 |
//-------------------------------------- |
//-------------------------------------- |
548 |
// |
// |
549 |
// |
// |
550 |
//-------------------------------------- |
//-------------------------------------- |
551 |
TrkSinglet::TrkSinglet(const TrkSinglet& s){ |
TrkSinglet::TrkSinglet(const TrkSinglet& s){ |
552 |
|
// cout << "TrkSinglet::TrkSinglet(const TrkSinglet& s) " << GetUniqueID()<<endl; |
553 |
plane = s.plane; |
plane = s.plane; |
554 |
coord[0] = s.coord[0]; |
coord[0] = s.coord[0]; |
555 |
coord[1] = s.coord[1]; |
coord[1] = s.coord[1]; |
556 |
sgnl = s.sgnl; |
sgnl = s.sgnl; |
557 |
// cls = 0;//<<<<pointer |
// cls = 0;//<<<<pointer |
558 |
cls = TRef(s.cls); |
cls = TRef(s.cls); |
559 |
}; |
}; |
560 |
//-------------------------------------- |
//-------------------------------------- |
561 |
// |
// |
572 |
// |
// |
573 |
// |
// |
574 |
//-------------------------------------- |
//-------------------------------------- |
575 |
|
void TrkSinglet::Clear(){ |
576 |
|
// cout << "TrkSinglet::Clear() " << GetUniqueID()<<endl; |
577 |
|
// cls=0; |
578 |
|
plane=-1; |
579 |
|
coord[0]=-999; |
580 |
|
coord[1]=-999; |
581 |
|
sgnl=0; |
582 |
|
|
583 |
|
} |
584 |
|
//-------------------------------------- |
585 |
|
// |
586 |
|
// |
587 |
|
//-------------------------------------- |
588 |
TrkLevel2::TrkLevel2(){ |
TrkLevel2::TrkLevel2(){ |
589 |
// good2 = -1; |
// cout <<"TrkLevel2::TrkLevel2()"<<endl; |
590 |
for(Int_t i=0; i<12 ; i++){ |
for(Int_t i=0; i<12 ; i++){ |
|
// crc[i] = -1; |
|
591 |
good[i] = -1; |
good[i] = -1; |
592 |
}; |
}; |
593 |
Track = new TClonesArray("TrkTrack"); |
// okkio!! memory-leak |
594 |
SingletX = new TClonesArray("TrkSinglet"); |
// Track = new TClonesArray("TrkTrack"); |
595 |
SingletY = new TClonesArray("TrkSinglet"); |
// SingletX = new TClonesArray("TrkSinglet"); |
596 |
|
// SingletY = new TClonesArray("TrkSinglet"); |
597 |
|
Track = 0; |
598 |
|
SingletX = 0; |
599 |
|
SingletY = 0; |
600 |
|
|
601 |
// PhysicalTrack = new TClonesArray("TrkTrack"); |
} |
602 |
//sostituire con TRefArray... appena ho capito come si usa |
//-------------------------------------- |
603 |
|
// |
604 |
|
// |
605 |
|
//-------------------------------------- |
606 |
|
void TrkLevel2::Set(){ |
607 |
|
if(!Track)Track = new TClonesArray("TrkTrack"); |
608 |
|
if(!SingletX)SingletX = new TClonesArray("TrkSinglet"); |
609 |
|
if(!SingletY)SingletY = new TClonesArray("TrkSinglet"); |
610 |
} |
} |
611 |
//-------------------------------------- |
//-------------------------------------- |
612 |
// |
// |
614 |
//-------------------------------------- |
//-------------------------------------- |
615 |
void TrkLevel2::Dump(){ |
void TrkLevel2::Dump(){ |
616 |
|
|
|
TClonesArray &t = *Track; |
|
|
TClonesArray &sx = *SingletX; |
|
|
TClonesArray &sy = *SingletY; |
|
617 |
// |
// |
618 |
cout << endl << endl << "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"; |
cout << endl << endl << "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"; |
619 |
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]<<" "; |
620 |
cout << endl << "ntrk() : " << this->ntrk() ; |
cout << endl << "ntrk() : " << this->ntrk() ; |
621 |
cout << endl << "nclsx() : " << this->nclsx(); |
cout << endl << "nclsx() : " << this->nclsx(); |
622 |
cout << endl << "nclsy() : " << this->nclsy(); |
cout << endl << "nclsy() : " << this->nclsy(); |
623 |
for(int i=0; i<this->ntrk(); i++) ((TrkTrack *)t[i])->Dump(); |
// TClonesArray &t = *Track; |
624 |
for(int i=0; i<this->nclsx(); i++) ((TrkSinglet *)sx[i])->Dump(); |
// TClonesArray &sx = *SingletX; |
625 |
for(int i=0; i<this->nclsy(); i++) ((TrkSinglet *)sy[i])->Dump(); |
// TClonesArray &sy = *SingletY; |
626 |
|
// for(int i=0; i<ntrk(); i++) ((TrkTrack *)t[i])->Dump(); |
627 |
|
// for(int i=0; i<nclsx(); i++) ((TrkSinglet *)sx[i])->Dump(); |
628 |
|
// for(int i=0; i<nclsy(); i++) ((TrkSinglet *)sy[i])->Dump(); |
629 |
|
if(Track){ |
630 |
|
TClonesArray &t = *Track; |
631 |
|
for(int i=0; i<ntrk(); i++) ((TrkTrack *)t[i])->Dump(); |
632 |
|
} |
633 |
|
if(SingletX){ |
634 |
|
TClonesArray &sx = *SingletX; |
635 |
|
for(int i=0; i<nclsx(); i++) ((TrkSinglet *)sx[i])->Dump(); |
636 |
|
} |
637 |
|
if(SingletY){ |
638 |
|
TClonesArray &sy = *SingletY; |
639 |
|
for(int i=0; i<nclsy(); i++) ((TrkSinglet *)sy[i])->Dump(); |
640 |
|
} |
641 |
} |
} |
642 |
//-------------------------------------- |
//-------------------------------------- |
643 |
// |
// |
646 |
/** |
/** |
647 |
* 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). |
648 |
*/ |
*/ |
649 |
void TrkLevel2::SetFromLevel2Struct(cTrkLevel2 *l2){ |
// void TrkLevel2::SetFromLevel2Struct(cTrkLevel2 *l2){ |
650 |
|
|
651 |
// temporary objects: |
// // temporary objects: |
652 |
TrkSinglet* t_singlet = new TrkSinglet(); |
// TrkSinglet* t_singlet = new TrkSinglet(); |
653 |
TrkTrack* t_track = new TrkTrack(); |
// TrkTrack* t_track = new TrkTrack(); |
654 |
|
|
655 |
// **** general variables **** |
// // **** general variables **** |
656 |
// good2 = l2->good2; |
// // good2 = l2->good2; |
657 |
for(Int_t i=0; i<12 ; i++){ |
// for(Int_t i=0; i<12 ; i++){ |
658 |
// crc[i] = l2->crc[i]; |
// // crc[i] = l2->crc[i]; |
659 |
good[i] = l2->good[i]; |
// good[i] = l2->good[i]; |
660 |
}; |
// }; |
661 |
// *** TRACKS *** |
// // *** TRACKS *** |
662 |
TClonesArray &t = *Track; |
// if(!Track) Track = new TClonesArray("TrkTrack"); |
663 |
for(int i=0; i<l2->ntrk; i++){ |
// TClonesArray &t = *Track; |
664 |
t_track->seqno = i;// NBNBNBNB deve sempre essere = i |
// for(int i=0; i<l2->ntrk; i++){ |
665 |
t_track->image = l2->image[i]-1; |
// t_track->seqno = i;// NBNBNBNB deve sempre essere = i |
666 |
// cout << "track "<<i<<t_track->seqno << t_track->image<<endl; |
// t_track->image = l2->image[i]-1; |
667 |
t_track->chi2 = l2->chi2_nt[i]; |
// // cout << "track "<<i<<t_track->seqno << t_track->image<<endl; |
668 |
t_track->nstep = l2->nstep_nt[i]; |
// t_track->chi2 = l2->chi2_nt[i]; |
669 |
for(int it1=0;it1<5;it1++){ |
// t_track->nstep = l2->nstep_nt[i]; |
670 |
t_track->al[it1] = l2->al_nt[i][it1]; |
// for(int it1=0;it1<5;it1++){ |
671 |
for(int it2=0;it2<5;it2++) |
// t_track->al[it1] = l2->al_nt[i][it1]; |
672 |
t_track->coval[it1][it2] = l2->coval[i][it2][it1]; |
// for(int it2=0;it2<5;it2++) |
673 |
}; |
// t_track->coval[it1][it2] = l2->coval[i][it2][it1]; |
674 |
for(int ip=0;ip<6;ip++){ |
// }; |
675 |
t_track->xgood[ip] = l2->xgood_nt[i][ip]; |
// for(int ip=0;ip<6;ip++){ |
676 |
t_track->ygood[ip] = l2->ygood_nt[i][ip]; |
// t_track->xgood[ip] = l2->xgood_nt[i][ip]; |
677 |
t_track->xm[ip] = l2->xm_nt[i][ip]; |
// t_track->ygood[ip] = l2->ygood_nt[i][ip]; |
678 |
t_track->ym[ip] = l2->ym_nt[i][ip]; |
// t_track->xm[ip] = l2->xm_nt[i][ip]; |
679 |
t_track->zm[ip] = l2->zm_nt[i][ip]; |
// t_track->ym[ip] = l2->ym_nt[i][ip]; |
680 |
t_track->resx[ip] = l2->resx_nt[i][ip]; |
// t_track->zm[ip] = l2->zm_nt[i][ip]; |
681 |
t_track->resy[ip] = l2->resy_nt[i][ip]; |
// t_track->resx[ip] = l2->resx_nt[i][ip]; |
682 |
t_track->xv[ip] = l2->xv_nt[i][ip]; |
// t_track->resy[ip] = l2->resy_nt[i][ip]; |
683 |
t_track->yv[ip] = l2->yv_nt[i][ip]; |
// t_track->xv[ip] = l2->xv_nt[i][ip]; |
684 |
t_track->zv[ip] = l2->zv_nt[i][ip]; |
// t_track->yv[ip] = l2->yv_nt[i][ip]; |
685 |
t_track->axv[ip] = l2->axv_nt[i][ip]; |
// t_track->zv[ip] = l2->zv_nt[i][ip]; |
686 |
t_track->ayv[ip] = l2->ayv_nt[i][ip]; |
// t_track->axv[ip] = l2->axv_nt[i][ip]; |
687 |
t_track->dedx_x[ip] = l2->dedx_x[i][ip]; |
// t_track->ayv[ip] = l2->ayv_nt[i][ip]; |
688 |
t_track->dedx_y[ip] = l2->dedx_y[i][ip]; |
// t_track->dedx_x[ip] = l2->dedx_x[i][ip]; |
689 |
// t_track->clx[ip] = 0; |
// t_track->dedx_y[ip] = l2->dedx_y[i][ip]; |
690 |
// t_track->cly[ip] = 0; |
// // t_track->clx[ip] = 0; |
691 |
}; |
// // t_track->cly[ip] = 0; |
692 |
new(t[i]) TrkTrack(*t_track); |
// }; |
693 |
t_track->Clear(); |
// new(t[i]) TrkTrack(*t_track); |
694 |
}; |
// t_track->Clear(); |
695 |
// *** SINGLETS *** |
// }; |
696 |
TClonesArray &sx = *SingletX; |
// // *** SINGLETS *** |
697 |
for(int i=0; i<l2->nclsx; i++){ |
// if(!SingletX)SingletX = new TClonesArray("TrkSinglet"); |
698 |
t_singlet->plane = l2->planex[i]; |
// TClonesArray &sx = *SingletX; |
699 |
t_singlet->coord[0] = l2->xs[i][0]; |
// for(int i=0; i<l2->nclsx; i++){ |
700 |
t_singlet->coord[1] = l2->xs[i][1]; |
// t_singlet->plane = l2->planex[i]; |
701 |
t_singlet->sgnl = l2->signlxs[i]; |
// t_singlet->coord[0] = l2->xs[i][0]; |
702 |
// t_singlet->cls = 0; |
// t_singlet->coord[1] = l2->xs[i][1]; |
703 |
new(sx[i]) TrkSinglet(*t_singlet); |
// t_singlet->sgnl = l2->signlxs[i]; |
704 |
t_singlet->Clear(); |
// // t_singlet->cls = 0; |
705 |
} |
// new(sx[i]) TrkSinglet(*t_singlet); |
706 |
TClonesArray &sy = *SingletY; |
// t_singlet->Clear(); |
707 |
for(int i=0; i<l2->nclsy; i++){ |
// } |
708 |
t_singlet->plane = l2->planey[i]; |
// if(!SingletY)SingletY = new TClonesArray("TrkSinglet"); |
709 |
t_singlet->coord[0] = l2->ys[i][0]; |
// TClonesArray &sy = *SingletY; |
710 |
t_singlet->coord[1] = l2->ys[i][1]; |
// for(int i=0; i<l2->nclsy; i++){ |
711 |
t_singlet->sgnl = l2->signlys[i]; |
// t_singlet->plane = l2->planey[i]; |
712 |
// t_singlet->cls = 0; |
// t_singlet->coord[0] = l2->ys[i][0]; |
713 |
new(sy[i]) TrkSinglet(*t_singlet); |
// t_singlet->coord[1] = l2->ys[i][1]; |
714 |
t_singlet->Clear(); |
// t_singlet->sgnl = l2->signlys[i]; |
715 |
}; |
// // t_singlet->cls = 0; |
716 |
|
// new(sy[i]) TrkSinglet(*t_singlet); |
717 |
|
// t_singlet->Clear(); |
718 |
|
// }; |
719 |
|
|
720 |
delete t_track; |
// delete t_track; |
721 |
delete t_singlet; |
// delete t_singlet; |
722 |
} |
// } |
723 |
//-------------------------------------- |
//-------------------------------------- |
724 |
// |
// |
725 |
// |
// |
726 |
//-------------------------------------- |
//-------------------------------------- |
727 |
/** |
/** |
728 |
* 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). |
729 |
* Ref to Level1 data (clusters) is also set. |
* Ref to Level1 data (clusters) is also set. If l1==NULL no references are set. |
730 |
|
* (NB It make sense to set references only if events are stored in a tree that contains also the Level1 branch) |
731 |
*/ |
*/ |
732 |
void TrkLevel2::SetFromLevel2Struct(cTrkLevel2 *l2, TrkLevel1 *l1){ |
void TrkLevel2::SetFromLevel2Struct(cTrkLevel2 *l2, TrkLevel1 *l1){ |
733 |
|
|
734 |
|
// cout << "void TrkLevel2::SetFromLevel2Struct(cTrkLevel2 *l2, TrkLevel1 *l1)"<<endl; |
735 |
|
Clear(); |
736 |
// temporary objects: |
// temporary objects: |
737 |
TrkSinglet* t_singlet = new TrkSinglet(); |
TrkSinglet* t_singlet = new TrkSinglet(); |
738 |
TrkTrack* t_track = new TrkTrack(); |
TrkTrack* t_track = new TrkTrack(); |
739 |
// general variables |
|
740 |
// good2 = l2->good2; |
// ----------------- |
741 |
for(Int_t i=0; i<12 ; i++){ |
// general variables |
742 |
// crc[i] = l2->crc[i]; |
// ----------------- |
743 |
good[i] = l2->good[i]; |
for(Int_t i=0; i<12 ; i++){ |
744 |
}; |
good[i] = l2->good[i]; |
745 |
// *** TRACKS *** |
}; |
746 |
TClonesArray &t = *Track; |
// -------------- |
747 |
for(int i=0; i<l2->ntrk; i++){ |
// *** TRACKS *** |
748 |
t_track->seqno = i;// NBNBNBNB deve sempre essere = i |
// -------------- |
749 |
t_track->image = l2->image[i]-1; |
if(!Track) Track = new TClonesArray("TrkTrack"); |
750 |
// cout << "track "<<i<<t_track->seqno << t_track->image<<endl; |
TClonesArray &t = *Track; |
751 |
t_track->chi2 = l2->chi2_nt[i]; |
//----------------------------------------------------- |
752 |
t_track->nstep = l2->nstep_nt[i]; |
if( l1 && !t_track->clx )t_track->clx = new TRefArray(6,0); |
753 |
for(int it1=0;it1<5;it1++){ |
if( l1 && !t_track->cly )t_track->cly = new TRefArray(6,0); |
754 |
t_track->al[it1] = l2->al_nt[i][it1]; |
//----------------------------------------------------- |
755 |
for(int it2=0;it2<5;it2++) |
for(int i=0; i<l2->ntrk; i++){ |
756 |
t_track->coval[it1][it2] = l2->coval[i][it2][it1]; |
// cout <<" TRACK "<<i<<" ------------------ "<<endl; |
757 |
}; |
t_track->seqno = i;// NBNBNBNB deve sempre essere = i |
758 |
for(int ip=0;ip<6;ip++){ |
t_track->image = l2->image[i]-1; |
759 |
t_track->xgood[ip] = l2->xgood_nt[i][ip]; |
t_track->chi2 = l2->chi2_nt[i]; |
760 |
t_track->ygood[ip] = l2->ygood_nt[i][ip]; |
t_track->nstep = l2->nstep_nt[i]; |
761 |
t_track->xm[ip] = l2->xm_nt[i][ip]; |
for(int it1=0;it1<5;it1++){ |
762 |
t_track->ym[ip] = l2->ym_nt[i][ip]; |
t_track->al[it1] = l2->al_nt[i][it1]; |
763 |
t_track->zm[ip] = l2->zm_nt[i][ip]; |
for(int it2=0;it2<5;it2++) |
764 |
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(); |
|
765 |
}; |
}; |
766 |
// *** SINGLETS *** |
for(int ip=0;ip<6;ip++){ |
767 |
TClonesArray &sx = *SingletX; |
t_track->xgood[ip] = l2->cltrx[i][ip];//l2->xgood_nt[i][ip]; |
768 |
for(int i=0; i<l2->nclsx; i++){ |
t_track->ygood[ip] = l2->cltry[i][ip];//l2->ygood_nt[i][ip]; |
769 |
t_singlet->plane = l2->planex[i]; |
t_track->xm[ip] = l2->xm_nt[i][ip]; |
770 |
t_singlet->coord[0] = l2->xs[i][0]; |
t_track->ym[ip] = l2->ym_nt[i][ip]; |
771 |
t_singlet->coord[1] = l2->xs[i][1]; |
t_track->zm[ip] = l2->zm_nt[i][ip]; |
772 |
t_singlet->sgnl = l2->signlxs[i]; |
t_track->resx[ip] = l2->resx_nt[i][ip]; |
773 |
//----------------------------------------------------- |
t_track->resy[ip] = l2->resy_nt[i][ip]; |
774 |
// cout << "singolo x "<<i<<" -- "<< l2->clsx[i] <<endl; |
t_track->xv[ip] = l2->xv_nt[i][ip]; |
775 |
t_singlet->cls = l1->GetCluster(l2->clsx[i]-1); |
t_track->yv[ip] = l2->yv_nt[i][ip]; |
776 |
// 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]; |
777 |
//----------------------------------------------------- |
t_track->axv[ip] = l2->axv_nt[i][ip]; |
778 |
new(sx[i]) TrkSinglet(*t_singlet); |
t_track->ayv[ip] = l2->ayv_nt[i][ip]; |
779 |
t_singlet->Clear(); |
t_track->dedx_x[ip] = l2->dedx_x[i][ip]; |
780 |
} |
t_track->dedx_y[ip] = l2->dedx_y[i][ip]; |
781 |
TClonesArray &sy = *SingletY; |
// cout << " ip "<<ip<<" l2->cltrx[i][ip] "<< l2->cltrx[i][ip]<<endl; |
782 |
for(int i=0; i<l2->nclsy; i++){ |
// cout << " ip "<<ip<<" l2->cltry[i][ip] "<< l2->cltry[i][ip]<<endl; |
783 |
t_singlet->plane = l2->planey[i]; |
//----------------------------------------------------- |
784 |
t_singlet->coord[0] = l2->ys[i][0]; |
//----------------------------------------------------- |
785 |
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); |
786 |
t_singlet->sgnl = l2->signlys[i]; |
// if(l1 && t_track->ygood[ip])t_track->cly->AddAt(l1->GetCluster(l2->cltry[i][ip]-1),ip); |
787 |
//----------------------------------------------------- |
if(l2->xgood_nt[i][ip]){ |
788 |
// cout << "singolo y "<<i<<" -- "<< l2->clsy[i] <<endl; |
// cout << " ip "<<ip<<" l2->cltrx[i][ip] "<< l2->cltrx[i][ip]<<endl; |
789 |
t_singlet->cls = l1->GetCluster(l2->clsy[i]-1); |
// cout << " ip "<<ip<<" l2->cltrx[i][ip] "<< l2->cltrx[i][ip]<<" "; |
790 |
// 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 "; |
791 |
//----------------------------------------------------- |
if(l1)t_track->clx->AddAt(l1->GetCluster(l2->cltrx[i][ip]-1),ip); |
792 |
new(sy[i]) TrkSinglet(*t_singlet); |
// cout << " --- "<<l1->GetCluster(l2->cltrx[i][ip]-1)->GetUniqueID()<<endl; |
793 |
t_singlet->Clear(); |
// t_track->xgood[ip] = l2->cltrx[i][ip]; // WORK-AROUND ***** |
794 |
|
}else{ |
795 |
|
if(l1)t_track->clx->RemoveAt(ip); |
796 |
|
} |
797 |
|
if(l2->ygood_nt[i][ip]){ |
798 |
|
// cout << " ip "<<ip<<" l2->cltry[i][ip] "<< l2->cltry[i][ip]<<endl; |
799 |
|
// cout << " ip "<<ip<<" l2->cltry[i][ip] "<< l2->cltry[i][ip]<<" "; |
800 |
|
// if( l1->GetCluster(l2->cltry[i][ip]-1)->TestBit(l1->GetCluster(l2->cltry[i][ip]-1)->kIsReferenced) )cout << ">> is referenced "; |
801 |
|
if(l1)t_track->cly->AddAt(l1->GetCluster(l2->cltry[i][ip]-1),ip); |
802 |
|
// cout << " --- "<<l1->GetCluster(l2->cltry[i][ip]-1)->GetUniqueID()<<endl; |
803 |
|
// t_track->ygood[ip] = l2->cltry[i][ip]; // WORK-AROUND ***** |
804 |
|
}else{ |
805 |
|
if(l1)t_track->cly->RemoveAt(ip); |
806 |
|
} |
807 |
|
//----------------------------------------------------- |
808 |
|
//----------------------------------------------------- |
809 |
}; |
}; |
810 |
|
new(t[i]) TrkTrack(*t_track); |
811 |
|
t_track->Clear(); |
812 |
|
}; |
813 |
|
// ---------------- |
814 |
|
// *** SINGLETS *** |
815 |
|
// ---------------- |
816 |
|
if(!SingletX)SingletX = new TClonesArray("TrkSinglet"); |
817 |
|
TClonesArray &sx = *SingletX; |
818 |
|
for(int i=0; i<l2->nclsx; i++){ |
819 |
|
t_singlet->plane = l2->planex[i]; |
820 |
|
t_singlet->coord[0] = l2->xs[i][0]; |
821 |
|
t_singlet->coord[1] = l2->xs[i][1]; |
822 |
|
t_singlet->sgnl = l2->signlxs[i]; |
823 |
|
//----------------------------------------------------- |
824 |
|
if(l1) t_singlet->cls = l1->GetCluster(l2->clsx[i]-1); |
825 |
|
//----------------------------------------------------- |
826 |
|
new(sx[i]) TrkSinglet(*t_singlet); |
827 |
|
t_singlet->Clear(); |
828 |
|
} |
829 |
|
if(!SingletY)SingletY = new TClonesArray("TrkSinglet"); |
830 |
|
TClonesArray &sy = *SingletY; |
831 |
|
for(int i=0; i<l2->nclsy; i++){ |
832 |
|
t_singlet->plane = l2->planey[i]; |
833 |
|
t_singlet->coord[0] = l2->ys[i][0]; |
834 |
|
t_singlet->coord[1] = l2->ys[i][1]; |
835 |
|
t_singlet->sgnl = l2->signlys[i]; |
836 |
|
//----------------------------------------------------- |
837 |
|
if(l1) t_singlet->cls = l1->GetCluster(l2->clsy[i]-1); |
838 |
|
//----------------------------------------------------- |
839 |
|
new(sy[i]) TrkSinglet(*t_singlet); |
840 |
|
t_singlet->Clear(); |
841 |
|
}; |
842 |
|
|
843 |
delete t_track; |
delete t_track; |
844 |
delete t_singlet; |
delete t_singlet; |
845 |
} |
} |
846 |
/** |
/** |
847 |
* 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). |
857 |
}; |
}; |
858 |
// *** TRACKS *** |
// *** TRACKS *** |
859 |
|
|
860 |
l2->ntrk = Track->GetEntries(); |
if(Track){ |
861 |
for(Int_t i=0;i<l2->ntrk;i++){ |
l2->ntrk = Track->GetEntries(); |
862 |
l2->image[i] = 1 + ((TrkTrack *)Track->At(i))->image; |
for(Int_t i=0;i<l2->ntrk;i++){ |
863 |
l2->chi2_nt[i] = ((TrkTrack *)Track->At(i))->chi2; |
l2->image[i] = 1 + ((TrkTrack *)Track->At(i))->image; |
864 |
l2->nstep_nt[i] = ((TrkTrack *)Track->At(i))->nstep; |
l2->chi2_nt[i] = ((TrkTrack *)Track->At(i))->chi2; |
865 |
for(int it1=0;it1<5;it1++){ |
l2->nstep_nt[i] = ((TrkTrack *)Track->At(i))->nstep; |
866 |
l2->al_nt[i][it1] = ((TrkTrack *)Track->At(i))->al[it1]; |
for(int it1=0;it1<5;it1++){ |
867 |
for(int it2=0;it2<5;it2++) |
l2->al_nt[i][it1] = ((TrkTrack *)Track->At(i))->al[it1]; |
868 |
l2->coval[i][it2][it1] = ((TrkTrack *)Track->At(i))->coval[it1][it2]; |
for(int it2=0;it2<5;it2++) |
869 |
}; |
l2->coval[i][it2][it1] = ((TrkTrack *)Track->At(i))->coval[it1][it2]; |
870 |
for(int ip=0;ip<6;ip++){ |
}; |
871 |
l2->xgood_nt[i][ip] = ((TrkTrack *)Track->At(i))->xgood[ip]; |
for(int ip=0;ip<6;ip++){ |
872 |
l2->ygood_nt[i][ip] = ((TrkTrack *)Track->At(i))->ygood[ip]; |
l2->xgood_nt[i][ip] = ((TrkTrack *)Track->At(i))->XGood(ip); |
873 |
l2->xm_nt[i][ip] = ((TrkTrack *)Track->At(i))->xm[ip]; |
l2->ygood_nt[i][ip] = ((TrkTrack *)Track->At(i))->YGood(ip); |
874 |
l2->ym_nt[i][ip] = ((TrkTrack *)Track->At(i))->ym[ip]; |
l2->xm_nt[i][ip] = ((TrkTrack *)Track->At(i))->xm[ip]; |
875 |
l2->zm_nt[i][ip] = ((TrkTrack *)Track->At(i))->zm[ip]; |
l2->ym_nt[i][ip] = ((TrkTrack *)Track->At(i))->ym[ip]; |
876 |
l2->resx_nt[i][ip] = ((TrkTrack *)Track->At(i))->resx[ip]; |
l2->zm_nt[i][ip] = ((TrkTrack *)Track->At(i))->zm[ip]; |
877 |
l2->resy_nt[i][ip] = ((TrkTrack *)Track->At(i))->resy[ip]; |
l2->resx_nt[i][ip] = ((TrkTrack *)Track->At(i))->resx[ip]; |
878 |
l2->xv_nt[i][ip] = ((TrkTrack *)Track->At(i))->xv[ip]; |
l2->resy_nt[i][ip] = ((TrkTrack *)Track->At(i))->resy[ip]; |
879 |
l2->yv_nt[i][ip] = ((TrkTrack *)Track->At(i))->yv[ip]; |
l2->xv_nt[i][ip] = ((TrkTrack *)Track->At(i))->xv[ip]; |
880 |
l2->zv_nt[i][ip] = ((TrkTrack *)Track->At(i))->zv[ip]; |
l2->yv_nt[i][ip] = ((TrkTrack *)Track->At(i))->yv[ip]; |
881 |
l2->axv_nt[i][ip] = ((TrkTrack *)Track->At(i))->axv[ip]; |
l2->zv_nt[i][ip] = ((TrkTrack *)Track->At(i))->zv[ip]; |
882 |
l2->ayv_nt[i][ip] = ((TrkTrack *)Track->At(i))->ayv[ip]; |
l2->axv_nt[i][ip] = ((TrkTrack *)Track->At(i))->axv[ip]; |
883 |
l2->dedx_x[i][ip] = ((TrkTrack *)Track->At(i))->dedx_x[ip]; |
l2->ayv_nt[i][ip] = ((TrkTrack *)Track->At(i))->ayv[ip]; |
884 |
l2->dedx_y[i][ip] = ((TrkTrack *)Track->At(i))->dedx_y[ip]; |
l2->dedx_x[i][ip] = ((TrkTrack *)Track->At(i))->dedx_x[ip]; |
885 |
}; |
l2->dedx_y[i][ip] = ((TrkTrack *)Track->At(i))->dedx_y[ip]; |
886 |
|
}; |
887 |
|
} |
888 |
} |
} |
|
|
|
889 |
// *** SINGLETS *** |
// *** SINGLETS *** |
890 |
l2->nclsx = SingletX->GetEntries(); |
if(SingletX){ |
891 |
for(Int_t i=0;i<l2->nclsx;i++){ |
l2->nclsx = SingletX->GetEntries(); |
892 |
l2->planex[i] = ((TrkSinglet *)SingletX->At(i))->plane; |
for(Int_t i=0;i<l2->nclsx;i++){ |
893 |
l2->xs[i][0] = ((TrkSinglet *)SingletX->At(i))->coord[0]; |
l2->planex[i] = ((TrkSinglet *)SingletX->At(i))->plane; |
894 |
l2->xs[i][1] = ((TrkSinglet *)SingletX->At(i))->coord[1]; |
l2->xs[i][0] = ((TrkSinglet *)SingletX->At(i))->coord[0]; |
895 |
l2->signlxs[i] = ((TrkSinglet *)SingletX->At(i))->sgnl; |
l2->xs[i][1] = ((TrkSinglet *)SingletX->At(i))->coord[1]; |
896 |
} |
l2->signlxs[i] = ((TrkSinglet *)SingletX->At(i))->sgnl; |
897 |
l2->nclsy = SingletY->GetEntries(); |
} |
898 |
for(Int_t i=0;i<l2->nclsy;i++){ |
} |
899 |
l2->planey[i] = ((TrkSinglet *)SingletY->At(i))->plane; |
|
900 |
l2->ys[i][0] = ((TrkSinglet *)SingletY->At(i))->coord[0]; |
if(SingletY){ |
901 |
l2->ys[i][1] = ((TrkSinglet *)SingletY->At(i))->coord[1]; |
l2->nclsy = SingletY->GetEntries(); |
902 |
l2->signlys[i] = ((TrkSinglet *)SingletY->At(i))->sgnl; |
for(Int_t i=0;i<l2->nclsy;i++){ |
903 |
|
l2->planey[i] = ((TrkSinglet *)SingletY->At(i))->plane; |
904 |
|
l2->ys[i][0] = ((TrkSinglet *)SingletY->At(i))->coord[0]; |
905 |
|
l2->ys[i][1] = ((TrkSinglet *)SingletY->At(i))->coord[1]; |
906 |
|
l2->signlys[i] = ((TrkSinglet *)SingletY->At(i))->sgnl; |
907 |
|
} |
908 |
} |
} |
909 |
} |
} |
910 |
//-------------------------------------- |
//-------------------------------------- |
912 |
// |
// |
913 |
//-------------------------------------- |
//-------------------------------------- |
914 |
void TrkLevel2::Clear(){ |
void TrkLevel2::Clear(){ |
|
// good2 = -1; |
|
915 |
for(Int_t i=0; i<12 ; i++){ |
for(Int_t i=0; i<12 ; i++){ |
916 |
// crc[i] = -1; |
good[i] = -1; |
917 |
good[i] = -1; |
}; |
918 |
}; |
// if(Track)Track->Clear("C"); |
919 |
/* Track->RemoveAll(); |
// if(SingletX)SingletX->Clear("C"); |
920 |
SingletX->RemoveAll(); |
// if(SingletY)SingletY->Clear("C"); |
921 |
SingletY->RemoveAll();*/ |
if(Track)Track->Delete(); |
922 |
// modify to avoid memory leakage |
if(SingletX)SingletX->Delete(); |
923 |
Track->Clear(); |
if(SingletY)SingletY->Delete(); |
924 |
SingletX->Clear(); |
} |
925 |
SingletY->Clear(); |
// //-------------------------------------- |
926 |
} |
// // |
927 |
//-------------------------------------- |
// // |
928 |
// |
// //-------------------------------------- |
|
// |
|
|
//-------------------------------------- |
|
929 |
void TrkLevel2::Delete(){ |
void TrkLevel2::Delete(){ |
930 |
|
|
931 |
Clear(); |
// cout << "void TrkLevel2::Delete()"<<endl; |
932 |
Track->Delete(); |
Clear(); |
933 |
SingletX->Delete(); |
if(Track)delete Track; |
934 |
SingletY->Delete(); |
if(SingletX)delete SingletX; |
935 |
|
if(SingletY)delete SingletY; |
936 |
|
|
937 |
} |
} |
938 |
//-------------------------------------- |
//-------------------------------------- |
939 |
// |
// |
945 |
*/ |
*/ |
946 |
TRefArray *TrkLevel2::GetTracks_NFitSorted(){ |
TRefArray *TrkLevel2::GetTracks_NFitSorted(){ |
947 |
|
|
948 |
TRefArray *sorted = new TRefArray(); |
if(!Track)return 0; |
949 |
|
|
950 |
|
TRefArray *sorted = new TRefArray(); |
951 |
|
|
952 |
TClonesArray &t = *Track; |
TClonesArray &t = *Track; |
953 |
// TClonesArray &ts = *PhysicalTrack; |
// TClonesArray &ts = *PhysicalTrack; |
954 |
int N = ntrk(); |
int N = ntrk(); |
955 |
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; |
956 |
// 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; |
957 |
|
|
958 |
int indo=0; |
int indo=0; |
959 |
int indi=0; |
int indi=0; |
960 |
while(N != 0){ |
while(N > 0){ |
961 |
int nfit =0; |
// while(N != 0){ |
962 |
float chi2ref = numeric_limits<float>::max(); |
int nfit =0; |
963 |
|
float chi2ref = numeric_limits<float>::max(); |
964 |
|
|
965 |
// first loop to search maximum num. of fit points |
// first loop to search maximum num. of fit points |
966 |
for(int i=0; i < ntrk(); i++){ |
for(int i=0; i < ntrk(); i++){ |
967 |
if( ((TrkTrack *)t[i])->GetNtot() >= nfit && m[i]==1){ |
if( ((TrkTrack *)t[i])->GetNtot() >= nfit && m[i]==1){ |
968 |
nfit = ((TrkTrack *)t[i])->GetNtot(); |
nfit = ((TrkTrack *)t[i])->GetNtot(); |
969 |
} |
} |
970 |
} |
} |
971 |
//second loop to search minimum chi2 among selected |
//second loop to search minimum chi2 among selected |
972 |
for(int i=0; i<this->ntrk(); i++){ |
for(int i=0; i<ntrk(); i++){ |
973 |
Float_t chi2 = ((TrkTrack *)t[i])->chi2; |
Float_t chi2 = ((TrkTrack *)t[i])->chi2; |
974 |
if(chi2 < 0) chi2 = chi2*1000; |
if(chi2 < 0) chi2 = -chi2*1000; |
975 |
if( chi2 < chi2ref |
if( chi2 < chi2ref |
976 |
&& ((TrkTrack *)t[i])->GetNtot() == nfit |
&& ((TrkTrack *)t[i])->GetNtot() == nfit |
977 |
&& m[i]==1){ |
&& m[i]==1){ |
978 |
chi2ref = ((TrkTrack *)t[i])->chi2; |
chi2ref = ((TrkTrack *)t[i])->chi2; |
979 |
indi = i; |
indi = i; |
980 |
}; |
}; |
981 |
}; |
}; |
982 |
if( ((TrkTrack *)t[indi])->HasImage() ){ |
if( ((TrkTrack *)t[indi])->HasImage() ){ |
983 |
m[((TrkTrack *)t[indi])->image] = 0; |
m[((TrkTrack *)t[indi])->image] = 0; |
984 |
N--; |
N--; |
985 |
|
|
986 |
// cout << "i** "<< ((TrkTrack *)t[indi])->image << " " << nfiti <<" "<<chi2i<<endl; |
// cout << "i** "<< ((TrkTrack *)t[indi])->image << " " << nfiti <<" "<<chi2i<<endl; |
987 |
}; |
}; |
988 |
sorted->Add( (TrkTrack*)t[indi] ); |
sorted->Add( (TrkTrack*)t[indi] ); |
989 |
|
|
990 |
m[indi] = 0; |
m[indi] = 0; |
991 |
// cout << "SORTED "<< indo << " "<< indi << " "<< N << endl; |
// cout << "SORTED "<< indo << " "<< indi << " "<< N << " "<<((TrkTrack *)t[indi])->image<<" "<<chi2ref<<endl; |
992 |
N--; |
N--; |
993 |
indo++; |
indo++; |
994 |
} |
} |
995 |
m.clear(); |
m.clear(); |
996 |
// cout << "GetTracks_NFitSorted(it): Done"<< endl; |
// cout << "GetTracks_NFitSorted(it): Done"<< endl; |
997 |
|
|
998 |
return sorted; |
return sorted; |
999 |
// return PhysicalTrack; |
// return PhysicalTrack; |
1000 |
} |
} |
1001 |
//-------------------------------------- |
//-------------------------------------- |
1014 |
cout << " Stored tracks ntrk() = "<< this->ntrk() << endl; |
cout << " Stored tracks ntrk() = "<< this->ntrk() << endl; |
1015 |
return 0; |
return 0; |
1016 |
} |
} |
1017 |
|
if(!Track){ |
1018 |
|
cout << "TrkTrack *TrkLevel2::GetStoredTrack(int is) >> (TClonesArray*) Track ==0 "<<endl; |
1019 |
|
}; |
1020 |
TClonesArray &t = *(Track); |
TClonesArray &t = *(Track); |
1021 |
TrkTrack *track = (TrkTrack*)t[is]; |
TrkTrack *track = (TrkTrack*)t[is]; |
1022 |
return track; |
return track; |
1036 |
cout << " Stored x-singlets nclsx() = "<< this->nclsx() << endl; |
cout << " Stored x-singlets nclsx() = "<< this->nclsx() << endl; |
1037 |
return 0; |
return 0; |
1038 |
} |
} |
1039 |
|
if(!SingletX)return 0; |
1040 |
TClonesArray &t = *(SingletX); |
TClonesArray &t = *(SingletX); |
1041 |
TrkSinglet *singlet = (TrkSinglet*)t[is]; |
TrkSinglet *singlet = (TrkSinglet*)t[is]; |
1042 |
return singlet; |
return singlet; |
1056 |
cout << " Stored y-singlets nclsy() = "<< this->nclsx() << endl; |
cout << " Stored y-singlets nclsy() = "<< this->nclsx() << endl; |
1057 |
return 0; |
return 0; |
1058 |
} |
} |
1059 |
|
if(!SingletY)return 0; |
1060 |
TClonesArray &t = *(SingletY); |
TClonesArray &t = *(SingletY); |
1061 |
TrkSinglet *singlet = (TrkSinglet*)t[is]; |
TrkSinglet *singlet = (TrkSinglet*)t[is]; |
1062 |
return singlet; |
return singlet; |
1079 |
} |
} |
1080 |
|
|
1081 |
TRefArray *sorted = GetTracks(); //TEMPORANEO |
TRefArray *sorted = GetTracks(); //TEMPORANEO |
1082 |
|
if(!sorted)return 0; |
1083 |
TrkTrack *track = (TrkTrack*)sorted->At(it); |
TrkTrack *track = (TrkTrack*)sorted->At(it); |
1084 |
sorted->Delete(); |
sorted->Clear(); |
1085 |
|
delete sorted; |
1086 |
return track; |
return track; |
1087 |
} |
} |
1088 |
/** |
/** |
1091 |
Int_t TrkLevel2::GetNTracks(){ |
Int_t TrkLevel2::GetNTracks(){ |
1092 |
|
|
1093 |
Float_t ntot=0; |
Float_t ntot=0; |
1094 |
|
if(!Track)return 0; |
1095 |
TClonesArray &t = *Track; |
TClonesArray &t = *Track; |
1096 |
for(int i=0; i<ntrk(); i++) { |
for(int i=0; i<ntrk(); i++) { |
1097 |
if( ((TrkTrack *)t[i])->GetImageSeqNo() == -1 ) ntot+=1.; |
if( ((TrkTrack *)t[i])->GetImageSeqNo() == -1 ) ntot+=1.; |
1110 |
*/ |
*/ |
1111 |
TrkTrack *TrkLevel2::GetTrackImage(int it){ |
TrkTrack *TrkLevel2::GetTrackImage(int it){ |
1112 |
|
|
1113 |
if(it >= this->GetNTracks()){ |
if(it >= this->GetNTracks()){ |
1114 |
cout << "** TrkLevel2 ** Track "<< it << "does not exits! " << endl; |
cout << "** TrkLevel2 ** Track "<< it << "does not exits! " << endl; |
1115 |
cout << " Physical tracks GetNTracks() = "<< this->ntrk() << endl; |
cout << " Physical tracks GetNTracks() = "<< this->ntrk() << endl; |
1116 |
return 0; |
return 0; |
1117 |
} |
} |
1118 |
|
|
1119 |
TRefArray* sorted = GetTracks(); //TEMPORANEO |
TRefArray* sorted = GetTracks(); //TEMPORANEO |
1120 |
TrkTrack *track = (TrkTrack*)sorted->At(it); |
if(!sorted)return 0; |
1121 |
|
TrkTrack *track = (TrkTrack*)sorted->At(it); |
1122 |
|
|
1123 |
if(!track->HasImage()){ |
if(!track->HasImage()){ |
1124 |
cout << "** TrkLevel2 ** Track "<< it << "does not have image! " << endl; |
cout << "** TrkLevel2 ** Track "<< it << "does not have image! " << endl; |
1125 |
return 0; |
return 0; |
1126 |
} |
} |
1127 |
TrkTrack *image = (TrkTrack*)(*Track)[track->image]; |
if(!Track)return 0; |
1128 |
|
TrkTrack *image = (TrkTrack*)(*Track)[track->image]; |
1129 |
|
|
1130 |
sorted->Delete(); |
sorted->Delete(); |
1131 |
|
delete sorted; |
1132 |
return image; |
|
1133 |
|
return image; |
1134 |
|
|
1135 |
} |
} |
1136 |
//-------------------------------------- |
//-------------------------------------- |
1141 |
* Loads the magnetic field. |
* Loads the magnetic field. |
1142 |
* @param s Path of the magnetic-field files. |
* @param s Path of the magnetic-field files. |
1143 |
*/ |
*/ |
1144 |
void TrkLevel2::LoadField(TString s){ |
void TrkLevel2::LoadField(TString path){ |
1145 |
readb_(s.Data()); |
// |
1146 |
|
// strcpy(path_.path,path.Data()); |
1147 |
|
// path_.pathlen = path.Length(); |
1148 |
|
// path_.error = 0; |
1149 |
|
// readb_(); |
1150 |
|
|
1151 |
|
TrkParams::Set(path,1); |
1152 |
|
TrkParams::Load(1); |
1153 |
|
|
1154 |
|
// |
1155 |
}; |
}; |
1156 |
|
/** |
1157 |
|
* Get BY (kGauss) |
1158 |
|
* @param v (x,y,z) coordinates in cm |
1159 |
|
*/ |
1160 |
|
float TrkLevel2::GetBX(float* v){ |
1161 |
|
float b[3]; |
1162 |
|
gufld_(v,b); |
1163 |
|
return b[0]/10.; |
1164 |
|
} |
1165 |
|
/** |
1166 |
|
* Get BY (kGauss) |
1167 |
|
* @param v (x,y,z) coordinates in cm |
1168 |
|
*/ |
1169 |
|
float TrkLevel2::GetBY(float* v){ |
1170 |
|
float b[3]; |
1171 |
|
gufld_(v,b); |
1172 |
|
return b[1]/10.; |
1173 |
|
} |
1174 |
|
/** |
1175 |
|
* Get BY (kGauss) |
1176 |
|
* @param v (x,y,z) coordinates in cm |
1177 |
|
*/ |
1178 |
|
float TrkLevel2::GetBZ(float* v){ |
1179 |
|
float b[3]; |
1180 |
|
gufld_(v,b); |
1181 |
|
return b[2]/10.; |
1182 |
|
} |
1183 |
//-------------------------------------- |
//-------------------------------------- |
1184 |
// |
// |
1185 |
// |
// |
1276 |
tl = new float[npoint]; |
tl = new float[npoint]; |
1277 |
int i=0; |
int i=0; |
1278 |
do{ |
do{ |
1279 |
x[i] = 0; |
x[i] = 0; |
1280 |
y[i] = 0; |
y[i] = 0; |
1281 |
z[i] = zin[i]; |
z[i] = zin[i]; |
1282 |
thx[i] = 0; |
thx[i] = 0; |
1283 |
thy[i] = 0; |
thy[i] = 0; |
1284 |
tl[i] = 0; |
tl[i] = 0; |
1285 |
i++; |
i++; |
1286 |
}while(zin[i-1] > zin[i] && i < npoint); |
}while(zin[i-1] > zin[i] && i < npoint); |
1287 |
npoint=i; |
npoint=i; |
1288 |
if(npoint != n)cout << "NB! Trajectory created with "<<npoint<<" points"<<endl; |
if(npoint != n)cout << "NB! Trajectory created with "<<npoint<<" points"<<endl; |
1289 |
} |
} |
1290 |
|
void Trajectory::Delete(){ |
1291 |
|
|
1292 |
|
if(x) delete [] x; |
1293 |
|
if(y) delete [] y; |
1294 |
|
if(z) delete [] z; |
1295 |
|
if(thx) delete [] thx; |
1296 |
|
if(thy) delete [] thy; |
1297 |
|
if(tl) delete [] tl; |
1298 |
|
|
1299 |
|
} |
1300 |
//-------------------------------------- |
//-------------------------------------- |
1301 |
// |
// |
1302 |
// |
// |
1335 |
|
|
1336 |
} |
} |
1337 |
|
|
1338 |
|
/** |
1339 |
|
* Evaluates the trajectory in the apparatus associated to the track. |
1340 |
|
* 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. |
1341 |
|
* @param t pointer to an object of the class Trajectory, |
1342 |
|
* which z coordinates should be previously initialized by calling the proper constructor ( Trajectory::Trajectory(int n, float* zin) ). |
1343 |
|
* @return error flag. |
1344 |
|
*/ |
1345 |
|
int Trajectory::DoTrack2(float* al){ |
1346 |
|
|
1347 |
|
double *dxout = new double[npoint]; |
1348 |
|
double *dyout = new double[npoint]; |
1349 |
|
double *dthxout = new double[npoint]; |
1350 |
|
double *dthyout = new double[npoint]; |
1351 |
|
double *dtlout = new double[npoint]; |
1352 |
|
double *dzin = new double[npoint]; |
1353 |
|
double dal[5]; |
1354 |
|
|
1355 |
|
int ifail = 0; |
1356 |
|
|
1357 |
|
for (int i=0; i<5; i++) dal[i] = (double)al[i]; |
1358 |
|
for (int i=0; i<npoint; i++) dzin[i] = (double)z[i]; |
1359 |
|
|
1360 |
|
TrkParams::Load(1); |
1361 |
|
if( !TrkParams::IsLoaded(1) ){ |
1362 |
|
cout << "int Trajectory::DoTrack2(float* al) --- ERROR --- m.field not loaded"<<endl; |
1363 |
|
return 0; |
1364 |
|
} |
1365 |
|
dotrack2_(&(npoint),dzin,dxout,dyout,dthxout,dthyout,dtlout,dal,&ifail); |
1366 |
|
|
1367 |
|
for (int i=0; i<npoint; i++){ |
1368 |
|
x[i] = (float)*dxout++; |
1369 |
|
y[i] = (float)*dyout++; |
1370 |
|
thx[i] = (float)*dthxout++; |
1371 |
|
thy[i] = (float)*dthyout++; |
1372 |
|
tl[i] = (float)*dtlout++; |
1373 |
|
} |
1374 |
|
|
1375 |
|
return ifail; |
1376 |
|
}; |
1377 |
|
|
1378 |
ClassImp(TrkLevel2); |
ClassImp(TrkLevel2); |
1379 |
ClassImp(TrkSinglet); |
ClassImp(TrkSinglet); |