10 |
//...................................... |
//...................................... |
11 |
extern "C" { |
extern "C" { |
12 |
void dotrack_(int*, double*, double*, double*, double*, int*); |
void dotrack_(int*, double*, double*, double*, double*, int*); |
13 |
int readb_(const char*); |
void dotrack2_(int*, double*, double*, double*, double*,double*, double*, double*,int*); |
14 |
|
int readb_(const char*); |
15 |
|
void mini2_(int*,int*,int*); |
16 |
} |
} |
17 |
//-------------------------------------- |
//-------------------------------------- |
18 |
// |
// |
19 |
// |
// |
20 |
//-------------------------------------- |
//-------------------------------------- |
21 |
TrkTrack::TrkTrack(){ |
TrkTrack::TrkTrack(){ |
22 |
image = 0; |
seqno = -1; |
23 |
|
image = -1; |
24 |
chi2 = 0; |
chi2 = 0; |
25 |
for(int it1=0;it1<5;it1++){ |
nstep = 0; |
26 |
al[it1] = 0; |
for(int it1=0;it1<5;it1++){ |
27 |
for(int it2=0;it2<5;it2++) |
al[it1] = 0; |
28 |
coval[it1][it2] = 0; |
for(int it2=0;it2<5;it2++)coval[it1][it2] = 0; |
29 |
}; |
}; |
30 |
for(int ip=0;ip<6;ip++){ |
for(int ip=0;ip<6;ip++){ |
31 |
xgood[ip] = 0; |
xgood[ip] = 0; |
32 |
ygood[ip] = 0; |
ygood[ip] = 0; |
33 |
xm[ip] = 0; |
xm[ip] = 0; |
34 |
ym[ip] = 0; |
ym[ip] = 0; |
35 |
zm[ip] = 0; |
zm[ip] = 0; |
36 |
resx[ip] = 0; |
resx[ip] = 0; |
37 |
resy[ip] = 0; |
resy[ip] = 0; |
38 |
xv[ip] = 0; |
xv[ip] = 0; |
39 |
yv[ip] = 0; |
yv[ip] = 0; |
40 |
zv[ip] = 0; |
zv[ip] = 0; |
41 |
axv[ip] = 0; |
axv[ip] = 0; |
42 |
ayv[ip] = 0; |
ayv[ip] = 0; |
43 |
dedx_x[ip] = 0; |
dedx_x[ip] = 0; |
44 |
dedx_y[ip] = 0; |
dedx_y[ip] = 0; |
45 |
}; |
// clx[ip] = 0; |
46 |
|
// cly[ip] = 0; |
47 |
|
}; |
48 |
|
clx = new TRefArray(6,0); |
49 |
|
cly = new TRefArray(6,0); |
50 |
}; |
}; |
51 |
//-------------------------------------- |
//-------------------------------------- |
52 |
// |
// |
53 |
// |
// |
54 |
//-------------------------------------- |
//-------------------------------------- |
55 |
TrkTrack::TrkTrack(const TrkTrack& t){ |
TrkTrack::TrkTrack(const TrkTrack& t){ |
56 |
|
seqno = t.seqno; |
57 |
image = t.image; |
image = t.image; |
58 |
chi2 = t.chi2; |
chi2 = t.chi2; |
59 |
for(int it1=0;it1<5;it1++){ |
nstep = t.nstep; |
60 |
al[it1] = t.al[it1]; |
for(int it1=0;it1<5;it1++){ |
61 |
for(int it2=0;it2<5;it2++) |
al[it1] = t.al[it1]; |
62 |
coval[it1][it2] = t.coval[it1][it2]; |
for(int it2=0;it2<5;it2++)coval[it1][it2] = t.coval[it1][it2]; |
63 |
}; |
}; |
64 |
for(int ip=0;ip<6;ip++){ |
for(int ip=0;ip<6;ip++){ |
65 |
xgood[ip] = t.xgood[ip]; |
xgood[ip] = t.xgood[ip]; |
66 |
ygood[ip] = t.ygood[ip]; |
ygood[ip] = t.ygood[ip]; |
67 |
xm[ip] = t.xm[ip]; |
xm[ip] = t.xm[ip]; |
68 |
ym[ip] = t.ym[ip]; |
ym[ip] = t.ym[ip]; |
69 |
zm[ip] = t.zm[ip]; |
zm[ip] = t.zm[ip]; |
70 |
resx[ip] = t.resx[ip]; |
resx[ip] = t.resx[ip]; |
71 |
resy[ip] = t.resy[ip]; |
resy[ip] = t.resy[ip]; |
72 |
xv[ip] = t.xv[ip]; |
xv[ip] = t.xv[ip]; |
73 |
yv[ip] = t.yv[ip]; |
yv[ip] = t.yv[ip]; |
74 |
zv[ip] = t.zv[ip]; |
zv[ip] = t.zv[ip]; |
75 |
axv[ip] = t.axv[ip]; |
axv[ip] = t.axv[ip]; |
76 |
ayv[ip] = t.ayv[ip]; |
ayv[ip] = t.ayv[ip]; |
77 |
dedx_x[ip] = t.dedx_x[ip]; |
dedx_x[ip] = t.dedx_x[ip]; |
78 |
dedx_y[ip] = t.dedx_y[ip]; |
dedx_y[ip] = t.dedx_y[ip]; |
79 |
}; |
// clx[ip] = 0;//<<<<pointer |
80 |
|
// cly[ip] = 0;//<<<<pointer |
81 |
|
}; |
82 |
|
clx = new TRefArray(*(t.clx)); |
83 |
|
cly = new TRefArray(*(t.cly)); |
84 |
|
|
85 |
}; |
}; |
86 |
//-------------------------------------- |
//-------------------------------------- |
87 |
// |
// |
123 |
// |
// |
124 |
// |
// |
125 |
//-------------------------------------- |
//-------------------------------------- |
126 |
|
/** |
127 |
|
* Evaluates the trajectory in the apparatus associated to the track. |
128 |
|
* 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. |
129 |
|
* @param t pointer to an object of the class Trajectory, |
130 |
|
* which z coordinates should be previously initialized by calling the proper constructor ( Trajectory::Trajectory(int n, float* zin) ). |
131 |
|
* @return error flag. |
132 |
|
*/ |
133 |
|
int TrkTrack::DoTrack2(Trajectory* t){ |
134 |
|
|
135 |
|
double *dxout = new double[t->npoint]; |
136 |
|
double *dyout = new double[t->npoint]; |
137 |
|
double *dthxout = new double[t->npoint]; |
138 |
|
double *dthyout = new double[t->npoint]; |
139 |
|
double *dtlout = new double[t->npoint]; |
140 |
|
double *dzin = new double[t->npoint]; |
141 |
|
double dal[5]; |
142 |
|
|
143 |
|
int ifail = 0; |
144 |
|
|
145 |
|
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]; |
147 |
|
|
148 |
|
dotrack2_(&(t->npoint),dzin,dxout,dyout,dthxout,dthyout,dtlout,dal,&ifail); |
149 |
|
|
150 |
|
for (int i=0; i<t->npoint; i++){ |
151 |
|
t->x[i] = (float)*dxout++; |
152 |
|
t->y[i] = (float)*dyout++; |
153 |
|
t->thx[i] = (float)*dthxout++; |
154 |
|
t->thy[i] = (float)*dthyout++; |
155 |
|
t->tl[i] = (float)*dtlout++; |
156 |
|
} |
157 |
|
|
158 |
|
// delete [] dxout; |
159 |
|
// delete [] dyout; |
160 |
|
// delete [] dzin; |
161 |
|
|
162 |
|
return ifail; |
163 |
|
}; |
164 |
|
//-------------------------------------- |
165 |
|
// |
166 |
|
// |
167 |
|
//-------------------------------------- |
168 |
//float TrkTrack::BdL(){ |
//float TrkTrack::BdL(){ |
169 |
//}; |
//}; |
170 |
//-------------------------------------- |
//-------------------------------------- |
197 |
//-------------------------------------- |
//-------------------------------------- |
198 |
void TrkTrack::Dump(){ |
void TrkTrack::Dump(){ |
199 |
cout << endl << "========== Track " ; |
cout << endl << "========== Track " ; |
200 |
|
cout << endl << "seq. n. : "<< seqno; |
201 |
|
cout << endl << "image n. : "<< image; |
202 |
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] << " "; |
203 |
cout << endl << "chi^2 : "<< chi2; |
cout << endl << "chi^2 : "<< chi2; |
204 |
|
cout << endl << "n.step : "<< nstep; |
205 |
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] ; |
206 |
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] ; |
207 |
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] << " "; |
208 |
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] << " "; |
209 |
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] << " "; |
210 |
|
cout << endl << "xv : "; for(int i=0; i<6; i++)cout << xv[i] << " "; |
211 |
|
cout << endl << "yv : "; for(int i=0; i<6; i++)cout << yv[i] << " "; |
212 |
|
cout << endl << "zv : "; for(int i=0; i<6; i++)cout << zv[i] << " "; |
213 |
|
cout << endl << "resx : "; for(int i=0; i<6; i++)cout << resx[i] << " "; |
214 |
|
cout << endl << "resy : "; for(int i=0; i<6; i++)cout << resy[i] << " "; |
215 |
|
cout << endl << "coval : "; for(int i=0; i<5; i++)cout << coval[0][i]<<" "; |
216 |
|
cout << endl << " "; for(int i=0; i<5; i++)cout << coval[1][i]<<" "; |
217 |
|
cout << endl << " "; for(int i=0; i<5; i++)cout << coval[2][i]<<" "; |
218 |
|
cout << endl << " "; for(int i=0; i<5; i++)cout << coval[3][i]<<" "; |
219 |
|
cout << endl << " "; for(int i=0; i<5; i++)cout << coval[4][i]<<" "; |
220 |
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] << " "; |
221 |
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] << " "; |
222 |
} |
} |
223 |
|
/** |
224 |
|
* Set the TrkTrack position measurements |
225 |
|
*/ |
226 |
|
void TrkTrack::SetMeasure(double *xmeas, double *ymeas, double *zmeas){ |
227 |
|
for(int i=0; i<6; i++) xm[i]=*xmeas++; |
228 |
|
for(int i=0; i<6; i++) ym[i]=*ymeas++; |
229 |
|
for(int i=0; i<6; i++) zm[i]=*zmeas++; |
230 |
|
} |
231 |
|
/** |
232 |
|
* Set the TrkTrack position resolution |
233 |
|
*/ |
234 |
|
void TrkTrack::SetResolution(double *rx, double *ry){ |
235 |
|
for(int i=0; i<6; i++) resx[i]=*rx++; |
236 |
|
for(int i=0; i<6; i++) resy[i]=*ry++; |
237 |
|
} |
238 |
|
/** |
239 |
|
* Set the TrkTrack good measurement |
240 |
|
*/ |
241 |
|
void TrkTrack::SetGood(int *xg, int *yg){ |
242 |
|
for(int i=0; i<6; i++) xgood[i]=*xg++; |
243 |
|
for(int i=0; i<6; i++) ygood[i]=*yg++; |
244 |
|
} |
245 |
|
|
246 |
|
/** |
247 |
|
* Load the magnetic field |
248 |
|
*/ |
249 |
|
void TrkTrack::LoadField(TString s){ |
250 |
|
readb_(s.Data()); |
251 |
|
}; |
252 |
|
/** |
253 |
|
* Tracking method. It calls F77 mini routine. |
254 |
|
*/ |
255 |
|
void TrkTrack::Fit(double pfixed, int& fail, int iprint){ |
256 |
|
extern cMini2track track_; |
257 |
|
fail = 0; |
258 |
|
// extern cMini2fitinfo fit_info_; |
259 |
|
// extern void mini_2_(int*,int*); |
260 |
|
// track_.xm[0]=1.0; |
261 |
|
for(int i=0; i<6; i++) track_.xm[i]=xm[i]; |
262 |
|
for(int i=0; i<6; i++) track_.ym[i]=ym[i]; |
263 |
|
for(int i=0; i<6; i++) track_.zm[i]=zm[i]; |
264 |
|
for(int i=0; i<6; i++) track_.resx[i]=resx[i]; |
265 |
|
for(int i=0; i<6; i++) track_.resy[i]=resy[i]; |
266 |
|
for(int i=0; i<6; i++) track_.xgood[i]=xgood[i]; |
267 |
|
for(int i=0; i<6; i++) track_.ygood[i]=ygood[i]; |
268 |
|
// initial guess of "al" with linear fit |
269 |
|
if(al[0]==-9999.&&al[1]==-9999.&&al[2]==-9999.&&al[3]==-9999.&&al[4]==-9999.){ |
270 |
|
double szz=0., szx=0., szy=0., ssx=0., ssy=0., sz=0., s1=0.; |
271 |
|
double det, ax, ay, bx, by; |
272 |
|
for(int i=0; i<NPLANE; i++) { |
273 |
|
szz=szz+zm[i]*zm[i]; |
274 |
|
szx=szx+zm[i]*xm[i]; |
275 |
|
szy=szy+zm[i]*ym[i]; |
276 |
|
ssx=ssx+xm[i]; |
277 |
|
ssy=ssy+ym[i]; |
278 |
|
sz=sz+zm[i]; |
279 |
|
s1=s1+1.; |
280 |
|
} |
281 |
|
det=szz*s1-sz*sz; |
282 |
|
ax=(szx*s1-sz*ssx)/det; |
283 |
|
bx=(szz*ssx-szx*sz)/det; |
284 |
|
ay=(szy*s1-sz*ssy)/det; |
285 |
|
by=(szz*ssy-szy*sz)/det; |
286 |
|
al[0]=ax*23.5+bx; // ZINI = 23.5 !!! it should be the same parameter in all codes |
287 |
|
al[1]=ay*23.5+by; // " |
288 |
|
al[2]= sqrt(pow(ax,2)+pow(ay,2))/ sqrt(pow(ax,2)+pow(ay,2)+1.); |
289 |
|
al[3]=0.; |
290 |
|
if( (ax!=0.)||(ay!=0.) ) { |
291 |
|
al[3]= asin(ay/ sqrt(pow(ax,2)+pow(ay,2))); |
292 |
|
if(ax<0.) al[3]=acos(-1.)-al[3]; |
293 |
|
} |
294 |
|
al[4]=0.; |
295 |
|
} |
296 |
|
// end guess |
297 |
|
for(int i=0; i<5; i++) track_.al[i]=al[i]; |
298 |
|
if(pfixed!=0.) { |
299 |
|
al[4]=1./pfixed; // to fix the momentum |
300 |
|
track_.pfixed=pfixed; // " |
301 |
|
} |
302 |
|
int istep=0; |
303 |
|
int ifail=0; |
304 |
|
mini2_(&istep,&ifail, &iprint); |
305 |
|
if(ifail!=0) { |
306 |
|
if(iprint==1)cout << "ERROR: ifail= " << ifail << endl; |
307 |
|
fail = 1; |
308 |
|
// return; |
309 |
|
} |
310 |
|
|
311 |
|
// cout << endl << "eta ===> " << track_.al[4] << endl; |
312 |
|
|
313 |
|
for(int i=0; i<5; i++) al[i]=track_.al[i]; |
314 |
|
chi2=track_.chi2; |
315 |
|
nstep=track_.nstep; |
316 |
|
for(int i=0; i<6; i++) xv[i]=track_.xv[i]; |
317 |
|
for(int i=0; i<6; i++) yv[i]=track_.yv[i]; |
318 |
|
for(int i=0; i<6; i++) zv[i]=track_.zv[i]; |
319 |
|
for(int i=0; i<6; i++) axv[i]=track_.axv[i]; |
320 |
|
for(int i=0; i<6; i++) ayv[i]=track_.ayv[i]; |
321 |
|
for(int i=0; i<5; i++) { |
322 |
|
for(int j=0; j<5; j++) coval[i][j]=track_.cov[i][j]; |
323 |
|
} |
324 |
|
}; |
325 |
|
/* |
326 |
|
* Reset the parameters fit |
327 |
|
*/ |
328 |
|
void TrkTrack::FitReset(){ |
329 |
|
for(int i=0; i<5; i++) al[i]=-9999.; |
330 |
|
chi2=0.; |
331 |
|
nstep=0; |
332 |
|
for(int i=0; i<6; i++) xv[i]=0.; |
333 |
|
for(int i=0; i<6; i++) yv[i]=0.; |
334 |
|
for(int i=0; i<6; i++) zv[i]=0.; |
335 |
|
for(int i=0; i<6; i++) axv[i]=0.; |
336 |
|
for(int i=0; i<6; i++) ayv[i]=0.; |
337 |
|
for(int i=0; i<5; i++) { |
338 |
|
for(int j=0; j<5; j++) coval[i][j]=0.; |
339 |
|
} |
340 |
|
} |
341 |
|
|
342 |
|
//-------------------------------------- |
343 |
|
// |
344 |
|
// |
345 |
|
//-------------------------------------- |
346 |
|
void TrkTrack::Clear(){ |
347 |
|
seqno = -1; |
348 |
|
image = -1; |
349 |
|
chi2 = 0; |
350 |
|
nstep = 0; |
351 |
|
for(int it1=0;it1<5;it1++){ |
352 |
|
al[it1] = 0; |
353 |
|
for(int it2=0;it2<5;it2++)coval[it1][it2] = 0; |
354 |
|
}; |
355 |
|
for(int ip=0;ip<6;ip++){ |
356 |
|
xgood[ip] = 0; |
357 |
|
ygood[ip] = 0; |
358 |
|
xm[ip] = 0; |
359 |
|
ym[ip] = 0; |
360 |
|
zm[ip] = 0; |
361 |
|
resx[ip] = 0; |
362 |
|
resy[ip] = 0; |
363 |
|
xv[ip] = 0; |
364 |
|
yv[ip] = 0; |
365 |
|
zv[ip] = 0; |
366 |
|
axv[ip] = 0; |
367 |
|
ayv[ip] = 0; |
368 |
|
dedx_x[ip] = 0; |
369 |
|
dedx_y[ip] = 0; |
370 |
|
// clx[ip] = 0; |
371 |
|
// cly[ip] = 0; |
372 |
|
}; |
373 |
|
clx->Clear(); |
374 |
|
cly->Clear(); |
375 |
|
}; |
376 |
|
//-------------------------------------- |
377 |
|
// |
378 |
|
// |
379 |
|
//-------------------------------------- |
380 |
|
void TrkTrack::Delete(){ |
381 |
|
Clear(); |
382 |
|
clx->Delete(); |
383 |
|
cly->Delete(); |
384 |
|
}; |
385 |
|
//-------------------------------------- |
386 |
|
// |
387 |
|
// |
388 |
|
//-------------------------------------- |
389 |
|
|
390 |
//-------------------------------------- |
//-------------------------------------- |
391 |
// |
// |
392 |
// |
// |
396 |
coord[0] = 0; |
coord[0] = 0; |
397 |
coord[1] = 0; |
coord[1] = 0; |
398 |
sgnl = 0; |
sgnl = 0; |
399 |
|
cls = 0; |
400 |
}; |
}; |
401 |
//-------------------------------------- |
//-------------------------------------- |
402 |
// |
// |
407 |
coord[0] = s.coord[0]; |
coord[0] = s.coord[0]; |
408 |
coord[1] = s.coord[1]; |
coord[1] = s.coord[1]; |
409 |
sgnl = s.sgnl; |
sgnl = s.sgnl; |
410 |
|
// cls = 0;//<<<<pointer |
411 |
|
cls = TRef(s.cls); |
412 |
}; |
}; |
413 |
//-------------------------------------- |
//-------------------------------------- |
414 |
// |
// |
426 |
// |
// |
427 |
//-------------------------------------- |
//-------------------------------------- |
428 |
TrkLevel2::TrkLevel2(){ |
TrkLevel2::TrkLevel2(){ |
429 |
good2 = -1; |
// good2 = -1; |
430 |
for(Int_t i=0; i<12 ; i++){ |
for(Int_t i=0; i<12 ; i++){ |
431 |
crc[i] = -1; |
// crc[i] = -1; |
432 |
}; |
good[i] = -1; |
433 |
|
}; |
434 |
Track = new TClonesArray("TrkTrack"); |
Track = new TClonesArray("TrkTrack"); |
435 |
SingletX = new TClonesArray("TrkSinglet"); |
SingletX = new TClonesArray("TrkSinglet"); |
436 |
SingletY = new TClonesArray("TrkSinglet"); |
SingletY = new TClonesArray("TrkSinglet"); |
437 |
|
|
438 |
|
// PhysicalTrack = new TClonesArray("TrkTrack"); |
439 |
|
//sostituire con TRefArray... appena ho capito come si usa |
440 |
} |
} |
441 |
//-------------------------------------- |
//-------------------------------------- |
442 |
// |
// |
443 |
// |
// |
444 |
//-------------------------------------- |
//-------------------------------------- |
445 |
void TrkLevel2::Dump(){ |
void TrkLevel2::Dump(){ |
446 |
|
|
447 |
TClonesArray &t = *Track; |
TClonesArray &t = *Track; |
448 |
TClonesArray &sx = *SingletX; |
TClonesArray &sx = *SingletX; |
449 |
TClonesArray &sy = *SingletY; |
TClonesArray &sy = *SingletY; |
450 |
|
// |
451 |
cout << endl << endl << "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"; |
cout << endl << endl << "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"; |
452 |
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]; |
|
453 |
cout << endl << "ntrk() : " << this->ntrk() ; |
cout << endl << "ntrk() : " << this->ntrk() ; |
454 |
cout << endl << "nclsx() : " << this->nclsx(); |
cout << endl << "nclsx() : " << this->nclsx(); |
455 |
cout << endl << "nclsy() : " << this->nclsy(); |
cout << endl << "nclsy() : " << this->nclsy(); |
464 |
/** |
/** |
465 |
* 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). |
466 |
*/ |
*/ |
467 |
void TrkLevel2::FillCommonVar(cTrkLevel2 *l2){ |
void TrkLevel2::SetFromLevel2Struct(cTrkLevel2 *l2){ |
468 |
// temporary objects: |
|
469 |
|
// temporary objects: |
470 |
TrkSinglet* t_singlet = new TrkSinglet(); |
TrkSinglet* t_singlet = new TrkSinglet(); |
471 |
TrkTrack* t_track = new TrkTrack(); |
TrkTrack* t_track = new TrkTrack(); |
472 |
// general variables |
|
473 |
good2 = l2->good2; |
// **** general variables **** |
474 |
|
// good2 = l2->good2; |
475 |
for(Int_t i=0; i<12 ; i++){ |
for(Int_t i=0; i<12 ; i++){ |
476 |
crc[i] = l2->crc[i]; |
// crc[i] = l2->crc[i]; |
477 |
}; |
good[i] = l2->good[i]; |
478 |
// *** TRACKS *** |
}; |
479 |
|
// *** TRACKS *** |
480 |
TClonesArray &t = *Track; |
TClonesArray &t = *Track; |
481 |
for(int i=0; i<l2->ntrk; i++){ |
for(int i=0; i<l2->ntrk; i++){ |
482 |
t_track->image = l2->image[i]-1; |
t_track->seqno = i;// NBNBNBNB deve sempre essere = i |
483 |
t_track->chi2 = l2->chi2_nt[i]; |
t_track->image = l2->image[i]-1; |
484 |
for(int it1=0;it1<5;it1++){ |
// cout << "track "<<i<<t_track->seqno << t_track->image<<endl; |
485 |
t_track->al[it1] = l2->al_nt[i][it1]; |
t_track->chi2 = l2->chi2_nt[i]; |
486 |
for(int it2=0;it2<5;it2++) |
t_track->nstep = l2->nstep_nt[i]; |
487 |
t_track->coval[it1][it2] = l2->coval[i][it2][it1]; |
for(int it1=0;it1<5;it1++){ |
488 |
}; |
t_track->al[it1] = l2->al_nt[i][it1]; |
489 |
for(int ip=0;ip<6;ip++){ |
for(int it2=0;it2<5;it2++) |
490 |
t_track->xgood[ip] = l2->xgood_nt[i][ip]; |
t_track->coval[it1][it2] = l2->coval[i][it2][it1]; |
491 |
t_track->ygood[ip] = l2->ygood_nt[i][ip]; |
}; |
492 |
t_track->xm[ip] = l2->xm_nt[i][ip]; |
for(int ip=0;ip<6;ip++){ |
493 |
t_track->ym[ip] = l2->ym_nt[i][ip]; |
t_track->xgood[ip] = l2->xgood_nt[i][ip]; |
494 |
t_track->zm[ip] = l2->zm_nt[i][ip]; |
t_track->ygood[ip] = l2->ygood_nt[i][ip]; |
495 |
t_track->resx[ip] = l2->resx_nt[i][ip]; |
t_track->xm[ip] = l2->xm_nt[i][ip]; |
496 |
t_track->resy[ip] = l2->resy_nt[i][ip]; |
t_track->ym[ip] = l2->ym_nt[i][ip]; |
497 |
t_track->xv[ip] = l2->xv_nt[i][ip]; |
t_track->zm[ip] = l2->zm_nt[i][ip]; |
498 |
t_track->yv[ip] = l2->yv_nt[i][ip]; |
t_track->resx[ip] = l2->resx_nt[i][ip]; |
499 |
t_track->zv[ip] = l2->zv_nt[i][ip]; |
t_track->resy[ip] = l2->resy_nt[i][ip]; |
500 |
t_track->axv[ip] = l2->axv_nt[i][ip]; |
t_track->xv[ip] = l2->xv_nt[i][ip]; |
501 |
t_track->ayv[ip] = l2->ayv_nt[i][ip]; |
t_track->yv[ip] = l2->yv_nt[i][ip]; |
502 |
t_track->dedx_x[ip] = l2->dedx_x[i][ip]; |
t_track->zv[ip] = l2->zv_nt[i][ip]; |
503 |
t_track->dedx_y[ip] = l2->dedx_y[i][ip]; |
t_track->axv[ip] = l2->axv_nt[i][ip]; |
504 |
}; |
t_track->ayv[ip] = l2->ayv_nt[i][ip]; |
505 |
new(t[i]) TrkTrack(*t_track); |
t_track->dedx_x[ip] = l2->dedx_x[i][ip]; |
506 |
t_track->Clear(); |
t_track->dedx_y[ip] = l2->dedx_y[i][ip]; |
507 |
|
// t_track->clx[ip] = 0; |
508 |
|
// t_track->cly[ip] = 0; |
509 |
|
}; |
510 |
|
new(t[i]) TrkTrack(*t_track); |
511 |
|
t_track->Clear(); |
512 |
}; |
}; |
513 |
// *** SINGLETS *** |
// *** SINGLETS *** |
514 |
TClonesArray &sx = *SingletX; |
TClonesArray &sx = *SingletX; |
515 |
for(int i=0; i<l2->nclsx; i++){ |
for(int i=0; i<l2->nclsx; i++){ |
516 |
t_singlet->plane = l2->planex[i]; |
t_singlet->plane = l2->planex[i]; |
517 |
t_singlet->coord[0] = l2->xs[i][0]; |
t_singlet->coord[0] = l2->xs[i][0]; |
518 |
t_singlet->coord[1] = l2->xs[i][1]; |
t_singlet->coord[1] = l2->xs[i][1]; |
519 |
t_singlet->sgnl = l2->signlxs[i]; |
t_singlet->sgnl = l2->signlxs[i]; |
520 |
new(sx[i]) TrkSinglet(*t_singlet); |
// t_singlet->cls = 0; |
521 |
t_singlet->Clear(); |
new(sx[i]) TrkSinglet(*t_singlet); |
522 |
|
t_singlet->Clear(); |
523 |
} |
} |
524 |
TClonesArray &sy = *SingletY; |
TClonesArray &sy = *SingletY; |
525 |
for(int i=0; i<l2->nclsy; i++){ |
for(int i=0; i<l2->nclsy; i++){ |
526 |
t_singlet->plane = l2->planey[i]; |
t_singlet->plane = l2->planey[i]; |
527 |
t_singlet->coord[0] = l2->ys[i][0]; |
t_singlet->coord[0] = l2->ys[i][0]; |
528 |
t_singlet->coord[1] = l2->ys[i][1]; |
t_singlet->coord[1] = l2->ys[i][1]; |
529 |
t_singlet->sgnl = l2->signlys[i]; |
t_singlet->sgnl = l2->signlys[i]; |
530 |
new(sy[i]) TrkSinglet(*t_singlet); |
// t_singlet->cls = 0; |
531 |
t_singlet->Clear(); |
new(sy[i]) TrkSinglet(*t_singlet); |
532 |
|
t_singlet->Clear(); |
533 |
}; |
}; |
534 |
|
|
535 |
|
delete t_track; |
536 |
|
delete t_singlet; |
537 |
} |
} |
538 |
//-------------------------------------- |
//-------------------------------------- |
539 |
// |
// |
540 |
// |
// |
541 |
//-------------------------------------- |
//-------------------------------------- |
542 |
void TrkLevel2::Clear(){ |
/** |
543 |
good2 = -1; |
* Fills a TrkLevel2 object with values from a struct cTrkLevel2 (to get data from F77 common). |
544 |
|
* Ref to Level1 data (clusters) is also set. |
545 |
|
*/ |
546 |
|
void TrkLevel2::SetFromLevel2Struct(cTrkLevel2 *l2, TrkLevel1 *l1){ |
547 |
|
|
548 |
|
// temporary objects: |
549 |
|
TrkSinglet* t_singlet = new TrkSinglet(); |
550 |
|
TrkTrack* t_track = new TrkTrack(); |
551 |
|
// general variables |
552 |
|
// good2 = l2->good2; |
553 |
|
for(Int_t i=0; i<12 ; i++){ |
554 |
|
// crc[i] = l2->crc[i]; |
555 |
|
good[i] = l2->good[i]; |
556 |
|
}; |
557 |
|
// *** TRACKS *** |
558 |
|
TClonesArray &t = *Track; |
559 |
|
for(int i=0; i<l2->ntrk; i++){ |
560 |
|
t_track->seqno = i;// NBNBNBNB deve sempre essere = i |
561 |
|
t_track->image = l2->image[i]-1; |
562 |
|
// cout << "track "<<i<<t_track->seqno << t_track->image<<endl; |
563 |
|
t_track->chi2 = l2->chi2_nt[i]; |
564 |
|
t_track->nstep = l2->nstep_nt[i]; |
565 |
|
for(int it1=0;it1<5;it1++){ |
566 |
|
t_track->al[it1] = l2->al_nt[i][it1]; |
567 |
|
for(int it2=0;it2<5;it2++) |
568 |
|
t_track->coval[it1][it2] = l2->coval[i][it2][it1]; |
569 |
|
}; |
570 |
|
for(int ip=0;ip<6;ip++){ |
571 |
|
t_track->xgood[ip] = l2->xgood_nt[i][ip]; |
572 |
|
t_track->ygood[ip] = l2->ygood_nt[i][ip]; |
573 |
|
t_track->xm[ip] = l2->xm_nt[i][ip]; |
574 |
|
t_track->ym[ip] = l2->ym_nt[i][ip]; |
575 |
|
t_track->zm[ip] = l2->zm_nt[i][ip]; |
576 |
|
t_track->resx[ip] = l2->resx_nt[i][ip]; |
577 |
|
t_track->resy[ip] = l2->resy_nt[i][ip]; |
578 |
|
t_track->xv[ip] = l2->xv_nt[i][ip]; |
579 |
|
t_track->yv[ip] = l2->yv_nt[i][ip]; |
580 |
|
t_track->zv[ip] = l2->zv_nt[i][ip]; |
581 |
|
t_track->axv[ip] = l2->axv_nt[i][ip]; |
582 |
|
t_track->ayv[ip] = l2->ayv_nt[i][ip]; |
583 |
|
t_track->dedx_x[ip] = l2->dedx_x[i][ip]; |
584 |
|
t_track->dedx_y[ip] = l2->dedx_y[i][ip]; |
585 |
|
// cout << "traccia "<<i<<" -- "<< ip << " "<< l2->cltrx[i][ip] <<" "<< l2->cltry[i][ip] <<" "<< t_track->xgood[ip] << t_track->ygood[ip]<<endl; |
586 |
|
//----------------------------------------------------- |
587 |
|
// t_track->clx[ip] = l1->GetCluster(l2->cltrx[i][ip]-1); |
588 |
|
// t_track->cly[ip] = l1->GetCluster(l2->cltry[i][ip]-1); |
589 |
|
if(t_track->xgood[ip])t_track->clx->AddAt(l1->GetCluster(l2->cltrx[i][ip]-1),ip); |
590 |
|
if(t_track->ygood[ip])t_track->cly->AddAt(l1->GetCluster(l2->cltry[i][ip]-1),ip); |
591 |
|
// 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; |
592 |
|
// 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; |
593 |
|
//----------------------------------------------------- |
594 |
|
}; |
595 |
|
new(t[i]) TrkTrack(*t_track); |
596 |
|
t_track->Clear(); |
597 |
|
}; |
598 |
|
// *** SINGLETS *** |
599 |
|
TClonesArray &sx = *SingletX; |
600 |
|
for(int i=0; i<l2->nclsx; i++){ |
601 |
|
t_singlet->plane = l2->planex[i]; |
602 |
|
t_singlet->coord[0] = l2->xs[i][0]; |
603 |
|
t_singlet->coord[1] = l2->xs[i][1]; |
604 |
|
t_singlet->sgnl = l2->signlxs[i]; |
605 |
|
//----------------------------------------------------- |
606 |
|
// cout << "singolo x "<<i<<" -- "<< l2->clsx[i] <<endl; |
607 |
|
t_singlet->cls = l1->GetCluster(l2->clsx[i]-1); |
608 |
|
// cout<<" i "<<i<<" l2->clsx[i] "<<l2->clsx[i]<< " l1->GetCluster(l2->clsx[i]-1) "<<l1->GetCluster(l2->clsx[i]-1)<<endl; |
609 |
|
//----------------------------------------------------- |
610 |
|
new(sx[i]) TrkSinglet(*t_singlet); |
611 |
|
t_singlet->Clear(); |
612 |
|
} |
613 |
|
TClonesArray &sy = *SingletY; |
614 |
|
for(int i=0; i<l2->nclsy; i++){ |
615 |
|
t_singlet->plane = l2->planey[i]; |
616 |
|
t_singlet->coord[0] = l2->ys[i][0]; |
617 |
|
t_singlet->coord[1] = l2->ys[i][1]; |
618 |
|
t_singlet->sgnl = l2->signlys[i]; |
619 |
|
//----------------------------------------------------- |
620 |
|
// cout << "singolo y "<<i<<" -- "<< l2->clsy[i] <<endl; |
621 |
|
t_singlet->cls = l1->GetCluster(l2->clsy[i]-1); |
622 |
|
// cout<<" i "<<i<<" l2->clsy[i] "<<l2->clsy[i]<< " l1->GetCluster(l2->clsy[i]-1) "<<l1->GetCluster(l2->clsy[i]-1)<<endl; |
623 |
|
//----------------------------------------------------- |
624 |
|
new(sy[i]) TrkSinglet(*t_singlet); |
625 |
|
t_singlet->Clear(); |
626 |
|
}; |
627 |
|
|
628 |
|
delete t_track; |
629 |
|
delete t_singlet; |
630 |
|
} |
631 |
|
/** |
632 |
|
* Fills a struct cTrkLevel2 with values from a TrkLevel2 object (to put data into a F77 common). |
633 |
|
*/ |
634 |
|
|
635 |
|
void TrkLevel2::GetLevel2Struct(cTrkLevel2 *l2) const { |
636 |
|
|
637 |
|
// general variables |
638 |
|
// l2->good2 = good2 ; |
639 |
for(Int_t i=0; i<12 ; i++){ |
for(Int_t i=0; i<12 ; i++){ |
640 |
crc[i] = -1; |
// l2->crc[i] = crc[i]; |
641 |
|
l2->good[i] = good[i]; |
642 |
}; |
}; |
643 |
Track->RemoveAll(); |
// *** TRACKS *** |
644 |
|
|
645 |
|
l2->ntrk = Track->GetEntries(); |
646 |
|
for(Int_t i=0;i<l2->ntrk;i++){ |
647 |
|
l2->image[i] = 1 + ((TrkTrack *)Track->At(i))->image; |
648 |
|
l2->chi2_nt[i] = ((TrkTrack *)Track->At(i))->chi2; |
649 |
|
l2->nstep_nt[i] = ((TrkTrack *)Track->At(i))->nstep; |
650 |
|
for(int it1=0;it1<5;it1++){ |
651 |
|
l2->al_nt[i][it1] = ((TrkTrack *)Track->At(i))->al[it1]; |
652 |
|
for(int it2=0;it2<5;it2++) |
653 |
|
l2->coval[i][it2][it1] = ((TrkTrack *)Track->At(i))->coval[it1][it2]; |
654 |
|
}; |
655 |
|
for(int ip=0;ip<6;ip++){ |
656 |
|
l2->xgood_nt[i][ip] = ((TrkTrack *)Track->At(i))->xgood[ip]; |
657 |
|
l2->ygood_nt[i][ip] = ((TrkTrack *)Track->At(i))->ygood[ip]; |
658 |
|
l2->xm_nt[i][ip] = ((TrkTrack *)Track->At(i))->xm[ip]; |
659 |
|
l2->ym_nt[i][ip] = ((TrkTrack *)Track->At(i))->ym[ip]; |
660 |
|
l2->zm_nt[i][ip] = ((TrkTrack *)Track->At(i))->zm[ip]; |
661 |
|
l2->resx_nt[i][ip] = ((TrkTrack *)Track->At(i))->resx[ip]; |
662 |
|
l2->resy_nt[i][ip] = ((TrkTrack *)Track->At(i))->resy[ip]; |
663 |
|
l2->xv_nt[i][ip] = ((TrkTrack *)Track->At(i))->xv[ip]; |
664 |
|
l2->yv_nt[i][ip] = ((TrkTrack *)Track->At(i))->yv[ip]; |
665 |
|
l2->zv_nt[i][ip] = ((TrkTrack *)Track->At(i))->zv[ip]; |
666 |
|
l2->axv_nt[i][ip] = ((TrkTrack *)Track->At(i))->axv[ip]; |
667 |
|
l2->ayv_nt[i][ip] = ((TrkTrack *)Track->At(i))->ayv[ip]; |
668 |
|
l2->dedx_x[i][ip] = ((TrkTrack *)Track->At(i))->dedx_x[ip]; |
669 |
|
l2->dedx_y[i][ip] = ((TrkTrack *)Track->At(i))->dedx_y[ip]; |
670 |
|
}; |
671 |
|
} |
672 |
|
|
673 |
|
// *** SINGLETS *** |
674 |
|
l2->nclsx = SingletX->GetEntries(); |
675 |
|
for(Int_t i=0;i<l2->nclsx;i++){ |
676 |
|
l2->planex[i] = ((TrkSinglet *)SingletX->At(i))->plane; |
677 |
|
l2->xs[i][0] = ((TrkSinglet *)SingletX->At(i))->coord[0]; |
678 |
|
l2->xs[i][1] = ((TrkSinglet *)SingletX->At(i))->coord[1]; |
679 |
|
l2->signlxs[i] = ((TrkSinglet *)SingletX->At(i))->sgnl; |
680 |
|
} |
681 |
|
l2->nclsy = SingletY->GetEntries(); |
682 |
|
for(Int_t i=0;i<l2->nclsy;i++){ |
683 |
|
l2->planey[i] = ((TrkSinglet *)SingletY->At(i))->plane; |
684 |
|
l2->ys[i][0] = ((TrkSinglet *)SingletY->At(i))->coord[0]; |
685 |
|
l2->ys[i][1] = ((TrkSinglet *)SingletY->At(i))->coord[1]; |
686 |
|
l2->signlys[i] = ((TrkSinglet *)SingletY->At(i))->sgnl; |
687 |
|
} |
688 |
|
} |
689 |
|
//-------------------------------------- |
690 |
|
// |
691 |
|
// |
692 |
|
//-------------------------------------- |
693 |
|
void TrkLevel2::Clear(){ |
694 |
|
// good2 = -1; |
695 |
|
for(Int_t i=0; i<12 ; i++){ |
696 |
|
// crc[i] = -1; |
697 |
|
good[i] = -1; |
698 |
|
}; |
699 |
|
/* Track->RemoveAll(); |
700 |
SingletX->RemoveAll(); |
SingletX->RemoveAll(); |
701 |
SingletY->RemoveAll(); |
SingletY->RemoveAll();*/ |
702 |
|
// modify to avoid memory leakage |
703 |
|
Track->Clear(); |
704 |
|
SingletX->Clear(); |
705 |
|
SingletY->Clear(); |
706 |
|
} |
707 |
|
//-------------------------------------- |
708 |
|
// |
709 |
|
// |
710 |
|
//-------------------------------------- |
711 |
|
void TrkLevel2::Delete(){ |
712 |
|
|
713 |
|
Clear(); |
714 |
|
Track->Delete(); |
715 |
|
SingletX->Delete(); |
716 |
|
SingletY->Delete(); |
717 |
} |
} |
718 |
//-------------------------------------- |
//-------------------------------------- |
719 |
// |
// |
723 |
* 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). |
724 |
* 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. |
725 |
*/ |
*/ |
726 |
TClonesArray *TrkLevel2::GetTracks(){ |
TRefArray *TrkLevel2::GetTracks_NFitSorted(){ |
727 |
|
|
728 |
TClonesArray *sorted = new TClonesArray("TrkTrack"); |
TRefArray *sorted = new TRefArray(); |
729 |
TClonesArray &t = *Track; |
|
730 |
TClonesArray &ts = *sorted; |
TClonesArray &t = *Track; |
731 |
int N=this->ntrk(); |
// TClonesArray &ts = *PhysicalTrack; |
732 |
vector<int> m(N); for(int i=0; i<N; i++)m[i]=1; |
int N = ntrk(); |
733 |
|
vector<int> m(N); for(int i=0; i<N; i++)m[i]=1; |
734 |
int indo=0; |
// int m[50]; for(int i=0; i<N; i++)m[i]=1; |
735 |
int indi=0; |
|
736 |
while(N != 0){ |
int indo=0; |
737 |
float chi2ref=1000000; |
int indi=0; |
738 |
for(int i=0; i<this->ntrk(); i++){ |
while(N != 0){ |
739 |
if(((TrkTrack *)t[i])->chi2 < chi2ref && m[i]==1){ |
int nfit =0; |
740 |
chi2ref = ((TrkTrack *)t[i])->chi2; |
float chi2ref = numeric_limits<float>::max(); |
741 |
indi = i; |
|
742 |
} |
// first loop to search maximum num. of fit points |
743 |
|
for(int i=0; i < ntrk(); i++){ |
744 |
|
if( ((TrkTrack *)t[i])->GetNtot() >= nfit && m[i]==1){ |
745 |
|
nfit = ((TrkTrack *)t[i])->GetNtot(); |
746 |
|
} |
747 |
|
} |
748 |
|
//second loop to search minimum chi2 among selected |
749 |
|
for(int i=0; i<this->ntrk(); i++){ |
750 |
|
Float_t chi2 = ((TrkTrack *)t[i])->chi2; |
751 |
|
if(chi2 < 0) chi2 = chi2*1000; |
752 |
|
if( chi2 < chi2ref |
753 |
|
&& ((TrkTrack *)t[i])->GetNtot() == nfit |
754 |
|
&& m[i]==1){ |
755 |
|
chi2ref = ((TrkTrack *)t[i])->chi2; |
756 |
|
indi = i; |
757 |
|
}; |
758 |
|
}; |
759 |
|
if( ((TrkTrack *)t[indi])->HasImage() ){ |
760 |
|
m[((TrkTrack *)t[indi])->image] = 0; |
761 |
|
N--; |
762 |
|
|
763 |
|
// cout << "i** "<< ((TrkTrack *)t[indi])->image << " " << nfiti <<" "<<chi2i<<endl; |
764 |
|
}; |
765 |
|
sorted->Add( (TrkTrack*)t[indi] ); |
766 |
|
|
767 |
|
m[indi] = 0; |
768 |
|
// cout << "SORTED "<< indo << " "<< indi << " "<< N << endl; |
769 |
|
N--; |
770 |
|
indo++; |
771 |
} |
} |
772 |
if( ((TrkTrack *)t[indi])->image != -1 ){ |
m.clear(); |
773 |
m[((TrkTrack *)t[indi])->image] = 0; |
// cout << "GetTracks_NFitSorted(it): Done"<< endl; |
774 |
N--; |
|
775 |
} |
return sorted; |
776 |
new(ts[indo]) TrkTrack(*(TrkTrack*)t[indi]); |
// return PhysicalTrack; |
|
m[indi] = 0; |
|
|
N--; |
|
|
indo++; |
|
|
} |
|
|
return sorted; |
|
777 |
} |
} |
778 |
//-------------------------------------- |
//-------------------------------------- |
779 |
// |
// |
800 |
// |
// |
801 |
//-------------------------------------- |
//-------------------------------------- |
802 |
/** |
/** |
803 |
|
* Retrieves the is-th stored X singlet. |
804 |
|
* @param it Singlet number, ranging from 0 to nclsx(). |
805 |
|
*/ |
806 |
|
TrkSinglet *TrkLevel2::GetSingletX(int is){ |
807 |
|
|
808 |
|
if(is >= this->nclsx()){ |
809 |
|
cout << "** TrkLevel2 ** Singlet "<< is << "doen not exits! " << endl; |
810 |
|
cout << " Stored x-singlets nclsx() = "<< this->nclsx() << endl; |
811 |
|
return 0; |
812 |
|
} |
813 |
|
TClonesArray &t = *(SingletX); |
814 |
|
TrkSinglet *singlet = (TrkSinglet*)t[is]; |
815 |
|
return singlet; |
816 |
|
} |
817 |
|
//-------------------------------------- |
818 |
|
// |
819 |
|
// |
820 |
|
//-------------------------------------- |
821 |
|
/** |
822 |
|
* Retrieves the is-th stored Y singlet. |
823 |
|
* @param it Singlet number, ranging from 0 to nclsx(). |
824 |
|
*/ |
825 |
|
TrkSinglet *TrkLevel2::GetSingletY(int is){ |
826 |
|
|
827 |
|
if(is >= this->nclsy()){ |
828 |
|
cout << "** TrkLevel2 ** Singlet "<< is << "doen not exits! " << endl; |
829 |
|
cout << " Stored y-singlets nclsy() = "<< this->nclsx() << endl; |
830 |
|
return 0; |
831 |
|
} |
832 |
|
TClonesArray &t = *(SingletY); |
833 |
|
TrkSinglet *singlet = (TrkSinglet*)t[is]; |
834 |
|
return singlet; |
835 |
|
} |
836 |
|
//-------------------------------------- |
837 |
|
// |
838 |
|
// |
839 |
|
//-------------------------------------- |
840 |
|
/** |
841 |
* Retrieves the it-th "physical" track, sorted by the method GetNTracks(). |
* Retrieves the it-th "physical" track, sorted by the method GetNTracks(). |
842 |
* @param it Track number, ranging from 0 to GetNTracks(). |
* @param it Track number, ranging from 0 to GetNTracks(). |
843 |
*/ |
*/ |
844 |
|
|
845 |
TrkTrack *TrkLevel2::GetTrack(int it){ |
TrkTrack *TrkLevel2::GetTrack(int it){ |
846 |
|
|
847 |
if(it >= this->GetNTracks()){ |
if(it >= this->GetNTracks()){ |
848 |
cout << "** TrkLevel2 ** Track "<< it << "does not exits! " << endl; |
cout << "** TrkLevel2 ** Track "<< it << "does not exits! " << endl; |
849 |
cout << " Physical tracks GetNTracks() = "<< this->ntrk() << endl; |
cout << " Physical tracks GetNTracks() = "<< this->ntrk() << endl; |
850 |
return 0; |
return 0; |
851 |
} |
} |
852 |
TrkTrack *track = (TrkTrack*)(*(this->GetTracks()))[it]; |
|
853 |
return track; |
TRefArray *sorted = GetTracks(); //TEMPORANEO |
854 |
|
TrkTrack *track = (TrkTrack*)sorted->At(it); |
855 |
|
sorted->Delete(); |
856 |
|
return track; |
857 |
} |
} |
858 |
|
/** |
859 |
|
* Give the number of "physical" tracks, sorted by the method GetTracks(). |
860 |
|
*/ |
861 |
|
Int_t TrkLevel2::GetNTracks(){ |
862 |
|
|
863 |
|
Float_t ntot=0; |
864 |
|
TClonesArray &t = *Track; |
865 |
|
for(int i=0; i<ntrk(); i++) { |
866 |
|
if( ((TrkTrack *)t[i])->GetImageSeqNo() == -1 ) ntot+=1.; |
867 |
|
else ntot+=0.5; |
868 |
|
} |
869 |
|
return (Int_t)ntot; |
870 |
|
|
871 |
|
}; |
872 |
//-------------------------------------- |
//-------------------------------------- |
873 |
// |
// |
874 |
// |
// |
879 |
*/ |
*/ |
880 |
TrkTrack *TrkLevel2::GetTrackImage(int it){ |
TrkTrack *TrkLevel2::GetTrackImage(int it){ |
881 |
|
|
882 |
if(it >= this->GetNTracks()){ |
if(it >= this->GetNTracks()){ |
883 |
cout << "** TrkLevel2 ** Track "<< it << "does not exits! " << endl; |
cout << "** TrkLevel2 ** Track "<< it << "does not exits! " << endl; |
884 |
cout << " Physical tracks GetNTracks() = "<< this->ntrk() << endl; |
cout << " Physical tracks GetNTracks() = "<< this->ntrk() << endl; |
885 |
return 0; |
return 0; |
886 |
} |
} |
887 |
TrkTrack *track = (TrkTrack*)(*(this->GetTracks()))[it]; |
|
888 |
if(!track->HasImage()){ |
TRefArray* sorted = GetTracks(); //TEMPORANEO |
889 |
cout << "** TrkLevel2 ** Track "<< it << "does not have image! " << endl; |
TrkTrack *track = (TrkTrack*)sorted->At(it); |
890 |
return 0; |
|
891 |
} |
if(!track->HasImage()){ |
892 |
TrkTrack *image = (TrkTrack*)(*Track)[track->image]; |
cout << "** TrkLevel2 ** Track "<< it << "does not have image! " << endl; |
893 |
return image; |
return 0; |
894 |
|
} |
895 |
|
TrkTrack *image = (TrkTrack*)(*Track)[track->image]; |
896 |
|
|
897 |
|
sorted->Delete(); |
898 |
|
|
899 |
|
return image; |
900 |
|
|
901 |
} |
} |
902 |
//-------------------------------------- |
//-------------------------------------- |
915 |
// |
// |
916 |
//-------------------------------------- |
//-------------------------------------- |
917 |
/** |
/** |
918 |
|
* Get tracker-plane (mechanical) z-coordinate |
919 |
|
* @param plane_id plane index (1=TOP,2,3,4,5,6=BOTTOM) |
920 |
|
*/ |
921 |
|
Float_t TrkLevel2::GetZTrk(Int_t plane_id){ |
922 |
|
switch(plane_id){ |
923 |
|
case 1: return ZTRK1; |
924 |
|
case 2: return ZTRK2; |
925 |
|
case 3: return ZTRK3; |
926 |
|
case 4: return ZTRK4; |
927 |
|
case 5: return ZTRK5; |
928 |
|
case 6: return ZTRK6; |
929 |
|
default: return 0.; |
930 |
|
}; |
931 |
|
}; |
932 |
|
//-------------------------------------- |
933 |
|
// |
934 |
|
// |
935 |
|
//-------------------------------------- |
936 |
|
/** |
937 |
|
* Trajectory default constructor. |
938 |
|
* (By default is created with z-coordinates inside the tracking volume) |
939 |
|
*/ |
940 |
|
Trajectory::Trajectory(){ |
941 |
|
npoint = 10; |
942 |
|
x = new float[npoint]; |
943 |
|
y = new float[npoint]; |
944 |
|
z = new float[npoint]; |
945 |
|
thx = new float[npoint]; |
946 |
|
thy = new float[npoint]; |
947 |
|
tl = new float[npoint]; |
948 |
|
float dz = ((ZTRK1)-(ZTRK6))/(npoint-1); |
949 |
|
for(int i=0; i<npoint; i++){ |
950 |
|
x[i] = 0; |
951 |
|
y[i] = 0; |
952 |
|
z[i] = (ZTRK1) - i*dz; |
953 |
|
thx[i] = 0; |
954 |
|
thy[i] = 0; |
955 |
|
tl[i] = 0; |
956 |
|
} |
957 |
|
} |
958 |
|
//-------------------------------------- |
959 |
|
// |
960 |
|
// |
961 |
|
//-------------------------------------- |
962 |
|
/** |
963 |
* Trajectory constructor. |
* Trajectory constructor. |
964 |
|
* (By default is created with z-coordinates inside the tracking volume) |
965 |
* \param n Number of points |
* \param n Number of points |
966 |
*/ |
*/ |
967 |
Trajectory::Trajectory(int n){ |
Trajectory::Trajectory(int n){ |
968 |
|
if(n<=0){ |
969 |
|
cout << "NB! Trajectory must have at least 1 point >>> created with 10 points" << endl; |
970 |
|
n=10; |
971 |
|
} |
972 |
npoint = n; |
npoint = n; |
973 |
x = new float[npoint]; |
x = new float[npoint]; |
974 |
y = new float[npoint]; |
y = new float[npoint]; |
975 |
z = new float[npoint]; |
z = new float[npoint]; |
976 |
|
thx = new float[npoint]; |
977 |
|
thy = new float[npoint]; |
978 |
|
tl = new float[npoint]; |
979 |
|
float dz = ((ZTRK1)-(ZTRK6))/(npoint-1); |
980 |
for(int i=0; i<npoint; i++){ |
for(int i=0; i<npoint; i++){ |
981 |
x[i] = 0; |
x[i] = 0; |
982 |
y[i] = 0; |
y[i] = 0; |
983 |
z[i] = 0; |
z[i] = (ZTRK1) - i*dz; |
984 |
|
thx[i] = 0; |
985 |
|
thy[i] = 0; |
986 |
|
tl[i] = 0; |
987 |
} |
} |
988 |
} |
} |
989 |
//-------------------------------------- |
//-------------------------------------- |
996 |
* \param pz Pointer to float array, defining z coordinates |
* \param pz Pointer to float array, defining z coordinates |
997 |
*/ |
*/ |
998 |
Trajectory::Trajectory(int n, float* zin){ |
Trajectory::Trajectory(int n, float* zin){ |
999 |
npoint = n; |
npoint = 10; |
1000 |
|
if(n>0)npoint = n; |
1001 |
x = new float[npoint]; |
x = new float[npoint]; |
1002 |
y = new float[npoint]; |
y = new float[npoint]; |
1003 |
z = new float[npoint]; |
z = new float[npoint]; |
1004 |
for(int i=0; i<npoint; i++){ |
thx = new float[npoint]; |
1005 |
x[i] = 0; |
thy = new float[npoint]; |
1006 |
y[i] = 0; |
tl = new float[npoint]; |
1007 |
z[i] = zin[i]; |
int i=0; |
1008 |
} |
do{ |
1009 |
|
x[i] = 0; |
1010 |
|
y[i] = 0; |
1011 |
|
z[i] = zin[i]; |
1012 |
|
thx[i] = 0; |
1013 |
|
thy[i] = 0; |
1014 |
|
tl[i] = 0; |
1015 |
|
i++; |
1016 |
|
}while(zin[i-1] > zin[i] && i < npoint); |
1017 |
|
npoint=i; |
1018 |
|
if(npoint != n)cout << "NB! Trajectory created with "<<npoint<<" points"<<endl; |
1019 |
} |
} |
1020 |
//-------------------------------------- |
//-------------------------------------- |
1021 |
// |
// |
1027 |
void Trajectory::Dump(){ |
void Trajectory::Dump(){ |
1028 |
cout <<endl<< "Trajectory ========== "<<endl; |
cout <<endl<< "Trajectory ========== "<<endl; |
1029 |
for (int i=0; i<npoint; i++){ |
for (int i=0; i<npoint; i++){ |
1030 |
cout << i <<" >> " << x[i] <<" "<< y[i] <<" "<< z[i] << endl;; |
cout << i <<" >> " << x[i] <<" "<< y[i] <<" "<< z[i] ; |
1031 |
|
cout <<" -- " << thx[i] <<" "<< thy[i] ; |
1032 |
|
cout <<" -- " << tl[i] << endl; |
1033 |
}; |
}; |
1034 |
} |
} |
1035 |
|
//-------------------------------------- |
1036 |
|
// |
1037 |
|
// |
1038 |
|
//-------------------------------------- |
1039 |
|
/** |
1040 |
|
* Get trajectory length between two points |
1041 |
|
* @param ifirst first point (default 0) |
1042 |
|
* @param ilast last point (default npoint) |
1043 |
|
*/ |
1044 |
|
float Trajectory::GetLength(int ifirst, int ilast){ |
1045 |
|
if( ifirst<0 ) ifirst = 0; |
1046 |
|
if( ilast>=npoint) ilast = npoint-1; |
1047 |
|
float l=0; |
1048 |
|
for(int i=ifirst;i<=ilast;i++){ |
1049 |
|
l=l+tl[i]; |
1050 |
|
}; |
1051 |
|
if(z[ilast] > ZINI)l=l-tl[ilast]; |
1052 |
|
if(z[ifirst] < ZINI) l=l-tl[ifirst]; |
1053 |
|
|
1054 |
|
return l; |
1055 |
|
|
1056 |
|
} |
1057 |
|
|
1058 |
|
|
1059 |
ClassImp(TrkLevel2); |
ClassImp(TrkLevel2); |
1060 |
ClassImp(TrkSinglet); |
ClassImp(TrkSinglet); |