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*); |
|
// int readb_(const char*); |
|
|
int readb_(); |
|
15 |
void mini2_(int*,int*,int*); |
void mini2_(int*,int*,int*); |
16 |
void guess_(); |
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 |
//-------------------------------------- |
//-------------------------------------- |
|
/** |
|
|
* Evaluates the trajectory in the apparatus associated to the track. |
|
|
* 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. |
|
|
* @param t pointer to an object of the class Trajectory, |
|
|
* which z coordinates should be previously initialized by calling the proper constructor ( Trajectory::Trajectory(int n, float* zin) ). |
|
|
* @return error flag. |
|
|
*/ |
|
|
int Trajectory::DoTrack2(float* al){ |
|
|
|
|
|
double *dxout = new double[npoint]; |
|
|
double *dyout = new double[npoint]; |
|
|
double *dthxout = new double[npoint]; |
|
|
double *dthyout = new double[npoint]; |
|
|
double *dtlout = new double[npoint]; |
|
|
double *dzin = new double[npoint]; |
|
|
double dal[5]; |
|
|
|
|
|
int ifail = 0; |
|
|
|
|
|
for (int i=0; i<5; i++) dal[i] = (double)al[i]; |
|
|
for (int i=0; i<npoint; i++) dzin[i] = (double)z[i]; |
|
|
|
|
|
dotrack2_(&(npoint),dzin,dxout,dyout,dthxout,dthyout,dtlout,dal,&ifail); |
|
|
|
|
|
for (int i=0; i<npoint; i++){ |
|
|
x[i] = (float)*dxout++; |
|
|
y[i] = (float)*dyout++; |
|
|
thx[i] = (float)*dthxout++; |
|
|
thy[i] = (float)*dthyout++; |
|
|
tl[i] = (float)*dtlout++; |
|
|
} |
|
|
|
|
|
return ifail; |
|
|
}; |
|
|
//--------------------------------------------- |
|
|
//--------------------------------------------- |
|
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; |
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 |
// |
// |
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 reduced chi-square of track x-projection |
404 |
|
*/ |
405 |
|
Float_t TrkTrack::GetChi2X(){ |
406 |
|
float chiq=0; |
407 |
|
for(int ip=0; ip<6; ip++)if(XGood(ip))chiq+= pow((xv[ip]-xm[ip])/resx[ip],2.); |
408 |
|
if(GetNX()>3)chiq=chiq/(GetNX()-3); |
409 |
|
else chiq=0; |
410 |
|
if(chiq==0)cout << " Float_t TrkTrack::GetChi2X() -- WARNING -- value not defined "<<chiq<<endl; |
411 |
|
return chiq; |
412 |
|
} |
413 |
|
/** |
414 |
|
* Returns the reduced chi-square of track y-projection |
415 |
|
*/ |
416 |
|
Float_t TrkTrack::GetChi2Y(){ |
417 |
|
float chiq=0; |
418 |
|
for(int ip=0; ip<6; ip++)if(YGood(ip))chiq+= pow((yv[ip]-ym[ip])/resy[ip],2.); |
419 |
|
if(GetNY()>2)chiq=chiq/(GetNY()-2); |
420 |
|
else chiq=0; |
421 |
|
if(chiq==0)cout << " Float_t TrkTrack::GetChi2Y() -- WARNING -- value not defined "<<chiq<<endl; |
422 |
|
return chiq; |
423 |
|
} |
424 |
|
/** |
425 |
|
* Returns the logarythm of the likeliwood-function of track x-projection |
426 |
|
*/ |
427 |
|
Float_t TrkTrack::GetLnLX(){ |
428 |
|
float lnl=0; |
429 |
|
for(int ip=0; ip<6; ip++) |
430 |
|
if( XGood(ip) && tailx[ip]!=0 ) |
431 |
|
lnl += (tailx[ip]+1.) * log( (tailx[ip]*pow(resx[ip],2.) + pow(xv[ip]-xm[ip],2.)) / (tailx[ip]*pow(resx[ip],2)) ); |
432 |
|
if(GetNX()>3)lnl=lnl/(GetNX()-3); |
433 |
|
else lnl=0; |
434 |
|
if(lnl==0){ |
435 |
|
cout << " Float_t TrkTrack::GetLnLX() -- WARNING -- value not defined "<<lnl<<endl; |
436 |
|
Dump(); |
437 |
|
} |
438 |
|
return lnl; |
439 |
|
|
440 |
|
} |
441 |
|
/** |
442 |
|
* Returns the logarythm of the likeliwood-function of track y-projection |
443 |
|
*/ |
444 |
|
Float_t TrkTrack::GetLnLY(){ |
445 |
|
float lnl=0; |
446 |
|
for(int ip=0; ip<6; ip++) |
447 |
|
if( YGood(ip) && taily[ip]!=0 ) |
448 |
|
lnl += (taily[ip]+1.) * log( (taily[ip]*pow(resy[ip],2.) + pow(yv[ip]-ym[ip],2.)) / (taily[ip]*pow(resy[ip],2)) ); |
449 |
|
if(GetNY()>2)lnl=lnl/(GetNY()-2); |
450 |
|
else lnl=0; |
451 |
|
if(lnl==0){ |
452 |
|
cout << " Float_t TrkTrack::GetLnLY() -- WARNING -- value not defined "<<lnl<<endl; |
453 |
|
Dump(); |
454 |
|
} |
455 |
|
return lnl; |
456 |
|
|
457 |
|
} |
458 |
|
/** |
459 |
|
* Returns the effective angle, relative to the sensor, on each plane. |
460 |
|
* @param ip plane (0-5) |
461 |
|
* @param iv view (0=x 1=y) |
462 |
|
*/ |
463 |
|
Float_t TrkTrack::GetEffectiveAngle(int ip, int iv){ |
464 |
|
|
465 |
|
if(ip<0 || ip>5){ |
466 |
|
cout << "Float_t TrkTrack::GetEffectiveAngle(int "<<ip<<", int "<<iv<<") ==> wrong input"<<endl; |
467 |
|
return 0.; |
468 |
|
} |
469 |
|
|
470 |
|
float v[3]={xv[ip],yv[ip],zv[ip]}; |
471 |
|
//----------------------------------------- |
472 |
|
// effective angle (relative to the sensor) |
473 |
|
//----------------------------------------- |
474 |
|
float axv_geo = axv[ip]; |
475 |
|
float muhall_h = 297.61; //cm**2/Vs |
476 |
|
float BY = TrkParams::GetBY(v); |
477 |
|
float axv_eff = 0; |
478 |
|
if(ip==5) axv_geo = -1*axv_geo; |
479 |
|
if(ip==5) BY = -1*BY; |
480 |
|
axv_eff = 180.*atan( tan(axv_geo*acos(-1.)/180.) + muhall_h * BY * 0.0001)/acos(-1.); |
481 |
|
//----------------------------------------- |
482 |
|
// effective angle (relative to the sensor) |
483 |
|
//----------------------------------------- |
484 |
|
float ayv_geo = ayv[ip]; |
485 |
|
float muhall_e = 1258.18; //cm**2/Vs |
486 |
|
float BX = TrkParams::GetBX(v); |
487 |
|
float ayv_eff = 0; |
488 |
|
ayv_eff = 180.*atan( tan(ayv_geo*acos(-1.)/180.) + muhall_e * BX * 0.0001)/acos(-1.); |
489 |
|
|
490 |
|
if (iv==0)return axv_eff; |
491 |
|
else if(iv==1)return ayv_eff; |
492 |
|
else{ |
493 |
|
cout << "Float_t TrkTrack::GetEffectiveAngle(int "<<ip<<", int "<<iv<<") ==> wrong input"<<endl; |
494 |
|
return 0.; |
495 |
|
} |
496 |
|
|
497 |
}; |
}; |
498 |
|
|
499 |
//-------------------------------------- |
//-------------------------------------- |
507 |
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] << " "; |
508 |
cout << endl << "chi^2 : "<< chi2; |
cout << endl << "chi^2 : "<< chi2; |
509 |
cout << endl << "n.step : "<< nstep; |
cout << endl << "n.step : "<< nstep; |
510 |
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) ; |
511 |
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) ; |
512 |
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] << " "; |
513 |
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] << " "; |
514 |
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] << " "; |
517 |
cout << endl << "zv : "; for(int i=0; i<6; i++)cout << zv[i] << " "; |
cout << endl << "zv : "; for(int i=0; i<6; i++)cout << zv[i] << " "; |
518 |
cout << endl << "resx : "; for(int i=0; i<6; i++)cout << resx[i] << " "; |
cout << endl << "resx : "; for(int i=0; i<6; i++)cout << resx[i] << " "; |
519 |
cout << endl << "resy : "; for(int i=0; i<6; i++)cout << resy[i] << " "; |
cout << endl << "resy : "; for(int i=0; i<6; i++)cout << resy[i] << " "; |
520 |
|
cout << endl << "tailx : "; for(int i=0; i<6; i++)cout << tailx[i] << " "; |
521 |
|
cout << endl << "taily : "; for(int i=0; i<6; i++)cout << taily[i] << " "; |
522 |
cout << endl << "coval : "; for(int i=0; i<5; i++)cout << coval[0][i]<<" "; |
cout << endl << "coval : "; for(int i=0; i<5; i++)cout << coval[0][i]<<" "; |
523 |
cout << endl << " "; for(int i=0; i<5; i++)cout << coval[1][i]<<" "; |
cout << endl << " "; for(int i=0; i<5; i++)cout << coval[1][i]<<" "; |
524 |
cout << endl << " "; for(int i=0; i<5; i++)cout << coval[2][i]<<" "; |
cout << endl << " "; for(int i=0; i<5; i++)cout << coval[2][i]<<" "; |
526 |
cout << endl << " "; for(int i=0; i<5; i++)cout << coval[4][i]<<" "; |
cout << endl << " "; for(int i=0; i<5; i++)cout << coval[4][i]<<" "; |
527 |
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] << " "; |
528 |
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] << " "; |
529 |
|
cout << endl << "maxs x : "; for(int i=0; i<6; i++)cout << GetClusterX_MaxStrip(i) << " "; |
530 |
|
cout << endl << "maxs y : "; for(int i=0; i<6; i++)cout << GetClusterY_MaxStrip(i) << " "; |
531 |
|
cout << endl << "mult x : "; for(int i=0; i<6; i++)cout << GetClusterX_Multiplicity(i) << " "; |
532 |
|
cout << endl << "mult y : "; for(int i=0; i<6; i++)cout << GetClusterY_Multiplicity(i) << " "; |
533 |
|
cout << endl << "seed x : "; for(int i=0; i<6; i++)cout << GetClusterX_Seed(i) << " "; |
534 |
|
cout << endl << "seed y : "; for(int i=0; i<6; i++)cout << GetClusterY_Seed(i) << " "; |
535 |
|
cout << endl << "xpu : "; for(int i=0; i<6; i++)cout << xpu[i] << " "; |
536 |
|
cout << endl << "ypu : "; for(int i=0; i<6; i++)cout << ypu[i] << " "; |
537 |
|
|
538 |
cout << endl; |
cout << endl; |
539 |
} |
} |
540 |
/** |
/** |
553 |
for(int i=0; i<6; i++) resy[i]=*ry++; |
for(int i=0; i<6; i++) resy[i]=*ry++; |
554 |
} |
} |
555 |
/** |
/** |
556 |
|
* Set the TrkTrack tails position resolution |
557 |
|
*/ |
558 |
|
void TrkTrack::SetTail(double *tx, double *ty, double factor){ |
559 |
|
for(int i=0; i<6; i++) tailx[i]=factor*(*tx++); |
560 |
|
for(int i=0; i<6; i++) taily[i]=factor*(*ty++); |
561 |
|
} |
562 |
|
/** |
563 |
|
* Set the TrkTrack Student parameter (resx,resy,tailx,taily) |
564 |
|
* from previous gausian fit |
565 |
|
*@param flag =0 standard, =1 with noise correction |
566 |
|
*/ |
567 |
|
void TrkTrack::SetStudentParam(int flag){ |
568 |
|
float sx[11]={0.000128242, |
569 |
|
0.000136942, |
570 |
|
0.000162718, |
571 |
|
0.000202644, |
572 |
|
0.00025597, |
573 |
|
0.000317456, |
574 |
|
0.000349048, |
575 |
|
0.000384638, |
576 |
|
0.000457295, |
577 |
|
0.000512319, |
578 |
|
0.000538573}; |
579 |
|
float tx[11]={1.79402, |
580 |
|
2.04876, |
581 |
|
2.88376, |
582 |
|
3.3, |
583 |
|
3.14084, |
584 |
|
4.07686, |
585 |
|
4.44736, |
586 |
|
3.5179, |
587 |
|
3.38697, |
588 |
|
3.45739, |
589 |
|
3.18627}; |
590 |
|
float sy[11]={0.000483075, |
591 |
|
0.000466925, |
592 |
|
0.000431658, |
593 |
|
0.000428317, |
594 |
|
0.000433854, |
595 |
|
0.000444044, |
596 |
|
0.000482098, |
597 |
|
0.000537579, |
598 |
|
0.000636279, |
599 |
|
0.000741998, |
600 |
|
0.000864261}; |
601 |
|
float ty[11]={0.997032, |
602 |
|
1.11147, |
603 |
|
1.18526, |
604 |
|
1.61404, |
605 |
|
2.21908, |
606 |
|
3.08959, |
607 |
|
4.48833, |
608 |
|
4.42687, |
609 |
|
4.65253, |
610 |
|
4.52043, |
611 |
|
4.29926}; |
612 |
|
int index; |
613 |
|
float fact; |
614 |
|
for(int i=0; i<6; i++) { |
615 |
|
index = int((fabs(axv[i])+1.)/2.); |
616 |
|
if(index>10) index=10; |
617 |
|
tailx[i]=tx[index]; |
618 |
|
if(flag==1) { |
619 |
|
if(fabs(axv[i])<=10.) fact = resx[i]/risxeta2_(&(axv[i])); |
620 |
|
if(fabs(axv[i])>10.&&fabs(axv[i])<=15.) fact = resx[i]/risxeta3_(&(axv[i])); |
621 |
|
if(fabs(axv[i])>15.) fact = resx[i]/risxeta4_(&(axv[i])); |
622 |
|
} else fact = 1.; |
623 |
|
resx[i] = sx[index]*fact; |
624 |
|
} |
625 |
|
for(int i=0; i<6; i++) { |
626 |
|
index = int((fabs(ayv[i])+1.)/2.); |
627 |
|
if(index>10) index=10; |
628 |
|
taily[i]=ty[index]; |
629 |
|
if(flag==1) fact = resy[i]/risyeta2_(&(ayv[i])); |
630 |
|
else fact = 1.; |
631 |
|
resy[i] = sy[index]*fact; |
632 |
|
} |
633 |
|
} |
634 |
|
/** |
635 |
* Set the TrkTrack good measurement |
* Set the TrkTrack good measurement |
636 |
*/ |
*/ |
637 |
void TrkTrack::SetGood(int *xg, int *yg){ |
void TrkTrack::SetGood(int *xg, int *yg){ |
638 |
|
|
639 |
for(int i=0; i<6; i++) xgood[i]=*xg++; |
for(int i=0; i<6; i++) xgood[i]=*xg++; |
640 |
for(int i=0; i<6; i++) ygood[i]=*yg++; |
for(int i=0; i<6; i++) ygood[i]=*yg++; |
641 |
} |
} |
645 |
*/ |
*/ |
646 |
void TrkTrack::LoadField(TString path){ |
void TrkTrack::LoadField(TString path){ |
647 |
|
|
648 |
strcpy(path_.path,path.Data()); |
// strcpy(path_.path,path.Data()); |
649 |
path_.pathlen = path.Length(); |
// path_.pathlen = path.Length(); |
650 |
path_.error = 0; |
// path_.error = 0; |
651 |
readb_(); |
// readb_(); |
652 |
|
|
653 |
|
// TrkParams::SetTrackingMode(); |
654 |
|
// TrkParams::SetPrecisionFactor(); |
655 |
|
// TrkParams::SetStepMin(); |
656 |
|
TrkParams::SetMiniDefault(); |
657 |
|
|
658 |
|
TrkParams::Set(path,1); |
659 |
|
TrkParams::Load(1); |
660 |
|
|
661 |
}; |
}; |
662 |
|
|
663 |
|
|
664 |
/** |
/** |
665 |
* Tracking method. It calls F77 mini routine. |
* Method to fill minimization-routine common |
666 |
*/ |
*/ |
667 |
void TrkTrack::Fit(double pfixed, int& fail, int iprint){ |
void TrkTrack::FillMiniStruct(cMini2track& track){ |
668 |
|
|
669 |
|
for(int i=0; i<6; i++){ |
670 |
|
|
671 |
|
// cout << i<<" - "<<xgood[i]<<" "<<XGood(i)<<endl; |
672 |
|
// cout << i<<" - "<<ygood[i]<<" "<<YGood(i)<<endl; |
673 |
|
track.xgood[i]=XGood(i); |
674 |
|
track.ygood[i]=YGood(i); |
675 |
|
|
676 |
|
track.xm[i]=xm[i]; |
677 |
|
track.ym[i]=ym[i]; |
678 |
|
track.zm[i]=zm[i]; |
679 |
|
|
680 |
|
// --- temporaneo ---------------------------- |
681 |
|
// andrebbe inserita la dimensione del sensore |
682 |
|
float segment = 100.; |
683 |
|
track.xm_a[i]=xm[i]; |
684 |
|
track.xm_b[i]=xm[i]; |
685 |
|
track.ym_a[i]=ym[i]; |
686 |
|
track.ym_b[i]=ym[i]; |
687 |
|
if( XGood(i) && !YGood(i) ){ |
688 |
|
track.ym_a[i] = track.ym_a[i]+segment; |
689 |
|
track.ym_b[i] = track.ym_b[i]-segment; |
690 |
|
}else if( !XGood(i) && YGood(i)){ |
691 |
|
track.xm_a[i] = track.xm_a[i]+segment; |
692 |
|
track.xm_b[i] = track.xm_b[i]-segment; |
693 |
|
} |
694 |
|
// --- temporaneo ---------------------------- |
695 |
|
|
696 |
|
track.resx[i]=resx[i]; |
697 |
|
track.resy[i]=resy[i]; |
698 |
|
track.tailx[i]=tailx[i]; |
699 |
|
track.taily[i]=taily[i]; |
700 |
|
} |
701 |
|
|
702 |
|
for(int i=0; i<5; i++) track.al[i]=al[i]; |
703 |
|
track.zini = 23.5; |
704 |
|
// ZINI = 23.5 !!! it should be the same parameter in all codes |
705 |
|
|
706 |
|
} |
707 |
|
/** |
708 |
|
* Method to set values from minimization-routine common |
709 |
|
*/ |
710 |
|
void TrkTrack::SetFromMiniStruct(cMini2track *track){ |
711 |
|
|
712 |
|
for(int i=0; i<5; i++) { |
713 |
|
al[i]=track->al[i]; |
714 |
|
for(int j=0; j<5; j++) coval[i][j]=track->cov[i][j]; |
715 |
|
} |
716 |
|
chi2 = track->chi2; |
717 |
|
nstep = track->nstep; |
718 |
|
for(int i=0; i<6; i++){ |
719 |
|
xv[i] = track->xv[i]; |
720 |
|
yv[i] = track->yv[i]; |
721 |
|
zv[i] = track->zv[i]; |
722 |
|
xm[i] = track->xm[i]; |
723 |
|
ym[i] = track->ym[i]; |
724 |
|
zm[i] = track->zm[i]; |
725 |
|
axv[i] = track->axv[i]; |
726 |
|
ayv[i] = track->ayv[i]; |
727 |
|
} |
728 |
|
|
729 |
|
} |
730 |
|
/** |
731 |
|
* \brief Method to re-evaluate coordinates of clusters associated with a track. |
732 |
|
* |
733 |
|
* The method can be applied only after recovering level1 information |
734 |
|
* (either by reprocessing single events from level0 or from |
735 |
|
* the TrkLevel1 branch, if present); it calls F77 subroutines that |
736 |
|
* read the level1 common and fill the minimization-routine common. |
737 |
|
* Some clusters can be excluded or added by means of the methods: |
738 |
|
* |
739 |
|
* TrkTrack::ResetXGood(int ip) |
740 |
|
* TrkTrack::ResetYGood(int ip) |
741 |
|
* TrkTrack::SetXGood(int ip, int cid, int is) |
742 |
|
* TrkTrack::SetYGood(int ip, int cid, int is) |
743 |
|
* |
744 |
|
* NB! The method TrkTrack::SetGood(int *xg, int *yg) set the plane-mask (0-1) |
745 |
|
* for the minimization-routine common. It deletes the cluster information |
746 |
|
* (at least for the moment...) thus cannot be applied before |
747 |
|
* TrkTrack::EvaluateClusterPositions(). |
748 |
|
* |
749 |
|
* Different p.f.a. can be applied by calling (once) the method: |
750 |
|
* |
751 |
|
* TrkParams::SetPFA(0); //Set ETA p.f.a. |
752 |
|
* |
753 |
|
* @see TrkParams::SetPFA(int) |
754 |
|
*/ |
755 |
|
Bool_t TrkTrack::EvaluateClusterPositions(){ |
756 |
|
|
757 |
|
// cout << "void TrkTrack::GetClusterositions() "<<endl; |
758 |
|
|
759 |
|
TrkParams::Load( ); |
760 |
|
if( !TrkParams::IsLoaded() )return false; |
761 |
|
|
762 |
|
for(int ip=0; ip<6; ip++){ |
763 |
|
// cout << ip<<" ** "<<xm[ip]<<" / "<<ym[ip]<<endl;; |
764 |
|
int icx = GetClusterX_ID(ip)+1; |
765 |
|
int icy = GetClusterY_ID(ip)+1; |
766 |
|
int sensor = GetSensor(ip)+1;//<< convenzione "Paolo" |
767 |
|
if(ip==5 && sensor!=0)sensor=3-sensor;//<< convenzione "Elena" |
768 |
|
int ladder = GetLadder(ip)+1; |
769 |
|
float ax = axv[ip]; |
770 |
|
float ay = ayv[ip]; |
771 |
|
float v[3]; |
772 |
|
v[0]=xv[ip]; |
773 |
|
v[1]=yv[ip]; |
774 |
|
v[2]=zv[ip]; |
775 |
|
float bfx = 10*TrkParams::GetBX(v);//Tesla |
776 |
|
float bfy = 10*TrkParams::GetBY(v);//Tesla |
777 |
|
int ipp=ip+1; |
778 |
|
xyzpam_(&ipp,&icx,&icy,&ladder,&sensor,&ax,&ay,&bfx,&bfy); |
779 |
|
if(icx<0 || icy<0)return false; |
780 |
|
} |
781 |
|
return true; |
782 |
|
} |
783 |
|
/** |
784 |
|
* \brief Tracking method. It calls F77 mini routine. |
785 |
|
* |
786 |
|
* @param pfixed Particle momentum. If pfixed=0 the momentum |
787 |
|
* is left as a free parameter, otherwise it is fixed to the input value. |
788 |
|
* @param fail Output flag (!=0 if the fit failed). |
789 |
|
* @param iprint Flag to set debug mode ( 0 = no output; 1 = verbose; 2 = debug). |
790 |
|
* @param froml1 Flag to re-evaluate positions (see TrkTrack::GetClusterPositions()). |
791 |
|
* |
792 |
|
* The option to re-evaluate positions can be used only after recovering |
793 |
|
* level1 information, eg. by reprocessing the single event. |
794 |
|
* |
795 |
|
* Example: |
796 |
|
* |
797 |
|
* if( !event->GetTrkLevel0() )return false; |
798 |
|
* event->GetTrkLevel0()->ProcessEvent(); // re-processing level0->level1 |
799 |
|
* int fail=0; |
800 |
|
* event->GetTrkLevel2()->GetTrack(0)->Fit(0.,fail,0,1); |
801 |
|
* |
802 |
|
* @see EvaluateClusterPositions() |
803 |
|
* |
804 |
|
* The fitting procedure can be varied by changing the tracking mode, |
805 |
|
* the fit-precision factor, the minimum number of step, etc. |
806 |
|
* @see SetTrackingMode(int) |
807 |
|
* @see SetPrecisionFactor(double) |
808 |
|
* @see SetStepMin(int) |
809 |
|
* @see SetDeltaB(int,double) |
810 |
|
*/ |
811 |
|
void TrkTrack::Fit(double pfixed, int& fail, int iprint, int froml1){ |
812 |
|
|
813 |
float al_ini[] = {0.,0.,0.,0.,0.}; |
float al_ini[] = {0.,0.,0.,0.,0.}; |
814 |
|
|
815 |
|
TrkParams::Load( ); |
816 |
|
if( !TrkParams::IsLoaded() )return; |
817 |
|
|
818 |
extern cMini2track track_; |
extern cMini2track track_; |
819 |
fail = 0; |
fail = 0; |
820 |
|
|
821 |
for(int i=0; i<6; i++) track_.xm[i]=xm[i]; |
FillMiniStruct(track_); |
822 |
for(int i=0; i<6; i++) track_.ym[i]=ym[i]; |
|
823 |
for(int i=0; i<6; i++) track_.zm[i]=zm[i]; |
if(froml1!=0){ |
824 |
for(int i=0; i<6; i++) track_.resx[i]=resx[i]; |
if( !EvaluateClusterPositions() ){ |
825 |
for(int i=0; i<6; i++) track_.resy[i]=resy[i]; |
cout << "void TrkTrack::Fit("<<pfixed<<","<<fail<<","<<iprint<<","<<froml1<<") --- ERROR evaluating cluster positions "<<endl; |
826 |
for(int i=0; i<6; i++) track_.xgood[i]=xgood[i]; |
FillMiniStruct(track_) ; |
827 |
for(int i=0; i<6; i++) track_.ygood[i]=ygood[i]; |
fail = 1; |
828 |
|
return; |
829 |
// initial guess of "al" with linear fit |
} |
830 |
// if(al[0]==-9999.&&al[1]==-9999.&&al[2]==-9999.&&al[3]==-9999.&&al[4]==-9999.){ |
}else{ |
831 |
// cout << "initial guess "<<endl; |
FillMiniStruct(track_); |
832 |
// double szz=0., szx=0., szy=0., ssx=0., ssy=0., sz=0., s1=0.; |
} |
833 |
// double det, ax, ay, bx, by; |
|
834 |
// for(int i=0; i<NPLANE; i++) { |
// if fit variables have been reset, evaluate the initial guess |
|
// szz=szz+zm[i]*zm[i]; |
|
|
// szx=szx+zm[i]*xm[i]; |
|
|
// szy=szy+zm[i]*ym[i]; |
|
|
// ssx=ssx+xm[i]; |
|
|
// ssy=ssy+ym[i]; |
|
|
// sz=sz+zm[i]; |
|
|
// s1=s1+1.; |
|
|
// } |
|
|
// det=szz*s1-sz*sz; |
|
|
// ax=(szx*s1-sz*ssx)/det; |
|
|
// bx=(szz*ssx-szx*sz)/det; |
|
|
// ay=(szy*s1-sz*ssy)/det; |
|
|
// by=(szz*ssy-szy*sz)/det; |
|
|
// al[0]=ax*23.5+bx; // ZINI = 23.5 !!! it should be the same parameter in all codes |
|
|
// al[1]=ay*23.5+by; // " |
|
|
// al[2]= sqrt(pow(ax,2)+pow(ay,2))/ sqrt(pow(ax,2)+pow(ay,2)+1.); |
|
|
// al[3]=0.; |
|
|
// if( (ax!=0.)||(ay!=0.) ) { |
|
|
// al[3]= asin(ay/ sqrt(pow(ax,2)+pow(ay,2))); |
|
|
// if(ax<0.) al[3]=acos(-1.)-al[3]; |
|
|
// } |
|
|
// al[4]=0.; |
|
|
// } |
|
|
// end guess |
|
|
|
|
|
for(int i=0; i<5; i++) track_.al[i]=al[i]; |
|
|
track_.zini = 23.5; |
|
|
// ZINI = 23.5 !!! it should be the same parameter in all codes |
|
|
|
|
835 |
if(al[0]==-9999.&&al[1]==-9999.&&al[2]==-9999.&&al[3]==-9999.&&al[4]==-9999.)guess_(); |
if(al[0]==-9999.&&al[1]==-9999.&&al[2]==-9999.&&al[3]==-9999.&&al[4]==-9999.)guess_(); |
836 |
|
|
837 |
// --------------------- free momentum |
// --------------------- free momentum |
838 |
if(pfixed==0.) { |
if(pfixed==0.) { |
839 |
// al[4]=0.; // free momentum |
track_.pfixed=0.; |
|
track_.pfixed=0.; // " |
|
840 |
} |
} |
841 |
// --------------------- fixed momentum |
// --------------------- fixed momentum |
842 |
if(pfixed!=0.) { |
if(pfixed!=0.) { |
843 |
al[4]=1./pfixed; // to fix the momentum |
al[4]=1./pfixed; |
844 |
track_.pfixed=pfixed; // " |
track_.pfixed=pfixed; |
845 |
} |
} |
846 |
|
|
847 |
// store temporarily the initial guess |
// store temporarily the initial guess |
848 |
for(int i=0; i<5; i++) al_ini[i]=track_.al[i]; |
for(int i=0; i<5; i++) al_ini[i]=track_.al[i]; |
849 |
|
|
850 |
|
// ------------------------------------------ |
851 |
|
// call mini routine |
852 |
|
// TrkParams::Load(1); |
853 |
|
// if( !TrkParams::IsLoaded(1) ){ |
854 |
|
// cout << "void TrkTrack::Fit(double pfixed, int& fail, int iprint) --- ERROR --- m.field not loaded"<<endl; |
855 |
|
// return; |
856 |
|
// } |
857 |
int istep=0; |
int istep=0; |
858 |
int ifail=0; |
int ifail=0; |
859 |
mini2_(&istep,&ifail, &iprint); |
mini2_(&istep,&ifail, &iprint); |
860 |
if(ifail!=0) { |
if(ifail!=0) { |
861 |
if(iprint==1)cout << "ERROR: ifail= " << ifail << endl; |
if(iprint)cout << "ERROR: ifail= " << ifail << endl; |
862 |
fail = 1; |
fail = 1; |
|
// return; |
|
863 |
} |
} |
864 |
|
// ------------------------------------------ |
865 |
|
|
866 |
|
SetFromMiniStruct(&track_); |
|
// cout << endl << "eta ===> " << track_.al[4] << endl; |
|
|
|
|
|
for(int i=0; i<5; i++) al[i]=track_.al[i]; |
|
|
chi2=track_.chi2; |
|
|
nstep=track_.nstep; |
|
|
for(int i=0; i<6; i++) xv[i]=track_.xv[i]; |
|
|
for(int i=0; i<6; i++) yv[i]=track_.yv[i]; |
|
|
for(int i=0; i<6; i++) zv[i]=track_.zv[i]; |
|
|
for(int i=0; i<6; i++) axv[i]=track_.axv[i]; |
|
|
for(int i=0; i<6; i++) ayv[i]=track_.ayv[i]; |
|
|
for(int i=0; i<5; i++) { |
|
|
for(int j=0; j<5; j++) coval[i][j]=track_.cov[i][j]; |
|
|
} |
|
867 |
|
|
868 |
if(fail){ |
if(fail){ |
869 |
cout << " >>>> fit failed >>>> drawing initial par"<<endl; |
if(iprint)cout << " >>>> fit failed "<<endl; |
870 |
for(int i=0; i<5; i++) al[i]=al_ini[i]; |
for(int i=0; i<5; i++) al[i]=al_ini[i]; |
871 |
} |
} |
872 |
|
|
873 |
}; |
}; |
874 |
/* |
/** |
875 |
* Reset the fit parameters |
* Reset the fit parameters |
876 |
*/ |
*/ |
877 |
void TrkTrack::FitReset(){ |
void TrkTrack::FitReset(){ |
878 |
for(int i=0; i<5; i++) al[i]=-9999.; |
for(int i=0; i<5; i++) al[i]=-9999.; |
879 |
chi2=0.; |
chi2=0.; |
880 |
nstep=0; |
nstep=0; |
881 |
for(int i=0; i<6; i++) xv[i]=0.; |
// for(int i=0; i<6; i++) xv[i]=0.; |
882 |
for(int i=0; i<6; i++) yv[i]=0.; |
// for(int i=0; i<6; i++) yv[i]=0.; |
883 |
for(int i=0; i<6; i++) zv[i]=0.; |
// for(int i=0; i<6; i++) zv[i]=0.; |
884 |
for(int i=0; i<6; i++) axv[i]=0.; |
// for(int i=0; i<6; i++) axv[i]=0.; |
885 |
for(int i=0; i<6; i++) ayv[i]=0.; |
// for(int i=0; i<6; i++) ayv[i]=0.; |
886 |
for(int i=0; i<5; i++) { |
for(int i=0; i<5; i++) { |
887 |
for(int j=0; j<5; j++) coval[i][j]=0.; |
for(int j=0; j<5; j++) coval[i][j]=0.; |
888 |
} |
} |
889 |
} |
} |
890 |
|
/** |
891 |
|
* Set the tracking mode |
892 |
|
*/ |
893 |
|
void TrkTrack::SetTrackingMode(int trackmode){ |
894 |
|
extern cMini2track track_; |
895 |
|
track_.trackmode = trackmode; |
896 |
|
} |
897 |
|
/** |
898 |
|
* Set the factor scale for tracking precision |
899 |
|
*/ |
900 |
|
void TrkTrack::SetPrecisionFactor(double fact){ |
901 |
|
extern cMini2track track_; |
902 |
|
track_.fact = fact; |
903 |
|
} |
904 |
|
/** |
905 |
|
* Set the minimum number of steps for tracking precision |
906 |
|
*/ |
907 |
|
void TrkTrack::SetStepMin(int istepmin){ |
908 |
|
extern cMini2track track_; |
909 |
|
track_.istepmin = istepmin; |
910 |
|
} |
911 |
|
/** |
912 |
|
* Set deltaB parameters (id=0,1). By default they are set to zero. |
913 |
|
*/ |
914 |
|
void TrkTrack::SetDeltaB(int id, double db){ |
915 |
|
if(id!=0 && id!=1)cout << "void TrkTrack::SetDeltaB(int id,double db) -- wrong input parameters: "<<id<<" "<<db<<endl; |
916 |
|
TrkParams::SetDeltaB(id,db); |
917 |
|
} |
918 |
|
|
919 |
|
/** |
920 |
|
* Returns true if the track is inside the magnet cavity. |
921 |
|
* @param toll Tolerance around the nominal volume (toll>0 define an inner fiducial volume) |
922 |
|
*/ |
923 |
|
Bool_t TrkTrack::IsInsideCavity(float toll){ |
924 |
|
|
925 |
|
// float xmagntop, ymagntop, xmagnbottom, ymagnbottom; |
926 |
|
// xmagntop = xv[0] + (ZMAGNHIGH-zv[0])*tan(acos(-1.0)*axv[0]/180.); |
927 |
|
// ymagntop = yv[0] + (ZMAGNHIGH-zv[0])*tan(acos(-1.0)*ayv[0]/180.); |
928 |
|
// xmagnbottom = xv[5] + (ZMAGNLOW-zv[5])*tan(acos(-1.0)*axv[5]/180.); |
929 |
|
// ymagnbottom = yv[5] + (ZMAGNLOW-zv[5])*tan(acos(-1.0)*ayv[5]/180.); |
930 |
|
// if( xmagntop>XMAGNLOW && xmagntop<XMAGNHIGH && |
931 |
|
// ymagntop>YMAGNLOW && ymagntop<YMAGNHIGH && |
932 |
|
// xmagnbottom>XMAGNLOW && xmagnbottom<XMAGNHIGH && |
933 |
|
// ymagnbottom>YMAGNLOW && ymagnbottom<YMAGNHIGH ) return(true); |
934 |
|
// else return(false); |
935 |
|
|
936 |
|
int ngf = TrkParams::nGF; |
937 |
|
for(int i=0; i<ngf; i++){ |
938 |
|
// |
939 |
|
// cout << endl << TrkParams::GF_element[i]; |
940 |
|
if( |
941 |
|
TrkParams::GF_element[i].CompareTo("CUF") && |
942 |
|
TrkParams::GF_element[i].CompareTo("T2") && |
943 |
|
TrkParams::GF_element[i].CompareTo("T3") && |
944 |
|
TrkParams::GF_element[i].CompareTo("T4") && |
945 |
|
TrkParams::GF_element[i].CompareTo("T5") && |
946 |
|
TrkParams::GF_element[i].CompareTo("CLF") && |
947 |
|
true)continue; |
948 |
|
// apply condition only within the cavity |
949 |
|
// cout << " -- "<<xGF[i]<<" "<<yGF[i]; |
950 |
|
if( |
951 |
|
xGF[i] <= TrkParams::xGF_min[i] + toll || |
952 |
|
xGF[i] >= TrkParams::xGF_max[i] - toll || |
953 |
|
yGF[i] <= TrkParams::yGF_min[i] + toll || |
954 |
|
yGF[i] >= TrkParams::yGF_max[i] - toll || |
955 |
|
false){ |
956 |
|
|
957 |
|
return false; |
958 |
|
} |
959 |
|
} |
960 |
|
return true; |
961 |
|
|
962 |
|
|
963 |
|
} |
964 |
|
/** |
965 |
|
* Returns true if the track is inside the nominal acceptance, which is defined |
966 |
|
* by the intersection among magnet cavity, silicon-plane sensitive area and |
967 |
|
* ToF sensitive area (nominal values from the official document used to |
968 |
|
* calculate the geometrical factor) |
969 |
|
*/ |
970 |
|
Bool_t TrkTrack::IsInsideAcceptance(){ |
971 |
|
|
972 |
|
int ngf = TrkParams::nGF; |
973 |
|
for(int i=0; i<ngf; i++){ |
974 |
|
if( |
975 |
|
xGF[i] <= TrkParams::xGF_min[i] || |
976 |
|
xGF[i] >= TrkParams::xGF_max[i] || |
977 |
|
yGF[i] <= TrkParams::yGF_min[i] || |
978 |
|
yGF[i] >= TrkParams::yGF_max[i] || |
979 |
|
false)return false; |
980 |
|
} |
981 |
|
return true; |
982 |
|
|
983 |
|
} |
984 |
|
/** |
985 |
|
* Method to retrieve ID (0,1,...) of x-cluster (if any) associated to this track. |
986 |
|
* If no cluster is associated, ID=-1. |
987 |
|
* @param ip Tracker plane (0-5) |
988 |
|
*/ |
989 |
|
Int_t TrkTrack::GetClusterX_ID(int ip){ |
990 |
|
return ((Int_t)fabs(xgood[ip]))%10000000-1; |
991 |
|
}; |
992 |
|
/** |
993 |
|
* Method to retrieve ID (0-xxx) of y-cluster (if any) associated to this track. |
994 |
|
* If no cluster is associated, ID=-1. |
995 |
|
* @param ip Tracker plane (0-5) |
996 |
|
*/ |
997 |
|
Int_t TrkTrack::GetClusterY_ID(int ip){ |
998 |
|
return ((Int_t)fabs(ygood[ip]))%10000000-1; |
999 |
|
}; |
1000 |
|
|
1001 |
|
/** |
1002 |
|
* Method to retrieve the ladder (0-4, increasing x) traversed by the track on this plane. |
1003 |
|
* If no ladder is traversed (dead area) the metod retuns -1. |
1004 |
|
* @param ip Tracker plane (0-5) |
1005 |
|
*/ |
1006 |
|
Int_t TrkTrack::GetLadder(int ip){ |
1007 |
|
if(XGood(ip))return (Int_t)fabs(xgood[ip]/100000000)-1; |
1008 |
|
if(YGood(ip))return (Int_t)fabs(ygood[ip]/100000000)-1; |
1009 |
|
return -1; |
1010 |
|
}; |
1011 |
|
/** |
1012 |
|
* Method to retrieve the sensor (0-1, increasing y) traversed by the track on this plane. |
1013 |
|
* If no sensor is traversed (dead area) the metod retuns -1. |
1014 |
|
* @param ip Tracker plane (0-5) |
1015 |
|
*/ |
1016 |
|
Int_t TrkTrack::GetSensor(int ip){ |
1017 |
|
if(XGood(ip))return (Int_t)((Int_t)fabs(xgood[ip]/10000000)%10)-1; |
1018 |
|
if(YGood(ip))return (Int_t)((Int_t)fabs(ygood[ip]/10000000)%10)-1; |
1019 |
|
return -1; |
1020 |
|
}; |
1021 |
|
|
1022 |
|
/** |
1023 |
|
* \brief Method to include a x-cluster to the track. |
1024 |
|
* @param ip Tracker plane (0-5) |
1025 |
|
* @param clid Cluster ID (0,1,...) |
1026 |
|
* @param is Sensor (0-1, increasing y) |
1027 |
|
* @see Fit(double pfixed, int& fail, int iprint, int froml1) |
1028 |
|
*/ |
1029 |
|
void TrkTrack::SetXGood(int ip, int clid, int is){ |
1030 |
|
int il=0; //ladder (temporary) |
1031 |
|
bool bad=false; //ladder (temporary) |
1032 |
|
xgood[ip]=il*100000000+is*10000000+clid; |
1033 |
|
if(bad)xgood[ip]=-xgood[ip]; |
1034 |
|
}; |
1035 |
|
/** |
1036 |
|
* \brief Method to include a y-cluster to the track. |
1037 |
|
* @param ip Tracker plane (0-5) |
1038 |
|
* @param clid Cluster ID (0,1,...) |
1039 |
|
* @param is Sensor (0-1) |
1040 |
|
* @see Fit(double pfixed, int& fail, int iprint, int froml1) |
1041 |
|
*/ |
1042 |
|
void TrkTrack::SetYGood(int ip, int clid, int is){ |
1043 |
|
int il=0; //ladder (temporary) |
1044 |
|
bool bad=false; //ladder (temporary) |
1045 |
|
ygood[ip]=il*100000000+is*10000000+clid; |
1046 |
|
if(bad)ygood[ip]=-ygood[ip]; |
1047 |
|
}; |
1048 |
|
|
1049 |
|
/** |
1050 |
|
* \brief Average X |
1051 |
|
* Average value of <xv>, evaluated from the first to the last hit x view. |
1052 |
|
*/ |
1053 |
|
Float_t TrkTrack::GetXav(){ |
1054 |
|
|
1055 |
|
int first_plane = -1; |
1056 |
|
int last_plane = -1; |
1057 |
|
for(Int_t ip=0; ip<6; ip++){ |
1058 |
|
if( XGood(ip) && first_plane == -1 )first_plane = ip; |
1059 |
|
if( XGood(ip) && first_plane != -1 )last_plane = ip; |
1060 |
|
} |
1061 |
|
if( first_plane == -1 || last_plane == -1){ |
1062 |
|
return -100; |
1063 |
|
} |
1064 |
|
if( last_plane-first_plane+1 ==0 )return -100; |
1065 |
|
|
1066 |
|
Float_t av = 0; |
1067 |
|
for(int ip=first_plane; ip<=last_plane; ip++)av+=xv[ip]; |
1068 |
|
|
1069 |
|
return (av/(last_plane-first_plane+1)); |
1070 |
|
} |
1071 |
|
/** |
1072 |
|
* \brief Average Y |
1073 |
|
* Average value of <yv>, evaluated from the first to the last hit x view. |
1074 |
|
*/ |
1075 |
|
Float_t TrkTrack::GetYav(){ |
1076 |
|
|
1077 |
|
int first_plane = -1; |
1078 |
|
int last_plane = -1; |
1079 |
|
for(Int_t ip=0; ip<6; ip++){ |
1080 |
|
if( XGood(ip) && first_plane == -1 )first_plane = ip; |
1081 |
|
if( XGood(ip) && first_plane != -1 )last_plane = ip; |
1082 |
|
} |
1083 |
|
if( first_plane == -1 || last_plane == -1){ |
1084 |
|
return -100; |
1085 |
|
} |
1086 |
|
if( last_plane-first_plane+1 ==0 )return -100; |
1087 |
|
|
1088 |
|
Float_t av = 0; |
1089 |
|
for(int ip=first_plane; ip<=last_plane; ip++)av+=yv[ip]; |
1090 |
|
|
1091 |
|
return (av/(last_plane-first_plane+1)); |
1092 |
|
} |
1093 |
|
/** |
1094 |
|
* \brief Average Z |
1095 |
|
* Average value of <zv>, evaluated from the first to the last hit x view. |
1096 |
|
*/ |
1097 |
|
Float_t TrkTrack::GetZav(){ |
1098 |
|
|
1099 |
|
int first_plane = -1; |
1100 |
|
int last_plane = -1; |
1101 |
|
for(Int_t ip=0; ip<6; ip++){ |
1102 |
|
if( XGood(ip) && first_plane == -1 )first_plane = ip; |
1103 |
|
if( XGood(ip) && first_plane != -1 )last_plane = ip; |
1104 |
|
} |
1105 |
|
if( first_plane == -1 || last_plane == -1){ |
1106 |
|
return -100; |
1107 |
|
} |
1108 |
|
if( last_plane-first_plane+1 ==0 )return -100; |
1109 |
|
|
1110 |
|
Float_t av = 0; |
1111 |
|
for(int ip=first_plane; ip<=last_plane; ip++)av+=zv[ip]; |
1112 |
|
|
1113 |
|
return (av/(last_plane-first_plane+1)); |
1114 |
|
} |
1115 |
|
|
1116 |
|
/** |
1117 |
|
* \brief Number of column traversed |
1118 |
|
*/ |
1119 |
|
Int_t TrkTrack::GetNColumns(){ |
1120 |
|
int sensors[] = {0,0,0,0,0,0}; |
1121 |
|
for(int ip=0; ip<6; ip++){ |
1122 |
|
int sensorid = GetLadder(ip)+3*GetSensor(ip); |
1123 |
|
if(XGood(ip)||YGood(ip)) |
1124 |
|
if(sensorid>=0 && sensorid<6)sensors[sensorid]=1; |
1125 |
|
} |
1126 |
|
int nsensors=0; |
1127 |
|
for(int is=0; is<6; is++)nsensors += sensors[is]; |
1128 |
|
return nsensors; |
1129 |
|
}; |
1130 |
|
/** |
1131 |
|
* \brief Give the maximum energy release |
1132 |
|
*/ |
1133 |
|
Float_t TrkTrack::GetDEDX_max(int ip, int iv){ |
1134 |
|
Float_t max=0; |
1135 |
|
int pfrom = 0; |
1136 |
|
int pto = 6; |
1137 |
|
int vfrom = 0; |
1138 |
|
int vto = 2; |
1139 |
|
if(ip>=0&&ip<6){ |
1140 |
|
pfrom = ip; |
1141 |
|
pto = ip+1; |
1142 |
|
} |
1143 |
|
if(iv>=0&&iv<2){ |
1144 |
|
vfrom = iv; |
1145 |
|
vto = iv+1; |
1146 |
|
} |
1147 |
|
for(int i=pfrom; i<pto; i++) |
1148 |
|
for(int j=0; j<vto; j++) |
1149 |
|
if(GetDEDX(i,j)>max)max=GetDEDX(i,j); |
1150 |
|
|
1151 |
|
return max; |
1152 |
|
|
1153 |
|
}; |
1154 |
|
|
1155 |
|
/** |
1156 |
|
* \brief Give the minimum energy release |
1157 |
|
*/ |
1158 |
|
Float_t TrkTrack::GetDEDX_min(int ip, int iv){ |
1159 |
|
Float_t min=100000000; |
1160 |
|
int pfrom = 0; |
1161 |
|
int pto = 6; |
1162 |
|
int vfrom = 0; |
1163 |
|
int vto = 2; |
1164 |
|
if(ip>=0&&ip<6){ |
1165 |
|
pfrom = ip; |
1166 |
|
pto = ip+1; |
1167 |
|
} |
1168 |
|
if(iv>=0&&iv<2){ |
1169 |
|
vfrom = iv; |
1170 |
|
vto = iv+1; |
1171 |
|
} |
1172 |
|
for(int i=pfrom; i<pto; i++) |
1173 |
|
for(int j=0; j<vto; j++) |
1174 |
|
if(GetDEDX(i,j)<min)min=GetDEDX(i,j); |
1175 |
|
|
1176 |
|
return min; |
1177 |
|
|
1178 |
|
}; |
1179 |
|
|
1180 |
|
/** |
1181 |
|
* \brief Give the maximum spatial residual release |
1182 |
|
*/ |
1183 |
|
Float_t TrkTrack::GetResidual_max(int ip, int iv){ |
1184 |
|
Float_t max=0; |
1185 |
|
int pfrom = 0; |
1186 |
|
int pto = 6; |
1187 |
|
int vfrom = 0; |
1188 |
|
int vto = 2; |
1189 |
|
if(ip>=0&&ip<6){ |
1190 |
|
pfrom = ip; |
1191 |
|
pto = ip+1; |
1192 |
|
} |
1193 |
|
if(iv>=0&&iv<2){ |
1194 |
|
vfrom = iv; |
1195 |
|
vto = iv+1; |
1196 |
|
} |
1197 |
|
for(int i=pfrom; i<pto; i++){ |
1198 |
|
for(int j=0; j<vto; j++){ |
1199 |
|
if(j==0 && XGood(i) && fabs(xm[i]-xv[i])>fabs(max))max=xv[i]-xm[i]; |
1200 |
|
if(j==1 && YGood(i) && fabs(ym[i]-yv[i])>fabs(max))max=yv[i]-ym[i]; |
1201 |
|
} |
1202 |
|
} |
1203 |
|
return max; |
1204 |
|
|
1205 |
|
}; |
1206 |
|
|
1207 |
|
|
1208 |
|
/** |
1209 |
|
* \brief Give the maximum multiplicity on the x view |
1210 |
|
*/ |
1211 |
|
Int_t TrkTrack::GetClusterX_Multiplicity_max(){ |
1212 |
|
int max=0; |
1213 |
|
for(int ip=0; ip<6; ip++) |
1214 |
|
if(GetClusterX_Multiplicity(ip)>max)max=GetClusterX_Multiplicity(ip); |
1215 |
|
return max; |
1216 |
|
}; |
1217 |
|
/** |
1218 |
|
* \brief Give the minimum multiplicity on the x view |
1219 |
|
*/ |
1220 |
|
Int_t TrkTrack::GetClusterX_Multiplicity_min(){ |
1221 |
|
int min=50; |
1222 |
|
for(int ip=0; ip<6; ip++) |
1223 |
|
if(GetClusterX_Multiplicity(ip)<min)min=GetClusterX_Multiplicity(ip); |
1224 |
|
return min; |
1225 |
|
}; |
1226 |
|
/** |
1227 |
|
* \brief Give the maximum multiplicity on the x view |
1228 |
|
*/ |
1229 |
|
Int_t TrkTrack::GetClusterY_Multiplicity_max(){ |
1230 |
|
int max=0; |
1231 |
|
for(int ip=0; ip<6; ip++) |
1232 |
|
if(GetClusterY_Multiplicity(ip)>max)max=GetClusterY_Multiplicity(ip); |
1233 |
|
return max; |
1234 |
|
}; |
1235 |
|
/** |
1236 |
|
* \brief Give the minimum multiplicity on the x view |
1237 |
|
*/ |
1238 |
|
Int_t TrkTrack::GetClusterY_Multiplicity_min(){ |
1239 |
|
int min=50; |
1240 |
|
for(int ip=0; ip<6; ip++) |
1241 |
|
if(GetClusterY_Multiplicity(ip)<min)min=GetClusterY_Multiplicity(ip); |
1242 |
|
return min; |
1243 |
|
}; |
1244 |
|
|
1245 |
|
/** |
1246 |
|
* \brief Give the minimum seed on the x view |
1247 |
|
*/ |
1248 |
|
Float_t TrkTrack::GetClusterX_Seed_min(){ |
1249 |
|
Float_t min=100000; |
1250 |
|
for(int ip=0; ip<6; ip++) |
1251 |
|
if(XGood(ip) && GetClusterX_Seed(ip)<min)min=GetClusterX_Seed(ip); |
1252 |
|
return min; |
1253 |
|
}; |
1254 |
|
/** |
1255 |
|
* \brief Give the minimum seed on the x view |
1256 |
|
*/ |
1257 |
|
Float_t TrkTrack::GetClusterY_Seed_min(){ |
1258 |
|
Float_t min=100000; |
1259 |
|
for(int ip=0; ip<6; ip++) |
1260 |
|
if(YGood(ip) && GetClusterY_Seed(ip)<min)min=GetClusterY_Seed(ip); |
1261 |
|
return min; |
1262 |
|
}; |
1263 |
|
|
1264 |
|
|
1265 |
//-------------------------------------- |
//-------------------------------------- |
1266 |
// |
// |
1267 |
// |
// |
1268 |
//-------------------------------------- |
//-------------------------------------- |
1269 |
void TrkTrack::Clear(){ |
void TrkTrack::Clear(){ |
1270 |
seqno = -1; |
// cout << "TrkTrack::Clear()"<<endl; |
1271 |
image = -1; |
seqno = -1; |
1272 |
chi2 = 0; |
image = -1; |
1273 |
nstep = 0; |
chi2 = 0; |
1274 |
for(int it1=0;it1<5;it1++){ |
nstep = 0; |
1275 |
al[it1] = 0; |
for(int it1=0;it1<5;it1++){ |
1276 |
for(int it2=0;it2<5;it2++)coval[it1][it2] = 0; |
al[it1] = 0; |
1277 |
}; |
for(int it2=0;it2<5;it2++)coval[it1][it2] = 0; |
1278 |
for(int ip=0;ip<6;ip++){ |
}; |
1279 |
xgood[ip] = 0; |
for(int ip=0;ip<6;ip++){ |
1280 |
ygood[ip] = 0; |
xgood[ip] = 0; |
1281 |
xm[ip] = 0; |
ygood[ip] = 0; |
1282 |
ym[ip] = 0; |
xm[ip] = 0; |
1283 |
zm[ip] = 0; |
ym[ip] = 0; |
1284 |
resx[ip] = 0; |
zm[ip] = 0; |
1285 |
resy[ip] = 0; |
resx[ip] = 0; |
1286 |
xv[ip] = 0; |
resy[ip] = 0; |
1287 |
yv[ip] = 0; |
tailx[ip] = 0; |
1288 |
zv[ip] = 0; |
taily[ip] = 0; |
1289 |
axv[ip] = 0; |
xv[ip] = 0; |
1290 |
ayv[ip] = 0; |
yv[ip] = 0; |
1291 |
dedx_x[ip] = 0; |
zv[ip] = 0; |
1292 |
dedx_y[ip] = 0; |
axv[ip] = 0; |
1293 |
// clx[ip] = 0; |
ayv[ip] = 0; |
1294 |
// cly[ip] = 0; |
dedx_x[ip] = 0; |
1295 |
}; |
dedx_y[ip] = 0; |
1296 |
clx->Clear(); |
|
1297 |
cly->Clear(); |
}; |
1298 |
|
int ngf = TrkParams::nGF; |
1299 |
|
for(int i=0; i<ngf; i++){ |
1300 |
|
xGF[i] = 0.; |
1301 |
|
yGF[i] = 0.; |
1302 |
|
} |
1303 |
|
// if(clx)clx->Clear(); |
1304 |
|
// if(cly)cly->Clear(); |
1305 |
|
// clx.Clear(); |
1306 |
|
// cly.Clear(); |
1307 |
}; |
}; |
1308 |
//-------------------------------------- |
//-------------------------------------- |
1309 |
// |
// |
1310 |
// |
// |
1311 |
//-------------------------------------- |
//-------------------------------------- |
1312 |
void TrkTrack::Delete(){ |
void TrkTrack::Delete(){ |
1313 |
Clear(); |
// cout << "TrkTrack::Delete()"<<endl; |
1314 |
clx->Delete(); |
Clear(); |
1315 |
cly->Delete(); |
// if(clx)delete clx; |
1316 |
|
// if(cly)delete cly; |
1317 |
}; |
}; |
1318 |
//-------------------------------------- |
//-------------------------------------- |
1319 |
// |
// |
1320 |
// |
// |
1321 |
//-------------------------------------- |
//-------------------------------------- |
1325 |
// |
// |
1326 |
//-------------------------------------- |
//-------------------------------------- |
1327 |
TrkSinglet::TrkSinglet(){ |
TrkSinglet::TrkSinglet(){ |
1328 |
plane = 0; |
// cout << "TrkSinglet::TrkSinglet() " << GetUniqueID()<<endl; |
1329 |
coord[0] = 0; |
// plane = 0; |
1330 |
coord[1] = 0; |
// coord[0] = 0; |
1331 |
sgnl = 0; |
// coord[1] = 0; |
1332 |
cls = 0; |
// sgnl = 0; |
1333 |
|
// multmax = 0; |
1334 |
|
// cls = 0; |
1335 |
|
Clear(); |
1336 |
}; |
}; |
1337 |
//-------------------------------------- |
//-------------------------------------- |
1338 |
// |
// |
1339 |
// |
// |
1340 |
//-------------------------------------- |
//-------------------------------------- |
1341 |
TrkSinglet::TrkSinglet(const TrkSinglet& s){ |
TrkSinglet::TrkSinglet(const TrkSinglet& s){ |
1342 |
|
// cout << "TrkSinglet::TrkSinglet(const TrkSinglet& s) " << GetUniqueID()<<endl; |
1343 |
plane = s.plane; |
plane = s.plane; |
1344 |
coord[0] = s.coord[0]; |
coord[0] = s.coord[0]; |
1345 |
coord[1] = s.coord[1]; |
coord[1] = s.coord[1]; |
1346 |
sgnl = s.sgnl; |
sgnl = s.sgnl; |
1347 |
|
multmax = s.multmax; |
1348 |
// cls = 0;//<<<<pointer |
// cls = 0;//<<<<pointer |
1349 |
cls = TRef(s.cls); |
// cls = TRef(s.cls); |
1350 |
}; |
}; |
1351 |
//-------------------------------------- |
//-------------------------------------- |
1352 |
// |
// |
1355 |
void TrkSinglet::Dump(){ |
void TrkSinglet::Dump(){ |
1356 |
int i=0; |
int i=0; |
1357 |
cout << endl << "========== Singlet " ; |
cout << endl << "========== Singlet " ; |
1358 |
cout << endl << "plane : " << plane; |
cout << endl << "plane : " << plane; |
1359 |
cout << endl << "coord[2] : "; while( i<2 && cout << coord[i] << " ") i++; |
cout << endl << "coord[2] : "; while( i<2 && cout << coord[i] << " ") i++; |
1360 |
cout << endl << "sgnl : " << sgnl; |
cout << endl << "sgnl : " << sgnl; |
1361 |
|
cout << endl << "max.strip : "; |
1362 |
|
cout << endl << "multiplicity : "; |
1363 |
|
} |
1364 |
|
//-------------------------------------- |
1365 |
|
// |
1366 |
|
// |
1367 |
|
//-------------------------------------- |
1368 |
|
void TrkSinglet::Clear(){ |
1369 |
|
// cout << "TrkSinglet::Clear() " << GetUniqueID()<<endl; |
1370 |
|
// cls=0; |
1371 |
|
plane=-1; |
1372 |
|
coord[0]=-999; |
1373 |
|
coord[1]=-999; |
1374 |
|
sgnl=0; |
1375 |
|
multmax = 0; |
1376 |
|
|
1377 |
} |
} |
1378 |
//-------------------------------------- |
//-------------------------------------- |
1379 |
// |
// |
1380 |
// |
// |
1381 |
//-------------------------------------- |
//-------------------------------------- |
1382 |
TrkLevel2::TrkLevel2(){ |
TrkLevel2::TrkLevel2(){ |
1383 |
// good2 = -1; |
// cout <<"TrkLevel2::TrkLevel2()"<<endl; |
1384 |
for(Int_t i=0; i<12 ; i++){ |
for(Int_t i=0; i<12 ; i++){ |
1385 |
// crc[i] = -1; |
good[i] = -1; |
1386 |
good[i] = -1; |
VKmask[i] = 0; |
1387 |
}; |
VKflag[i] = 0; |
1388 |
Track = new TClonesArray("TrkTrack"); |
}; |
1389 |
SingletX = new TClonesArray("TrkSinglet"); |
Track = 0; |
1390 |
SingletY = new TClonesArray("TrkSinglet"); |
SingletX = 0; |
1391 |
|
SingletY = 0; |
1392 |
|
|
1393 |
// PhysicalTrack = new TClonesArray("TrkTrack"); |
} |
1394 |
//sostituire con TRefArray... appena ho capito come si usa |
//-------------------------------------- |
1395 |
|
// |
1396 |
|
// |
1397 |
|
//-------------------------------------- |
1398 |
|
void TrkLevel2::Set(){ |
1399 |
|
if(!Track)Track = new TClonesArray("TrkTrack"); |
1400 |
|
if(!SingletX)SingletX = new TClonesArray("TrkSinglet"); |
1401 |
|
if(!SingletY)SingletY = new TClonesArray("TrkSinglet"); |
1402 |
} |
} |
1403 |
//-------------------------------------- |
//-------------------------------------- |
1404 |
// |
// |
1406 |
//-------------------------------------- |
//-------------------------------------- |
1407 |
void TrkLevel2::Dump(){ |
void TrkLevel2::Dump(){ |
1408 |
|
|
|
TClonesArray &t = *Track; |
|
|
TClonesArray &sx = *SingletX; |
|
|
TClonesArray &sy = *SingletY; |
|
1409 |
// |
// |
1410 |
cout << endl << endl << "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"; |
cout << endl << endl << "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"; |
1411 |
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; |
1412 |
cout << endl << "ntrk() : " << this->ntrk() ; |
cout << endl << "ntrk() : " << ntrk() ; |
1413 |
cout << endl << "nclsx() : " << this->nclsx(); |
cout << endl << "nclsx() : " << nclsx(); |
1414 |
cout << endl << "nclsy() : " << this->nclsy(); |
cout << endl << "nclsy() : " << nclsy(); |
1415 |
for(int i=0; i<this->ntrk(); i++) ((TrkTrack *)t[i])->Dump(); |
if(Track){ |
1416 |
for(int i=0; i<this->nclsx(); i++) ((TrkSinglet *)sx[i])->Dump(); |
TClonesArray &t = *Track; |
1417 |
for(int i=0; i<this->nclsy(); i++) ((TrkSinglet *)sy[i])->Dump(); |
for(int i=0; i<ntrk(); i++) ((TrkTrack *)t[i])->Dump(); |
1418 |
|
} |
1419 |
|
// if(SingletX){ |
1420 |
|
// TClonesArray &sx = *SingletX; |
1421 |
|
// for(int i=0; i<nclsx(); i++) ((TrkSinglet *)sx[i])->Dump(); |
1422 |
|
// } |
1423 |
|
// if(SingletY){ |
1424 |
|
// TClonesArray &sy = *SingletY; |
1425 |
|
// for(int i=0; i<nclsy(); i++) ((TrkSinglet *)sy[i])->Dump(); |
1426 |
|
// } |
1427 |
|
cout << endl; |
1428 |
} |
} |
1429 |
|
/** |
1430 |
|
* \brief Dump processing status |
1431 |
|
*/ |
1432 |
|
void TrkLevel2::StatusDump(int view){ |
1433 |
|
cout << "DSP n. "<<view+1<<" status: "<<hex<<good[view]<<endl; |
1434 |
|
}; |
1435 |
|
/** |
1436 |
|
* \brief Check event status |
1437 |
|
* |
1438 |
|
* Check the event status, according to a flag-mask given as input. |
1439 |
|
* Return true if the view passes the check. |
1440 |
|
* |
1441 |
|
* @param view View number (0-11) |
1442 |
|
* @param flagmask Mask of flags to check (eg. flagmask=0x111 no missing packet, |
1443 |
|
* no crc error, no software alarm) |
1444 |
|
* |
1445 |
|
* @see TrkLevel2 class definition to know how the status flag is defined |
1446 |
|
* |
1447 |
|
*/ |
1448 |
|
Bool_t TrkLevel2::StatusCheck(int view, int flagmask){ |
1449 |
|
|
1450 |
|
if( view<0 || view >= 12)return false; |
1451 |
|
return !(good[view]&flagmask); |
1452 |
|
|
1453 |
|
}; |
1454 |
|
|
1455 |
|
|
1456 |
|
//-------------------------------------- |
1457 |
|
// |
1458 |
|
// |
1459 |
|
//-------------------------------------- |
1460 |
|
/** |
1461 |
|
* The method returns false if the viking-chip was masked |
1462 |
|
* either apriori ,on the basis of the mask read from the DB, |
1463 |
|
* or run-by-run, on the basis of the calibration parameters) |
1464 |
|
* @param iv Tracker view (0-11) |
1465 |
|
* @param ivk Viking-chip number (0-23) |
1466 |
|
*/ |
1467 |
|
Bool_t TrkLevel2::GetVKMask(int iv, int ivk){ |
1468 |
|
Int_t whichbit = (Int_t)pow(2,ivk); |
1469 |
|
return (whichbit&VKmask[iv])!=0; |
1470 |
|
} |
1471 |
|
/** |
1472 |
|
* The method returns false if the viking-chip was masked |
1473 |
|
* for this event due to common-noise computation failure. |
1474 |
|
* @param iv Tracker view (0-11) |
1475 |
|
* @param ivk Viking-chip number (0-23) |
1476 |
|
*/ |
1477 |
|
Bool_t TrkLevel2::GetVKFlag(int iv, int ivk){ |
1478 |
|
Int_t whichbit = (Int_t)pow(2,ivk); |
1479 |
|
return (whichbit&VKflag[iv])!=0; |
1480 |
|
} |
1481 |
|
/** |
1482 |
|
* The method returns true if the viking-chip was masked, either |
1483 |
|
* forced (see TrkLevel2::GetVKMask(int,int)) or |
1484 |
|
* for this event only (TrkLevel2::GetVKFlag(int,int)). |
1485 |
|
* @param iv Tracker view (0-11) |
1486 |
|
* @param ivk Viking-chip number (0-23) |
1487 |
|
*/ |
1488 |
|
Bool_t TrkLevel2::IsMaskedVK(int iv, int ivk){ |
1489 |
|
return !(GetVKMask(iv,ivk)&&GetVKFlag(iv,ivk) ); |
1490 |
|
}; |
1491 |
|
|
1492 |
//-------------------------------------- |
//-------------------------------------- |
1493 |
// |
// |
1494 |
// |
// |
1495 |
//-------------------------------------- |
//-------------------------------------- |
1496 |
/** |
/** |
1497 |
* 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). |
1498 |
|
* Ref to Level1 data (clusters) is also set. If l1==NULL no references are set. |
1499 |
|
* (NB It make sense to set references only if events are stored in a tree that contains also the Level1 branch) |
1500 |
*/ |
*/ |
1501 |
void TrkLevel2::SetFromLevel2Struct(cTrkLevel2 *l2){ |
void TrkLevel2::SetFromLevel2Struct(cTrkLevel2 *l2, TrkLevel1 *l1){ |
1502 |
|
|
1503 |
// temporary objects: |
// cout << "void TrkLevel2::SetFromLevel2Struct(cTrkLevel2 *l2, TrkLevel1 *l1)"<<endl; |
1504 |
|
Clear(); |
1505 |
|
|
1506 |
|
// temporary objects: |
1507 |
TrkSinglet* t_singlet = new TrkSinglet(); |
TrkSinglet* t_singlet = new TrkSinglet(); |
1508 |
TrkTrack* t_track = new TrkTrack(); |
TrkTrack* t_track = new TrkTrack(); |
1509 |
|
|
1510 |
// **** general variables **** |
// ----------------- |
1511 |
// good2 = l2->good2; |
// general variables |
1512 |
|
// ----------------- |
1513 |
for(Int_t i=0; i<12 ; i++){ |
for(Int_t i=0; i<12 ; i++){ |
1514 |
// crc[i] = l2->crc[i]; |
good[i] = l2->good[i]; |
1515 |
good[i] = l2->good[i]; |
VKmask[i]=0; |
1516 |
|
VKflag[i]=0; |
1517 |
|
for(Int_t ii=0; ii<24 ; ii++){ |
1518 |
|
Int_t setbit = (Int_t)pow(2,ii); |
1519 |
|
if( l2->vkflag[ii][i]!=-1 )VKmask[i]=VKmask[i]|setbit; |
1520 |
|
if( l2->vkflag[ii][i]!=0 )VKflag[i]=VKflag[i]|setbit; |
1521 |
}; |
}; |
1522 |
// *** TRACKS *** |
}; |
1523 |
|
// -------------- |
1524 |
|
// *** TRACKS *** |
1525 |
|
// -------------- |
1526 |
|
if(!Track) Track = new TClonesArray("TrkTrack"); |
1527 |
TClonesArray &t = *Track; |
TClonesArray &t = *Track; |
1528 |
|
|
1529 |
for(int i=0; i<l2->ntrk; i++){ |
for(int i=0; i<l2->ntrk; i++){ |
1530 |
t_track->seqno = i;// NBNBNBNB deve sempre essere = i |
t_track->seqno = i;// NBNBNBNB deve sempre essere = i |
1531 |
t_track->image = l2->image[i]-1; |
t_track->image = l2->image[i]-1; |
1532 |
// cout << "track "<<i<<t_track->seqno << t_track->image<<endl; |
t_track->chi2 = l2->chi2_nt[i]; |
1533 |
t_track->chi2 = l2->chi2_nt[i]; |
t_track->nstep = l2->nstep_nt[i]; |
1534 |
t_track->nstep = l2->nstep_nt[i]; |
for(int it1=0;it1<5;it1++){ |
1535 |
for(int it1=0;it1<5;it1++){ |
t_track->al[it1] = l2->al_nt[i][it1]; |
1536 |
t_track->al[it1] = l2->al_nt[i][it1]; |
for(int it2=0;it2<5;it2++) |
1537 |
for(int it2=0;it2<5;it2++) |
t_track->coval[it1][it2] = l2->coval[i][it2][it1]; |
1538 |
t_track->coval[it1][it2] = l2->coval[i][it2][it1]; |
}; |
1539 |
}; |
for(int ip=0;ip<6;ip++){ |
1540 |
for(int ip=0;ip<6;ip++){ |
// --------------------------------- |
1541 |
t_track->xgood[ip] = l2->xgood_nt[i][ip]; |
// new implementation of xgood/ygood |
1542 |
t_track->ygood[ip] = l2->ygood_nt[i][ip]; |
// --------------------------------- |
1543 |
t_track->xm[ip] = l2->xm_nt[i][ip]; |
t_track->xgood[ip] = l2->cltrx[i][ip]; //cluster ID |
1544 |
t_track->ym[ip] = l2->ym_nt[i][ip]; |
t_track->ygood[ip] = l2->cltry[i][ip]; //cluster ID |
1545 |
t_track->zm[ip] = l2->zm_nt[i][ip]; |
t_track->xgood[ip] += 10000000*l2->ls[i][ip]; // ladder+sensor |
1546 |
t_track->resx[ip] = l2->resx_nt[i][ip]; |
t_track->ygood[ip] += 10000000*l2->ls[i][ip]; // ladder+sensor |
1547 |
t_track->resy[ip] = l2->resy_nt[i][ip]; |
if(l2->xbad[i][ip]>0)t_track->xgood[ip]=-t_track->xgood[ip]; |
1548 |
t_track->xv[ip] = l2->xv_nt[i][ip]; |
if(l2->ybad[i][ip]>0)t_track->ygood[ip]=-t_track->ygood[ip]; |
1549 |
t_track->yv[ip] = l2->yv_nt[i][ip]; |
// if(l2->xbad[i][ip]>0 || l2->ybad[i][ip]>0){ |
1550 |
t_track->zv[ip] = l2->zv_nt[i][ip]; |
// if(l2->dedx_x[i][ip]<0 || l2->dedx_y[i][ip]<0){ |
1551 |
t_track->axv[ip] = l2->axv_nt[i][ip]; |
// cout << ip << " - "<< l2->cltrx[i][ip] << " "<<l2->cltry[i][ip]<<" "<<l2->ls[i][ip]<<endl; |
1552 |
t_track->ayv[ip] = l2->ayv_nt[i][ip]; |
// cout << ip << " - "<<t_track->xgood[ip]<<" "<<t_track->ygood[ip]<<endl; |
1553 |
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; |
1554 |
t_track->dedx_y[ip] = l2->dedx_y[i][ip]; |
// cout << ip << " - "<<t_track->BadClusterX(ip)<<" "<<t_track->BadClusterY(ip)<<endl; |
1555 |
// t_track->clx[ip] = 0; |
// cout << ip << " - "<<t_track->SaturatedClusterX(ip)<<" "<<t_track->SaturatedClusterY(ip)<<endl; |
1556 |
// t_track->cly[ip] = 0; |
// } |
1557 |
}; |
t_track->xm[ip] = l2->xm_nt[i][ip]; |
1558 |
new(t[i]) TrkTrack(*t_track); |
t_track->ym[ip] = l2->ym_nt[i][ip]; |
1559 |
t_track->Clear(); |
t_track->zm[ip] = l2->zm_nt[i][ip]; |
1560 |
}; |
t_track->resx[ip] = l2->resx_nt[i][ip]; |
1561 |
|
t_track->resy[ip] = l2->resy_nt[i][ip]; |
1562 |
|
t_track->tailx[ip] = l2->tailx[i][ip]; |
1563 |
|
t_track->taily[ip] = l2->taily[i][ip]; |
1564 |
|
t_track->xv[ip] = l2->xv_nt[i][ip]; |
1565 |
|
t_track->yv[ip] = l2->yv_nt[i][ip]; |
1566 |
|
t_track->zv[ip] = l2->zv_nt[i][ip]; |
1567 |
|
t_track->axv[ip] = l2->axv_nt[i][ip]; |
1568 |
|
t_track->ayv[ip] = l2->ayv_nt[i][ip]; |
1569 |
|
t_track->dedx_x[ip] = l2->dedx_x[i][ip]; |
1570 |
|
t_track->dedx_y[ip] = l2->dedx_y[i][ip]; |
1571 |
|
t_track->multmaxx[ip] = l2->multmaxx[i][ip]; |
1572 |
|
t_track->multmaxy[ip] = l2->multmaxy[i][ip]; |
1573 |
|
t_track->seedx[ip] = l2->seedx[i][ip]; |
1574 |
|
t_track->seedy[ip] = l2->seedy[i][ip]; |
1575 |
|
t_track->xpu[ip] = l2->xpu[i][ip]; |
1576 |
|
t_track->ypu[ip] = l2->ypu[i][ip]; |
1577 |
|
//----------------------------------------------------- |
1578 |
|
//----------------------------------------------------- |
1579 |
|
//----------------------------------------------------- |
1580 |
|
//----------------------------------------------------- |
1581 |
|
}; |
1582 |
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
1583 |
|
// evaluated coordinates (to define GF) |
1584 |
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
1585 |
|
int ngf = TrkParams::nGF; |
1586 |
|
float *zgf = TrkParams::zGF; |
1587 |
|
Trajectory tgf = Trajectory(ngf,zgf); |
1588 |
|
tgf.DoTrack2(t_track->al);//<<<< integrate the trajectory |
1589 |
|
for(int ip=0; ip<ngf; ip++){ |
1590 |
|
t_track->xGF[ip] = tgf.x[ip]; |
1591 |
|
t_track->yGF[ip] = tgf.y[ip]; |
1592 |
|
} |
1593 |
|
|
1594 |
|
// if(t_track->IsSaturated())t_track->Dump(); |
1595 |
|
new(t[i]) TrkTrack(*t_track); |
1596 |
|
t_track->Clear(); |
1597 |
|
};//end loop over track |
1598 |
|
|
1599 |
|
// ---------------- |
1600 |
// *** SINGLETS *** |
// *** SINGLETS *** |
1601 |
|
// ---------------- |
1602 |
|
if(!SingletX)SingletX = new TClonesArray("TrkSinglet"); |
1603 |
TClonesArray &sx = *SingletX; |
TClonesArray &sx = *SingletX; |
1604 |
for(int i=0; i<l2->nclsx; i++){ |
for(int i=0; i<l2->nclsx; i++){ |
1605 |
t_singlet->plane = l2->planex[i]; |
t_singlet->plane = l2->planex[i]; |
1606 |
t_singlet->coord[0] = l2->xs[i][0]; |
t_singlet->coord[0] = l2->xs[i][0]; |
1607 |
t_singlet->coord[1] = l2->xs[i][1]; |
t_singlet->coord[1] = l2->xs[i][1]; |
1608 |
t_singlet->sgnl = l2->signlxs[i]; |
t_singlet->sgnl = l2->signlxs[i]; |
1609 |
// t_singlet->cls = 0; |
t_singlet->multmax = l2->multmaxsx[i]; |
1610 |
new(sx[i]) TrkSinglet(*t_singlet); |
if(l2->sxbad[i]>0) t_singlet->multmax = -1*t_singlet->multmax; |
1611 |
t_singlet->Clear(); |
//----------------------------------------------------- |
1612 |
|
// if(l1) t_singlet->cls = l1->GetCluster(l2->clsx[i]-1); |
1613 |
|
//----------------------------------------------------- |
1614 |
|
new(sx[i]) TrkSinglet(*t_singlet); |
1615 |
|
t_singlet->Clear(); |
1616 |
} |
} |
1617 |
|
if(!SingletY)SingletY = new TClonesArray("TrkSinglet"); |
1618 |
TClonesArray &sy = *SingletY; |
TClonesArray &sy = *SingletY; |
1619 |
for(int i=0; i<l2->nclsy; i++){ |
for(int i=0; i<l2->nclsy; i++){ |
1620 |
t_singlet->plane = l2->planey[i]; |
t_singlet->plane = l2->planey[i]; |
1621 |
t_singlet->coord[0] = l2->ys[i][0]; |
t_singlet->coord[0] = l2->ys[i][0]; |
1622 |
t_singlet->coord[1] = l2->ys[i][1]; |
t_singlet->coord[1] = l2->ys[i][1]; |
1623 |
t_singlet->sgnl = l2->signlys[i]; |
t_singlet->sgnl = l2->signlys[i]; |
1624 |
// t_singlet->cls = 0; |
t_singlet->multmax = l2->multmaxsy[i]; |
1625 |
new(sy[i]) TrkSinglet(*t_singlet); |
if(l2->sybad[i]>0) t_singlet->multmax = -1*t_singlet->multmax; |
1626 |
t_singlet->Clear(); |
//----------------------------------------------------- |
1627 |
}; |
// if(l1) t_singlet->cls = l1->GetCluster(l2->clsy[i]-1); |
1628 |
|
//----------------------------------------------------- |
1629 |
delete t_track; |
new(sy[i]) TrkSinglet(*t_singlet); |
1630 |
delete t_singlet; |
t_singlet->Clear(); |
1631 |
} |
}; |
1632 |
//-------------------------------------- |
|
|
// |
|
|
// |
|
|
//-------------------------------------- |
|
|
/** |
|
|
* 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){ |
|
1633 |
|
|
|
// 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(); |
|
|
}; |
|
1634 |
|
|
1635 |
delete t_track; |
delete t_track; |
1636 |
delete t_singlet; |
delete t_singlet; |
1637 |
} |
} |
1638 |
/** |
/** |
1639 |
* 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). |
1649 |
}; |
}; |
1650 |
// *** TRACKS *** |
// *** TRACKS *** |
1651 |
|
|
1652 |
l2->ntrk = Track->GetEntries(); |
if(Track){ |
1653 |
for(Int_t i=0;i<l2->ntrk;i++){ |
l2->ntrk = Track->GetEntries(); |
1654 |
l2->image[i] = 1 + ((TrkTrack *)Track->At(i))->image; |
for(Int_t i=0;i<l2->ntrk;i++){ |
1655 |
l2->chi2_nt[i] = ((TrkTrack *)Track->At(i))->chi2; |
l2->image[i] = 1 + ((TrkTrack *)Track->At(i))->image; |
1656 |
l2->nstep_nt[i] = ((TrkTrack *)Track->At(i))->nstep; |
l2->chi2_nt[i] = ((TrkTrack *)Track->At(i))->chi2; |
1657 |
for(int it1=0;it1<5;it1++){ |
l2->nstep_nt[i] = ((TrkTrack *)Track->At(i))->nstep; |
1658 |
l2->al_nt[i][it1] = ((TrkTrack *)Track->At(i))->al[it1]; |
for(int it1=0;it1<5;it1++){ |
1659 |
for(int it2=0;it2<5;it2++) |
l2->al_nt[i][it1] = ((TrkTrack *)Track->At(i))->al[it1]; |
1660 |
l2->coval[i][it2][it1] = ((TrkTrack *)Track->At(i))->coval[it1][it2]; |
for(int it2=0;it2<5;it2++) |
1661 |
}; |
l2->coval[i][it2][it1] = ((TrkTrack *)Track->At(i))->coval[it1][it2]; |
1662 |
for(int ip=0;ip<6;ip++){ |
}; |
1663 |
l2->xgood_nt[i][ip] = ((TrkTrack *)Track->At(i))->xgood[ip]; |
for(int ip=0;ip<6;ip++){ |
1664 |
l2->ygood_nt[i][ip] = ((TrkTrack *)Track->At(i))->ygood[ip]; |
l2->xgood_nt[i][ip] = ((TrkTrack *)Track->At(i))->XGood(ip); |
1665 |
l2->xm_nt[i][ip] = ((TrkTrack *)Track->At(i))->xm[ip]; |
l2->ygood_nt[i][ip] = ((TrkTrack *)Track->At(i))->YGood(ip); |
1666 |
l2->ym_nt[i][ip] = ((TrkTrack *)Track->At(i))->ym[ip]; |
l2->xm_nt[i][ip] = ((TrkTrack *)Track->At(i))->xm[ip]; |
1667 |
l2->zm_nt[i][ip] = ((TrkTrack *)Track->At(i))->zm[ip]; |
l2->ym_nt[i][ip] = ((TrkTrack *)Track->At(i))->ym[ip]; |
1668 |
l2->resx_nt[i][ip] = ((TrkTrack *)Track->At(i))->resx[ip]; |
l2->zm_nt[i][ip] = ((TrkTrack *)Track->At(i))->zm[ip]; |
1669 |
l2->resy_nt[i][ip] = ((TrkTrack *)Track->At(i))->resy[ip]; |
l2->resx_nt[i][ip] = ((TrkTrack *)Track->At(i))->resx[ip]; |
1670 |
l2->xv_nt[i][ip] = ((TrkTrack *)Track->At(i))->xv[ip]; |
l2->resy_nt[i][ip] = ((TrkTrack *)Track->At(i))->resy[ip]; |
1671 |
l2->yv_nt[i][ip] = ((TrkTrack *)Track->At(i))->yv[ip]; |
l2->tailx[i][ip] = ((TrkTrack *)Track->At(i))->tailx[ip]; |
1672 |
l2->zv_nt[i][ip] = ((TrkTrack *)Track->At(i))->zv[ip]; |
l2->taily[i][ip] = ((TrkTrack *)Track->At(i))->taily[ip]; |
1673 |
l2->axv_nt[i][ip] = ((TrkTrack *)Track->At(i))->axv[ip]; |
l2->xv_nt[i][ip] = ((TrkTrack *)Track->At(i))->xv[ip]; |
1674 |
l2->ayv_nt[i][ip] = ((TrkTrack *)Track->At(i))->ayv[ip]; |
l2->yv_nt[i][ip] = ((TrkTrack *)Track->At(i))->yv[ip]; |
1675 |
l2->dedx_x[i][ip] = ((TrkTrack *)Track->At(i))->dedx_x[ip]; |
l2->zv_nt[i][ip] = ((TrkTrack *)Track->At(i))->zv[ip]; |
1676 |
l2->dedx_y[i][ip] = ((TrkTrack *)Track->At(i))->dedx_y[ip]; |
l2->axv_nt[i][ip] = ((TrkTrack *)Track->At(i))->axv[ip]; |
1677 |
}; |
l2->ayv_nt[i][ip] = ((TrkTrack *)Track->At(i))->ayv[ip]; |
1678 |
|
l2->dedx_x[i][ip] = ((TrkTrack *)Track->At(i))->dedx_x[ip]; |
1679 |
|
l2->dedx_y[i][ip] = ((TrkTrack *)Track->At(i))->dedx_y[ip]; |
1680 |
|
}; |
1681 |
|
} |
1682 |
} |
} |
|
|
|
1683 |
// *** SINGLETS *** |
// *** SINGLETS *** |
1684 |
l2->nclsx = SingletX->GetEntries(); |
if(SingletX){ |
1685 |
for(Int_t i=0;i<l2->nclsx;i++){ |
l2->nclsx = SingletX->GetEntries(); |
1686 |
l2->planex[i] = ((TrkSinglet *)SingletX->At(i))->plane; |
for(Int_t i=0;i<l2->nclsx;i++){ |
1687 |
l2->xs[i][0] = ((TrkSinglet *)SingletX->At(i))->coord[0]; |
l2->planex[i] = ((TrkSinglet *)SingletX->At(i))->plane; |
1688 |
l2->xs[i][1] = ((TrkSinglet *)SingletX->At(i))->coord[1]; |
l2->xs[i][0] = ((TrkSinglet *)SingletX->At(i))->coord[0]; |
1689 |
l2->signlxs[i] = ((TrkSinglet *)SingletX->At(i))->sgnl; |
l2->xs[i][1] = ((TrkSinglet *)SingletX->At(i))->coord[1]; |
1690 |
} |
l2->signlxs[i] = ((TrkSinglet *)SingletX->At(i))->sgnl; |
1691 |
l2->nclsy = SingletY->GetEntries(); |
} |
1692 |
for(Int_t i=0;i<l2->nclsy;i++){ |
} |
1693 |
l2->planey[i] = ((TrkSinglet *)SingletY->At(i))->plane; |
|
1694 |
l2->ys[i][0] = ((TrkSinglet *)SingletY->At(i))->coord[0]; |
if(SingletY){ |
1695 |
l2->ys[i][1] = ((TrkSinglet *)SingletY->At(i))->coord[1]; |
l2->nclsy = SingletY->GetEntries(); |
1696 |
l2->signlys[i] = ((TrkSinglet *)SingletY->At(i))->sgnl; |
for(Int_t i=0;i<l2->nclsy;i++){ |
1697 |
|
l2->planey[i] = ((TrkSinglet *)SingletY->At(i))->plane; |
1698 |
|
l2->ys[i][0] = ((TrkSinglet *)SingletY->At(i))->coord[0]; |
1699 |
|
l2->ys[i][1] = ((TrkSinglet *)SingletY->At(i))->coord[1]; |
1700 |
|
l2->signlys[i] = ((TrkSinglet *)SingletY->At(i))->sgnl; |
1701 |
|
} |
1702 |
} |
} |
1703 |
} |
} |
1704 |
//-------------------------------------- |
//-------------------------------------- |
1706 |
// |
// |
1707 |
//-------------------------------------- |
//-------------------------------------- |
1708 |
void TrkLevel2::Clear(){ |
void TrkLevel2::Clear(){ |
|
// good2 = -1; |
|
1709 |
for(Int_t i=0; i<12 ; i++){ |
for(Int_t i=0; i<12 ; i++){ |
1710 |
// crc[i] = -1; |
good[i] = -1; |
1711 |
good[i] = -1; |
VKflag[i] = 0; |
1712 |
}; |
VKmask[i] = 0; |
1713 |
/* Track->RemoveAll(); |
}; |
1714 |
SingletX->RemoveAll(); |
// if(Track)Track->Clear("C"); |
1715 |
SingletY->RemoveAll();*/ |
// if(SingletX)SingletX->Clear("C"); |
1716 |
// modify to avoid memory leakage |
// if(SingletY)SingletY->Clear("C"); |
1717 |
Track->Clear(); |
if(Track)Track->Delete(); |
1718 |
SingletX->Clear(); |
if(SingletX)SingletX->Delete(); |
1719 |
SingletY->Clear(); |
if(SingletY)SingletY->Delete(); |
1720 |
} |
} |
1721 |
//-------------------------------------- |
// //-------------------------------------- |
1722 |
// |
// // |
1723 |
// |
// // |
1724 |
//-------------------------------------- |
// //-------------------------------------- |
1725 |
void TrkLevel2::Delete(){ |
void TrkLevel2::Delete(){ |
1726 |
|
|
1727 |
Clear(); |
// cout << "void TrkLevel2::Delete()"<<endl; |
1728 |
Track->Delete(); |
Clear(); |
1729 |
SingletX->Delete(); |
if(Track)delete Track; |
1730 |
SingletY->Delete(); |
if(SingletX)delete SingletX; |
1731 |
|
if(SingletY)delete SingletY; |
1732 |
|
|
1733 |
} |
} |
1734 |
//-------------------------------------- |
//-------------------------------------- |
1735 |
// |
// |
1741 |
*/ |
*/ |
1742 |
TRefArray *TrkLevel2::GetTracks_NFitSorted(){ |
TRefArray *TrkLevel2::GetTracks_NFitSorted(){ |
1743 |
|
|
1744 |
TRefArray *sorted = new TRefArray(); |
if(!Track)return 0; |
1745 |
|
|
1746 |
|
TRefArray *sorted = new TRefArray(); |
1747 |
|
|
1748 |
TClonesArray &t = *Track; |
TClonesArray &t = *Track; |
1749 |
// TClonesArray &ts = *PhysicalTrack; |
// TClonesArray &ts = *PhysicalTrack; |
1750 |
int N = ntrk(); |
int N = ntrk(); |
1751 |
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; |
1752 |
// 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; |
1753 |
|
|
1754 |
int indo=0; |
int indo=0; |
1755 |
int indi=0; |
int indi=0; |
1756 |
while(N != 0){ |
while(N > 0){ |
1757 |
int nfit =0; |
// while(N != 0){ |
1758 |
float chi2ref = numeric_limits<float>::max(); |
int nfit =0; |
1759 |
|
float chi2ref = numeric_limits<float>::max(); |
1760 |
|
|
1761 |
// first loop to search maximum num. of fit points |
// first loop to search maximum num. of fit points |
1762 |
for(int i=0; i < ntrk(); i++){ |
for(int i=0; i < ntrk(); i++){ |
1763 |
if( ((TrkTrack *)t[i])->GetNtot() >= nfit && m[i]==1){ |
if( ((TrkTrack *)t[i])->GetNtot() >= nfit && m[i]==1){ |
1764 |
nfit = ((TrkTrack *)t[i])->GetNtot(); |
nfit = ((TrkTrack *)t[i])->GetNtot(); |
1765 |
} |
} |
1766 |
} |
} |
1767 |
//second loop to search minimum chi2 among selected |
//second loop to search minimum chi2 among selected |
1768 |
for(int i=0; i<this->ntrk(); i++){ |
for(int i=0; i<ntrk(); i++){ |
1769 |
Float_t chi2 = ((TrkTrack *)t[i])->chi2; |
Float_t chi2 = ((TrkTrack *)t[i])->chi2; |
1770 |
if(chi2 < 0) chi2 = chi2*1000; |
if(chi2 < 0) chi2 = -chi2*1000; |
1771 |
if( chi2 < chi2ref |
if( chi2 < chi2ref |
1772 |
&& ((TrkTrack *)t[i])->GetNtot() == nfit |
&& ((TrkTrack *)t[i])->GetNtot() == nfit |
1773 |
&& m[i]==1){ |
&& m[i]==1){ |
1774 |
chi2ref = ((TrkTrack *)t[i])->chi2; |
chi2ref = ((TrkTrack *)t[i])->chi2; |
1775 |
indi = i; |
indi = i; |
1776 |
}; |
}; |
1777 |
}; |
}; |
1778 |
if( ((TrkTrack *)t[indi])->HasImage() ){ |
if( ((TrkTrack *)t[indi])->HasImage() ){ |
1779 |
m[((TrkTrack *)t[indi])->image] = 0; |
m[((TrkTrack *)t[indi])->image] = 0; |
1780 |
N--; |
N--; |
1781 |
|
|
1782 |
// cout << "i** "<< ((TrkTrack *)t[indi])->image << " " << nfiti <<" "<<chi2i<<endl; |
// cout << "i** "<< ((TrkTrack *)t[indi])->image << " " << nfiti <<" "<<chi2i<<endl; |
1783 |
}; |
}; |
1784 |
sorted->Add( (TrkTrack*)t[indi] ); |
sorted->Add( (TrkTrack*)t[indi] ); |
1785 |
|
|
1786 |
m[indi] = 0; |
m[indi] = 0; |
1787 |
// cout << "SORTED "<< indo << " "<< indi << " "<< N << endl; |
// cout << "SORTED "<< indo << " "<< indi << " "<< N << " "<<((TrkTrack *)t[indi])->image<<" "<<chi2ref<<endl; |
1788 |
N--; |
N--; |
1789 |
indo++; |
indo++; |
1790 |
} |
} |
1791 |
m.clear(); |
m.clear(); |
1792 |
// cout << "GetTracks_NFitSorted(it): Done"<< endl; |
// cout << "GetTracks_NFitSorted(it): Done"<< endl; |
1793 |
|
|
1794 |
return sorted; |
return sorted; |
1795 |
// return PhysicalTrack; |
// return PhysicalTrack; |
1796 |
} |
} |
1797 |
//-------------------------------------- |
//-------------------------------------- |
1806 |
TrkTrack *TrkLevel2::GetStoredTrack(int is){ |
TrkTrack *TrkLevel2::GetStoredTrack(int is){ |
1807 |
|
|
1808 |
if(is >= this->ntrk()){ |
if(is >= this->ntrk()){ |
1809 |
cout << "** TrkLevel2 ** Track "<< is << "doen not exits! " << endl; |
cout << "TrkTrack *TrkLevel2::GetStoredTrack(int) >> Track "<< is << "doen not exits! " << endl; |
1810 |
cout << " Stored tracks ntrk() = "<< this->ntrk() << endl; |
cout << "Stored tracks ntrk() = "<< this->ntrk() << endl; |
1811 |
return 0; |
return 0; |
1812 |
} |
} |
1813 |
|
if(!Track){ |
1814 |
|
cout << "TrkTrack *TrkLevel2::GetStoredTrack(int is) >> (TClonesArray*) Track ==0 "<<endl; |
1815 |
|
}; |
1816 |
TClonesArray &t = *(Track); |
TClonesArray &t = *(Track); |
1817 |
TrkTrack *track = (TrkTrack*)t[is]; |
TrkTrack *track = (TrkTrack*)t[is]; |
1818 |
return track; |
return track; |
1828 |
TrkSinglet *TrkLevel2::GetSingletX(int is){ |
TrkSinglet *TrkLevel2::GetSingletX(int is){ |
1829 |
|
|
1830 |
if(is >= this->nclsx()){ |
if(is >= this->nclsx()){ |
1831 |
cout << "** TrkLevel2 ** Singlet "<< is << "doen not exits! " << endl; |
cout << "TrkSinglet *TrkLevel2::GetSingletX(int) >> Singlet "<< is << "doen not exits! " << endl; |
1832 |
cout << " Stored x-singlets nclsx() = "<< this->nclsx() << endl; |
cout << "Stored x-singlets nclsx() = "<< this->nclsx() << endl; |
1833 |
return 0; |
return 0; |
1834 |
} |
} |
1835 |
|
if(!SingletX)return 0; |
1836 |
TClonesArray &t = *(SingletX); |
TClonesArray &t = *(SingletX); |
1837 |
TrkSinglet *singlet = (TrkSinglet*)t[is]; |
TrkSinglet *singlet = (TrkSinglet*)t[is]; |
1838 |
return singlet; |
return singlet; |
1848 |
TrkSinglet *TrkLevel2::GetSingletY(int is){ |
TrkSinglet *TrkLevel2::GetSingletY(int is){ |
1849 |
|
|
1850 |
if(is >= this->nclsy()){ |
if(is >= this->nclsy()){ |
1851 |
cout << "** TrkLevel2 ** Singlet "<< is << "doen not exits! " << endl; |
cout << "TrkSinglet *TrkLevel2::GetSingletY(int) >> Singlet "<< is << "doen not exits! " << endl; |
1852 |
cout << " Stored y-singlets nclsy() = "<< this->nclsx() << endl; |
cout << "Stored y-singlets nclsx() = "<< this->nclsx() << endl; |
1853 |
return 0; |
return 0; |
1854 |
} |
} |
1855 |
|
if(!SingletY)return 0; |
1856 |
TClonesArray &t = *(SingletY); |
TClonesArray &t = *(SingletY); |
1857 |
TrkSinglet *singlet = (TrkSinglet*)t[is]; |
TrkSinglet *singlet = (TrkSinglet*)t[is]; |
1858 |
return singlet; |
return singlet; |
1869 |
TrkTrack *TrkLevel2::GetTrack(int it){ |
TrkTrack *TrkLevel2::GetTrack(int it){ |
1870 |
|
|
1871 |
if(it >= this->GetNTracks()){ |
if(it >= this->GetNTracks()){ |
1872 |
cout << "** TrkLevel2 ** Track "<< it << "does not exits! " << endl; |
cout << "TrkTrack *TrkLevel2::GetTrack(int) >> Track "<< it << "does not exits! " << endl; |
1873 |
cout << " Physical tracks GetNTracks() = "<< this->ntrk() << endl; |
cout << "Physical tracks GetNTracks() = "<< this->ntrk() << endl; |
1874 |
return 0; |
return 0; |
1875 |
} |
} |
1876 |
|
|
1877 |
TRefArray *sorted = GetTracks(); //TEMPORANEO |
TRefArray *sorted = GetTracks(); //TEMPORANEO |
1878 |
|
if(!sorted)return 0; |
1879 |
TrkTrack *track = (TrkTrack*)sorted->At(it); |
TrkTrack *track = (TrkTrack*)sorted->At(it); |
1880 |
sorted->Delete(); |
sorted->Clear(); |
1881 |
|
delete sorted; |
1882 |
return track; |
return track; |
1883 |
} |
} |
1884 |
/** |
/** |
1887 |
Int_t TrkLevel2::GetNTracks(){ |
Int_t TrkLevel2::GetNTracks(){ |
1888 |
|
|
1889 |
Float_t ntot=0; |
Float_t ntot=0; |
1890 |
|
if(!Track)return 0; |
1891 |
TClonesArray &t = *Track; |
TClonesArray &t = *Track; |
1892 |
for(int i=0; i<ntrk(); i++) { |
for(int i=0; i<ntrk(); i++) { |
1893 |
if( ((TrkTrack *)t[i])->GetImageSeqNo() == -1 ) ntot+=1.; |
if( ((TrkTrack *)t[i])->GetImageSeqNo() == -1 ) ntot+=1.; |
1906 |
*/ |
*/ |
1907 |
TrkTrack *TrkLevel2::GetTrackImage(int it){ |
TrkTrack *TrkLevel2::GetTrackImage(int it){ |
1908 |
|
|
1909 |
if(it >= this->GetNTracks()){ |
if(it >= this->GetNTracks()){ |
1910 |
cout << "** TrkLevel2 ** Track "<< it << "does not exits! " << endl; |
cout << "TrkTrack *TrkLevel2::GetTrackImage(int) >> Track "<< it << "does not exits! " << endl; |
1911 |
cout << " Physical tracks GetNTracks() = "<< this->ntrk() << endl; |
cout << "Physical tracks GetNTracks() = "<< this->ntrk() << endl; |
1912 |
return 0; |
return 0; |
1913 |
} |
} |
1914 |
|
|
1915 |
TRefArray* sorted = GetTracks(); //TEMPORANEO |
TRefArray* sorted = GetTracks(); //TEMPORANEO |
1916 |
TrkTrack *track = (TrkTrack*)sorted->At(it); |
if(!sorted)return 0; |
1917 |
|
TrkTrack *track = (TrkTrack*)sorted->At(it); |
1918 |
|
|
1919 |
if(!track->HasImage()){ |
if(!track->HasImage()){ |
1920 |
cout << "** TrkLevel2 ** Track "<< it << "does not have image! " << endl; |
cout << "TrkTrack *TrkLevel2::GetTrackImage(int) >> Track "<< it << "does not have image! " << endl; |
1921 |
return 0; |
return 0; |
1922 |
} |
} |
1923 |
TrkTrack *image = (TrkTrack*)(*Track)[track->image]; |
if(!Track)return 0; |
1924 |
|
TrkTrack *image = (TrkTrack*)(*Track)[track->image]; |
1925 |
|
|
1926 |
sorted->Delete(); |
sorted->Delete(); |
1927 |
|
delete sorted; |
1928 |
return image; |
|
1929 |
|
return image; |
1930 |
|
|
1931 |
} |
} |
1932 |
//-------------------------------------- |
//-------------------------------------- |
1939 |
*/ |
*/ |
1940 |
void TrkLevel2::LoadField(TString path){ |
void TrkLevel2::LoadField(TString path){ |
1941 |
// |
// |
1942 |
strcpy(path_.path,path.Data()); |
// strcpy(path_.path,path.Data()); |
1943 |
path_.pathlen = path.Length(); |
// path_.pathlen = path.Length(); |
1944 |
path_.error = 0; |
// path_.error = 0; |
1945 |
readb_(); |
// readb_(); |
1946 |
|
|
1947 |
|
// TrkParams::SetTrackingMode(); |
1948 |
|
// TrkParams::SetPrecisionFactor(); |
1949 |
|
// TrkParams::SetStepMin(); |
1950 |
|
TrkParams::SetMiniDefault(); |
1951 |
|
|
1952 |
|
TrkParams::Set(path,1); |
1953 |
|
TrkParams::Load(1); |
1954 |
|
|
1955 |
// |
// |
1956 |
}; |
}; |
1957 |
|
// /** |
1958 |
|
// * Get BY (kGauss) |
1959 |
|
// * @param v (x,y,z) coordinates in cm |
1960 |
|
// */ |
1961 |
|
// float TrkLevel2::GetBX(float* v){ |
1962 |
|
// float b[3]; |
1963 |
|
// gufld_(v,b); |
1964 |
|
// return b[0]/10.; |
1965 |
|
// } |
1966 |
|
// /** |
1967 |
|
// * Get BY (kGauss) |
1968 |
|
// * @param v (x,y,z) coordinates in cm |
1969 |
|
// */ |
1970 |
|
// float TrkLevel2::GetBY(float* v){ |
1971 |
|
// float b[3]; |
1972 |
|
// gufld_(v,b); |
1973 |
|
// return b[1]/10.; |
1974 |
|
// } |
1975 |
|
// /** |
1976 |
|
// * Get BY (kGauss) |
1977 |
|
// * @param v (x,y,z) coordinates in cm |
1978 |
|
// */ |
1979 |
|
// float TrkLevel2::GetBZ(float* v){ |
1980 |
|
// float b[3]; |
1981 |
|
// gufld_(v,b); |
1982 |
|
// return b[2]/10.; |
1983 |
|
// } |
1984 |
//-------------------------------------- |
//-------------------------------------- |
1985 |
// |
// |
1986 |
// |
// |
2077 |
tl = new float[npoint]; |
tl = new float[npoint]; |
2078 |
int i=0; |
int i=0; |
2079 |
do{ |
do{ |
2080 |
x[i] = 0; |
x[i] = 0; |
2081 |
y[i] = 0; |
y[i] = 0; |
2082 |
z[i] = zin[i]; |
z[i] = zin[i]; |
2083 |
thx[i] = 0; |
thx[i] = 0; |
2084 |
thy[i] = 0; |
thy[i] = 0; |
2085 |
tl[i] = 0; |
tl[i] = 0; |
2086 |
i++; |
i++; |
2087 |
}while(zin[i-1] > zin[i] && i < npoint); |
}while(zin[i-1] > zin[i] && i < npoint); |
2088 |
npoint=i; |
npoint=i; |
2089 |
if(npoint != n)cout << "NB! Trajectory created with "<<npoint<<" points"<<endl; |
if(npoint != n)cout << "NB! Trajectory created with "<<npoint<<" points"<<endl; |
2090 |
} |
} |
2091 |
|
void Trajectory::Delete(){ |
2092 |
|
|
2093 |
|
if(x) delete [] x; |
2094 |
|
if(y) delete [] y; |
2095 |
|
if(z) delete [] z; |
2096 |
|
if(thx) delete [] thx; |
2097 |
|
if(thy) delete [] thy; |
2098 |
|
if(tl) delete [] tl; |
2099 |
|
|
2100 |
|
} |
2101 |
//-------------------------------------- |
//-------------------------------------- |
2102 |
// |
// |
2103 |
// |
// |
2136 |
|
|
2137 |
} |
} |
2138 |
|
|
2139 |
|
/** |
2140 |
|
* Evaluates the trajectory in the apparatus associated to the track. |
2141 |
|
* 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. |
2142 |
|
* @param t pointer to an object of the class Trajectory, |
2143 |
|
* which z coordinates should be previously initialized by calling the proper constructor ( Trajectory::Trajectory(int n, float* zin) ). |
2144 |
|
* @return error flag. |
2145 |
|
*/ |
2146 |
|
int Trajectory::DoTrack2(float* al){ |
2147 |
|
|
2148 |
|
// double *dxout = new double[npoint]; |
2149 |
|
// double *dyout = new double[npoint]; |
2150 |
|
// double *dthxout = new double[npoint]; |
2151 |
|
// double *dthyout = new double[npoint]; |
2152 |
|
// double *dtlout = new double[npoint]; |
2153 |
|
// double *dzin = new double[npoint]; |
2154 |
|
|
2155 |
|
double *dxout; |
2156 |
|
double *dyout; |
2157 |
|
double *dthxout; |
2158 |
|
double *dthyout; |
2159 |
|
double *dtlout; |
2160 |
|
double *dzin; |
2161 |
|
|
2162 |
|
dxout = (double*) malloc(npoint*sizeof(double)); |
2163 |
|
dyout = (double*) malloc(npoint*sizeof(double)); |
2164 |
|
dthxout = (double*) malloc(npoint*sizeof(double)); |
2165 |
|
dthyout = (double*) malloc(npoint*sizeof(double)); |
2166 |
|
dtlout = (double*) malloc(npoint*sizeof(double)); |
2167 |
|
dzin = (double*) malloc(npoint*sizeof(double)); |
2168 |
|
|
2169 |
|
double dal[5]; |
2170 |
|
|
2171 |
|
int ifail = 0; |
2172 |
|
|
2173 |
|
for (int i=0; i<5; i++) dal[i] = (double)al[i]; |
2174 |
|
for (int i=0; i<npoint; i++) dzin[i] = (double)z[i]; |
2175 |
|
|
2176 |
|
TrkParams::Load(1); |
2177 |
|
if( !TrkParams::IsLoaded(1) ){ |
2178 |
|
cout << "int Trajectory::DoTrack2(float* al) --- ERROR --- m.field not loaded"<<endl; |
2179 |
|
return 0; |
2180 |
|
} |
2181 |
|
dotrack2_(&(npoint),dzin,dxout,dyout,dthxout,dthyout,dtlout,dal,&ifail); |
2182 |
|
|
2183 |
|
for (int i=0; i<npoint; i++){ |
2184 |
|
x[i] = (float)*(dxout+i); |
2185 |
|
y[i] = (float)*(dyout+i); |
2186 |
|
thx[i] = (float)*(dthxout+i); |
2187 |
|
thy[i] = (float)*(dthyout+i); |
2188 |
|
tl[i] = (float)*(dtlout+i); |
2189 |
|
} |
2190 |
|
|
2191 |
|
if(dxout) free( dxout ); |
2192 |
|
if(dyout) free( dyout ); |
2193 |
|
if(dthxout)free( dthxout ); |
2194 |
|
if(dthyout)free( dthyout ); |
2195 |
|
if(dtlout) free( dtlout ); |
2196 |
|
if(dzin) free( dzin ); |
2197 |
|
|
2198 |
|
// delete [] dxout; |
2199 |
|
// delete [] dyout; |
2200 |
|
// delete [] dthxout; |
2201 |
|
// delete [] dthyout; |
2202 |
|
// delete [] dtlout; |
2203 |
|
// delete [] dzin; |
2204 |
|
|
2205 |
|
|
2206 |
|
return ifail; |
2207 |
|
}; |
2208 |
|
|
2209 |
ClassImp(TrkLevel2); |
ClassImp(TrkLevel2); |
2210 |
ClassImp(TrkSinglet); |
ClassImp(TrkSinglet); |