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*); |
void mini2_(int*,int*,int*); |
16 |
|
void guess_(); |
17 |
} |
} |
18 |
|
|
19 |
//-------------------------------------- |
//-------------------------------------- |
20 |
// |
// |
21 |
// |
// |
22 |
//-------------------------------------- |
//-------------------------------------- |
23 |
TrkTrack::TrkTrack(){ |
TrkTrack::TrkTrack(){ |
24 |
|
// cout << "TrkTrack::TrkTrack()" << endl; |
25 |
seqno = -1; |
seqno = -1; |
26 |
image = -1; |
image = -1; |
27 |
chi2 = 0; |
chi2 = 0; |
28 |
|
nstep = 0; |
29 |
for(int it1=0;it1<5;it1++){ |
for(int it1=0;it1<5;it1++){ |
30 |
al[it1] = 0; |
al[it1] = 0; |
31 |
for(int it2=0;it2<5;it2++) |
for(int it2=0;it2<5;it2++)coval[it1][it2] = 0; |
|
coval[it1][it2] = 0; |
|
32 |
}; |
}; |
33 |
for(int ip=0;ip<6;ip++){ |
for(int ip=0;ip<6;ip++){ |
34 |
xgood[ip] = 0; |
xgood[ip] = 0; |
38 |
zm[ip] = 0; |
zm[ip] = 0; |
39 |
resx[ip] = 0; |
resx[ip] = 0; |
40 |
resy[ip] = 0; |
resy[ip] = 0; |
41 |
|
tailx[ip] = 0; |
42 |
|
taily[ip] = 0; |
43 |
xv[ip] = 0; |
xv[ip] = 0; |
44 |
yv[ip] = 0; |
yv[ip] = 0; |
45 |
zv[ip] = 0; |
zv[ip] = 0; |
47 |
ayv[ip] = 0; |
ayv[ip] = 0; |
48 |
dedx_x[ip] = 0; |
dedx_x[ip] = 0; |
49 |
dedx_y[ip] = 0; |
dedx_y[ip] = 0; |
50 |
}; |
}; |
51 |
|
// clx = 0; |
52 |
|
// cly = 0; |
53 |
|
// clx = new TRefArray(6,0); //forse causa memory leak??? |
54 |
|
// cly = new TRefArray(6,0); //forse causa memory leak??? |
55 |
|
// clx = TRefArray(6,0); |
56 |
|
// cly = TRefArray(6,0); |
57 |
|
|
58 |
|
TrkParams::SetTrackingMode(); |
59 |
|
TrkParams::SetPrecisionFactor(); |
60 |
|
TrkParams::SetStepMin(); |
61 |
|
TrkParams::SetPFA(); |
62 |
|
|
63 |
}; |
}; |
64 |
//-------------------------------------- |
//-------------------------------------- |
65 |
// |
// |
69 |
seqno = t.seqno; |
seqno = t.seqno; |
70 |
image = t.image; |
image = t.image; |
71 |
chi2 = t.chi2; |
chi2 = t.chi2; |
72 |
|
nstep = t.nstep; |
73 |
for(int it1=0;it1<5;it1++){ |
for(int it1=0;it1<5;it1++){ |
74 |
al[it1] = t.al[it1]; |
al[it1] = t.al[it1]; |
75 |
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]; |
|
76 |
}; |
}; |
77 |
for(int ip=0;ip<6;ip++){ |
for(int ip=0;ip<6;ip++){ |
78 |
xgood[ip] = t.xgood[ip]; |
xgood[ip] = t.xgood[ip]; |
82 |
zm[ip] = t.zm[ip]; |
zm[ip] = t.zm[ip]; |
83 |
resx[ip] = t.resx[ip]; |
resx[ip] = t.resx[ip]; |
84 |
resy[ip] = t.resy[ip]; |
resy[ip] = t.resy[ip]; |
85 |
|
tailx[ip] = t.tailx[ip]; |
86 |
|
taily[ip] = t.taily[ip]; |
87 |
xv[ip] = t.xv[ip]; |
xv[ip] = t.xv[ip]; |
88 |
yv[ip] = t.yv[ip]; |
yv[ip] = t.yv[ip]; |
89 |
zv[ip] = t.zv[ip]; |
zv[ip] = t.zv[ip]; |
91 |
ayv[ip] = t.ayv[ip]; |
ayv[ip] = t.ayv[ip]; |
92 |
dedx_x[ip] = t.dedx_x[ip]; |
dedx_x[ip] = t.dedx_x[ip]; |
93 |
dedx_y[ip] = t.dedx_y[ip]; |
dedx_y[ip] = t.dedx_y[ip]; |
94 |
}; |
}; |
95 |
|
// clx = 0; |
96 |
|
// cly = 0; |
97 |
|
// if(t.clx)clx = new TRefArray(*(t.clx)); |
98 |
|
// if(t.cly)cly = new TRefArray(*(t.cly)); |
99 |
|
// clx = TRefArray(t.clx); |
100 |
|
// cly = TRefArray(t.cly); |
101 |
|
|
102 |
|
TrkParams::SetTrackingMode(); |
103 |
|
TrkParams::SetPrecisionFactor(); |
104 |
|
TrkParams::SetStepMin(); |
105 |
|
TrkParams::SetPFA(); |
106 |
|
|
107 |
|
}; |
108 |
|
//-------------------------------------- |
109 |
|
// |
110 |
|
// |
111 |
|
//-------------------------------------- |
112 |
|
void TrkTrack::Copy(TrkTrack& t){ |
113 |
|
|
114 |
|
t.seqno = seqno; |
115 |
|
t.image = image; |
116 |
|
t.chi2 = chi2; |
117 |
|
t.nstep = nstep; |
118 |
|
for(int it1=0;it1<5;it1++){ |
119 |
|
t.al[it1] = al[it1]; |
120 |
|
for(int it2=0;it2<5;it2++)t.coval[it1][it2] = coval[it1][it2]; |
121 |
|
}; |
122 |
|
for(int ip=0;ip<6;ip++){ |
123 |
|
t.xgood[ip] = xgood[ip]; |
124 |
|
t.ygood[ip] = ygood[ip]; |
125 |
|
t.xm[ip] = xm[ip]; |
126 |
|
t.ym[ip] = ym[ip]; |
127 |
|
t.zm[ip] = zm[ip]; |
128 |
|
t.resx[ip] = resx[ip]; |
129 |
|
t.resy[ip] = resy[ip]; |
130 |
|
t.tailx[ip] = tailx[ip]; |
131 |
|
t.taily[ip] = taily[ip]; |
132 |
|
t.xv[ip] = xv[ip]; |
133 |
|
t.yv[ip] = yv[ip]; |
134 |
|
t.zv[ip] = zv[ip]; |
135 |
|
t.axv[ip] = axv[ip]; |
136 |
|
t.ayv[ip] = ayv[ip]; |
137 |
|
t.dedx_x[ip] = dedx_x[ip]; |
138 |
|
t.dedx_y[ip] = dedx_y[ip]; |
139 |
|
|
140 |
|
}; |
141 |
|
|
142 |
|
// t.clx = TRefArray(clx); |
143 |
|
// t.cly = TRefArray(cly); |
144 |
|
|
145 |
}; |
}; |
146 |
//-------------------------------------- |
//-------------------------------------- |
147 |
// |
// |
166 |
for (int i=0; i<5; i++) dal[i] = (double)al[i]; |
for (int i=0; i<5; i++) dal[i] = (double)al[i]; |
167 |
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]; |
168 |
|
|
169 |
|
TrkParams::Load(1); |
170 |
|
if( !TrkParams::IsLoaded(1) ){ |
171 |
|
cout << "int TrkTrack::DoTrack(Trajectory* t) --- ERROR --- m.field not loaded"<<endl; |
172 |
|
return 0; |
173 |
|
} |
174 |
dotrack_(&(t->npoint),dzin,dxout,dyout,dal,&ifail); |
dotrack_(&(t->npoint),dzin,dxout,dyout,dal,&ifail); |
175 |
|
|
176 |
for (int i=0; i<t->npoint; i++){ |
for (int i=0; i<t->npoint; i++){ |
210 |
for (int i=0; i<5; i++) dal[i] = (double)al[i]; |
for (int i=0; i<5; i++) dal[i] = (double)al[i]; |
211 |
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]; |
212 |
|
|
213 |
|
TrkParams::Load(1); |
214 |
|
if( !TrkParams::IsLoaded(1) ){ |
215 |
|
cout << "int TrkTrack::DoTrack2(Trajectory* t) --- ERROR --- m.field not loaded"<<endl; |
216 |
|
return 0; |
217 |
|
} |
218 |
dotrack2_(&(t->npoint),dzin,dxout,dyout,dthxout,dthyout,dtlout,dal,&ifail); |
dotrack2_(&(t->npoint),dzin,dxout,dyout,dthxout,dthyout,dtlout,dal,&ifail); |
219 |
|
|
220 |
for (int i=0; i<t->npoint; i++){ |
for (int i=0; i<t->npoint; i++){ |
254 |
return def; |
return def; |
255 |
}; |
}; |
256 |
// |
// |
257 |
Float_t TrkTrack::GetDEDX(){ |
/** |
258 |
Float_t dedx=0; |
* Method to retrieve the dE/dx measured on a tracker view. |
259 |
for(Int_t i=0; i<6; i++)dedx+=dedx_x[i]*xgood[i]+dedx_y[i]*ygood[i]; |
* @param ip plane (0-5) |
260 |
dedx = dedx/(this->GetNX()+this->GetNY()); |
* @param iv view (0=x 1=y) |
261 |
return dedx; |
*/ |
262 |
|
Float_t TrkTrack::GetDEDX(int ip, int iv){ |
263 |
|
if(iv==0 && ip>=0 && ip<6)return fabs(dedx_x[ip]); |
264 |
|
else if(iv==1 && ip>=0 && ip<6)return fabs(dedx_y[ip]); |
265 |
|
else { |
266 |
|
cout << "TrkTrack::GetDEDX(int ip, int iv) -- wrong input parameters "<<ip<<iv<<endl; |
267 |
|
return 0.; |
268 |
|
} |
269 |
|
} |
270 |
|
/** |
271 |
|
* Method to evaluate the dE/dx measured on a tracker plane. |
272 |
|
* The two measurements on x- and y-view are averaged. |
273 |
|
* @param ip plane (0-5) |
274 |
|
*/ |
275 |
|
Float_t TrkTrack::GetDEDX(int ip){ |
276 |
|
if( (Int_t)XGood(ip)+(Int_t)YGood(ip) == 0 ) return 0; |
277 |
|
return (GetDEDX(ip,0)+GetDEDX(ip,1))/((Int_t)XGood(ip)+(Int_t)YGood(ip)); |
278 |
}; |
}; |
279 |
|
|
280 |
|
/** |
281 |
|
* Method to evaluate the dE/dx averaged over all planes. |
282 |
|
*/ |
283 |
|
Float_t TrkTrack::GetDEDX(){ |
284 |
|
Float_t dedx=0; |
285 |
|
for(Int_t ip=0; ip<6; ip++)dedx+=GetDEDX(ip,0)*XGood(ip)+GetDEDX(ip,1)*YGood(ip); |
286 |
|
dedx = dedx/(GetNX()+GetNY()); |
287 |
|
return dedx; |
288 |
|
}; |
289 |
|
/** |
290 |
|
* Returns 1 if the cluster on a tracker view includes bad strips. |
291 |
|
* @param ip plane (0-5) |
292 |
|
* @param iv view (0=x 1=y) |
293 |
|
*/ |
294 |
|
Bool_t TrkTrack::IsBad(int ip,int iv){ |
295 |
|
if(iv==0 && ip>=0 && ip<6)return (xgood[ip]<0) ; |
296 |
|
else if(iv==1 && ip>=0 && ip<6)return (ygood[ip]<0) ; |
297 |
|
else { |
298 |
|
cout << "TrkTrack::IsBad(int ip, int iv) -- wrong input parameters "<<ip<<iv<<endl; |
299 |
|
return 0.; |
300 |
|
} |
301 |
|
}; |
302 |
|
/** |
303 |
|
* Returns 1 if the signal on a tracker view is saturated. |
304 |
|
* @param ip plane (0-5) |
305 |
|
* @param iv view (0=x 1=y) |
306 |
|
*/ |
307 |
|
Bool_t TrkTrack::IsSaturated(int ip,int iv){ |
308 |
|
if(iv==0 && ip>=0 && ip<6)return (dedx_x[ip]<0) ; |
309 |
|
else if(iv==1 && ip>=0 && ip<6)return (dedx_y[ip]<0) ; |
310 |
|
else { |
311 |
|
cout << "TrkTrack::IsSaturated(int ip, int iv) -- wrong input parameters "<<ip<<iv<<endl; |
312 |
|
return 0.; |
313 |
|
} |
314 |
|
}; |
315 |
|
/** |
316 |
|
* Returns 1 if either the x or the y signal on a tracker plane is saturated. |
317 |
|
* @param ip plane (0-5) |
318 |
|
*/ |
319 |
|
Bool_t TrkTrack::IsSaturated(int ip){ |
320 |
|
return (IsSaturated(ip,0)||IsSaturated(ip,1)); |
321 |
|
}; |
322 |
|
/** |
323 |
|
* Returns 1 if there is at least a saturated signal along the track. |
324 |
|
*/ |
325 |
|
Bool_t TrkTrack::IsSaturated(){ |
326 |
|
for(int ip=0; ip<6; ip++)for(int iv=0; iv<2; iv++)if(IsSaturated(ip,iv))return true; |
327 |
|
return false; |
328 |
|
} |
329 |
|
/** |
330 |
|
* Returns the track "lever-arm" on the x view, defined as the distance (in planes) between |
331 |
|
* the upper and lower x measurements (the maximum value of lever-arm is 6). |
332 |
|
*/ |
333 |
|
Int_t TrkTrack::GetLeverArmX(){ |
334 |
|
int first_plane = -1; |
335 |
|
int last_plane = -1; |
336 |
|
for(Int_t ip=0; ip<6; ip++){ |
337 |
|
if( XGood(ip) && first_plane == -1 )first_plane = ip; |
338 |
|
if( XGood(ip) && first_plane != -1 )last_plane = ip; |
339 |
|
} |
340 |
|
if( first_plane == -1 || last_plane == -1){ |
341 |
|
cout<< "Int_t TrkTrack::GetLeverArmX() -- XGood(ip) always false ??? "<<endl; |
342 |
|
return 0; |
343 |
|
} |
344 |
|
return (last_plane-first_plane+1); |
345 |
|
} |
346 |
|
/** |
347 |
|
* Returns the track "lever-arm" on the y view, defined as the distance (in planes) between |
348 |
|
* the upper and lower y measurements (the maximum value of lever-arm is 6). |
349 |
|
*/ |
350 |
|
Int_t TrkTrack::GetLeverArmY(){ |
351 |
|
int first_plane = -1; |
352 |
|
int last_plane = -1; |
353 |
|
for(Int_t ip=0; ip<6; ip++){ |
354 |
|
if( YGood(ip) && first_plane == -1 )first_plane = ip; |
355 |
|
if( YGood(ip) && first_plane != -1 )last_plane = ip; |
356 |
|
} |
357 |
|
if( first_plane == -1 || last_plane == -1){ |
358 |
|
cout<< "Int_t TrkTrack::GetLeverArmY() -- YGood(ip) always false ??? "<<endl; |
359 |
|
return 0; |
360 |
|
} |
361 |
|
return (last_plane-first_plane+1); |
362 |
|
} |
363 |
//-------------------------------------- |
//-------------------------------------- |
364 |
// |
// |
365 |
// |
// |
366 |
//-------------------------------------- |
//-------------------------------------- |
367 |
void TrkTrack::Dump(){ |
void TrkTrack::Dump(){ |
368 |
cout << endl << "========== Track " ; |
cout << endl << "========== Track " ; |
369 |
|
cout << endl << "seq. n. : "<< seqno; |
370 |
|
cout << endl << "image n. : "<< image; |
371 |
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] << " "; |
372 |
cout << endl << "chi^2 : "<< chi2; |
cout << endl << "chi^2 : "<< chi2; |
373 |
cout << endl << "xgood : "; for(int i=0; i<6; i++)cout << xgood[i] ; |
cout << endl << "n.step : "<< nstep; |
374 |
cout << endl << "ygood : "; for(int i=0; i<6; i++)cout << ygood[i] ; |
cout << endl << "xgood : "; for(int i=0; i<6; i++)cout << XGood(i) ; |
375 |
|
cout << endl << "ygood : "; for(int i=0; i<6; i++)cout << YGood(i) ; |
376 |
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] << " "; |
377 |
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] << " "; |
378 |
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] << " "; |
379 |
|
cout << endl << "xv : "; for(int i=0; i<6; i++)cout << xv[i] << " "; |
380 |
|
cout << endl << "yv : "; for(int i=0; i<6; i++)cout << yv[i] << " "; |
381 |
|
cout << endl << "zv : "; for(int i=0; i<6; i++)cout << zv[i] << " "; |
382 |
|
cout << endl << "resx : "; for(int i=0; i<6; i++)cout << resx[i] << " "; |
383 |
|
cout << endl << "resy : "; for(int i=0; i<6; i++)cout << resy[i] << " "; |
384 |
|
cout << endl << "coval : "; for(int i=0; i<5; i++)cout << coval[0][i]<<" "; |
385 |
|
cout << endl << " "; for(int i=0; i<5; i++)cout << coval[1][i]<<" "; |
386 |
|
cout << endl << " "; for(int i=0; i<5; i++)cout << coval[2][i]<<" "; |
387 |
|
cout << endl << " "; for(int i=0; i<5; i++)cout << coval[3][i]<<" "; |
388 |
|
cout << endl << " "; for(int i=0; i<5; i++)cout << coval[4][i]<<" "; |
389 |
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] << " "; |
390 |
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] << " "; |
391 |
|
cout << endl; |
392 |
|
} |
393 |
|
/** |
394 |
|
* Set the TrkTrack position measurements |
395 |
|
*/ |
396 |
|
void TrkTrack::SetMeasure(double *xmeas, double *ymeas, double *zmeas){ |
397 |
|
for(int i=0; i<6; i++) xm[i]=*xmeas++; |
398 |
|
for(int i=0; i<6; i++) ym[i]=*ymeas++; |
399 |
|
for(int i=0; i<6; i++) zm[i]=*zmeas++; |
400 |
|
} |
401 |
|
/** |
402 |
|
* Set the TrkTrack position resolution |
403 |
|
*/ |
404 |
|
void TrkTrack::SetResolution(double *rx, double *ry){ |
405 |
|
for(int i=0; i<6; i++) resx[i]=*rx++; |
406 |
|
for(int i=0; i<6; i++) resy[i]=*ry++; |
407 |
} |
} |
408 |
|
/** |
409 |
|
* Set the TrkTrack good measurement. |
410 |
|
*/ |
411 |
|
void TrkTrack::SetGood(int *xg, int *yg){ |
412 |
|
|
413 |
|
for(int i=0; i<6; i++) xgood[i]=*xg++; |
414 |
|
for(int i=0; i<6; i++) ygood[i]=*yg++; |
415 |
|
} |
416 |
|
|
417 |
|
/** |
418 |
|
* Load the magnetic field |
419 |
|
*/ |
420 |
|
void TrkTrack::LoadField(TString path){ |
421 |
|
|
422 |
|
// strcpy(path_.path,path.Data()); |
423 |
|
// path_.pathlen = path.Length(); |
424 |
|
// path_.error = 0; |
425 |
|
// readb_(); |
426 |
|
|
427 |
|
TrkParams::SetTrackingMode(); |
428 |
|
TrkParams::SetPrecisionFactor(); |
429 |
|
TrkParams::SetStepMin(); |
430 |
|
|
431 |
|
TrkParams::Set(path,1); |
432 |
|
TrkParams::Load(1); |
433 |
|
|
434 |
|
}; |
435 |
|
|
436 |
|
|
437 |
|
/** |
438 |
|
* Method to fill minimization-routine common |
439 |
|
*/ |
440 |
|
void TrkTrack::FillMiniStruct(cMini2track& track){ |
441 |
|
|
442 |
|
for(int i=0; i<6; i++){ |
443 |
|
|
444 |
|
// cout << i<<" - "<<xgood[i]<<" "<<XGood(i)<<endl; |
445 |
|
// cout << i<<" - "<<ygood[i]<<" "<<YGood(i)<<endl; |
446 |
|
track.xgood[i]=XGood(i); |
447 |
|
track.ygood[i]=YGood(i); |
448 |
|
|
449 |
|
track.xm[i]=xm[i]; |
450 |
|
track.ym[i]=ym[i]; |
451 |
|
track.zm[i]=zm[i]; |
452 |
|
|
453 |
|
// --- temporaneo ---------------------------- |
454 |
|
// andrebbe inserita la dimensione del sensore |
455 |
|
float segment = 100.; |
456 |
|
track.xm_a[i]=xm[i]; |
457 |
|
track.xm_b[i]=xm[i]; |
458 |
|
track.ym_a[i]=ym[i]; |
459 |
|
track.ym_b[i]=ym[i]; |
460 |
|
if( XGood(i) && !YGood(i) ){ |
461 |
|
track.ym_a[i] = track.ym_a[i]+segment; |
462 |
|
track.ym_b[i] = track.ym_b[i]-segment; |
463 |
|
}else if( !XGood(i) && YGood(i)){ |
464 |
|
track.xm_a[i] = track.xm_a[i]+segment; |
465 |
|
track.xm_b[i] = track.xm_b[i]-segment; |
466 |
|
} |
467 |
|
// --- temporaneo ---------------------------- |
468 |
|
|
469 |
|
track.resx[i]=resx[i]; |
470 |
|
track.resy[i]=resy[i]; |
471 |
|
} |
472 |
|
|
473 |
|
for(int i=0; i<5; i++) track.al[i]=al[i]; |
474 |
|
track.zini = 23.5; |
475 |
|
// ZINI = 23.5 !!! it should be the same parameter in all codes |
476 |
|
|
477 |
|
} |
478 |
|
/** |
479 |
|
* Method to set values from minimization-routine common |
480 |
|
*/ |
481 |
|
void TrkTrack::SetFromMiniStruct(cMini2track *track){ |
482 |
|
|
483 |
|
for(int i=0; i<5; i++) { |
484 |
|
al[i]=track->al[i]; |
485 |
|
for(int j=0; j<5; j++) coval[i][j]=track->cov[i][j]; |
486 |
|
} |
487 |
|
chi2 = track->chi2; |
488 |
|
nstep = track->nstep; |
489 |
|
for(int i=0; i<6; i++){ |
490 |
|
xv[i] = track->xv[i]; |
491 |
|
yv[i] = track->yv[i]; |
492 |
|
zv[i] = track->zv[i]; |
493 |
|
xm[i] = track->xm[i]; |
494 |
|
ym[i] = track->ym[i]; |
495 |
|
zm[i] = track->zm[i]; |
496 |
|
axv[i] = track->axv[i]; |
497 |
|
ayv[i] = track->ayv[i]; |
498 |
|
} |
499 |
|
|
500 |
|
} |
501 |
|
/** |
502 |
|
* \brief Method to re-evaluate coordinates of clusters associated with a track. |
503 |
|
* |
504 |
|
* The method can be applied only after recovering level1 information |
505 |
|
* (either by reprocessing single events from level0 or from |
506 |
|
* the TrkLevel1 branch, if present); it calls F77 subroutines that |
507 |
|
* read the level1 common and fill the minimization-routine common. |
508 |
|
* Some clusters can be excluded or added by means of the methods: |
509 |
|
* |
510 |
|
* TrkTrack::ResetXGood(int ip) |
511 |
|
* TrkTrack::ResetYGood(int ip) |
512 |
|
* TrkTrack::SetXGood(int ip, int cid, int is) |
513 |
|
* TrkTrack::SetYGood(int ip, int cid, int is) |
514 |
|
* |
515 |
|
* NB! The method TrkTrack::SetGood(int *xg, int *yg) set the plane-mask (0-1) |
516 |
|
* for the minimization-routine common. It deletes the cluster information |
517 |
|
* (at least for the moment...) thus cannot be applied before |
518 |
|
* TrkTrack::EvaluateClusterPositions(). |
519 |
|
* |
520 |
|
* Different p.f.a. can be applied by calling (once) the method: |
521 |
|
* |
522 |
|
* TrkParams::SetPFA(0); //Set ETA p.f.a. |
523 |
|
* |
524 |
|
* @see TrkParams::SetPFA(int) |
525 |
|
*/ |
526 |
|
void TrkTrack::EvaluateClusterPositions(){ |
527 |
|
|
528 |
|
// cout << "void TrkTrack::GetClusterPositions() "<<endl; |
529 |
|
|
530 |
|
TrkParams::Load( ); |
531 |
|
if( !TrkParams::IsLoaded() )return; |
532 |
|
|
533 |
|
for(int ip=0; ip<6; ip++){ |
534 |
|
// cout << ip<<" ** "<<xm[ip]<<" / "<<ym[ip]<<endl;; |
535 |
|
int icx = GetClusterX_ID(ip)+1; |
536 |
|
int icy = GetClusterY_ID(ip)+1; |
537 |
|
int sensor = GetSensor(ip)+1;//<< convenzione "Paolo" |
538 |
|
if(ip==5 && sensor!=0)sensor=3-sensor;//<< convenzione "Elena" |
539 |
|
int ladder = GetLadder(ip)+1; |
540 |
|
float ax = axv[ip]; |
541 |
|
float ay = ayv[ip]; |
542 |
|
float v[3]; |
543 |
|
v[0]=xv[ip]; |
544 |
|
v[1]=yv[ip]; |
545 |
|
v[2]=zv[ip]; |
546 |
|
float bfx = 10*TrkParams::GetBX(v);//Tesla |
547 |
|
float bfy = 10*TrkParams::GetBY(v);//Tesla |
548 |
|
int ipp=ip+1; |
549 |
|
xyzpam_(&ipp,&icx,&icy,&ladder,&sensor,&ax,&ay,&bfx,&bfy); |
550 |
|
} |
551 |
|
} |
552 |
|
/** |
553 |
|
* \brief Tracking method. It calls F77 mini routine. |
554 |
|
* |
555 |
|
* @param pfixed Particle momentum. If pfixed=0 the momentum |
556 |
|
* is left as a free parameter, otherwise it is fixed to the input value. |
557 |
|
* @param fail Output flag (!=0 if the fit failed). |
558 |
|
* @param iprint Flag to set debug mode ( 0 = no output; 1 = verbose; 2 = debug). |
559 |
|
* @param froml1 Flag to re-evaluate positions (see TrkTrack::GetClusterPositions()). |
560 |
|
* |
561 |
|
* The option to re-evaluate positions can be used only after recovering |
562 |
|
* level1 information, eg. by reprocessing the single event. |
563 |
|
* |
564 |
|
* Example: |
565 |
|
* |
566 |
|
* if( !event->GetTrkLevel0() )return false; |
567 |
|
* event->GetTrkLevel0()->ProcessEvent(); // re-processing level0->level1 |
568 |
|
* int fail=0; |
569 |
|
* event->GetTrkLevel2()->GetTrack(0)->Fit(0.,fail,0,1); |
570 |
|
* |
571 |
|
* @see EvaluateClusterPositions() |
572 |
|
* |
573 |
|
* The fitting procedure can be varied by changing the tracking mode, |
574 |
|
* the fit-precision factor and the minimum number of step. |
575 |
|
* @see SetTrackingMode(int) |
576 |
|
* @see SetPrecisionFactor(double) |
577 |
|
* @see SetStepMin(int) |
578 |
|
*/ |
579 |
|
void TrkTrack::Fit(double pfixed, int& fail, int iprint, int froml1){ |
580 |
|
|
581 |
|
float al_ini[] = {0.,0.,0.,0.,0.}; |
582 |
|
|
583 |
|
TrkParams::Load( ); |
584 |
|
if( !TrkParams::IsLoaded() )return; |
585 |
|
|
586 |
|
extern cMini2track track_; |
587 |
|
fail = 0; |
588 |
|
FillMiniStruct(track_); |
589 |
|
|
590 |
|
if(froml1!=0)EvaluateClusterPositions(); |
591 |
|
|
592 |
|
// if fit variables have been reset, evaluate the initial guess |
593 |
|
if(al[0]==-9999.&&al[1]==-9999.&&al[2]==-9999.&&al[3]==-9999.&&al[4]==-9999.)guess_(); |
594 |
|
|
595 |
|
// --------------------- free momentum |
596 |
|
if(pfixed==0.) { |
597 |
|
track_.pfixed=0.; |
598 |
|
} |
599 |
|
// --------------------- fixed momentum |
600 |
|
if(pfixed!=0.) { |
601 |
|
al[4]=1./pfixed; |
602 |
|
track_.pfixed=pfixed; |
603 |
|
} |
604 |
|
|
605 |
|
// store temporarily the initial guess |
606 |
|
for(int i=0; i<5; i++) al_ini[i]=track_.al[i]; |
607 |
|
|
608 |
|
// ------------------------------------------ |
609 |
|
// call mini routine |
610 |
|
// TrkParams::Load(1); |
611 |
|
// if( !TrkParams::IsLoaded(1) ){ |
612 |
|
// cout << "void TrkTrack::Fit(double pfixed, int& fail, int iprint) --- ERROR --- m.field not loaded"<<endl; |
613 |
|
// return; |
614 |
|
// } |
615 |
|
int istep=0; |
616 |
|
int ifail=0; |
617 |
|
mini2_(&istep,&ifail, &iprint); |
618 |
|
if(ifail!=0) { |
619 |
|
if(iprint)cout << "ERROR: ifail= " << ifail << endl; |
620 |
|
fail = 1; |
621 |
|
} |
622 |
|
// ------------------------------------------ |
623 |
|
|
624 |
|
SetFromMiniStruct(&track_); |
625 |
|
|
626 |
|
if(fail){ |
627 |
|
if(iprint)cout << " >>>> fit failed "<<endl; |
628 |
|
for(int i=0; i<5; i++) al[i]=al_ini[i]; |
629 |
|
} |
630 |
|
|
631 |
|
}; |
632 |
|
/** |
633 |
|
* Reset the fit parameters |
634 |
|
*/ |
635 |
|
void TrkTrack::FitReset(){ |
636 |
|
for(int i=0; i<5; i++) al[i]=-9999.; |
637 |
|
chi2=0.; |
638 |
|
nstep=0; |
639 |
|
// for(int i=0; i<6; i++) xv[i]=0.; |
640 |
|
// for(int i=0; i<6; i++) yv[i]=0.; |
641 |
|
// for(int i=0; i<6; i++) zv[i]=0.; |
642 |
|
// for(int i=0; i<6; i++) axv[i]=0.; |
643 |
|
// for(int i=0; i<6; i++) ayv[i]=0.; |
644 |
|
for(int i=0; i<5; i++) { |
645 |
|
for(int j=0; j<5; j++) coval[i][j]=0.; |
646 |
|
} |
647 |
|
} |
648 |
|
/** |
649 |
|
* Set the tracking mode |
650 |
|
*/ |
651 |
|
void TrkTrack::SetTrackingMode(int trackmode){ |
652 |
|
extern cMini2track track_; |
653 |
|
track_.trackmode = trackmode; |
654 |
|
} |
655 |
|
/** |
656 |
|
* Set the factor scale for tracking precision |
657 |
|
*/ |
658 |
|
void TrkTrack::SetPrecisionFactor(double fact){ |
659 |
|
extern cMini2track track_; |
660 |
|
track_.fact = fact; |
661 |
|
} |
662 |
|
/** |
663 |
|
* Set the factor scale for tracking precision |
664 |
|
*/ |
665 |
|
void TrkTrack::SetStepMin(int istepmin){ |
666 |
|
extern cMini2track track_; |
667 |
|
track_.istepmin = istepmin; |
668 |
|
} |
669 |
|
|
670 |
|
|
671 |
|
/** |
672 |
|
* Method to retrieve ID (0,1,...) of x-cluster (if any) associated to this track. |
673 |
|
* If no cluster is associated, ID=-1. |
674 |
|
* @param ip Tracker plane (0-5) |
675 |
|
*/ |
676 |
|
Int_t TrkTrack::GetClusterX_ID(int ip){ |
677 |
|
return ((Int_t)fabs(xgood[ip]))%10000000-1; |
678 |
|
}; |
679 |
|
/** |
680 |
|
* Method to retrieve ID (0-xxx) of y-cluster (if any) associated to this track. |
681 |
|
* If no cluster is associated, ID=-1. |
682 |
|
* @param ip Tracker plane (0-5) |
683 |
|
*/ |
684 |
|
Int_t TrkTrack::GetClusterY_ID(int ip){ |
685 |
|
return ((Int_t)fabs(ygood[ip]))%10000000-1; |
686 |
|
}; |
687 |
|
/** |
688 |
|
* Method to retrieve the ladder (0-4, increasing x) traversed by the track on this plane. |
689 |
|
* If no ladder is traversed (dead area) the metod retuns -1. |
690 |
|
* @param ip Tracker plane (0-5) |
691 |
|
*/ |
692 |
|
Int_t TrkTrack::GetLadder(int ip){ |
693 |
|
if(XGood(ip))return (Int_t)fabs(xgood[ip]/100000000)-1; |
694 |
|
if(YGood(ip))return (Int_t)fabs(ygood[ip]/100000000)-1; |
695 |
|
return -1; |
696 |
|
}; |
697 |
|
/** |
698 |
|
* Method to retrieve the sensor (0-1, increasing y) traversed by the track on this plane. |
699 |
|
* If no sensor is traversed (dead area) the metod retuns -1. |
700 |
|
* @param ip Tracker plane (0-5) |
701 |
|
*/ |
702 |
|
Int_t TrkTrack::GetSensor(int ip){ |
703 |
|
if(XGood(ip))return (Int_t)((Int_t)fabs(xgood[ip]/10000000)%10)-1; |
704 |
|
if(YGood(ip))return (Int_t)((Int_t)fabs(ygood[ip]/10000000)%10)-1; |
705 |
|
return -1; |
706 |
|
}; |
707 |
|
|
708 |
|
/** |
709 |
|
* \brief Method to include a x-cluster to the track. |
710 |
|
* @param ip Tracker plane (0-5) |
711 |
|
* @param clid Cluster ID (0,1,...) |
712 |
|
* @param is Sensor (0-1, increasing y) |
713 |
|
* @see Fit(double pfixed, int& fail, int iprint, int froml1) |
714 |
|
*/ |
715 |
|
void TrkTrack::SetXGood(int ip, int clid, int is){ |
716 |
|
int il=0; //ladder (temporary) |
717 |
|
bool bad=false; //ladder (temporary) |
718 |
|
xgood[ip]=il*100000000+is*10000000+clid; |
719 |
|
if(bad)xgood[ip]=-xgood[ip]; |
720 |
|
}; |
721 |
|
/** |
722 |
|
* \brief Method to include a y-cluster to the track. |
723 |
|
* @param ip Tracker plane (0-5) |
724 |
|
* @param clid Cluster ID (0,1,...) |
725 |
|
* @param is Sensor (0-1) |
726 |
|
* @see Fit(double pfixed, int& fail, int iprint, int froml1) |
727 |
|
*/ |
728 |
|
void TrkTrack::SetYGood(int ip, int clid, int is){ |
729 |
|
int il=0; //ladder (temporary) |
730 |
|
bool bad=false; //ladder (temporary) |
731 |
|
ygood[ip]=il*100000000+is*10000000+clid; |
732 |
|
if(bad)ygood[ip]=-ygood[ip]; |
733 |
|
}; |
734 |
|
|
735 |
|
//-------------------------------------- |
736 |
|
// |
737 |
|
// |
738 |
|
//-------------------------------------- |
739 |
|
void TrkTrack::Clear(){ |
740 |
|
// cout << "TrkTrack::Clear()"<<endl; |
741 |
|
seqno = -1; |
742 |
|
image = -1; |
743 |
|
chi2 = 0; |
744 |
|
nstep = 0; |
745 |
|
for(int it1=0;it1<5;it1++){ |
746 |
|
al[it1] = 0; |
747 |
|
for(int it2=0;it2<5;it2++)coval[it1][it2] = 0; |
748 |
|
}; |
749 |
|
for(int ip=0;ip<6;ip++){ |
750 |
|
xgood[ip] = 0; |
751 |
|
ygood[ip] = 0; |
752 |
|
xm[ip] = 0; |
753 |
|
ym[ip] = 0; |
754 |
|
zm[ip] = 0; |
755 |
|
resx[ip] = 0; |
756 |
|
resy[ip] = 0; |
757 |
|
tailx[ip] = 0; |
758 |
|
taily[ip] = 0; |
759 |
|
xv[ip] = 0; |
760 |
|
yv[ip] = 0; |
761 |
|
zv[ip] = 0; |
762 |
|
axv[ip] = 0; |
763 |
|
ayv[ip] = 0; |
764 |
|
dedx_x[ip] = 0; |
765 |
|
dedx_y[ip] = 0; |
766 |
|
|
767 |
|
}; |
768 |
|
// if(clx)clx->Clear(); |
769 |
|
// if(cly)cly->Clear(); |
770 |
|
// clx.Clear(); |
771 |
|
// cly.Clear(); |
772 |
|
}; |
773 |
|
//-------------------------------------- |
774 |
|
// |
775 |
|
// |
776 |
|
//-------------------------------------- |
777 |
|
void TrkTrack::Delete(){ |
778 |
|
// cout << "TrkTrack::Delete()"<<endl; |
779 |
|
Clear(); |
780 |
|
// if(clx)delete clx; |
781 |
|
// if(cly)delete cly; |
782 |
|
}; |
783 |
|
//-------------------------------------- |
784 |
|
// |
785 |
|
// |
786 |
|
//-------------------------------------- |
787 |
|
|
788 |
//-------------------------------------- |
//-------------------------------------- |
789 |
// |
// |
790 |
// |
// |
791 |
//-------------------------------------- |
//-------------------------------------- |
792 |
TrkSinglet::TrkSinglet(){ |
TrkSinglet::TrkSinglet(){ |
793 |
|
// cout << "TrkSinglet::TrkSinglet() " << GetUniqueID()<<endl; |
794 |
plane = 0; |
plane = 0; |
795 |
coord[0] = 0; |
coord[0] = 0; |
796 |
coord[1] = 0; |
coord[1] = 0; |
797 |
sgnl = 0; |
sgnl = 0; |
798 |
|
// cls = 0; |
799 |
}; |
}; |
800 |
//-------------------------------------- |
//-------------------------------------- |
801 |
// |
// |
802 |
// |
// |
803 |
//-------------------------------------- |
//-------------------------------------- |
804 |
TrkSinglet::TrkSinglet(const TrkSinglet& s){ |
TrkSinglet::TrkSinglet(const TrkSinglet& s){ |
805 |
|
// cout << "TrkSinglet::TrkSinglet(const TrkSinglet& s) " << GetUniqueID()<<endl; |
806 |
plane = s.plane; |
plane = s.plane; |
807 |
coord[0] = s.coord[0]; |
coord[0] = s.coord[0]; |
808 |
coord[1] = s.coord[1]; |
coord[1] = s.coord[1]; |
809 |
sgnl = s.sgnl; |
sgnl = s.sgnl; |
810 |
|
// cls = 0;//<<<<pointer |
811 |
|
// cls = TRef(s.cls); |
812 |
}; |
}; |
813 |
//-------------------------------------- |
//-------------------------------------- |
814 |
// |
// |
825 |
// |
// |
826 |
// |
// |
827 |
//-------------------------------------- |
//-------------------------------------- |
828 |
|
void TrkSinglet::Clear(){ |
829 |
|
// cout << "TrkSinglet::Clear() " << GetUniqueID()<<endl; |
830 |
|
// cls=0; |
831 |
|
plane=-1; |
832 |
|
coord[0]=-999; |
833 |
|
coord[1]=-999; |
834 |
|
sgnl=0; |
835 |
|
|
836 |
|
} |
837 |
|
//-------------------------------------- |
838 |
|
// |
839 |
|
// |
840 |
|
//-------------------------------------- |
841 |
TrkLevel2::TrkLevel2(){ |
TrkLevel2::TrkLevel2(){ |
842 |
good2 = -1; |
// cout <<"TrkLevel2::TrkLevel2()"<<endl; |
843 |
for(Int_t i=0; i<12 ; i++){ |
for(Int_t i=0; i<12 ; i++){ |
844 |
crc[i] = -1; |
good[i] = -1; |
845 |
|
VKmask[i] = 0; |
846 |
|
VKflag[i] = 0; |
847 |
}; |
}; |
848 |
Track = new TClonesArray("TrkTrack"); |
Track = 0; |
849 |
SingletX = new TClonesArray("TrkSinglet"); |
SingletX = 0; |
850 |
SingletY = new TClonesArray("TrkSinglet"); |
SingletY = 0; |
851 |
|
|
852 |
// PhysicalTrack = new TClonesArray("TrkTrack"); |
} |
853 |
//sostituire con TRefArray... appena ho capito come si usa |
//-------------------------------------- |
854 |
|
// |
855 |
|
// |
856 |
|
//-------------------------------------- |
857 |
|
void TrkLevel2::Set(){ |
858 |
|
if(!Track)Track = new TClonesArray("TrkTrack"); |
859 |
|
if(!SingletX)SingletX = new TClonesArray("TrkSinglet"); |
860 |
|
if(!SingletY)SingletY = new TClonesArray("TrkSinglet"); |
861 |
} |
} |
862 |
//-------------------------------------- |
//-------------------------------------- |
863 |
// |
// |
864 |
// |
// |
865 |
//-------------------------------------- |
//-------------------------------------- |
866 |
void TrkLevel2::Dump(){ |
void TrkLevel2::Dump(){ |
867 |
TClonesArray &t = *Track; |
|
868 |
TClonesArray &sx = *SingletX; |
// |
|
TClonesArray &sy = *SingletY; |
|
|
|
|
869 |
cout << endl << endl << "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"; |
cout << endl << endl << "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"; |
870 |
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]; |
|
871 |
cout << endl << "ntrk() : " << this->ntrk() ; |
cout << endl << "ntrk() : " << this->ntrk() ; |
872 |
cout << endl << "nclsx() : " << this->nclsx(); |
cout << endl << "nclsx() : " << this->nclsx(); |
873 |
cout << endl << "nclsy() : " << this->nclsy(); |
cout << endl << "nclsy() : " << this->nclsy(); |
874 |
for(int i=0; i<this->ntrk(); i++) ((TrkTrack *)t[i])->Dump(); |
if(Track){ |
875 |
for(int i=0; i<this->nclsx(); i++) ((TrkSinglet *)sx[i])->Dump(); |
TClonesArray &t = *Track; |
876 |
for(int i=0; i<this->nclsy(); i++) ((TrkSinglet *)sy[i])->Dump(); |
for(int i=0; i<ntrk(); i++) ((TrkTrack *)t[i])->Dump(); |
877 |
|
} |
878 |
|
if(SingletX){ |
879 |
|
TClonesArray &sx = *SingletX; |
880 |
|
for(int i=0; i<nclsx(); i++) ((TrkSinglet *)sx[i])->Dump(); |
881 |
|
} |
882 |
|
if(SingletY){ |
883 |
|
TClonesArray &sy = *SingletY; |
884 |
|
for(int i=0; i<nclsy(); i++) ((TrkSinglet *)sy[i])->Dump(); |
885 |
|
} |
886 |
} |
} |
887 |
//-------------------------------------- |
//-------------------------------------- |
888 |
// |
// |
889 |
// |
// |
890 |
//-------------------------------------- |
//-------------------------------------- |
891 |
/** |
/** |
892 |
* Fills a TrkLevel2 object with values from a struct cTrkLevel2 (to get data from F77 common). |
* The method returns false if the viking-chip was masked |
893 |
|
* either apriori ,on the basis of the mask read from the DB, |
894 |
|
* or run-by-run, on the basis of the calibration parameters) |
895 |
|
* @param iv Tracker view (0-11) |
896 |
|
* @param ivk Viking-chip number (0-23) |
897 |
|
*/ |
898 |
|
Bool_t TrkLevel2::GetVKMask(int iv, int ivk){ |
899 |
|
Int_t whichbit = (Int_t)pow(2,ivk); |
900 |
|
return (whichbit&VKmask[iv])!=0; |
901 |
|
} |
902 |
|
/** |
903 |
|
* The method returns false if the viking-chip was masked |
904 |
|
* for this event due to common-noise computation failure. |
905 |
|
* @param iv Tracker view (0-11) |
906 |
|
* @param ivk Viking-chip number (0-23) |
907 |
*/ |
*/ |
908 |
void TrkLevel2::FillCommonVar(cTrkLevel2 *l2){ |
Bool_t TrkLevel2::GetVKFlag(int iv, int ivk){ |
909 |
// |
Int_t whichbit = (Int_t)pow(2,ivk); |
910 |
// Track = new TClonesArray("TrkTrack"); |
return (whichbit&VKflag[iv])!=0; |
911 |
// SingletX = new TClonesArray("TrkSinglet"); |
} |
912 |
// SingletY = new TClonesArray("TrkSinglet"); |
/** |
913 |
|
* The method returns true if the viking-chip was masked, either |
914 |
|
* forced (see TrkLevel2::GetVKMask(int,int)) or |
915 |
|
* for this event only (TrkLevel2::GetVKFlag(int,int)). |
916 |
|
* @param iv Tracker view (0-11) |
917 |
|
* @param ivk Viking-chip number (0-23) |
918 |
|
*/ |
919 |
|
Bool_t TrkLevel2::IsMaskedVK(int iv, int ivk){ |
920 |
|
return !(GetVKMask(iv,ivk)&&GetVKFlag(iv,ivk) ); |
921 |
|
}; |
922 |
|
|
923 |
|
//-------------------------------------- |
924 |
|
// |
925 |
|
// |
926 |
|
//-------------------------------------- |
927 |
|
/** |
928 |
|
* Fills a TrkLevel2 object with values from a struct cTrkLevel2 (to get data from F77 common). |
929 |
|
* Ref to Level1 data (clusters) is also set. If l1==NULL no references are set. |
930 |
|
* (NB It make sense to set references only if events are stored in a tree that contains also the Level1 branch) |
931 |
|
*/ |
932 |
|
void TrkLevel2::SetFromLevel2Struct(cTrkLevel2 *l2, TrkLevel1 *l1){ |
933 |
|
|
934 |
|
// cout << "void TrkLevel2::SetFromLevel2Struct(cTrkLevel2 *l2, TrkLevel1 *l1)"<<endl; |
935 |
|
Clear(); |
936 |
|
|
937 |
// temporary objects: |
// temporary objects: |
938 |
TrkSinglet* t_singlet = new TrkSinglet(); |
TrkSinglet* t_singlet = new TrkSinglet(); |
939 |
TrkTrack* t_track = new TrkTrack(); |
TrkTrack* t_track = new TrkTrack(); |
940 |
|
|
941 |
|
// ----------------- |
942 |
// general variables |
// general variables |
943 |
good2 = l2->good2; |
// ----------------- |
944 |
for(Int_t i=0; i<12 ; i++){ |
for(Int_t i=0; i<12 ; i++){ |
945 |
crc[i] = l2->crc[i]; |
good[i] = l2->good[i]; |
946 |
|
VKmask[i]=0; |
947 |
|
VKflag[i]=0; |
948 |
|
for(Int_t ii=0; ii<24 ; ii++){ |
949 |
|
Int_t setbit = (Int_t)pow(2,ii); |
950 |
|
if( l2->vkflag[ii][i]!=-1 )VKmask[i]=VKmask[i]|setbit; |
951 |
|
if( l2->vkflag[ii][i]!=0 )VKflag[i]=VKflag[i]|setbit; |
952 |
|
}; |
953 |
}; |
}; |
954 |
|
// -------------- |
955 |
// *** TRACKS *** |
// *** TRACKS *** |
956 |
|
// -------------- |
957 |
|
if(!Track) Track = new TClonesArray("TrkTrack"); |
958 |
TClonesArray &t = *Track; |
TClonesArray &t = *Track; |
959 |
|
|
960 |
for(int i=0; i<l2->ntrk; i++){ |
for(int i=0; i<l2->ntrk; i++){ |
961 |
t_track->seqno = i; |
t_track->seqno = i;// NBNBNBNB deve sempre essere = i |
962 |
t_track->image = l2->image[i]-1; |
t_track->image = l2->image[i]-1; |
|
// cout << "track "<<i<<t_track->seqno << t_track->image<<endl; |
|
963 |
t_track->chi2 = l2->chi2_nt[i]; |
t_track->chi2 = l2->chi2_nt[i]; |
964 |
|
t_track->nstep = l2->nstep_nt[i]; |
965 |
for(int it1=0;it1<5;it1++){ |
for(int it1=0;it1<5;it1++){ |
966 |
t_track->al[it1] = l2->al_nt[i][it1]; |
t_track->al[it1] = l2->al_nt[i][it1]; |
967 |
for(int it2=0;it2<5;it2++) |
for(int it2=0;it2<5;it2++) |
968 |
t_track->coval[it1][it2] = l2->coval[i][it2][it1]; |
t_track->coval[it1][it2] = l2->coval[i][it2][it1]; |
969 |
}; |
}; |
970 |
for(int ip=0;ip<6;ip++){ |
for(int ip=0;ip<6;ip++){ |
971 |
t_track->xgood[ip] = l2->xgood_nt[i][ip]; |
// --------------------------------- |
972 |
t_track->ygood[ip] = l2->ygood_nt[i][ip]; |
// new implementation of xgood/ygood |
973 |
|
// --------------------------------- |
974 |
|
t_track->xgood[ip] = l2->cltrx[i][ip]; //cluster ID |
975 |
|
t_track->ygood[ip] = l2->cltry[i][ip]; //cluster ID |
976 |
|
t_track->xgood[ip] += 10000000*l2->ls[i][ip]; // ladder+sensor |
977 |
|
t_track->ygood[ip] += 10000000*l2->ls[i][ip]; // ladder+sensor |
978 |
|
if(l2->xbad[i][ip]>0)t_track->xgood[ip]=-t_track->xgood[ip]; |
979 |
|
if(l2->ybad[i][ip]>0)t_track->ygood[ip]=-t_track->ygood[ip]; |
980 |
|
// if(l2->xbad[i][ip]>0 || l2->ybad[i][ip]>0){ |
981 |
|
// if(l2->dedx_x[i][ip]<0 || l2->dedx_y[i][ip]<0){ |
982 |
|
// cout << ip << " - "<< l2->cltrx[i][ip] << " "<<l2->cltry[i][ip]<<" "<<l2->ls[i][ip]<<endl; |
983 |
|
// cout << ip << " - "<<t_track->xgood[ip]<<" "<<t_track->ygood[ip]<<endl; |
984 |
|
// cout << ip << " - "<<t_track->GetClusterX_ID(ip)<<" "<<t_track->GetClusterY_ID(ip)<<" "<<t_track->GetLadder(ip)<<" "<<t_track->GetSensor(ip)<<endl; |
985 |
|
// cout << ip << " - "<<t_track->BadClusterX(ip)<<" "<<t_track->BadClusterY(ip)<<endl; |
986 |
|
// cout << ip << " - "<<t_track->SaturatedClusterX(ip)<<" "<<t_track->SaturatedClusterY(ip)<<endl; |
987 |
|
// } |
988 |
t_track->xm[ip] = l2->xm_nt[i][ip]; |
t_track->xm[ip] = l2->xm_nt[i][ip]; |
989 |
t_track->ym[ip] = l2->ym_nt[i][ip]; |
t_track->ym[ip] = l2->ym_nt[i][ip]; |
990 |
t_track->zm[ip] = l2->zm_nt[i][ip]; |
t_track->zm[ip] = l2->zm_nt[i][ip]; |
991 |
t_track->resx[ip] = l2->resx_nt[i][ip]; |
t_track->resx[ip] = l2->resx_nt[i][ip]; |
992 |
t_track->resy[ip] = l2->resy_nt[i][ip]; |
t_track->resy[ip] = l2->resy_nt[i][ip]; |
993 |
|
t_track->tailx[ip] = l2->tailx[i][ip]; |
994 |
|
t_track->taily[ip] = l2->taily[i][ip]; |
995 |
t_track->xv[ip] = l2->xv_nt[i][ip]; |
t_track->xv[ip] = l2->xv_nt[i][ip]; |
996 |
t_track->yv[ip] = l2->yv_nt[i][ip]; |
t_track->yv[ip] = l2->yv_nt[i][ip]; |
997 |
t_track->zv[ip] = l2->zv_nt[i][ip]; |
t_track->zv[ip] = l2->zv_nt[i][ip]; |
999 |
t_track->ayv[ip] = l2->ayv_nt[i][ip]; |
t_track->ayv[ip] = l2->ayv_nt[i][ip]; |
1000 |
t_track->dedx_x[ip] = l2->dedx_x[i][ip]; |
t_track->dedx_x[ip] = l2->dedx_x[i][ip]; |
1001 |
t_track->dedx_y[ip] = l2->dedx_y[i][ip]; |
t_track->dedx_y[ip] = l2->dedx_y[i][ip]; |
1002 |
|
//----------------------------------------------------- |
1003 |
|
//----------------------------------------------------- |
1004 |
|
//----------------------------------------------------- |
1005 |
|
//----------------------------------------------------- |
1006 |
}; |
}; |
1007 |
|
// if(t_track->IsSaturated())t_track->Dump(); |
1008 |
new(t[i]) TrkTrack(*t_track); |
new(t[i]) TrkTrack(*t_track); |
1009 |
t_track->Clear(); |
t_track->Clear(); |
1010 |
}; |
}; |
1011 |
|
|
1012 |
|
// ---------------- |
1013 |
// *** SINGLETS *** |
// *** SINGLETS *** |
1014 |
|
// ---------------- |
1015 |
|
if(!SingletX)SingletX = new TClonesArray("TrkSinglet"); |
1016 |
TClonesArray &sx = *SingletX; |
TClonesArray &sx = *SingletX; |
1017 |
for(int i=0; i<l2->nclsx; i++){ |
for(int i=0; i<l2->nclsx; i++){ |
1018 |
t_singlet->plane = l2->planex[i]; |
t_singlet->plane = l2->planex[i]; |
1019 |
t_singlet->coord[0] = l2->xs[i][0]; |
t_singlet->coord[0] = l2->xs[i][0]; |
1020 |
t_singlet->coord[1] = l2->xs[i][1]; |
t_singlet->coord[1] = l2->xs[i][1]; |
1021 |
t_singlet->sgnl = l2->signlxs[i]; |
t_singlet->sgnl = l2->signlxs[i]; |
1022 |
|
//----------------------------------------------------- |
1023 |
|
// if(l1) t_singlet->cls = l1->GetCluster(l2->clsx[i]-1); |
1024 |
|
//----------------------------------------------------- |
1025 |
new(sx[i]) TrkSinglet(*t_singlet); |
new(sx[i]) TrkSinglet(*t_singlet); |
1026 |
t_singlet->Clear(); |
t_singlet->Clear(); |
1027 |
} |
} |
1028 |
|
if(!SingletY)SingletY = new TClonesArray("TrkSinglet"); |
1029 |
TClonesArray &sy = *SingletY; |
TClonesArray &sy = *SingletY; |
1030 |
for(int i=0; i<l2->nclsy; i++){ |
for(int i=0; i<l2->nclsy; i++){ |
1031 |
t_singlet->plane = l2->planey[i]; |
t_singlet->plane = l2->planey[i]; |
1032 |
t_singlet->coord[0] = l2->ys[i][0]; |
t_singlet->coord[0] = l2->ys[i][0]; |
1033 |
t_singlet->coord[1] = l2->ys[i][1]; |
t_singlet->coord[1] = l2->ys[i][1]; |
1034 |
t_singlet->sgnl = l2->signlys[i]; |
t_singlet->sgnl = l2->signlys[i]; |
1035 |
|
//----------------------------------------------------- |
1036 |
|
// if(l1) t_singlet->cls = l1->GetCluster(l2->clsy[i]-1); |
1037 |
|
//----------------------------------------------------- |
1038 |
new(sy[i]) TrkSinglet(*t_singlet); |
new(sy[i]) TrkSinglet(*t_singlet); |
1039 |
t_singlet->Clear(); |
t_singlet->Clear(); |
1040 |
}; |
}; |
1041 |
|
|
1042 |
delete t_track; |
delete t_track; |
1043 |
delete t_singlet; |
delete t_singlet; |
1044 |
|
} |
1045 |
|
/** |
1046 |
|
* Fills a struct cTrkLevel2 with values from a TrkLevel2 object (to put data into a F77 common). |
1047 |
|
*/ |
1048 |
|
|
1049 |
|
void TrkLevel2::GetLevel2Struct(cTrkLevel2 *l2) const { |
1050 |
|
|
1051 |
|
// general variables |
1052 |
|
// l2->good2 = good2 ; |
1053 |
|
for(Int_t i=0; i<12 ; i++){ |
1054 |
|
// l2->crc[i] = crc[i]; |
1055 |
|
l2->good[i] = good[i]; |
1056 |
|
}; |
1057 |
|
// *** TRACKS *** |
1058 |
|
|
1059 |
|
if(Track){ |
1060 |
|
l2->ntrk = Track->GetEntries(); |
1061 |
|
for(Int_t i=0;i<l2->ntrk;i++){ |
1062 |
|
l2->image[i] = 1 + ((TrkTrack *)Track->At(i))->image; |
1063 |
|
l2->chi2_nt[i] = ((TrkTrack *)Track->At(i))->chi2; |
1064 |
|
l2->nstep_nt[i] = ((TrkTrack *)Track->At(i))->nstep; |
1065 |
|
for(int it1=0;it1<5;it1++){ |
1066 |
|
l2->al_nt[i][it1] = ((TrkTrack *)Track->At(i))->al[it1]; |
1067 |
|
for(int it2=0;it2<5;it2++) |
1068 |
|
l2->coval[i][it2][it1] = ((TrkTrack *)Track->At(i))->coval[it1][it2]; |
1069 |
|
}; |
1070 |
|
for(int ip=0;ip<6;ip++){ |
1071 |
|
l2->xgood_nt[i][ip] = ((TrkTrack *)Track->At(i))->XGood(ip); |
1072 |
|
l2->ygood_nt[i][ip] = ((TrkTrack *)Track->At(i))->YGood(ip); |
1073 |
|
l2->xm_nt[i][ip] = ((TrkTrack *)Track->At(i))->xm[ip]; |
1074 |
|
l2->ym_nt[i][ip] = ((TrkTrack *)Track->At(i))->ym[ip]; |
1075 |
|
l2->zm_nt[i][ip] = ((TrkTrack *)Track->At(i))->zm[ip]; |
1076 |
|
l2->resx_nt[i][ip] = ((TrkTrack *)Track->At(i))->resx[ip]; |
1077 |
|
l2->resy_nt[i][ip] = ((TrkTrack *)Track->At(i))->resy[ip]; |
1078 |
|
l2->tailx[i][ip] = ((TrkTrack *)Track->At(i))->tailx[ip]; |
1079 |
|
l2->taily[i][ip] = ((TrkTrack *)Track->At(i))->taily[ip]; |
1080 |
|
l2->xv_nt[i][ip] = ((TrkTrack *)Track->At(i))->xv[ip]; |
1081 |
|
l2->yv_nt[i][ip] = ((TrkTrack *)Track->At(i))->yv[ip]; |
1082 |
|
l2->zv_nt[i][ip] = ((TrkTrack *)Track->At(i))->zv[ip]; |
1083 |
|
l2->axv_nt[i][ip] = ((TrkTrack *)Track->At(i))->axv[ip]; |
1084 |
|
l2->ayv_nt[i][ip] = ((TrkTrack *)Track->At(i))->ayv[ip]; |
1085 |
|
l2->dedx_x[i][ip] = ((TrkTrack *)Track->At(i))->dedx_x[ip]; |
1086 |
|
l2->dedx_y[i][ip] = ((TrkTrack *)Track->At(i))->dedx_y[ip]; |
1087 |
|
}; |
1088 |
|
} |
1089 |
|
} |
1090 |
|
// *** SINGLETS *** |
1091 |
|
if(SingletX){ |
1092 |
|
l2->nclsx = SingletX->GetEntries(); |
1093 |
|
for(Int_t i=0;i<l2->nclsx;i++){ |
1094 |
|
l2->planex[i] = ((TrkSinglet *)SingletX->At(i))->plane; |
1095 |
|
l2->xs[i][0] = ((TrkSinglet *)SingletX->At(i))->coord[0]; |
1096 |
|
l2->xs[i][1] = ((TrkSinglet *)SingletX->At(i))->coord[1]; |
1097 |
|
l2->signlxs[i] = ((TrkSinglet *)SingletX->At(i))->sgnl; |
1098 |
|
} |
1099 |
|
} |
1100 |
|
|
1101 |
|
if(SingletY){ |
1102 |
|
l2->nclsy = SingletY->GetEntries(); |
1103 |
|
for(Int_t i=0;i<l2->nclsy;i++){ |
1104 |
|
l2->planey[i] = ((TrkSinglet *)SingletY->At(i))->plane; |
1105 |
|
l2->ys[i][0] = ((TrkSinglet *)SingletY->At(i))->coord[0]; |
1106 |
|
l2->ys[i][1] = ((TrkSinglet *)SingletY->At(i))->coord[1]; |
1107 |
|
l2->signlys[i] = ((TrkSinglet *)SingletY->At(i))->sgnl; |
1108 |
|
} |
1109 |
|
} |
1110 |
} |
} |
1111 |
//-------------------------------------- |
//-------------------------------------- |
1112 |
// |
// |
1113 |
// |
// |
1114 |
//-------------------------------------- |
//-------------------------------------- |
1115 |
void TrkLevel2::Clear(){ |
void TrkLevel2::Clear(){ |
|
good2 = -1; |
|
1116 |
for(Int_t i=0; i<12 ; i++){ |
for(Int_t i=0; i<12 ; i++){ |
1117 |
crc[i] = -1; |
good[i] = -1; |
1118 |
|
VKflag[i] = 0; |
1119 |
|
VKmask[i] = 0; |
1120 |
}; |
}; |
1121 |
/* Track->RemoveAll(); |
// if(Track)Track->Clear("C"); |
1122 |
SingletX->RemoveAll(); |
// if(SingletX)SingletX->Clear("C"); |
1123 |
SingletY->RemoveAll();*/ |
// if(SingletY)SingletY->Clear("C"); |
1124 |
// modify to avoid memory leakage |
if(Track)Track->Delete(); |
1125 |
Track->Clear(); |
if(SingletX)SingletX->Delete(); |
1126 |
SingletX->Clear(); |
if(SingletY)SingletY->Delete(); |
1127 |
SingletY->Clear(); |
} |
1128 |
|
// //-------------------------------------- |
1129 |
|
// // |
1130 |
|
// // |
1131 |
|
// //-------------------------------------- |
1132 |
|
void TrkLevel2::Delete(){ |
1133 |
|
|
1134 |
|
// cout << "void TrkLevel2::Delete()"<<endl; |
1135 |
|
Clear(); |
1136 |
|
if(Track)delete Track; |
1137 |
|
if(SingletX)delete SingletX; |
1138 |
|
if(SingletY)delete SingletY; |
1139 |
|
|
1140 |
} |
} |
1141 |
//-------------------------------------- |
//-------------------------------------- |
1142 |
// |
// |
1146 |
* 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). |
1147 |
* 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. |
1148 |
*/ |
*/ |
1149 |
TClonesArray *TrkLevel2::GetTracks(){ |
TRefArray *TrkLevel2::GetTracks_NFitSorted(){ |
|
TClonesArray *sorted = GetTracks_NFitSorted(); |
|
|
return sorted; |
|
|
|
|
|
// fare di meglio... |
|
|
/* PhysicalTrack->Clear(); |
|
|
if(ntrk() > 0) GetTracks_NFitSorted(); |
|
|
return PhysicalTrack;*/ |
|
|
}; |
|
1150 |
|
|
1151 |
/*TClonesArray *TrkLevel2::GetTracks_Chi2Sorted(){ |
if(!Track)return 0; |
|
|
|
|
TClonesArray *sorted = new TClonesArray("TrkTrack"); |
|
|
TClonesArray &t = *Track; |
|
|
TClonesArray &ts = *sorted; |
|
|
int N=this->ntrk(); |
|
|
vector<int> m(N); for(int i=0; i<N; i++)m[i]=1; |
|
|
|
|
|
int indo=0; |
|
|
int indi=0; |
|
|
while(N != 0){ |
|
|
float chi2ref=1000000; |
|
|
for(int i=0; i<this->ntrk(); i++){ |
|
|
if(((TrkTrack *)t[i])->chi2 < chi2ref && m[i]==1){ |
|
|
chi2ref = ((TrkTrack *)t[i])->chi2; |
|
|
indi = i; |
|
|
} |
|
|
} |
|
|
if( ((TrkTrack *)t[indi])->image != -1 ){ |
|
|
m[((TrkTrack *)t[indi])->image] = 0; |
|
|
N--; |
|
|
} |
|
|
new(ts[indo]) TrkTrack(*(TrkTrack*)t[indi]); |
|
|
m[indi] = 0; |
|
|
N--; |
|
|
indo++; |
|
|
} |
|
|
return sorted; |
|
|
}*/ |
|
|
TClonesArray *TrkLevel2::GetTracks_NFitSorted(){ |
|
1152 |
|
|
1153 |
TClonesArray *sorted = new TClonesArray("TrkTrack"); |
TRefArray *sorted = new TRefArray(); |
1154 |
TClonesArray &t = *Track; |
|
1155 |
TClonesArray &ts = *sorted; |
TClonesArray &t = *Track; |
1156 |
// TClonesArray &ts = *PhysicalTrack; |
// TClonesArray &ts = *PhysicalTrack; |
1157 |
int N=this->ntrk(); |
int N = ntrk(); |
1158 |
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; |
1159 |
|
// int m[50]; for(int i=0; i<N; i++)m[i]=1; |
1160 |
|
|
1161 |
int indo=0; |
int indo=0; |
1162 |
int indi=0; |
int indi=0; |
1163 |
while(N != 0){ |
while(N > 0){ |
1164 |
|
// while(N != 0){ |
1165 |
int nfit =0; |
int nfit =0; |
1166 |
float chi2ref=1000000; |
float chi2ref = numeric_limits<float>::max(); |
1167 |
|
|
1168 |
// first loop to search maximum num. of fit points |
// first loop to search maximum num. of fit points |
1169 |
for(int i=0; i<this->ntrk(); i++){ |
for(int i=0; i < ntrk(); i++){ |
1170 |
if( ((TrkTrack *)t[i])->GetNtot() >= nfit && m[i]==1){ |
if( ((TrkTrack *)t[i])->GetNtot() >= nfit && m[i]==1){ |
1171 |
nfit = ((TrkTrack *)t[i])->GetNtot(); |
nfit = ((TrkTrack *)t[i])->GetNtot(); |
|
// cout << "1** "<<i<< " " << nfit<<endl; |
|
1172 |
} |
} |
1173 |
} |
} |
1174 |
//second loop to search minimum chi2 among selected |
//second loop to search minimum chi2 among selected |
1175 |
for(int i=0; i<this->ntrk(); i++){ |
for(int i=0; i<ntrk(); i++){ |
1176 |
if( ((TrkTrack *)t[i])->chi2 < chi2ref |
Float_t chi2 = ((TrkTrack *)t[i])->chi2; |
1177 |
&& ((TrkTrack *)t[i])->GetNtot()== nfit |
if(chi2 < 0) chi2 = -chi2*1000; |
1178 |
&& m[i]==1){ |
if( chi2 < chi2ref |
1179 |
|
&& ((TrkTrack *)t[i])->GetNtot() == nfit |
1180 |
|
&& m[i]==1){ |
1181 |
chi2ref = ((TrkTrack *)t[i])->chi2; |
chi2ref = ((TrkTrack *)t[i])->chi2; |
1182 |
indi = i; |
indi = i; |
1183 |
// cout << "2** "<<i<< " " << nfit <<" "<<chi2ref<<endl; |
}; |
1184 |
} |
}; |
|
} |
|
1185 |
if( ((TrkTrack *)t[indi])->HasImage() ){ |
if( ((TrkTrack *)t[indi])->HasImage() ){ |
1186 |
m[((TrkTrack *)t[indi])->image] = 0; |
m[((TrkTrack *)t[indi])->image] = 0; |
1187 |
N--; |
N--; |
1188 |
|
|
|
// Int_t nfiti=((TrkTrack *)t[((TrkTrack *)t[indi])->image ])->GetNtot(); |
|
|
// Float_t chi2i=((TrkTrack *)t[((TrkTrack *)t[indi])->image ])->chi2; |
|
|
|
|
1189 |
// cout << "i** "<< ((TrkTrack *)t[indi])->image << " " << nfiti <<" "<<chi2i<<endl; |
// cout << "i** "<< ((TrkTrack *)t[indi])->image << " " << nfiti <<" "<<chi2i<<endl; |
1190 |
} |
}; |
1191 |
new(ts[indo]) TrkTrack(*(TrkTrack*)t[indi]); |
sorted->Add( (TrkTrack*)t[indi] ); |
1192 |
|
|
1193 |
m[indi] = 0; |
m[indi] = 0; |
1194 |
|
// cout << "SORTED "<< indo << " "<< indi << " "<< N << " "<<((TrkTrack *)t[indi])->image<<" "<<chi2ref<<endl; |
1195 |
N--; |
N--; |
1196 |
indo++; |
indo++; |
1197 |
} |
} |
1198 |
|
m.clear(); |
1199 |
|
// cout << "GetTracks_NFitSorted(it): Done"<< endl; |
1200 |
|
|
1201 |
return sorted; |
return sorted; |
1202 |
// return PhysicalTrack; |
// return PhysicalTrack; |
1203 |
} |
} |
1217 |
cout << " Stored tracks ntrk() = "<< this->ntrk() << endl; |
cout << " Stored tracks ntrk() = "<< this->ntrk() << endl; |
1218 |
return 0; |
return 0; |
1219 |
} |
} |
1220 |
|
if(!Track){ |
1221 |
|
cout << "TrkTrack *TrkLevel2::GetStoredTrack(int is) >> (TClonesArray*) Track ==0 "<<endl; |
1222 |
|
}; |
1223 |
TClonesArray &t = *(Track); |
TClonesArray &t = *(Track); |
1224 |
TrkTrack *track = (TrkTrack*)t[is]; |
TrkTrack *track = (TrkTrack*)t[is]; |
1225 |
return track; |
return track; |
1239 |
cout << " Stored x-singlets nclsx() = "<< this->nclsx() << endl; |
cout << " Stored x-singlets nclsx() = "<< this->nclsx() << endl; |
1240 |
return 0; |
return 0; |
1241 |
} |
} |
1242 |
|
if(!SingletX)return 0; |
1243 |
TClonesArray &t = *(SingletX); |
TClonesArray &t = *(SingletX); |
1244 |
TrkSinglet *singlet = (TrkSinglet*)t[is]; |
TrkSinglet *singlet = (TrkSinglet*)t[is]; |
1245 |
return singlet; |
return singlet; |
1259 |
cout << " Stored y-singlets nclsy() = "<< this->nclsx() << endl; |
cout << " Stored y-singlets nclsy() = "<< this->nclsx() << endl; |
1260 |
return 0; |
return 0; |
1261 |
} |
} |
1262 |
|
if(!SingletY)return 0; |
1263 |
TClonesArray &t = *(SingletY); |
TClonesArray &t = *(SingletY); |
1264 |
TrkSinglet *singlet = (TrkSinglet*)t[is]; |
TrkSinglet *singlet = (TrkSinglet*)t[is]; |
1265 |
return singlet; |
return singlet; |
1272 |
* Retrieves the it-th "physical" track, sorted by the method GetNTracks(). |
* Retrieves the it-th "physical" track, sorted by the method GetNTracks(). |
1273 |
* @param it Track number, ranging from 0 to GetNTracks(). |
* @param it Track number, ranging from 0 to GetNTracks(). |
1274 |
*/ |
*/ |
1275 |
|
|
1276 |
TrkTrack *TrkLevel2::GetTrack(int it){ |
TrkTrack *TrkLevel2::GetTrack(int it){ |
1277 |
|
|
1278 |
if(it >= this->GetNTracks()){ |
if(it >= this->GetNTracks()){ |
1279 |
cout << "** TrkLevel2 ** Track "<< it << "does not exits! " << endl; |
cout << "** TrkLevel2 ** Track "<< it << "does not exits! " << endl; |
1280 |
cout << " Physical tracks GetNTracks() = "<< this->ntrk() << endl; |
cout << " Physical tracks GetNTracks() = "<< this->ntrk() << endl; |
1281 |
return 0; |
return 0; |
1282 |
} |
} |
1283 |
TrkTrack *track = (TrkTrack*)(*(this->GetTracks()))[it]; |
|
1284 |
GetTracks()->Delete();////TEMPORANEO |
TRefArray *sorted = GetTracks(); //TEMPORANEO |
1285 |
return track; |
if(!sorted)return 0; |
1286 |
|
TrkTrack *track = (TrkTrack*)sorted->At(it); |
1287 |
|
sorted->Clear(); |
1288 |
|
delete sorted; |
1289 |
|
return track; |
1290 |
} |
} |
1291 |
/** |
/** |
1292 |
* Give the number of "physical" tracks, sorted by the method GetTracks(). |
* Give the number of "physical" tracks, sorted by the method GetTracks(). |
1293 |
*/ |
*/ |
1294 |
Int_t TrkLevel2::GetNTracks(){ |
Int_t TrkLevel2::GetNTracks(){ |
1295 |
Int_t ntot=0; |
|
1296 |
ntot = GetTracks()->GetEntries(); |
Float_t ntot=0; |
1297 |
GetTracks()->Delete();////TEMPORANEO |
if(!Track)return 0; |
1298 |
return ntot; |
TClonesArray &t = *Track; |
1299 |
|
for(int i=0; i<ntrk(); i++) { |
1300 |
|
if( ((TrkTrack *)t[i])->GetImageSeqNo() == -1 ) ntot+=1.; |
1301 |
|
else ntot+=0.5; |
1302 |
|
} |
1303 |
|
return (Int_t)ntot; |
1304 |
|
|
1305 |
}; |
}; |
1306 |
//-------------------------------------- |
//-------------------------------------- |
1307 |
// |
// |
1318 |
cout << " Physical tracks GetNTracks() = "<< this->ntrk() << endl; |
cout << " Physical tracks GetNTracks() = "<< this->ntrk() << endl; |
1319 |
return 0; |
return 0; |
1320 |
} |
} |
1321 |
TrkTrack *track = (TrkTrack*)(*(this->GetTracks()))[it]; |
|
1322 |
|
TRefArray* sorted = GetTracks(); //TEMPORANEO |
1323 |
|
if(!sorted)return 0; |
1324 |
|
TrkTrack *track = (TrkTrack*)sorted->At(it); |
1325 |
|
|
1326 |
if(!track->HasImage()){ |
if(!track->HasImage()){ |
1327 |
cout << "** TrkLevel2 ** Track "<< it << "does not have image! " << endl; |
cout << "** TrkLevel2 ** Track "<< it << "does not have image! " << endl; |
1328 |
return 0; |
return 0; |
1329 |
} |
} |
1330 |
|
if(!Track)return 0; |
1331 |
TrkTrack *image = (TrkTrack*)(*Track)[track->image]; |
TrkTrack *image = (TrkTrack*)(*Track)[track->image]; |
1332 |
GetTracks()->Delete(); ////TEMPORANEO |
|
1333 |
|
sorted->Delete(); |
1334 |
|
delete sorted; |
1335 |
|
|
1336 |
return image; |
return image; |
1337 |
|
|
1338 |
} |
} |
1344 |
* Loads the magnetic field. |
* Loads the magnetic field. |
1345 |
* @param s Path of the magnetic-field files. |
* @param s Path of the magnetic-field files. |
1346 |
*/ |
*/ |
1347 |
void TrkLevel2::LoadField(TString s){ |
void TrkLevel2::LoadField(TString path){ |
1348 |
readb_(s.Data()); |
// |
1349 |
|
// strcpy(path_.path,path.Data()); |
1350 |
|
// path_.pathlen = path.Length(); |
1351 |
|
// path_.error = 0; |
1352 |
|
// readb_(); |
1353 |
|
|
1354 |
|
TrkParams::SetTrackingMode(); |
1355 |
|
TrkParams::SetPrecisionFactor(); |
1356 |
|
TrkParams::SetStepMin(); |
1357 |
|
|
1358 |
|
TrkParams::Set(path,1); |
1359 |
|
TrkParams::Load(1); |
1360 |
|
|
1361 |
|
// |
1362 |
}; |
}; |
1363 |
|
// /** |
1364 |
|
// * Get BY (kGauss) |
1365 |
|
// * @param v (x,y,z) coordinates in cm |
1366 |
|
// */ |
1367 |
|
// float TrkLevel2::GetBX(float* v){ |
1368 |
|
// float b[3]; |
1369 |
|
// gufld_(v,b); |
1370 |
|
// return b[0]/10.; |
1371 |
|
// } |
1372 |
|
// /** |
1373 |
|
// * Get BY (kGauss) |
1374 |
|
// * @param v (x,y,z) coordinates in cm |
1375 |
|
// */ |
1376 |
|
// float TrkLevel2::GetBY(float* v){ |
1377 |
|
// float b[3]; |
1378 |
|
// gufld_(v,b); |
1379 |
|
// return b[1]/10.; |
1380 |
|
// } |
1381 |
|
// /** |
1382 |
|
// * Get BY (kGauss) |
1383 |
|
// * @param v (x,y,z) coordinates in cm |
1384 |
|
// */ |
1385 |
|
// float TrkLevel2::GetBZ(float* v){ |
1386 |
|
// float b[3]; |
1387 |
|
// gufld_(v,b); |
1388 |
|
// return b[2]/10.; |
1389 |
|
// } |
1390 |
//-------------------------------------- |
//-------------------------------------- |
1391 |
// |
// |
1392 |
// |
// |
1494 |
npoint=i; |
npoint=i; |
1495 |
if(npoint != n)cout << "NB! Trajectory created with "<<npoint<<" points"<<endl; |
if(npoint != n)cout << "NB! Trajectory created with "<<npoint<<" points"<<endl; |
1496 |
} |
} |
1497 |
|
void Trajectory::Delete(){ |
1498 |
|
|
1499 |
|
if(x) delete [] x; |
1500 |
|
if(y) delete [] y; |
1501 |
|
if(z) delete [] z; |
1502 |
|
if(thx) delete [] thx; |
1503 |
|
if(thy) delete [] thy; |
1504 |
|
if(tl) delete [] tl; |
1505 |
|
|
1506 |
|
} |
1507 |
//-------------------------------------- |
//-------------------------------------- |
1508 |
// |
// |
1509 |
// |
// |
1542 |
|
|
1543 |
} |
} |
1544 |
|
|
1545 |
|
/** |
1546 |
|
* Evaluates the trajectory in the apparatus associated to the track. |
1547 |
|
* 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. |
1548 |
|
* @param t pointer to an object of the class Trajectory, |
1549 |
|
* which z coordinates should be previously initialized by calling the proper constructor ( Trajectory::Trajectory(int n, float* zin) ). |
1550 |
|
* @return error flag. |
1551 |
|
*/ |
1552 |
|
int Trajectory::DoTrack2(float* al){ |
1553 |
|
|
1554 |
|
double *dxout = new double[npoint]; |
1555 |
|
double *dyout = new double[npoint]; |
1556 |
|
double *dthxout = new double[npoint]; |
1557 |
|
double *dthyout = new double[npoint]; |
1558 |
|
double *dtlout = new double[npoint]; |
1559 |
|
double *dzin = new double[npoint]; |
1560 |
|
double dal[5]; |
1561 |
|
|
1562 |
|
int ifail = 0; |
1563 |
|
|
1564 |
|
for (int i=0; i<5; i++) dal[i] = (double)al[i]; |
1565 |
|
for (int i=0; i<npoint; i++) dzin[i] = (double)z[i]; |
1566 |
|
|
1567 |
|
TrkParams::Load(1); |
1568 |
|
if( !TrkParams::IsLoaded(1) ){ |
1569 |
|
cout << "int Trajectory::DoTrack2(float* al) --- ERROR --- m.field not loaded"<<endl; |
1570 |
|
return 0; |
1571 |
|
} |
1572 |
|
dotrack2_(&(npoint),dzin,dxout,dyout,dthxout,dthyout,dtlout,dal,&ifail); |
1573 |
|
|
1574 |
|
for (int i=0; i<npoint; i++){ |
1575 |
|
x[i] = (float)*dxout++; |
1576 |
|
y[i] = (float)*dyout++; |
1577 |
|
thx[i] = (float)*dthxout++; |
1578 |
|
thy[i] = (float)*dthyout++; |
1579 |
|
tl[i] = (float)*dtlout++; |
1580 |
|
} |
1581 |
|
|
1582 |
|
return ifail; |
1583 |
|
}; |
1584 |
|
|
1585 |
ClassImp(TrkLevel2); |
ClassImp(TrkLevel2); |
1586 |
ClassImp(TrkSinglet); |
ClassImp(TrkSinglet); |
1587 |
ClassImp(TrkTrack); |
ClassImp(TrkTrack); |