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; |
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 |
}; |
multmaxx[ip] = 0; |
56 |
clx = new TRefArray(6,0); |
multmaxy[ip] = 0; |
57 |
cly = new TRefArray(6,0); |
seedx[ip] = 0; |
58 |
|
seedy[ip] = 0; |
59 |
|
xpu[ip] = 0; |
60 |
|
ypu[ip] = 0; |
61 |
|
|
62 |
|
}; |
63 |
|
|
64 |
|
// TrkParams::SetTrackingMode(); |
65 |
|
// TrkParams::SetPrecisionFactor(); |
66 |
|
// TrkParams::SetStepMin(); |
67 |
|
TrkParams::SetMiniDefault(); |
68 |
|
TrkParams::SetPFA(); |
69 |
|
|
70 |
|
int ngf = TrkParams::nGF; |
71 |
|
for(int i=0; i<ngf; i++){ |
72 |
|
xGF[i] = 0.; |
73 |
|
yGF[i] = 0.; |
74 |
|
} |
75 |
|
|
76 |
|
|
77 |
}; |
}; |
78 |
//-------------------------------------- |
//-------------------------------------- |
79 |
// |
// |
83 |
seqno = t.seqno; |
seqno = t.seqno; |
84 |
image = t.image; |
image = t.image; |
85 |
chi2 = t.chi2; |
chi2 = t.chi2; |
86 |
nstep = t.nstep; |
nstep = t.nstep; |
87 |
for(int it1=0;it1<5;it1++){ |
for(int it1=0;it1<5;it1++){ |
88 |
al[it1] = t.al[it1]; |
al[it1] = t.al[it1]; |
89 |
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]; |
90 |
}; |
}; |
91 |
for(int ip=0;ip<6;ip++){ |
for(int ip=0;ip<6;ip++){ |
92 |
xgood[ip] = t.xgood[ip]; |
xgood[ip] = t.xgood[ip]; |
93 |
ygood[ip] = t.ygood[ip]; |
ygood[ip] = t.ygood[ip]; |
94 |
xm[ip] = t.xm[ip]; |
xm[ip] = t.xm[ip]; |
95 |
ym[ip] = t.ym[ip]; |
ym[ip] = t.ym[ip]; |
96 |
zm[ip] = t.zm[ip]; |
zm[ip] = t.zm[ip]; |
97 |
resx[ip] = t.resx[ip]; |
resx[ip] = t.resx[ip]; |
98 |
resy[ip] = t.resy[ip]; |
resy[ip] = t.resy[ip]; |
99 |
xv[ip] = t.xv[ip]; |
tailx[ip] = t.tailx[ip]; |
100 |
yv[ip] = t.yv[ip]; |
taily[ip] = t.taily[ip]; |
101 |
zv[ip] = t.zv[ip]; |
xv[ip] = t.xv[ip]; |
102 |
axv[ip] = t.axv[ip]; |
yv[ip] = t.yv[ip]; |
103 |
ayv[ip] = t.ayv[ip]; |
zv[ip] = t.zv[ip]; |
104 |
dedx_x[ip] = t.dedx_x[ip]; |
axv[ip] = t.axv[ip]; |
105 |
dedx_y[ip] = t.dedx_y[ip]; |
ayv[ip] = t.ayv[ip]; |
106 |
// clx[ip] = 0;//<<<<pointer |
dedx_x[ip] = t.dedx_x[ip]; |
107 |
// cly[ip] = 0;//<<<<pointer |
dedx_y[ip] = t.dedx_y[ip]; |
108 |
}; |
multmaxx[ip] = t.multmaxx[ip]; |
109 |
clx = new TRefArray(*(t.clx)); |
multmaxy[ip] = t.multmaxy[ip]; |
110 |
cly = new TRefArray(*(t.cly)); |
seedx[ip] = t.seedx[ip]; |
111 |
|
seedy[ip] = t.seedy[ip]; |
112 |
|
xpu[ip] = t.xpu[ip]; |
113 |
|
ypu[ip] = t.ypu[ip]; |
114 |
|
}; |
115 |
|
|
116 |
|
// TrkParams::SetTrackingMode(); |
117 |
|
// TrkParams::SetPrecisionFactor(); |
118 |
|
// TrkParams::SetStepMin(); |
119 |
|
TrkParams::SetMiniDefault(); |
120 |
|
TrkParams::SetPFA(); |
121 |
|
|
122 |
|
int ngf = TrkParams::nGF; |
123 |
|
for(int i=0; i<ngf; i++){ |
124 |
|
xGF[i] = t.xGF[i]; |
125 |
|
yGF[i] = t.yGF[i]; |
126 |
|
} |
127 |
|
}; |
128 |
|
//-------------------------------------- |
129 |
|
// |
130 |
|
// |
131 |
|
//-------------------------------------- |
132 |
|
void TrkTrack::Copy(TrkTrack& t){ |
133 |
|
|
134 |
|
t.seqno = seqno; |
135 |
|
t.image = image; |
136 |
|
t.chi2 = chi2; |
137 |
|
t.nstep = nstep; |
138 |
|
for(int it1=0;it1<5;it1++){ |
139 |
|
t.al[it1] = al[it1]; |
140 |
|
for(int it2=0;it2<5;it2++)t.coval[it1][it2] = coval[it1][it2]; |
141 |
|
}; |
142 |
|
for(int ip=0;ip<6;ip++){ |
143 |
|
t.xgood[ip] = xgood[ip]; |
144 |
|
t.ygood[ip] = ygood[ip]; |
145 |
|
t.xm[ip] = xm[ip]; |
146 |
|
t.ym[ip] = ym[ip]; |
147 |
|
t.zm[ip] = zm[ip]; |
148 |
|
t.resx[ip] = resx[ip]; |
149 |
|
t.resy[ip] = resy[ip]; |
150 |
|
t.tailx[ip] = tailx[ip]; |
151 |
|
t.taily[ip] = taily[ip]; |
152 |
|
t.xv[ip] = xv[ip]; |
153 |
|
t.yv[ip] = yv[ip]; |
154 |
|
t.zv[ip] = zv[ip]; |
155 |
|
t.axv[ip] = axv[ip]; |
156 |
|
t.ayv[ip] = ayv[ip]; |
157 |
|
t.dedx_x[ip] = dedx_x[ip]; |
158 |
|
t.dedx_y[ip] = dedx_y[ip]; |
159 |
|
t.multmaxx[ip] = multmaxx[ip]; |
160 |
|
t.multmaxy[ip] = multmaxy[ip]; |
161 |
|
t.seedx[ip] = seedx[ip]; |
162 |
|
t.seedy[ip] = seedy[ip]; |
163 |
|
t.xpu[ip] = xpu[ip]; |
164 |
|
t.ypu[ip] = ypu[ip]; |
165 |
|
|
166 |
|
}; |
167 |
|
int ngf = TrkParams::nGF; |
168 |
|
for(int i=0; i<ngf; i++){ |
169 |
|
t.xGF[i] = xGF[i]; |
170 |
|
t.yGF[i] = yGF[i]; |
171 |
|
} |
172 |
|
|
173 |
|
|
174 |
}; |
}; |
175 |
//-------------------------------------- |
//-------------------------------------- |
176 |
// |
// |
182 |
* @param t pointer to an object of the class Trajectory, |
* @param t pointer to an object of the class Trajectory, |
183 |
* which z coordinates should be previously initialized by calling the proper constructor ( Trajectory::Trajectory(int n, float* zin) ). |
* which z coordinates should be previously initialized by calling the proper constructor ( Trajectory::Trajectory(int n, float* zin) ). |
184 |
* @return error flag. |
* @return error flag. |
185 |
|
* |
186 |
|
* >>> OBSOLETE !!! use TrkTrack::DoTrack2(Trajectory* t) instead |
187 |
|
* |
188 |
*/ |
*/ |
189 |
int TrkTrack::DoTrack(Trajectory* t){ |
int TrkTrack::DoTrack(Trajectory* t){ |
190 |
|
|
191 |
|
cout << " int TrkTrack::DoTrack(Trajectory* t) --->> OBSOLETE !!! "<<endl; |
192 |
|
cout << " use int TrkTrack::DoTrack2(Trajectory* t)"<<endl; |
193 |
|
|
194 |
double *dxout = new double[t->npoint]; |
double *dxout = new double[t->npoint]; |
195 |
double *dyout = new double[t->npoint]; |
double *dyout = new double[t->npoint]; |
196 |
double *dzin = new double[t->npoint]; |
double *dzin = new double[t->npoint]; |
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::DoTrack(Trajectory* t) --- ERROR --- m.field not loaded"<<endl; |
207 |
|
return 0; |
208 |
|
} |
209 |
dotrack_(&(t->npoint),dzin,dxout,dyout,dal,&ifail); |
dotrack_(&(t->npoint),dzin,dxout,dyout,dal,&ifail); |
210 |
|
|
211 |
for (int i=0; i<t->npoint; i++){ |
for (int i=0; i<t->npoint; i++){ |
212 |
t->x[i] = (float)*dxout++; |
t->x[i] = (float)*(dxout+i); |
213 |
t->y[i] = (float)*dyout++; |
t->y[i] = (float)*(dyout+i); |
214 |
} |
} |
215 |
|
|
216 |
// delete [] dxout; |
delete [] dxout; |
217 |
// delete [] dyout; |
delete [] dyout; |
218 |
// delete [] dzin; |
delete [] dzin; |
219 |
|
|
220 |
return ifail; |
return ifail; |
221 |
}; |
}; |
245 |
for (int i=0; i<5; i++) dal[i] = (double)al[i]; |
for (int i=0; i<5; i++) dal[i] = (double)al[i]; |
246 |
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]; |
247 |
|
|
248 |
|
TrkParams::Load(1); |
249 |
|
if( !TrkParams::IsLoaded(1) ){ |
250 |
|
cout << "int TrkTrack::DoTrack2(Trajectory* t) --- ERROR --- m.field not loaded"<<endl; |
251 |
|
return 0; |
252 |
|
} |
253 |
dotrack2_(&(t->npoint),dzin,dxout,dyout,dthxout,dthyout,dtlout,dal,&ifail); |
dotrack2_(&(t->npoint),dzin,dxout,dyout,dthxout,dthyout,dtlout,dal,&ifail); |
254 |
|
|
255 |
for (int i=0; i<t->npoint; i++){ |
for (int i=0; i<t->npoint; i++){ |
256 |
t->x[i] = (float)*dxout++; |
t->x[i] = (float)*(dxout+i); |
257 |
t->y[i] = (float)*dyout++; |
t->y[i] = (float)*(dyout+i); |
258 |
t->thx[i] = (float)*dthxout++; |
t->thx[i] = (float)*(dthxout+i); |
259 |
t->thy[i] = (float)*dthyout++; |
t->thy[i] = (float)*(dthyout+i); |
260 |
t->tl[i] = (float)*dtlout++; |
t->tl[i] = (float)*(dtlout+i); |
261 |
} |
} |
262 |
|
|
263 |
// delete [] dxout; |
delete [] dxout; |
264 |
// delete [] dyout; |
delete [] dyout; |
265 |
// delete [] dzin; |
delete [] dzin; |
266 |
|
delete [] dthxout; |
267 |
|
delete [] dthyout; |
268 |
|
delete [] dtlout; |
269 |
|
|
270 |
return ifail; |
return ifail; |
271 |
}; |
}; |
292 |
return def; |
return def; |
293 |
}; |
}; |
294 |
// |
// |
295 |
|
/** |
296 |
|
* Method to retrieve the dE/dx measured on a tracker view. |
297 |
|
* @param ip plane (0-5) |
298 |
|
* @param iv view (0=x 1=y) |
299 |
|
*/ |
300 |
|
Float_t TrkTrack::GetDEDX(int ip, int iv){ |
301 |
|
if(iv==0 && ip>=0 && ip<6)return fabs(dedx_x[ip]); |
302 |
|
else if(iv==1 && ip>=0 && ip<6)return fabs(dedx_y[ip]); |
303 |
|
else { |
304 |
|
cout << "TrkTrack::GetDEDX(int ip, int iv) -- wrong input parameters "<<ip<<iv<<endl; |
305 |
|
return 0.; |
306 |
|
} |
307 |
|
} |
308 |
|
/** |
309 |
|
* Method to evaluate the dE/dx measured on a tracker plane. |
310 |
|
* The two measurements on x- and y-view are averaged. |
311 |
|
* @param ip plane (0-5) |
312 |
|
*/ |
313 |
|
Float_t TrkTrack::GetDEDX(int ip){ |
314 |
|
if( (Int_t)XGood(ip)+(Int_t)YGood(ip) == 0 ) return 0; |
315 |
|
return (GetDEDX(ip,0)+GetDEDX(ip,1))/((Int_t)XGood(ip)+(Int_t)YGood(ip)); |
316 |
|
}; |
317 |
|
|
318 |
|
/** |
319 |
|
* Method to evaluate the dE/dx averaged over all planes. |
320 |
|
*/ |
321 |
Float_t TrkTrack::GetDEDX(){ |
Float_t TrkTrack::GetDEDX(){ |
322 |
Float_t dedx=0; |
Float_t dedx=0; |
323 |
for(Int_t i=0; i<6; i++)dedx+=dedx_x[i]*xgood[i]+dedx_y[i]*ygood[i]; |
for(Int_t ip=0; ip<6; ip++)dedx+=GetDEDX(ip,0)*XGood(ip)+GetDEDX(ip,1)*YGood(ip); |
324 |
dedx = dedx/(this->GetNX()+this->GetNY()); |
dedx = dedx/(GetNX()+GetNY()); |
325 |
return dedx; |
return dedx; |
326 |
|
}; |
327 |
|
/** |
328 |
|
* Returns 1 if the cluster on a tracker view includes bad strips |
329 |
|
* (at least one bad strip among the four strip used by p.f.a.) |
330 |
|
* @param ip plane (0-5) |
331 |
|
* @param iv view (0=x 1=y) |
332 |
|
*/ |
333 |
|
Bool_t TrkTrack::IsBad(int ip,int iv){ |
334 |
|
if(iv==0 && ip>=0 && ip<6)return (xgood[ip]<0) ; |
335 |
|
else if(iv==1 && ip>=0 && ip<6)return (ygood[ip]<0) ; |
336 |
|
else { |
337 |
|
cout << "TrkTrack::IsBad(int ip, int iv) -- wrong input parameters "<<ip<<iv<<endl; |
338 |
|
return 0.; |
339 |
|
} |
340 |
|
}; |
341 |
|
/** |
342 |
|
* Returns 1 if the signal on a tracker view is saturated. |
343 |
|
* @param ip plane (0-5) |
344 |
|
* @param iv view (0=x 1=y) |
345 |
|
*/ |
346 |
|
Bool_t TrkTrack::IsSaturated(int ip,int iv){ |
347 |
|
if(iv==0 && ip>=0 && ip<6)return (dedx_x[ip]<0) ; |
348 |
|
else if(iv==1 && ip>=0 && ip<6)return (dedx_y[ip]<0) ; |
349 |
|
else { |
350 |
|
cout << "TrkTrack::IsSaturated(int ip, int iv) -- wrong input parameters "<<ip<<iv<<endl; |
351 |
|
return 0.; |
352 |
|
} |
353 |
|
}; |
354 |
|
/** |
355 |
|
* Returns 1 if either the x or the y signal on a tracker plane is saturated. |
356 |
|
* @param ip plane (0-5) |
357 |
|
*/ |
358 |
|
Bool_t TrkTrack::IsSaturated(int ip){ |
359 |
|
return (IsSaturated(ip,0)||IsSaturated(ip,1)); |
360 |
|
}; |
361 |
|
/** |
362 |
|
* Returns 1 if there is at least a saturated signal along the track. |
363 |
|
*/ |
364 |
|
Bool_t TrkTrack::IsSaturated(){ |
365 |
|
for(int ip=0; ip<6; ip++)for(int iv=0; iv<2; iv++)if(IsSaturated(ip,iv))return true; |
366 |
|
return false; |
367 |
|
} |
368 |
|
/** |
369 |
|
* Returns the track "lever-arm" on the x view, defined as the distance (in planes) between |
370 |
|
* the upper and lower x measurements (the maximum value of lever-arm is 6). |
371 |
|
*/ |
372 |
|
Int_t TrkTrack::GetLeverArmX(){ |
373 |
|
int first_plane = -1; |
374 |
|
int last_plane = -1; |
375 |
|
for(Int_t ip=0; ip<6; ip++){ |
376 |
|
if( XGood(ip) && first_plane == -1 )first_plane = ip; |
377 |
|
if( XGood(ip) && first_plane != -1 )last_plane = ip; |
378 |
|
} |
379 |
|
if( first_plane == -1 || last_plane == -1){ |
380 |
|
cout<< "Int_t TrkTrack::GetLeverArmX() -- XGood(ip) always false ??? "<<endl; |
381 |
|
return 0; |
382 |
|
} |
383 |
|
return (last_plane-first_plane+1); |
384 |
|
} |
385 |
|
/** |
386 |
|
* Returns the track "lever-arm" on the y view, defined as the distance (in planes) between |
387 |
|
* the upper and lower y measurements (the maximum value of lever-arm is 6). |
388 |
|
*/ |
389 |
|
Int_t TrkTrack::GetLeverArmY(){ |
390 |
|
int first_plane = -1; |
391 |
|
int last_plane = -1; |
392 |
|
for(Int_t ip=0; ip<6; ip++){ |
393 |
|
if( YGood(ip) && first_plane == -1 )first_plane = ip; |
394 |
|
if( YGood(ip) && first_plane != -1 )last_plane = ip; |
395 |
|
} |
396 |
|
if( first_plane == -1 || last_plane == -1){ |
397 |
|
cout<< "Int_t TrkTrack::GetLeverArmY() -- YGood(ip) always false ??? "<<endl; |
398 |
|
return 0; |
399 |
|
} |
400 |
|
return (last_plane-first_plane+1); |
401 |
|
} |
402 |
|
/** |
403 |
|
* Returns the track "lever-arm" on the x+y view, defined as the distance (in planes) between |
404 |
|
* the upper and lower x,y (couple) measurements (the maximum value of lever-arm is 6). |
405 |
|
*/ |
406 |
|
Int_t TrkTrack::GetLeverArmXY(){ |
407 |
|
int first_plane = -1; |
408 |
|
int last_plane = -1; |
409 |
|
for(Int_t ip=0; ip<6; ip++){ |
410 |
|
if( XGood(ip)*YGood(ip) && first_plane == -1 )first_plane = ip; |
411 |
|
if( XGood(ip)*YGood(ip) && first_plane != -1 )last_plane = ip; |
412 |
|
} |
413 |
|
if( first_plane == -1 || last_plane == -1){ |
414 |
|
cout<< "Int_t TrkTrack::GetLeverArmXY() -- XGood(ip)*YGood(ip) always false ??? "<<endl; |
415 |
|
return 0; |
416 |
|
} |
417 |
|
return (last_plane-first_plane+1); |
418 |
|
} |
419 |
|
/** |
420 |
|
* Returns the reduced chi-square of track x-projection |
421 |
|
*/ |
422 |
|
Float_t TrkTrack::GetChi2X(){ |
423 |
|
float chiq=0; |
424 |
|
for(int ip=0; ip<6; ip++)if(XGood(ip))chiq+= pow((xv[ip]-xm[ip])/resx[ip],2.); |
425 |
|
if(GetNX()>3)chiq=chiq/(GetNX()-3); |
426 |
|
else chiq=0; |
427 |
|
if(chiq==0)cout << " Float_t TrkTrack::GetChi2X() -- WARNING -- value not defined "<<chiq<<endl; |
428 |
|
return chiq; |
429 |
|
} |
430 |
|
/** |
431 |
|
* Returns the reduced chi-square of track y-projection |
432 |
|
*/ |
433 |
|
Float_t TrkTrack::GetChi2Y(){ |
434 |
|
float chiq=0; |
435 |
|
for(int ip=0; ip<6; ip++)if(YGood(ip))chiq+= pow((yv[ip]-ym[ip])/resy[ip],2.); |
436 |
|
if(GetNY()>2)chiq=chiq/(GetNY()-2); |
437 |
|
else chiq=0; |
438 |
|
if(chiq==0)cout << " Float_t TrkTrack::GetChi2Y() -- WARNING -- value not defined "<<chiq<<endl; |
439 |
|
return chiq; |
440 |
|
} |
441 |
|
/** |
442 |
|
* Returns the logarythm of the likeliwood-function of track x-projection |
443 |
|
*/ |
444 |
|
Float_t TrkTrack::GetLnLX(){ |
445 |
|
float lnl=0; |
446 |
|
for(int ip=0; ip<6; ip++) |
447 |
|
if( XGood(ip) && tailx[ip]!=0 ) |
448 |
|
lnl += (tailx[ip]+1.) * log( (tailx[ip]*pow(resx[ip],2.) + pow(xv[ip]-xm[ip],2.)) / (tailx[ip]*pow(resx[ip],2)) ); |
449 |
|
if(GetNX()>3)lnl=lnl/(GetNX()-3); |
450 |
|
else lnl=0; |
451 |
|
if(lnl==0){ |
452 |
|
cout << " Float_t TrkTrack::GetLnLX() -- WARNING -- value not defined "<<lnl<<endl; |
453 |
|
Dump(); |
454 |
|
} |
455 |
|
return lnl; |
456 |
|
|
457 |
|
} |
458 |
|
/** |
459 |
|
* Returns the logarythm of the likeliwood-function of track y-projection |
460 |
|
*/ |
461 |
|
Float_t TrkTrack::GetLnLY(){ |
462 |
|
float lnl=0; |
463 |
|
for(int ip=0; ip<6; ip++) |
464 |
|
if( YGood(ip) && taily[ip]!=0 ) |
465 |
|
lnl += (taily[ip]+1.) * log( (taily[ip]*pow(resy[ip],2.) + pow(yv[ip]-ym[ip],2.)) / (taily[ip]*pow(resy[ip],2)) ); |
466 |
|
if(GetNY()>2)lnl=lnl/(GetNY()-2); |
467 |
|
else lnl=0; |
468 |
|
if(lnl==0){ |
469 |
|
cout << " Float_t TrkTrack::GetLnLY() -- WARNING -- value not defined "<<lnl<<endl; |
470 |
|
Dump(); |
471 |
|
} |
472 |
|
return lnl; |
473 |
|
|
474 |
|
} |
475 |
|
/** |
476 |
|
* Returns the effective angle, relative to the sensor, on each plane. |
477 |
|
* @param ip plane (0-5) |
478 |
|
* @param iv view (0=x 1=y) |
479 |
|
*/ |
480 |
|
Float_t TrkTrack::GetEffectiveAngle(int ip, int iv){ |
481 |
|
|
482 |
|
if(ip<0 || ip>5){ |
483 |
|
cout << "Float_t TrkTrack::GetEffectiveAngle(int "<<ip<<", int "<<iv<<") ==> wrong input"<<endl; |
484 |
|
return 0.; |
485 |
|
} |
486 |
|
|
487 |
|
float v[3]={xv[ip],yv[ip],zv[ip]}; |
488 |
|
//----------------------------------------- |
489 |
|
// effective angle (relative to the sensor) |
490 |
|
//----------------------------------------- |
491 |
|
float axv_geo = axv[ip]; |
492 |
|
float muhall_h = 297.61; //cm**2/Vs |
493 |
|
float BY = TrkParams::GetBY(v); |
494 |
|
float axv_eff = 0; |
495 |
|
if(ip==5) axv_geo = -1*axv_geo; |
496 |
|
if(ip==5) BY = -1*BY; |
497 |
|
axv_eff = 180.*atan( tan(axv_geo*acos(-1.)/180.) + muhall_h * BY * 0.0001)/acos(-1.); |
498 |
|
//----------------------------------------- |
499 |
|
// effective angle (relative to the sensor) |
500 |
|
//----------------------------------------- |
501 |
|
float ayv_geo = ayv[ip]; |
502 |
|
float muhall_e = 1258.18; //cm**2/Vs |
503 |
|
float BX = TrkParams::GetBX(v); |
504 |
|
float ayv_eff = 0; |
505 |
|
ayv_eff = 180.*atan( tan(ayv_geo*acos(-1.)/180.) + muhall_e * BX * 0.0001)/acos(-1.); |
506 |
|
|
507 |
|
if (iv==0)return axv_eff; |
508 |
|
else if(iv==1)return ayv_eff; |
509 |
|
else{ |
510 |
|
cout << "Float_t TrkTrack::GetEffectiveAngle(int "<<ip<<", int "<<iv<<") ==> wrong input"<<endl; |
511 |
|
return 0.; |
512 |
|
} |
513 |
|
|
514 |
}; |
}; |
515 |
|
|
516 |
//-------------------------------------- |
//-------------------------------------- |
519 |
//-------------------------------------- |
//-------------------------------------- |
520 |
void TrkTrack::Dump(){ |
void TrkTrack::Dump(){ |
521 |
cout << endl << "========== Track " ; |
cout << endl << "========== Track " ; |
522 |
cout << endl << "seq. n. : "<< seqno; |
cout << endl << "seq. n. : "<< seqno; |
523 |
cout << endl << "image n. : "<< image; |
cout << endl << "image n. : "<< image; |
524 |
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] << " "; |
525 |
cout << endl << "chi^2 : "<< chi2; |
cout << endl << "chi^2 : "<< chi2; |
526 |
cout << endl << "n.step : "<< nstep; |
cout << endl << "n.step : "<< nstep; |
527 |
cout << endl << "xgood : "; for(int i=0; i<6; i++)cout << xgood[i] ; |
cout << endl << "xgood : "; for(int i=0; i<6; i++)cout << XGood(i) ; |
528 |
cout << endl << "ygood : "; for(int i=0; i<6; i++)cout << ygood[i] ; |
cout << endl << "ygood : "; for(int i=0; i<6; i++)cout << YGood(i) ; |
529 |
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] << " "; |
530 |
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] << " "; |
531 |
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] << " "; |
532 |
|
cout << endl << "xv : "; for(int i=0; i<6; i++)cout << xv[i] << " "; |
533 |
|
cout << endl << "yv : "; for(int i=0; i<6; i++)cout << yv[i] << " "; |
534 |
|
cout << endl << "zv : "; for(int i=0; i<6; i++)cout << zv[i] << " "; |
535 |
|
cout << endl << "resx : "; for(int i=0; i<6; i++)cout << resx[i] << " "; |
536 |
|
cout << endl << "resy : "; for(int i=0; i<6; i++)cout << resy[i] << " "; |
537 |
|
cout << endl << "tailx : "; for(int i=0; i<6; i++)cout << tailx[i] << " "; |
538 |
|
cout << endl << "taily : "; for(int i=0; i<6; i++)cout << taily[i] << " "; |
539 |
|
cout << endl << "coval : "; for(int i=0; i<5; i++)cout << coval[0][i]<<" "; |
540 |
|
cout << endl << " "; for(int i=0; i<5; i++)cout << coval[1][i]<<" "; |
541 |
|
cout << endl << " "; for(int i=0; i<5; i++)cout << coval[2][i]<<" "; |
542 |
|
cout << endl << " "; for(int i=0; i<5; i++)cout << coval[3][i]<<" "; |
543 |
|
cout << endl << " "; for(int i=0; i<5; i++)cout << coval[4][i]<<" "; |
544 |
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] << " "; |
545 |
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] << " "; |
546 |
|
cout << endl << "maxs x : "; for(int i=0; i<6; i++)cout << GetClusterX_MaxStrip(i) << " "; |
547 |
|
cout << endl << "maxs y : "; for(int i=0; i<6; i++)cout << GetClusterY_MaxStrip(i) << " "; |
548 |
|
cout << endl << "mult x : "; for(int i=0; i<6; i++)cout << GetClusterX_Multiplicity(i) << " "; |
549 |
|
cout << endl << "mult y : "; for(int i=0; i<6; i++)cout << GetClusterY_Multiplicity(i) << " "; |
550 |
|
cout << endl << "seed x : "; for(int i=0; i<6; i++)cout << GetClusterX_Seed(i) << " "; |
551 |
|
cout << endl << "seed y : "; for(int i=0; i<6; i++)cout << GetClusterY_Seed(i) << " "; |
552 |
|
cout << endl << "xpu : "; for(int i=0; i<6; i++)cout << xpu[i] << " "; |
553 |
|
cout << endl << "ypu : "; for(int i=0; i<6; i++)cout << ypu[i] << " "; |
554 |
|
|
555 |
|
cout << endl; |
556 |
|
} |
557 |
|
/** |
558 |
|
* Set the TrkTrack position measurements |
559 |
|
*/ |
560 |
|
void TrkTrack::SetMeasure(double *xmeas, double *ymeas, double *zmeas){ |
561 |
|
for(int i=0; i<6; i++) xm[i]=*xmeas++; |
562 |
|
for(int i=0; i<6; i++) ym[i]=*ymeas++; |
563 |
|
for(int i=0; i<6; i++) zm[i]=*zmeas++; |
564 |
|
} |
565 |
|
/** |
566 |
|
* Set the TrkTrack position resolution |
567 |
|
*/ |
568 |
|
void TrkTrack::SetResolution(double *rx, double *ry){ |
569 |
|
for(int i=0; i<6; i++) resx[i]=*rx++; |
570 |
|
for(int i=0; i<6; i++) resy[i]=*ry++; |
571 |
|
} |
572 |
|
/** |
573 |
|
* Set the TrkTrack tails position resolution |
574 |
|
*/ |
575 |
|
void TrkTrack::SetTail(double *tx, double *ty, double factor){ |
576 |
|
for(int i=0; i<6; i++) tailx[i]=factor*(*tx++); |
577 |
|
for(int i=0; i<6; i++) taily[i]=factor*(*ty++); |
578 |
|
} |
579 |
|
/** |
580 |
|
* Set the TrkTrack Student parameter (resx,resy,tailx,taily) |
581 |
|
* from previous gausian fit |
582 |
|
*@param flag =0 standard, =1 with noise correction |
583 |
|
*/ |
584 |
|
void TrkTrack::SetStudentParam(int flag){ |
585 |
|
float sx[11]={0.000128242, |
586 |
|
0.000136942, |
587 |
|
0.000162718, |
588 |
|
0.000202644, |
589 |
|
0.00025597, |
590 |
|
0.000317456, |
591 |
|
0.000349048, |
592 |
|
0.000384638, |
593 |
|
0.000457295, |
594 |
|
0.000512319, |
595 |
|
0.000538573}; |
596 |
|
float tx[11]={1.79402, |
597 |
|
2.04876, |
598 |
|
2.88376, |
599 |
|
3.3, |
600 |
|
3.14084, |
601 |
|
4.07686, |
602 |
|
4.44736, |
603 |
|
3.5179, |
604 |
|
3.38697, |
605 |
|
3.45739, |
606 |
|
3.18627}; |
607 |
|
float sy[11]={0.000483075, |
608 |
|
0.000466925, |
609 |
|
0.000431658, |
610 |
|
0.000428317, |
611 |
|
0.000433854, |
612 |
|
0.000444044, |
613 |
|
0.000482098, |
614 |
|
0.000537579, |
615 |
|
0.000636279, |
616 |
|
0.000741998, |
617 |
|
0.000864261}; |
618 |
|
float ty[11]={0.997032, |
619 |
|
1.11147, |
620 |
|
1.18526, |
621 |
|
1.61404, |
622 |
|
2.21908, |
623 |
|
3.08959, |
624 |
|
4.48833, |
625 |
|
4.42687, |
626 |
|
4.65253, |
627 |
|
4.52043, |
628 |
|
4.29926}; |
629 |
|
int index; |
630 |
|
float fact=0.; |
631 |
|
for(int i=0; i<6; i++) { |
632 |
|
index = int((fabs(axv[i])+1.)/2.); |
633 |
|
if(index>10) index=10; |
634 |
|
tailx[i]=tx[index]; |
635 |
|
if(flag==1) { |
636 |
|
if(fabs(axv[i])<=10.) fact = resx[i]/risxeta2_(&(axv[i])); |
637 |
|
if(fabs(axv[i])>10.&&fabs(axv[i])<=15.) fact = resx[i]/risxeta3_(&(axv[i])); |
638 |
|
if(fabs(axv[i])>15.) fact = resx[i]/risxeta4_(&(axv[i])); |
639 |
|
} else fact = 1.; |
640 |
|
resx[i] = sx[index]*fact; |
641 |
|
} |
642 |
|
for(int i=0; i<6; i++) { |
643 |
|
index = int((fabs(ayv[i])+1.)/2.); |
644 |
|
if(index>10) index=10; |
645 |
|
taily[i]=ty[index]; |
646 |
|
if(flag==1) fact = resy[i]/risyeta2_(&(ayv[i])); |
647 |
|
else fact = 1.; |
648 |
|
resy[i] = sy[index]*fact; |
649 |
|
} |
650 |
|
} |
651 |
|
/** |
652 |
|
* Set the TrkTrack good measurement |
653 |
|
*/ |
654 |
|
void TrkTrack::SetGood(int *xg, int *yg){ |
655 |
|
|
656 |
|
for(int i=0; i<6; i++) xgood[i]=*xg++; |
657 |
|
for(int i=0; i<6; i++) ygood[i]=*yg++; |
658 |
|
} |
659 |
|
|
660 |
|
/** |
661 |
|
* Load the magnetic field |
662 |
|
*/ |
663 |
|
void TrkTrack::LoadField(TString path){ |
664 |
|
|
665 |
|
// strcpy(path_.path,path.Data()); |
666 |
|
// path_.pathlen = path.Length(); |
667 |
|
// path_.error = 0; |
668 |
|
// readb_(); |
669 |
|
|
670 |
|
// TrkParams::SetTrackingMode(); |
671 |
|
// TrkParams::SetPrecisionFactor(); |
672 |
|
// TrkParams::SetStepMin(); |
673 |
|
TrkParams::SetMiniDefault(); |
674 |
|
|
675 |
|
TrkParams::Set(path,1); |
676 |
|
TrkParams::Load(1); |
677 |
|
if( !TrkParams::IsLoaded(1) ){ |
678 |
|
cout << "void TrkTrack::LoadField(TString path) --- ERROR --- m.field not loaded"<<endl; |
679 |
|
} |
680 |
|
|
681 |
|
}; |
682 |
|
|
683 |
|
|
684 |
|
/** |
685 |
|
* Method to fill minimization-routine common |
686 |
|
*/ |
687 |
|
void TrkTrack::FillMiniStruct(cMini2track& track){ |
688 |
|
|
689 |
|
for(int i=0; i<6; i++){ |
690 |
|
|
691 |
|
// cout << i<<" - "<<xgood[i]<<" "<<XGood(i)<<endl; |
692 |
|
// cout << i<<" - "<<ygood[i]<<" "<<YGood(i)<<endl; |
693 |
|
track.xgood[i]=XGood(i); |
694 |
|
track.ygood[i]=YGood(i); |
695 |
|
|
696 |
|
track.xm[i]=xm[i]; |
697 |
|
track.ym[i]=ym[i]; |
698 |
|
track.zm[i]=zm[i]; |
699 |
|
|
700 |
|
// --- temporaneo ---------------------------- |
701 |
|
// float segment = 100.; |
702 |
|
// track.xm_a[i]=xm[i]; |
703 |
|
// track.xm_b[i]=xm[i]; |
704 |
|
// track.ym_a[i]=ym[i]; |
705 |
|
// track.ym_b[i]=ym[i]; |
706 |
|
// if( XGood(i) && !YGood(i) ){ |
707 |
|
// track.ym_a[i] = track.ym_a[i]+segment; |
708 |
|
// track.ym_b[i] = track.ym_b[i]-segment; |
709 |
|
// }else if( !XGood(i) && YGood(i)){ |
710 |
|
// track.xm_a[i] = track.xm_a[i]+segment; |
711 |
|
// track.xm_b[i] = track.xm_b[i]-segment; |
712 |
|
// } |
713 |
|
// --- temporaneo ---------------------------- |
714 |
|
|
715 |
|
if( XGood(i) || YGood(i) ){ |
716 |
|
double segment = 2.;//cm |
717 |
|
// NB: i parametri di allineamento hanno una notazione particolare!!! |
718 |
|
// sensor = 0 (hybrid side), 1 |
719 |
|
// ladder = 0-2 (increasing x) |
720 |
|
// plane = 0-5 (from bottom to top!!!) |
721 |
|
int is = (int)GetSensor(i); if(i==5)is=1-is; |
722 |
|
int ip = 5-i; |
723 |
|
int il = (int)GetLadder(i); |
724 |
|
|
725 |
|
double omega = 0.; |
726 |
|
double beta = 0.; |
727 |
|
double gamma = 0.; |
728 |
|
if( |
729 |
|
(is < 0 || is > 1 || ip < 0 || ip > 5 || il < 0 || il > 2) && |
730 |
|
true){ |
731 |
|
// se il piano risulta colpito, ladder e sensore devono essere |
732 |
|
// assegnati correttamente |
733 |
|
cout << " void TrkTrack::FillMiniStruct(cMini2track&) --- WARNING --- sensor not defined, cannot read alignment parameters "<<endl; |
734 |
|
cout << " is ip il = "<<is<<" "<<ip<<" "<<il<<endl; |
735 |
|
}else{ |
736 |
|
omega = alignparameters_.omega[is][il][ip]; |
737 |
|
beta = alignparameters_.beta[is][il][ip]; |
738 |
|
gamma = alignparameters_.gamma[is][il][ip]; |
739 |
|
} |
740 |
|
|
741 |
|
if( XGood(i) && !YGood(i) ){ |
742 |
|
track.xm_a[i] = xm[i] - omega * segment; |
743 |
|
track.ym_a[i] = ym[i] + segment; |
744 |
|
// track.zm_a[i] = zm[i] + beta * segment;//not used yet |
745 |
|
track.xm_b[i] = xm[i] + omega * segment; |
746 |
|
track.ym_b[i] = ym[i] - segment; |
747 |
|
// track.zm_b[i] = zm[i] - beta * segment;//not used yet |
748 |
|
}else if( !XGood(i) && YGood(i) ){ |
749 |
|
track.xm_a[i] = xm[i] + segment; |
750 |
|
track.ym_a[i] = ym[i] + omega * segment; |
751 |
|
// track.zm_a[i] = zm[i] - gamma * segment;//not used yet |
752 |
|
track.xm_b[i] = xm[i] - segment; |
753 |
|
track.ym_b[i] = ym[i] - omega * segment; |
754 |
|
// track.zm_b[i] = zm[i] + gamma * segment;//not used yet |
755 |
|
} |
756 |
|
} |
757 |
|
|
758 |
|
track.resx[i]=resx[i]; |
759 |
|
track.resy[i]=resy[i]; |
760 |
|
track.tailx[i]=tailx[i]; |
761 |
|
track.taily[i]=taily[i]; |
762 |
|
} |
763 |
|
|
764 |
|
for(int i=0; i<5; i++) track.al[i]=al[i]; |
765 |
|
track.zini = 23.5; |
766 |
|
// ZINI = 23.5 !!! it should be the same parameter in all codes |
767 |
|
|
768 |
|
} |
769 |
|
/** |
770 |
|
* Method to set values from minimization-routine common |
771 |
|
*/ |
772 |
|
void TrkTrack::SetFromMiniStruct(cMini2track *track){ |
773 |
|
|
774 |
|
for(int i=0; i<5; i++) { |
775 |
|
al[i]=track->al[i]; |
776 |
|
for(int j=0; j<5; j++) coval[i][j]=track->cov[i][j]; |
777 |
|
} |
778 |
|
chi2 = track->chi2; |
779 |
|
nstep = track->nstep; |
780 |
|
for(int i=0; i<6; i++){ |
781 |
|
xv[i] = track->xv[i]; |
782 |
|
yv[i] = track->yv[i]; |
783 |
|
zv[i] = track->zv[i]; |
784 |
|
xm[i] = track->xm[i]; |
785 |
|
ym[i] = track->ym[i]; |
786 |
|
zm[i] = track->zm[i]; |
787 |
|
axv[i] = track->axv[i]; |
788 |
|
ayv[i] = track->ayv[i]; |
789 |
|
} |
790 |
|
|
791 |
|
} |
792 |
|
/** |
793 |
|
* \brief Method to re-evaluate coordinates of clusters associated with a track. |
794 |
|
* |
795 |
|
* The method can be applied only after recovering level1 information |
796 |
|
* (either by reprocessing single events from level0 or from |
797 |
|
* the TrkLevel1 branch, if present); it calls F77 subroutines that |
798 |
|
* read the level1 common and fill the minimization-routine common. |
799 |
|
* Some clusters can be excluded or added by means of the methods: |
800 |
|
* |
801 |
|
* TrkTrack::ResetXGood(int ip) |
802 |
|
* TrkTrack::ResetYGood(int ip) |
803 |
|
* TrkTrack::SetXGood(int ip, int cid, int is) |
804 |
|
* TrkTrack::SetYGood(int ip, int cid, int is) |
805 |
|
* |
806 |
|
* NB! The method TrkTrack::SetGood(int *xg, int *yg) set the plane-mask (0-1) |
807 |
|
* for the minimization-routine common. It deletes the cluster information |
808 |
|
* (at least for the moment...) thus cannot be applied before |
809 |
|
* TrkTrack::EvaluateClusterPositions(). |
810 |
|
* |
811 |
|
* Different p.f.a. can be applied by calling (once) the method: |
812 |
|
* |
813 |
|
* TrkParams::SetPFA(0); //Set ETA p.f.a. |
814 |
|
* |
815 |
|
* @see TrkParams::SetPFA(int) |
816 |
|
*/ |
817 |
|
Bool_t TrkTrack::EvaluateClusterPositions(){ |
818 |
|
|
819 |
|
// cout << "void TrkTrack::GetClusterositions() "<<endl; |
820 |
|
|
821 |
|
bool OK=true; |
822 |
|
TrkParams::Load(1); if( !TrkParams::IsLoaded(1) )cout << "Bool_t TrkTrack::EvaluateClusterPositions() ---ERROR--- m.field not loaded "<<endl; |
823 |
|
TrkParams::Load(4); if( !TrkParams::IsLoaded(4) )cout << "Bool_t TrkTrack::EvaluateClusterPositions() ---ERROR--- p.f.a. par. not loaded "<<endl; |
824 |
|
TrkParams::Load(5); if( !TrkParams::IsLoaded(5) )cout << "Bool_t TrkTrack::EvaluateClusterPositions() ---ERROR--- alignment par. not loaded "<<endl; |
825 |
|
if(!OK)return false; |
826 |
|
|
827 |
|
for(int ip=0; ip<6; ip++){ |
828 |
|
// cout << ip<<" ** "<<xm[ip]<<" / "<<ym[ip]<<endl;; |
829 |
|
int icx = GetClusterX_ID(ip)+1; |
830 |
|
int icy = GetClusterY_ID(ip)+1; |
831 |
|
int sensor = GetSensor(ip)+1;//<< convenzione "Paolo" |
832 |
|
if(ip==5 && sensor!=0)sensor=3-sensor;//<< convenzione "Elena" |
833 |
|
int ladder = GetLadder(ip)+1; |
834 |
|
float ax = axv[ip]; |
835 |
|
float ay = ayv[ip]; |
836 |
|
float v[3]; |
837 |
|
v[0]=xv[ip]; |
838 |
|
v[1]=yv[ip]; |
839 |
|
v[2]=zv[ip]; |
840 |
|
float bfx = 10*TrkParams::GetBX(v);//Tesla |
841 |
|
float bfy = 10*TrkParams::GetBY(v);//Tesla |
842 |
|
int ipp=ip+1; |
843 |
|
xyzpam_(&ipp,&icx,&icy,&ladder,&sensor,&ax,&ay,&bfx,&bfy); |
844 |
|
if(icx<0 || icy<0)return false; |
845 |
|
} |
846 |
|
return true; |
847 |
|
} |
848 |
|
/** |
849 |
|
* \brief Tracking method. It calls F77 mini routine. |
850 |
|
* |
851 |
|
* @param pfixed Particle momentum. If pfixed=0 the momentum |
852 |
|
* is left as a free parameter, otherwise it is fixed to the input value. |
853 |
|
* @param fail Output flag (!=0 if the fit failed). |
854 |
|
* @param iprint Flag to set debug mode ( 0 = no output; 1 = verbose; 2 = debug). |
855 |
|
* @param froml1 Flag to re-evaluate positions (see TrkTrack::GetClusterPositions()). |
856 |
|
* |
857 |
|
* The option to re-evaluate positions can be used only after recovering |
858 |
|
* level1 information, eg. by reprocessing the single event. |
859 |
|
* |
860 |
|
* Example: |
861 |
|
* |
862 |
|
* if( !event->GetTrkLevel0() )return false; |
863 |
|
* event->GetTrkLevel0()->ProcessEvent(); // re-processing level0->level1 |
864 |
|
* int fail=0; |
865 |
|
* event->GetTrkLevel2()->GetTrack(0)->Fit(0.,fail,0,1); |
866 |
|
* |
867 |
|
* @see EvaluateClusterPositions() |
868 |
|
* |
869 |
|
* The fitting procedure can be varied by changing the tracking mode, |
870 |
|
* the fit-precision factor, the minimum number of step, etc. |
871 |
|
* @see SetTrackingMode(int) |
872 |
|
* @see SetPrecisionFactor(double) |
873 |
|
* @see SetStepMin(int) |
874 |
|
* @see SetDeltaB(int,double) |
875 |
|
*/ |
876 |
|
void TrkTrack::Fit(double pfixed, int& fail, int iprint, int froml1){ |
877 |
|
|
878 |
|
bool OK=true; |
879 |
|
TrkParams::Load(1); if( !TrkParams::IsLoaded(1) )cout << "void TrkTrack::Fit(double,int&,int,int) ---ERROR--- m.field not loaded "<<endl; |
880 |
|
if(!OK)return; |
881 |
|
|
882 |
|
float al_ini[] = {0.,0.,0.,0.,0.}; |
883 |
|
|
884 |
|
extern cMini2track track_; |
885 |
|
fail = 0; |
886 |
|
|
887 |
|
FillMiniStruct(track_); |
888 |
|
|
889 |
|
if(froml1!=0){ |
890 |
|
if( !EvaluateClusterPositions() ){ |
891 |
|
cout << "void TrkTrack::Fit("<<pfixed<<","<<fail<<","<<iprint<<","<<froml1<<") --- ERROR evaluating cluster positions "<<endl; |
892 |
|
FillMiniStruct(track_) ; |
893 |
|
fail = 1; |
894 |
|
return; |
895 |
|
} |
896 |
|
}else{ |
897 |
|
FillMiniStruct(track_); |
898 |
|
} |
899 |
|
|
900 |
|
// if fit variables have been reset, evaluate the initial guess |
901 |
|
if(al[0]==-9999.&&al[1]==-9999.&&al[2]==-9999.&&al[3]==-9999.&&al[4]==-9999.)guess_(); |
902 |
|
|
903 |
|
// --------------------- free momentum |
904 |
|
if(pfixed==0.) { |
905 |
|
track_.pfixed=0.; |
906 |
|
} |
907 |
|
// --------------------- fixed momentum |
908 |
|
if(pfixed!=0.) { |
909 |
|
al[4]=1./pfixed; |
910 |
|
track_.pfixed=pfixed; |
911 |
|
} |
912 |
|
|
913 |
|
// store temporarily the initial guess |
914 |
|
for(int i=0; i<5; i++) al_ini[i]=track_.al[i]; |
915 |
|
|
916 |
|
// ------------------------------------------ |
917 |
|
// call mini routine |
918 |
|
// ------------------------------------------ |
919 |
|
int istep=0; |
920 |
|
int ifail=0; |
921 |
|
mini2_(&istep,&ifail, &iprint); |
922 |
|
if(ifail!=0) { |
923 |
|
if(iprint)cout << "ERROR: ifail= " << ifail << endl; |
924 |
|
fail = 1; |
925 |
|
} |
926 |
|
// ------------------------------------------ |
927 |
|
|
928 |
|
SetFromMiniStruct(&track_); |
929 |
|
|
930 |
|
if(fail){ |
931 |
|
if(iprint)cout << " >>>> fit failed "<<endl; |
932 |
|
for(int i=0; i<5; i++) al[i]=al_ini[i]; |
933 |
|
} |
934 |
|
|
935 |
|
}; |
936 |
|
/** |
937 |
|
* Reset the fit parameters |
938 |
|
*/ |
939 |
|
void TrkTrack::FitReset(){ |
940 |
|
for(int i=0; i<5; i++) al[i]=-9999.; |
941 |
|
chi2=0.; |
942 |
|
nstep=0; |
943 |
|
// for(int i=0; i<6; i++) xv[i]=0.; |
944 |
|
// for(int i=0; i<6; i++) yv[i]=0.; |
945 |
|
// for(int i=0; i<6; i++) zv[i]=0.; |
946 |
|
// for(int i=0; i<6; i++) axv[i]=0.; |
947 |
|
// for(int i=0; i<6; i++) ayv[i]=0.; |
948 |
|
for(int i=0; i<5; i++) { |
949 |
|
for(int j=0; j<5; j++) coval[i][j]=0.; |
950 |
|
} |
951 |
|
} |
952 |
|
/** |
953 |
|
* Set the tracking mode |
954 |
|
*/ |
955 |
|
void TrkTrack::SetTrackingMode(int trackmode){ |
956 |
|
extern cMini2track track_; |
957 |
|
track_.trackmode = trackmode; |
958 |
|
} |
959 |
|
/** |
960 |
|
* Set the factor scale for tracking precision |
961 |
|
*/ |
962 |
|
void TrkTrack::SetPrecisionFactor(double fact){ |
963 |
|
extern cMini2track track_; |
964 |
|
track_.fact = fact; |
965 |
|
} |
966 |
|
/** |
967 |
|
* Set the minimum number of steps for tracking precision |
968 |
|
*/ |
969 |
|
void TrkTrack::SetStepMin(int istepmin){ |
970 |
|
extern cMini2track track_; |
971 |
|
track_.istepmin = istepmin; |
972 |
|
} |
973 |
|
/** |
974 |
|
* Set deltaB parameters (id=0,1). By default they are set to zero. |
975 |
|
*/ |
976 |
|
void TrkTrack::SetDeltaB(int id, double db){ |
977 |
|
if(id!=0 && id!=1)cout << "void TrkTrack::SetDeltaB(int id,double db) -- wrong input parameters: "<<id<<" "<<db<<endl; |
978 |
|
TrkParams::SetDeltaB(id,db); |
979 |
|
} |
980 |
|
|
981 |
|
/** |
982 |
|
* Returns true if the track is inside the magnet cavity. |
983 |
|
* @param toll Tolerance around the nominal volume (toll>0 define an inner fiducial volume) |
984 |
|
*/ |
985 |
|
Bool_t TrkTrack::IsInsideCavity(float toll){ |
986 |
|
|
987 |
|
// float xmagntop, ymagntop, xmagnbottom, ymagnbottom; |
988 |
|
// xmagntop = xv[0] + (ZMAGNHIGH-zv[0])*tan(acos(-1.0)*axv[0]/180.); |
989 |
|
// ymagntop = yv[0] + (ZMAGNHIGH-zv[0])*tan(acos(-1.0)*ayv[0]/180.); |
990 |
|
// xmagnbottom = xv[5] + (ZMAGNLOW-zv[5])*tan(acos(-1.0)*axv[5]/180.); |
991 |
|
// ymagnbottom = yv[5] + (ZMAGNLOW-zv[5])*tan(acos(-1.0)*ayv[5]/180.); |
992 |
|
// if( xmagntop>XMAGNLOW && xmagntop<XMAGNHIGH && |
993 |
|
// ymagntop>YMAGNLOW && ymagntop<YMAGNHIGH && |
994 |
|
// xmagnbottom>XMAGNLOW && xmagnbottom<XMAGNHIGH && |
995 |
|
// ymagnbottom>YMAGNLOW && ymagnbottom<YMAGNHIGH ) return(true); |
996 |
|
// else return(false); |
997 |
|
|
998 |
|
int ngf = TrkParams::nGF; |
999 |
|
for(int i=0; i<ngf; i++){ |
1000 |
|
// |
1001 |
|
// cout << endl << TrkParams::GF_element[i]; |
1002 |
|
if( |
1003 |
|
TrkParams::GF_element[i].CompareTo("CUF") && |
1004 |
|
TrkParams::GF_element[i].CompareTo("T2") && |
1005 |
|
TrkParams::GF_element[i].CompareTo("T3") && |
1006 |
|
TrkParams::GF_element[i].CompareTo("T4") && |
1007 |
|
TrkParams::GF_element[i].CompareTo("T5") && |
1008 |
|
TrkParams::GF_element[i].CompareTo("CLF") && |
1009 |
|
true)continue; |
1010 |
|
// apply condition only within the cavity |
1011 |
|
// cout << " -- "<<xGF[i]<<" "<<yGF[i]; |
1012 |
|
if( |
1013 |
|
xGF[i] <= TrkParams::xGF_min[i] + toll || |
1014 |
|
xGF[i] >= TrkParams::xGF_max[i] - toll || |
1015 |
|
yGF[i] <= TrkParams::yGF_min[i] + toll || |
1016 |
|
yGF[i] >= TrkParams::yGF_max[i] - toll || |
1017 |
|
false){ |
1018 |
|
|
1019 |
|
return false; |
1020 |
|
} |
1021 |
|
} |
1022 |
|
return true; |
1023 |
|
|
1024 |
|
|
1025 |
|
} |
1026 |
|
/** |
1027 |
|
* Returns true if the track is inside the nominal acceptance, which is defined |
1028 |
|
* by the intersection among magnet cavity, silicon-plane sensitive area and |
1029 |
|
* ToF sensitive area (nominal values from the official document used to |
1030 |
|
* calculate the geometrical factor) |
1031 |
|
*/ |
1032 |
|
Bool_t TrkTrack::IsInsideAcceptance(){ |
1033 |
|
|
1034 |
|
int ngf = TrkParams::nGF; |
1035 |
|
for(int i=0; i<ngf; i++){ |
1036 |
|
if( |
1037 |
|
xGF[i] <= TrkParams::xGF_min[i] || |
1038 |
|
xGF[i] >= TrkParams::xGF_max[i] || |
1039 |
|
yGF[i] <= TrkParams::yGF_min[i] || |
1040 |
|
yGF[i] >= TrkParams::yGF_max[i] || |
1041 |
|
false)return false; |
1042 |
|
} |
1043 |
|
return true; |
1044 |
|
|
1045 |
|
} |
1046 |
|
/** |
1047 |
|
* Method to retrieve ID (0,1,...) of x-cluster (if any) associated to this track. |
1048 |
|
* If no cluster is associated, ID=-1. |
1049 |
|
* @param ip Tracker plane (0-5) |
1050 |
|
*/ |
1051 |
|
Int_t TrkTrack::GetClusterX_ID(int ip){ |
1052 |
|
return ((Int_t)fabs(xgood[ip]))%10000000-1; |
1053 |
|
}; |
1054 |
|
/** |
1055 |
|
* Method to retrieve ID (0-xxx) of y-cluster (if any) associated to this track. |
1056 |
|
* If no cluster is associated, ID=-1. |
1057 |
|
* @param ip Tracker plane (0-5) |
1058 |
|
*/ |
1059 |
|
Int_t TrkTrack::GetClusterY_ID(int ip){ |
1060 |
|
return ((Int_t)fabs(ygood[ip]))%10000000-1; |
1061 |
|
}; |
1062 |
|
|
1063 |
|
/** |
1064 |
|
* Method to retrieve the ladder (0-2, increasing x) traversed by the track on this plane. |
1065 |
|
* If no ladder is traversed (dead area) the metod retuns -1. |
1066 |
|
* @param ip Tracker plane (0-5) |
1067 |
|
*/ |
1068 |
|
Int_t TrkTrack::GetLadder(int ip){ |
1069 |
|
if(XGood(ip))return (Int_t)fabs(xgood[ip]/100000000)-1; |
1070 |
|
if(YGood(ip))return (Int_t)fabs(ygood[ip]/100000000)-1; |
1071 |
|
return -1; |
1072 |
|
}; |
1073 |
|
/** |
1074 |
|
* Method to retrieve the sensor (0-1, increasing y) traversed by the track on this plane. |
1075 |
|
* If no sensor is traversed (dead area) the metod retuns -1. |
1076 |
|
* @param ip Tracker plane (0-5) |
1077 |
|
*/ |
1078 |
|
Int_t TrkTrack::GetSensor(int ip){ |
1079 |
|
if(XGood(ip))return (Int_t)((Int_t)fabs(xgood[ip]/10000000)%10)-1; |
1080 |
|
if(YGood(ip))return (Int_t)((Int_t)fabs(ygood[ip]/10000000)%10)-1; |
1081 |
|
return -1; |
1082 |
|
}; |
1083 |
|
|
1084 |
|
/** |
1085 |
|
* \brief Method to include a x-cluster to the track. |
1086 |
|
* @param ip Tracker plane (0-5) |
1087 |
|
* @param clid Cluster ID (0 = no-cluster, 1,2,... otherwise ) |
1088 |
|
* @param il Ladder (0-2, increasing x, -1 if no sensitive area is hit) |
1089 |
|
* @param is Sensor (0-1, increasing y, -1 if no sensitive area is hit) |
1090 |
|
* @param bad True if the cluster contains bad strips |
1091 |
|
* @see Fit(double pfixed, int& fail, int iprint, int froml1) |
1092 |
|
*/ |
1093 |
|
void TrkTrack::SetXGood(int ip, int clid, int il, int is, bool bad){ |
1094 |
|
// int il=0; //ladder (temporary) |
1095 |
|
// bool bad=false; //ladder (temporary) |
1096 |
|
if(ip<0||ip>5||clid<0||il<-1||il>2||is<-1||is>1) |
1097 |
|
cout << " void TrkTrack::SetXGood(int,int,int,int,bool) --> MA SEI DI COCCIO?!?!"<<endl; |
1098 |
|
xgood[ip]=(il+1)*100000000+(is+1)*10000000+clid; |
1099 |
|
if(bad)xgood[ip]=-xgood[ip]; |
1100 |
|
}; |
1101 |
|
/** |
1102 |
|
* \brief Method to include a y-cluster to the track. |
1103 |
|
* @param ip Tracker plane (0-5) |
1104 |
|
* @param clid Cluster ID (0 = no-cluster, 1,2,... otherwise ) |
1105 |
|
* @param il Ladder (0-2, increasing x, -1 if no sensitive area is hit) |
1106 |
|
* @param is Sensor (0-1, increasing y, -1 if no sensitive area is hit) |
1107 |
|
* @param bad True if the cluster contains bad strips |
1108 |
|
* @see Fit(double pfixed, int& fail, int iprint, int froml1) |
1109 |
|
*/ |
1110 |
|
void TrkTrack::SetYGood(int ip, int clid, int il, int is, bool bad){ |
1111 |
|
// int il=0; //ladder (temporary) |
1112 |
|
// bool bad=false; //ladder (temporary) |
1113 |
|
if(ip<0||ip>5||clid<0||il<-1||il>2||is<-1||is>1) |
1114 |
|
cout << " void TrkTrack::SetYGood(int,int,int,int,bool) --> MA SEI DI COCCIO?!?!"<<endl; |
1115 |
|
ygood[ip]=(il+1)*100000000+(is+1)*10000000+clid; |
1116 |
|
if(bad)ygood[ip]=-ygood[ip]; |
1117 |
|
}; |
1118 |
|
|
1119 |
|
/** |
1120 |
|
* \brief Average X |
1121 |
|
* Average value of <xv>, evaluated from the first to the last hit x view. |
1122 |
|
*/ |
1123 |
|
Float_t TrkTrack::GetXav(){ |
1124 |
|
|
1125 |
|
int first_plane = -1; |
1126 |
|
int last_plane = -1; |
1127 |
|
for(Int_t ip=0; ip<6; ip++){ |
1128 |
|
if( XGood(ip) && first_plane == -1 )first_plane = ip; |
1129 |
|
if( XGood(ip) && first_plane != -1 )last_plane = ip; |
1130 |
|
} |
1131 |
|
if( first_plane == -1 || last_plane == -1){ |
1132 |
|
return -100; |
1133 |
|
} |
1134 |
|
if( last_plane-first_plane+1 ==0 )return -100; |
1135 |
|
|
1136 |
|
Float_t av = 0; |
1137 |
|
for(int ip=first_plane; ip<=last_plane; ip++)av+=xv[ip]; |
1138 |
|
|
1139 |
|
return (av/(last_plane-first_plane+1)); |
1140 |
|
} |
1141 |
|
/** |
1142 |
|
* \brief Average Y |
1143 |
|
* Average value of <yv>, evaluated from the first to the last hit x view. |
1144 |
|
*/ |
1145 |
|
Float_t TrkTrack::GetYav(){ |
1146 |
|
|
1147 |
|
int first_plane = -1; |
1148 |
|
int last_plane = -1; |
1149 |
|
for(Int_t ip=0; ip<6; ip++){ |
1150 |
|
if( XGood(ip) && first_plane == -1 )first_plane = ip; |
1151 |
|
if( XGood(ip) && first_plane != -1 )last_plane = ip; |
1152 |
|
} |
1153 |
|
if( first_plane == -1 || last_plane == -1){ |
1154 |
|
return -100; |
1155 |
|
} |
1156 |
|
if( last_plane-first_plane+1 ==0 )return -100; |
1157 |
|
|
1158 |
|
Float_t av = 0; |
1159 |
|
for(int ip=first_plane; ip<=last_plane; ip++)av+=yv[ip]; |
1160 |
|
|
1161 |
|
return (av/(last_plane-first_plane+1)); |
1162 |
} |
} |
1163 |
|
/** |
1164 |
|
* \brief Average Z |
1165 |
|
* Average value of <zv>, evaluated from the first to the last hit x view. |
1166 |
|
*/ |
1167 |
|
Float_t TrkTrack::GetZav(){ |
1168 |
|
|
1169 |
|
int first_plane = -1; |
1170 |
|
int last_plane = -1; |
1171 |
|
for(Int_t ip=0; ip<6; ip++){ |
1172 |
|
if( XGood(ip) && first_plane == -1 )first_plane = ip; |
1173 |
|
if( XGood(ip) && first_plane != -1 )last_plane = ip; |
1174 |
|
} |
1175 |
|
if( first_plane == -1 || last_plane == -1){ |
1176 |
|
return -100; |
1177 |
|
} |
1178 |
|
if( last_plane-first_plane+1 ==0 )return -100; |
1179 |
|
|
1180 |
|
Float_t av = 0; |
1181 |
|
for(int ip=first_plane; ip<=last_plane; ip++)av+=zv[ip]; |
1182 |
|
|
1183 |
|
return (av/(last_plane-first_plane+1)); |
1184 |
|
} |
1185 |
|
|
1186 |
|
/** |
1187 |
|
* \brief Number of column traversed |
1188 |
|
*/ |
1189 |
|
Int_t TrkTrack::GetNColumns(){ |
1190 |
|
int sensors[] = {0,0,0,0,0,0}; |
1191 |
|
for(int ip=0; ip<6; ip++){ |
1192 |
|
int sensorid = GetLadder(ip)+3*GetSensor(ip); |
1193 |
|
if(XGood(ip)||YGood(ip)) |
1194 |
|
if(sensorid>=0 && sensorid<6)sensors[sensorid]=1; |
1195 |
|
} |
1196 |
|
int nsensors=0; |
1197 |
|
for(int is=0; is<6; is++)nsensors += sensors[is]; |
1198 |
|
return nsensors; |
1199 |
|
}; |
1200 |
|
/** |
1201 |
|
* \brief Give the maximum energy release |
1202 |
|
*/ |
1203 |
|
Float_t TrkTrack::GetDEDX_max(int ip, int iv){ |
1204 |
|
Float_t max=0; |
1205 |
|
int pfrom = 0; |
1206 |
|
int pto = 6; |
1207 |
|
int vfrom = 0; |
1208 |
|
int vto = 2; |
1209 |
|
if(ip>=0&&ip<6){ |
1210 |
|
pfrom = ip; |
1211 |
|
pto = ip+1; |
1212 |
|
} |
1213 |
|
if(iv>=0&&iv<2){ |
1214 |
|
vfrom = iv; |
1215 |
|
vto = iv+1; |
1216 |
|
} |
1217 |
|
for(int i=pfrom; i<pto; i++) |
1218 |
|
for(int j=vfrom; j<vto; j++){ |
1219 |
|
if(j==0 && XGood(i) && GetDEDX(i,j)>max)max=GetDEDX(i,j); |
1220 |
|
if(j==1 && YGood(i) && GetDEDX(i,j)>max)max=GetDEDX(i,j); |
1221 |
|
} |
1222 |
|
return max; |
1223 |
|
|
1224 |
|
}; |
1225 |
|
|
1226 |
|
/** |
1227 |
|
* \brief Give the minimum energy release |
1228 |
|
*/ |
1229 |
|
Float_t TrkTrack::GetDEDX_min(int ip, int iv){ |
1230 |
|
Float_t min=100000000; |
1231 |
|
int pfrom = 0; |
1232 |
|
int pto = 6; |
1233 |
|
int vfrom = 0; |
1234 |
|
int vto = 2; |
1235 |
|
if(ip>=0&&ip<6){ |
1236 |
|
pfrom = ip; |
1237 |
|
pto = ip+1; |
1238 |
|
} |
1239 |
|
if(iv>=0&&iv<2){ |
1240 |
|
vfrom = iv; |
1241 |
|
vto = iv+1; |
1242 |
|
} |
1243 |
|
for(int i=pfrom; i<pto; i++) |
1244 |
|
for(int j=vfrom; j<vto; j++){ |
1245 |
|
if(j==0 && XGood(i) && GetDEDX(i,j)<min)min=GetDEDX(i,j); |
1246 |
|
if(j==1 && YGood(i) && GetDEDX(i,j)<min)min=GetDEDX(i,j); |
1247 |
|
} |
1248 |
|
return min; |
1249 |
|
|
1250 |
|
}; |
1251 |
|
|
1252 |
|
/** |
1253 |
|
* \brief Give the maximum spatial residual |
1254 |
|
*/ |
1255 |
|
Float_t TrkTrack::GetResidual_max(int ip, int iv){ |
1256 |
|
Float_t max=0; |
1257 |
|
int pfrom = 0; |
1258 |
|
int pto = 6; |
1259 |
|
int vfrom = 0; |
1260 |
|
int vto = 2; |
1261 |
|
if(ip>=0&&ip<6){ |
1262 |
|
pfrom = ip; |
1263 |
|
pto = ip+1; |
1264 |
|
} |
1265 |
|
if(iv>=0&&iv<2){ |
1266 |
|
vfrom = iv; |
1267 |
|
vto = iv+1; |
1268 |
|
} |
1269 |
|
for(int i=pfrom; i<pto; i++){ |
1270 |
|
for(int j=vfrom; j<vto; j++){ |
1271 |
|
if(j==0 && XGood(i) && fabs(xm[i]-xv[i])>fabs(max))max=xm[i]-xv[i]; |
1272 |
|
if(j==1 && YGood(i) && fabs(ym[i]-yv[i])>fabs(max))max=ym[i]-yv[i]; |
1273 |
|
} |
1274 |
|
} |
1275 |
|
return max; |
1276 |
|
|
1277 |
|
}; |
1278 |
|
/** |
1279 |
|
* \brief Give the anerage spatial residual |
1280 |
|
*/ |
1281 |
|
Float_t TrkTrack::GetResidual_av(int ip, int iv){ |
1282 |
|
// |
1283 |
|
//Sum$((xm>-50)*(xm-xv)/resx)/sqrt(TrkTrack.GetNX()*TrkTrack.GetChi2X())<0.3 |
1284 |
|
|
1285 |
|
Float_t av = 0.; |
1286 |
|
int nav = 0; |
1287 |
|
// |
1288 |
|
int pfrom = 0; |
1289 |
|
int pto = 6; |
1290 |
|
int vfrom = 0; |
1291 |
|
int vto = 2; |
1292 |
|
if(ip>=0&&ip<6){ |
1293 |
|
pfrom = ip; |
1294 |
|
pto = ip+1; |
1295 |
|
} |
1296 |
|
if(iv>=0&&iv<2){ |
1297 |
|
vfrom = iv; |
1298 |
|
vto = iv+1; |
1299 |
|
} |
1300 |
|
for(int i=pfrom; i<pto; i++){ |
1301 |
|
for(int j=vfrom; j<vto; j++){ |
1302 |
|
nav++; |
1303 |
|
if(j==0 && XGood(i)) av += (xm[i]-xv[i])/resx[i]; |
1304 |
|
if(j==1 && YGood(i)) av += (ym[i]-yv[i])/resy[i]; |
1305 |
|
} |
1306 |
|
} |
1307 |
|
if(nav==0)return -100.; |
1308 |
|
return av/nav; |
1309 |
|
|
1310 |
|
}; |
1311 |
|
|
1312 |
|
|
1313 |
|
/** |
1314 |
|
* \brief Give the maximum multiplicity on the x view |
1315 |
|
*/ |
1316 |
|
Int_t TrkTrack::GetClusterX_Multiplicity_max(){ |
1317 |
|
int max=0; |
1318 |
|
for(int ip=0; ip<6; ip++) |
1319 |
|
if(GetClusterX_Multiplicity(ip)>max)max=GetClusterX_Multiplicity(ip); |
1320 |
|
return max; |
1321 |
|
}; |
1322 |
|
/** |
1323 |
|
* \brief Give the minimum multiplicity on the x view |
1324 |
|
*/ |
1325 |
|
Int_t TrkTrack::GetClusterX_Multiplicity_min(){ |
1326 |
|
int min=50; |
1327 |
|
for(int ip=0; ip<6; ip++) |
1328 |
|
if(GetClusterX_Multiplicity(ip)<min)min=GetClusterX_Multiplicity(ip); |
1329 |
|
return min; |
1330 |
|
}; |
1331 |
|
/** |
1332 |
|
* \brief Give the maximum multiplicity on the x view |
1333 |
|
*/ |
1334 |
|
Int_t TrkTrack::GetClusterY_Multiplicity_max(){ |
1335 |
|
int max=0; |
1336 |
|
for(int ip=0; ip<6; ip++) |
1337 |
|
if(GetClusterY_Multiplicity(ip)>max)max=GetClusterY_Multiplicity(ip); |
1338 |
|
return max; |
1339 |
|
}; |
1340 |
|
/** |
1341 |
|
* \brief Give the minimum multiplicity on the x view |
1342 |
|
*/ |
1343 |
|
Int_t TrkTrack::GetClusterY_Multiplicity_min(){ |
1344 |
|
int min=50; |
1345 |
|
for(int ip=0; ip<6; ip++) |
1346 |
|
if(GetClusterY_Multiplicity(ip)<min)min=GetClusterY_Multiplicity(ip); |
1347 |
|
return min; |
1348 |
|
}; |
1349 |
|
|
1350 |
|
/** |
1351 |
|
* \brief Give the minimum seed on the x view |
1352 |
|
*/ |
1353 |
|
Float_t TrkTrack::GetClusterX_Seed_min(){ |
1354 |
|
Float_t min=100000; |
1355 |
|
for(int ip=0; ip<6; ip++) |
1356 |
|
if(XGood(ip) && GetClusterX_Seed(ip)<min)min=GetClusterX_Seed(ip); |
1357 |
|
return min; |
1358 |
|
}; |
1359 |
|
/** |
1360 |
|
* \brief Give the minimum seed on the x view |
1361 |
|
*/ |
1362 |
|
Float_t TrkTrack::GetClusterY_Seed_min(){ |
1363 |
|
Float_t min=100000; |
1364 |
|
for(int ip=0; ip<6; ip++) |
1365 |
|
if(YGood(ip) && GetClusterY_Seed(ip)<min)min=GetClusterY_Seed(ip); |
1366 |
|
return min; |
1367 |
|
}; |
1368 |
|
|
1369 |
|
|
1370 |
//-------------------------------------- |
//-------------------------------------- |
1371 |
// |
// |
1372 |
// |
// |
1373 |
//-------------------------------------- |
//-------------------------------------- |
1374 |
void TrkTrack::Clear(){ |
void TrkTrack::Clear(){ |
1375 |
seqno = -1; |
// cout << "TrkTrack::Clear()"<<endl; |
1376 |
image = -1; |
seqno = -1; |
1377 |
chi2 = 0; |
image = -1; |
1378 |
nstep = 0; |
chi2 = 0; |
1379 |
for(int it1=0;it1<5;it1++){ |
nstep = 0; |
1380 |
al[it1] = 0; |
for(int it1=0;it1<5;it1++){ |
1381 |
for(int it2=0;it2<5;it2++)coval[it1][it2] = 0; |
al[it1] = 0; |
1382 |
}; |
for(int it2=0;it2<5;it2++)coval[it1][it2] = 0; |
1383 |
for(int ip=0;ip<6;ip++){ |
}; |
1384 |
xgood[ip] = 0; |
for(int ip=0;ip<6;ip++){ |
1385 |
ygood[ip] = 0; |
xgood[ip] = 0; |
1386 |
xm[ip] = 0; |
ygood[ip] = 0; |
1387 |
ym[ip] = 0; |
xm[ip] = 0; |
1388 |
zm[ip] = 0; |
ym[ip] = 0; |
1389 |
resx[ip] = 0; |
zm[ip] = 0; |
1390 |
resy[ip] = 0; |
resx[ip] = 0; |
1391 |
xv[ip] = 0; |
resy[ip] = 0; |
1392 |
yv[ip] = 0; |
tailx[ip] = 0; |
1393 |
zv[ip] = 0; |
taily[ip] = 0; |
1394 |
axv[ip] = 0; |
xv[ip] = 0; |
1395 |
ayv[ip] = 0; |
yv[ip] = 0; |
1396 |
dedx_x[ip] = 0; |
zv[ip] = 0; |
1397 |
dedx_y[ip] = 0; |
axv[ip] = 0; |
1398 |
// clx[ip] = 0; |
ayv[ip] = 0; |
1399 |
// cly[ip] = 0; |
dedx_x[ip] = 0; |
1400 |
}; |
dedx_y[ip] = 0; |
1401 |
clx->Clear(); |
|
1402 |
cly->Clear(); |
}; |
1403 |
|
int ngf = TrkParams::nGF; |
1404 |
|
for(int i=0; i<ngf; i++){ |
1405 |
|
xGF[i] = 0.; |
1406 |
|
yGF[i] = 0.; |
1407 |
|
} |
1408 |
|
// if(clx)clx->Clear(); |
1409 |
|
// if(cly)cly->Clear(); |
1410 |
|
// clx.Clear(); |
1411 |
|
// cly.Clear(); |
1412 |
}; |
}; |
1413 |
//-------------------------------------- |
//-------------------------------------- |
1414 |
// |
// |
1415 |
// |
// |
1416 |
//-------------------------------------- |
//-------------------------------------- |
1417 |
void TrkTrack::Delete(){ |
void TrkTrack::Delete(){ |
1418 |
Clear(); |
// cout << "TrkTrack::Delete()"<<endl; |
1419 |
clx->Delete(); |
Clear(); |
1420 |
cly->Delete(); |
// if(clx)delete clx; |
1421 |
|
// if(cly)delete cly; |
1422 |
}; |
}; |
1423 |
//-------------------------------------- |
//-------------------------------------- |
1424 |
// |
// |
1425 |
// |
// |
1426 |
//-------------------------------------- |
//-------------------------------------- |
1430 |
// |
// |
1431 |
//-------------------------------------- |
//-------------------------------------- |
1432 |
TrkSinglet::TrkSinglet(){ |
TrkSinglet::TrkSinglet(){ |
1433 |
plane = 0; |
// cout << "TrkSinglet::TrkSinglet() " << GetUniqueID()<<endl; |
1434 |
coord[0] = 0; |
// plane = 0; |
1435 |
coord[1] = 0; |
// coord[0] = 0; |
1436 |
sgnl = 0; |
// coord[1] = 0; |
1437 |
cls = 0; |
// sgnl = 0; |
1438 |
|
// multmax = 0; |
1439 |
|
// cls = 0; |
1440 |
|
Clear(); |
1441 |
}; |
}; |
1442 |
//-------------------------------------- |
//-------------------------------------- |
1443 |
// |
// |
1444 |
// |
// |
1445 |
//-------------------------------------- |
//-------------------------------------- |
1446 |
TrkSinglet::TrkSinglet(const TrkSinglet& s){ |
TrkSinglet::TrkSinglet(const TrkSinglet& s){ |
1447 |
|
// cout << "TrkSinglet::TrkSinglet(const TrkSinglet& s) " << GetUniqueID()<<endl; |
1448 |
plane = s.plane; |
plane = s.plane; |
1449 |
coord[0] = s.coord[0]; |
coord[0] = s.coord[0]; |
1450 |
coord[1] = s.coord[1]; |
coord[1] = s.coord[1]; |
1451 |
sgnl = s.sgnl; |
sgnl = s.sgnl; |
1452 |
|
multmax = s.multmax; |
1453 |
// cls = 0;//<<<<pointer |
// cls = 0;//<<<<pointer |
1454 |
cls = TRef(s.cls); |
// cls = TRef(s.cls); |
1455 |
}; |
}; |
1456 |
//-------------------------------------- |
//-------------------------------------- |
1457 |
// |
// |
1460 |
void TrkSinglet::Dump(){ |
void TrkSinglet::Dump(){ |
1461 |
int i=0; |
int i=0; |
1462 |
cout << endl << "========== Singlet " ; |
cout << endl << "========== Singlet " ; |
1463 |
cout << endl << "plane : " << plane; |
cout << endl << "plane : " << plane; |
1464 |
cout << endl << "coord[2] : "; while( i<2 && cout << coord[i] << " ") i++; |
cout << endl << "coord[2] : "; while( i<2 && cout << coord[i] << " ") i++; |
1465 |
cout << endl << "sgnl : " << sgnl; |
cout << endl << "sgnl : " << sgnl; |
1466 |
|
cout << endl << "max.strip : "; |
1467 |
|
cout << endl << "multiplicity : "; |
1468 |
|
} |
1469 |
|
//-------------------------------------- |
1470 |
|
// |
1471 |
|
// |
1472 |
|
//-------------------------------------- |
1473 |
|
void TrkSinglet::Clear(){ |
1474 |
|
// cout << "TrkSinglet::Clear() " << GetUniqueID()<<endl; |
1475 |
|
// cls=0; |
1476 |
|
plane=-1; |
1477 |
|
coord[0]=-999; |
1478 |
|
coord[1]=-999; |
1479 |
|
sgnl=0; |
1480 |
|
multmax = 0; |
1481 |
|
|
1482 |
} |
} |
1483 |
//-------------------------------------- |
//-------------------------------------- |
1484 |
// |
// |
1485 |
// |
// |
1486 |
//-------------------------------------- |
//-------------------------------------- |
1487 |
TrkLevel2::TrkLevel2(){ |
TrkLevel2::TrkLevel2(){ |
1488 |
// good2 = -1; |
// cout <<"TrkLevel2::TrkLevel2()"<<endl; |
1489 |
for(Int_t i=0; i<12 ; i++){ |
for(Int_t i=0; i<12 ; i++){ |
1490 |
// crc[i] = -1; |
good[i] = -1; |
1491 |
good[i] = -1; |
VKmask[i] = 0; |
1492 |
}; |
VKflag[i] = 0; |
1493 |
Track = new TClonesArray("TrkTrack"); |
}; |
1494 |
SingletX = new TClonesArray("TrkSinglet"); |
Track = 0; |
1495 |
SingletY = new TClonesArray("TrkSinglet"); |
SingletX = 0; |
1496 |
|
SingletY = 0; |
1497 |
|
|
1498 |
// PhysicalTrack = new TClonesArray("TrkTrack"); |
} |
1499 |
//sostituire con TRefArray... appena ho capito come si usa |
//-------------------------------------- |
1500 |
|
// |
1501 |
|
// |
1502 |
|
//-------------------------------------- |
1503 |
|
void TrkLevel2::Set(){ |
1504 |
|
if(!Track)Track = new TClonesArray("TrkTrack"); |
1505 |
|
if(!SingletX)SingletX = new TClonesArray("TrkSinglet"); |
1506 |
|
if(!SingletY)SingletY = new TClonesArray("TrkSinglet"); |
1507 |
} |
} |
1508 |
//-------------------------------------- |
//-------------------------------------- |
1509 |
// |
// |
1511 |
//-------------------------------------- |
//-------------------------------------- |
1512 |
void TrkLevel2::Dump(){ |
void TrkLevel2::Dump(){ |
1513 |
|
|
|
TClonesArray &t = *Track; |
|
|
TClonesArray &sx = *SingletX; |
|
|
TClonesArray &sy = *SingletY; |
|
1514 |
// |
// |
1515 |
cout << endl << endl << "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"; |
cout << endl << endl << "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"; |
1516 |
cout << endl << "good : "; for(int i=0; i<12; i++) cout << good[i]<<" "; |
cout << endl << "good : "; for(int i=0; i<12; i++) cout << hex <<" 0x"<< good[i]<<dec; |
1517 |
cout << endl << "ntrk() : " << this->ntrk() ; |
cout << endl << "ntrk() : " << ntrk() ; |
1518 |
cout << endl << "nclsx() : " << this->nclsx(); |
cout << endl << "nclsx() : " << nclsx(); |
1519 |
cout << endl << "nclsy() : " << this->nclsy(); |
cout << endl << "nclsy() : " << nclsy(); |
1520 |
for(int i=0; i<this->ntrk(); i++) ((TrkTrack *)t[i])->Dump(); |
if(Track){ |
1521 |
for(int i=0; i<this->nclsx(); i++) ((TrkSinglet *)sx[i])->Dump(); |
TClonesArray &t = *Track; |
1522 |
for(int i=0; i<this->nclsy(); i++) ((TrkSinglet *)sy[i])->Dump(); |
for(int i=0; i<ntrk(); i++) ((TrkTrack *)t[i])->Dump(); |
1523 |
|
} |
1524 |
|
// if(SingletX){ |
1525 |
|
// TClonesArray &sx = *SingletX; |
1526 |
|
// for(int i=0; i<nclsx(); i++) ((TrkSinglet *)sx[i])->Dump(); |
1527 |
|
// } |
1528 |
|
// if(SingletY){ |
1529 |
|
// TClonesArray &sy = *SingletY; |
1530 |
|
// for(int i=0; i<nclsy(); i++) ((TrkSinglet *)sy[i])->Dump(); |
1531 |
|
// } |
1532 |
|
cout << endl; |
1533 |
|
} |
1534 |
|
/** |
1535 |
|
* \brief Dump processing status |
1536 |
|
*/ |
1537 |
|
void TrkLevel2::StatusDump(int view){ |
1538 |
|
cout << "DSP n. "<<view+1<<" status: "<<hex<<good[view]<<endl; |
1539 |
|
}; |
1540 |
|
/** |
1541 |
|
* \brief Check event status |
1542 |
|
* |
1543 |
|
* Check the event status, according to a flag-mask given as input. |
1544 |
|
* Return true if the view passes the check. |
1545 |
|
* |
1546 |
|
* @param view View number (0-11) |
1547 |
|
* @param flagmask Mask of flags to check (eg. flagmask=0x111 no missing packet, |
1548 |
|
* no crc error, no software alarm) |
1549 |
|
* |
1550 |
|
* @see TrkLevel2 class definition to know how the status flag is defined |
1551 |
|
* |
1552 |
|
*/ |
1553 |
|
Bool_t TrkLevel2::StatusCheck(int view, int flagmask){ |
1554 |
|
|
1555 |
|
if( view<0 || view >= 12)return false; |
1556 |
|
return !(good[view]&flagmask); |
1557 |
|
|
1558 |
|
}; |
1559 |
|
|
1560 |
|
|
1561 |
|
//-------------------------------------- |
1562 |
|
// |
1563 |
|
// |
1564 |
|
//-------------------------------------- |
1565 |
|
/** |
1566 |
|
* The method returns false if the viking-chip was masked |
1567 |
|
* either apriori ,on the basis of the mask read from the DB, |
1568 |
|
* or run-by-run, on the basis of the calibration parameters) |
1569 |
|
* @param iv Tracker view (0-11) |
1570 |
|
* @param ivk Viking-chip number (0-23) |
1571 |
|
*/ |
1572 |
|
Bool_t TrkLevel2::GetVKMask(int iv, int ivk){ |
1573 |
|
Int_t whichbit = (Int_t)pow(2,ivk); |
1574 |
|
return (whichbit&VKmask[iv])!=0; |
1575 |
} |
} |
1576 |
|
/** |
1577 |
|
* The method returns false if the viking-chip was masked |
1578 |
|
* for this event due to common-noise computation failure. |
1579 |
|
* @param iv Tracker view (0-11) |
1580 |
|
* @param ivk Viking-chip number (0-23) |
1581 |
|
*/ |
1582 |
|
Bool_t TrkLevel2::GetVKFlag(int iv, int ivk){ |
1583 |
|
Int_t whichbit = (Int_t)pow(2,ivk); |
1584 |
|
return (whichbit&VKflag[iv])!=0; |
1585 |
|
} |
1586 |
|
/** |
1587 |
|
* The method returns true if the viking-chip was masked, either |
1588 |
|
* forced (see TrkLevel2::GetVKMask(int,int)) or |
1589 |
|
* for this event only (TrkLevel2::GetVKFlag(int,int)). |
1590 |
|
* @param iv Tracker view (0-11) |
1591 |
|
* @param ivk Viking-chip number (0-23) |
1592 |
|
*/ |
1593 |
|
Bool_t TrkLevel2::IsMaskedVK(int iv, int ivk){ |
1594 |
|
return !(GetVKMask(iv,ivk)&&GetVKFlag(iv,ivk) ); |
1595 |
|
}; |
1596 |
|
|
1597 |
//-------------------------------------- |
//-------------------------------------- |
1598 |
// |
// |
1599 |
// |
// |
1600 |
//-------------------------------------- |
//-------------------------------------- |
1601 |
/** |
/** |
1602 |
* 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). |
1603 |
|
* Ref to Level1 data (clusters) is also set. If l1==NULL no references are set. |
1604 |
|
* (NB It make sense to set references only if events are stored in a tree that contains also the Level1 branch) |
1605 |
*/ |
*/ |
1606 |
void TrkLevel2::SetFromLevel2Struct(cTrkLevel2 *l2){ |
void TrkLevel2::SetFromLevel2Struct(cTrkLevel2 *l2, TrkLevel1 *l1){ |
1607 |
|
|
1608 |
|
// cout << "void TrkLevel2::SetFromLevel2Struct(cTrkLevel2 *l2, TrkLevel1 *l1)"<<endl; |
1609 |
|
Clear(); |
1610 |
|
|
1611 |
// temporary objects: |
// temporary objects: |
1612 |
TrkSinglet* t_singlet = new TrkSinglet(); |
TrkSinglet* t_singlet = new TrkSinglet(); |
1613 |
TrkTrack* t_track = new TrkTrack(); |
TrkTrack* t_track = new TrkTrack(); |
1614 |
|
|
1615 |
// **** general variables **** |
// ----------------- |
1616 |
// good2 = l2->good2; |
// general variables |
1617 |
|
// ----------------- |
1618 |
for(Int_t i=0; i<12 ; i++){ |
for(Int_t i=0; i<12 ; i++){ |
1619 |
// crc[i] = l2->crc[i]; |
good[i] = l2->good[i]; |
1620 |
good[i] = l2->good[i]; |
VKmask[i]=0; |
1621 |
|
VKflag[i]=0; |
1622 |
|
for(Int_t ii=0; ii<24 ; ii++){ |
1623 |
|
Int_t setbit = (Int_t)pow(2,ii); |
1624 |
|
if( l2->vkflag[ii][i]!=-1 )VKmask[i]=VKmask[i]|setbit; |
1625 |
|
if( l2->vkflag[ii][i]!=0 )VKflag[i]=VKflag[i]|setbit; |
1626 |
}; |
}; |
1627 |
// *** TRACKS *** |
}; |
1628 |
|
// -------------- |
1629 |
|
// *** TRACKS *** |
1630 |
|
// -------------- |
1631 |
|
if(!Track) Track = new TClonesArray("TrkTrack"); |
1632 |
TClonesArray &t = *Track; |
TClonesArray &t = *Track; |
1633 |
|
|
1634 |
for(int i=0; i<l2->ntrk; i++){ |
for(int i=0; i<l2->ntrk; i++){ |
1635 |
t_track->seqno = i;// NBNBNBNB deve sempre essere = i |
t_track->seqno = i;// NBNBNBNB deve sempre essere = i |
1636 |
t_track->image = l2->image[i]-1; |
t_track->image = l2->image[i]-1; |
1637 |
// cout << "track "<<i<<t_track->seqno << t_track->image<<endl; |
t_track->chi2 = l2->chi2_nt[i]; |
1638 |
t_track->chi2 = l2->chi2_nt[i]; |
t_track->nstep = l2->nstep_nt[i]; |
1639 |
t_track->nstep = l2->nstep_nt[i]; |
for(int it1=0;it1<5;it1++){ |
1640 |
for(int it1=0;it1<5;it1++){ |
t_track->al[it1] = l2->al_nt[i][it1]; |
1641 |
t_track->al[it1] = l2->al_nt[i][it1]; |
for(int it2=0;it2<5;it2++) |
1642 |
for(int it2=0;it2<5;it2++) |
t_track->coval[it1][it2] = l2->coval[i][it2][it1]; |
1643 |
t_track->coval[it1][it2] = l2->coval[i][it2][it1]; |
}; |
1644 |
}; |
for(int ip=0;ip<6;ip++){ |
1645 |
for(int ip=0;ip<6;ip++){ |
// --------------------------------- |
1646 |
t_track->xgood[ip] = l2->xgood_nt[i][ip]; |
// new implementation of xgood/ygood |
1647 |
t_track->ygood[ip] = l2->ygood_nt[i][ip]; |
// --------------------------------- |
1648 |
t_track->xm[ip] = l2->xm_nt[i][ip]; |
t_track->xgood[ip] = l2->cltrx[i][ip]; //cluster ID |
1649 |
t_track->ym[ip] = l2->ym_nt[i][ip]; |
t_track->ygood[ip] = l2->cltry[i][ip]; //cluster ID |
1650 |
t_track->zm[ip] = l2->zm_nt[i][ip]; |
t_track->xgood[ip] += 10000000*l2->ls[i][ip]; // ladder+sensor |
1651 |
t_track->resx[ip] = l2->resx_nt[i][ip]; |
t_track->ygood[ip] += 10000000*l2->ls[i][ip]; // ladder+sensor |
1652 |
t_track->resy[ip] = l2->resy_nt[i][ip]; |
if(l2->xbad[i][ip]>0)t_track->xgood[ip]=-t_track->xgood[ip]; |
1653 |
t_track->xv[ip] = l2->xv_nt[i][ip]; |
if(l2->ybad[i][ip]>0)t_track->ygood[ip]=-t_track->ygood[ip]; |
1654 |
t_track->yv[ip] = l2->yv_nt[i][ip]; |
// if(l2->xbad[i][ip]>0 || l2->ybad[i][ip]>0){ |
1655 |
t_track->zv[ip] = l2->zv_nt[i][ip]; |
// if(l2->dedx_x[i][ip]<0 || l2->dedx_y[i][ip]<0){ |
1656 |
t_track->axv[ip] = l2->axv_nt[i][ip]; |
// cout << ip << " - "<< l2->cltrx[i][ip] << " "<<l2->cltry[i][ip]<<" "<<l2->ls[i][ip]<<endl; |
1657 |
t_track->ayv[ip] = l2->ayv_nt[i][ip]; |
// cout << ip << " - "<<t_track->xgood[ip]<<" "<<t_track->ygood[ip]<<endl; |
1658 |
t_track->dedx_x[ip] = l2->dedx_x[i][ip]; |
// cout << ip << " - "<<t_track->GetClusterX_ID(ip)<<" "<<t_track->GetClusterY_ID(ip)<<" "<<t_track->GetLadder(ip)<<" "<<t_track->GetSensor(ip)<<endl; |
1659 |
t_track->dedx_y[ip] = l2->dedx_y[i][ip]; |
// cout << ip << " - "<<t_track->BadClusterX(ip)<<" "<<t_track->BadClusterY(ip)<<endl; |
1660 |
// t_track->clx[ip] = 0; |
// cout << ip << " - "<<t_track->SaturatedClusterX(ip)<<" "<<t_track->SaturatedClusterY(ip)<<endl; |
1661 |
// t_track->cly[ip] = 0; |
// } |
1662 |
}; |
t_track->xm[ip] = l2->xm_nt[i][ip]; |
1663 |
new(t[i]) TrkTrack(*t_track); |
t_track->ym[ip] = l2->ym_nt[i][ip]; |
1664 |
t_track->Clear(); |
t_track->zm[ip] = l2->zm_nt[i][ip]; |
1665 |
}; |
t_track->resx[ip] = l2->resx_nt[i][ip]; |
1666 |
|
t_track->resy[ip] = l2->resy_nt[i][ip]; |
1667 |
|
t_track->tailx[ip] = l2->tailx[i][ip]; |
1668 |
|
t_track->taily[ip] = l2->taily[i][ip]; |
1669 |
|
t_track->xv[ip] = l2->xv_nt[i][ip]; |
1670 |
|
t_track->yv[ip] = l2->yv_nt[i][ip]; |
1671 |
|
t_track->zv[ip] = l2->zv_nt[i][ip]; |
1672 |
|
t_track->axv[ip] = l2->axv_nt[i][ip]; |
1673 |
|
t_track->ayv[ip] = l2->ayv_nt[i][ip]; |
1674 |
|
t_track->dedx_x[ip] = l2->dedx_x[i][ip]; |
1675 |
|
t_track->dedx_y[ip] = l2->dedx_y[i][ip]; |
1676 |
|
t_track->multmaxx[ip] = l2->multmaxx[i][ip]; |
1677 |
|
t_track->multmaxy[ip] = l2->multmaxy[i][ip]; |
1678 |
|
t_track->seedx[ip] = l2->seedx[i][ip]; |
1679 |
|
t_track->seedy[ip] = l2->seedy[i][ip]; |
1680 |
|
t_track->xpu[ip] = l2->xpu[i][ip]; |
1681 |
|
t_track->ypu[ip] = l2->ypu[i][ip]; |
1682 |
|
//----------------------------------------------------- |
1683 |
|
//----------------------------------------------------- |
1684 |
|
//----------------------------------------------------- |
1685 |
|
//----------------------------------------------------- |
1686 |
|
}; |
1687 |
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
1688 |
|
// evaluated coordinates (to define GF) |
1689 |
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
1690 |
|
int ngf = TrkParams::nGF; |
1691 |
|
float *zgf = TrkParams::zGF; |
1692 |
|
Trajectory tgf = Trajectory(ngf,zgf); |
1693 |
|
tgf.DoTrack2(t_track->al);//<<<< integrate the trajectory |
1694 |
|
for(int ip=0; ip<ngf; ip++){ |
1695 |
|
t_track->xGF[ip] = tgf.x[ip]; |
1696 |
|
t_track->yGF[ip] = tgf.y[ip]; |
1697 |
|
} |
1698 |
|
|
1699 |
|
// if(t_track->IsSaturated())t_track->Dump(); |
1700 |
|
new(t[i]) TrkTrack(*t_track); |
1701 |
|
t_track->Clear(); |
1702 |
|
};//end loop over track |
1703 |
|
|
1704 |
|
// ---------------- |
1705 |
// *** SINGLETS *** |
// *** SINGLETS *** |
1706 |
|
// ---------------- |
1707 |
|
if(!SingletX)SingletX = new TClonesArray("TrkSinglet"); |
1708 |
TClonesArray &sx = *SingletX; |
TClonesArray &sx = *SingletX; |
1709 |
for(int i=0; i<l2->nclsx; i++){ |
for(int i=0; i<l2->nclsx; i++){ |
1710 |
t_singlet->plane = l2->planex[i]; |
t_singlet->plane = l2->planex[i]; |
1711 |
t_singlet->coord[0] = l2->xs[i][0]; |
t_singlet->coord[0] = l2->xs[i][0]; |
1712 |
t_singlet->coord[1] = l2->xs[i][1]; |
t_singlet->coord[1] = l2->xs[i][1]; |
1713 |
t_singlet->sgnl = l2->signlxs[i]; |
t_singlet->sgnl = l2->signlxs[i]; |
1714 |
// t_singlet->cls = 0; |
t_singlet->multmax = l2->multmaxsx[i]; |
1715 |
new(sx[i]) TrkSinglet(*t_singlet); |
if(l2->sxbad[i]>0) t_singlet->multmax = -1*t_singlet->multmax; |
1716 |
t_singlet->Clear(); |
//----------------------------------------------------- |
1717 |
|
// if(l1) t_singlet->cls = l1->GetCluster(l2->clsx[i]-1); |
1718 |
|
//----------------------------------------------------- |
1719 |
|
new(sx[i]) TrkSinglet(*t_singlet); |
1720 |
|
t_singlet->Clear(); |
1721 |
} |
} |
1722 |
|
if(!SingletY)SingletY = new TClonesArray("TrkSinglet"); |
1723 |
TClonesArray &sy = *SingletY; |
TClonesArray &sy = *SingletY; |
1724 |
for(int i=0; i<l2->nclsy; i++){ |
for(int i=0; i<l2->nclsy; i++){ |
1725 |
t_singlet->plane = l2->planey[i]; |
t_singlet->plane = l2->planey[i]; |
1726 |
t_singlet->coord[0] = l2->ys[i][0]; |
t_singlet->coord[0] = l2->ys[i][0]; |
1727 |
t_singlet->coord[1] = l2->ys[i][1]; |
t_singlet->coord[1] = l2->ys[i][1]; |
1728 |
t_singlet->sgnl = l2->signlys[i]; |
t_singlet->sgnl = l2->signlys[i]; |
1729 |
// t_singlet->cls = 0; |
t_singlet->multmax = l2->multmaxsy[i]; |
1730 |
new(sy[i]) TrkSinglet(*t_singlet); |
if(l2->sybad[i]>0) t_singlet->multmax = -1*t_singlet->multmax; |
1731 |
t_singlet->Clear(); |
//----------------------------------------------------- |
1732 |
}; |
// if(l1) t_singlet->cls = l1->GetCluster(l2->clsy[i]-1); |
1733 |
|
//----------------------------------------------------- |
1734 |
delete t_track; |
new(sy[i]) TrkSinglet(*t_singlet); |
1735 |
delete t_singlet; |
t_singlet->Clear(); |
1736 |
} |
}; |
1737 |
//-------------------------------------- |
|
|
// |
|
|
// |
|
|
//-------------------------------------- |
|
|
/** |
|
|
* 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){ |
|
1738 |
|
|
|
// 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]; |
|
|
good[i] = l2->good[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]; |
|
|
t_track->nstep = l2->nstep_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); |
|
|
// if(t_track->ygood[ip])cout<<" i "<<i<<" ip "<<ip<<" l2->cltry[i][ip] "<<l2->cltry[i][ip]<< " l1->GetCluster(l2->cltry[i][ip]-1) "<<l1->GetCluster(l2->cltry[i][ip]-1)<<endl; |
|
|
// if(t_track->xgood[ip])cout<<" i "<<i<<" ip "<<ip<<" l2->cltrx[i][ip] "<<l2->cltrx[i][ip]<< " l1->GetCluster(l2->cltrx[i][ip]-1) "<<l1->GetCluster(l2->cltrx[i][ip]-1)<<endl; |
|
|
//----------------------------------------------------- |
|
|
}; |
|
|
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); |
|
|
// cout<<" i "<<i<<" l2->clsx[i] "<<l2->clsx[i]<< " l1->GetCluster(l2->clsx[i]-1) "<<l1->GetCluster(l2->clsx[i]-1)<<endl; |
|
|
//----------------------------------------------------- |
|
|
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); |
|
|
// cout<<" i "<<i<<" l2->clsy[i] "<<l2->clsy[i]<< " l1->GetCluster(l2->clsy[i]-1) "<<l1->GetCluster(l2->clsy[i]-1)<<endl; |
|
|
//----------------------------------------------------- |
|
|
new(sy[i]) TrkSinglet(*t_singlet); |
|
|
t_singlet->Clear(); |
|
|
}; |
|
1739 |
|
|
1740 |
delete t_track; |
delete t_track; |
1741 |
delete t_singlet; |
delete t_singlet; |
1742 |
} |
} |
1743 |
/** |
/** |
1744 |
* 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). |
1754 |
}; |
}; |
1755 |
// *** TRACKS *** |
// *** TRACKS *** |
1756 |
|
|
1757 |
l2->ntrk = Track->GetEntries(); |
if(Track){ |
1758 |
for(Int_t i=0;i<l2->ntrk;i++){ |
l2->ntrk = Track->GetEntries(); |
1759 |
l2->image[i] = 1 + ((TrkTrack *)Track->At(i))->image; |
for(Int_t i=0;i<l2->ntrk;i++){ |
1760 |
l2->chi2_nt[i] = ((TrkTrack *)Track->At(i))->chi2; |
l2->image[i] = 1 + ((TrkTrack *)Track->At(i))->image; |
1761 |
l2->nstep_nt[i] = ((TrkTrack *)Track->At(i))->nstep; |
l2->chi2_nt[i] = ((TrkTrack *)Track->At(i))->chi2; |
1762 |
for(int it1=0;it1<5;it1++){ |
l2->nstep_nt[i] = ((TrkTrack *)Track->At(i))->nstep; |
1763 |
l2->al_nt[i][it1] = ((TrkTrack *)Track->At(i))->al[it1]; |
for(int it1=0;it1<5;it1++){ |
1764 |
for(int it2=0;it2<5;it2++) |
l2->al_nt[i][it1] = ((TrkTrack *)Track->At(i))->al[it1]; |
1765 |
l2->coval[i][it2][it1] = ((TrkTrack *)Track->At(i))->coval[it1][it2]; |
for(int it2=0;it2<5;it2++) |
1766 |
}; |
l2->coval[i][it2][it1] = ((TrkTrack *)Track->At(i))->coval[it1][it2]; |
1767 |
for(int ip=0;ip<6;ip++){ |
}; |
1768 |
l2->xgood_nt[i][ip] = ((TrkTrack *)Track->At(i))->xgood[ip]; |
for(int ip=0;ip<6;ip++){ |
1769 |
l2->ygood_nt[i][ip] = ((TrkTrack *)Track->At(i))->ygood[ip]; |
l2->xgood_nt[i][ip] = ((TrkTrack *)Track->At(i))->XGood(ip); |
1770 |
l2->xm_nt[i][ip] = ((TrkTrack *)Track->At(i))->xm[ip]; |
l2->ygood_nt[i][ip] = ((TrkTrack *)Track->At(i))->YGood(ip); |
1771 |
l2->ym_nt[i][ip] = ((TrkTrack *)Track->At(i))->ym[ip]; |
l2->xm_nt[i][ip] = ((TrkTrack *)Track->At(i))->xm[ip]; |
1772 |
l2->zm_nt[i][ip] = ((TrkTrack *)Track->At(i))->zm[ip]; |
l2->ym_nt[i][ip] = ((TrkTrack *)Track->At(i))->ym[ip]; |
1773 |
l2->resx_nt[i][ip] = ((TrkTrack *)Track->At(i))->resx[ip]; |
l2->zm_nt[i][ip] = ((TrkTrack *)Track->At(i))->zm[ip]; |
1774 |
l2->resy_nt[i][ip] = ((TrkTrack *)Track->At(i))->resy[ip]; |
l2->resx_nt[i][ip] = ((TrkTrack *)Track->At(i))->resx[ip]; |
1775 |
l2->xv_nt[i][ip] = ((TrkTrack *)Track->At(i))->xv[ip]; |
l2->resy_nt[i][ip] = ((TrkTrack *)Track->At(i))->resy[ip]; |
1776 |
l2->yv_nt[i][ip] = ((TrkTrack *)Track->At(i))->yv[ip]; |
l2->tailx[i][ip] = ((TrkTrack *)Track->At(i))->tailx[ip]; |
1777 |
l2->zv_nt[i][ip] = ((TrkTrack *)Track->At(i))->zv[ip]; |
l2->taily[i][ip] = ((TrkTrack *)Track->At(i))->taily[ip]; |
1778 |
l2->axv_nt[i][ip] = ((TrkTrack *)Track->At(i))->axv[ip]; |
l2->xv_nt[i][ip] = ((TrkTrack *)Track->At(i))->xv[ip]; |
1779 |
l2->ayv_nt[i][ip] = ((TrkTrack *)Track->At(i))->ayv[ip]; |
l2->yv_nt[i][ip] = ((TrkTrack *)Track->At(i))->yv[ip]; |
1780 |
l2->dedx_x[i][ip] = ((TrkTrack *)Track->At(i))->dedx_x[ip]; |
l2->zv_nt[i][ip] = ((TrkTrack *)Track->At(i))->zv[ip]; |
1781 |
l2->dedx_y[i][ip] = ((TrkTrack *)Track->At(i))->dedx_y[ip]; |
l2->axv_nt[i][ip] = ((TrkTrack *)Track->At(i))->axv[ip]; |
1782 |
}; |
l2->ayv_nt[i][ip] = ((TrkTrack *)Track->At(i))->ayv[ip]; |
1783 |
|
l2->dedx_x[i][ip] = ((TrkTrack *)Track->At(i))->dedx_x[ip]; |
1784 |
|
l2->dedx_y[i][ip] = ((TrkTrack *)Track->At(i))->dedx_y[ip]; |
1785 |
|
}; |
1786 |
|
} |
1787 |
} |
} |
|
|
|
1788 |
// *** SINGLETS *** |
// *** SINGLETS *** |
1789 |
l2->nclsx = SingletX->GetEntries(); |
if(SingletX){ |
1790 |
for(Int_t i=0;i<l2->nclsx;i++){ |
l2->nclsx = SingletX->GetEntries(); |
1791 |
l2->planex[i] = ((TrkSinglet *)SingletX->At(i))->plane; |
for(Int_t i=0;i<l2->nclsx;i++){ |
1792 |
l2->xs[i][0] = ((TrkSinglet *)SingletX->At(i))->coord[0]; |
l2->planex[i] = ((TrkSinglet *)SingletX->At(i))->plane; |
1793 |
l2->xs[i][1] = ((TrkSinglet *)SingletX->At(i))->coord[1]; |
l2->xs[i][0] = ((TrkSinglet *)SingletX->At(i))->coord[0]; |
1794 |
l2->signlxs[i] = ((TrkSinglet *)SingletX->At(i))->sgnl; |
l2->xs[i][1] = ((TrkSinglet *)SingletX->At(i))->coord[1]; |
1795 |
} |
l2->signlxs[i] = ((TrkSinglet *)SingletX->At(i))->sgnl; |
1796 |
l2->nclsy = SingletY->GetEntries(); |
} |
1797 |
for(Int_t i=0;i<l2->nclsy;i++){ |
} |
1798 |
l2->planey[i] = ((TrkSinglet *)SingletY->At(i))->plane; |
|
1799 |
l2->ys[i][0] = ((TrkSinglet *)SingletY->At(i))->coord[0]; |
if(SingletY){ |
1800 |
l2->ys[i][1] = ((TrkSinglet *)SingletY->At(i))->coord[1]; |
l2->nclsy = SingletY->GetEntries(); |
1801 |
l2->signlys[i] = ((TrkSinglet *)SingletY->At(i))->sgnl; |
for(Int_t i=0;i<l2->nclsy;i++){ |
1802 |
|
l2->planey[i] = ((TrkSinglet *)SingletY->At(i))->plane; |
1803 |
|
l2->ys[i][0] = ((TrkSinglet *)SingletY->At(i))->coord[0]; |
1804 |
|
l2->ys[i][1] = ((TrkSinglet *)SingletY->At(i))->coord[1]; |
1805 |
|
l2->signlys[i] = ((TrkSinglet *)SingletY->At(i))->sgnl; |
1806 |
|
} |
1807 |
} |
} |
1808 |
} |
} |
1809 |
//-------------------------------------- |
//-------------------------------------- |
1811 |
// |
// |
1812 |
//-------------------------------------- |
//-------------------------------------- |
1813 |
void TrkLevel2::Clear(){ |
void TrkLevel2::Clear(){ |
|
// good2 = -1; |
|
1814 |
for(Int_t i=0; i<12 ; i++){ |
for(Int_t i=0; i<12 ; i++){ |
1815 |
// crc[i] = -1; |
good[i] = -1; |
1816 |
good[i] = -1; |
VKflag[i] = 0; |
1817 |
}; |
VKmask[i] = 0; |
1818 |
/* Track->RemoveAll(); |
}; |
1819 |
SingletX->RemoveAll(); |
// if(Track)Track->Clear("C"); |
1820 |
SingletY->RemoveAll();*/ |
// if(SingletX)SingletX->Clear("C"); |
1821 |
// modify to avoid memory leakage |
// if(SingletY)SingletY->Clear("C"); |
1822 |
Track->Clear(); |
if(Track)Track->Delete(); |
1823 |
SingletX->Clear(); |
if(SingletX)SingletX->Delete(); |
1824 |
SingletY->Clear(); |
if(SingletY)SingletY->Delete(); |
1825 |
} |
} |
1826 |
//-------------------------------------- |
// //-------------------------------------- |
1827 |
// |
// // |
1828 |
// |
// // |
1829 |
//-------------------------------------- |
// //-------------------------------------- |
1830 |
void TrkLevel2::Delete(){ |
void TrkLevel2::Delete(){ |
1831 |
|
|
1832 |
Clear(); |
// cout << "void TrkLevel2::Delete()"<<endl; |
1833 |
Track->Delete(); |
Clear(); |
1834 |
SingletX->Delete(); |
if(Track)delete Track; |
1835 |
SingletY->Delete(); |
if(SingletX)delete SingletX; |
1836 |
|
if(SingletY)delete SingletY; |
1837 |
|
|
1838 |
} |
} |
1839 |
//-------------------------------------- |
//-------------------------------------- |
1840 |
// |
// |
1846 |
*/ |
*/ |
1847 |
TRefArray *TrkLevel2::GetTracks_NFitSorted(){ |
TRefArray *TrkLevel2::GetTracks_NFitSorted(){ |
1848 |
|
|
1849 |
TRefArray *sorted = new TRefArray(); |
if(!Track)return 0; |
1850 |
|
|
1851 |
|
// TRefArray *sorted = new TRefArray(); |
1852 |
|
TRefArray *sorted = NULL; |
1853 |
|
|
1854 |
TClonesArray &t = *Track; |
TClonesArray &t = *Track; |
1855 |
// TClonesArray &ts = *PhysicalTrack; |
// TClonesArray &ts = *PhysicalTrack; |
1856 |
int N = ntrk(); |
int N = ntrk(); |
1857 |
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; |
1858 |
// int m[50]; for(int i=0; i<N; i++)m[i]=1; |
// int m[50]; for(int i=0; i<N; i++)m[i]=1; |
1859 |
|
|
1860 |
int indo=0; |
int indo=0; |
1861 |
int indi=0; |
int indi=0; |
1862 |
while(N != 0){ |
while(N > 0){ |
1863 |
int nfit =0; |
// while(N != 0){ |
1864 |
float chi2ref = numeric_limits<float>::max(); |
int nfit =0; |
1865 |
|
float chi2ref = numeric_limits<float>::max(); |
1866 |
|
|
1867 |
// first loop to search maximum num. of fit points |
// first loop to search maximum num. of fit points |
1868 |
for(int i=0; i < ntrk(); i++){ |
for(int i=0; i < ntrk(); i++){ |
1869 |
if( ((TrkTrack *)t[i])->GetNtot() >= nfit && m[i]==1){ |
if( ((TrkTrack *)t[i])->GetNtot() >= nfit && m[i]==1){ |
1870 |
nfit = ((TrkTrack *)t[i])->GetNtot(); |
nfit = ((TrkTrack *)t[i])->GetNtot(); |
1871 |
} |
} |
|
} |
|
|
//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--; |
|
|
|
|
|
// cout << "i** "<< ((TrkTrack *)t[indi])->image << " " << nfiti <<" "<<chi2i<<endl; |
|
|
}; |
|
|
sorted->Add( (TrkTrack*)t[indi] ); |
|
|
|
|
|
m[indi] = 0; |
|
|
// cout << "SORTED "<< indo << " "<< indi << " "<< N << endl; |
|
|
N--; |
|
|
indo++; |
|
1872 |
} |
} |
1873 |
m.clear(); |
//second loop to search minimum chi2 among selected |
1874 |
// cout << "GetTracks_NFitSorted(it): Done"<< endl; |
for(int i=0; i<ntrk(); i++){ |
1875 |
|
Float_t chi2 = ((TrkTrack *)t[i])->chi2; |
1876 |
|
if(chi2 < 0) chi2 = -chi2*1000; |
1877 |
|
if( chi2 < chi2ref |
1878 |
|
&& ((TrkTrack *)t[i])->GetNtot() == nfit |
1879 |
|
&& m[i]==1){ |
1880 |
|
chi2ref = ((TrkTrack *)t[i])->chi2; |
1881 |
|
indi = i; |
1882 |
|
}; |
1883 |
|
}; |
1884 |
|
if( ((TrkTrack *)t[indi])->HasImage() ){ |
1885 |
|
m[((TrkTrack *)t[indi])->image] = 0; |
1886 |
|
N--; |
1887 |
|
|
1888 |
|
// cout << "i** "<< ((TrkTrack *)t[indi])->image << " " << nfiti <<" "<<chi2i<<endl; |
1889 |
|
}; |
1890 |
|
if(!sorted)sorted = new TRefArray( TProcessID::GetProcessWithUID(t[indi])); |
1891 |
|
sorted->Add( (TrkTrack*)t[indi] ); |
1892 |
|
|
1893 |
|
m[indi] = 0; |
1894 |
|
// cout << "SORTED "<< indo << " "<< indi << " "<< N << " "<<((TrkTrack *)t[indi])->image<<" "<<chi2ref<<endl; |
1895 |
|
N--; |
1896 |
|
indo++; |
1897 |
|
} |
1898 |
|
m.clear(); |
1899 |
|
// cout << "GetTracks_NFitSorted(it): Done"<< endl; |
1900 |
|
|
1901 |
return sorted; |
return sorted; |
1902 |
// return PhysicalTrack; |
// return PhysicalTrack; |
1903 |
} |
} |
1904 |
//-------------------------------------- |
//-------------------------------------- |
1913 |
TrkTrack *TrkLevel2::GetStoredTrack(int is){ |
TrkTrack *TrkLevel2::GetStoredTrack(int is){ |
1914 |
|
|
1915 |
if(is >= this->ntrk()){ |
if(is >= this->ntrk()){ |
1916 |
cout << "** TrkLevel2 ** Track "<< is << "doen not exits! " << endl; |
cout << "TrkTrack *TrkLevel2::GetStoredTrack(int) >> Track "<< is << "doen not exits! " << endl; |
1917 |
cout << " Stored tracks ntrk() = "<< this->ntrk() << endl; |
cout << "Stored tracks ntrk() = "<< this->ntrk() << endl; |
1918 |
return 0; |
return 0; |
1919 |
} |
} |
1920 |
|
if(!Track){ |
1921 |
|
cout << "TrkTrack *TrkLevel2::GetStoredTrack(int is) >> (TClonesArray*) Track ==0 "<<endl; |
1922 |
|
}; |
1923 |
TClonesArray &t = *(Track); |
TClonesArray &t = *(Track); |
1924 |
TrkTrack *track = (TrkTrack*)t[is]; |
TrkTrack *track = (TrkTrack*)t[is]; |
1925 |
return track; |
return track; |
1935 |
TrkSinglet *TrkLevel2::GetSingletX(int is){ |
TrkSinglet *TrkLevel2::GetSingletX(int is){ |
1936 |
|
|
1937 |
if(is >= this->nclsx()){ |
if(is >= this->nclsx()){ |
1938 |
cout << "** TrkLevel2 ** Singlet "<< is << "doen not exits! " << endl; |
cout << "TrkSinglet *TrkLevel2::GetSingletX(int) >> Singlet "<< is << "doen not exits! " << endl; |
1939 |
cout << " Stored x-singlets nclsx() = "<< this->nclsx() << endl; |
cout << "Stored x-singlets nclsx() = "<< this->nclsx() << endl; |
1940 |
return 0; |
return 0; |
1941 |
} |
} |
1942 |
|
if(!SingletX)return 0; |
1943 |
TClonesArray &t = *(SingletX); |
TClonesArray &t = *(SingletX); |
1944 |
TrkSinglet *singlet = (TrkSinglet*)t[is]; |
TrkSinglet *singlet = (TrkSinglet*)t[is]; |
1945 |
return singlet; |
return singlet; |
1955 |
TrkSinglet *TrkLevel2::GetSingletY(int is){ |
TrkSinglet *TrkLevel2::GetSingletY(int is){ |
1956 |
|
|
1957 |
if(is >= this->nclsy()){ |
if(is >= this->nclsy()){ |
1958 |
cout << "** TrkLevel2 ** Singlet "<< is << "doen not exits! " << endl; |
cout << "TrkSinglet *TrkLevel2::GetSingletY(int) >> Singlet "<< is << "doen not exits! " << endl; |
1959 |
cout << " Stored y-singlets nclsy() = "<< this->nclsx() << endl; |
cout << "Stored y-singlets nclsx() = "<< this->nclsx() << endl; |
1960 |
return 0; |
return 0; |
1961 |
} |
} |
1962 |
|
if(!SingletY)return 0; |
1963 |
TClonesArray &t = *(SingletY); |
TClonesArray &t = *(SingletY); |
1964 |
TrkSinglet *singlet = (TrkSinglet*)t[is]; |
TrkSinglet *singlet = (TrkSinglet*)t[is]; |
1965 |
return singlet; |
return singlet; |
1976 |
TrkTrack *TrkLevel2::GetTrack(int it){ |
TrkTrack *TrkLevel2::GetTrack(int it){ |
1977 |
|
|
1978 |
if(it >= this->GetNTracks()){ |
if(it >= this->GetNTracks()){ |
1979 |
cout << "** TrkLevel2 ** Track "<< it << "does not exits! " << endl; |
cout << "TrkTrack *TrkLevel2::GetTrack(int) >> Track "<< it << "does not exits! " << endl; |
1980 |
cout << " Physical tracks GetNTracks() = "<< this->ntrk() << endl; |
cout << "Physical tracks GetNTracks() = "<< this->ntrk() << endl; |
1981 |
return 0; |
return 0; |
1982 |
} |
} |
1983 |
|
|
1984 |
TRefArray *sorted = GetTracks(); //TEMPORANEO |
TRefArray *sorted = GetTracks(); //TEMPORANEO |
1985 |
|
if(!sorted)return 0; |
1986 |
TrkTrack *track = (TrkTrack*)sorted->At(it); |
TrkTrack *track = (TrkTrack*)sorted->At(it); |
1987 |
sorted->Delete(); |
sorted->Clear(); |
1988 |
|
delete sorted; |
1989 |
return track; |
return track; |
1990 |
} |
} |
1991 |
/** |
/** |
1994 |
Int_t TrkLevel2::GetNTracks(){ |
Int_t TrkLevel2::GetNTracks(){ |
1995 |
|
|
1996 |
Float_t ntot=0; |
Float_t ntot=0; |
1997 |
|
if(!Track)return 0; |
1998 |
TClonesArray &t = *Track; |
TClonesArray &t = *Track; |
1999 |
for(int i=0; i<ntrk(); i++) { |
for(int i=0; i<ntrk(); i++) { |
2000 |
if( ((TrkTrack *)t[i])->GetImageSeqNo() == -1 ) ntot+=1.; |
if( ((TrkTrack *)t[i])->GetImageSeqNo() == -1 ) ntot+=1.; |
2001 |
else ntot+=0.5; |
else ntot+=0.5; |
2002 |
} |
} |
2013 |
*/ |
*/ |
2014 |
TrkTrack *TrkLevel2::GetTrackImage(int it){ |
TrkTrack *TrkLevel2::GetTrackImage(int it){ |
2015 |
|
|
2016 |
if(it >= this->GetNTracks()){ |
if(it >= this->GetNTracks()){ |
2017 |
cout << "** TrkLevel2 ** Track "<< it << "does not exits! " << endl; |
cout << "TrkTrack *TrkLevel2::GetTrackImage(int) >> Track "<< it << "does not exits! " << endl; |
2018 |
cout << " Physical tracks GetNTracks() = "<< this->ntrk() << endl; |
cout << "Physical tracks GetNTracks() = "<< this->ntrk() << endl; |
2019 |
return 0; |
return 0; |
2020 |
} |
} |
2021 |
|
|
2022 |
TRefArray* sorted = GetTracks(); //TEMPORANEO |
TRefArray* sorted = GetTracks(); //TEMPORANEO |
2023 |
TrkTrack *track = (TrkTrack*)sorted->At(it); |
if(!sorted)return 0; |
2024 |
|
TrkTrack *track = (TrkTrack*)sorted->At(it); |
2025 |
|
|
2026 |
if(!track->HasImage()){ |
if(!track->HasImage()){ |
2027 |
cout << "** TrkLevel2 ** Track "<< it << "does not have image! " << endl; |
cout << "TrkTrack *TrkLevel2::GetTrackImage(int) >> Track "<< it << "does not have image! " << endl; |
2028 |
return 0; |
return 0; |
2029 |
} |
} |
2030 |
TrkTrack *image = (TrkTrack*)(*Track)[track->image]; |
if(!Track)return 0; |
2031 |
|
TrkTrack *image = (TrkTrack*)(*Track)[track->image]; |
2032 |
|
|
2033 |
sorted->Delete(); |
sorted->Delete(); |
2034 |
|
delete sorted; |
2035 |
return image; |
|
2036 |
|
return image; |
2037 |
|
|
2038 |
} |
} |
2039 |
//-------------------------------------- |
//-------------------------------------- |
2044 |
* Loads the magnetic field. |
* Loads the magnetic field. |
2045 |
* @param s Path of the magnetic-field files. |
* @param s Path of the magnetic-field files. |
2046 |
*/ |
*/ |
2047 |
void TrkLevel2::LoadField(TString s){ |
void TrkLevel2::LoadField(TString path){ |
2048 |
readb_(s.Data()); |
// |
2049 |
|
// strcpy(path_.path,path.Data()); |
2050 |
|
// path_.pathlen = path.Length(); |
2051 |
|
// path_.error = 0; |
2052 |
|
// readb_(); |
2053 |
|
|
2054 |
|
// TrkParams::SetTrackingMode(); |
2055 |
|
// TrkParams::SetPrecisionFactor(); |
2056 |
|
// TrkParams::SetStepMin(); |
2057 |
|
TrkParams::SetMiniDefault(); |
2058 |
|
|
2059 |
|
TrkParams::Set(path,1); |
2060 |
|
TrkParams::Load(1); |
2061 |
|
if( !TrkParams::IsLoaded(1) ){ |
2062 |
|
cout << "void TrkLevel2::LoadField(TString path) --- ERROR --- m.field not loaded"<<endl; |
2063 |
|
} |
2064 |
|
|
2065 |
|
// |
2066 |
}; |
}; |
2067 |
|
// /** |
2068 |
|
// * Get BY (kGauss) |
2069 |
|
// * @param v (x,y,z) coordinates in cm |
2070 |
|
// */ |
2071 |
|
// float TrkLevel2::GetBX(float* v){ |
2072 |
|
// float b[3]; |
2073 |
|
// gufld_(v,b); |
2074 |
|
// return b[0]/10.; |
2075 |
|
// } |
2076 |
|
// /** |
2077 |
|
// * Get BY (kGauss) |
2078 |
|
// * @param v (x,y,z) coordinates in cm |
2079 |
|
// */ |
2080 |
|
// float TrkLevel2::GetBY(float* v){ |
2081 |
|
// float b[3]; |
2082 |
|
// gufld_(v,b); |
2083 |
|
// return b[1]/10.; |
2084 |
|
// } |
2085 |
|
// /** |
2086 |
|
// * Get BY (kGauss) |
2087 |
|
// * @param v (x,y,z) coordinates in cm |
2088 |
|
// */ |
2089 |
|
// float TrkLevel2::GetBZ(float* v){ |
2090 |
|
// float b[3]; |
2091 |
|
// gufld_(v,b); |
2092 |
|
// return b[2]/10.; |
2093 |
|
// } |
2094 |
//-------------------------------------- |
//-------------------------------------- |
2095 |
// |
// |
2096 |
// |
// |
2187 |
tl = new float[npoint]; |
tl = new float[npoint]; |
2188 |
int i=0; |
int i=0; |
2189 |
do{ |
do{ |
2190 |
x[i] = 0; |
x[i] = 0; |
2191 |
y[i] = 0; |
y[i] = 0; |
2192 |
z[i] = zin[i]; |
z[i] = zin[i]; |
2193 |
thx[i] = 0; |
thx[i] = 0; |
2194 |
thy[i] = 0; |
thy[i] = 0; |
2195 |
tl[i] = 0; |
tl[i] = 0; |
2196 |
i++; |
i++; |
2197 |
}while(zin[i-1] > zin[i] && i < npoint); |
}while(zin[i-1] > zin[i] && i < npoint); |
2198 |
npoint=i; |
npoint=i; |
2199 |
if(npoint != n)cout << "NB! Trajectory created with "<<npoint<<" points"<<endl; |
if(npoint != n)cout << "NB! Trajectory created with "<<npoint<<" points"<<endl; |
2200 |
} |
} |
2201 |
|
void Trajectory::Delete(){ |
2202 |
|
|
2203 |
|
if(x) delete [] x; |
2204 |
|
if(y) delete [] y; |
2205 |
|
if(z) delete [] z; |
2206 |
|
if(thx) delete [] thx; |
2207 |
|
if(thy) delete [] thy; |
2208 |
|
if(tl) delete [] tl; |
2209 |
|
|
2210 |
|
} |
2211 |
//-------------------------------------- |
//-------------------------------------- |
2212 |
// |
// |
2213 |
// |
// |
2246 |
|
|
2247 |
} |
} |
2248 |
|
|
2249 |
|
/** |
2250 |
|
* Evaluates the trajectory in the apparatus associated to the track. |
2251 |
|
* 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. |
2252 |
|
* @param t pointer to an object of the class Trajectory, |
2253 |
|
* which z coordinates should be previously initialized by calling the proper constructor ( Trajectory::Trajectory(int n, float* zin) ). |
2254 |
|
* @return error flag. |
2255 |
|
*/ |
2256 |
|
int Trajectory::DoTrack2(float* al){ |
2257 |
|
|
2258 |
|
// double *dxout = new double[npoint]; |
2259 |
|
// double *dyout = new double[npoint]; |
2260 |
|
// double *dthxout = new double[npoint]; |
2261 |
|
// double *dthyout = new double[npoint]; |
2262 |
|
// double *dtlout = new double[npoint]; |
2263 |
|
// double *dzin = new double[npoint]; |
2264 |
|
|
2265 |
|
double *dxout; |
2266 |
|
double *dyout; |
2267 |
|
double *dthxout; |
2268 |
|
double *dthyout; |
2269 |
|
double *dtlout; |
2270 |
|
double *dzin; |
2271 |
|
|
2272 |
|
dxout = (double*) malloc(npoint*sizeof(double)); |
2273 |
|
dyout = (double*) malloc(npoint*sizeof(double)); |
2274 |
|
dthxout = (double*) malloc(npoint*sizeof(double)); |
2275 |
|
dthyout = (double*) malloc(npoint*sizeof(double)); |
2276 |
|
dtlout = (double*) malloc(npoint*sizeof(double)); |
2277 |
|
dzin = (double*) malloc(npoint*sizeof(double)); |
2278 |
|
|
2279 |
|
double dal[5]; |
2280 |
|
|
2281 |
|
int ifail = 0; |
2282 |
|
|
2283 |
|
for (int i=0; i<5; i++) dal[i] = (double)al[i]; |
2284 |
|
for (int i=0; i<npoint; i++) dzin[i] = (double)z[i]; |
2285 |
|
|
2286 |
|
TrkParams::Load(1); |
2287 |
|
if( !TrkParams::IsLoaded(1) ){ |
2288 |
|
cout << "int Trajectory::DoTrack2(float* al) --- ERROR --- m.field not loaded"<<endl; |
2289 |
|
return 0; |
2290 |
|
} |
2291 |
|
dotrack2_(&(npoint),dzin,dxout,dyout,dthxout,dthyout,dtlout,dal,&ifail); |
2292 |
|
|
2293 |
|
for (int i=0; i<npoint; i++){ |
2294 |
|
x[i] = (float)*(dxout+i); |
2295 |
|
y[i] = (float)*(dyout+i); |
2296 |
|
thx[i] = (float)*(dthxout+i); |
2297 |
|
thy[i] = (float)*(dthyout+i); |
2298 |
|
tl[i] = (float)*(dtlout+i); |
2299 |
|
} |
2300 |
|
|
2301 |
|
if(dxout) free( dxout ); |
2302 |
|
if(dyout) free( dyout ); |
2303 |
|
if(dthxout)free( dthxout ); |
2304 |
|
if(dthyout)free( dthyout ); |
2305 |
|
if(dtlout) free( dtlout ); |
2306 |
|
if(dzin) free( dzin ); |
2307 |
|
|
2308 |
|
// delete [] dxout; |
2309 |
|
// delete [] dyout; |
2310 |
|
// delete [] dthxout; |
2311 |
|
// delete [] dthyout; |
2312 |
|
// delete [] dtlout; |
2313 |
|
// delete [] dzin; |
2314 |
|
|
2315 |
|
|
2316 |
|
return ifail; |
2317 |
|
}; |
2318 |
|
|
2319 |
ClassImp(TrkLevel2); |
ClassImp(TrkLevel2); |
2320 |
ClassImp(TrkSinglet); |
ClassImp(TrkSinglet); |