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