4 |
*/ |
*/ |
5 |
#include <TrkLevel2.h> |
#include <TrkLevel2.h> |
6 |
#include <iostream> |
#include <iostream> |
7 |
|
#include <math.h> |
8 |
using namespace std; |
using namespace std; |
9 |
//...................................... |
//...................................... |
10 |
// F77 routines |
// F77 routines |
12 |
extern "C" { |
extern "C" { |
13 |
void dotrack_(int*, double*, double*, double*, double*, int*); |
void dotrack_(int*, double*, double*, double*, double*, int*); |
14 |
void dotrack2_(int*, double*, double*, double*, double*,double*, double*, double*,int*); |
void dotrack2_(int*, double*, double*, double*, double*,double*, double*, double*,int*); |
15 |
int readb_(const char*); |
int readb_(const char*); |
16 |
|
void mini2_(int*,int*,int*); |
17 |
} |
} |
18 |
//-------------------------------------- |
//-------------------------------------- |
19 |
// |
// |
23 |
seqno = -1; |
seqno = -1; |
24 |
image = -1; |
image = -1; |
25 |
chi2 = 0; |
chi2 = 0; |
26 |
|
nstep = 0; |
27 |
for(int it1=0;it1<5;it1++){ |
for(int it1=0;it1<5;it1++){ |
28 |
al[it1] = 0; |
al[it1] = 0; |
29 |
for(int it2=0;it2<5;it2++) |
for(int it2=0;it2<5;it2++)coval[it1][it2] = 0; |
|
coval[it1][it2] = 0; |
|
30 |
}; |
}; |
31 |
for(int ip=0;ip<6;ip++){ |
for(int ip=0;ip<6;ip++){ |
32 |
xgood[ip] = 0; |
xgood[ip] = 0; |
33 |
ygood[ip] = 0; |
ygood[ip] = 0; |
34 |
xm[ip] = 0; |
xm[ip] = 0; |
35 |
ym[ip] = 0; |
ym[ip] = 0; |
36 |
zm[ip] = 0; |
zm[ip] = 0; |
37 |
resx[ip] = 0; |
resx[ip] = 0; |
38 |
resy[ip] = 0; |
resy[ip] = 0; |
39 |
xv[ip] = 0; |
xv[ip] = 0; |
40 |
yv[ip] = 0; |
yv[ip] = 0; |
41 |
zv[ip] = 0; |
zv[ip] = 0; |
42 |
axv[ip] = 0; |
axv[ip] = 0; |
43 |
ayv[ip] = 0; |
ayv[ip] = 0; |
44 |
dedx_x[ip] = 0; |
dedx_x[ip] = 0; |
45 |
dedx_y[ip] = 0; |
dedx_y[ip] = 0; |
46 |
}; |
// clx[ip] = 0; |
47 |
|
// cly[ip] = 0; |
48 |
|
}; |
49 |
|
clx = new TRefArray(6,0); |
50 |
|
cly = new TRefArray(6,0); |
51 |
}; |
}; |
52 |
//-------------------------------------- |
//-------------------------------------- |
53 |
// |
// |
57 |
seqno = t.seqno; |
seqno = t.seqno; |
58 |
image = t.image; |
image = t.image; |
59 |
chi2 = t.chi2; |
chi2 = t.chi2; |
60 |
|
nstep = t.nstep; |
61 |
for(int it1=0;it1<5;it1++){ |
for(int it1=0;it1<5;it1++){ |
62 |
al[it1] = t.al[it1]; |
al[it1] = t.al[it1]; |
63 |
for(int it2=0;it2<5;it2++) |
for(int it2=0;it2<5;it2++)coval[it1][it2] = t.coval[it1][it2]; |
|
coval[it1][it2] = t.coval[it1][it2]; |
|
64 |
}; |
}; |
65 |
for(int ip=0;ip<6;ip++){ |
for(int ip=0;ip<6;ip++){ |
66 |
xgood[ip] = t.xgood[ip]; |
xgood[ip] = t.xgood[ip]; |
67 |
ygood[ip] = t.ygood[ip]; |
ygood[ip] = t.ygood[ip]; |
68 |
xm[ip] = t.xm[ip]; |
xm[ip] = t.xm[ip]; |
69 |
ym[ip] = t.ym[ip]; |
ym[ip] = t.ym[ip]; |
70 |
zm[ip] = t.zm[ip]; |
zm[ip] = t.zm[ip]; |
71 |
resx[ip] = t.resx[ip]; |
resx[ip] = t.resx[ip]; |
72 |
resy[ip] = t.resy[ip]; |
resy[ip] = t.resy[ip]; |
73 |
xv[ip] = t.xv[ip]; |
xv[ip] = t.xv[ip]; |
74 |
yv[ip] = t.yv[ip]; |
yv[ip] = t.yv[ip]; |
75 |
zv[ip] = t.zv[ip]; |
zv[ip] = t.zv[ip]; |
76 |
axv[ip] = t.axv[ip]; |
axv[ip] = t.axv[ip]; |
77 |
ayv[ip] = t.ayv[ip]; |
ayv[ip] = t.ayv[ip]; |
78 |
dedx_x[ip] = t.dedx_x[ip]; |
dedx_x[ip] = t.dedx_x[ip]; |
79 |
dedx_y[ip] = t.dedx_y[ip]; |
dedx_y[ip] = t.dedx_y[ip]; |
80 |
}; |
// clx[ip] = 0;//<<<<pointer |
81 |
|
// cly[ip] = 0;//<<<<pointer |
82 |
|
}; |
83 |
|
clx = new TRefArray(*(t.clx)); |
84 |
|
cly = new TRefArray(*(t.cly)); |
85 |
|
|
86 |
}; |
}; |
87 |
//-------------------------------------- |
//-------------------------------------- |
88 |
// |
// |
198 |
//-------------------------------------- |
//-------------------------------------- |
199 |
void TrkTrack::Dump(){ |
void TrkTrack::Dump(){ |
200 |
cout << endl << "========== Track " ; |
cout << endl << "========== Track " ; |
201 |
|
cout << endl << "seq. n. : "<< seqno; |
202 |
|
cout << endl << "image n. : "<< image; |
203 |
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] << " "; |
204 |
cout << endl << "chi^2 : "<< chi2; |
cout << endl << "chi^2 : "<< chi2; |
205 |
|
cout << endl << "n.step : "<< nstep; |
206 |
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] ; |
207 |
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] ; |
208 |
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] << " "; |
209 |
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] << " "; |
210 |
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] << " "; |
211 |
|
cout << endl << "xv : "; for(int i=0; i<6; i++)cout << xv[i] << " "; |
212 |
|
cout << endl << "yv : "; for(int i=0; i<6; i++)cout << yv[i] << " "; |
213 |
|
cout << endl << "zv : "; for(int i=0; i<6; i++)cout << zv[i] << " "; |
214 |
|
cout << endl << "resx : "; for(int i=0; i<6; i++)cout << resx[i] << " "; |
215 |
|
cout << endl << "resy : "; for(int i=0; i<6; i++)cout << resy[i] << " "; |
216 |
|
cout << endl << "coval : "; for(int i=0; i<5; i++)cout << coval[0][i]<<" "; |
217 |
|
cout << endl << " "; for(int i=0; i<5; i++)cout << coval[1][i]<<" "; |
218 |
|
cout << endl << " "; for(int i=0; i<5; i++)cout << coval[2][i]<<" "; |
219 |
|
cout << endl << " "; for(int i=0; i<5; i++)cout << coval[3][i]<<" "; |
220 |
|
cout << endl << " "; for(int i=0; i<5; i++)cout << coval[4][i]<<" "; |
221 |
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] << " "; |
222 |
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] << " "; |
223 |
|
cout << endl; |
224 |
|
} |
225 |
|
/** |
226 |
|
* Set the TrkTrack position measurements |
227 |
|
*/ |
228 |
|
void TrkTrack::SetMeasure(double *xmeas, double *ymeas, double *zmeas){ |
229 |
|
for(int i=0; i<6; i++) xm[i]=*xmeas++; |
230 |
|
for(int i=0; i<6; i++) ym[i]=*ymeas++; |
231 |
|
for(int i=0; i<6; i++) zm[i]=*zmeas++; |
232 |
|
} |
233 |
|
/** |
234 |
|
* Set the TrkTrack position resolution |
235 |
|
*/ |
236 |
|
void TrkTrack::SetResolution(double *rx, double *ry){ |
237 |
|
for(int i=0; i<6; i++) resx[i]=*rx++; |
238 |
|
for(int i=0; i<6; i++) resy[i]=*ry++; |
239 |
} |
} |
240 |
|
/** |
241 |
|
* Set the TrkTrack good measurement |
242 |
|
*/ |
243 |
|
void TrkTrack::SetGood(int *xg, int *yg){ |
244 |
|
for(int i=0; i<6; i++) xgood[i]=*xg++; |
245 |
|
for(int i=0; i<6; i++) ygood[i]=*yg++; |
246 |
|
} |
247 |
|
|
248 |
|
/** |
249 |
|
* Load the magnetic field |
250 |
|
*/ |
251 |
|
void TrkTrack::LoadField(TString s){ |
252 |
|
readb_(s.Data()); |
253 |
|
}; |
254 |
|
/** |
255 |
|
* Tracking method. It calls F77 mini routine. |
256 |
|
*/ |
257 |
|
void TrkTrack::Fit(double pfixed, int& fail, int iprint){ |
258 |
|
extern cMini2track track_; |
259 |
|
fail = 0; |
260 |
|
// extern cMini2fitinfo fit_info_; |
261 |
|
// extern void mini_2_(int*,int*); |
262 |
|
// track_.xm[0]=1.0; |
263 |
|
for(int i=0; i<6; i++) track_.xm[i]=xm[i]; |
264 |
|
for(int i=0; i<6; i++) track_.ym[i]=ym[i]; |
265 |
|
for(int i=0; i<6; i++) track_.zm[i]=zm[i]; |
266 |
|
for(int i=0; i<6; i++) track_.resx[i]=resx[i]; |
267 |
|
for(int i=0; i<6; i++) track_.resy[i]=resy[i]; |
268 |
|
for(int i=0; i<6; i++) track_.xgood[i]=xgood[i]; |
269 |
|
for(int i=0; i<6; i++) track_.ygood[i]=ygood[i]; |
270 |
|
// initial guess of "al" with linear fit |
271 |
|
if(al[0]==-9999.&&al[1]==-9999.&&al[2]==-9999.&&al[3]==-9999.&&al[4]==-9999.){ |
272 |
|
double szz=0., szx=0., szy=0., ssx=0., ssy=0., sz=0., s1=0.; |
273 |
|
double det, ax, ay, bx, by; |
274 |
|
for(int i=0; i<NPLANE; i++) { |
275 |
|
szz=szz+zm[i]*zm[i]; |
276 |
|
szx=szx+zm[i]*xm[i]; |
277 |
|
szy=szy+zm[i]*ym[i]; |
278 |
|
ssx=ssx+xm[i]; |
279 |
|
ssy=ssy+ym[i]; |
280 |
|
sz=sz+zm[i]; |
281 |
|
s1=s1+1.; |
282 |
|
} |
283 |
|
det=szz*s1-sz*sz; |
284 |
|
ax=(szx*s1-sz*ssx)/det; |
285 |
|
bx=(szz*ssx-szx*sz)/det; |
286 |
|
ay=(szy*s1-sz*ssy)/det; |
287 |
|
by=(szz*ssy-szy*sz)/det; |
288 |
|
al[0]=ax*23.5+bx; // ZINI = 23.5 !!! it should be the same parameter in all codes |
289 |
|
al[1]=ay*23.5+by; // " |
290 |
|
al[2]= sqrt(pow(ax,2)+pow(ay,2))/ sqrt(pow(ax,2)+pow(ay,2)+1.); |
291 |
|
al[3]=0.; |
292 |
|
if( (ax!=0.)||(ay!=0.) ) { |
293 |
|
al[3]= asin(ay/ sqrt(pow(ax,2)+pow(ay,2))); |
294 |
|
if(ax<0.) al[3]=acos(-1.)-al[3]; |
295 |
|
} |
296 |
|
al[4]=0.; |
297 |
|
} |
298 |
|
// end guess |
299 |
|
if(pfixed==0.) { |
300 |
|
al[4]=0.; // free momentum |
301 |
|
track_.pfixed=0.; // " |
302 |
|
} |
303 |
|
if(pfixed!=0.) { |
304 |
|
al[4]=1./pfixed; // to fix the momentum |
305 |
|
track_.pfixed=pfixed; // " |
306 |
|
} |
307 |
|
track_.zini = 23.5; // ZINI = 23.5 !!! it should be the same parameter in all codes |
308 |
|
for(int i=0; i<5; i++) track_.al[i]=al[i]; |
309 |
|
int istep=0; |
310 |
|
int ifail=0; |
311 |
|
mini2_(&istep,&ifail, &iprint); |
312 |
|
if(ifail!=0) { |
313 |
|
if(iprint==1)cout << "ERROR: ifail= " << ifail << endl; |
314 |
|
fail = 1; |
315 |
|
// return; |
316 |
|
} |
317 |
|
|
318 |
|
// cout << endl << "eta ===> " << track_.al[4] << endl; |
319 |
|
|
320 |
|
for(int i=0; i<5; i++) al[i]=track_.al[i]; |
321 |
|
chi2=track_.chi2; |
322 |
|
nstep=track_.nstep; |
323 |
|
for(int i=0; i<6; i++) xv[i]=track_.xv[i]; |
324 |
|
for(int i=0; i<6; i++) yv[i]=track_.yv[i]; |
325 |
|
for(int i=0; i<6; i++) zv[i]=track_.zv[i]; |
326 |
|
for(int i=0; i<6; i++) axv[i]=track_.axv[i]; |
327 |
|
for(int i=0; i<6; i++) ayv[i]=track_.ayv[i]; |
328 |
|
for(int i=0; i<5; i++) { |
329 |
|
for(int j=0; j<5; j++) coval[i][j]=track_.cov[i][j]; |
330 |
|
} |
331 |
|
}; |
332 |
|
/* |
333 |
|
* Reset the parameters fit |
334 |
|
*/ |
335 |
|
void TrkTrack::FitReset(){ |
336 |
|
for(int i=0; i<5; i++) al[i]=-9999.; |
337 |
|
chi2=0.; |
338 |
|
nstep=0; |
339 |
|
for(int i=0; i<6; i++) xv[i]=0.; |
340 |
|
for(int i=0; i<6; i++) yv[i]=0.; |
341 |
|
for(int i=0; i<6; i++) zv[i]=0.; |
342 |
|
for(int i=0; i<6; i++) axv[i]=0.; |
343 |
|
for(int i=0; i<6; i++) ayv[i]=0.; |
344 |
|
for(int i=0; i<5; i++) { |
345 |
|
for(int j=0; j<5; j++) coval[i][j]=0.; |
346 |
|
} |
347 |
|
} |
348 |
|
|
349 |
|
//-------------------------------------- |
350 |
|
// |
351 |
|
// |
352 |
|
//-------------------------------------- |
353 |
|
void TrkTrack::Clear(){ |
354 |
|
seqno = -1; |
355 |
|
image = -1; |
356 |
|
chi2 = 0; |
357 |
|
nstep = 0; |
358 |
|
for(int it1=0;it1<5;it1++){ |
359 |
|
al[it1] = 0; |
360 |
|
for(int it2=0;it2<5;it2++)coval[it1][it2] = 0; |
361 |
|
}; |
362 |
|
for(int ip=0;ip<6;ip++){ |
363 |
|
xgood[ip] = 0; |
364 |
|
ygood[ip] = 0; |
365 |
|
xm[ip] = 0; |
366 |
|
ym[ip] = 0; |
367 |
|
zm[ip] = 0; |
368 |
|
resx[ip] = 0; |
369 |
|
resy[ip] = 0; |
370 |
|
xv[ip] = 0; |
371 |
|
yv[ip] = 0; |
372 |
|
zv[ip] = 0; |
373 |
|
axv[ip] = 0; |
374 |
|
ayv[ip] = 0; |
375 |
|
dedx_x[ip] = 0; |
376 |
|
dedx_y[ip] = 0; |
377 |
|
// clx[ip] = 0; |
378 |
|
// cly[ip] = 0; |
379 |
|
}; |
380 |
|
clx->Clear(); |
381 |
|
cly->Clear(); |
382 |
|
}; |
383 |
|
//-------------------------------------- |
384 |
|
// |
385 |
|
// |
386 |
|
//-------------------------------------- |
387 |
|
void TrkTrack::Delete(){ |
388 |
|
Clear(); |
389 |
|
clx->Delete(); |
390 |
|
cly->Delete(); |
391 |
|
}; |
392 |
|
//-------------------------------------- |
393 |
|
// |
394 |
|
// |
395 |
|
//-------------------------------------- |
396 |
|
|
397 |
//-------------------------------------- |
//-------------------------------------- |
398 |
// |
// |
399 |
// |
// |
403 |
coord[0] = 0; |
coord[0] = 0; |
404 |
coord[1] = 0; |
coord[1] = 0; |
405 |
sgnl = 0; |
sgnl = 0; |
406 |
|
cls = 0; |
407 |
}; |
}; |
408 |
//-------------------------------------- |
//-------------------------------------- |
409 |
// |
// |
414 |
coord[0] = s.coord[0]; |
coord[0] = s.coord[0]; |
415 |
coord[1] = s.coord[1]; |
coord[1] = s.coord[1]; |
416 |
sgnl = s.sgnl; |
sgnl = s.sgnl; |
417 |
|
// cls = 0;//<<<<pointer |
418 |
|
cls = TRef(s.cls); |
419 |
}; |
}; |
420 |
//-------------------------------------- |
//-------------------------------------- |
421 |
// |
// |
433 |
// |
// |
434 |
//-------------------------------------- |
//-------------------------------------- |
435 |
TrkLevel2::TrkLevel2(){ |
TrkLevel2::TrkLevel2(){ |
436 |
good2 = -1; |
// good2 = -1; |
437 |
for(Int_t i=0; i<12 ; i++){ |
for(Int_t i=0; i<12 ; i++){ |
438 |
crc[i] = -1; |
// crc[i] = -1; |
439 |
}; |
good[i] = -1; |
440 |
|
}; |
441 |
Track = new TClonesArray("TrkTrack"); |
Track = new TClonesArray("TrkTrack"); |
442 |
SingletX = new TClonesArray("TrkSinglet"); |
SingletX = new TClonesArray("TrkSinglet"); |
443 |
SingletY = new TClonesArray("TrkSinglet"); |
SingletY = new TClonesArray("TrkSinglet"); |
444 |
// Track = 0; |
|
445 |
// Singlet = 0; |
// PhysicalTrack = new TClonesArray("TrkTrack"); |
446 |
// SingletY = 0; |
//sostituire con TRefArray... appena ho capito come si usa |
447 |
} |
} |
448 |
//-------------------------------------- |
//-------------------------------------- |
449 |
// |
// |
450 |
// |
// |
451 |
//-------------------------------------- |
//-------------------------------------- |
452 |
void TrkLevel2::Dump(){ |
void TrkLevel2::Dump(){ |
453 |
|
|
454 |
TClonesArray &t = *Track; |
TClonesArray &t = *Track; |
455 |
TClonesArray &sx = *SingletX; |
TClonesArray &sx = *SingletX; |
456 |
TClonesArray &sy = *SingletY; |
TClonesArray &sy = *SingletY; |
457 |
|
// |
458 |
cout << endl << endl << "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"; |
cout << endl << endl << "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"; |
459 |
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]; |
|
460 |
cout << endl << "ntrk() : " << this->ntrk() ; |
cout << endl << "ntrk() : " << this->ntrk() ; |
461 |
cout << endl << "nclsx() : " << this->nclsx(); |
cout << endl << "nclsx() : " << this->nclsx(); |
462 |
cout << endl << "nclsy() : " << this->nclsy(); |
cout << endl << "nclsy() : " << this->nclsy(); |
471 |
/** |
/** |
472 |
* 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). |
473 |
*/ |
*/ |
474 |
void TrkLevel2::FillCommonVar(cTrkLevel2 *l2){ |
void TrkLevel2::SetFromLevel2Struct(cTrkLevel2 *l2){ |
475 |
// |
|
476 |
// Track = new TClonesArray("TrkTrack"); |
// temporary objects: |
|
// SingletX = new TClonesArray("TrkSinglet"); |
|
|
// SingletY = new TClonesArray("TrkSinglet"); |
|
|
// temporary objects: |
|
477 |
TrkSinglet* t_singlet = new TrkSinglet(); |
TrkSinglet* t_singlet = new TrkSinglet(); |
478 |
TrkTrack* t_track = new TrkTrack(); |
TrkTrack* t_track = new TrkTrack(); |
479 |
// general variables |
|
480 |
good2 = l2->good2; |
// **** general variables **** |
481 |
|
// good2 = l2->good2; |
482 |
for(Int_t i=0; i<12 ; i++){ |
for(Int_t i=0; i<12 ; i++){ |
483 |
crc[i] = l2->crc[i]; |
// crc[i] = l2->crc[i]; |
484 |
}; |
good[i] = l2->good[i]; |
485 |
// *** TRACKS *** |
}; |
486 |
|
// *** TRACKS *** |
487 |
TClonesArray &t = *Track; |
TClonesArray &t = *Track; |
488 |
for(int i=0; i<l2->ntrk; i++){ |
for(int i=0; i<l2->ntrk; i++){ |
489 |
t_track->seqno = i; |
t_track->seqno = i;// NBNBNBNB deve sempre essere = i |
490 |
t_track->image = l2->image[i]-1; |
t_track->image = l2->image[i]-1; |
491 |
// cout << "track "<<i<<t_track->seqno << t_track->image<<endl; |
// cout << "track "<<i<<t_track->seqno << t_track->image<<endl; |
492 |
t_track->chi2 = l2->chi2_nt[i]; |
t_track->chi2 = l2->chi2_nt[i]; |
493 |
for(int it1=0;it1<5;it1++){ |
t_track->nstep = l2->nstep_nt[i]; |
494 |
t_track->al[it1] = l2->al_nt[i][it1]; |
for(int it1=0;it1<5;it1++){ |
495 |
for(int it2=0;it2<5;it2++) |
t_track->al[it1] = l2->al_nt[i][it1]; |
496 |
t_track->coval[it1][it2] = l2->coval[i][it2][it1]; |
for(int it2=0;it2<5;it2++) |
497 |
}; |
t_track->coval[it1][it2] = l2->coval[i][it2][it1]; |
498 |
for(int ip=0;ip<6;ip++){ |
}; |
499 |
t_track->xgood[ip] = l2->xgood_nt[i][ip]; |
for(int ip=0;ip<6;ip++){ |
500 |
t_track->ygood[ip] = l2->ygood_nt[i][ip]; |
t_track->xgood[ip] = l2->xgood_nt[i][ip]; |
501 |
t_track->xm[ip] = l2->xm_nt[i][ip]; |
t_track->ygood[ip] = l2->ygood_nt[i][ip]; |
502 |
t_track->ym[ip] = l2->ym_nt[i][ip]; |
t_track->xm[ip] = l2->xm_nt[i][ip]; |
503 |
t_track->zm[ip] = l2->zm_nt[i][ip]; |
t_track->ym[ip] = l2->ym_nt[i][ip]; |
504 |
t_track->resx[ip] = l2->resx_nt[i][ip]; |
t_track->zm[ip] = l2->zm_nt[i][ip]; |
505 |
t_track->resy[ip] = l2->resy_nt[i][ip]; |
t_track->resx[ip] = l2->resx_nt[i][ip]; |
506 |
t_track->xv[ip] = l2->xv_nt[i][ip]; |
t_track->resy[ip] = l2->resy_nt[i][ip]; |
507 |
t_track->yv[ip] = l2->yv_nt[i][ip]; |
t_track->xv[ip] = l2->xv_nt[i][ip]; |
508 |
t_track->zv[ip] = l2->zv_nt[i][ip]; |
t_track->yv[ip] = l2->yv_nt[i][ip]; |
509 |
t_track->axv[ip] = l2->axv_nt[i][ip]; |
t_track->zv[ip] = l2->zv_nt[i][ip]; |
510 |
t_track->ayv[ip] = l2->ayv_nt[i][ip]; |
t_track->axv[ip] = l2->axv_nt[i][ip]; |
511 |
t_track->dedx_x[ip] = l2->dedx_x[i][ip]; |
t_track->ayv[ip] = l2->ayv_nt[i][ip]; |
512 |
t_track->dedx_y[ip] = l2->dedx_y[i][ip]; |
t_track->dedx_x[ip] = l2->dedx_x[i][ip]; |
513 |
}; |
t_track->dedx_y[ip] = l2->dedx_y[i][ip]; |
514 |
new(t[i]) TrkTrack(*t_track); |
// t_track->clx[ip] = 0; |
515 |
t_track->Clear(); |
// t_track->cly[ip] = 0; |
516 |
|
}; |
517 |
|
new(t[i]) TrkTrack(*t_track); |
518 |
|
t_track->Clear(); |
519 |
}; |
}; |
520 |
// *** SINGLETS *** |
// *** SINGLETS *** |
521 |
TClonesArray &sx = *SingletX; |
TClonesArray &sx = *SingletX; |
522 |
for(int i=0; i<l2->nclsx; i++){ |
for(int i=0; i<l2->nclsx; i++){ |
523 |
t_singlet->plane = l2->planex[i]; |
t_singlet->plane = l2->planex[i]; |
524 |
t_singlet->coord[0] = l2->xs[i][0]; |
t_singlet->coord[0] = l2->xs[i][0]; |
525 |
t_singlet->coord[1] = l2->xs[i][1]; |
t_singlet->coord[1] = l2->xs[i][1]; |
526 |
t_singlet->sgnl = l2->signlxs[i]; |
t_singlet->sgnl = l2->signlxs[i]; |
527 |
new(sx[i]) TrkSinglet(*t_singlet); |
// t_singlet->cls = 0; |
528 |
t_singlet->Clear(); |
new(sx[i]) TrkSinglet(*t_singlet); |
529 |
|
t_singlet->Clear(); |
530 |
} |
} |
531 |
TClonesArray &sy = *SingletY; |
TClonesArray &sy = *SingletY; |
532 |
for(int i=0; i<l2->nclsy; i++){ |
for(int i=0; i<l2->nclsy; i++){ |
533 |
t_singlet->plane = l2->planey[i]; |
t_singlet->plane = l2->planey[i]; |
534 |
t_singlet->coord[0] = l2->ys[i][0]; |
t_singlet->coord[0] = l2->ys[i][0]; |
535 |
t_singlet->coord[1] = l2->ys[i][1]; |
t_singlet->coord[1] = l2->ys[i][1]; |
536 |
t_singlet->sgnl = l2->signlys[i]; |
t_singlet->sgnl = l2->signlys[i]; |
537 |
new(sy[i]) TrkSinglet(*t_singlet); |
// t_singlet->cls = 0; |
538 |
t_singlet->Clear(); |
new(sy[i]) TrkSinglet(*t_singlet); |
539 |
|
t_singlet->Clear(); |
540 |
}; |
}; |
541 |
|
|
542 |
delete t_track; |
delete t_track; |
546 |
// |
// |
547 |
// |
// |
548 |
//-------------------------------------- |
//-------------------------------------- |
549 |
void TrkLevel2::Clear(){ |
/** |
550 |
good2 = -1; |
* Fills a TrkLevel2 object with values from a struct cTrkLevel2 (to get data from F77 common). |
551 |
|
* Ref to Level1 data (clusters) is also set. |
552 |
|
*/ |
553 |
|
void TrkLevel2::SetFromLevel2Struct(cTrkLevel2 *l2, TrkLevel1 *l1){ |
554 |
|
|
555 |
|
// temporary objects: |
556 |
|
TrkSinglet* t_singlet = new TrkSinglet(); |
557 |
|
TrkTrack* t_track = new TrkTrack(); |
558 |
|
// general variables |
559 |
|
// good2 = l2->good2; |
560 |
|
for(Int_t i=0; i<12 ; i++){ |
561 |
|
// crc[i] = l2->crc[i]; |
562 |
|
good[i] = l2->good[i]; |
563 |
|
}; |
564 |
|
// *** TRACKS *** |
565 |
|
TClonesArray &t = *Track; |
566 |
|
for(int i=0; i<l2->ntrk; i++){ |
567 |
|
t_track->seqno = i;// NBNBNBNB deve sempre essere = i |
568 |
|
t_track->image = l2->image[i]-1; |
569 |
|
// cout << "track "<<i<<t_track->seqno << t_track->image<<endl; |
570 |
|
t_track->chi2 = l2->chi2_nt[i]; |
571 |
|
t_track->nstep = l2->nstep_nt[i]; |
572 |
|
for(int it1=0;it1<5;it1++){ |
573 |
|
t_track->al[it1] = l2->al_nt[i][it1]; |
574 |
|
for(int it2=0;it2<5;it2++) |
575 |
|
t_track->coval[it1][it2] = l2->coval[i][it2][it1]; |
576 |
|
}; |
577 |
|
for(int ip=0;ip<6;ip++){ |
578 |
|
t_track->xgood[ip] = l2->xgood_nt[i][ip]; |
579 |
|
t_track->ygood[ip] = l2->ygood_nt[i][ip]; |
580 |
|
t_track->xm[ip] = l2->xm_nt[i][ip]; |
581 |
|
t_track->ym[ip] = l2->ym_nt[i][ip]; |
582 |
|
t_track->zm[ip] = l2->zm_nt[i][ip]; |
583 |
|
t_track->resx[ip] = l2->resx_nt[i][ip]; |
584 |
|
t_track->resy[ip] = l2->resy_nt[i][ip]; |
585 |
|
t_track->xv[ip] = l2->xv_nt[i][ip]; |
586 |
|
t_track->yv[ip] = l2->yv_nt[i][ip]; |
587 |
|
t_track->zv[ip] = l2->zv_nt[i][ip]; |
588 |
|
t_track->axv[ip] = l2->axv_nt[i][ip]; |
589 |
|
t_track->ayv[ip] = l2->ayv_nt[i][ip]; |
590 |
|
t_track->dedx_x[ip] = l2->dedx_x[i][ip]; |
591 |
|
t_track->dedx_y[ip] = l2->dedx_y[i][ip]; |
592 |
|
// cout << "traccia "<<i<<" -- "<< ip << " "<< l2->cltrx[i][ip] <<" "<< l2->cltry[i][ip] <<" "<< t_track->xgood[ip] << t_track->ygood[ip]<<endl; |
593 |
|
//----------------------------------------------------- |
594 |
|
// t_track->clx[ip] = l1->GetCluster(l2->cltrx[i][ip]-1); |
595 |
|
// t_track->cly[ip] = l1->GetCluster(l2->cltry[i][ip]-1); |
596 |
|
if(t_track->xgood[ip])t_track->clx->AddAt(l1->GetCluster(l2->cltrx[i][ip]-1),ip); |
597 |
|
if(t_track->ygood[ip])t_track->cly->AddAt(l1->GetCluster(l2->cltry[i][ip]-1),ip); |
598 |
|
// 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; |
599 |
|
// 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; |
600 |
|
//----------------------------------------------------- |
601 |
|
}; |
602 |
|
new(t[i]) TrkTrack(*t_track); |
603 |
|
t_track->Clear(); |
604 |
|
}; |
605 |
|
// *** SINGLETS *** |
606 |
|
TClonesArray &sx = *SingletX; |
607 |
|
for(int i=0; i<l2->nclsx; i++){ |
608 |
|
t_singlet->plane = l2->planex[i]; |
609 |
|
t_singlet->coord[0] = l2->xs[i][0]; |
610 |
|
t_singlet->coord[1] = l2->xs[i][1]; |
611 |
|
t_singlet->sgnl = l2->signlxs[i]; |
612 |
|
//----------------------------------------------------- |
613 |
|
// cout << "singolo x "<<i<<" -- "<< l2->clsx[i] <<endl; |
614 |
|
t_singlet->cls = l1->GetCluster(l2->clsx[i]-1); |
615 |
|
// cout<<" i "<<i<<" l2->clsx[i] "<<l2->clsx[i]<< " l1->GetCluster(l2->clsx[i]-1) "<<l1->GetCluster(l2->clsx[i]-1)<<endl; |
616 |
|
//----------------------------------------------------- |
617 |
|
new(sx[i]) TrkSinglet(*t_singlet); |
618 |
|
t_singlet->Clear(); |
619 |
|
} |
620 |
|
TClonesArray &sy = *SingletY; |
621 |
|
for(int i=0; i<l2->nclsy; i++){ |
622 |
|
t_singlet->plane = l2->planey[i]; |
623 |
|
t_singlet->coord[0] = l2->ys[i][0]; |
624 |
|
t_singlet->coord[1] = l2->ys[i][1]; |
625 |
|
t_singlet->sgnl = l2->signlys[i]; |
626 |
|
//----------------------------------------------------- |
627 |
|
// cout << "singolo y "<<i<<" -- "<< l2->clsy[i] <<endl; |
628 |
|
t_singlet->cls = l1->GetCluster(l2->clsy[i]-1); |
629 |
|
// cout<<" i "<<i<<" l2->clsy[i] "<<l2->clsy[i]<< " l1->GetCluster(l2->clsy[i]-1) "<<l1->GetCluster(l2->clsy[i]-1)<<endl; |
630 |
|
//----------------------------------------------------- |
631 |
|
new(sy[i]) TrkSinglet(*t_singlet); |
632 |
|
t_singlet->Clear(); |
633 |
|
}; |
634 |
|
|
635 |
|
delete t_track; |
636 |
|
delete t_singlet; |
637 |
|
} |
638 |
|
/** |
639 |
|
* Fills a struct cTrkLevel2 with values from a TrkLevel2 object (to put data into a F77 common). |
640 |
|
*/ |
641 |
|
|
642 |
|
void TrkLevel2::GetLevel2Struct(cTrkLevel2 *l2) const { |
643 |
|
|
644 |
|
// general variables |
645 |
|
// l2->good2 = good2 ; |
646 |
for(Int_t i=0; i<12 ; i++){ |
for(Int_t i=0; i<12 ; i++){ |
647 |
crc[i] = -1; |
// l2->crc[i] = crc[i]; |
648 |
|
l2->good[i] = good[i]; |
649 |
}; |
}; |
650 |
|
// *** TRACKS *** |
651 |
|
|
652 |
|
l2->ntrk = Track->GetEntries(); |
653 |
|
for(Int_t i=0;i<l2->ntrk;i++){ |
654 |
|
l2->image[i] = 1 + ((TrkTrack *)Track->At(i))->image; |
655 |
|
l2->chi2_nt[i] = ((TrkTrack *)Track->At(i))->chi2; |
656 |
|
l2->nstep_nt[i] = ((TrkTrack *)Track->At(i))->nstep; |
657 |
|
for(int it1=0;it1<5;it1++){ |
658 |
|
l2->al_nt[i][it1] = ((TrkTrack *)Track->At(i))->al[it1]; |
659 |
|
for(int it2=0;it2<5;it2++) |
660 |
|
l2->coval[i][it2][it1] = ((TrkTrack *)Track->At(i))->coval[it1][it2]; |
661 |
|
}; |
662 |
|
for(int ip=0;ip<6;ip++){ |
663 |
|
l2->xgood_nt[i][ip] = ((TrkTrack *)Track->At(i))->xgood[ip]; |
664 |
|
l2->ygood_nt[i][ip] = ((TrkTrack *)Track->At(i))->ygood[ip]; |
665 |
|
l2->xm_nt[i][ip] = ((TrkTrack *)Track->At(i))->xm[ip]; |
666 |
|
l2->ym_nt[i][ip] = ((TrkTrack *)Track->At(i))->ym[ip]; |
667 |
|
l2->zm_nt[i][ip] = ((TrkTrack *)Track->At(i))->zm[ip]; |
668 |
|
l2->resx_nt[i][ip] = ((TrkTrack *)Track->At(i))->resx[ip]; |
669 |
|
l2->resy_nt[i][ip] = ((TrkTrack *)Track->At(i))->resy[ip]; |
670 |
|
l2->xv_nt[i][ip] = ((TrkTrack *)Track->At(i))->xv[ip]; |
671 |
|
l2->yv_nt[i][ip] = ((TrkTrack *)Track->At(i))->yv[ip]; |
672 |
|
l2->zv_nt[i][ip] = ((TrkTrack *)Track->At(i))->zv[ip]; |
673 |
|
l2->axv_nt[i][ip] = ((TrkTrack *)Track->At(i))->axv[ip]; |
674 |
|
l2->ayv_nt[i][ip] = ((TrkTrack *)Track->At(i))->ayv[ip]; |
675 |
|
l2->dedx_x[i][ip] = ((TrkTrack *)Track->At(i))->dedx_x[ip]; |
676 |
|
l2->dedx_y[i][ip] = ((TrkTrack *)Track->At(i))->dedx_y[ip]; |
677 |
|
}; |
678 |
|
} |
679 |
|
|
680 |
|
// *** SINGLETS *** |
681 |
|
l2->nclsx = SingletX->GetEntries(); |
682 |
|
for(Int_t i=0;i<l2->nclsx;i++){ |
683 |
|
l2->planex[i] = ((TrkSinglet *)SingletX->At(i))->plane; |
684 |
|
l2->xs[i][0] = ((TrkSinglet *)SingletX->At(i))->coord[0]; |
685 |
|
l2->xs[i][1] = ((TrkSinglet *)SingletX->At(i))->coord[1]; |
686 |
|
l2->signlxs[i] = ((TrkSinglet *)SingletX->At(i))->sgnl; |
687 |
|
} |
688 |
|
l2->nclsy = SingletY->GetEntries(); |
689 |
|
for(Int_t i=0;i<l2->nclsy;i++){ |
690 |
|
l2->planey[i] = ((TrkSinglet *)SingletY->At(i))->plane; |
691 |
|
l2->ys[i][0] = ((TrkSinglet *)SingletY->At(i))->coord[0]; |
692 |
|
l2->ys[i][1] = ((TrkSinglet *)SingletY->At(i))->coord[1]; |
693 |
|
l2->signlys[i] = ((TrkSinglet *)SingletY->At(i))->sgnl; |
694 |
|
} |
695 |
|
} |
696 |
|
//-------------------------------------- |
697 |
|
// |
698 |
|
// |
699 |
|
//-------------------------------------- |
700 |
|
void TrkLevel2::Clear(){ |
701 |
|
// good2 = -1; |
702 |
|
for(Int_t i=0; i<12 ; i++){ |
703 |
|
// crc[i] = -1; |
704 |
|
good[i] = -1; |
705 |
|
}; |
706 |
/* Track->RemoveAll(); |
/* Track->RemoveAll(); |
707 |
SingletX->RemoveAll(); |
SingletX->RemoveAll(); |
708 |
SingletY->RemoveAll();*/ |
SingletY->RemoveAll();*/ |
715 |
// |
// |
716 |
// |
// |
717 |
//-------------------------------------- |
//-------------------------------------- |
718 |
|
void TrkLevel2::Delete(){ |
719 |
|
|
720 |
|
Clear(); |
721 |
|
Track->Delete(); |
722 |
|
SingletX->Delete(); |
723 |
|
SingletY->Delete(); |
724 |
|
} |
725 |
|
//-------------------------------------- |
726 |
|
// |
727 |
|
// |
728 |
|
//-------------------------------------- |
729 |
/** |
/** |
730 |
* 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). |
731 |
* 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. |
732 |
*/ |
*/ |
733 |
TClonesArray *TrkLevel2::GetTracks(){ |
TRefArray *TrkLevel2::GetTracks_NFitSorted(){ |
|
TClonesArray *sorted = GetTracks_NFitSorted(); |
|
|
return sorted; |
|
|
}; |
|
734 |
|
|
735 |
TClonesArray *TrkLevel2::GetTracks_Chi2Sorted(){ |
TRefArray *sorted = new TRefArray(); |
736 |
|
|
737 |
TClonesArray *sorted = new TClonesArray("TrkTrack"); |
TClonesArray &t = *Track; |
738 |
TClonesArray &t = *Track; |
// TClonesArray &ts = *PhysicalTrack; |
739 |
TClonesArray &ts = *sorted; |
int N = ntrk(); |
740 |
int N=this->ntrk(); |
vector<int> m(N); for(int i=0; i<N; i++)m[i]=1; |
741 |
vector<int> m(N); for(int i=0; i<N; i++)m[i]=1; |
// int m[50]; for(int i=0; i<N; i++)m[i]=1; |
742 |
|
|
743 |
int indo=0; |
int indo=0; |
744 |
int indi=0; |
int indi=0; |
745 |
while(N != 0){ |
while(N != 0){ |
746 |
float chi2ref=1000000; |
int nfit =0; |
747 |
for(int i=0; i<this->ntrk(); i++){ |
float chi2ref = numeric_limits<float>::max(); |
|
if(((TrkTrack *)t[i])->chi2 < chi2ref && m[i]==1){ |
|
|
chi2ref = ((TrkTrack *)t[i])->chi2; |
|
|
indi = i; |
|
|
} |
|
|
} |
|
|
if( ((TrkTrack *)t[indi])->image != -1 ){ |
|
|
m[((TrkTrack *)t[indi])->image] = 0; |
|
|
N--; |
|
|
} |
|
|
new(ts[indo]) TrkTrack(*(TrkTrack*)t[indi]); |
|
|
m[indi] = 0; |
|
|
N--; |
|
|
indo++; |
|
|
} |
|
|
return sorted; |
|
|
} |
|
|
TClonesArray *TrkLevel2::GetTracks_NFitSorted(){ |
|
|
|
|
|
TClonesArray *sorted = new TClonesArray("TrkTrack"); |
|
|
TClonesArray &t = *Track; |
|
|
TClonesArray &ts = *sorted; |
|
|
int N=this->ntrk(); |
|
|
vector<int> m(N); for(int i=0; i<N; i++)m[i]=1; |
|
|
|
|
|
int indo=0; |
|
|
int indi=0; |
|
|
while(N != 0){ |
|
|
int nfit =0; |
|
|
float chi2ref=1000000; |
|
|
// first loop to search maximum num. of fit points |
|
|
for(int i=0; i<this->ntrk(); i++){ |
|
|
if( ((TrkTrack *)t[i])->GetNtot() >= nfit && m[i]==1){ |
|
|
nfit = ((TrkTrack *)t[i])->GetNtot(); |
|
|
// cout << "1** "<<i<< " " << nfit<<endl; |
|
|
} |
|
|
} |
|
|
//second loop to search minimum chi2 among selected |
|
|
for(int i=0; i<this->ntrk(); i++){ |
|
|
if( ((TrkTrack *)t[i])->chi2 < chi2ref |
|
|
&& ((TrkTrack *)t[i])->GetNtot()== nfit |
|
|
&& m[i]==1){ |
|
|
chi2ref = ((TrkTrack *)t[i])->chi2; |
|
|
indi = i; |
|
|
// cout << "2** "<<i<< " " << nfit <<" "<<chi2ref<<endl; |
|
|
} |
|
|
} |
|
|
if( ((TrkTrack *)t[indi])->HasImage() ){ |
|
|
m[((TrkTrack *)t[indi])->image] = 0; |
|
|
N--; |
|
|
|
|
|
// Int_t nfiti=((TrkTrack *)t[((TrkTrack *)t[indi])->image ])->GetNtot(); |
|
|
// Float_t chi2i=((TrkTrack *)t[((TrkTrack *)t[indi])->image ])->chi2; |
|
748 |
|
|
749 |
// cout << "i** "<< ((TrkTrack *)t[indi])->image << " " << nfiti <<" "<<chi2i<<endl; |
// first loop to search maximum num. of fit points |
750 |
|
for(int i=0; i < ntrk(); i++){ |
751 |
|
if( ((TrkTrack *)t[i])->GetNtot() >= nfit && m[i]==1){ |
752 |
|
nfit = ((TrkTrack *)t[i])->GetNtot(); |
753 |
|
} |
754 |
|
} |
755 |
|
//second loop to search minimum chi2 among selected |
756 |
|
for(int i=0; i<this->ntrk(); i++){ |
757 |
|
Float_t chi2 = ((TrkTrack *)t[i])->chi2; |
758 |
|
if(chi2 < 0) chi2 = chi2*1000; |
759 |
|
if( chi2 < chi2ref |
760 |
|
&& ((TrkTrack *)t[i])->GetNtot() == nfit |
761 |
|
&& m[i]==1){ |
762 |
|
chi2ref = ((TrkTrack *)t[i])->chi2; |
763 |
|
indi = i; |
764 |
|
}; |
765 |
|
}; |
766 |
|
if( ((TrkTrack *)t[indi])->HasImage() ){ |
767 |
|
m[((TrkTrack *)t[indi])->image] = 0; |
768 |
|
N--; |
769 |
|
|
770 |
|
// cout << "i** "<< ((TrkTrack *)t[indi])->image << " " << nfiti <<" "<<chi2i<<endl; |
771 |
|
}; |
772 |
|
sorted->Add( (TrkTrack*)t[indi] ); |
773 |
|
|
774 |
|
m[indi] = 0; |
775 |
|
// cout << "SORTED "<< indo << " "<< indi << " "<< N << endl; |
776 |
|
N--; |
777 |
|
indo++; |
778 |
} |
} |
779 |
new(ts[indo]) TrkTrack(*(TrkTrack*)t[indi]); |
m.clear(); |
780 |
m[indi] = 0; |
// cout << "GetTracks_NFitSorted(it): Done"<< endl; |
781 |
N--; |
|
782 |
indo++; |
return sorted; |
783 |
} |
// return PhysicalTrack; |
|
return sorted; |
|
784 |
} |
} |
785 |
//-------------------------------------- |
//-------------------------------------- |
786 |
// |
// |
807 |
// |
// |
808 |
//-------------------------------------- |
//-------------------------------------- |
809 |
/** |
/** |
810 |
|
* Retrieves the is-th stored X singlet. |
811 |
|
* @param it Singlet number, ranging from 0 to nclsx(). |
812 |
|
*/ |
813 |
|
TrkSinglet *TrkLevel2::GetSingletX(int is){ |
814 |
|
|
815 |
|
if(is >= this->nclsx()){ |
816 |
|
cout << "** TrkLevel2 ** Singlet "<< is << "doen not exits! " << endl; |
817 |
|
cout << " Stored x-singlets nclsx() = "<< this->nclsx() << endl; |
818 |
|
return 0; |
819 |
|
} |
820 |
|
TClonesArray &t = *(SingletX); |
821 |
|
TrkSinglet *singlet = (TrkSinglet*)t[is]; |
822 |
|
return singlet; |
823 |
|
} |
824 |
|
//-------------------------------------- |
825 |
|
// |
826 |
|
// |
827 |
|
//-------------------------------------- |
828 |
|
/** |
829 |
|
* Retrieves the is-th stored Y singlet. |
830 |
|
* @param it Singlet number, ranging from 0 to nclsx(). |
831 |
|
*/ |
832 |
|
TrkSinglet *TrkLevel2::GetSingletY(int is){ |
833 |
|
|
834 |
|
if(is >= this->nclsy()){ |
835 |
|
cout << "** TrkLevel2 ** Singlet "<< is << "doen not exits! " << endl; |
836 |
|
cout << " Stored y-singlets nclsy() = "<< this->nclsx() << endl; |
837 |
|
return 0; |
838 |
|
} |
839 |
|
TClonesArray &t = *(SingletY); |
840 |
|
TrkSinglet *singlet = (TrkSinglet*)t[is]; |
841 |
|
return singlet; |
842 |
|
} |
843 |
|
//-------------------------------------- |
844 |
|
// |
845 |
|
// |
846 |
|
//-------------------------------------- |
847 |
|
/** |
848 |
* Retrieves the it-th "physical" track, sorted by the method GetNTracks(). |
* Retrieves the it-th "physical" track, sorted by the method GetNTracks(). |
849 |
* @param it Track number, ranging from 0 to GetNTracks(). |
* @param it Track number, ranging from 0 to GetNTracks(). |
850 |
*/ |
*/ |
851 |
|
|
852 |
TrkTrack *TrkLevel2::GetTrack(int it){ |
TrkTrack *TrkLevel2::GetTrack(int it){ |
853 |
|
|
854 |
if(it >= this->GetNTracks()){ |
if(it >= this->GetNTracks()){ |
855 |
cout << "** TrkLevel2 ** Track "<< it << "does not exits! " << endl; |
cout << "** TrkLevel2 ** Track "<< it << "does not exits! " << endl; |
856 |
cout << " Physical tracks GetNTracks() = "<< this->ntrk() << endl; |
cout << " Physical tracks GetNTracks() = "<< this->ntrk() << endl; |
857 |
return 0; |
return 0; |
858 |
} |
} |
859 |
TrkTrack *track = (TrkTrack*)(*(this->GetTracks()))[it]; |
|
860 |
GetTracks()->Delete();////TEMPORANEO |
TRefArray *sorted = GetTracks(); //TEMPORANEO |
861 |
return track; |
TrkTrack *track = (TrkTrack*)sorted->At(it); |
862 |
|
sorted->Delete(); |
863 |
|
return track; |
864 |
} |
} |
865 |
|
/** |
866 |
|
* Give the number of "physical" tracks, sorted by the method GetTracks(). |
867 |
|
*/ |
868 |
Int_t TrkLevel2::GetNTracks(){ |
Int_t TrkLevel2::GetNTracks(){ |
869 |
Int_t ntot=0; |
|
870 |
ntot = GetTracks()->GetEntries(); |
Float_t ntot=0; |
871 |
GetTracks()->Delete();////TEMPORANEO |
TClonesArray &t = *Track; |
872 |
return ntot; |
for(int i=0; i<ntrk(); i++) { |
873 |
|
if( ((TrkTrack *)t[i])->GetImageSeqNo() == -1 ) ntot+=1.; |
874 |
|
else ntot+=0.5; |
875 |
|
} |
876 |
|
return (Int_t)ntot; |
877 |
|
|
878 |
}; |
}; |
879 |
//-------------------------------------- |
//-------------------------------------- |
880 |
// |
// |
886 |
*/ |
*/ |
887 |
TrkTrack *TrkLevel2::GetTrackImage(int it){ |
TrkTrack *TrkLevel2::GetTrackImage(int it){ |
888 |
|
|
889 |
if(it >= this->GetNTracks()){ |
if(it >= this->GetNTracks()){ |
890 |
cout << "** TrkLevel2 ** Track "<< it << "does not exits! " << endl; |
cout << "** TrkLevel2 ** Track "<< it << "does not exits! " << endl; |
891 |
cout << " Physical tracks GetNTracks() = "<< this->ntrk() << endl; |
cout << " Physical tracks GetNTracks() = "<< this->ntrk() << endl; |
892 |
return 0; |
return 0; |
893 |
} |
} |
894 |
TrkTrack *track = (TrkTrack*)(*(this->GetTracks()))[it]; |
|
895 |
if(!track->HasImage()){ |
TRefArray* sorted = GetTracks(); //TEMPORANEO |
896 |
cout << "** TrkLevel2 ** Track "<< it << "does not have image! " << endl; |
TrkTrack *track = (TrkTrack*)sorted->At(it); |
897 |
return 0; |
|
898 |
} |
if(!track->HasImage()){ |
899 |
TrkTrack *image = (TrkTrack*)(*Track)[track->image]; |
cout << "** TrkLevel2 ** Track "<< it << "does not have image! " << endl; |
900 |
return image; |
return 0; |
901 |
|
} |
902 |
|
TrkTrack *image = (TrkTrack*)(*Track)[track->image]; |
903 |
|
|
904 |
|
sorted->Delete(); |
905 |
|
|
906 |
|
return image; |
907 |
|
|
908 |
} |
} |
909 |
//-------------------------------------- |
//-------------------------------------- |
922 |
// |
// |
923 |
//-------------------------------------- |
//-------------------------------------- |
924 |
/** |
/** |
925 |
|
* Get tracker-plane (mechanical) z-coordinate |
926 |
|
* @param plane_id plane index (1=TOP,2,3,4,5,6=BOTTOM) |
927 |
|
*/ |
928 |
|
Float_t TrkLevel2::GetZTrk(Int_t plane_id){ |
929 |
|
switch(plane_id){ |
930 |
|
case 1: return ZTRK1; |
931 |
|
case 2: return ZTRK2; |
932 |
|
case 3: return ZTRK3; |
933 |
|
case 4: return ZTRK4; |
934 |
|
case 5: return ZTRK5; |
935 |
|
case 6: return ZTRK6; |
936 |
|
default: return 0.; |
937 |
|
}; |
938 |
|
}; |
939 |
|
//-------------------------------------- |
940 |
|
// |
941 |
|
// |
942 |
|
//-------------------------------------- |
943 |
|
/** |
944 |
* Trajectory default constructor. |
* Trajectory default constructor. |
945 |
* (By default is created with z-coordinates inside the tracking volume) |
* (By default is created with z-coordinates inside the tracking volume) |
946 |
*/ |
*/ |
952 |
thx = new float[npoint]; |
thx = new float[npoint]; |
953 |
thy = new float[npoint]; |
thy = new float[npoint]; |
954 |
tl = new float[npoint]; |
tl = new float[npoint]; |
955 |
float dz = ((ZTRKUP)-(ZTRKDW))/(npoint-1); |
float dz = ((ZTRK1)-(ZTRK6))/(npoint-1); |
956 |
for(int i=0; i<npoint; i++){ |
for(int i=0; i<npoint; i++){ |
957 |
x[i] = 0; |
x[i] = 0; |
958 |
y[i] = 0; |
y[i] = 0; |
959 |
z[i] = (ZTRKUP) - i*dz; |
z[i] = (ZTRK1) - i*dz; |
960 |
thx[i] = 0; |
thx[i] = 0; |
961 |
thy[i] = 0; |
thy[i] = 0; |
962 |
tl[i] = 0; |
tl[i] = 0; |
983 |
thx = new float[npoint]; |
thx = new float[npoint]; |
984 |
thy = new float[npoint]; |
thy = new float[npoint]; |
985 |
tl = new float[npoint]; |
tl = new float[npoint]; |
986 |
float dz = ((ZTRKUP)-(ZTRKDW))/(npoint-1); |
float dz = ((ZTRK1)-(ZTRK6))/(npoint-1); |
987 |
for(int i=0; i<npoint; i++){ |
for(int i=0; i<npoint; i++){ |
988 |
x[i] = 0; |
x[i] = 0; |
989 |
y[i] = 0; |
y[i] = 0; |
990 |
z[i] = (ZTRKUP) - i*dz; |
z[i] = (ZTRK1) - i*dz; |
991 |
thx[i] = 0; |
thx[i] = 0; |
992 |
thy[i] = 0; |
thy[i] = 0; |
993 |
tl[i] = 0; |
tl[i] = 0; |
1013 |
tl = new float[npoint]; |
tl = new float[npoint]; |
1014 |
int i=0; |
int i=0; |
1015 |
do{ |
do{ |
1016 |
x[i] = 0; |
x[i] = 0; |
1017 |
y[i] = 0; |
y[i] = 0; |
1018 |
z[i] = zin[i]; |
z[i] = zin[i]; |
1019 |
thx[i] = 0; |
thx[i] = 0; |
1020 |
thy[i] = 0; |
thy[i] = 0; |
1021 |
tl[i] = 0; |
tl[i] = 0; |
1022 |
i++; |
i++; |
1023 |
}while(zin[i-1] > zin[i] && i < npoint); |
}while(zin[i-1] > zin[i] && i < npoint); |
1024 |
npoint=i; |
npoint=i; |
1025 |
if(npoint != n)cout << "NB! Trajectory created with "<<npoint<<" points"<<endl; |
if(npoint != n)cout << "NB! Trajectory created with "<<npoint<<" points"<<endl; |
1061 |
return l; |
return l; |
1062 |
|
|
1063 |
} |
} |
1064 |
|
|
1065 |
|
|
1066 |
ClassImp(TrkLevel2); |
ClassImp(TrkLevel2); |
1067 |
ClassImp(TrkSinglet); |
ClassImp(TrkSinglet); |
1068 |
ClassImp(TrkTrack); |
ClassImp(TrkTrack); |