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 |
} |
} |
19 |
|
|
20 |
//-------------------------------------- |
//-------------------------------------- |
21 |
// |
// |
22 |
// |
// |
23 |
//-------------------------------------- |
//-------------------------------------- |
24 |
TrkTrack::TrkTrack(){ |
TrkTrack::TrkTrack(){ |
25 |
|
// cout << "TrkTrack::TrkTrack()" << endl; |
26 |
seqno = -1; |
seqno = -1; |
27 |
image = -1; |
image = -1; |
28 |
chi2 = 0; |
chi2 = 0; |
29 |
|
nstep = 0; |
30 |
for(int it1=0;it1<5;it1++){ |
for(int it1=0;it1<5;it1++){ |
31 |
al[it1] = 0; |
al[it1] = 0; |
32 |
for(int it2=0;it2<5;it2++) |
for(int it2=0;it2<5;it2++)coval[it1][it2] = 0; |
|
coval[it1][it2] = 0; |
|
33 |
}; |
}; |
34 |
for(int ip=0;ip<6;ip++){ |
for(int ip=0;ip<6;ip++){ |
35 |
xgood[ip] = 0; |
xgood[ip] = 0; |
39 |
zm[ip] = 0; |
zm[ip] = 0; |
40 |
resx[ip] = 0; |
resx[ip] = 0; |
41 |
resy[ip] = 0; |
resy[ip] = 0; |
42 |
|
tailx[ip] = 0; |
43 |
|
taily[ip] = 0; |
44 |
xv[ip] = 0; |
xv[ip] = 0; |
45 |
yv[ip] = 0; |
yv[ip] = 0; |
46 |
zv[ip] = 0; |
zv[ip] = 0; |
48 |
ayv[ip] = 0; |
ayv[ip] = 0; |
49 |
dedx_x[ip] = 0; |
dedx_x[ip] = 0; |
50 |
dedx_y[ip] = 0; |
dedx_y[ip] = 0; |
51 |
}; |
}; |
52 |
|
// clx = 0; |
53 |
|
// cly = 0; |
54 |
|
// clx = new TRefArray(6,0); //forse causa memory leak??? |
55 |
|
// cly = new TRefArray(6,0); //forse causa memory leak??? |
56 |
|
// clx = TRefArray(6,0); |
57 |
|
// cly = TRefArray(6,0); |
58 |
|
|
59 |
}; |
}; |
60 |
//-------------------------------------- |
//-------------------------------------- |
61 |
// |
// |
65 |
seqno = t.seqno; |
seqno = t.seqno; |
66 |
image = t.image; |
image = t.image; |
67 |
chi2 = t.chi2; |
chi2 = t.chi2; |
68 |
|
nstep = t.nstep; |
69 |
for(int it1=0;it1<5;it1++){ |
for(int it1=0;it1<5;it1++){ |
70 |
al[it1] = t.al[it1]; |
al[it1] = t.al[it1]; |
71 |
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]; |
|
72 |
}; |
}; |
73 |
for(int ip=0;ip<6;ip++){ |
for(int ip=0;ip<6;ip++){ |
74 |
xgood[ip] = t.xgood[ip]; |
xgood[ip] = t.xgood[ip]; |
78 |
zm[ip] = t.zm[ip]; |
zm[ip] = t.zm[ip]; |
79 |
resx[ip] = t.resx[ip]; |
resx[ip] = t.resx[ip]; |
80 |
resy[ip] = t.resy[ip]; |
resy[ip] = t.resy[ip]; |
81 |
|
tailx[ip] = t.tailx[ip]; |
82 |
|
taily[ip] = t.taily[ip]; |
83 |
xv[ip] = t.xv[ip]; |
xv[ip] = t.xv[ip]; |
84 |
yv[ip] = t.yv[ip]; |
yv[ip] = t.yv[ip]; |
85 |
zv[ip] = t.zv[ip]; |
zv[ip] = t.zv[ip]; |
87 |
ayv[ip] = t.ayv[ip]; |
ayv[ip] = t.ayv[ip]; |
88 |
dedx_x[ip] = t.dedx_x[ip]; |
dedx_x[ip] = t.dedx_x[ip]; |
89 |
dedx_y[ip] = t.dedx_y[ip]; |
dedx_y[ip] = t.dedx_y[ip]; |
90 |
}; |
}; |
91 |
|
// clx = 0; |
92 |
|
// cly = 0; |
93 |
|
// if(t.clx)clx = new TRefArray(*(t.clx)); |
94 |
|
// if(t.cly)cly = new TRefArray(*(t.cly)); |
95 |
|
// clx = TRefArray(t.clx); |
96 |
|
// cly = TRefArray(t.cly); |
97 |
|
|
98 |
|
}; |
99 |
|
//-------------------------------------- |
100 |
|
// |
101 |
|
// |
102 |
|
//-------------------------------------- |
103 |
|
void TrkTrack::Copy(TrkTrack& t){ |
104 |
|
|
105 |
|
t.seqno = seqno; |
106 |
|
t.image = image; |
107 |
|
t.chi2 = chi2; |
108 |
|
t.nstep = nstep; |
109 |
|
for(int it1=0;it1<5;it1++){ |
110 |
|
t.al[it1] = al[it1]; |
111 |
|
for(int it2=0;it2<5;it2++)t.coval[it1][it2] = coval[it1][it2]; |
112 |
|
}; |
113 |
|
for(int ip=0;ip<6;ip++){ |
114 |
|
t.xgood[ip] = xgood[ip]; |
115 |
|
t.ygood[ip] = ygood[ip]; |
116 |
|
t.xm[ip] = xm[ip]; |
117 |
|
t.ym[ip] = ym[ip]; |
118 |
|
t.zm[ip] = zm[ip]; |
119 |
|
t.resx[ip] = resx[ip]; |
120 |
|
t.resy[ip] = resy[ip]; |
121 |
|
t.tailx[ip] = tailx[ip]; |
122 |
|
t.taily[ip] = taily[ip]; |
123 |
|
t.xv[ip] = xv[ip]; |
124 |
|
t.yv[ip] = yv[ip]; |
125 |
|
t.zv[ip] = zv[ip]; |
126 |
|
t.axv[ip] = axv[ip]; |
127 |
|
t.ayv[ip] = ayv[ip]; |
128 |
|
t.dedx_x[ip] = dedx_x[ip]; |
129 |
|
t.dedx_y[ip] = dedx_y[ip]; |
130 |
|
|
131 |
|
}; |
132 |
|
|
133 |
|
// t.clx = TRefArray(clx); |
134 |
|
// t.cly = TRefArray(cly); |
135 |
|
|
136 |
}; |
}; |
137 |
//-------------------------------------- |
//-------------------------------------- |
138 |
// |
// |
157 |
for (int i=0; i<5; i++) dal[i] = (double)al[i]; |
for (int i=0; i<5; i++) dal[i] = (double)al[i]; |
158 |
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]; |
159 |
|
|
160 |
|
TrkParams::Load(1); |
161 |
|
if( !TrkParams::IsLoaded(1) ){ |
162 |
|
cout << "int TrkTrack::DoTrack(Trajectory* t) --- ERROR --- m.field not loaded"<<endl; |
163 |
|
return 0; |
164 |
|
} |
165 |
dotrack_(&(t->npoint),dzin,dxout,dyout,dal,&ifail); |
dotrack_(&(t->npoint),dzin,dxout,dyout,dal,&ifail); |
166 |
|
|
167 |
for (int i=0; i<t->npoint; i++){ |
for (int i=0; i<t->npoint; i++){ |
201 |
for (int i=0; i<5; i++) dal[i] = (double)al[i]; |
for (int i=0; i<5; i++) dal[i] = (double)al[i]; |
202 |
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]; |
203 |
|
|
204 |
|
TrkParams::Load(1); |
205 |
|
if( !TrkParams::IsLoaded(1) ){ |
206 |
|
cout << "int TrkTrack::DoTrack2(Trajectory* t) --- ERROR --- m.field not loaded"<<endl; |
207 |
|
return 0; |
208 |
|
} |
209 |
dotrack2_(&(t->npoint),dzin,dxout,dyout,dthxout,dthyout,dtlout,dal,&ifail); |
dotrack2_(&(t->npoint),dzin,dxout,dyout,dthxout,dthyout,dtlout,dal,&ifail); |
210 |
|
|
211 |
for (int i=0; i<t->npoint; i++){ |
for (int i=0; i<t->npoint; i++){ |
245 |
return def; |
return def; |
246 |
}; |
}; |
247 |
// |
// |
248 |
Float_t TrkTrack::GetDEDX(){ |
/** |
249 |
Float_t dedx=0; |
* Method to retrieve the dE/dx measured on a tracker view. |
250 |
for(Int_t i=0; i<6; i++)dedx+=dedx_x[i]*xgood[i]+dedx_y[i]*ygood[i]; |
* @param ip plane (0-5) |
251 |
dedx = dedx/(this->GetNX()+this->GetNY()); |
* @param iv view (0=x 1=y) |
252 |
return dedx; |
*/ |
253 |
|
Float_t TrkTrack::GetDEDX(int ip, int iv){ |
254 |
|
if(iv==0 && ip>=0 && ip<6)return fabs(dedx_x[ip]); |
255 |
|
else if(iv==1 && ip>=0 && ip<6)return fabs(dedx_y[ip]); |
256 |
|
else { |
257 |
|
cout << "TrkTrack::GetDEDX(int ip, int iv) -- wrong input parameters "<<ip<<iv<<endl; |
258 |
|
return 0.; |
259 |
|
} |
260 |
|
} |
261 |
|
/** |
262 |
|
* Method to evaluate the dE/dx measured on a tracker plane. |
263 |
|
* The two measurements on x- and y-view are averaged. |
264 |
|
* @param ip plane (0-5) |
265 |
|
*/ |
266 |
|
Float_t TrkTrack::GetDEDX(int ip){ |
267 |
|
if( (Int_t)XGood(ip)+(Int_t)YGood(ip) == 0 ) return 0; |
268 |
|
return (GetDEDX(ip,0)+GetDEDX(ip,1))/((Int_t)XGood(ip)+(Int_t)YGood(ip)); |
269 |
}; |
}; |
270 |
|
|
271 |
|
/** |
272 |
|
* Method to evaluate the dE/dx averaged over all planes. |
273 |
|
*/ |
274 |
|
Float_t TrkTrack::GetDEDX(){ |
275 |
|
Float_t dedx=0; |
276 |
|
for(Int_t ip=0; ip<6; ip++)dedx+=GetDEDX(ip,0)*XGood(ip)+GetDEDX(ip,1)*YGood(ip); |
277 |
|
dedx = dedx/(GetNX()+GetNY()); |
278 |
|
return dedx; |
279 |
|
}; |
280 |
|
/** |
281 |
|
* Returns 1 if the cluster on a tracker view includes bad strips. |
282 |
|
* @param ip plane (0-5) |
283 |
|
* @param iv view (0=x 1=y) |
284 |
|
*/ |
285 |
|
Bool_t TrkTrack::IsBad(int ip,int iv){ |
286 |
|
if(iv==0 && ip>=0 && ip<6)return (xgood[ip]<0) ; |
287 |
|
else if(iv==1 && ip>=0 && ip<6)return (ygood[ip]<0) ; |
288 |
|
else { |
289 |
|
cout << "TrkTrack::IsBad(int ip, int iv) -- wrong input parameters "<<ip<<iv<<endl; |
290 |
|
return 0.; |
291 |
|
} |
292 |
|
}; |
293 |
|
/** |
294 |
|
* Returns 1 if the signal on a tracker view is saturated. |
295 |
|
* @param ip plane (0-5) |
296 |
|
* @param iv view (0=x 1=y) |
297 |
|
*/ |
298 |
|
Bool_t TrkTrack::IsSaturated(int ip,int iv){ |
299 |
|
if(iv==0 && ip>=0 && ip<6)return (dedx_x[ip]<0) ; |
300 |
|
else if(iv==1 && ip>=0 && ip<6)return (dedx_y[ip]<0) ; |
301 |
|
else { |
302 |
|
cout << "TrkTrack::IsSaturated(int ip, int iv) -- wrong input parameters "<<ip<<iv<<endl; |
303 |
|
return 0.; |
304 |
|
} |
305 |
|
}; |
306 |
|
/** |
307 |
|
* Returns 1 if either the x or the y signal on a tracker plane is saturated. |
308 |
|
* @param ip plane (0-5) |
309 |
|
*/ |
310 |
|
Bool_t TrkTrack::IsSaturated(int ip){ |
311 |
|
return (IsSaturated(ip,0)||IsSaturated(ip,1)); |
312 |
|
}; |
313 |
|
/** |
314 |
|
* Returns 1 if there is at least a saturated signal along the track. |
315 |
|
*/ |
316 |
|
Bool_t TrkTrack::IsSaturated(){ |
317 |
|
for(int ip=0; ip<6; ip++)for(int iv=0; iv<2; iv++)if(IsSaturated(ip,iv))return true; |
318 |
|
return false; |
319 |
|
} |
320 |
|
/** |
321 |
|
* Returns the track "lever-arm" on the x view, defined as the distance (in planes) between |
322 |
|
* the upper and lower x measurements (the maximum value of lever-arm is 6). |
323 |
|
*/ |
324 |
|
Int_t TrkTrack::GetLeverArmX(){ |
325 |
|
int first_plane = -1; |
326 |
|
int last_plane = -1; |
327 |
|
for(Int_t ip=0; ip<6; ip++){ |
328 |
|
if( XGood(ip) && first_plane == -1 )first_plane = ip; |
329 |
|
if( XGood(ip) && first_plane != -1 )last_plane = ip; |
330 |
|
} |
331 |
|
if( first_plane == -1 || last_plane == -1){ |
332 |
|
cout<< "Int_t TrkTrack::GetLeverArmX() -- XGood(ip) always false ??? "<<endl; |
333 |
|
return 0; |
334 |
|
} |
335 |
|
return (last_plane-first_plane+1); |
336 |
|
} |
337 |
|
/** |
338 |
|
* Returns the track "lever-arm" on the y view, defined as the distance (in planes) between |
339 |
|
* the upper and lower y measurements (the maximum value of lever-arm is 6). |
340 |
|
*/ |
341 |
|
Int_t TrkTrack::GetLeverArmY(){ |
342 |
|
int first_plane = -1; |
343 |
|
int last_plane = -1; |
344 |
|
for(Int_t ip=0; ip<6; ip++){ |
345 |
|
if( YGood(ip) && first_plane == -1 )first_plane = ip; |
346 |
|
if( YGood(ip) && first_plane != -1 )last_plane = ip; |
347 |
|
} |
348 |
|
if( first_plane == -1 || last_plane == -1){ |
349 |
|
cout<< "Int_t TrkTrack::GetLeverArmY() -- YGood(ip) always false ??? "<<endl; |
350 |
|
return 0; |
351 |
|
} |
352 |
|
return (last_plane-first_plane+1); |
353 |
|
} |
354 |
//-------------------------------------- |
//-------------------------------------- |
355 |
// |
// |
356 |
// |
// |
357 |
//-------------------------------------- |
//-------------------------------------- |
358 |
void TrkTrack::Dump(){ |
void TrkTrack::Dump(){ |
359 |
cout << endl << "========== Track " ; |
cout << endl << "========== Track " ; |
360 |
|
cout << endl << "seq. n. : "<< seqno; |
361 |
|
cout << endl << "image n. : "<< image; |
362 |
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] << " "; |
363 |
cout << endl << "chi^2 : "<< chi2; |
cout << endl << "chi^2 : "<< chi2; |
364 |
cout << endl << "xgood : "; for(int i=0; i<6; i++)cout << xgood[i] ; |
cout << endl << "n.step : "<< nstep; |
365 |
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) ; |
366 |
|
cout << endl << "ygood : "; for(int i=0; i<6; i++)cout << YGood(i) ; |
367 |
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] << " "; |
368 |
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] << " "; |
369 |
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] << " "; |
370 |
|
cout << endl << "xv : "; for(int i=0; i<6; i++)cout << xv[i] << " "; |
371 |
|
cout << endl << "yv : "; for(int i=0; i<6; i++)cout << yv[i] << " "; |
372 |
|
cout << endl << "zv : "; for(int i=0; i<6; i++)cout << zv[i] << " "; |
373 |
|
cout << endl << "resx : "; for(int i=0; i<6; i++)cout << resx[i] << " "; |
374 |
|
cout << endl << "resy : "; for(int i=0; i<6; i++)cout << resy[i] << " "; |
375 |
|
cout << endl << "coval : "; for(int i=0; i<5; i++)cout << coval[0][i]<<" "; |
376 |
|
cout << endl << " "; for(int i=0; i<5; i++)cout << coval[1][i]<<" "; |
377 |
|
cout << endl << " "; for(int i=0; i<5; i++)cout << coval[2][i]<<" "; |
378 |
|
cout << endl << " "; for(int i=0; i<5; i++)cout << coval[3][i]<<" "; |
379 |
|
cout << endl << " "; for(int i=0; i<5; i++)cout << coval[4][i]<<" "; |
380 |
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] << " "; |
381 |
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] << " "; |
382 |
|
cout << endl; |
383 |
|
} |
384 |
|
/** |
385 |
|
* Set the TrkTrack position measurements |
386 |
|
*/ |
387 |
|
void TrkTrack::SetMeasure(double *xmeas, double *ymeas, double *zmeas){ |
388 |
|
for(int i=0; i<6; i++) xm[i]=*xmeas++; |
389 |
|
for(int i=0; i<6; i++) ym[i]=*ymeas++; |
390 |
|
for(int i=0; i<6; i++) zm[i]=*zmeas++; |
391 |
|
} |
392 |
|
/** |
393 |
|
* Set the TrkTrack position resolution |
394 |
|
*/ |
395 |
|
void TrkTrack::SetResolution(double *rx, double *ry){ |
396 |
|
for(int i=0; i<6; i++) resx[i]=*rx++; |
397 |
|
for(int i=0; i<6; i++) resy[i]=*ry++; |
398 |
|
} |
399 |
|
/** |
400 |
|
* Set the TrkTrack good measurement |
401 |
|
*/ |
402 |
|
void TrkTrack::SetGood(int *xg, int *yg){ |
403 |
|
// NB! si perdera` l'informazione sul numero del cluster |
404 |
|
for(int i=0; i<6; i++) xgood[i]=*xg++; |
405 |
|
for(int i=0; i<6; i++) ygood[i]=*yg++; |
406 |
|
} |
407 |
|
|
408 |
|
/** |
409 |
|
* Load the magnetic field |
410 |
|
*/ |
411 |
|
void TrkTrack::LoadField(TString path){ |
412 |
|
|
413 |
|
// strcpy(path_.path,path.Data()); |
414 |
|
// path_.pathlen = path.Length(); |
415 |
|
// path_.error = 0; |
416 |
|
// readb_(); |
417 |
|
|
418 |
|
TrkParams::Set(path,1); |
419 |
|
TrkParams::Load(1); |
420 |
|
|
421 |
|
}; |
422 |
|
|
423 |
|
|
424 |
|
/** |
425 |
|
* Method to fill minimization-routine common |
426 |
|
*/ |
427 |
|
void TrkTrack::FillMiniStruct(cMini2track& track){ |
428 |
|
|
429 |
|
for(int i=0; i<6; i++){ |
430 |
|
|
431 |
|
// track.xgood[i]=xgood[i]; |
432 |
|
// track.ygood[i]=ygood[i]; |
433 |
|
track.xgood[i]=XGood(i); |
434 |
|
track.ygood[i]=YGood(i); |
435 |
|
|
436 |
|
track.xm[i]=xm[i]; |
437 |
|
track.ym[i]=ym[i]; |
438 |
|
track.zm[i]=zm[i]; |
439 |
|
|
440 |
|
// --- temporaneo ---------------------------- |
441 |
|
// andrebbe inserita la dimensione del sensore |
442 |
|
float segment = 100.; |
443 |
|
track.xm_a[i]=xm[i]; |
444 |
|
track.xm_b[i]=xm[i]; |
445 |
|
track.ym_a[i]=ym[i]; |
446 |
|
track.ym_b[i]=ym[i]; |
447 |
|
if( XGood(i) && !YGood(i) ){ |
448 |
|
track.ym_a[i] = track.ym_a[i]+segment; |
449 |
|
track.ym_b[i] = track.ym_b[i]-segment; |
450 |
|
}else if( !XGood(i) && YGood(i)){ |
451 |
|
track.xm_a[i] = track.xm_a[i]+segment; |
452 |
|
track.xm_b[i] = track.xm_b[i]-segment; |
453 |
|
} |
454 |
|
// --- temporaneo ---------------------------- |
455 |
|
|
456 |
|
track.resx[i]=resx[i]; |
457 |
|
track.resy[i]=resy[i]; |
458 |
|
} |
459 |
|
|
460 |
|
for(int i=0; i<5; i++) track.al[i]=al[i]; |
461 |
|
track.zini = 23.5; |
462 |
|
// ZINI = 23.5 !!! it should be the same parameter in all codes |
463 |
|
|
464 |
} |
} |
465 |
|
/** |
466 |
|
* Method to set values from minimization-routine common |
467 |
|
*/ |
468 |
|
void TrkTrack::SetFromMiniStruct(cMini2track *track){ |
469 |
|
|
470 |
|
for(int i=0; i<5; i++) { |
471 |
|
al[i]=track->al[i]; |
472 |
|
for(int j=0; j<5; j++) coval[i][j]=track->cov[i][j]; |
473 |
|
} |
474 |
|
chi2 = track->chi2; |
475 |
|
nstep = track->nstep; |
476 |
|
for(int i=0; i<6; i++){ |
477 |
|
xv[i] = track->xv[i]; |
478 |
|
yv[i] = track->yv[i]; |
479 |
|
zv[i] = track->zv[i]; |
480 |
|
xm[i] = track->xm[i]; |
481 |
|
ym[i] = track->ym[i]; |
482 |
|
zm[i] = track->zm[i]; |
483 |
|
axv[i] = track->axv[i]; |
484 |
|
ayv[i] = track->ayv[i]; |
485 |
|
} |
486 |
|
|
487 |
|
} |
488 |
|
/** |
489 |
|
* Tracking method. It calls F77 mini routine. |
490 |
|
*/ |
491 |
|
void TrkTrack::Fit(double pfixed, int& fail, int iprint){ |
492 |
|
|
493 |
|
float al_ini[] = {0.,0.,0.,0.,0.}; |
494 |
|
|
495 |
|
extern cMini2track track_; |
496 |
|
fail = 0; |
497 |
|
FillMiniStruct(track_); |
498 |
|
|
499 |
|
// if fit variables have been reset, evaluate the initial guess |
500 |
|
if(al[0]==-9999.&&al[1]==-9999.&&al[2]==-9999.&&al[3]==-9999.&&al[4]==-9999.)guess_(); |
501 |
|
|
502 |
|
// --------------------- free momentum |
503 |
|
if(pfixed==0.) { |
504 |
|
track_.pfixed=0.; |
505 |
|
} |
506 |
|
// --------------------- fixed momentum |
507 |
|
if(pfixed!=0.) { |
508 |
|
al[4]=1./pfixed; |
509 |
|
track_.pfixed=pfixed; |
510 |
|
} |
511 |
|
|
512 |
|
// store temporarily the initial guess |
513 |
|
for(int i=0; i<5; i++) al_ini[i]=track_.al[i]; |
514 |
|
|
515 |
|
// ------------------------------------------ |
516 |
|
// call mini routine |
517 |
|
TrkParams::Load(1); |
518 |
|
if( !TrkParams::IsLoaded(1) ){ |
519 |
|
cout << "void TrkTrack::Fit(double pfixed, int& fail, int iprint) --- ERROR --- m.field not loaded"<<endl; |
520 |
|
return; |
521 |
|
} |
522 |
|
int istep=0; |
523 |
|
int ifail=0; |
524 |
|
mini2_(&istep,&ifail, &iprint); |
525 |
|
if(ifail!=0) { |
526 |
|
if(iprint)cout << "ERROR: ifail= " << ifail << endl; |
527 |
|
fail = 1; |
528 |
|
} |
529 |
|
// ------------------------------------------ |
530 |
|
|
531 |
|
SetFromMiniStruct(&track_); |
532 |
|
// cout << endl << "eta ===> " << track_.al[4] << endl; |
533 |
|
|
534 |
|
// for(int i=0; i<5; i++) al[i]=track_.al[i]; |
535 |
|
// chi2=track_.chi2; |
536 |
|
// nstep=track_.nstep; |
537 |
|
// for(int i=0; i<6; i++) xv[i]=track_.xv[i]; |
538 |
|
// for(int i=0; i<6; i++) yv[i]=track_.yv[i]; |
539 |
|
// for(int i=0; i<6; i++) zv[i]=track_.zv[i]; |
540 |
|
// for(int i=0; i<6; i++) axv[i]=track_.axv[i]; |
541 |
|
// for(int i=0; i<6; i++) ayv[i]=track_.ayv[i]; |
542 |
|
// for(int i=0; i<5; i++) { |
543 |
|
// for(int j=0; j<5; j++) coval[i][j]=track_.cov[i][j]; |
544 |
|
// } |
545 |
|
|
546 |
|
if(fail){ |
547 |
|
if(iprint)cout << " >>>> fit failed >>>> drawing initial par"<<endl; |
548 |
|
for(int i=0; i<5; i++) al[i]=al_ini[i]; |
549 |
|
} |
550 |
|
|
551 |
|
}; |
552 |
|
/* |
553 |
|
* Reset the fit parameters |
554 |
|
*/ |
555 |
|
void TrkTrack::FitReset(){ |
556 |
|
for(int i=0; i<5; i++) al[i]=-9999.; |
557 |
|
chi2=0.; |
558 |
|
nstep=0; |
559 |
|
for(int i=0; i<6; i++) xv[i]=0.; |
560 |
|
for(int i=0; i<6; i++) yv[i]=0.; |
561 |
|
for(int i=0; i<6; i++) zv[i]=0.; |
562 |
|
for(int i=0; i<6; i++) axv[i]=0.; |
563 |
|
for(int i=0; i<6; i++) ayv[i]=0.; |
564 |
|
for(int i=0; i<5; i++) { |
565 |
|
for(int j=0; j<5; j++) coval[i][j]=0.; |
566 |
|
} |
567 |
|
} |
568 |
|
/* |
569 |
|
* Set the tracking mode |
570 |
|
*/ |
571 |
|
void TrkTrack::SetTrackingMode(int trackmode){ |
572 |
|
extern cMini2track track_; |
573 |
|
track_.trackmode = trackmode; |
574 |
|
} |
575 |
|
/* |
576 |
|
* Set the factor scale for tracking precision |
577 |
|
*/ |
578 |
|
void TrkTrack::SetPrecisionFactor(double fact){ |
579 |
|
extern cMini2track track_; |
580 |
|
track_.fact = fact; |
581 |
|
} |
582 |
|
/* |
583 |
|
* Set the factor scale for tracking precision |
584 |
|
*/ |
585 |
|
void TrkTrack::SetStepMin(int istepmin){ |
586 |
|
extern cMini2track track_; |
587 |
|
track_.istepmin = istepmin; |
588 |
|
} |
589 |
|
|
590 |
|
|
591 |
|
/* |
592 |
|
* Method to retrieve ID (0,1,...) of x-cluster (if any) associated to this track. |
593 |
|
* If no cluster is associated, ID=-1. |
594 |
|
* @param ip Tracker plane (0-5) |
595 |
|
*/ |
596 |
|
Int_t TrkTrack::GetClusterX_ID(int ip){ |
597 |
|
return ((Int_t)fabs(xgood[ip]))%10000000-1; |
598 |
|
}; |
599 |
|
/* |
600 |
|
* Method to retrieve ID (0-xxx) of y-cluster (if any) associated to this track. |
601 |
|
* If no cluster is associated, ID=-1. |
602 |
|
* @param ip Tracker plane (0-5) |
603 |
|
*/ |
604 |
|
Int_t TrkTrack::GetClusterY_ID(int ip){ |
605 |
|
return ((Int_t)fabs(ygood[ip]))%10000000-1; |
606 |
|
}; |
607 |
|
/* |
608 |
|
* Method to retrieve the ladder (0-4, increasing x) traversed by the track on this plane. |
609 |
|
* If no ladder is traversed (dead area) the metod retuns -1. |
610 |
|
* @param ip Tracker plane (0-5) |
611 |
|
*/ |
612 |
|
Int_t TrkTrack::GetLadder(int ip){ |
613 |
|
if(XGood(ip))return (Int_t)fabs(xgood[ip]/100000000)-1; |
614 |
|
if(YGood(ip))return (Int_t)fabs(ygood[ip]/100000000)-1; |
615 |
|
return -1; |
616 |
|
}; |
617 |
|
/* |
618 |
|
* Method to retrieve the sensor (0-1, increasing y) traversed by the track on this plane. |
619 |
|
* If no sensor is traversed (dead area) the metod retuns -1. |
620 |
|
* @param ip Tracker plane (0-5) |
621 |
|
*/ |
622 |
|
Int_t TrkTrack::GetSensor(int ip){ |
623 |
|
if(XGood(ip))return (Int_t)((Int_t)fabs(xgood[ip]/10000000)%10)-1; |
624 |
|
if(YGood(ip))return (Int_t)((Int_t)fabs(ygood[ip]/10000000)%10)-1; |
625 |
|
return -1; |
626 |
|
}; |
627 |
|
|
628 |
|
|
629 |
|
//-------------------------------------- |
630 |
|
// |
631 |
|
// |
632 |
|
//-------------------------------------- |
633 |
|
void TrkTrack::Clear(){ |
634 |
|
// cout << "TrkTrack::Clear()"<<endl; |
635 |
|
seqno = -1; |
636 |
|
image = -1; |
637 |
|
chi2 = 0; |
638 |
|
nstep = 0; |
639 |
|
for(int it1=0;it1<5;it1++){ |
640 |
|
al[it1] = 0; |
641 |
|
for(int it2=0;it2<5;it2++)coval[it1][it2] = 0; |
642 |
|
}; |
643 |
|
for(int ip=0;ip<6;ip++){ |
644 |
|
xgood[ip] = 0; |
645 |
|
ygood[ip] = 0; |
646 |
|
xm[ip] = 0; |
647 |
|
ym[ip] = 0; |
648 |
|
zm[ip] = 0; |
649 |
|
resx[ip] = 0; |
650 |
|
resy[ip] = 0; |
651 |
|
tailx[ip] = 0; |
652 |
|
taily[ip] = 0; |
653 |
|
xv[ip] = 0; |
654 |
|
yv[ip] = 0; |
655 |
|
zv[ip] = 0; |
656 |
|
axv[ip] = 0; |
657 |
|
ayv[ip] = 0; |
658 |
|
dedx_x[ip] = 0; |
659 |
|
dedx_y[ip] = 0; |
660 |
|
|
661 |
|
}; |
662 |
|
// if(clx)clx->Clear(); |
663 |
|
// if(cly)cly->Clear(); |
664 |
|
// clx.Clear(); |
665 |
|
// cly.Clear(); |
666 |
|
}; |
667 |
|
//-------------------------------------- |
668 |
|
// |
669 |
|
// |
670 |
|
//-------------------------------------- |
671 |
|
void TrkTrack::Delete(){ |
672 |
|
// cout << "TrkTrack::Delete()"<<endl; |
673 |
|
Clear(); |
674 |
|
// if(clx)delete clx; |
675 |
|
// if(cly)delete cly; |
676 |
|
}; |
677 |
|
//-------------------------------------- |
678 |
|
// |
679 |
|
// |
680 |
|
//-------------------------------------- |
681 |
|
|
682 |
//-------------------------------------- |
//-------------------------------------- |
683 |
// |
// |
684 |
// |
// |
685 |
//-------------------------------------- |
//-------------------------------------- |
686 |
TrkSinglet::TrkSinglet(){ |
TrkSinglet::TrkSinglet(){ |
687 |
|
// cout << "TrkSinglet::TrkSinglet() " << GetUniqueID()<<endl; |
688 |
plane = 0; |
plane = 0; |
689 |
coord[0] = 0; |
coord[0] = 0; |
690 |
coord[1] = 0; |
coord[1] = 0; |
691 |
sgnl = 0; |
sgnl = 0; |
692 |
|
// cls = 0; |
693 |
}; |
}; |
694 |
//-------------------------------------- |
//-------------------------------------- |
695 |
// |
// |
696 |
// |
// |
697 |
//-------------------------------------- |
//-------------------------------------- |
698 |
TrkSinglet::TrkSinglet(const TrkSinglet& s){ |
TrkSinglet::TrkSinglet(const TrkSinglet& s){ |
699 |
|
// cout << "TrkSinglet::TrkSinglet(const TrkSinglet& s) " << GetUniqueID()<<endl; |
700 |
plane = s.plane; |
plane = s.plane; |
701 |
coord[0] = s.coord[0]; |
coord[0] = s.coord[0]; |
702 |
coord[1] = s.coord[1]; |
coord[1] = s.coord[1]; |
703 |
sgnl = s.sgnl; |
sgnl = s.sgnl; |
704 |
|
// cls = 0;//<<<<pointer |
705 |
|
// cls = TRef(s.cls); |
706 |
}; |
}; |
707 |
//-------------------------------------- |
//-------------------------------------- |
708 |
// |
// |
719 |
// |
// |
720 |
// |
// |
721 |
//-------------------------------------- |
//-------------------------------------- |
722 |
|
void TrkSinglet::Clear(){ |
723 |
|
// cout << "TrkSinglet::Clear() " << GetUniqueID()<<endl; |
724 |
|
// cls=0; |
725 |
|
plane=-1; |
726 |
|
coord[0]=-999; |
727 |
|
coord[1]=-999; |
728 |
|
sgnl=0; |
729 |
|
|
730 |
|
} |
731 |
|
//-------------------------------------- |
732 |
|
// |
733 |
|
// |
734 |
|
//-------------------------------------- |
735 |
TrkLevel2::TrkLevel2(){ |
TrkLevel2::TrkLevel2(){ |
736 |
good2 = -1; |
// cout <<"TrkLevel2::TrkLevel2()"<<endl; |
737 |
for(Int_t i=0; i<12 ; i++){ |
for(Int_t i=0; i<12 ; i++){ |
738 |
crc[i] = -1; |
good[i] = -1; |
739 |
|
VKmask[i] = 0; |
740 |
|
VKflag[i] = 0; |
741 |
}; |
}; |
742 |
Track = new TClonesArray("TrkTrack"); |
Track = 0; |
743 |
SingletX = new TClonesArray("TrkSinglet"); |
SingletX = 0; |
744 |
SingletY = new TClonesArray("TrkSinglet"); |
SingletY = 0; |
745 |
// Track = 0; |
|
746 |
// Singlet = 0; |
} |
747 |
// SingletY = 0; |
//-------------------------------------- |
748 |
|
// |
749 |
|
// |
750 |
|
//-------------------------------------- |
751 |
|
void TrkLevel2::Set(){ |
752 |
|
if(!Track)Track = new TClonesArray("TrkTrack"); |
753 |
|
if(!SingletX)SingletX = new TClonesArray("TrkSinglet"); |
754 |
|
if(!SingletY)SingletY = new TClonesArray("TrkSinglet"); |
755 |
} |
} |
756 |
//-------------------------------------- |
//-------------------------------------- |
757 |
// |
// |
758 |
// |
// |
759 |
//-------------------------------------- |
//-------------------------------------- |
760 |
void TrkLevel2::Dump(){ |
void TrkLevel2::Dump(){ |
761 |
TClonesArray &t = *Track; |
|
762 |
TClonesArray &sx = *SingletX; |
// |
|
TClonesArray &sy = *SingletY; |
|
|
|
|
763 |
cout << endl << endl << "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"; |
cout << endl << endl << "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"; |
764 |
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]; |
|
765 |
cout << endl << "ntrk() : " << this->ntrk() ; |
cout << endl << "ntrk() : " << this->ntrk() ; |
766 |
cout << endl << "nclsx() : " << this->nclsx(); |
cout << endl << "nclsx() : " << this->nclsx(); |
767 |
cout << endl << "nclsy() : " << this->nclsy(); |
cout << endl << "nclsy() : " << this->nclsy(); |
768 |
for(int i=0; i<this->ntrk(); i++) ((TrkTrack *)t[i])->Dump(); |
if(Track){ |
769 |
for(int i=0; i<this->nclsx(); i++) ((TrkSinglet *)sx[i])->Dump(); |
TClonesArray &t = *Track; |
770 |
for(int i=0; i<this->nclsy(); i++) ((TrkSinglet *)sy[i])->Dump(); |
for(int i=0; i<ntrk(); i++) ((TrkTrack *)t[i])->Dump(); |
771 |
|
} |
772 |
|
if(SingletX){ |
773 |
|
TClonesArray &sx = *SingletX; |
774 |
|
for(int i=0; i<nclsx(); i++) ((TrkSinglet *)sx[i])->Dump(); |
775 |
|
} |
776 |
|
if(SingletY){ |
777 |
|
TClonesArray &sy = *SingletY; |
778 |
|
for(int i=0; i<nclsy(); i++) ((TrkSinglet *)sy[i])->Dump(); |
779 |
|
} |
780 |
|
} |
781 |
|
//-------------------------------------- |
782 |
|
// |
783 |
|
// |
784 |
|
//-------------------------------------- |
785 |
|
/** |
786 |
|
* The method returns false if the viking-chip was masked |
787 |
|
* either apriori ,on the basis of the mask read from the DB, |
788 |
|
* or run-by-run, on the basis of the calibration parameters) |
789 |
|
* @param iv Tracker view (0-11) |
790 |
|
* @param ivk Viking-chip number (0-23) |
791 |
|
*/ |
792 |
|
Bool_t TrkLevel2::GetVKMask(int iv, int ivk){ |
793 |
|
Int_t whichbit = (Int_t)pow(2,ivk); |
794 |
|
return (whichbit&VKmask[iv])!=0; |
795 |
|
} |
796 |
|
/** |
797 |
|
* The method returns false if the viking-chip was masked |
798 |
|
* for this event due to common-noise computation failure. |
799 |
|
* @param iv Tracker view (0-11) |
800 |
|
* @param ivk Viking-chip number (0-23) |
801 |
|
*/ |
802 |
|
Bool_t TrkLevel2::GetVKFlag(int iv, int ivk){ |
803 |
|
Int_t whichbit = (Int_t)pow(2,ivk); |
804 |
|
return (whichbit&VKflag[iv])!=0; |
805 |
} |
} |
806 |
|
/** |
807 |
|
* The method returns true if the viking-chip was masked, either |
808 |
|
* forced (see TrkLevel2::GetVKMask(int,int)) or |
809 |
|
* for this event only (TrkLevel2::GetVKFlag(int,int)). |
810 |
|
* @param iv Tracker view (0-11) |
811 |
|
* @param ivk Viking-chip number (0-23) |
812 |
|
*/ |
813 |
|
Bool_t TrkLevel2::IsMaskedVK(int iv, int ivk){ |
814 |
|
return !(GetVKMask(iv,ivk)&&GetVKFlag(iv,ivk) ); |
815 |
|
}; |
816 |
|
|
817 |
//-------------------------------------- |
//-------------------------------------- |
818 |
// |
// |
819 |
// |
// |
820 |
//-------------------------------------- |
//-------------------------------------- |
821 |
/** |
/** |
822 |
* 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). |
823 |
|
* Ref to Level1 data (clusters) is also set. If l1==NULL no references are set. |
824 |
|
* (NB It make sense to set references only if events are stored in a tree that contains also the Level1 branch) |
825 |
*/ |
*/ |
826 |
void TrkLevel2::FillCommonVar(cTrkLevel2 *l2){ |
void TrkLevel2::SetFromLevel2Struct(cTrkLevel2 *l2, TrkLevel1 *l1){ |
827 |
// |
|
828 |
// Track = new TClonesArray("TrkTrack"); |
// cout << "void TrkLevel2::SetFromLevel2Struct(cTrkLevel2 *l2, TrkLevel1 *l1)"<<endl; |
829 |
// SingletX = new TClonesArray("TrkSinglet"); |
Clear(); |
830 |
// SingletY = new TClonesArray("TrkSinglet"); |
|
831 |
// temporary objects: |
// temporary objects: |
832 |
TrkSinglet* t_singlet = new TrkSinglet(); |
TrkSinglet* t_singlet = new TrkSinglet(); |
833 |
TrkTrack* t_track = new TrkTrack(); |
TrkTrack* t_track = new TrkTrack(); |
834 |
|
|
835 |
|
// ----------------- |
836 |
// general variables |
// general variables |
837 |
good2 = l2->good2; |
// ----------------- |
838 |
for(Int_t i=0; i<12 ; i++){ |
for(Int_t i=0; i<12 ; i++){ |
839 |
crc[i] = l2->crc[i]; |
good[i] = l2->good[i]; |
840 |
|
VKmask[i]=0; |
841 |
|
VKflag[i]=0; |
842 |
|
for(Int_t ii=0; ii<24 ; ii++){ |
843 |
|
Int_t setbit = (Int_t)pow(2,ii); |
844 |
|
if( l2->vkflag[ii][i]!=-1 )VKmask[i]=VKmask[i]|setbit; |
845 |
|
if( l2->vkflag[ii][i]!=0 )VKflag[i]=VKflag[i]|setbit; |
846 |
|
}; |
847 |
}; |
}; |
848 |
|
// -------------- |
849 |
// *** TRACKS *** |
// *** TRACKS *** |
850 |
|
// -------------- |
851 |
|
if(!Track) Track = new TClonesArray("TrkTrack"); |
852 |
TClonesArray &t = *Track; |
TClonesArray &t = *Track; |
853 |
|
|
854 |
for(int i=0; i<l2->ntrk; i++){ |
for(int i=0; i<l2->ntrk; i++){ |
855 |
t_track->seqno = i; |
t_track->seqno = i;// NBNBNBNB deve sempre essere = i |
856 |
t_track->image = l2->image[i]-1; |
t_track->image = l2->image[i]-1; |
|
// cout << "track "<<i<<t_track->seqno << t_track->image<<endl; |
|
857 |
t_track->chi2 = l2->chi2_nt[i]; |
t_track->chi2 = l2->chi2_nt[i]; |
858 |
|
t_track->nstep = l2->nstep_nt[i]; |
859 |
for(int it1=0;it1<5;it1++){ |
for(int it1=0;it1<5;it1++){ |
860 |
t_track->al[it1] = l2->al_nt[i][it1]; |
t_track->al[it1] = l2->al_nt[i][it1]; |
861 |
for(int it2=0;it2<5;it2++) |
for(int it2=0;it2<5;it2++) |
862 |
t_track->coval[it1][it2] = l2->coval[i][it2][it1]; |
t_track->coval[it1][it2] = l2->coval[i][it2][it1]; |
863 |
}; |
}; |
864 |
for(int ip=0;ip<6;ip++){ |
for(int ip=0;ip<6;ip++){ |
865 |
t_track->xgood[ip] = l2->xgood_nt[i][ip]; |
// --------------------------------- |
866 |
t_track->ygood[ip] = l2->ygood_nt[i][ip]; |
// new implementation of xgood/ygood |
867 |
|
// --------------------------------- |
868 |
|
t_track->xgood[ip] = l2->cltrx[i][ip]; //cluster ID |
869 |
|
t_track->ygood[ip] = l2->cltry[i][ip]; //cluster ID |
870 |
|
t_track->xgood[ip] += 10000000*l2->ls[i][ip]; // ladder+sensor |
871 |
|
t_track->ygood[ip] += 10000000*l2->ls[i][ip]; // ladder+sensor |
872 |
|
if(l2->xbad[i][ip]>0)t_track->xgood[ip]=-t_track->xgood[ip]; |
873 |
|
if(l2->ybad[i][ip]>0)t_track->ygood[ip]=-t_track->ygood[ip]; |
874 |
|
// if(l2->xbad[i][ip]>0 || l2->ybad[i][ip]>0){ |
875 |
|
// if(l2->dedx_x[i][ip]<0 || l2->dedx_y[i][ip]<0){ |
876 |
|
// cout << ip << " - "<< l2->cltrx[i][ip] << " "<<l2->cltry[i][ip]<<" "<<l2->ls[i][ip]<<endl; |
877 |
|
// cout << ip << " - "<<t_track->xgood[ip]<<" "<<t_track->ygood[ip]<<endl; |
878 |
|
// cout << ip << " - "<<t_track->GetClusterX_ID(ip)<<" "<<t_track->GetClusterY_ID(ip)<<" "<<t_track->GetLadder(ip)<<" "<<t_track->GetSensor(ip)<<endl; |
879 |
|
// cout << ip << " - "<<t_track->BadClusterX(ip)<<" "<<t_track->BadClusterY(ip)<<endl; |
880 |
|
// cout << ip << " - "<<t_track->SaturatedClusterX(ip)<<" "<<t_track->SaturatedClusterY(ip)<<endl; |
881 |
|
// } |
882 |
t_track->xm[ip] = l2->xm_nt[i][ip]; |
t_track->xm[ip] = l2->xm_nt[i][ip]; |
883 |
t_track->ym[ip] = l2->ym_nt[i][ip]; |
t_track->ym[ip] = l2->ym_nt[i][ip]; |
884 |
t_track->zm[ip] = l2->zm_nt[i][ip]; |
t_track->zm[ip] = l2->zm_nt[i][ip]; |
885 |
t_track->resx[ip] = l2->resx_nt[i][ip]; |
t_track->resx[ip] = l2->resx_nt[i][ip]; |
886 |
t_track->resy[ip] = l2->resy_nt[i][ip]; |
t_track->resy[ip] = l2->resy_nt[i][ip]; |
887 |
|
t_track->tailx[ip] = l2->tailx[i][ip]; |
888 |
|
t_track->taily[ip] = l2->taily[i][ip]; |
889 |
t_track->xv[ip] = l2->xv_nt[i][ip]; |
t_track->xv[ip] = l2->xv_nt[i][ip]; |
890 |
t_track->yv[ip] = l2->yv_nt[i][ip]; |
t_track->yv[ip] = l2->yv_nt[i][ip]; |
891 |
t_track->zv[ip] = l2->zv_nt[i][ip]; |
t_track->zv[ip] = l2->zv_nt[i][ip]; |
893 |
t_track->ayv[ip] = l2->ayv_nt[i][ip]; |
t_track->ayv[ip] = l2->ayv_nt[i][ip]; |
894 |
t_track->dedx_x[ip] = l2->dedx_x[i][ip]; |
t_track->dedx_x[ip] = l2->dedx_x[i][ip]; |
895 |
t_track->dedx_y[ip] = l2->dedx_y[i][ip]; |
t_track->dedx_y[ip] = l2->dedx_y[i][ip]; |
896 |
|
//----------------------------------------------------- |
897 |
|
//----------------------------------------------------- |
898 |
|
//----------------------------------------------------- |
899 |
|
//----------------------------------------------------- |
900 |
}; |
}; |
901 |
|
// if(t_track->IsSaturated())t_track->Dump(); |
902 |
new(t[i]) TrkTrack(*t_track); |
new(t[i]) TrkTrack(*t_track); |
903 |
t_track->Clear(); |
t_track->Clear(); |
904 |
}; |
}; |
905 |
|
|
906 |
|
// ---------------- |
907 |
// *** SINGLETS *** |
// *** SINGLETS *** |
908 |
|
// ---------------- |
909 |
|
if(!SingletX)SingletX = new TClonesArray("TrkSinglet"); |
910 |
TClonesArray &sx = *SingletX; |
TClonesArray &sx = *SingletX; |
911 |
for(int i=0; i<l2->nclsx; i++){ |
for(int i=0; i<l2->nclsx; i++){ |
912 |
t_singlet->plane = l2->planex[i]; |
t_singlet->plane = l2->planex[i]; |
913 |
t_singlet->coord[0] = l2->xs[i][0]; |
t_singlet->coord[0] = l2->xs[i][0]; |
914 |
t_singlet->coord[1] = l2->xs[i][1]; |
t_singlet->coord[1] = l2->xs[i][1]; |
915 |
t_singlet->sgnl = l2->signlxs[i]; |
t_singlet->sgnl = l2->signlxs[i]; |
916 |
|
//----------------------------------------------------- |
917 |
|
// if(l1) t_singlet->cls = l1->GetCluster(l2->clsx[i]-1); |
918 |
|
//----------------------------------------------------- |
919 |
new(sx[i]) TrkSinglet(*t_singlet); |
new(sx[i]) TrkSinglet(*t_singlet); |
920 |
t_singlet->Clear(); |
t_singlet->Clear(); |
921 |
} |
} |
922 |
|
if(!SingletY)SingletY = new TClonesArray("TrkSinglet"); |
923 |
TClonesArray &sy = *SingletY; |
TClonesArray &sy = *SingletY; |
924 |
for(int i=0; i<l2->nclsy; i++){ |
for(int i=0; i<l2->nclsy; i++){ |
925 |
t_singlet->plane = l2->planey[i]; |
t_singlet->plane = l2->planey[i]; |
926 |
t_singlet->coord[0] = l2->ys[i][0]; |
t_singlet->coord[0] = l2->ys[i][0]; |
927 |
t_singlet->coord[1] = l2->ys[i][1]; |
t_singlet->coord[1] = l2->ys[i][1]; |
928 |
t_singlet->sgnl = l2->signlys[i]; |
t_singlet->sgnl = l2->signlys[i]; |
929 |
|
//----------------------------------------------------- |
930 |
|
// if(l1) t_singlet->cls = l1->GetCluster(l2->clsy[i]-1); |
931 |
|
//----------------------------------------------------- |
932 |
new(sy[i]) TrkSinglet(*t_singlet); |
new(sy[i]) TrkSinglet(*t_singlet); |
933 |
t_singlet->Clear(); |
t_singlet->Clear(); |
934 |
}; |
}; |
935 |
|
|
936 |
delete t_track; |
delete t_track; |
937 |
delete t_singlet; |
delete t_singlet; |
938 |
|
} |
939 |
|
/** |
940 |
|
* Fills a struct cTrkLevel2 with values from a TrkLevel2 object (to put data into a F77 common). |
941 |
|
*/ |
942 |
|
|
943 |
|
void TrkLevel2::GetLevel2Struct(cTrkLevel2 *l2) const { |
944 |
|
|
945 |
|
// general variables |
946 |
|
// l2->good2 = good2 ; |
947 |
|
for(Int_t i=0; i<12 ; i++){ |
948 |
|
// l2->crc[i] = crc[i]; |
949 |
|
l2->good[i] = good[i]; |
950 |
|
}; |
951 |
|
// *** TRACKS *** |
952 |
|
|
953 |
|
if(Track){ |
954 |
|
l2->ntrk = Track->GetEntries(); |
955 |
|
for(Int_t i=0;i<l2->ntrk;i++){ |
956 |
|
l2->image[i] = 1 + ((TrkTrack *)Track->At(i))->image; |
957 |
|
l2->chi2_nt[i] = ((TrkTrack *)Track->At(i))->chi2; |
958 |
|
l2->nstep_nt[i] = ((TrkTrack *)Track->At(i))->nstep; |
959 |
|
for(int it1=0;it1<5;it1++){ |
960 |
|
l2->al_nt[i][it1] = ((TrkTrack *)Track->At(i))->al[it1]; |
961 |
|
for(int it2=0;it2<5;it2++) |
962 |
|
l2->coval[i][it2][it1] = ((TrkTrack *)Track->At(i))->coval[it1][it2]; |
963 |
|
}; |
964 |
|
for(int ip=0;ip<6;ip++){ |
965 |
|
l2->xgood_nt[i][ip] = ((TrkTrack *)Track->At(i))->XGood(ip); |
966 |
|
l2->ygood_nt[i][ip] = ((TrkTrack *)Track->At(i))->YGood(ip); |
967 |
|
l2->xm_nt[i][ip] = ((TrkTrack *)Track->At(i))->xm[ip]; |
968 |
|
l2->ym_nt[i][ip] = ((TrkTrack *)Track->At(i))->ym[ip]; |
969 |
|
l2->zm_nt[i][ip] = ((TrkTrack *)Track->At(i))->zm[ip]; |
970 |
|
l2->resx_nt[i][ip] = ((TrkTrack *)Track->At(i))->resx[ip]; |
971 |
|
l2->resy_nt[i][ip] = ((TrkTrack *)Track->At(i))->resy[ip]; |
972 |
|
l2->tailx[i][ip] = ((TrkTrack *)Track->At(i))->tailx[ip]; |
973 |
|
l2->taily[i][ip] = ((TrkTrack *)Track->At(i))->taily[ip]; |
974 |
|
l2->xv_nt[i][ip] = ((TrkTrack *)Track->At(i))->xv[ip]; |
975 |
|
l2->yv_nt[i][ip] = ((TrkTrack *)Track->At(i))->yv[ip]; |
976 |
|
l2->zv_nt[i][ip] = ((TrkTrack *)Track->At(i))->zv[ip]; |
977 |
|
l2->axv_nt[i][ip] = ((TrkTrack *)Track->At(i))->axv[ip]; |
978 |
|
l2->ayv_nt[i][ip] = ((TrkTrack *)Track->At(i))->ayv[ip]; |
979 |
|
l2->dedx_x[i][ip] = ((TrkTrack *)Track->At(i))->dedx_x[ip]; |
980 |
|
l2->dedx_y[i][ip] = ((TrkTrack *)Track->At(i))->dedx_y[ip]; |
981 |
|
}; |
982 |
|
} |
983 |
|
} |
984 |
|
// *** SINGLETS *** |
985 |
|
if(SingletX){ |
986 |
|
l2->nclsx = SingletX->GetEntries(); |
987 |
|
for(Int_t i=0;i<l2->nclsx;i++){ |
988 |
|
l2->planex[i] = ((TrkSinglet *)SingletX->At(i))->plane; |
989 |
|
l2->xs[i][0] = ((TrkSinglet *)SingletX->At(i))->coord[0]; |
990 |
|
l2->xs[i][1] = ((TrkSinglet *)SingletX->At(i))->coord[1]; |
991 |
|
l2->signlxs[i] = ((TrkSinglet *)SingletX->At(i))->sgnl; |
992 |
|
} |
993 |
|
} |
994 |
|
|
995 |
|
if(SingletY){ |
996 |
|
l2->nclsy = SingletY->GetEntries(); |
997 |
|
for(Int_t i=0;i<l2->nclsy;i++){ |
998 |
|
l2->planey[i] = ((TrkSinglet *)SingletY->At(i))->plane; |
999 |
|
l2->ys[i][0] = ((TrkSinglet *)SingletY->At(i))->coord[0]; |
1000 |
|
l2->ys[i][1] = ((TrkSinglet *)SingletY->At(i))->coord[1]; |
1001 |
|
l2->signlys[i] = ((TrkSinglet *)SingletY->At(i))->sgnl; |
1002 |
|
} |
1003 |
|
} |
1004 |
} |
} |
1005 |
//-------------------------------------- |
//-------------------------------------- |
1006 |
// |
// |
1007 |
// |
// |
1008 |
//-------------------------------------- |
//-------------------------------------- |
1009 |
void TrkLevel2::Clear(){ |
void TrkLevel2::Clear(){ |
|
good2 = -1; |
|
1010 |
for(Int_t i=0; i<12 ; i++){ |
for(Int_t i=0; i<12 ; i++){ |
1011 |
crc[i] = -1; |
good[i] = -1; |
1012 |
|
VKflag[i] = 0; |
1013 |
|
VKmask[i] = 0; |
1014 |
}; |
}; |
1015 |
/* Track->RemoveAll(); |
// if(Track)Track->Clear("C"); |
1016 |
SingletX->RemoveAll(); |
// if(SingletX)SingletX->Clear("C"); |
1017 |
SingletY->RemoveAll();*/ |
// if(SingletY)SingletY->Clear("C"); |
1018 |
// modify to avoid memory leakage |
if(Track)Track->Delete(); |
1019 |
Track->Clear(); |
if(SingletX)SingletX->Delete(); |
1020 |
SingletX->Clear(); |
if(SingletY)SingletY->Delete(); |
1021 |
SingletY->Clear(); |
} |
1022 |
|
// //-------------------------------------- |
1023 |
|
// // |
1024 |
|
// // |
1025 |
|
// //-------------------------------------- |
1026 |
|
void TrkLevel2::Delete(){ |
1027 |
|
|
1028 |
|
// cout << "void TrkLevel2::Delete()"<<endl; |
1029 |
|
Clear(); |
1030 |
|
if(Track)delete Track; |
1031 |
|
if(SingletX)delete SingletX; |
1032 |
|
if(SingletY)delete SingletY; |
1033 |
|
|
1034 |
} |
} |
1035 |
//-------------------------------------- |
//-------------------------------------- |
1036 |
// |
// |
1040 |
* 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). |
1041 |
* 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. |
1042 |
*/ |
*/ |
1043 |
TClonesArray *TrkLevel2::GetTracks(){ |
TRefArray *TrkLevel2::GetTracks_NFitSorted(){ |
|
TClonesArray *sorted = GetTracks_NFitSorted(); |
|
|
return sorted; |
|
|
}; |
|
|
|
|
|
TClonesArray *TrkLevel2::GetTracks_Chi2Sorted(){ |
|
|
|
|
|
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; |
|
1044 |
|
|
1045 |
int indo=0; |
if(!Track)return 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(){ |
|
1046 |
|
|
1047 |
TClonesArray *sorted = new TClonesArray("TrkTrack"); |
TRefArray *sorted = new TRefArray(); |
1048 |
TClonesArray &t = *Track; |
|
1049 |
TClonesArray &ts = *sorted; |
TClonesArray &t = *Track; |
1050 |
int N=this->ntrk(); |
// TClonesArray &ts = *PhysicalTrack; |
1051 |
|
int N = ntrk(); |
1052 |
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; |
1053 |
|
// int m[50]; for(int i=0; i<N; i++)m[i]=1; |
1054 |
|
|
1055 |
int indo=0; |
int indo=0; |
1056 |
int indi=0; |
int indi=0; |
1057 |
while(N != 0){ |
while(N > 0){ |
1058 |
|
// while(N != 0){ |
1059 |
int nfit =0; |
int nfit =0; |
1060 |
float chi2ref=1000000; |
float chi2ref = numeric_limits<float>::max(); |
1061 |
|
|
1062 |
// first loop to search maximum num. of fit points |
// first loop to search maximum num. of fit points |
1063 |
for(int i=0; i<this->ntrk(); i++){ |
for(int i=0; i < ntrk(); i++){ |
1064 |
if( ((TrkTrack *)t[i])->GetNtot() >= nfit && m[i]==1){ |
if( ((TrkTrack *)t[i])->GetNtot() >= nfit && m[i]==1){ |
1065 |
nfit = ((TrkTrack *)t[i])->GetNtot(); |
nfit = ((TrkTrack *)t[i])->GetNtot(); |
|
// cout << "1** "<<i<< " " << nfit<<endl; |
|
1066 |
} |
} |
1067 |
} |
} |
1068 |
//second loop to search minimum chi2 among selected |
//second loop to search minimum chi2 among selected |
1069 |
for(int i=0; i<this->ntrk(); i++){ |
for(int i=0; i<ntrk(); i++){ |
1070 |
if( ((TrkTrack *)t[i])->chi2 < chi2ref |
Float_t chi2 = ((TrkTrack *)t[i])->chi2; |
1071 |
&& ((TrkTrack *)t[i])->GetNtot()== nfit |
if(chi2 < 0) chi2 = -chi2*1000; |
1072 |
&& m[i]==1){ |
if( chi2 < chi2ref |
1073 |
|
&& ((TrkTrack *)t[i])->GetNtot() == nfit |
1074 |
|
&& m[i]==1){ |
1075 |
chi2ref = ((TrkTrack *)t[i])->chi2; |
chi2ref = ((TrkTrack *)t[i])->chi2; |
1076 |
indi = i; |
indi = i; |
1077 |
// cout << "2** "<<i<< " " << nfit <<" "<<chi2ref<<endl; |
}; |
1078 |
} |
}; |
|
} |
|
1079 |
if( ((TrkTrack *)t[indi])->HasImage() ){ |
if( ((TrkTrack *)t[indi])->HasImage() ){ |
1080 |
m[((TrkTrack *)t[indi])->image] = 0; |
m[((TrkTrack *)t[indi])->image] = 0; |
1081 |
N--; |
N--; |
1082 |
|
|
|
// Int_t nfiti=((TrkTrack *)t[((TrkTrack *)t[indi])->image ])->GetNtot(); |
|
|
// Float_t chi2i=((TrkTrack *)t[((TrkTrack *)t[indi])->image ])->chi2; |
|
|
|
|
1083 |
// cout << "i** "<< ((TrkTrack *)t[indi])->image << " " << nfiti <<" "<<chi2i<<endl; |
// cout << "i** "<< ((TrkTrack *)t[indi])->image << " " << nfiti <<" "<<chi2i<<endl; |
1084 |
} |
}; |
1085 |
new(ts[indo]) TrkTrack(*(TrkTrack*)t[indi]); |
sorted->Add( (TrkTrack*)t[indi] ); |
1086 |
|
|
1087 |
m[indi] = 0; |
m[indi] = 0; |
1088 |
|
// cout << "SORTED "<< indo << " "<< indi << " "<< N << " "<<((TrkTrack *)t[indi])->image<<" "<<chi2ref<<endl; |
1089 |
N--; |
N--; |
1090 |
indo++; |
indo++; |
1091 |
} |
} |
1092 |
|
m.clear(); |
1093 |
|
// cout << "GetTracks_NFitSorted(it): Done"<< endl; |
1094 |
|
|
1095 |
return sorted; |
return sorted; |
1096 |
|
// return PhysicalTrack; |
1097 |
} |
} |
1098 |
//-------------------------------------- |
//-------------------------------------- |
1099 |
// |
// |
1111 |
cout << " Stored tracks ntrk() = "<< this->ntrk() << endl; |
cout << " Stored tracks ntrk() = "<< this->ntrk() << endl; |
1112 |
return 0; |
return 0; |
1113 |
} |
} |
1114 |
|
if(!Track){ |
1115 |
|
cout << "TrkTrack *TrkLevel2::GetStoredTrack(int is) >> (TClonesArray*) Track ==0 "<<endl; |
1116 |
|
}; |
1117 |
TClonesArray &t = *(Track); |
TClonesArray &t = *(Track); |
1118 |
TrkTrack *track = (TrkTrack*)t[is]; |
TrkTrack *track = (TrkTrack*)t[is]; |
1119 |
return track; |
return track; |
1123 |
// |
// |
1124 |
//-------------------------------------- |
//-------------------------------------- |
1125 |
/** |
/** |
1126 |
|
* Retrieves the is-th stored X singlet. |
1127 |
|
* @param it Singlet number, ranging from 0 to nclsx(). |
1128 |
|
*/ |
1129 |
|
TrkSinglet *TrkLevel2::GetSingletX(int is){ |
1130 |
|
|
1131 |
|
if(is >= this->nclsx()){ |
1132 |
|
cout << "** TrkLevel2 ** Singlet "<< is << "doen not exits! " << endl; |
1133 |
|
cout << " Stored x-singlets nclsx() = "<< this->nclsx() << endl; |
1134 |
|
return 0; |
1135 |
|
} |
1136 |
|
if(!SingletX)return 0; |
1137 |
|
TClonesArray &t = *(SingletX); |
1138 |
|
TrkSinglet *singlet = (TrkSinglet*)t[is]; |
1139 |
|
return singlet; |
1140 |
|
} |
1141 |
|
//-------------------------------------- |
1142 |
|
// |
1143 |
|
// |
1144 |
|
//-------------------------------------- |
1145 |
|
/** |
1146 |
|
* Retrieves the is-th stored Y singlet. |
1147 |
|
* @param it Singlet number, ranging from 0 to nclsx(). |
1148 |
|
*/ |
1149 |
|
TrkSinglet *TrkLevel2::GetSingletY(int is){ |
1150 |
|
|
1151 |
|
if(is >= this->nclsy()){ |
1152 |
|
cout << "** TrkLevel2 ** Singlet "<< is << "doen not exits! " << endl; |
1153 |
|
cout << " Stored y-singlets nclsy() = "<< this->nclsx() << endl; |
1154 |
|
return 0; |
1155 |
|
} |
1156 |
|
if(!SingletY)return 0; |
1157 |
|
TClonesArray &t = *(SingletY); |
1158 |
|
TrkSinglet *singlet = (TrkSinglet*)t[is]; |
1159 |
|
return singlet; |
1160 |
|
} |
1161 |
|
//-------------------------------------- |
1162 |
|
// |
1163 |
|
// |
1164 |
|
//-------------------------------------- |
1165 |
|
/** |
1166 |
* Retrieves the it-th "physical" track, sorted by the method GetNTracks(). |
* Retrieves the it-th "physical" track, sorted by the method GetNTracks(). |
1167 |
* @param it Track number, ranging from 0 to GetNTracks(). |
* @param it Track number, ranging from 0 to GetNTracks(). |
1168 |
*/ |
*/ |
1169 |
|
|
1170 |
TrkTrack *TrkLevel2::GetTrack(int it){ |
TrkTrack *TrkLevel2::GetTrack(int it){ |
1171 |
|
|
1172 |
if(it >= this->GetNTracks()){ |
if(it >= this->GetNTracks()){ |
1173 |
cout << "** TrkLevel2 ** Track "<< it << "does not exits! " << endl; |
cout << "** TrkLevel2 ** Track "<< it << "does not exits! " << endl; |
1174 |
cout << " Physical tracks GetNTracks() = "<< this->ntrk() << endl; |
cout << " Physical tracks GetNTracks() = "<< this->ntrk() << endl; |
1175 |
return 0; |
return 0; |
1176 |
} |
} |
1177 |
TrkTrack *track = (TrkTrack*)(*(this->GetTracks()))[it]; |
|
1178 |
GetTracks()->Delete();////TEMPORANEO |
TRefArray *sorted = GetTracks(); //TEMPORANEO |
1179 |
return track; |
if(!sorted)return 0; |
1180 |
|
TrkTrack *track = (TrkTrack*)sorted->At(it); |
1181 |
|
sorted->Clear(); |
1182 |
|
delete sorted; |
1183 |
|
return track; |
1184 |
} |
} |
1185 |
|
/** |
1186 |
|
* Give the number of "physical" tracks, sorted by the method GetTracks(). |
1187 |
|
*/ |
1188 |
Int_t TrkLevel2::GetNTracks(){ |
Int_t TrkLevel2::GetNTracks(){ |
1189 |
Int_t ntot=0; |
|
1190 |
ntot = GetTracks()->GetEntries(); |
Float_t ntot=0; |
1191 |
GetTracks()->Delete();////TEMPORANEO |
if(!Track)return 0; |
1192 |
return ntot; |
TClonesArray &t = *Track; |
1193 |
|
for(int i=0; i<ntrk(); i++) { |
1194 |
|
if( ((TrkTrack *)t[i])->GetImageSeqNo() == -1 ) ntot+=1.; |
1195 |
|
else ntot+=0.5; |
1196 |
|
} |
1197 |
|
return (Int_t)ntot; |
1198 |
|
|
1199 |
}; |
}; |
1200 |
//-------------------------------------- |
//-------------------------------------- |
1201 |
// |
// |
1212 |
cout << " Physical tracks GetNTracks() = "<< this->ntrk() << endl; |
cout << " Physical tracks GetNTracks() = "<< this->ntrk() << endl; |
1213 |
return 0; |
return 0; |
1214 |
} |
} |
1215 |
TrkTrack *track = (TrkTrack*)(*(this->GetTracks()))[it]; |
|
1216 |
|
TRefArray* sorted = GetTracks(); //TEMPORANEO |
1217 |
|
if(!sorted)return 0; |
1218 |
|
TrkTrack *track = (TrkTrack*)sorted->At(it); |
1219 |
|
|
1220 |
if(!track->HasImage()){ |
if(!track->HasImage()){ |
1221 |
cout << "** TrkLevel2 ** Track "<< it << "does not have image! " << endl; |
cout << "** TrkLevel2 ** Track "<< it << "does not have image! " << endl; |
1222 |
return 0; |
return 0; |
1223 |
} |
} |
1224 |
|
if(!Track)return 0; |
1225 |
TrkTrack *image = (TrkTrack*)(*Track)[track->image]; |
TrkTrack *image = (TrkTrack*)(*Track)[track->image]; |
1226 |
|
|
1227 |
|
sorted->Delete(); |
1228 |
|
delete sorted; |
1229 |
|
|
1230 |
return image; |
return image; |
1231 |
|
|
1232 |
} |
} |
1238 |
* Loads the magnetic field. |
* Loads the magnetic field. |
1239 |
* @param s Path of the magnetic-field files. |
* @param s Path of the magnetic-field files. |
1240 |
*/ |
*/ |
1241 |
void TrkLevel2::LoadField(TString s){ |
void TrkLevel2::LoadField(TString path){ |
1242 |
readb_(s.Data()); |
// |
1243 |
|
// strcpy(path_.path,path.Data()); |
1244 |
|
// path_.pathlen = path.Length(); |
1245 |
|
// path_.error = 0; |
1246 |
|
// readb_(); |
1247 |
|
|
1248 |
|
TrkParams::Set(path,1); |
1249 |
|
TrkParams::Load(1); |
1250 |
|
|
1251 |
|
// |
1252 |
|
}; |
1253 |
|
/** |
1254 |
|
* Get BY (kGauss) |
1255 |
|
* @param v (x,y,z) coordinates in cm |
1256 |
|
*/ |
1257 |
|
float TrkLevel2::GetBX(float* v){ |
1258 |
|
float b[3]; |
1259 |
|
gufld_(v,b); |
1260 |
|
return b[0]/10.; |
1261 |
|
} |
1262 |
|
/** |
1263 |
|
* Get BY (kGauss) |
1264 |
|
* @param v (x,y,z) coordinates in cm |
1265 |
|
*/ |
1266 |
|
float TrkLevel2::GetBY(float* v){ |
1267 |
|
float b[3]; |
1268 |
|
gufld_(v,b); |
1269 |
|
return b[1]/10.; |
1270 |
|
} |
1271 |
|
/** |
1272 |
|
* Get BY (kGauss) |
1273 |
|
* @param v (x,y,z) coordinates in cm |
1274 |
|
*/ |
1275 |
|
float TrkLevel2::GetBZ(float* v){ |
1276 |
|
float b[3]; |
1277 |
|
gufld_(v,b); |
1278 |
|
return b[2]/10.; |
1279 |
|
} |
1280 |
|
//-------------------------------------- |
1281 |
|
// |
1282 |
|
// |
1283 |
|
//-------------------------------------- |
1284 |
|
/** |
1285 |
|
* Get tracker-plane (mechanical) z-coordinate |
1286 |
|
* @param plane_id plane index (1=TOP,2,3,4,5,6=BOTTOM) |
1287 |
|
*/ |
1288 |
|
Float_t TrkLevel2::GetZTrk(Int_t plane_id){ |
1289 |
|
switch(plane_id){ |
1290 |
|
case 1: return ZTRK1; |
1291 |
|
case 2: return ZTRK2; |
1292 |
|
case 3: return ZTRK3; |
1293 |
|
case 4: return ZTRK4; |
1294 |
|
case 5: return ZTRK5; |
1295 |
|
case 6: return ZTRK6; |
1296 |
|
default: return 0.; |
1297 |
|
}; |
1298 |
}; |
}; |
1299 |
//-------------------------------------- |
//-------------------------------------- |
1300 |
// |
// |
1312 |
thx = new float[npoint]; |
thx = new float[npoint]; |
1313 |
thy = new float[npoint]; |
thy = new float[npoint]; |
1314 |
tl = new float[npoint]; |
tl = new float[npoint]; |
1315 |
float dz = ((ZTRKUP)-(ZTRKDW))/(npoint-1); |
float dz = ((ZTRK1)-(ZTRK6))/(npoint-1); |
1316 |
for(int i=0; i<npoint; i++){ |
for(int i=0; i<npoint; i++){ |
1317 |
x[i] = 0; |
x[i] = 0; |
1318 |
y[i] = 0; |
y[i] = 0; |
1319 |
z[i] = (ZTRKUP) - i*dz; |
z[i] = (ZTRK1) - i*dz; |
1320 |
thx[i] = 0; |
thx[i] = 0; |
1321 |
thy[i] = 0; |
thy[i] = 0; |
1322 |
tl[i] = 0; |
tl[i] = 0; |
1343 |
thx = new float[npoint]; |
thx = new float[npoint]; |
1344 |
thy = new float[npoint]; |
thy = new float[npoint]; |
1345 |
tl = new float[npoint]; |
tl = new float[npoint]; |
1346 |
float dz = ((ZTRKUP)-(ZTRKDW))/(npoint-1); |
float dz = ((ZTRK1)-(ZTRK6))/(npoint-1); |
1347 |
for(int i=0; i<npoint; i++){ |
for(int i=0; i<npoint; i++){ |
1348 |
x[i] = 0; |
x[i] = 0; |
1349 |
y[i] = 0; |
y[i] = 0; |
1350 |
z[i] = (ZTRKUP) - i*dz; |
z[i] = (ZTRK1) - i*dz; |
1351 |
thx[i] = 0; |
thx[i] = 0; |
1352 |
thy[i] = 0; |
thy[i] = 0; |
1353 |
tl[i] = 0; |
tl[i] = 0; |
1384 |
npoint=i; |
npoint=i; |
1385 |
if(npoint != n)cout << "NB! Trajectory created with "<<npoint<<" points"<<endl; |
if(npoint != n)cout << "NB! Trajectory created with "<<npoint<<" points"<<endl; |
1386 |
} |
} |
1387 |
|
void Trajectory::Delete(){ |
1388 |
|
|
1389 |
|
if(x) delete [] x; |
1390 |
|
if(y) delete [] y; |
1391 |
|
if(z) delete [] z; |
1392 |
|
if(thx) delete [] thx; |
1393 |
|
if(thy) delete [] thy; |
1394 |
|
if(tl) delete [] tl; |
1395 |
|
|
1396 |
|
} |
1397 |
//-------------------------------------- |
//-------------------------------------- |
1398 |
// |
// |
1399 |
// |
// |
1431 |
return l; |
return l; |
1432 |
|
|
1433 |
} |
} |
1434 |
|
|
1435 |
|
/** |
1436 |
|
* Evaluates the trajectory in the apparatus associated to the track. |
1437 |
|
* 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. |
1438 |
|
* @param t pointer to an object of the class Trajectory, |
1439 |
|
* which z coordinates should be previously initialized by calling the proper constructor ( Trajectory::Trajectory(int n, float* zin) ). |
1440 |
|
* @return error flag. |
1441 |
|
*/ |
1442 |
|
int Trajectory::DoTrack2(float* al){ |
1443 |
|
|
1444 |
|
double *dxout = new double[npoint]; |
1445 |
|
double *dyout = new double[npoint]; |
1446 |
|
double *dthxout = new double[npoint]; |
1447 |
|
double *dthyout = new double[npoint]; |
1448 |
|
double *dtlout = new double[npoint]; |
1449 |
|
double *dzin = new double[npoint]; |
1450 |
|
double dal[5]; |
1451 |
|
|
1452 |
|
int ifail = 0; |
1453 |
|
|
1454 |
|
for (int i=0; i<5; i++) dal[i] = (double)al[i]; |
1455 |
|
for (int i=0; i<npoint; i++) dzin[i] = (double)z[i]; |
1456 |
|
|
1457 |
|
TrkParams::Load(1); |
1458 |
|
if( !TrkParams::IsLoaded(1) ){ |
1459 |
|
cout << "int Trajectory::DoTrack2(float* al) --- ERROR --- m.field not loaded"<<endl; |
1460 |
|
return 0; |
1461 |
|
} |
1462 |
|
dotrack2_(&(npoint),dzin,dxout,dyout,dthxout,dthyout,dtlout,dal,&ifail); |
1463 |
|
|
1464 |
|
for (int i=0; i<npoint; i++){ |
1465 |
|
x[i] = (float)*dxout++; |
1466 |
|
y[i] = (float)*dyout++; |
1467 |
|
thx[i] = (float)*dthxout++; |
1468 |
|
thy[i] = (float)*dthyout++; |
1469 |
|
tl[i] = (float)*dtlout++; |
1470 |
|
} |
1471 |
|
|
1472 |
|
return ifail; |
1473 |
|
}; |
1474 |
|
|
1475 |
ClassImp(TrkLevel2); |
ClassImp(TrkLevel2); |
1476 |
ClassImp(TrkSinglet); |
ClassImp(TrkSinglet); |
1477 |
ClassImp(TrkTrack); |
ClassImp(TrkTrack); |