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 |
|
void gufld_(float*, float*); |
18 |
|
float risxeta2_(float *); |
19 |
|
float risxeta3_(float *); |
20 |
|
float risxeta4_(float *); |
21 |
|
float risyeta2_(float *); |
22 |
} |
} |
23 |
|
|
24 |
//-------------------------------------- |
//-------------------------------------- |
25 |
// |
// |
26 |
// |
// |
27 |
//-------------------------------------- |
//-------------------------------------- |
28 |
TrkTrack::TrkTrack(){ |
TrkTrack::TrkTrack(){ |
29 |
|
// cout << "TrkTrack::TrkTrack()" << endl; |
30 |
seqno = -1; |
seqno = -1; |
31 |
image = -1; |
image = -1; |
32 |
chi2 = 0; |
chi2 = 0; |
33 |
|
nstep = 0; |
34 |
for(int it1=0;it1<5;it1++){ |
for(int it1=0;it1<5;it1++){ |
35 |
al[it1] = 0; |
al[it1] = 0; |
36 |
for(int it2=0;it2<5;it2++)coval[it1][it2] = 0; |
for(int it2=0;it2<5;it2++)coval[it1][it2] = 0; |
37 |
}; |
}; |
38 |
for(int ip=0;ip<6;ip++){ |
for(int ip=0;ip<6;ip++){ |
39 |
xgood[ip] = 0; |
xgood[ip] = 0; |
40 |
ygood[ip] = 0; |
ygood[ip] = 0; |
41 |
xm[ip] = 0; |
xm[ip] = 0; |
42 |
ym[ip] = 0; |
ym[ip] = 0; |
43 |
zm[ip] = 0; |
zm[ip] = 0; |
44 |
resx[ip] = 0; |
resx[ip] = 0; |
45 |
resy[ip] = 0; |
resy[ip] = 0; |
46 |
xv[ip] = 0; |
tailx[ip] = 0; |
47 |
yv[ip] = 0; |
taily[ip] = 0; |
48 |
zv[ip] = 0; |
xv[ip] = 0; |
49 |
axv[ip] = 0; |
yv[ip] = 0; |
50 |
ayv[ip] = 0; |
zv[ip] = 0; |
51 |
dedx_x[ip] = 0; |
axv[ip] = 0; |
52 |
dedx_y[ip] = 0; |
ayv[ip] = 0; |
53 |
// clx[ip] = 0; |
dedx_x[ip] = 0; |
54 |
// cly[ip] = 0; |
dedx_y[ip] = 0; |
55 |
}; |
}; |
56 |
clx = new TRefArray(6,0); |
// clx = 0; |
57 |
cly = new TRefArray(6,0); |
// cly = 0; |
58 |
|
// clx = new TRefArray(6,0); //forse causa memory leak??? |
59 |
|
// cly = new TRefArray(6,0); //forse causa memory leak??? |
60 |
|
// clx = TRefArray(6,0); |
61 |
|
// cly = TRefArray(6,0); |
62 |
|
|
63 |
|
TrkParams::SetTrackingMode(); |
64 |
|
TrkParams::SetPrecisionFactor(); |
65 |
|
TrkParams::SetStepMin(); |
66 |
|
TrkParams::SetPFA(); |
67 |
|
|
68 |
}; |
}; |
69 |
//-------------------------------------- |
//-------------------------------------- |
70 |
// |
// |
74 |
seqno = t.seqno; |
seqno = t.seqno; |
75 |
image = t.image; |
image = t.image; |
76 |
chi2 = t.chi2; |
chi2 = t.chi2; |
77 |
|
nstep = t.nstep; |
78 |
for(int it1=0;it1<5;it1++){ |
for(int it1=0;it1<5;it1++){ |
79 |
al[it1] = t.al[it1]; |
al[it1] = t.al[it1]; |
80 |
for(int it2=0;it2<5;it2++)coval[it1][it2] = t.coval[it1][it2]; |
for(int it2=0;it2<5;it2++)coval[it1][it2] = t.coval[it1][it2]; |
81 |
}; |
}; |
82 |
for(int ip=0;ip<6;ip++){ |
for(int ip=0;ip<6;ip++){ |
83 |
xgood[ip] = t.xgood[ip]; |
xgood[ip] = t.xgood[ip]; |
84 |
ygood[ip] = t.ygood[ip]; |
ygood[ip] = t.ygood[ip]; |
85 |
xm[ip] = t.xm[ip]; |
xm[ip] = t.xm[ip]; |
86 |
ym[ip] = t.ym[ip]; |
ym[ip] = t.ym[ip]; |
87 |
zm[ip] = t.zm[ip]; |
zm[ip] = t.zm[ip]; |
88 |
resx[ip] = t.resx[ip]; |
resx[ip] = t.resx[ip]; |
89 |
resy[ip] = t.resy[ip]; |
resy[ip] = t.resy[ip]; |
90 |
xv[ip] = t.xv[ip]; |
tailx[ip] = t.tailx[ip]; |
91 |
yv[ip] = t.yv[ip]; |
taily[ip] = t.taily[ip]; |
92 |
zv[ip] = t.zv[ip]; |
xv[ip] = t.xv[ip]; |
93 |
axv[ip] = t.axv[ip]; |
yv[ip] = t.yv[ip]; |
94 |
ayv[ip] = t.ayv[ip]; |
zv[ip] = t.zv[ip]; |
95 |
dedx_x[ip] = t.dedx_x[ip]; |
axv[ip] = t.axv[ip]; |
96 |
dedx_y[ip] = t.dedx_y[ip]; |
ayv[ip] = t.ayv[ip]; |
97 |
// clx[ip] = 0;//<<<<pointer |
dedx_x[ip] = t.dedx_x[ip]; |
98 |
// cly[ip] = 0;//<<<<pointer |
dedx_y[ip] = t.dedx_y[ip]; |
99 |
}; |
}; |
100 |
clx = new TRefArray(*(t.clx)); |
// clx = 0; |
101 |
cly = new TRefArray(*(t.cly)); |
// cly = 0; |
102 |
|
// if(t.clx)clx = new TRefArray(*(t.clx)); |
103 |
|
// if(t.cly)cly = new TRefArray(*(t.cly)); |
104 |
|
// clx = TRefArray(t.clx); |
105 |
|
// cly = TRefArray(t.cly); |
106 |
|
|
107 |
|
TrkParams::SetTrackingMode(); |
108 |
|
TrkParams::SetPrecisionFactor(); |
109 |
|
TrkParams::SetStepMin(); |
110 |
|
TrkParams::SetPFA(); |
111 |
|
|
112 |
|
}; |
113 |
|
//-------------------------------------- |
114 |
|
// |
115 |
|
// |
116 |
|
//-------------------------------------- |
117 |
|
void TrkTrack::Copy(TrkTrack& t){ |
118 |
|
|
119 |
|
t.seqno = seqno; |
120 |
|
t.image = image; |
121 |
|
t.chi2 = chi2; |
122 |
|
t.nstep = nstep; |
123 |
|
for(int it1=0;it1<5;it1++){ |
124 |
|
t.al[it1] = al[it1]; |
125 |
|
for(int it2=0;it2<5;it2++)t.coval[it1][it2] = coval[it1][it2]; |
126 |
|
}; |
127 |
|
for(int ip=0;ip<6;ip++){ |
128 |
|
t.xgood[ip] = xgood[ip]; |
129 |
|
t.ygood[ip] = ygood[ip]; |
130 |
|
t.xm[ip] = xm[ip]; |
131 |
|
t.ym[ip] = ym[ip]; |
132 |
|
t.zm[ip] = zm[ip]; |
133 |
|
t.resx[ip] = resx[ip]; |
134 |
|
t.resy[ip] = resy[ip]; |
135 |
|
t.tailx[ip] = tailx[ip]; |
136 |
|
t.taily[ip] = taily[ip]; |
137 |
|
t.xv[ip] = xv[ip]; |
138 |
|
t.yv[ip] = yv[ip]; |
139 |
|
t.zv[ip] = zv[ip]; |
140 |
|
t.axv[ip] = axv[ip]; |
141 |
|
t.ayv[ip] = ayv[ip]; |
142 |
|
t.dedx_x[ip] = dedx_x[ip]; |
143 |
|
t.dedx_y[ip] = dedx_y[ip]; |
144 |
|
|
145 |
|
}; |
146 |
|
|
147 |
|
// t.clx = TRefArray(clx); |
148 |
|
// t.cly = TRefArray(cly); |
149 |
|
|
150 |
}; |
}; |
151 |
//-------------------------------------- |
//-------------------------------------- |
152 |
// |
// |
171 |
for (int i=0; i<5; i++) dal[i] = (double)al[i]; |
for (int i=0; i<5; i++) dal[i] = (double)al[i]; |
172 |
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]; |
173 |
|
|
174 |
|
TrkParams::Load(1); |
175 |
|
if( !TrkParams::IsLoaded(1) ){ |
176 |
|
cout << "int TrkTrack::DoTrack(Trajectory* t) --- ERROR --- m.field not loaded"<<endl; |
177 |
|
return 0; |
178 |
|
} |
179 |
dotrack_(&(t->npoint),dzin,dxout,dyout,dal,&ifail); |
dotrack_(&(t->npoint),dzin,dxout,dyout,dal,&ifail); |
180 |
|
|
181 |
for (int i=0; i<t->npoint; i++){ |
for (int i=0; i<t->npoint; i++){ |
215 |
for (int i=0; i<5; i++) dal[i] = (double)al[i]; |
for (int i=0; i<5; i++) dal[i] = (double)al[i]; |
216 |
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]; |
217 |
|
|
218 |
|
TrkParams::Load(1); |
219 |
|
if( !TrkParams::IsLoaded(1) ){ |
220 |
|
cout << "int TrkTrack::DoTrack2(Trajectory* t) --- ERROR --- m.field not loaded"<<endl; |
221 |
|
return 0; |
222 |
|
} |
223 |
dotrack2_(&(t->npoint),dzin,dxout,dyout,dthxout,dthyout,dtlout,dal,&ifail); |
dotrack2_(&(t->npoint),dzin,dxout,dyout,dthxout,dthyout,dtlout,dal,&ifail); |
224 |
|
|
225 |
for (int i=0; i<t->npoint; i++){ |
for (int i=0; i<t->npoint; i++){ |
259 |
return def; |
return def; |
260 |
}; |
}; |
261 |
// |
// |
262 |
Float_t TrkTrack::GetDEDX(){ |
/** |
263 |
Float_t dedx=0; |
* Method to retrieve the dE/dx measured on a tracker view. |
264 |
for(Int_t i=0; i<6; i++)dedx+=dedx_x[i]*xgood[i]+dedx_y[i]*ygood[i]; |
* @param ip plane (0-5) |
265 |
dedx = dedx/(this->GetNX()+this->GetNY()); |
* @param iv view (0=x 1=y) |
266 |
return dedx; |
*/ |
267 |
|
Float_t TrkTrack::GetDEDX(int ip, int iv){ |
268 |
|
if(iv==0 && ip>=0 && ip<6)return fabs(dedx_x[ip]); |
269 |
|
else if(iv==1 && ip>=0 && ip<6)return fabs(dedx_y[ip]); |
270 |
|
else { |
271 |
|
cout << "TrkTrack::GetDEDX(int ip, int iv) -- wrong input parameters "<<ip<<iv<<endl; |
272 |
|
return 0.; |
273 |
|
} |
274 |
|
} |
275 |
|
/** |
276 |
|
* Method to evaluate the dE/dx measured on a tracker plane. |
277 |
|
* The two measurements on x- and y-view are averaged. |
278 |
|
* @param ip plane (0-5) |
279 |
|
*/ |
280 |
|
Float_t TrkTrack::GetDEDX(int ip){ |
281 |
|
if( (Int_t)XGood(ip)+(Int_t)YGood(ip) == 0 ) return 0; |
282 |
|
return (GetDEDX(ip,0)+GetDEDX(ip,1))/((Int_t)XGood(ip)+(Int_t)YGood(ip)); |
283 |
}; |
}; |
284 |
|
|
285 |
|
/** |
286 |
|
* Method to evaluate the dE/dx averaged over all planes. |
287 |
|
*/ |
288 |
|
Float_t TrkTrack::GetDEDX(){ |
289 |
|
Float_t dedx=0; |
290 |
|
for(Int_t ip=0; ip<6; ip++)dedx+=GetDEDX(ip,0)*XGood(ip)+GetDEDX(ip,1)*YGood(ip); |
291 |
|
dedx = dedx/(GetNX()+GetNY()); |
292 |
|
return dedx; |
293 |
|
}; |
294 |
|
/** |
295 |
|
* Returns 1 if the cluster on a tracker view includes bad strips. |
296 |
|
* @param ip plane (0-5) |
297 |
|
* @param iv view (0=x 1=y) |
298 |
|
*/ |
299 |
|
Bool_t TrkTrack::IsBad(int ip,int iv){ |
300 |
|
if(iv==0 && ip>=0 && ip<6)return (xgood[ip]<0) ; |
301 |
|
else if(iv==1 && ip>=0 && ip<6)return (ygood[ip]<0) ; |
302 |
|
else { |
303 |
|
cout << "TrkTrack::IsBad(int ip, int iv) -- wrong input parameters "<<ip<<iv<<endl; |
304 |
|
return 0.; |
305 |
|
} |
306 |
|
}; |
307 |
|
/** |
308 |
|
* Returns 1 if the signal on a tracker view is saturated. |
309 |
|
* @param ip plane (0-5) |
310 |
|
* @param iv view (0=x 1=y) |
311 |
|
*/ |
312 |
|
Bool_t TrkTrack::IsSaturated(int ip,int iv){ |
313 |
|
if(iv==0 && ip>=0 && ip<6)return (dedx_x[ip]<0) ; |
314 |
|
else if(iv==1 && ip>=0 && ip<6)return (dedx_y[ip]<0) ; |
315 |
|
else { |
316 |
|
cout << "TrkTrack::IsSaturated(int ip, int iv) -- wrong input parameters "<<ip<<iv<<endl; |
317 |
|
return 0.; |
318 |
|
} |
319 |
|
}; |
320 |
|
/** |
321 |
|
* Returns 1 if either the x or the y signal on a tracker plane is saturated. |
322 |
|
* @param ip plane (0-5) |
323 |
|
*/ |
324 |
|
Bool_t TrkTrack::IsSaturated(int ip){ |
325 |
|
return (IsSaturated(ip,0)||IsSaturated(ip,1)); |
326 |
|
}; |
327 |
|
/** |
328 |
|
* Returns 1 if there is at least a saturated signal along the track. |
329 |
|
*/ |
330 |
|
Bool_t TrkTrack::IsSaturated(){ |
331 |
|
for(int ip=0; ip<6; ip++)for(int iv=0; iv<2; iv++)if(IsSaturated(ip,iv))return true; |
332 |
|
return false; |
333 |
|
} |
334 |
|
/** |
335 |
|
* Returns the track "lever-arm" on the x view, defined as the distance (in planes) between |
336 |
|
* the upper and lower x measurements (the maximum value of lever-arm is 6). |
337 |
|
*/ |
338 |
|
Int_t TrkTrack::GetLeverArmX(){ |
339 |
|
int first_plane = -1; |
340 |
|
int last_plane = -1; |
341 |
|
for(Int_t ip=0; ip<6; ip++){ |
342 |
|
if( XGood(ip) && first_plane == -1 )first_plane = ip; |
343 |
|
if( XGood(ip) && first_plane != -1 )last_plane = ip; |
344 |
|
} |
345 |
|
if( first_plane == -1 || last_plane == -1){ |
346 |
|
cout<< "Int_t TrkTrack::GetLeverArmX() -- XGood(ip) always false ??? "<<endl; |
347 |
|
return 0; |
348 |
|
} |
349 |
|
return (last_plane-first_plane+1); |
350 |
|
} |
351 |
|
/** |
352 |
|
* Returns the track "lever-arm" on the y view, defined as the distance (in planes) between |
353 |
|
* the upper and lower y measurements (the maximum value of lever-arm is 6). |
354 |
|
*/ |
355 |
|
Int_t TrkTrack::GetLeverArmY(){ |
356 |
|
int first_plane = -1; |
357 |
|
int last_plane = -1; |
358 |
|
for(Int_t ip=0; ip<6; ip++){ |
359 |
|
if( YGood(ip) && first_plane == -1 )first_plane = ip; |
360 |
|
if( YGood(ip) && first_plane != -1 )last_plane = ip; |
361 |
|
} |
362 |
|
if( first_plane == -1 || last_plane == -1){ |
363 |
|
cout<< "Int_t TrkTrack::GetLeverArmY() -- YGood(ip) always false ??? "<<endl; |
364 |
|
return 0; |
365 |
|
} |
366 |
|
return (last_plane-first_plane+1); |
367 |
|
} |
368 |
//-------------------------------------- |
//-------------------------------------- |
369 |
// |
// |
370 |
// |
// |
371 |
//-------------------------------------- |
//-------------------------------------- |
372 |
void TrkTrack::Dump(){ |
void TrkTrack::Dump(){ |
373 |
cout << endl << "========== Track " ; |
cout << endl << "========== Track " ; |
374 |
|
cout << endl << "seq. n. : "<< seqno; |
375 |
|
cout << endl << "image n. : "<< image; |
376 |
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] << " "; |
377 |
cout << endl << "chi^2 : "<< chi2; |
cout << endl << "chi^2 : "<< chi2; |
378 |
cout << endl << "xgood : "; for(int i=0; i<6; i++)cout << xgood[i] ; |
cout << endl << "n.step : "<< nstep; |
379 |
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) ; |
380 |
|
cout << endl << "ygood : "; for(int i=0; i<6; i++)cout << YGood(i) ; |
381 |
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] << " "; |
382 |
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] << " "; |
383 |
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] << " "; |
384 |
|
cout << endl << "xv : "; for(int i=0; i<6; i++)cout << xv[i] << " "; |
385 |
|
cout << endl << "yv : "; for(int i=0; i<6; i++)cout << yv[i] << " "; |
386 |
|
cout << endl << "zv : "; for(int i=0; i<6; i++)cout << zv[i] << " "; |
387 |
|
cout << endl << "resx : "; for(int i=0; i<6; i++)cout << resx[i] << " "; |
388 |
|
cout << endl << "resy : "; for(int i=0; i<6; i++)cout << resy[i] << " "; |
389 |
|
cout << endl << "tailx : "; for(int i=0; i<6; i++)cout << tailx[i] << " "; |
390 |
|
cout << endl << "taily : "; for(int i=0; i<6; i++)cout << taily[i] << " "; |
391 |
|
cout << endl << "coval : "; for(int i=0; i<5; i++)cout << coval[0][i]<<" "; |
392 |
|
cout << endl << " "; for(int i=0; i<5; i++)cout << coval[1][i]<<" "; |
393 |
|
cout << endl << " "; for(int i=0; i<5; i++)cout << coval[2][i]<<" "; |
394 |
|
cout << endl << " "; for(int i=0; i<5; i++)cout << coval[3][i]<<" "; |
395 |
|
cout << endl << " "; for(int i=0; i<5; i++)cout << coval[4][i]<<" "; |
396 |
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] << " "; |
397 |
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] << " "; |
398 |
|
cout << endl; |
399 |
|
} |
400 |
|
/** |
401 |
|
* Set the TrkTrack position measurements |
402 |
|
*/ |
403 |
|
void TrkTrack::SetMeasure(double *xmeas, double *ymeas, double *zmeas){ |
404 |
|
for(int i=0; i<6; i++) xm[i]=*xmeas++; |
405 |
|
for(int i=0; i<6; i++) ym[i]=*ymeas++; |
406 |
|
for(int i=0; i<6; i++) zm[i]=*zmeas++; |
407 |
|
} |
408 |
|
/** |
409 |
|
* Set the TrkTrack position resolution |
410 |
|
*/ |
411 |
|
void TrkTrack::SetResolution(double *rx, double *ry){ |
412 |
|
for(int i=0; i<6; i++) resx[i]=*rx++; |
413 |
|
for(int i=0; i<6; i++) resy[i]=*ry++; |
414 |
|
} |
415 |
|
/** |
416 |
|
* Set the TrkTrack tails position resolution |
417 |
|
*/ |
418 |
|
void TrkTrack::SetTail(double *tx, double *ty, double factor){ |
419 |
|
for(int i=0; i<6; i++) tailx[i]=factor*(*tx++); |
420 |
|
for(int i=0; i<6; i++) taily[i]=factor*(*ty++); |
421 |
|
} |
422 |
|
/** |
423 |
|
* Set the TrkTrack Student parameter (resx,resy,tailx,taily) |
424 |
|
* from previous gausian fit |
425 |
|
*@param flag =0 standard, =1 with noise correction |
426 |
|
*/ |
427 |
|
void TrkTrack::SetStudentParam(int flag){ |
428 |
|
float sx[11]={0.000128242, |
429 |
|
0.000136942, |
430 |
|
0.000162718, |
431 |
|
0.000202644, |
432 |
|
0.00025597, |
433 |
|
0.000317456, |
434 |
|
0.000349048, |
435 |
|
0.000384638, |
436 |
|
0.000457295, |
437 |
|
0.000512319, |
438 |
|
0.000538573}; |
439 |
|
float tx[11]={1.79402, |
440 |
|
2.04876, |
441 |
|
2.88376, |
442 |
|
3.3, |
443 |
|
3.14084, |
444 |
|
4.07686, |
445 |
|
4.44736, |
446 |
|
3.5179, |
447 |
|
3.38697, |
448 |
|
3.45739, |
449 |
|
3.18627}; |
450 |
|
float sy[11]={0.000483075, |
451 |
|
0.000466925, |
452 |
|
0.000431658, |
453 |
|
0.000428317, |
454 |
|
0.000433854, |
455 |
|
0.000444044, |
456 |
|
0.000482098, |
457 |
|
0.000537579, |
458 |
|
0.000636279, |
459 |
|
0.000741998, |
460 |
|
0.000864261}; |
461 |
|
float ty[11]={0.997032, |
462 |
|
1.11147, |
463 |
|
1.18526, |
464 |
|
1.61404, |
465 |
|
2.21908, |
466 |
|
3.08959, |
467 |
|
4.48833, |
468 |
|
4.42687, |
469 |
|
4.65253, |
470 |
|
4.52043, |
471 |
|
4.29926}; |
472 |
|
int index; |
473 |
|
float fact; |
474 |
|
for(int i=0; i<6; i++) { |
475 |
|
index = int((fabs(axv[i])+1.)/2.); |
476 |
|
if(index>10) index=10; |
477 |
|
tailx[i]=tx[index]; |
478 |
|
if(flag==1) { |
479 |
|
if(fabs(axv[i])<=10.) fact = resx[i]/risxeta2_(&(axv[i])); |
480 |
|
if(fabs(axv[i])>10.&&fabs(axv[i])<=15.) fact = resx[i]/risxeta3_(&(axv[i])); |
481 |
|
if(fabs(axv[i])>15.) fact = resx[i]/risxeta4_(&(axv[i])); |
482 |
|
} else fact = 1.; |
483 |
|
resx[i] = sx[index]*fact; |
484 |
|
} |
485 |
|
for(int i=0; i<6; i++) { |
486 |
|
index = int((fabs(ayv[i])+1.)/2.); |
487 |
|
if(index>10) index=10; |
488 |
|
taily[i]=ty[index]; |
489 |
|
if(flag==1) fact = resy[i]/risyeta2_(&(ayv[i])); |
490 |
|
else fact = 1.; |
491 |
|
resy[i] = sy[index]*fact; |
492 |
|
} |
493 |
|
} |
494 |
|
/** |
495 |
|
* Set the TrkTrack good measurement |
496 |
|
*/ |
497 |
|
void TrkTrack::SetGood(int *xg, int *yg){ |
498 |
|
|
499 |
|
for(int i=0; i<6; i++) xgood[i]=*xg++; |
500 |
|
for(int i=0; i<6; i++) ygood[i]=*yg++; |
501 |
|
} |
502 |
|
|
503 |
|
/** |
504 |
|
* Load the magnetic field |
505 |
|
*/ |
506 |
|
void TrkTrack::LoadField(TString path){ |
507 |
|
|
508 |
|
// strcpy(path_.path,path.Data()); |
509 |
|
// path_.pathlen = path.Length(); |
510 |
|
// path_.error = 0; |
511 |
|
// readb_(); |
512 |
|
|
513 |
|
TrkParams::SetTrackingMode(); |
514 |
|
TrkParams::SetPrecisionFactor(); |
515 |
|
TrkParams::SetStepMin(); |
516 |
|
|
517 |
|
TrkParams::Set(path,1); |
518 |
|
TrkParams::Load(1); |
519 |
|
|
520 |
|
}; |
521 |
|
|
522 |
|
|
523 |
|
/** |
524 |
|
* Method to fill minimization-routine common |
525 |
|
*/ |
526 |
|
void TrkTrack::FillMiniStruct(cMini2track& track){ |
527 |
|
|
528 |
|
for(int i=0; i<6; i++){ |
529 |
|
|
530 |
|
// cout << i<<" - "<<xgood[i]<<" "<<XGood(i)<<endl; |
531 |
|
// cout << i<<" - "<<ygood[i]<<" "<<YGood(i)<<endl; |
532 |
|
track.xgood[i]=XGood(i); |
533 |
|
track.ygood[i]=YGood(i); |
534 |
|
|
535 |
|
track.xm[i]=xm[i]; |
536 |
|
track.ym[i]=ym[i]; |
537 |
|
track.zm[i]=zm[i]; |
538 |
|
|
539 |
|
// --- temporaneo ---------------------------- |
540 |
|
// andrebbe inserita la dimensione del sensore |
541 |
|
float segment = 100.; |
542 |
|
track.xm_a[i]=xm[i]; |
543 |
|
track.xm_b[i]=xm[i]; |
544 |
|
track.ym_a[i]=ym[i]; |
545 |
|
track.ym_b[i]=ym[i]; |
546 |
|
if( XGood(i) && !YGood(i) ){ |
547 |
|
track.ym_a[i] = track.ym_a[i]+segment; |
548 |
|
track.ym_b[i] = track.ym_b[i]-segment; |
549 |
|
}else if( !XGood(i) && YGood(i)){ |
550 |
|
track.xm_a[i] = track.xm_a[i]+segment; |
551 |
|
track.xm_b[i] = track.xm_b[i]-segment; |
552 |
|
} |
553 |
|
// --- temporaneo ---------------------------- |
554 |
|
|
555 |
|
track.resx[i]=resx[i]; |
556 |
|
track.resy[i]=resy[i]; |
557 |
|
track.tailx[i]=tailx[i]; |
558 |
|
track.taily[i]=taily[i]; |
559 |
|
} |
560 |
|
|
561 |
|
for(int i=0; i<5; i++) track.al[i]=al[i]; |
562 |
|
track.zini = 23.5; |
563 |
|
// ZINI = 23.5 !!! it should be the same parameter in all codes |
564 |
|
|
565 |
|
} |
566 |
|
/** |
567 |
|
* Method to set values from minimization-routine common |
568 |
|
*/ |
569 |
|
void TrkTrack::SetFromMiniStruct(cMini2track *track){ |
570 |
|
|
571 |
|
for(int i=0; i<5; i++) { |
572 |
|
al[i]=track->al[i]; |
573 |
|
for(int j=0; j<5; j++) coval[i][j]=track->cov[i][j]; |
574 |
|
} |
575 |
|
chi2 = track->chi2; |
576 |
|
nstep = track->nstep; |
577 |
|
for(int i=0; i<6; i++){ |
578 |
|
xv[i] = track->xv[i]; |
579 |
|
yv[i] = track->yv[i]; |
580 |
|
zv[i] = track->zv[i]; |
581 |
|
xm[i] = track->xm[i]; |
582 |
|
ym[i] = track->ym[i]; |
583 |
|
zm[i] = track->zm[i]; |
584 |
|
axv[i] = track->axv[i]; |
585 |
|
ayv[i] = track->ayv[i]; |
586 |
|
} |
587 |
|
|
588 |
|
} |
589 |
|
/** |
590 |
|
* \brief Method to re-evaluate coordinates of clusters associated with a track. |
591 |
|
* |
592 |
|
* The method can be applied only after recovering level1 information |
593 |
|
* (either by reprocessing single events from level0 or from |
594 |
|
* the TrkLevel1 branch, if present); it calls F77 subroutines that |
595 |
|
* read the level1 common and fill the minimization-routine common. |
596 |
|
* Some clusters can be excluded or added by means of the methods: |
597 |
|
* |
598 |
|
* TrkTrack::ResetXGood(int ip) |
599 |
|
* TrkTrack::ResetYGood(int ip) |
600 |
|
* TrkTrack::SetXGood(int ip, int cid, int is) |
601 |
|
* TrkTrack::SetYGood(int ip, int cid, int is) |
602 |
|
* |
603 |
|
* NB! The method TrkTrack::SetGood(int *xg, int *yg) set the plane-mask (0-1) |
604 |
|
* for the minimization-routine common. It deletes the cluster information |
605 |
|
* (at least for the moment...) thus cannot be applied before |
606 |
|
* TrkTrack::EvaluateClusterPositions(). |
607 |
|
* |
608 |
|
* Different p.f.a. can be applied by calling (once) the method: |
609 |
|
* |
610 |
|
* TrkParams::SetPFA(0); //Set ETA p.f.a. |
611 |
|
* |
612 |
|
* @see TrkParams::SetPFA(int) |
613 |
|
*/ |
614 |
|
Bool_t TrkTrack::EvaluateClusterPositions(){ |
615 |
|
|
616 |
|
// cout << "void TrkTrack::GetClusterPositions() "<<endl; |
617 |
|
|
618 |
|
TrkParams::Load( ); |
619 |
|
if( !TrkParams::IsLoaded() )return false; |
620 |
|
|
621 |
|
for(int ip=0; ip<6; ip++){ |
622 |
|
// cout << ip<<" ** "<<xm[ip]<<" / "<<ym[ip]<<endl;; |
623 |
|
int icx = GetClusterX_ID(ip)+1; |
624 |
|
int icy = GetClusterY_ID(ip)+1; |
625 |
|
int sensor = GetSensor(ip)+1;//<< convenzione "Paolo" |
626 |
|
if(ip==5 && sensor!=0)sensor=3-sensor;//<< convenzione "Elena" |
627 |
|
int ladder = GetLadder(ip)+1; |
628 |
|
float ax = axv[ip]; |
629 |
|
float ay = ayv[ip]; |
630 |
|
float v[3]; |
631 |
|
v[0]=xv[ip]; |
632 |
|
v[1]=yv[ip]; |
633 |
|
v[2]=zv[ip]; |
634 |
|
float bfx = 10*TrkParams::GetBX(v);//Tesla |
635 |
|
float bfy = 10*TrkParams::GetBY(v);//Tesla |
636 |
|
int ipp=ip+1; |
637 |
|
xyzpam_(&ipp,&icx,&icy,&ladder,&sensor,&ax,&ay,&bfx,&bfy); |
638 |
|
if(icx<0 || icy<0)return false; |
639 |
|
} |
640 |
|
return true; |
641 |
|
} |
642 |
|
/** |
643 |
|
* \brief Tracking method. It calls F77 mini routine. |
644 |
|
* |
645 |
|
* @param pfixed Particle momentum. If pfixed=0 the momentum |
646 |
|
* is left as a free parameter, otherwise it is fixed to the input value. |
647 |
|
* @param fail Output flag (!=0 if the fit failed). |
648 |
|
* @param iprint Flag to set debug mode ( 0 = no output; 1 = verbose; 2 = debug). |
649 |
|
* @param froml1 Flag to re-evaluate positions (see TrkTrack::GetClusterPositions()). |
650 |
|
* |
651 |
|
* The option to re-evaluate positions can be used only after recovering |
652 |
|
* level1 information, eg. by reprocessing the single event. |
653 |
|
* |
654 |
|
* Example: |
655 |
|
* |
656 |
|
* if( !event->GetTrkLevel0() )return false; |
657 |
|
* event->GetTrkLevel0()->ProcessEvent(); // re-processing level0->level1 |
658 |
|
* int fail=0; |
659 |
|
* event->GetTrkLevel2()->GetTrack(0)->Fit(0.,fail,0,1); |
660 |
|
* |
661 |
|
* @see EvaluateClusterPositions() |
662 |
|
* |
663 |
|
* The fitting procedure can be varied by changing the tracking mode, |
664 |
|
* the fit-precision factor and the minimum number of step. |
665 |
|
* @see SetTrackingMode(int) |
666 |
|
* @see SetPrecisionFactor(double) |
667 |
|
* @see SetStepMin(int) |
668 |
|
*/ |
669 |
|
void TrkTrack::Fit(double pfixed, int& fail, int iprint, int froml1){ |
670 |
|
|
671 |
|
float al_ini[] = {0.,0.,0.,0.,0.}; |
672 |
|
|
673 |
|
TrkParams::Load( ); |
674 |
|
if( !TrkParams::IsLoaded() )return; |
675 |
|
|
676 |
|
extern cMini2track track_; |
677 |
|
fail = 0; |
678 |
|
|
679 |
|
FillMiniStruct(track_); |
680 |
|
|
681 |
|
if(froml1!=0){ |
682 |
|
if( !EvaluateClusterPositions() ){ |
683 |
|
cout << "void TrkTrack::Fit("<<pfixed<<","<<fail<<","<<iprint<<","<<froml1<<") --- ERROR evaluating cluster positions "<<endl; |
684 |
|
FillMiniStruct(track_) ; |
685 |
|
fail = 1; |
686 |
|
return; |
687 |
|
} |
688 |
|
}else{ |
689 |
|
FillMiniStruct(track_); |
690 |
|
} |
691 |
|
|
692 |
|
// if fit variables have been reset, evaluate the initial guess |
693 |
|
if(al[0]==-9999.&&al[1]==-9999.&&al[2]==-9999.&&al[3]==-9999.&&al[4]==-9999.)guess_(); |
694 |
|
|
695 |
|
// --------------------- free momentum |
696 |
|
if(pfixed==0.) { |
697 |
|
track_.pfixed=0.; |
698 |
|
} |
699 |
|
// --------------------- fixed momentum |
700 |
|
if(pfixed!=0.) { |
701 |
|
al[4]=1./pfixed; |
702 |
|
track_.pfixed=pfixed; |
703 |
|
} |
704 |
|
|
705 |
|
// store temporarily the initial guess |
706 |
|
for(int i=0; i<5; i++) al_ini[i]=track_.al[i]; |
707 |
|
|
708 |
|
// ------------------------------------------ |
709 |
|
// call mini routine |
710 |
|
// TrkParams::Load(1); |
711 |
|
// if( !TrkParams::IsLoaded(1) ){ |
712 |
|
// cout << "void TrkTrack::Fit(double pfixed, int& fail, int iprint) --- ERROR --- m.field not loaded"<<endl; |
713 |
|
// return; |
714 |
|
// } |
715 |
|
int istep=0; |
716 |
|
int ifail=0; |
717 |
|
mini2_(&istep,&ifail, &iprint); |
718 |
|
if(ifail!=0) { |
719 |
|
if(iprint)cout << "ERROR: ifail= " << ifail << endl; |
720 |
|
fail = 1; |
721 |
|
} |
722 |
|
// ------------------------------------------ |
723 |
|
|
724 |
|
SetFromMiniStruct(&track_); |
725 |
|
|
726 |
|
if(fail){ |
727 |
|
if(iprint)cout << " >>>> fit failed "<<endl; |
728 |
|
for(int i=0; i<5; i++) al[i]=al_ini[i]; |
729 |
|
} |
730 |
|
|
731 |
|
}; |
732 |
|
/** |
733 |
|
* Reset the fit parameters |
734 |
|
*/ |
735 |
|
void TrkTrack::FitReset(){ |
736 |
|
for(int i=0; i<5; i++) al[i]=-9999.; |
737 |
|
chi2=0.; |
738 |
|
nstep=0; |
739 |
|
// for(int i=0; i<6; i++) xv[i]=0.; |
740 |
|
// for(int i=0; i<6; i++) yv[i]=0.; |
741 |
|
// for(int i=0; i<6; i++) zv[i]=0.; |
742 |
|
// for(int i=0; i<6; i++) axv[i]=0.; |
743 |
|
// for(int i=0; i<6; i++) ayv[i]=0.; |
744 |
|
for(int i=0; i<5; i++) { |
745 |
|
for(int j=0; j<5; j++) coval[i][j]=0.; |
746 |
|
} |
747 |
|
} |
748 |
|
/** |
749 |
|
* Set the tracking mode |
750 |
|
*/ |
751 |
|
void TrkTrack::SetTrackingMode(int trackmode){ |
752 |
|
extern cMini2track track_; |
753 |
|
track_.trackmode = trackmode; |
754 |
|
} |
755 |
|
/** |
756 |
|
* Set the factor scale for tracking precision |
757 |
|
*/ |
758 |
|
void TrkTrack::SetPrecisionFactor(double fact){ |
759 |
|
extern cMini2track track_; |
760 |
|
track_.fact = fact; |
761 |
} |
} |
762 |
|
/** |
763 |
|
* Set the minimum number of steps for tracking precision |
764 |
|
*/ |
765 |
|
void TrkTrack::SetStepMin(int istepmin){ |
766 |
|
extern cMini2track track_; |
767 |
|
track_.istepmin = istepmin; |
768 |
|
} |
769 |
|
/** |
770 |
|
* Returns 1 if the track is inside the magnet cavity |
771 |
|
* Set the minimum number of steps for tracking precision |
772 |
|
*/ |
773 |
|
Bool_t TrkTrack::IsInsideCavity(){ |
774 |
|
float xmagntop, ymagntop, xmagnbottom, ymagnbottom; |
775 |
|
xmagntop = xv[0] + (ZMAGNHIGH-zv[0])*tan(cos(-1.0)*axv[0]/180.); |
776 |
|
ymagntop = yv[0] + (ZMAGNHIGH-zv[0])*tan(cos(-1.0)*ayv[0]/180.); |
777 |
|
xmagnbottom = xv[5] + (ZMAGNLOW-zv[5])*tan(cos(-1.0)*axv[5]/180.); |
778 |
|
ymagnbottom = yv[5] + (ZMAGNLOW-zv[5])*tan(cos(-1.0)*ayv[5]/180.); |
779 |
|
if( xmagntop>XMAGNLOW && xmagntop<XMAGNHIGH && |
780 |
|
ymagntop>YMAGNLOW && ymagntop<YMAGNHIGH && |
781 |
|
xmagnbottom>XMAGNLOW && xmagnbottom<XMAGNHIGH && |
782 |
|
ymagnbottom>YMAGNLOW && ymagnbottom<YMAGNHIGH ) return(true); |
783 |
|
else return(false); |
784 |
|
} |
785 |
|
/** |
786 |
|
* Method to retrieve ID (0,1,...) of x-cluster (if any) associated to this track. |
787 |
|
* If no cluster is associated, ID=-1. |
788 |
|
* @param ip Tracker plane (0-5) |
789 |
|
*/ |
790 |
|
Int_t TrkTrack::GetClusterX_ID(int ip){ |
791 |
|
return ((Int_t)fabs(xgood[ip]))%10000000-1; |
792 |
|
}; |
793 |
|
/** |
794 |
|
* Method to retrieve ID (0-xxx) of y-cluster (if any) associated to this track. |
795 |
|
* If no cluster is associated, ID=-1. |
796 |
|
* @param ip Tracker plane (0-5) |
797 |
|
*/ |
798 |
|
Int_t TrkTrack::GetClusterY_ID(int ip){ |
799 |
|
return ((Int_t)fabs(ygood[ip]))%10000000-1; |
800 |
|
}; |
801 |
|
/** |
802 |
|
* Method to retrieve the ladder (0-4, increasing x) traversed by the track on this plane. |
803 |
|
* If no ladder is traversed (dead area) the metod retuns -1. |
804 |
|
* @param ip Tracker plane (0-5) |
805 |
|
*/ |
806 |
|
Int_t TrkTrack::GetLadder(int ip){ |
807 |
|
if(XGood(ip))return (Int_t)fabs(xgood[ip]/100000000)-1; |
808 |
|
if(YGood(ip))return (Int_t)fabs(ygood[ip]/100000000)-1; |
809 |
|
return -1; |
810 |
|
}; |
811 |
|
/** |
812 |
|
* Method to retrieve the sensor (0-1, increasing y) traversed by the track on this plane. |
813 |
|
* If no sensor is traversed (dead area) the metod retuns -1. |
814 |
|
* @param ip Tracker plane (0-5) |
815 |
|
*/ |
816 |
|
Int_t TrkTrack::GetSensor(int ip){ |
817 |
|
if(XGood(ip))return (Int_t)((Int_t)fabs(xgood[ip]/10000000)%10)-1; |
818 |
|
if(YGood(ip))return (Int_t)((Int_t)fabs(ygood[ip]/10000000)%10)-1; |
819 |
|
return -1; |
820 |
|
}; |
821 |
|
|
822 |
|
/** |
823 |
|
* \brief Method to include a x-cluster to the track. |
824 |
|
* @param ip Tracker plane (0-5) |
825 |
|
* @param clid Cluster ID (0,1,...) |
826 |
|
* @param is Sensor (0-1, increasing y) |
827 |
|
* @see Fit(double pfixed, int& fail, int iprint, int froml1) |
828 |
|
*/ |
829 |
|
void TrkTrack::SetXGood(int ip, int clid, int is){ |
830 |
|
int il=0; //ladder (temporary) |
831 |
|
bool bad=false; //ladder (temporary) |
832 |
|
xgood[ip]=il*100000000+is*10000000+clid; |
833 |
|
if(bad)xgood[ip]=-xgood[ip]; |
834 |
|
}; |
835 |
|
/** |
836 |
|
* \brief Method to include a y-cluster to the track. |
837 |
|
* @param ip Tracker plane (0-5) |
838 |
|
* @param clid Cluster ID (0,1,...) |
839 |
|
* @param is Sensor (0-1) |
840 |
|
* @see Fit(double pfixed, int& fail, int iprint, int froml1) |
841 |
|
*/ |
842 |
|
void TrkTrack::SetYGood(int ip, int clid, int is){ |
843 |
|
int il=0; //ladder (temporary) |
844 |
|
bool bad=false; //ladder (temporary) |
845 |
|
ygood[ip]=il*100000000+is*10000000+clid; |
846 |
|
if(bad)ygood[ip]=-ygood[ip]; |
847 |
|
}; |
848 |
|
|
849 |
|
//-------------------------------------- |
850 |
|
// |
851 |
|
// |
852 |
|
//-------------------------------------- |
853 |
|
void TrkTrack::Clear(){ |
854 |
|
// cout << "TrkTrack::Clear()"<<endl; |
855 |
|
seqno = -1; |
856 |
|
image = -1; |
857 |
|
chi2 = 0; |
858 |
|
nstep = 0; |
859 |
|
for(int it1=0;it1<5;it1++){ |
860 |
|
al[it1] = 0; |
861 |
|
for(int it2=0;it2<5;it2++)coval[it1][it2] = 0; |
862 |
|
}; |
863 |
|
for(int ip=0;ip<6;ip++){ |
864 |
|
xgood[ip] = 0; |
865 |
|
ygood[ip] = 0; |
866 |
|
xm[ip] = 0; |
867 |
|
ym[ip] = 0; |
868 |
|
zm[ip] = 0; |
869 |
|
resx[ip] = 0; |
870 |
|
resy[ip] = 0; |
871 |
|
tailx[ip] = 0; |
872 |
|
taily[ip] = 0; |
873 |
|
xv[ip] = 0; |
874 |
|
yv[ip] = 0; |
875 |
|
zv[ip] = 0; |
876 |
|
axv[ip] = 0; |
877 |
|
ayv[ip] = 0; |
878 |
|
dedx_x[ip] = 0; |
879 |
|
dedx_y[ip] = 0; |
880 |
|
|
881 |
|
}; |
882 |
|
// if(clx)clx->Clear(); |
883 |
|
// if(cly)cly->Clear(); |
884 |
|
// clx.Clear(); |
885 |
|
// cly.Clear(); |
886 |
|
}; |
887 |
|
//-------------------------------------- |
888 |
|
// |
889 |
|
// |
890 |
|
//-------------------------------------- |
891 |
|
void TrkTrack::Delete(){ |
892 |
|
// cout << "TrkTrack::Delete()"<<endl; |
893 |
|
Clear(); |
894 |
|
// if(clx)delete clx; |
895 |
|
// if(cly)delete cly; |
896 |
|
}; |
897 |
|
//-------------------------------------- |
898 |
|
// |
899 |
|
// |
900 |
|
//-------------------------------------- |
901 |
|
|
902 |
//-------------------------------------- |
//-------------------------------------- |
903 |
// |
// |
904 |
// |
// |
905 |
//-------------------------------------- |
//-------------------------------------- |
906 |
TrkSinglet::TrkSinglet(){ |
TrkSinglet::TrkSinglet(){ |
907 |
|
// cout << "TrkSinglet::TrkSinglet() " << GetUniqueID()<<endl; |
908 |
plane = 0; |
plane = 0; |
909 |
coord[0] = 0; |
coord[0] = 0; |
910 |
coord[1] = 0; |
coord[1] = 0; |
911 |
sgnl = 0; |
sgnl = 0; |
912 |
cls = 0; |
// cls = 0; |
913 |
}; |
}; |
914 |
//-------------------------------------- |
//-------------------------------------- |
915 |
// |
// |
916 |
// |
// |
917 |
//-------------------------------------- |
//-------------------------------------- |
918 |
TrkSinglet::TrkSinglet(const TrkSinglet& s){ |
TrkSinglet::TrkSinglet(const TrkSinglet& s){ |
919 |
|
// cout << "TrkSinglet::TrkSinglet(const TrkSinglet& s) " << GetUniqueID()<<endl; |
920 |
plane = s.plane; |
plane = s.plane; |
921 |
coord[0] = s.coord[0]; |
coord[0] = s.coord[0]; |
922 |
coord[1] = s.coord[1]; |
coord[1] = s.coord[1]; |
923 |
sgnl = s.sgnl; |
sgnl = s.sgnl; |
924 |
// cls = 0;//<<<<pointer |
// cls = 0;//<<<<pointer |
925 |
cls = TRef(s.cls); |
// cls = TRef(s.cls); |
926 |
}; |
}; |
927 |
//-------------------------------------- |
//-------------------------------------- |
928 |
// |
// |
939 |
// |
// |
940 |
// |
// |
941 |
//-------------------------------------- |
//-------------------------------------- |
942 |
|
void TrkSinglet::Clear(){ |
943 |
|
// cout << "TrkSinglet::Clear() " << GetUniqueID()<<endl; |
944 |
|
// cls=0; |
945 |
|
plane=-1; |
946 |
|
coord[0]=-999; |
947 |
|
coord[1]=-999; |
948 |
|
sgnl=0; |
949 |
|
|
950 |
|
} |
951 |
|
//-------------------------------------- |
952 |
|
// |
953 |
|
// |
954 |
|
//-------------------------------------- |
955 |
TrkLevel2::TrkLevel2(){ |
TrkLevel2::TrkLevel2(){ |
956 |
good2 = -1; |
// cout <<"TrkLevel2::TrkLevel2()"<<endl; |
957 |
for(Int_t i=0; i<12 ; i++){ |
for(Int_t i=0; i<12 ; i++){ |
958 |
crc[i] = -1; |
good[i] = -1; |
959 |
|
VKmask[i] = 0; |
960 |
|
VKflag[i] = 0; |
961 |
}; |
}; |
962 |
Track = new TClonesArray("TrkTrack"); |
Track = 0; |
963 |
SingletX = new TClonesArray("TrkSinglet"); |
SingletX = 0; |
964 |
SingletY = new TClonesArray("TrkSinglet"); |
SingletY = 0; |
965 |
|
|
966 |
// PhysicalTrack = new TClonesArray("TrkTrack"); |
} |
967 |
//sostituire con TRefArray... appena ho capito come si usa |
//-------------------------------------- |
968 |
|
// |
969 |
|
// |
970 |
|
//-------------------------------------- |
971 |
|
void TrkLevel2::Set(){ |
972 |
|
if(!Track)Track = new TClonesArray("TrkTrack"); |
973 |
|
if(!SingletX)SingletX = new TClonesArray("TrkSinglet"); |
974 |
|
if(!SingletY)SingletY = new TClonesArray("TrkSinglet"); |
975 |
} |
} |
976 |
//-------------------------------------- |
//-------------------------------------- |
977 |
// |
// |
978 |
// |
// |
979 |
//-------------------------------------- |
//-------------------------------------- |
980 |
void TrkLevel2::Dump(){ |
void TrkLevel2::Dump(){ |
981 |
TClonesArray &t = *Track; |
|
982 |
TClonesArray &sx = *SingletX; |
// |
|
TClonesArray &sy = *SingletY; |
|
|
|
|
983 |
cout << endl << endl << "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"; |
cout << endl << endl << "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"; |
984 |
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]; |
|
985 |
cout << endl << "ntrk() : " << this->ntrk() ; |
cout << endl << "ntrk() : " << this->ntrk() ; |
986 |
cout << endl << "nclsx() : " << this->nclsx(); |
cout << endl << "nclsx() : " << this->nclsx(); |
987 |
cout << endl << "nclsy() : " << this->nclsy(); |
cout << endl << "nclsy() : " << this->nclsy(); |
988 |
for(int i=0; i<this->ntrk(); i++) ((TrkTrack *)t[i])->Dump(); |
if(Track){ |
989 |
for(int i=0; i<this->nclsx(); i++) ((TrkSinglet *)sx[i])->Dump(); |
TClonesArray &t = *Track; |
990 |
for(int i=0; i<this->nclsy(); i++) ((TrkSinglet *)sy[i])->Dump(); |
for(int i=0; i<ntrk(); i++) ((TrkTrack *)t[i])->Dump(); |
991 |
|
} |
992 |
|
if(SingletX){ |
993 |
|
TClonesArray &sx = *SingletX; |
994 |
|
for(int i=0; i<nclsx(); i++) ((TrkSinglet *)sx[i])->Dump(); |
995 |
|
} |
996 |
|
if(SingletY){ |
997 |
|
TClonesArray &sy = *SingletY; |
998 |
|
for(int i=0; i<nclsy(); i++) ((TrkSinglet *)sy[i])->Dump(); |
999 |
|
} |
1000 |
|
} |
1001 |
|
/** |
1002 |
|
* \brief Dump processing status |
1003 |
|
*/ |
1004 |
|
void TrkLevel2::StatusDump(int view){ |
1005 |
|
cout << "DSP n. "<<view+1<<" status: "<<hex<<good[view]<<endl; |
1006 |
|
}; |
1007 |
|
/** |
1008 |
|
* \brief Check event status |
1009 |
|
* |
1010 |
|
* Check the event status, according to a flag-mask given as input. |
1011 |
|
* Return true if the view passes the check. |
1012 |
|
* |
1013 |
|
* @param view View number (0-11) |
1014 |
|
* @param flagmask Mask of flags to check (eg. flagmask=0x111 no missing packet, |
1015 |
|
* no crc error, no software alarm) |
1016 |
|
* |
1017 |
|
* @see TrkLevel2 class definition to know how the status flag is defined |
1018 |
|
* |
1019 |
|
*/ |
1020 |
|
Bool_t TrkLevel2::StatusCheck(int view, int flagmask){ |
1021 |
|
|
1022 |
|
if( view<0 || view >= 12)return false; |
1023 |
|
return !(good[view]&flagmask); |
1024 |
|
|
1025 |
|
}; |
1026 |
|
|
1027 |
|
|
1028 |
|
//-------------------------------------- |
1029 |
|
// |
1030 |
|
// |
1031 |
|
//-------------------------------------- |
1032 |
|
/** |
1033 |
|
* The method returns false if the viking-chip was masked |
1034 |
|
* either apriori ,on the basis of the mask read from the DB, |
1035 |
|
* or run-by-run, on the basis of the calibration parameters) |
1036 |
|
* @param iv Tracker view (0-11) |
1037 |
|
* @param ivk Viking-chip number (0-23) |
1038 |
|
*/ |
1039 |
|
Bool_t TrkLevel2::GetVKMask(int iv, int ivk){ |
1040 |
|
Int_t whichbit = (Int_t)pow(2,ivk); |
1041 |
|
return (whichbit&VKmask[iv])!=0; |
1042 |
|
} |
1043 |
|
/** |
1044 |
|
* The method returns false if the viking-chip was masked |
1045 |
|
* for this event due to common-noise computation failure. |
1046 |
|
* @param iv Tracker view (0-11) |
1047 |
|
* @param ivk Viking-chip number (0-23) |
1048 |
|
*/ |
1049 |
|
Bool_t TrkLevel2::GetVKFlag(int iv, int ivk){ |
1050 |
|
Int_t whichbit = (Int_t)pow(2,ivk); |
1051 |
|
return (whichbit&VKflag[iv])!=0; |
1052 |
} |
} |
1053 |
|
/** |
1054 |
|
* The method returns true if the viking-chip was masked, either |
1055 |
|
* forced (see TrkLevel2::GetVKMask(int,int)) or |
1056 |
|
* for this event only (TrkLevel2::GetVKFlag(int,int)). |
1057 |
|
* @param iv Tracker view (0-11) |
1058 |
|
* @param ivk Viking-chip number (0-23) |
1059 |
|
*/ |
1060 |
|
Bool_t TrkLevel2::IsMaskedVK(int iv, int ivk){ |
1061 |
|
return !(GetVKMask(iv,ivk)&&GetVKFlag(iv,ivk) ); |
1062 |
|
}; |
1063 |
|
|
1064 |
//-------------------------------------- |
//-------------------------------------- |
1065 |
// |
// |
1066 |
// |
// |
1067 |
//-------------------------------------- |
//-------------------------------------- |
1068 |
/** |
/** |
1069 |
* 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). |
1070 |
|
* Ref to Level1 data (clusters) is also set. If l1==NULL no references are set. |
1071 |
|
* (NB It make sense to set references only if events are stored in a tree that contains also the Level1 branch) |
1072 |
*/ |
*/ |
1073 |
void TrkLevel2::SetFromLevel2Struct(cTrkLevel2 *l2){ |
void TrkLevel2::SetFromLevel2Struct(cTrkLevel2 *l2, TrkLevel1 *l1){ |
1074 |
// |
|
1075 |
// Track = new TClonesArray("TrkTrack"); |
// cout << "void TrkLevel2::SetFromLevel2Struct(cTrkLevel2 *l2, TrkLevel1 *l1)"<<endl; |
1076 |
// SingletX = new TClonesArray("TrkSinglet"); |
Clear(); |
1077 |
// SingletY = new TClonesArray("TrkSinglet"); |
|
1078 |
// temporary objects: |
// temporary objects: |
1079 |
TrkSinglet* t_singlet = new TrkSinglet(); |
TrkSinglet* t_singlet = new TrkSinglet(); |
1080 |
TrkTrack* t_track = new TrkTrack(); |
TrkTrack* t_track = new TrkTrack(); |
1081 |
|
|
1082 |
|
// ----------------- |
1083 |
// general variables |
// general variables |
1084 |
good2 = l2->good2; |
// ----------------- |
1085 |
for(Int_t i=0; i<12 ; i++){ |
for(Int_t i=0; i<12 ; i++){ |
1086 |
crc[i] = l2->crc[i]; |
good[i] = l2->good[i]; |
1087 |
|
VKmask[i]=0; |
1088 |
|
VKflag[i]=0; |
1089 |
|
for(Int_t ii=0; ii<24 ; ii++){ |
1090 |
|
Int_t setbit = (Int_t)pow(2,ii); |
1091 |
|
if( l2->vkflag[ii][i]!=-1 )VKmask[i]=VKmask[i]|setbit; |
1092 |
|
if( l2->vkflag[ii][i]!=0 )VKflag[i]=VKflag[i]|setbit; |
1093 |
|
}; |
1094 |
}; |
}; |
1095 |
|
// -------------- |
1096 |
// *** TRACKS *** |
// *** TRACKS *** |
1097 |
|
// -------------- |
1098 |
|
if(!Track) Track = new TClonesArray("TrkTrack"); |
1099 |
TClonesArray &t = *Track; |
TClonesArray &t = *Track; |
1100 |
|
|
1101 |
for(int i=0; i<l2->ntrk; i++){ |
for(int i=0; i<l2->ntrk; i++){ |
1102 |
t_track->seqno = i;// NBNBNBNB deve sempre essere = i |
t_track->seqno = i;// NBNBNBNB deve sempre essere = i |
1103 |
t_track->image = l2->image[i]-1; |
t_track->image = l2->image[i]-1; |
1104 |
// cout << "track "<<i<<t_track->seqno << t_track->image<<endl; |
t_track->chi2 = l2->chi2_nt[i]; |
1105 |
t_track->chi2 = l2->chi2_nt[i]; |
t_track->nstep = l2->nstep_nt[i]; |
1106 |
for(int it1=0;it1<5;it1++){ |
for(int it1=0;it1<5;it1++){ |
1107 |
t_track->al[it1] = l2->al_nt[i][it1]; |
t_track->al[it1] = l2->al_nt[i][it1]; |
1108 |
for(int it2=0;it2<5;it2++) |
for(int it2=0;it2<5;it2++) |
1109 |
t_track->coval[it1][it2] = l2->coval[i][it2][it1]; |
t_track->coval[it1][it2] = l2->coval[i][it2][it1]; |
1110 |
}; |
}; |
1111 |
for(int ip=0;ip<6;ip++){ |
for(int ip=0;ip<6;ip++){ |
1112 |
t_track->xgood[ip] = l2->xgood_nt[i][ip]; |
// --------------------------------- |
1113 |
t_track->ygood[ip] = l2->ygood_nt[i][ip]; |
// new implementation of xgood/ygood |
1114 |
t_track->xm[ip] = l2->xm_nt[i][ip]; |
// --------------------------------- |
1115 |
t_track->ym[ip] = l2->ym_nt[i][ip]; |
t_track->xgood[ip] = l2->cltrx[i][ip]; //cluster ID |
1116 |
t_track->zm[ip] = l2->zm_nt[i][ip]; |
t_track->ygood[ip] = l2->cltry[i][ip]; //cluster ID |
1117 |
t_track->resx[ip] = l2->resx_nt[i][ip]; |
t_track->xgood[ip] += 10000000*l2->ls[i][ip]; // ladder+sensor |
1118 |
t_track->resy[ip] = l2->resy_nt[i][ip]; |
t_track->ygood[ip] += 10000000*l2->ls[i][ip]; // ladder+sensor |
1119 |
t_track->xv[ip] = l2->xv_nt[i][ip]; |
if(l2->xbad[i][ip]>0)t_track->xgood[ip]=-t_track->xgood[ip]; |
1120 |
t_track->yv[ip] = l2->yv_nt[i][ip]; |
if(l2->ybad[i][ip]>0)t_track->ygood[ip]=-t_track->ygood[ip]; |
1121 |
t_track->zv[ip] = l2->zv_nt[i][ip]; |
// if(l2->xbad[i][ip]>0 || l2->ybad[i][ip]>0){ |
1122 |
t_track->axv[ip] = l2->axv_nt[i][ip]; |
// if(l2->dedx_x[i][ip]<0 || l2->dedx_y[i][ip]<0){ |
1123 |
t_track->ayv[ip] = l2->ayv_nt[i][ip]; |
// cout << ip << " - "<< l2->cltrx[i][ip] << " "<<l2->cltry[i][ip]<<" "<<l2->ls[i][ip]<<endl; |
1124 |
t_track->dedx_x[ip] = l2->dedx_x[i][ip]; |
// cout << ip << " - "<<t_track->xgood[ip]<<" "<<t_track->ygood[ip]<<endl; |
1125 |
t_track->dedx_y[ip] = l2->dedx_y[i][ip]; |
// cout << ip << " - "<<t_track->GetClusterX_ID(ip)<<" "<<t_track->GetClusterY_ID(ip)<<" "<<t_track->GetLadder(ip)<<" "<<t_track->GetSensor(ip)<<endl; |
1126 |
// t_track->clx[ip] = 0; |
// cout << ip << " - "<<t_track->BadClusterX(ip)<<" "<<t_track->BadClusterY(ip)<<endl; |
1127 |
// t_track->cly[ip] = 0; |
// cout << ip << " - "<<t_track->SaturatedClusterX(ip)<<" "<<t_track->SaturatedClusterY(ip)<<endl; |
1128 |
}; |
// } |
1129 |
new(t[i]) TrkTrack(*t_track); |
t_track->xm[ip] = l2->xm_nt[i][ip]; |
1130 |
t_track->Clear(); |
t_track->ym[ip] = l2->ym_nt[i][ip]; |
1131 |
|
t_track->zm[ip] = l2->zm_nt[i][ip]; |
1132 |
|
t_track->resx[ip] = l2->resx_nt[i][ip]; |
1133 |
|
t_track->resy[ip] = l2->resy_nt[i][ip]; |
1134 |
|
t_track->tailx[ip] = l2->tailx[i][ip]; |
1135 |
|
t_track->taily[ip] = l2->taily[i][ip]; |
1136 |
|
t_track->xv[ip] = l2->xv_nt[i][ip]; |
1137 |
|
t_track->yv[ip] = l2->yv_nt[i][ip]; |
1138 |
|
t_track->zv[ip] = l2->zv_nt[i][ip]; |
1139 |
|
t_track->axv[ip] = l2->axv_nt[i][ip]; |
1140 |
|
t_track->ayv[ip] = l2->ayv_nt[i][ip]; |
1141 |
|
t_track->dedx_x[ip] = l2->dedx_x[i][ip]; |
1142 |
|
t_track->dedx_y[ip] = l2->dedx_y[i][ip]; |
1143 |
|
//----------------------------------------------------- |
1144 |
|
//----------------------------------------------------- |
1145 |
|
//----------------------------------------------------- |
1146 |
|
//----------------------------------------------------- |
1147 |
|
}; |
1148 |
|
// if(t_track->IsSaturated())t_track->Dump(); |
1149 |
|
new(t[i]) TrkTrack(*t_track); |
1150 |
|
t_track->Clear(); |
1151 |
}; |
}; |
1152 |
|
|
1153 |
|
// ---------------- |
1154 |
// *** SINGLETS *** |
// *** SINGLETS *** |
1155 |
|
// ---------------- |
1156 |
|
if(!SingletX)SingletX = new TClonesArray("TrkSinglet"); |
1157 |
TClonesArray &sx = *SingletX; |
TClonesArray &sx = *SingletX; |
1158 |
for(int i=0; i<l2->nclsx; i++){ |
for(int i=0; i<l2->nclsx; i++){ |
1159 |
t_singlet->plane = l2->planex[i]; |
t_singlet->plane = l2->planex[i]; |
1160 |
t_singlet->coord[0] = l2->xs[i][0]; |
t_singlet->coord[0] = l2->xs[i][0]; |
1161 |
t_singlet->coord[1] = l2->xs[i][1]; |
t_singlet->coord[1] = l2->xs[i][1]; |
1162 |
t_singlet->sgnl = l2->signlxs[i]; |
t_singlet->sgnl = l2->signlxs[i]; |
1163 |
// t_singlet->cls = 0; |
//----------------------------------------------------- |
1164 |
new(sx[i]) TrkSinglet(*t_singlet); |
// if(l1) t_singlet->cls = l1->GetCluster(l2->clsx[i]-1); |
1165 |
t_singlet->Clear(); |
//----------------------------------------------------- |
1166 |
|
new(sx[i]) TrkSinglet(*t_singlet); |
1167 |
|
t_singlet->Clear(); |
1168 |
} |
} |
1169 |
|
if(!SingletY)SingletY = new TClonesArray("TrkSinglet"); |
1170 |
TClonesArray &sy = *SingletY; |
TClonesArray &sy = *SingletY; |
1171 |
for(int i=0; i<l2->nclsy; i++){ |
for(int i=0; i<l2->nclsy; i++){ |
1172 |
t_singlet->plane = l2->planey[i]; |
t_singlet->plane = l2->planey[i]; |
1173 |
t_singlet->coord[0] = l2->ys[i][0]; |
t_singlet->coord[0] = l2->ys[i][0]; |
1174 |
t_singlet->coord[1] = l2->ys[i][1]; |
t_singlet->coord[1] = l2->ys[i][1]; |
1175 |
t_singlet->sgnl = l2->signlys[i]; |
t_singlet->sgnl = l2->signlys[i]; |
1176 |
// t_singlet->cls = 0; |
//----------------------------------------------------- |
1177 |
new(sy[i]) TrkSinglet(*t_singlet); |
// if(l1) t_singlet->cls = l1->GetCluster(l2->clsy[i]-1); |
1178 |
t_singlet->Clear(); |
//----------------------------------------------------- |
1179 |
}; |
new(sy[i]) TrkSinglet(*t_singlet); |
1180 |
|
t_singlet->Clear(); |
1181 |
delete t_track; |
}; |
|
delete t_singlet; |
|
|
} |
|
|
//-------------------------------------- |
|
|
// |
|
|
// |
|
|
//-------------------------------------- |
|
|
/** |
|
|
* Fills a TrkLevel2 object with values from a struct cTrkLevel2 (to get data from F77 common). |
|
|
* Ref to Level1 data (clusters) is also set. |
|
|
*/ |
|
|
void TrkLevel2::SetFromLevel2Struct(cTrkLevel2 *l2, TrkLevel1 *l1){ |
|
|
|
|
|
// temporary objects: |
|
|
TrkSinglet* t_singlet = new TrkSinglet(); |
|
|
TrkTrack* t_track = new TrkTrack(); |
|
|
// general variables |
|
|
good2 = l2->good2; |
|
|
for(Int_t i=0; i<12 ; i++){ |
|
|
crc[i] = l2->crc[i]; |
|
|
}; |
|
|
// *** TRACKS *** |
|
|
TClonesArray &t = *Track; |
|
|
for(int i=0; i<l2->ntrk; i++){ |
|
|
t_track->seqno = i;// NBNBNBNB deve sempre essere = i |
|
|
t_track->image = l2->image[i]-1; |
|
|
// cout << "track "<<i<<t_track->seqno << t_track->image<<endl; |
|
|
t_track->chi2 = l2->chi2_nt[i]; |
|
|
for(int it1=0;it1<5;it1++){ |
|
|
t_track->al[it1] = l2->al_nt[i][it1]; |
|
|
for(int it2=0;it2<5;it2++) |
|
|
t_track->coval[it1][it2] = l2->coval[i][it2][it1]; |
|
|
}; |
|
|
for(int ip=0;ip<6;ip++){ |
|
|
t_track->xgood[ip] = l2->xgood_nt[i][ip]; |
|
|
t_track->ygood[ip] = l2->ygood_nt[i][ip]; |
|
|
t_track->xm[ip] = l2->xm_nt[i][ip]; |
|
|
t_track->ym[ip] = l2->ym_nt[i][ip]; |
|
|
t_track->zm[ip] = l2->zm_nt[i][ip]; |
|
|
t_track->resx[ip] = l2->resx_nt[i][ip]; |
|
|
t_track->resy[ip] = l2->resy_nt[i][ip]; |
|
|
t_track->xv[ip] = l2->xv_nt[i][ip]; |
|
|
t_track->yv[ip] = l2->yv_nt[i][ip]; |
|
|
t_track->zv[ip] = l2->zv_nt[i][ip]; |
|
|
t_track->axv[ip] = l2->axv_nt[i][ip]; |
|
|
t_track->ayv[ip] = l2->ayv_nt[i][ip]; |
|
|
t_track->dedx_x[ip] = l2->dedx_x[i][ip]; |
|
|
t_track->dedx_y[ip] = l2->dedx_y[i][ip]; |
|
|
// cout << "traccia "<<i<<" -- "<< ip << " "<< l2->cltrx[i][ip] <<" "<< l2->cltry[i][ip] <<" "<< t_track->xgood[ip] << t_track->ygood[ip]<<endl; |
|
|
//----------------------------------------------------- |
|
|
// t_track->clx[ip] = l1->GetCluster(l2->cltrx[i][ip]-1); |
|
|
// t_track->cly[ip] = l1->GetCluster(l2->cltry[i][ip]-1); |
|
|
if(t_track->xgood[ip])t_track->clx->AddAt(l1->GetCluster(l2->cltrx[i][ip]-1),ip); |
|
|
if(t_track->ygood[ip])t_track->cly->AddAt(l1->GetCluster(l2->cltry[i][ip]-1),ip); |
|
|
//----------------------------------------------------- |
|
|
}; |
|
|
new(t[i]) TrkTrack(*t_track); |
|
|
t_track->Clear(); |
|
|
}; |
|
|
// *** SINGLETS *** |
|
|
TClonesArray &sx = *SingletX; |
|
|
for(int i=0; i<l2->nclsx; i++){ |
|
|
t_singlet->plane = l2->planex[i]; |
|
|
t_singlet->coord[0] = l2->xs[i][0]; |
|
|
t_singlet->coord[1] = l2->xs[i][1]; |
|
|
t_singlet->sgnl = l2->signlxs[i]; |
|
|
//----------------------------------------------------- |
|
|
// cout << "singolo x "<<i<<" -- "<< l2->clsx[i] <<endl; |
|
|
t_singlet->cls = l1->GetCluster(l2->clsx[i]-1); |
|
|
//----------------------------------------------------- |
|
|
new(sx[i]) TrkSinglet(*t_singlet); |
|
|
t_singlet->Clear(); |
|
|
} |
|
|
TClonesArray &sy = *SingletY; |
|
|
for(int i=0; i<l2->nclsy; i++){ |
|
|
t_singlet->plane = l2->planey[i]; |
|
|
t_singlet->coord[0] = l2->ys[i][0]; |
|
|
t_singlet->coord[1] = l2->ys[i][1]; |
|
|
t_singlet->sgnl = l2->signlys[i]; |
|
|
//----------------------------------------------------- |
|
|
// cout << "singolo y "<<i<<" -- "<< l2->clsy[i] <<endl; |
|
|
t_singlet->cls = l1->GetCluster(l2->clsy[i]-1); |
|
|
//----------------------------------------------------- |
|
|
new(sy[i]) TrkSinglet(*t_singlet); |
|
|
t_singlet->Clear(); |
|
|
}; |
|
1182 |
|
|
1183 |
delete t_track; |
delete t_track; |
1184 |
delete t_singlet; |
delete t_singlet; |
1185 |
} |
} |
1186 |
/** |
/** |
1187 |
* Fills a struct cTrkLevel2 with values from a TrkLevel2 object (to put data into a F77 common). |
* Fills a struct cTrkLevel2 with values from a TrkLevel2 object (to put data into a F77 common). |
1190 |
void TrkLevel2::GetLevel2Struct(cTrkLevel2 *l2) const { |
void TrkLevel2::GetLevel2Struct(cTrkLevel2 *l2) const { |
1191 |
|
|
1192 |
// general variables |
// general variables |
1193 |
l2->good2 = good2 ; |
// l2->good2 = good2 ; |
1194 |
for(Int_t i=0; i<12 ; i++){ |
for(Int_t i=0; i<12 ; i++){ |
1195 |
l2->crc[i] = crc[i]; |
// l2->crc[i] = crc[i]; |
1196 |
|
l2->good[i] = good[i]; |
1197 |
}; |
}; |
1198 |
// *** TRACKS *** |
// *** TRACKS *** |
1199 |
|
|
1200 |
l2->ntrk = Track->GetEntries(); |
if(Track){ |
1201 |
for(Int_t i=0;i<l2->ntrk;i++){ |
l2->ntrk = Track->GetEntries(); |
1202 |
l2->image[i] = 1 + ((TrkTrack *)Track->At(i))->image; |
for(Int_t i=0;i<l2->ntrk;i++){ |
1203 |
l2->chi2_nt[i] = ((TrkTrack *)Track->At(i))->chi2; |
l2->image[i] = 1 + ((TrkTrack *)Track->At(i))->image; |
1204 |
for(int it1=0;it1<5;it1++){ |
l2->chi2_nt[i] = ((TrkTrack *)Track->At(i))->chi2; |
1205 |
l2->al_nt[i][it1] = ((TrkTrack *)Track->At(i))->al[it1]; |
l2->nstep_nt[i] = ((TrkTrack *)Track->At(i))->nstep; |
1206 |
for(int it2=0;it2<5;it2++) |
for(int it1=0;it1<5;it1++){ |
1207 |
l2->coval[i][it2][it1] = ((TrkTrack *)Track->At(i))->coval[it1][it2]; |
l2->al_nt[i][it1] = ((TrkTrack *)Track->At(i))->al[it1]; |
1208 |
}; |
for(int it2=0;it2<5;it2++) |
1209 |
for(int ip=0;ip<6;ip++){ |
l2->coval[i][it2][it1] = ((TrkTrack *)Track->At(i))->coval[it1][it2]; |
1210 |
l2->xgood_nt[i][ip] = ((TrkTrack *)Track->At(i))->xgood[ip]; |
}; |
1211 |
l2->ygood_nt[i][ip] = ((TrkTrack *)Track->At(i))->ygood[ip]; |
for(int ip=0;ip<6;ip++){ |
1212 |
l2->xm_nt[i][ip] = ((TrkTrack *)Track->At(i))->xm[ip]; |
l2->xgood_nt[i][ip] = ((TrkTrack *)Track->At(i))->XGood(ip); |
1213 |
l2->ym_nt[i][ip] = ((TrkTrack *)Track->At(i))->ym[ip]; |
l2->ygood_nt[i][ip] = ((TrkTrack *)Track->At(i))->YGood(ip); |
1214 |
l2->zm_nt[i][ip] = ((TrkTrack *)Track->At(i))->zm[ip]; |
l2->xm_nt[i][ip] = ((TrkTrack *)Track->At(i))->xm[ip]; |
1215 |
l2->resx_nt[i][ip] = ((TrkTrack *)Track->At(i))->resx[ip]; |
l2->ym_nt[i][ip] = ((TrkTrack *)Track->At(i))->ym[ip]; |
1216 |
l2->resy_nt[i][ip] = ((TrkTrack *)Track->At(i))->resy[ip]; |
l2->zm_nt[i][ip] = ((TrkTrack *)Track->At(i))->zm[ip]; |
1217 |
l2->xv_nt[i][ip] = ((TrkTrack *)Track->At(i))->xv[ip]; |
l2->resx_nt[i][ip] = ((TrkTrack *)Track->At(i))->resx[ip]; |
1218 |
l2->yv_nt[i][ip] = ((TrkTrack *)Track->At(i))->yv[ip]; |
l2->resy_nt[i][ip] = ((TrkTrack *)Track->At(i))->resy[ip]; |
1219 |
l2->zv_nt[i][ip] = ((TrkTrack *)Track->At(i))->zv[ip]; |
l2->tailx[i][ip] = ((TrkTrack *)Track->At(i))->tailx[ip]; |
1220 |
l2->axv_nt[i][ip] = ((TrkTrack *)Track->At(i))->axv[ip]; |
l2->taily[i][ip] = ((TrkTrack *)Track->At(i))->taily[ip]; |
1221 |
l2->ayv_nt[i][ip] = ((TrkTrack *)Track->At(i))->ayv[ip]; |
l2->xv_nt[i][ip] = ((TrkTrack *)Track->At(i))->xv[ip]; |
1222 |
l2->dedx_x[i][ip] = ((TrkTrack *)Track->At(i))->dedx_x[ip]; |
l2->yv_nt[i][ip] = ((TrkTrack *)Track->At(i))->yv[ip]; |
1223 |
l2->dedx_y[i][ip] = ((TrkTrack *)Track->At(i))->dedx_y[ip]; |
l2->zv_nt[i][ip] = ((TrkTrack *)Track->At(i))->zv[ip]; |
1224 |
}; |
l2->axv_nt[i][ip] = ((TrkTrack *)Track->At(i))->axv[ip]; |
1225 |
|
l2->ayv_nt[i][ip] = ((TrkTrack *)Track->At(i))->ayv[ip]; |
1226 |
|
l2->dedx_x[i][ip] = ((TrkTrack *)Track->At(i))->dedx_x[ip]; |
1227 |
|
l2->dedx_y[i][ip] = ((TrkTrack *)Track->At(i))->dedx_y[ip]; |
1228 |
|
}; |
1229 |
|
} |
1230 |
} |
} |
|
|
|
1231 |
// *** SINGLETS *** |
// *** SINGLETS *** |
1232 |
l2->nclsx = SingletX->GetEntries(); |
if(SingletX){ |
1233 |
for(Int_t i=0;i<l2->nclsx;i++){ |
l2->nclsx = SingletX->GetEntries(); |
1234 |
l2->planex[i] = ((TrkSinglet *)SingletX->At(i))->plane; |
for(Int_t i=0;i<l2->nclsx;i++){ |
1235 |
l2->xs[i][0] = ((TrkSinglet *)SingletX->At(i))->coord[0]; |
l2->planex[i] = ((TrkSinglet *)SingletX->At(i))->plane; |
1236 |
l2->xs[i][1] = ((TrkSinglet *)SingletX->At(i))->coord[1]; |
l2->xs[i][0] = ((TrkSinglet *)SingletX->At(i))->coord[0]; |
1237 |
l2->signlxs[i] = ((TrkSinglet *)SingletX->At(i))->sgnl; |
l2->xs[i][1] = ((TrkSinglet *)SingletX->At(i))->coord[1]; |
1238 |
} |
l2->signlxs[i] = ((TrkSinglet *)SingletX->At(i))->sgnl; |
1239 |
l2->nclsy = SingletY->GetEntries(); |
} |
1240 |
for(Int_t i=0;i<l2->nclsy;i++){ |
} |
1241 |
l2->planey[i] = ((TrkSinglet *)SingletY->At(i))->plane; |
|
1242 |
l2->ys[i][0] = ((TrkSinglet *)SingletY->At(i))->coord[0]; |
if(SingletY){ |
1243 |
l2->ys[i][1] = ((TrkSinglet *)SingletY->At(i))->coord[1]; |
l2->nclsy = SingletY->GetEntries(); |
1244 |
l2->signlys[i] = ((TrkSinglet *)SingletY->At(i))->sgnl; |
for(Int_t i=0;i<l2->nclsy;i++){ |
1245 |
|
l2->planey[i] = ((TrkSinglet *)SingletY->At(i))->plane; |
1246 |
|
l2->ys[i][0] = ((TrkSinglet *)SingletY->At(i))->coord[0]; |
1247 |
|
l2->ys[i][1] = ((TrkSinglet *)SingletY->At(i))->coord[1]; |
1248 |
|
l2->signlys[i] = ((TrkSinglet *)SingletY->At(i))->sgnl; |
1249 |
|
} |
1250 |
} |
} |
1251 |
} |
} |
1252 |
//-------------------------------------- |
//-------------------------------------- |
1254 |
// |
// |
1255 |
//-------------------------------------- |
//-------------------------------------- |
1256 |
void TrkLevel2::Clear(){ |
void TrkLevel2::Clear(){ |
|
good2 = -1; |
|
1257 |
for(Int_t i=0; i<12 ; i++){ |
for(Int_t i=0; i<12 ; i++){ |
1258 |
crc[i] = -1; |
good[i] = -1; |
1259 |
|
VKflag[i] = 0; |
1260 |
|
VKmask[i] = 0; |
1261 |
}; |
}; |
1262 |
/* Track->RemoveAll(); |
// if(Track)Track->Clear("C"); |
1263 |
SingletX->RemoveAll(); |
// if(SingletX)SingletX->Clear("C"); |
1264 |
SingletY->RemoveAll();*/ |
// if(SingletY)SingletY->Clear("C"); |
1265 |
// modify to avoid memory leakage |
if(Track)Track->Delete(); |
1266 |
Track->Clear(); |
if(SingletX)SingletX->Delete(); |
1267 |
SingletX->Clear(); |
if(SingletY)SingletY->Delete(); |
1268 |
SingletY->Clear(); |
} |
1269 |
|
// //-------------------------------------- |
1270 |
|
// // |
1271 |
|
// // |
1272 |
|
// //-------------------------------------- |
1273 |
|
void TrkLevel2::Delete(){ |
1274 |
|
|
1275 |
|
// cout << "void TrkLevel2::Delete()"<<endl; |
1276 |
|
Clear(); |
1277 |
|
if(Track)delete Track; |
1278 |
|
if(SingletX)delete SingletX; |
1279 |
|
if(SingletY)delete SingletY; |
1280 |
|
|
1281 |
} |
} |
1282 |
//-------------------------------------- |
//-------------------------------------- |
1283 |
// |
// |
1287 |
* 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). |
1288 |
* 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. |
1289 |
*/ |
*/ |
1290 |
// TClonesArray *TrkLevel2::GetTracks(){ |
TRefArray *TrkLevel2::GetTracks_NFitSorted(){ |
|
// TClonesArray *sorted = GetTracks_NFitSorted(); |
|
|
// return sorted; |
|
|
// }; |
|
1291 |
|
|
1292 |
/*TClonesArray *TrkLevel2::GetTracks_Chi2Sorted(){ |
if(!Track)return 0; |
1293 |
|
|
1294 |
TClonesArray *sorted = new TClonesArray("TrkTrack"); |
TRefArray *sorted = new TRefArray(); |
1295 |
TClonesArray &t = *Track; |
|
1296 |
TClonesArray &ts = *sorted; |
TClonesArray &t = *Track; |
1297 |
int N=this->ntrk(); |
// TClonesArray &ts = *PhysicalTrack; |
1298 |
|
int N = ntrk(); |
1299 |
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; |
1300 |
|
// int m[50]; for(int i=0; i<N; i++)m[i]=1; |
1301 |
|
|
1302 |
int indo=0; |
int indo=0; |
1303 |
int indi=0; |
int indi=0; |
1304 |
while(N != 0){ |
while(N > 0){ |
1305 |
float chi2ref=1000000; |
// while(N != 0){ |
1306 |
for(int i=0; i<this->ntrk(); i++){ |
int nfit =0; |
1307 |
if(((TrkTrack *)t[i])->chi2 < chi2ref && m[i]==1){ |
float chi2ref = numeric_limits<float>::max(); |
1308 |
chi2ref = ((TrkTrack *)t[i])->chi2; |
|
1309 |
indi = i; |
// first loop to search maximum num. of fit points |
1310 |
|
for(int i=0; i < ntrk(); i++){ |
1311 |
|
if( ((TrkTrack *)t[i])->GetNtot() >= nfit && m[i]==1){ |
1312 |
|
nfit = ((TrkTrack *)t[i])->GetNtot(); |
1313 |
} |
} |
1314 |
} |
} |
1315 |
if( ((TrkTrack *)t[indi])->image != -1 ){ |
//second loop to search minimum chi2 among selected |
1316 |
|
for(int i=0; i<ntrk(); i++){ |
1317 |
|
Float_t chi2 = ((TrkTrack *)t[i])->chi2; |
1318 |
|
if(chi2 < 0) chi2 = -chi2*1000; |
1319 |
|
if( chi2 < chi2ref |
1320 |
|
&& ((TrkTrack *)t[i])->GetNtot() == nfit |
1321 |
|
&& m[i]==1){ |
1322 |
|
chi2ref = ((TrkTrack *)t[i])->chi2; |
1323 |
|
indi = i; |
1324 |
|
}; |
1325 |
|
}; |
1326 |
|
if( ((TrkTrack *)t[indi])->HasImage() ){ |
1327 |
m[((TrkTrack *)t[indi])->image] = 0; |
m[((TrkTrack *)t[indi])->image] = 0; |
1328 |
N--; |
N--; |
1329 |
} |
|
1330 |
new(ts[indo]) TrkTrack(*(TrkTrack*)t[indi]); |
// cout << "i** "<< ((TrkTrack *)t[indi])->image << " " << nfiti <<" "<<chi2i<<endl; |
1331 |
|
}; |
1332 |
|
sorted->Add( (TrkTrack*)t[indi] ); |
1333 |
|
|
1334 |
m[indi] = 0; |
m[indi] = 0; |
1335 |
|
// cout << "SORTED "<< indo << " "<< indi << " "<< N << " "<<((TrkTrack *)t[indi])->image<<" "<<chi2ref<<endl; |
1336 |
N--; |
N--; |
1337 |
indo++; |
indo++; |
1338 |
} |
} |
1339 |
return sorted; |
m.clear(); |
1340 |
}*/ |
// cout << "GetTracks_NFitSorted(it): Done"<< endl; |
|
/*TClonesArray *TrkLevel2::GetTracks_NFitSorted(){ |
|
1341 |
|
|
|
TClonesArray *sorted = new TClonesArray("TrkTrack"); |
|
|
TClonesArray &t = *Track; |
|
|
TClonesArray &ts = *sorted; |
|
|
// TClonesArray &ts = *PhysicalTrack; |
|
|
int N = ntrk(); |
|
|
vector<int> m(N); for(int i=0; i<N; i++)m[i]=1; |
|
|
// int m[50]; for(int i=0; i<N; i++)m[i]=1; |
|
|
|
|
|
int indo=0; |
|
|
int indi=0; |
|
|
while(N != 0){ |
|
|
int nfit =0; |
|
|
float chi2ref = numeric_limits<float>::max(); |
|
|
// first loop to search maximum num. of fit points |
|
|
for(int i=0; i < ntrk(); i++){ |
|
|
// if(N==ntrk())cout << "** "<<i<< " " << ((TrkTrack *)t[i])->GetImageSeqNo()<< " " <<((TrkTrack *)t[i])->GetNtot() << " " <<((TrkTrack *)t[i])->chi2 << endl; |
|
|
if( ((TrkTrack *)t[i])->GetNtot() >= nfit && m[i]==1){ |
|
|
nfit = ((TrkTrack *)t[i])->GetNtot(); |
|
|
} |
|
|
} |
|
|
//second loop to search minimum chi2 among selected |
|
|
for(int i=0; i<this->ntrk(); i++){ |
|
|
if( ((TrkTrack *)t[i])->chi2 < chi2ref |
|
|
&& ((TrkTrack *)t[i])->GetNtot()== nfit |
|
|
&& m[i]==1){ |
|
|
chi2ref = ((TrkTrack *)t[i])->chi2; |
|
|
indi = i; |
|
|
// cout << "2** "<<i<< " " << nfit <<" "<<chi2ref<<endl; |
|
|
} |
|
|
} |
|
|
if( ((TrkTrack *)t[indi])->HasImage() ){ |
|
|
m[((TrkTrack *)t[indi])->image] = 0; |
|
|
N--; |
|
|
|
|
|
// Int_t nfiti=((TrkTrack *)t[((TrkTrack *)t[indi])->image ])->GetNtot(); |
|
|
// Float_t chi2i=((TrkTrack *)t[((TrkTrack *)t[indi])->image ])->chi2; |
|
|
|
|
|
// cout << "i** "<< ((TrkTrack *)t[indi])->image << " " << nfiti <<" "<<chi2i<<endl; |
|
|
} |
|
|
new(ts[indo]) TrkTrack(*(TrkTrack*)t[indi]); |
|
|
m[indi] = 0; |
|
|
// cout << "SORTED "<< indo << " "<< indi << " "<< N << endl; |
|
|
N--; |
|
|
indo++; |
|
|
} |
|
|
m.clear(); |
|
1342 |
return sorted; |
return sorted; |
1343 |
// return PhysicalTrack; |
// return PhysicalTrack; |
|
}*/ |
|
|
//TClonesArray *TrkLevel2::GetTracks_NFitSorted(){ |
|
|
TRefArray *TrkLevel2::GetTracks_NFitSorted(){ |
|
|
|
|
|
// cout << "GetTracks_NFitSorted(it): new TRefArray()"<< endl; |
|
|
// TClonesArray *sorted = new TClonesArray("TrkTrack"); |
|
|
// TClonesArray &ts = *sorted; |
|
|
TRefArray *sorted = new TRefArray(); |
|
|
|
|
|
TClonesArray &t = *Track; |
|
|
// TClonesArray &ts = *PhysicalTrack; |
|
|
int N = ntrk(); |
|
|
vector<int> m(N); for(int i=0; i<N; i++)m[i]=1; |
|
|
// int m[50]; for(int i=0; i<N; i++)m[i]=1; |
|
|
|
|
|
int indo=0; |
|
|
int indi=0; |
|
|
while(N != 0){ |
|
|
int nfit =0; |
|
|
float chi2ref = numeric_limits<float>::max(); |
|
|
|
|
|
// first loop to search maximum num. of fit points |
|
|
for(int i=0; i < ntrk(); i++){ |
|
|
if( ((TrkTrack *)t[i])->GetNtot() >= nfit && m[i]==1){ |
|
|
nfit = ((TrkTrack *)t[i])->GetNtot(); |
|
|
} |
|
|
} |
|
|
//second loop to search minimum chi2 among selected |
|
|
for(int i=0; i<this->ntrk(); i++){ |
|
|
Float_t chi2 = ((TrkTrack *)t[i])->chi2; |
|
|
if(chi2 < 0) chi2 = chi2*1000; |
|
|
if( chi2 < chi2ref |
|
|
&& ((TrkTrack *)t[i])->GetNtot() == nfit |
|
|
&& m[i]==1){ |
|
|
chi2ref = ((TrkTrack *)t[i])->chi2; |
|
|
indi = i; |
|
|
}; |
|
|
}; |
|
|
if( ((TrkTrack *)t[indi])->HasImage() ){ |
|
|
m[((TrkTrack *)t[indi])->image] = 0; |
|
|
N--; |
|
|
|
|
|
// Int_t nfiti=((TrkTrack *)t[((TrkTrack *)t[indi])->image ])->GetNtot(); |
|
|
// Float_t chi2i=((TrkTrack *)t[((TrkTrack *)t[indi])->image ])->chi2; |
|
|
|
|
|
// cout << "i** "<< ((TrkTrack *)t[indi])->image << " " << nfiti <<" "<<chi2i<<endl; |
|
|
}; |
|
|
// new(ts[indo]) TrkTrack(*(TrkTrack*)t[indi]); |
|
|
// cout << "GetTracks_NFitSorted(it): Add("<<indo<<")"<< endl; |
|
|
sorted->Add( (TrkTrack*)t[indi] ); |
|
|
|
|
|
m[indi] = 0; |
|
|
// cout << "SORTED "<< indo << " "<< indi << " "<< N << endl; |
|
|
N--; |
|
|
indo++; |
|
|
} |
|
|
m.clear(); |
|
|
// cout << "GetTracks_NFitSorted(it): Done"<< endl; |
|
|
|
|
|
return sorted; |
|
|
// return PhysicalTrack; |
|
1344 |
} |
} |
1345 |
//-------------------------------------- |
//-------------------------------------- |
1346 |
// |
// |
1358 |
cout << " Stored tracks ntrk() = "<< this->ntrk() << endl; |
cout << " Stored tracks ntrk() = "<< this->ntrk() << endl; |
1359 |
return 0; |
return 0; |
1360 |
} |
} |
1361 |
|
if(!Track){ |
1362 |
|
cout << "TrkTrack *TrkLevel2::GetStoredTrack(int is) >> (TClonesArray*) Track ==0 "<<endl; |
1363 |
|
}; |
1364 |
TClonesArray &t = *(Track); |
TClonesArray &t = *(Track); |
1365 |
TrkTrack *track = (TrkTrack*)t[is]; |
TrkTrack *track = (TrkTrack*)t[is]; |
1366 |
return track; |
return track; |
1380 |
cout << " Stored x-singlets nclsx() = "<< this->nclsx() << endl; |
cout << " Stored x-singlets nclsx() = "<< this->nclsx() << endl; |
1381 |
return 0; |
return 0; |
1382 |
} |
} |
1383 |
|
if(!SingletX)return 0; |
1384 |
TClonesArray &t = *(SingletX); |
TClonesArray &t = *(SingletX); |
1385 |
TrkSinglet *singlet = (TrkSinglet*)t[is]; |
TrkSinglet *singlet = (TrkSinglet*)t[is]; |
1386 |
return singlet; |
return singlet; |
1400 |
cout << " Stored y-singlets nclsy() = "<< this->nclsx() << endl; |
cout << " Stored y-singlets nclsy() = "<< this->nclsx() << endl; |
1401 |
return 0; |
return 0; |
1402 |
} |
} |
1403 |
|
if(!SingletY)return 0; |
1404 |
TClonesArray &t = *(SingletY); |
TClonesArray &t = *(SingletY); |
1405 |
TrkSinglet *singlet = (TrkSinglet*)t[is]; |
TrkSinglet *singlet = (TrkSinglet*)t[is]; |
1406 |
return singlet; |
return singlet; |
1413 |
* Retrieves the it-th "physical" track, sorted by the method GetNTracks(). |
* Retrieves the it-th "physical" track, sorted by the method GetNTracks(). |
1414 |
* @param it Track number, ranging from 0 to GetNTracks(). |
* @param it Track number, ranging from 0 to GetNTracks(). |
1415 |
*/ |
*/ |
1416 |
/*TrkTrack *TrkLevel2::GetTrack(int it){ |
|
|
|
|
|
if(it >= this->GetNTracks()){ |
|
|
cout << "** TrkLevel2 ** Track "<< it << "does not exits! " << endl; |
|
|
cout << " Physical tracks GetNTracks() = "<< this->ntrk() << endl; |
|
|
return 0; |
|
|
} |
|
|
TClonesArray* sorted = GetTracks(); |
|
|
TClonesArray &ts = *sorted; |
|
|
|
|
|
// TrkTrack *track = (TrkTrack*)ts[it]; |
|
|
TrkTrack *track = new TrkTrack( *(TrkTrack*)ts[it] ); //copia |
|
|
sorted->Delete("all");////TEMPORANEO |
|
|
return track; |
|
|
}*/ |
|
1417 |
TrkTrack *TrkLevel2::GetTrack(int it){ |
TrkTrack *TrkLevel2::GetTrack(int it){ |
1418 |
|
|
1419 |
if(it >= this->GetNTracks()){ |
if(it >= this->GetNTracks()){ |
1423 |
} |
} |
1424 |
|
|
1425 |
TRefArray *sorted = GetTracks(); //TEMPORANEO |
TRefArray *sorted = GetTracks(); //TEMPORANEO |
1426 |
|
if(!sorted)return 0; |
1427 |
TrkTrack *track = (TrkTrack*)sorted->At(it); |
TrkTrack *track = (TrkTrack*)sorted->At(it); |
1428 |
sorted->Delete(); |
sorted->Clear(); |
1429 |
|
delete sorted; |
1430 |
return track; |
return track; |
1431 |
} |
} |
1432 |
/** |
/** |
1435 |
Int_t TrkLevel2::GetNTracks(){ |
Int_t TrkLevel2::GetNTracks(){ |
1436 |
|
|
1437 |
Float_t ntot=0; |
Float_t ntot=0; |
1438 |
|
if(!Track)return 0; |
1439 |
TClonesArray &t = *Track; |
TClonesArray &t = *Track; |
1440 |
for(int i=0; i<ntrk(); i++) { |
for(int i=0; i<ntrk(); i++) { |
1441 |
if( ((TrkTrack *)t[i])->GetImageSeqNo() == -1 ) ntot+=1.; |
if( ((TrkTrack *)t[i])->GetImageSeqNo() == -1 ) ntot+=1.; |
1442 |
else ntot+=0.5; |
else ntot+=0.5; |
1443 |
} |
} |
1452 |
* Retrieves (if present) the image of the it-th "physical" track, sorted by the method GetNTracks(). |
* Retrieves (if present) the image of the it-th "physical" track, sorted by the method GetNTracks(). |
1453 |
* @param it Track number, ranging from 0 to GetNTracks(). |
* @param it Track number, ranging from 0 to GetNTracks(). |
1454 |
*/ |
*/ |
1455 |
/*TrkTrack *TrkLevel2::GetTrackImage(int it){ |
TrkTrack *TrkLevel2::GetTrackImage(int it){ |
1456 |
|
|
1457 |
if(it >= this->GetNTracks()){ |
if(it >= this->GetNTracks()){ |
1458 |
cout << "** TrkLevel2 ** Track "<< it << "does not exits! " << endl; |
cout << "** TrkLevel2 ** Track "<< it << "does not exits! " << endl; |
1460 |
return 0; |
return 0; |
1461 |
} |
} |
1462 |
|
|
1463 |
TClonesArray* sorted = GetTracks(); |
TRefArray* sorted = GetTracks(); //TEMPORANEO |
1464 |
TClonesArray &ts = *sorted; |
if(!sorted)return 0; |
1465 |
TrkTrack *track = (TrkTrack*)ts[it]; |
TrkTrack *track = (TrkTrack*)sorted->At(it); |
1466 |
// TrkTrack *track = (TrkTrack*)(*(this->GetTracks()))[it]; |
|
1467 |
|
if(!track->HasImage()){ |
|
if(!track->HasImage()){ |
|
1468 |
cout << "** TrkLevel2 ** Track "<< it << "does not have image! " << endl; |
cout << "** TrkLevel2 ** Track "<< it << "does not have image! " << endl; |
1469 |
return 0; |
return 0; |
1470 |
} |
} |
1471 |
|
if(!Track)return 0; |
1472 |
TrkTrack *image = (TrkTrack*)(*Track)[track->image]; |
TrkTrack *image = (TrkTrack*)(*Track)[track->image]; |
1473 |
|
|
1474 |
// GetTracks()->Delete(); ////TEMPORANEO |
sorted->Delete(); |
1475 |
sorted->Delete(); ////TEMPORANEO |
delete sorted; |
|
|
|
|
return image; |
|
|
|
|
|
}*/ |
|
|
TrkTrack *TrkLevel2::GetTrackImage(int it){ |
|
|
|
|
|
if(it >= this->GetNTracks()){ |
|
|
cout << "** TrkLevel2 ** Track "<< it << "does not exits! " << endl; |
|
|
cout << " Physical tracks GetNTracks() = "<< this->ntrk() << endl; |
|
|
return 0; |
|
|
} |
|
|
|
|
|
TRefArray* sorted = GetTracks(); //TEMPORANEO |
|
|
TrkTrack *track = (TrkTrack*)sorted->At(it); |
|
|
|
|
|
if(!track->HasImage()){ |
|
|
cout << "** TrkLevel2 ** Track "<< it << "does not have image! " << endl; |
|
|
return 0; |
|
|
} |
|
|
TrkTrack *image = (TrkTrack*)(*Track)[track->image]; |
|
1476 |
|
|
1477 |
sorted->Delete(); |
return image; |
|
|
|
|
return image; |
|
1478 |
|
|
1479 |
} |
} |
1480 |
//-------------------------------------- |
//-------------------------------------- |
1485 |
* Loads the magnetic field. |
* Loads the magnetic field. |
1486 |
* @param s Path of the magnetic-field files. |
* @param s Path of the magnetic-field files. |
1487 |
*/ |
*/ |
1488 |
void TrkLevel2::LoadField(TString s){ |
void TrkLevel2::LoadField(TString path){ |
1489 |
readb_(s.Data()); |
// |
1490 |
|
// strcpy(path_.path,path.Data()); |
1491 |
|
// path_.pathlen = path.Length(); |
1492 |
|
// path_.error = 0; |
1493 |
|
// readb_(); |
1494 |
|
|
1495 |
|
TrkParams::SetTrackingMode(); |
1496 |
|
TrkParams::SetPrecisionFactor(); |
1497 |
|
TrkParams::SetStepMin(); |
1498 |
|
|
1499 |
|
TrkParams::Set(path,1); |
1500 |
|
TrkParams::Load(1); |
1501 |
|
|
1502 |
|
// |
1503 |
}; |
}; |
1504 |
|
// /** |
1505 |
|
// * Get BY (kGauss) |
1506 |
|
// * @param v (x,y,z) coordinates in cm |
1507 |
|
// */ |
1508 |
|
// float TrkLevel2::GetBX(float* v){ |
1509 |
|
// float b[3]; |
1510 |
|
// gufld_(v,b); |
1511 |
|
// return b[0]/10.; |
1512 |
|
// } |
1513 |
|
// /** |
1514 |
|
// * Get BY (kGauss) |
1515 |
|
// * @param v (x,y,z) coordinates in cm |
1516 |
|
// */ |
1517 |
|
// float TrkLevel2::GetBY(float* v){ |
1518 |
|
// float b[3]; |
1519 |
|
// gufld_(v,b); |
1520 |
|
// return b[1]/10.; |
1521 |
|
// } |
1522 |
|
// /** |
1523 |
|
// * Get BY (kGauss) |
1524 |
|
// * @param v (x,y,z) coordinates in cm |
1525 |
|
// */ |
1526 |
|
// float TrkLevel2::GetBZ(float* v){ |
1527 |
|
// float b[3]; |
1528 |
|
// gufld_(v,b); |
1529 |
|
// return b[2]/10.; |
1530 |
|
// } |
1531 |
//-------------------------------------- |
//-------------------------------------- |
1532 |
// |
// |
1533 |
// |
// |
1624 |
tl = new float[npoint]; |
tl = new float[npoint]; |
1625 |
int i=0; |
int i=0; |
1626 |
do{ |
do{ |
1627 |
x[i] = 0; |
x[i] = 0; |
1628 |
y[i] = 0; |
y[i] = 0; |
1629 |
z[i] = zin[i]; |
z[i] = zin[i]; |
1630 |
thx[i] = 0; |
thx[i] = 0; |
1631 |
thy[i] = 0; |
thy[i] = 0; |
1632 |
tl[i] = 0; |
tl[i] = 0; |
1633 |
i++; |
i++; |
1634 |
}while(zin[i-1] > zin[i] && i < npoint); |
}while(zin[i-1] > zin[i] && i < npoint); |
1635 |
npoint=i; |
npoint=i; |
1636 |
if(npoint != n)cout << "NB! Trajectory created with "<<npoint<<" points"<<endl; |
if(npoint != n)cout << "NB! Trajectory created with "<<npoint<<" points"<<endl; |
1637 |
} |
} |
1638 |
|
void Trajectory::Delete(){ |
1639 |
|
|
1640 |
|
if(x) delete [] x; |
1641 |
|
if(y) delete [] y; |
1642 |
|
if(z) delete [] z; |
1643 |
|
if(thx) delete [] thx; |
1644 |
|
if(thy) delete [] thy; |
1645 |
|
if(tl) delete [] tl; |
1646 |
|
|
1647 |
|
} |
1648 |
//-------------------------------------- |
//-------------------------------------- |
1649 |
// |
// |
1650 |
// |
// |
1683 |
|
|
1684 |
} |
} |
1685 |
|
|
1686 |
|
/** |
1687 |
|
* Evaluates the trajectory in the apparatus associated to the track. |
1688 |
|
* 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. |
1689 |
|
* @param t pointer to an object of the class Trajectory, |
1690 |
|
* which z coordinates should be previously initialized by calling the proper constructor ( Trajectory::Trajectory(int n, float* zin) ). |
1691 |
|
* @return error flag. |
1692 |
|
*/ |
1693 |
|
int Trajectory::DoTrack2(float* al){ |
1694 |
|
|
1695 |
|
double *dxout = new double[npoint]; |
1696 |
|
double *dyout = new double[npoint]; |
1697 |
|
double *dthxout = new double[npoint]; |
1698 |
|
double *dthyout = new double[npoint]; |
1699 |
|
double *dtlout = new double[npoint]; |
1700 |
|
double *dzin = new double[npoint]; |
1701 |
|
double dal[5]; |
1702 |
|
|
1703 |
|
int ifail = 0; |
1704 |
|
|
1705 |
|
for (int i=0; i<5; i++) dal[i] = (double)al[i]; |
1706 |
|
for (int i=0; i<npoint; i++) dzin[i] = (double)z[i]; |
1707 |
|
|
1708 |
|
TrkParams::Load(1); |
1709 |
|
if( !TrkParams::IsLoaded(1) ){ |
1710 |
|
cout << "int Trajectory::DoTrack2(float* al) --- ERROR --- m.field not loaded"<<endl; |
1711 |
|
return 0; |
1712 |
|
} |
1713 |
|
dotrack2_(&(npoint),dzin,dxout,dyout,dthxout,dthyout,dtlout,dal,&ifail); |
1714 |
|
|
1715 |
|
for (int i=0; i<npoint; i++){ |
1716 |
|
x[i] = (float)*dxout++; |
1717 |
|
y[i] = (float)*dyout++; |
1718 |
|
thx[i] = (float)*dthxout++; |
1719 |
|
thy[i] = (float)*dthyout++; |
1720 |
|
tl[i] = (float)*dtlout++; |
1721 |
|
} |
1722 |
|
|
1723 |
|
return ifail; |
1724 |
|
}; |
1725 |
|
|
1726 |
ClassImp(TrkLevel2); |
ClassImp(TrkLevel2); |
1727 |
ClassImp(TrkSinglet); |
ClassImp(TrkSinglet); |
1728 |
ClassImp(TrkTrack); |
ClassImp(TrkTrack); |