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.16 |
// int readb_(const char*); |
16 |
|
|
int readb_(); |
17 |
pam-fi |
1.13 |
void mini2_(int*,int*,int*); |
18 |
pam-fi |
1.15 |
void guess_(); |
19 |
mocchiut |
1.1 |
} |
20 |
|
|
//-------------------------------------- |
21 |
|
|
// |
22 |
|
|
// |
23 |
|
|
//-------------------------------------- |
24 |
|
|
TrkTrack::TrkTrack(){ |
25 |
pam-fi |
1.3 |
seqno = -1; |
26 |
|
|
image = -1; |
27 |
mocchiut |
1.1 |
chi2 = 0; |
28 |
pam-fi |
1.14 |
nstep = 0; |
29 |
|
|
for(int it1=0;it1<5;it1++){ |
30 |
|
|
al[it1] = 0; |
31 |
|
|
for(int it2=0;it2<5;it2++)coval[it1][it2] = 0; |
32 |
mocchiut |
1.1 |
}; |
33 |
|
|
for(int ip=0;ip<6;ip++){ |
34 |
pam-fi |
1.9 |
xgood[ip] = 0; |
35 |
|
|
ygood[ip] = 0; |
36 |
|
|
xm[ip] = 0; |
37 |
|
|
ym[ip] = 0; |
38 |
|
|
zm[ip] = 0; |
39 |
|
|
resx[ip] = 0; |
40 |
|
|
resy[ip] = 0; |
41 |
|
|
xv[ip] = 0; |
42 |
|
|
yv[ip] = 0; |
43 |
|
|
zv[ip] = 0; |
44 |
|
|
axv[ip] = 0; |
45 |
|
|
ayv[ip] = 0; |
46 |
|
|
dedx_x[ip] = 0; |
47 |
|
|
dedx_y[ip] = 0; |
48 |
|
|
// clx[ip] = 0; |
49 |
|
|
// cly[ip] = 0; |
50 |
|
|
}; |
51 |
|
|
clx = new TRefArray(6,0); |
52 |
|
|
cly = new TRefArray(6,0); |
53 |
mocchiut |
1.1 |
}; |
54 |
|
|
//-------------------------------------- |
55 |
|
|
// |
56 |
|
|
// |
57 |
|
|
//-------------------------------------- |
58 |
|
|
TrkTrack::TrkTrack(const TrkTrack& t){ |
59 |
pam-fi |
1.3 |
seqno = t.seqno; |
60 |
mocchiut |
1.1 |
image = t.image; |
61 |
|
|
chi2 = t.chi2; |
62 |
pam-fi |
1.14 |
nstep = t.nstep; |
63 |
|
|
for(int it1=0;it1<5;it1++){ |
64 |
|
|
al[it1] = t.al[it1]; |
65 |
|
|
for(int it2=0;it2<5;it2++)coval[it1][it2] = t.coval[it1][it2]; |
66 |
mocchiut |
1.1 |
}; |
67 |
|
|
for(int ip=0;ip<6;ip++){ |
68 |
pam-fi |
1.9 |
xgood[ip] = t.xgood[ip]; |
69 |
|
|
ygood[ip] = t.ygood[ip]; |
70 |
|
|
xm[ip] = t.xm[ip]; |
71 |
|
|
ym[ip] = t.ym[ip]; |
72 |
|
|
zm[ip] = t.zm[ip]; |
73 |
|
|
resx[ip] = t.resx[ip]; |
74 |
|
|
resy[ip] = t.resy[ip]; |
75 |
|
|
xv[ip] = t.xv[ip]; |
76 |
|
|
yv[ip] = t.yv[ip]; |
77 |
|
|
zv[ip] = t.zv[ip]; |
78 |
|
|
axv[ip] = t.axv[ip]; |
79 |
|
|
ayv[ip] = t.ayv[ip]; |
80 |
|
|
dedx_x[ip] = t.dedx_x[ip]; |
81 |
|
|
dedx_y[ip] = t.dedx_y[ip]; |
82 |
|
|
// clx[ip] = 0;//<<<<pointer |
83 |
|
|
// cly[ip] = 0;//<<<<pointer |
84 |
|
|
}; |
85 |
|
|
clx = new TRefArray(*(t.clx)); |
86 |
|
|
cly = new TRefArray(*(t.cly)); |
87 |
|
|
|
88 |
mocchiut |
1.1 |
}; |
89 |
|
|
//-------------------------------------- |
90 |
|
|
// |
91 |
|
|
// |
92 |
|
|
//-------------------------------------- |
93 |
|
|
/** |
94 |
|
|
* Evaluates the trajectory in the apparatus associated to the track. |
95 |
|
|
* 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. |
96 |
|
|
* @param t pointer to an object of the class Trajectory, |
97 |
|
|
* which z coordinates should be previously initialized by calling the proper constructor ( Trajectory::Trajectory(int n, float* zin) ). |
98 |
|
|
* @return error flag. |
99 |
|
|
*/ |
100 |
|
|
int TrkTrack::DoTrack(Trajectory* t){ |
101 |
|
|
|
102 |
|
|
double *dxout = new double[t->npoint]; |
103 |
|
|
double *dyout = new double[t->npoint]; |
104 |
|
|
double *dzin = new double[t->npoint]; |
105 |
|
|
double dal[5]; |
106 |
|
|
|
107 |
|
|
int ifail = 0; |
108 |
|
|
|
109 |
|
|
for (int i=0; i<5; i++) dal[i] = (double)al[i]; |
110 |
|
|
for (int i=0; i<t->npoint; i++) dzin[i] = (double)t->z[i]; |
111 |
|
|
|
112 |
|
|
dotrack_(&(t->npoint),dzin,dxout,dyout,dal,&ifail); |
113 |
|
|
|
114 |
|
|
for (int i=0; i<t->npoint; i++){ |
115 |
|
|
t->x[i] = (float)*dxout++; |
116 |
|
|
t->y[i] = (float)*dyout++; |
117 |
|
|
} |
118 |
|
|
|
119 |
|
|
// delete [] dxout; |
120 |
|
|
// delete [] dyout; |
121 |
|
|
// delete [] dzin; |
122 |
|
|
|
123 |
|
|
return ifail; |
124 |
|
|
}; |
125 |
|
|
//-------------------------------------- |
126 |
|
|
// |
127 |
|
|
// |
128 |
|
|
//-------------------------------------- |
129 |
pam-fi |
1.2 |
/** |
130 |
|
|
* Evaluates the trajectory in the apparatus associated to the track. |
131 |
|
|
* 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. |
132 |
|
|
* @param t pointer to an object of the class Trajectory, |
133 |
|
|
* which z coordinates should be previously initialized by calling the proper constructor ( Trajectory::Trajectory(int n, float* zin) ). |
134 |
|
|
* @return error flag. |
135 |
|
|
*/ |
136 |
|
|
int TrkTrack::DoTrack2(Trajectory* t){ |
137 |
|
|
|
138 |
|
|
double *dxout = new double[t->npoint]; |
139 |
|
|
double *dyout = new double[t->npoint]; |
140 |
|
|
double *dthxout = new double[t->npoint]; |
141 |
|
|
double *dthyout = new double[t->npoint]; |
142 |
|
|
double *dtlout = new double[t->npoint]; |
143 |
|
|
double *dzin = new double[t->npoint]; |
144 |
|
|
double dal[5]; |
145 |
|
|
|
146 |
|
|
int ifail = 0; |
147 |
|
|
|
148 |
|
|
for (int i=0; i<5; i++) dal[i] = (double)al[i]; |
149 |
|
|
for (int i=0; i<t->npoint; i++) dzin[i] = (double)t->z[i]; |
150 |
|
|
|
151 |
|
|
dotrack2_(&(t->npoint),dzin,dxout,dyout,dthxout,dthyout,dtlout,dal,&ifail); |
152 |
|
|
|
153 |
|
|
for (int i=0; i<t->npoint; i++){ |
154 |
|
|
t->x[i] = (float)*dxout++; |
155 |
|
|
t->y[i] = (float)*dyout++; |
156 |
|
|
t->thx[i] = (float)*dthxout++; |
157 |
|
|
t->thy[i] = (float)*dthyout++; |
158 |
|
|
t->tl[i] = (float)*dtlout++; |
159 |
|
|
} |
160 |
|
|
|
161 |
|
|
// delete [] dxout; |
162 |
|
|
// delete [] dyout; |
163 |
|
|
// delete [] dzin; |
164 |
|
|
|
165 |
|
|
return ifail; |
166 |
|
|
}; |
167 |
|
|
//-------------------------------------- |
168 |
|
|
// |
169 |
|
|
// |
170 |
|
|
//-------------------------------------- |
171 |
mocchiut |
1.1 |
//float TrkTrack::BdL(){ |
172 |
|
|
//}; |
173 |
|
|
//-------------------------------------- |
174 |
|
|
// |
175 |
|
|
// |
176 |
|
|
//-------------------------------------- |
177 |
|
|
Float_t TrkTrack::GetRigidity(){ |
178 |
|
|
Float_t rig=0; |
179 |
|
|
if(chi2>0)rig=1./al[4]; |
180 |
|
|
if(rig<0) rig=-rig; |
181 |
|
|
return rig; |
182 |
|
|
}; |
183 |
|
|
// |
184 |
|
|
Float_t TrkTrack::GetDeflection(){ |
185 |
|
|
Float_t def=0; |
186 |
|
|
if(chi2>0)def=al[4]; |
187 |
|
|
return def; |
188 |
|
|
}; |
189 |
|
|
// |
190 |
|
|
Float_t TrkTrack::GetDEDX(){ |
191 |
|
|
Float_t dedx=0; |
192 |
|
|
for(Int_t i=0; i<6; i++)dedx+=dedx_x[i]*xgood[i]+dedx_y[i]*ygood[i]; |
193 |
|
|
dedx = dedx/(this->GetNX()+this->GetNY()); |
194 |
|
|
return dedx; |
195 |
|
|
}; |
196 |
|
|
|
197 |
|
|
//-------------------------------------- |
198 |
|
|
// |
199 |
|
|
// |
200 |
|
|
//-------------------------------------- |
201 |
|
|
void TrkTrack::Dump(){ |
202 |
|
|
cout << endl << "========== Track " ; |
203 |
pam-fi |
1.13 |
cout << endl << "seq. n. : "<< seqno; |
204 |
|
|
cout << endl << "image n. : "<< image; |
205 |
|
|
cout << endl << "al : "; for(int i=0; i<5; i++)cout << al[i] << " "; |
206 |
mocchiut |
1.1 |
cout << endl << "chi^2 : "<< chi2; |
207 |
pam-fi |
1.13 |
cout << endl << "n.step : "<< nstep; |
208 |
|
|
cout << endl << "xgood : "; for(int i=0; i<6; i++)cout << xgood[i] ; |
209 |
mocchiut |
1.1 |
cout << endl << "ygood : "; for(int i=0; i<6; i++)cout << ygood[i] ; |
210 |
|
|
cout << endl << "xm : "; for(int i=0; i<6; i++)cout << xm[i] << " "; |
211 |
|
|
cout << endl << "ym : "; for(int i=0; i<6; i++)cout << ym[i] << " "; |
212 |
|
|
cout << endl << "zm : "; for(int i=0; i<6; i++)cout << zm[i] << " "; |
213 |
pam-fi |
1.13 |
cout << endl << "xv : "; for(int i=0; i<6; i++)cout << xv[i] << " "; |
214 |
|
|
cout << endl << "yv : "; for(int i=0; i<6; i++)cout << yv[i] << " "; |
215 |
|
|
cout << endl << "zv : "; for(int i=0; i<6; i++)cout << zv[i] << " "; |
216 |
|
|
cout << endl << "resx : "; for(int i=0; i<6; i++)cout << resx[i] << " "; |
217 |
|
|
cout << endl << "resy : "; for(int i=0; i<6; i++)cout << resy[i] << " "; |
218 |
|
|
cout << endl << "coval : "; for(int i=0; i<5; i++)cout << coval[0][i]<<" "; |
219 |
|
|
cout << endl << " "; for(int i=0; i<5; i++)cout << coval[1][i]<<" "; |
220 |
|
|
cout << endl << " "; for(int i=0; i<5; i++)cout << coval[2][i]<<" "; |
221 |
|
|
cout << endl << " "; for(int i=0; i<5; i++)cout << coval[3][i]<<" "; |
222 |
|
|
cout << endl << " "; for(int i=0; i<5; i++)cout << coval[4][i]<<" "; |
223 |
mocchiut |
1.1 |
cout << endl << "dedx_x : "; for(int i=0; i<6; i++)cout << dedx_x[i] << " "; |
224 |
|
|
cout << endl << "dedx_y : "; for(int i=0; i<6; i++)cout << dedx_y[i] << " "; |
225 |
pam-fi |
1.14 |
cout << endl; |
226 |
mocchiut |
1.1 |
} |
227 |
pam-fi |
1.13 |
/** |
228 |
|
|
* Set the TrkTrack position measurements |
229 |
|
|
*/ |
230 |
|
|
void TrkTrack::SetMeasure(double *xmeas, double *ymeas, double *zmeas){ |
231 |
|
|
for(int i=0; i<6; i++) xm[i]=*xmeas++; |
232 |
|
|
for(int i=0; i<6; i++) ym[i]=*ymeas++; |
233 |
|
|
for(int i=0; i<6; i++) zm[i]=*zmeas++; |
234 |
|
|
} |
235 |
|
|
/** |
236 |
|
|
* Set the TrkTrack position resolution |
237 |
|
|
*/ |
238 |
|
|
void TrkTrack::SetResolution(double *rx, double *ry){ |
239 |
|
|
for(int i=0; i<6; i++) resx[i]=*rx++; |
240 |
|
|
for(int i=0; i<6; i++) resy[i]=*ry++; |
241 |
|
|
} |
242 |
|
|
/** |
243 |
|
|
* Set the TrkTrack good measurement |
244 |
|
|
*/ |
245 |
|
|
void TrkTrack::SetGood(int *xg, int *yg){ |
246 |
|
|
for(int i=0; i<6; i++) xgood[i]=*xg++; |
247 |
|
|
for(int i=0; i<6; i++) ygood[i]=*yg++; |
248 |
|
|
} |
249 |
|
|
|
250 |
|
|
/** |
251 |
|
|
* Load the magnetic field |
252 |
|
|
*/ |
253 |
pam-fi |
1.16 |
void TrkTrack::LoadField(TString path){ |
254 |
|
|
|
255 |
|
|
strcpy(path_.path,path.Data()); |
256 |
|
|
path_.pathlen = path.Length(); |
257 |
|
|
path_.error = 0; |
258 |
|
|
readb_(); |
259 |
|
|
|
260 |
pam-fi |
1.13 |
}; |
261 |
pam-fi |
1.19 |
|
262 |
|
|
/** |
263 |
|
|
* Method to fill minimization-routine common |
264 |
|
|
*/ |
265 |
|
|
void TrkTrack::FillMiniStruct(cMini2track& track){ |
266 |
|
|
|
267 |
|
|
for(int i=0; i<6; i++){ |
268 |
|
|
|
269 |
|
|
track.xgood[i]=xgood[i]; |
270 |
|
|
track.ygood[i]=ygood[i]; |
271 |
|
|
|
272 |
|
|
track.xm[i]=xm[i]; |
273 |
|
|
track.ym[i]=ym[i]; |
274 |
|
|
track.zm[i]=zm[i]; |
275 |
|
|
|
276 |
|
|
// --- temporaneo ---------------------------- |
277 |
|
|
// andrebbe inserita la dimensione del sensore |
278 |
|
|
float segment = 100.; |
279 |
|
|
track.xm_a[i]=xm[i]; |
280 |
|
|
track.xm_b[i]=xm[i]; |
281 |
|
|
track.ym_a[i]=ym[i]; |
282 |
|
|
track.ym_b[i]=ym[i]; |
283 |
|
|
if( xgood[i] && !ygood[i] ){ |
284 |
|
|
track.ym_a[i] = track.ym_a[i]+segment; |
285 |
|
|
track.ym_b[i] = track.ym_b[i]-segment; |
286 |
|
|
}else if( !xgood[i] && ygood[i]){ |
287 |
|
|
track.xm_a[i] = track.xm_a[i]+segment; |
288 |
|
|
track.xm_b[i] = track.xm_b[i]-segment; |
289 |
|
|
} |
290 |
|
|
// --- temporaneo ---------------------------- |
291 |
|
|
|
292 |
|
|
track.resx[i]=resx[i]; |
293 |
|
|
track.resy[i]=resy[i]; |
294 |
|
|
} |
295 |
|
|
|
296 |
|
|
for(int i=0; i<5; i++) track.al[i]=al[i]; |
297 |
|
|
track.zini = 23.5; |
298 |
|
|
// ZINI = 23.5 !!! it should be the same parameter in all codes |
299 |
|
|
|
300 |
|
|
} |
301 |
|
|
/** |
302 |
|
|
* Method to set values from minimization-routine common |
303 |
|
|
*/ |
304 |
|
|
void TrkTrack::SetFromMiniStruct(cMini2track *track){ |
305 |
|
|
|
306 |
|
|
for(int i=0; i<5; i++) { |
307 |
|
|
al[i]=track->al[i]; |
308 |
|
|
for(int j=0; j<5; j++) coval[i][j]=track->cov[i][j]; |
309 |
|
|
} |
310 |
|
|
chi2 = track->chi2; |
311 |
|
|
nstep = track->nstep; |
312 |
|
|
for(int i=0; i<6; i++){ |
313 |
|
|
xv[i] = track->xv[i]; |
314 |
|
|
yv[i] = track->yv[i]; |
315 |
|
|
zv[i] = track->zv[i]; |
316 |
|
|
xm[i] = track->xm[i]; |
317 |
|
|
ym[i] = track->ym[i]; |
318 |
|
|
zm[i] = track->zm[i]; |
319 |
|
|
axv[i] = track->axv[i]; |
320 |
|
|
ayv[i] = track->ayv[i]; |
321 |
|
|
} |
322 |
|
|
|
323 |
|
|
|
324 |
|
|
} |
325 |
pam-fi |
1.13 |
/** |
326 |
|
|
* Tracking method. It calls F77 mini routine. |
327 |
|
|
*/ |
328 |
|
|
void TrkTrack::Fit(double pfixed, int& fail, int iprint){ |
329 |
pam-fi |
1.15 |
|
330 |
|
|
float al_ini[] = {0.,0.,0.,0.,0.}; |
331 |
|
|
|
332 |
pam-fi |
1.13 |
extern cMini2track track_; |
333 |
|
|
fail = 0; |
334 |
pam-fi |
1.19 |
FillMiniStruct(track_); |
335 |
pam-fi |
1.15 |
|
336 |
pam-fi |
1.19 |
// if fit variables have been reset, evaluate the initial guess |
337 |
pam-fi |
1.15 |
if(al[0]==-9999.&&al[1]==-9999.&&al[2]==-9999.&&al[3]==-9999.&&al[4]==-9999.)guess_(); |
338 |
|
|
|
339 |
pam-fi |
1.16 |
// --------------------- free momentum |
340 |
pam-fi |
1.14 |
if(pfixed==0.) { |
341 |
pam-fi |
1.19 |
track_.pfixed=0.; |
342 |
pam-fi |
1.14 |
} |
343 |
pam-fi |
1.16 |
// --------------------- fixed momentum |
344 |
pam-fi |
1.13 |
if(pfixed!=0.) { |
345 |
pam-fi |
1.19 |
al[4]=1./pfixed; |
346 |
|
|
track_.pfixed=pfixed; |
347 |
pam-fi |
1.13 |
} |
348 |
pam-fi |
1.15 |
|
349 |
pam-fi |
1.19 |
// store temporarily the initial guess |
350 |
pam-fi |
1.15 |
for(int i=0; i<5; i++) al_ini[i]=track_.al[i]; |
351 |
|
|
|
352 |
pam-fi |
1.19 |
// ------------------------------------------ |
353 |
|
|
// call mini routine |
354 |
pam-fi |
1.13 |
int istep=0; |
355 |
|
|
int ifail=0; |
356 |
|
|
mini2_(&istep,&ifail, &iprint); |
357 |
|
|
if(ifail!=0) { |
358 |
pam-fi |
1.19 |
if(iprint)cout << "ERROR: ifail= " << ifail << endl; |
359 |
pam-fi |
1.13 |
fail = 1; |
360 |
|
|
} |
361 |
pam-fi |
1.19 |
// ------------------------------------------ |
362 |
pam-fi |
1.15 |
|
363 |
pam-fi |
1.19 |
SetFromMiniStruct(&track_); |
364 |
pam-fi |
1.13 |
// cout << endl << "eta ===> " << track_.al[4] << endl; |
365 |
|
|
|
366 |
pam-fi |
1.19 |
// for(int i=0; i<5; i++) al[i]=track_.al[i]; |
367 |
|
|
// chi2=track_.chi2; |
368 |
|
|
// nstep=track_.nstep; |
369 |
|
|
// for(int i=0; i<6; i++) xv[i]=track_.xv[i]; |
370 |
|
|
// for(int i=0; i<6; i++) yv[i]=track_.yv[i]; |
371 |
|
|
// for(int i=0; i<6; i++) zv[i]=track_.zv[i]; |
372 |
|
|
// for(int i=0; i<6; i++) axv[i]=track_.axv[i]; |
373 |
|
|
// for(int i=0; i<6; i++) ayv[i]=track_.ayv[i]; |
374 |
|
|
// for(int i=0; i<5; i++) { |
375 |
|
|
// for(int j=0; j<5; j++) coval[i][j]=track_.cov[i][j]; |
376 |
|
|
// } |
377 |
pam-fi |
1.15 |
|
378 |
pam-fi |
1.19 |
// if(fail && iprint){ |
379 |
|
|
// cout << " >>>> fit failed >>>> drawing initial par"<<endl; |
380 |
|
|
// for(int i=0; i<5; i++) al[i]=al_ini[i]; |
381 |
|
|
// } |
382 |
pam-fi |
1.15 |
|
383 |
pam-fi |
1.13 |
}; |
384 |
|
|
/* |
385 |
pam-fi |
1.15 |
* Reset the fit parameters |
386 |
pam-fi |
1.13 |
*/ |
387 |
|
|
void TrkTrack::FitReset(){ |
388 |
|
|
for(int i=0; i<5; i++) al[i]=-9999.; |
389 |
|
|
chi2=0.; |
390 |
|
|
nstep=0; |
391 |
|
|
for(int i=0; i<6; i++) xv[i]=0.; |
392 |
|
|
for(int i=0; i<6; i++) yv[i]=0.; |
393 |
|
|
for(int i=0; i<6; i++) zv[i]=0.; |
394 |
|
|
for(int i=0; i<6; i++) axv[i]=0.; |
395 |
|
|
for(int i=0; i<6; i++) ayv[i]=0.; |
396 |
|
|
for(int i=0; i<5; i++) { |
397 |
|
|
for(int j=0; j<5; j++) coval[i][j]=0.; |
398 |
|
|
} |
399 |
|
|
} |
400 |
|
|
|
401 |
mocchiut |
1.1 |
//-------------------------------------- |
402 |
|
|
// |
403 |
|
|
// |
404 |
|
|
//-------------------------------------- |
405 |
pam-fi |
1.10 |
void TrkTrack::Clear(){ |
406 |
|
|
seqno = -1; |
407 |
|
|
image = -1; |
408 |
|
|
chi2 = 0; |
409 |
|
|
nstep = 0; |
410 |
|
|
for(int it1=0;it1<5;it1++){ |
411 |
|
|
al[it1] = 0; |
412 |
|
|
for(int it2=0;it2<5;it2++)coval[it1][it2] = 0; |
413 |
|
|
}; |
414 |
|
|
for(int ip=0;ip<6;ip++){ |
415 |
|
|
xgood[ip] = 0; |
416 |
|
|
ygood[ip] = 0; |
417 |
|
|
xm[ip] = 0; |
418 |
|
|
ym[ip] = 0; |
419 |
|
|
zm[ip] = 0; |
420 |
|
|
resx[ip] = 0; |
421 |
|
|
resy[ip] = 0; |
422 |
|
|
xv[ip] = 0; |
423 |
|
|
yv[ip] = 0; |
424 |
|
|
zv[ip] = 0; |
425 |
|
|
axv[ip] = 0; |
426 |
|
|
ayv[ip] = 0; |
427 |
|
|
dedx_x[ip] = 0; |
428 |
|
|
dedx_y[ip] = 0; |
429 |
|
|
// clx[ip] = 0; |
430 |
|
|
// cly[ip] = 0; |
431 |
|
|
}; |
432 |
|
|
clx->Clear(); |
433 |
|
|
cly->Clear(); |
434 |
|
|
}; |
435 |
|
|
//-------------------------------------- |
436 |
|
|
// |
437 |
|
|
// |
438 |
|
|
//-------------------------------------- |
439 |
pam-fi |
1.11 |
void TrkTrack::Delete(){ |
440 |
|
|
Clear(); |
441 |
|
|
clx->Delete(); |
442 |
|
|
cly->Delete(); |
443 |
|
|
}; |
444 |
|
|
//-------------------------------------- |
445 |
|
|
// |
446 |
|
|
// |
447 |
|
|
//-------------------------------------- |
448 |
pam-fi |
1.10 |
|
449 |
|
|
//-------------------------------------- |
450 |
|
|
// |
451 |
|
|
// |
452 |
|
|
//-------------------------------------- |
453 |
mocchiut |
1.1 |
TrkSinglet::TrkSinglet(){ |
454 |
|
|
plane = 0; |
455 |
|
|
coord[0] = 0; |
456 |
|
|
coord[1] = 0; |
457 |
|
|
sgnl = 0; |
458 |
pam-fi |
1.9 |
cls = 0; |
459 |
mocchiut |
1.1 |
}; |
460 |
|
|
//-------------------------------------- |
461 |
|
|
// |
462 |
|
|
// |
463 |
|
|
//-------------------------------------- |
464 |
|
|
TrkSinglet::TrkSinglet(const TrkSinglet& s){ |
465 |
|
|
plane = s.plane; |
466 |
|
|
coord[0] = s.coord[0]; |
467 |
|
|
coord[1] = s.coord[1]; |
468 |
|
|
sgnl = s.sgnl; |
469 |
pam-fi |
1.9 |
// cls = 0;//<<<<pointer |
470 |
|
|
cls = TRef(s.cls); |
471 |
mocchiut |
1.1 |
}; |
472 |
|
|
//-------------------------------------- |
473 |
|
|
// |
474 |
|
|
// |
475 |
|
|
//-------------------------------------- |
476 |
|
|
void TrkSinglet::Dump(){ |
477 |
|
|
int i=0; |
478 |
|
|
cout << endl << "========== Singlet " ; |
479 |
|
|
cout << endl << "plane : " << plane; |
480 |
|
|
cout << endl << "coord[2] : "; while( i<2 && cout << coord[i] << " ") i++; |
481 |
|
|
cout << endl << "sgnl : " << sgnl; |
482 |
|
|
} |
483 |
|
|
//-------------------------------------- |
484 |
|
|
// |
485 |
|
|
// |
486 |
|
|
//-------------------------------------- |
487 |
|
|
TrkLevel2::TrkLevel2(){ |
488 |
pam-fi |
1.10 |
// good2 = -1; |
489 |
mocchiut |
1.1 |
for(Int_t i=0; i<12 ; i++){ |
490 |
pam-fi |
1.10 |
// crc[i] = -1; |
491 |
|
|
good[i] = -1; |
492 |
|
|
}; |
493 |
mocchiut |
1.1 |
Track = new TClonesArray("TrkTrack"); |
494 |
|
|
SingletX = new TClonesArray("TrkSinglet"); |
495 |
|
|
SingletY = new TClonesArray("TrkSinglet"); |
496 |
pam-fi |
1.6 |
|
497 |
|
|
// PhysicalTrack = new TClonesArray("TrkTrack"); |
498 |
|
|
//sostituire con TRefArray... appena ho capito come si usa |
499 |
mocchiut |
1.1 |
} |
500 |
|
|
//-------------------------------------- |
501 |
|
|
// |
502 |
|
|
// |
503 |
|
|
//-------------------------------------- |
504 |
|
|
void TrkLevel2::Dump(){ |
505 |
pam-fi |
1.10 |
|
506 |
mocchiut |
1.1 |
TClonesArray &t = *Track; |
507 |
|
|
TClonesArray &sx = *SingletX; |
508 |
|
|
TClonesArray &sy = *SingletY; |
509 |
pam-fi |
1.10 |
// |
510 |
mocchiut |
1.1 |
cout << endl << endl << "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"; |
511 |
pam-fi |
1.10 |
cout << endl << "good : "; for(int i=0; i<12; i++) cout << good[i]<<" "; |
512 |
mocchiut |
1.1 |
cout << endl << "ntrk() : " << this->ntrk() ; |
513 |
|
|
cout << endl << "nclsx() : " << this->nclsx(); |
514 |
|
|
cout << endl << "nclsy() : " << this->nclsy(); |
515 |
|
|
for(int i=0; i<this->ntrk(); i++) ((TrkTrack *)t[i])->Dump(); |
516 |
|
|
for(int i=0; i<this->nclsx(); i++) ((TrkSinglet *)sx[i])->Dump(); |
517 |
|
|
for(int i=0; i<this->nclsy(); i++) ((TrkSinglet *)sy[i])->Dump(); |
518 |
|
|
} |
519 |
|
|
//-------------------------------------- |
520 |
|
|
// |
521 |
|
|
// |
522 |
|
|
//-------------------------------------- |
523 |
|
|
/** |
524 |
|
|
* Fills a TrkLevel2 object with values from a struct cTrkLevel2 (to get data from F77 common). |
525 |
|
|
*/ |
526 |
pam-fi |
1.7 |
void TrkLevel2::SetFromLevel2Struct(cTrkLevel2 *l2){ |
527 |
pam-fi |
1.10 |
|
528 |
|
|
// temporary objects: |
529 |
mocchiut |
1.1 |
TrkSinglet* t_singlet = new TrkSinglet(); |
530 |
|
|
TrkTrack* t_track = new TrkTrack(); |
531 |
pam-fi |
1.10 |
|
532 |
|
|
// **** general variables **** |
533 |
|
|
// good2 = l2->good2; |
534 |
mocchiut |
1.1 |
for(Int_t i=0; i<12 ; i++){ |
535 |
pam-fi |
1.10 |
// crc[i] = l2->crc[i]; |
536 |
|
|
good[i] = l2->good[i]; |
537 |
|
|
}; |
538 |
|
|
// *** TRACKS *** |
539 |
mocchiut |
1.1 |
TClonesArray &t = *Track; |
540 |
|
|
for(int i=0; i<l2->ntrk; i++){ |
541 |
pam-fi |
1.9 |
t_track->seqno = i;// NBNBNBNB deve sempre essere = i |
542 |
|
|
t_track->image = l2->image[i]-1; |
543 |
|
|
// cout << "track "<<i<<t_track->seqno << t_track->image<<endl; |
544 |
|
|
t_track->chi2 = l2->chi2_nt[i]; |
545 |
pam-fi |
1.10 |
t_track->nstep = l2->nstep_nt[i]; |
546 |
pam-fi |
1.9 |
for(int it1=0;it1<5;it1++){ |
547 |
|
|
t_track->al[it1] = l2->al_nt[i][it1]; |
548 |
|
|
for(int it2=0;it2<5;it2++) |
549 |
|
|
t_track->coval[it1][it2] = l2->coval[i][it2][it1]; |
550 |
|
|
}; |
551 |
|
|
for(int ip=0;ip<6;ip++){ |
552 |
|
|
t_track->xgood[ip] = l2->xgood_nt[i][ip]; |
553 |
|
|
t_track->ygood[ip] = l2->ygood_nt[i][ip]; |
554 |
|
|
t_track->xm[ip] = l2->xm_nt[i][ip]; |
555 |
|
|
t_track->ym[ip] = l2->ym_nt[i][ip]; |
556 |
|
|
t_track->zm[ip] = l2->zm_nt[i][ip]; |
557 |
|
|
t_track->resx[ip] = l2->resx_nt[i][ip]; |
558 |
|
|
t_track->resy[ip] = l2->resy_nt[i][ip]; |
559 |
|
|
t_track->xv[ip] = l2->xv_nt[i][ip]; |
560 |
|
|
t_track->yv[ip] = l2->yv_nt[i][ip]; |
561 |
|
|
t_track->zv[ip] = l2->zv_nt[i][ip]; |
562 |
|
|
t_track->axv[ip] = l2->axv_nt[i][ip]; |
563 |
|
|
t_track->ayv[ip] = l2->ayv_nt[i][ip]; |
564 |
|
|
t_track->dedx_x[ip] = l2->dedx_x[i][ip]; |
565 |
|
|
t_track->dedx_y[ip] = l2->dedx_y[i][ip]; |
566 |
|
|
// t_track->clx[ip] = 0; |
567 |
|
|
// t_track->cly[ip] = 0; |
568 |
|
|
}; |
569 |
|
|
new(t[i]) TrkTrack(*t_track); |
570 |
|
|
t_track->Clear(); |
571 |
mocchiut |
1.1 |
}; |
572 |
|
|
// *** SINGLETS *** |
573 |
|
|
TClonesArray &sx = *SingletX; |
574 |
|
|
for(int i=0; i<l2->nclsx; i++){ |
575 |
pam-fi |
1.9 |
t_singlet->plane = l2->planex[i]; |
576 |
|
|
t_singlet->coord[0] = l2->xs[i][0]; |
577 |
|
|
t_singlet->coord[1] = l2->xs[i][1]; |
578 |
|
|
t_singlet->sgnl = l2->signlxs[i]; |
579 |
|
|
// t_singlet->cls = 0; |
580 |
|
|
new(sx[i]) TrkSinglet(*t_singlet); |
581 |
|
|
t_singlet->Clear(); |
582 |
mocchiut |
1.1 |
} |
583 |
|
|
TClonesArray &sy = *SingletY; |
584 |
|
|
for(int i=0; i<l2->nclsy; i++){ |
585 |
pam-fi |
1.9 |
t_singlet->plane = l2->planey[i]; |
586 |
|
|
t_singlet->coord[0] = l2->ys[i][0]; |
587 |
|
|
t_singlet->coord[1] = l2->ys[i][1]; |
588 |
|
|
t_singlet->sgnl = l2->signlys[i]; |
589 |
|
|
// t_singlet->cls = 0; |
590 |
|
|
new(sy[i]) TrkSinglet(*t_singlet); |
591 |
|
|
t_singlet->Clear(); |
592 |
|
|
}; |
593 |
|
|
|
594 |
|
|
delete t_track; |
595 |
|
|
delete t_singlet; |
596 |
|
|
} |
597 |
|
|
//-------------------------------------- |
598 |
|
|
// |
599 |
|
|
// |
600 |
|
|
//-------------------------------------- |
601 |
|
|
/** |
602 |
|
|
* Fills a TrkLevel2 object with values from a struct cTrkLevel2 (to get data from F77 common). |
603 |
|
|
* Ref to Level1 data (clusters) is also set. |
604 |
|
|
*/ |
605 |
|
|
void TrkLevel2::SetFromLevel2Struct(cTrkLevel2 *l2, TrkLevel1 *l1){ |
606 |
|
|
|
607 |
|
|
// temporary objects: |
608 |
|
|
TrkSinglet* t_singlet = new TrkSinglet(); |
609 |
|
|
TrkTrack* t_track = new TrkTrack(); |
610 |
|
|
// general variables |
611 |
pam-fi |
1.10 |
// good2 = l2->good2; |
612 |
pam-fi |
1.9 |
for(Int_t i=0; i<12 ; i++){ |
613 |
pam-fi |
1.10 |
// crc[i] = l2->crc[i]; |
614 |
|
|
good[i] = l2->good[i]; |
615 |
pam-fi |
1.9 |
}; |
616 |
|
|
// *** TRACKS *** |
617 |
|
|
TClonesArray &t = *Track; |
618 |
|
|
for(int i=0; i<l2->ntrk; i++){ |
619 |
|
|
t_track->seqno = i;// NBNBNBNB deve sempre essere = i |
620 |
|
|
t_track->image = l2->image[i]-1; |
621 |
|
|
// cout << "track "<<i<<t_track->seqno << t_track->image<<endl; |
622 |
|
|
t_track->chi2 = l2->chi2_nt[i]; |
623 |
pam-fi |
1.10 |
t_track->nstep = l2->nstep_nt[i]; |
624 |
pam-fi |
1.9 |
for(int it1=0;it1<5;it1++){ |
625 |
|
|
t_track->al[it1] = l2->al_nt[i][it1]; |
626 |
|
|
for(int it2=0;it2<5;it2++) |
627 |
|
|
t_track->coval[it1][it2] = l2->coval[i][it2][it1]; |
628 |
|
|
}; |
629 |
|
|
for(int ip=0;ip<6;ip++){ |
630 |
|
|
t_track->xgood[ip] = l2->xgood_nt[i][ip]; |
631 |
|
|
t_track->ygood[ip] = l2->ygood_nt[i][ip]; |
632 |
|
|
t_track->xm[ip] = l2->xm_nt[i][ip]; |
633 |
|
|
t_track->ym[ip] = l2->ym_nt[i][ip]; |
634 |
|
|
t_track->zm[ip] = l2->zm_nt[i][ip]; |
635 |
|
|
t_track->resx[ip] = l2->resx_nt[i][ip]; |
636 |
|
|
t_track->resy[ip] = l2->resy_nt[i][ip]; |
637 |
|
|
t_track->xv[ip] = l2->xv_nt[i][ip]; |
638 |
|
|
t_track->yv[ip] = l2->yv_nt[i][ip]; |
639 |
|
|
t_track->zv[ip] = l2->zv_nt[i][ip]; |
640 |
|
|
t_track->axv[ip] = l2->axv_nt[i][ip]; |
641 |
|
|
t_track->ayv[ip] = l2->ayv_nt[i][ip]; |
642 |
|
|
t_track->dedx_x[ip] = l2->dedx_x[i][ip]; |
643 |
|
|
t_track->dedx_y[ip] = l2->dedx_y[i][ip]; |
644 |
|
|
// cout << "traccia "<<i<<" -- "<< ip << " "<< l2->cltrx[i][ip] <<" "<< l2->cltry[i][ip] <<" "<< t_track->xgood[ip] << t_track->ygood[ip]<<endl; |
645 |
|
|
//----------------------------------------------------- |
646 |
|
|
// t_track->clx[ip] = l1->GetCluster(l2->cltrx[i][ip]-1); |
647 |
|
|
// t_track->cly[ip] = l1->GetCluster(l2->cltry[i][ip]-1); |
648 |
|
|
if(t_track->xgood[ip])t_track->clx->AddAt(l1->GetCluster(l2->cltrx[i][ip]-1),ip); |
649 |
|
|
if(t_track->ygood[ip])t_track->cly->AddAt(l1->GetCluster(l2->cltry[i][ip]-1),ip); |
650 |
pam-fi |
1.10 |
// 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; |
651 |
|
|
// 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; |
652 |
pam-fi |
1.9 |
//----------------------------------------------------- |
653 |
|
|
}; |
654 |
|
|
new(t[i]) TrkTrack(*t_track); |
655 |
|
|
t_track->Clear(); |
656 |
|
|
}; |
657 |
|
|
// *** SINGLETS *** |
658 |
|
|
TClonesArray &sx = *SingletX; |
659 |
|
|
for(int i=0; i<l2->nclsx; i++){ |
660 |
|
|
t_singlet->plane = l2->planex[i]; |
661 |
|
|
t_singlet->coord[0] = l2->xs[i][0]; |
662 |
|
|
t_singlet->coord[1] = l2->xs[i][1]; |
663 |
|
|
t_singlet->sgnl = l2->signlxs[i]; |
664 |
|
|
//----------------------------------------------------- |
665 |
|
|
// cout << "singolo x "<<i<<" -- "<< l2->clsx[i] <<endl; |
666 |
|
|
t_singlet->cls = l1->GetCluster(l2->clsx[i]-1); |
667 |
pam-fi |
1.10 |
// cout<<" i "<<i<<" l2->clsx[i] "<<l2->clsx[i]<< " l1->GetCluster(l2->clsx[i]-1) "<<l1->GetCluster(l2->clsx[i]-1)<<endl; |
668 |
pam-fi |
1.9 |
//----------------------------------------------------- |
669 |
|
|
new(sx[i]) TrkSinglet(*t_singlet); |
670 |
|
|
t_singlet->Clear(); |
671 |
|
|
} |
672 |
|
|
TClonesArray &sy = *SingletY; |
673 |
|
|
for(int i=0; i<l2->nclsy; i++){ |
674 |
|
|
t_singlet->plane = l2->planey[i]; |
675 |
|
|
t_singlet->coord[0] = l2->ys[i][0]; |
676 |
|
|
t_singlet->coord[1] = l2->ys[i][1]; |
677 |
|
|
t_singlet->sgnl = l2->signlys[i]; |
678 |
|
|
//----------------------------------------------------- |
679 |
|
|
// cout << "singolo y "<<i<<" -- "<< l2->clsy[i] <<endl; |
680 |
|
|
t_singlet->cls = l1->GetCluster(l2->clsy[i]-1); |
681 |
pam-fi |
1.10 |
// cout<<" i "<<i<<" l2->clsy[i] "<<l2->clsy[i]<< " l1->GetCluster(l2->clsy[i]-1) "<<l1->GetCluster(l2->clsy[i]-1)<<endl; |
682 |
pam-fi |
1.9 |
//----------------------------------------------------- |
683 |
|
|
new(sy[i]) TrkSinglet(*t_singlet); |
684 |
|
|
t_singlet->Clear(); |
685 |
mocchiut |
1.1 |
}; |
686 |
pam-fi |
1.5 |
|
687 |
|
|
delete t_track; |
688 |
|
|
delete t_singlet; |
689 |
mocchiut |
1.1 |
} |
690 |
pam-fi |
1.7 |
/** |
691 |
|
|
* Fills a struct cTrkLevel2 with values from a TrkLevel2 object (to put data into a F77 common). |
692 |
|
|
*/ |
693 |
|
|
|
694 |
|
|
void TrkLevel2::GetLevel2Struct(cTrkLevel2 *l2) const { |
695 |
|
|
|
696 |
|
|
// general variables |
697 |
pam-fi |
1.10 |
// l2->good2 = good2 ; |
698 |
pam-fi |
1.7 |
for(Int_t i=0; i<12 ; i++){ |
699 |
pam-fi |
1.10 |
// l2->crc[i] = crc[i]; |
700 |
|
|
l2->good[i] = good[i]; |
701 |
pam-fi |
1.7 |
}; |
702 |
|
|
// *** TRACKS *** |
703 |
|
|
|
704 |
|
|
l2->ntrk = Track->GetEntries(); |
705 |
|
|
for(Int_t i=0;i<l2->ntrk;i++){ |
706 |
|
|
l2->image[i] = 1 + ((TrkTrack *)Track->At(i))->image; |
707 |
|
|
l2->chi2_nt[i] = ((TrkTrack *)Track->At(i))->chi2; |
708 |
pam-fi |
1.10 |
l2->nstep_nt[i] = ((TrkTrack *)Track->At(i))->nstep; |
709 |
|
|
for(int it1=0;it1<5;it1++){ |
710 |
pam-fi |
1.7 |
l2->al_nt[i][it1] = ((TrkTrack *)Track->At(i))->al[it1]; |
711 |
|
|
for(int it2=0;it2<5;it2++) |
712 |
|
|
l2->coval[i][it2][it1] = ((TrkTrack *)Track->At(i))->coval[it1][it2]; |
713 |
|
|
}; |
714 |
|
|
for(int ip=0;ip<6;ip++){ |
715 |
|
|
l2->xgood_nt[i][ip] = ((TrkTrack *)Track->At(i))->xgood[ip]; |
716 |
|
|
l2->ygood_nt[i][ip] = ((TrkTrack *)Track->At(i))->ygood[ip]; |
717 |
|
|
l2->xm_nt[i][ip] = ((TrkTrack *)Track->At(i))->xm[ip]; |
718 |
|
|
l2->ym_nt[i][ip] = ((TrkTrack *)Track->At(i))->ym[ip]; |
719 |
|
|
l2->zm_nt[i][ip] = ((TrkTrack *)Track->At(i))->zm[ip]; |
720 |
|
|
l2->resx_nt[i][ip] = ((TrkTrack *)Track->At(i))->resx[ip]; |
721 |
|
|
l2->resy_nt[i][ip] = ((TrkTrack *)Track->At(i))->resy[ip]; |
722 |
|
|
l2->xv_nt[i][ip] = ((TrkTrack *)Track->At(i))->xv[ip]; |
723 |
|
|
l2->yv_nt[i][ip] = ((TrkTrack *)Track->At(i))->yv[ip]; |
724 |
|
|
l2->zv_nt[i][ip] = ((TrkTrack *)Track->At(i))->zv[ip]; |
725 |
|
|
l2->axv_nt[i][ip] = ((TrkTrack *)Track->At(i))->axv[ip]; |
726 |
|
|
l2->ayv_nt[i][ip] = ((TrkTrack *)Track->At(i))->ayv[ip]; |
727 |
|
|
l2->dedx_x[i][ip] = ((TrkTrack *)Track->At(i))->dedx_x[ip]; |
728 |
|
|
l2->dedx_y[i][ip] = ((TrkTrack *)Track->At(i))->dedx_y[ip]; |
729 |
|
|
}; |
730 |
|
|
} |
731 |
|
|
|
732 |
|
|
// *** SINGLETS *** |
733 |
|
|
l2->nclsx = SingletX->GetEntries(); |
734 |
|
|
for(Int_t i=0;i<l2->nclsx;i++){ |
735 |
|
|
l2->planex[i] = ((TrkSinglet *)SingletX->At(i))->plane; |
736 |
|
|
l2->xs[i][0] = ((TrkSinglet *)SingletX->At(i))->coord[0]; |
737 |
|
|
l2->xs[i][1] = ((TrkSinglet *)SingletX->At(i))->coord[1]; |
738 |
|
|
l2->signlxs[i] = ((TrkSinglet *)SingletX->At(i))->sgnl; |
739 |
|
|
} |
740 |
|
|
l2->nclsy = SingletY->GetEntries(); |
741 |
|
|
for(Int_t i=0;i<l2->nclsy;i++){ |
742 |
|
|
l2->planey[i] = ((TrkSinglet *)SingletY->At(i))->plane; |
743 |
|
|
l2->ys[i][0] = ((TrkSinglet *)SingletY->At(i))->coord[0]; |
744 |
|
|
l2->ys[i][1] = ((TrkSinglet *)SingletY->At(i))->coord[1]; |
745 |
|
|
l2->signlys[i] = ((TrkSinglet *)SingletY->At(i))->sgnl; |
746 |
|
|
} |
747 |
|
|
} |
748 |
mocchiut |
1.1 |
//-------------------------------------- |
749 |
|
|
// |
750 |
|
|
// |
751 |
|
|
//-------------------------------------- |
752 |
|
|
void TrkLevel2::Clear(){ |
753 |
pam-fi |
1.10 |
// good2 = -1; |
754 |
mocchiut |
1.1 |
for(Int_t i=0; i<12 ; i++){ |
755 |
pam-fi |
1.10 |
// crc[i] = -1; |
756 |
|
|
good[i] = -1; |
757 |
|
|
}; |
758 |
pam-fi |
1.5 |
/* Track->RemoveAll(); |
759 |
mocchiut |
1.1 |
SingletX->RemoveAll(); |
760 |
pam-fi |
1.5 |
SingletY->RemoveAll();*/ |
761 |
|
|
// modify to avoid memory leakage |
762 |
|
|
Track->Clear(); |
763 |
|
|
SingletX->Clear(); |
764 |
|
|
SingletY->Clear(); |
765 |
mocchiut |
1.1 |
} |
766 |
|
|
//-------------------------------------- |
767 |
|
|
// |
768 |
|
|
// |
769 |
|
|
//-------------------------------------- |
770 |
pam-fi |
1.11 |
void TrkLevel2::Delete(){ |
771 |
|
|
|
772 |
|
|
Clear(); |
773 |
|
|
Track->Delete(); |
774 |
|
|
SingletX->Delete(); |
775 |
|
|
SingletY->Delete(); |
776 |
|
|
} |
777 |
|
|
//-------------------------------------- |
778 |
|
|
// |
779 |
|
|
// |
780 |
|
|
//-------------------------------------- |
781 |
mocchiut |
1.1 |
/** |
782 |
|
|
* 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). |
783 |
|
|
* This method is overridden by PamLevel2::GetTracks(), where calorimeter and TOF information is used. |
784 |
|
|
*/ |
785 |
pam-fi |
1.8 |
TRefArray *TrkLevel2::GetTracks_NFitSorted(){ |
786 |
pam-fi |
1.3 |
|
787 |
pam-fi |
1.8 |
TRefArray *sorted = new TRefArray(); |
788 |
|
|
|
789 |
|
|
TClonesArray &t = *Track; |
790 |
|
|
// TClonesArray &ts = *PhysicalTrack; |
791 |
|
|
int N = ntrk(); |
792 |
|
|
vector<int> m(N); for(int i=0; i<N; i++)m[i]=1; |
793 |
|
|
// int m[50]; for(int i=0; i<N; i++)m[i]=1; |
794 |
|
|
|
795 |
|
|
int indo=0; |
796 |
|
|
int indi=0; |
797 |
|
|
while(N != 0){ |
798 |
|
|
int nfit =0; |
799 |
|
|
float chi2ref = numeric_limits<float>::max(); |
800 |
pam-fi |
1.9 |
|
801 |
pam-fi |
1.8 |
// first loop to search maximum num. of fit points |
802 |
|
|
for(int i=0; i < ntrk(); i++){ |
803 |
|
|
if( ((TrkTrack *)t[i])->GetNtot() >= nfit && m[i]==1){ |
804 |
|
|
nfit = ((TrkTrack *)t[i])->GetNtot(); |
805 |
|
|
} |
806 |
|
|
} |
807 |
|
|
//second loop to search minimum chi2 among selected |
808 |
|
|
for(int i=0; i<this->ntrk(); i++){ |
809 |
pam-fi |
1.9 |
Float_t chi2 = ((TrkTrack *)t[i])->chi2; |
810 |
|
|
if(chi2 < 0) chi2 = chi2*1000; |
811 |
|
|
if( chi2 < chi2ref |
812 |
|
|
&& ((TrkTrack *)t[i])->GetNtot() == nfit |
813 |
|
|
&& m[i]==1){ |
814 |
pam-fi |
1.8 |
chi2ref = ((TrkTrack *)t[i])->chi2; |
815 |
|
|
indi = i; |
816 |
pam-fi |
1.9 |
}; |
817 |
|
|
}; |
818 |
pam-fi |
1.8 |
if( ((TrkTrack *)t[indi])->HasImage() ){ |
819 |
|
|
m[((TrkTrack *)t[indi])->image] = 0; |
820 |
|
|
N--; |
821 |
|
|
|
822 |
|
|
// cout << "i** "<< ((TrkTrack *)t[indi])->image << " " << nfiti <<" "<<chi2i<<endl; |
823 |
pam-fi |
1.9 |
}; |
824 |
pam-fi |
1.8 |
sorted->Add( (TrkTrack*)t[indi] ); |
825 |
pam-fi |
1.3 |
|
826 |
pam-fi |
1.8 |
m[indi] = 0; |
827 |
|
|
// cout << "SORTED "<< indo << " "<< indi << " "<< N << endl; |
828 |
|
|
N--; |
829 |
|
|
indo++; |
830 |
pam-fi |
1.3 |
} |
831 |
pam-fi |
1.8 |
m.clear(); |
832 |
|
|
// cout << "GetTracks_NFitSorted(it): Done"<< endl; |
833 |
|
|
|
834 |
|
|
return sorted; |
835 |
pam-fi |
1.6 |
// return PhysicalTrack; |
836 |
pam-fi |
1.3 |
} |
837 |
mocchiut |
1.1 |
//-------------------------------------- |
838 |
|
|
// |
839 |
|
|
// |
840 |
|
|
//-------------------------------------- |
841 |
|
|
/** |
842 |
|
|
* Retrieves the is-th stored track. |
843 |
|
|
* @param it Track number, ranging from 0 to ntrk(). |
844 |
|
|
* Fitted tracks ( images included ) are stored in a TObjectArray ( TrkLevel2::Track ) in the same order they are returned by the F77 fitting routine. |
845 |
|
|
*/ |
846 |
|
|
TrkTrack *TrkLevel2::GetStoredTrack(int is){ |
847 |
|
|
|
848 |
|
|
if(is >= this->ntrk()){ |
849 |
|
|
cout << "** TrkLevel2 ** Track "<< is << "doen not exits! " << endl; |
850 |
|
|
cout << " Stored tracks ntrk() = "<< this->ntrk() << endl; |
851 |
|
|
return 0; |
852 |
|
|
} |
853 |
|
|
TClonesArray &t = *(Track); |
854 |
|
|
TrkTrack *track = (TrkTrack*)t[is]; |
855 |
|
|
return track; |
856 |
|
|
} |
857 |
|
|
//-------------------------------------- |
858 |
|
|
// |
859 |
|
|
// |
860 |
|
|
//-------------------------------------- |
861 |
|
|
/** |
862 |
pam-fi |
1.6 |
* Retrieves the is-th stored X singlet. |
863 |
|
|
* @param it Singlet number, ranging from 0 to nclsx(). |
864 |
|
|
*/ |
865 |
|
|
TrkSinglet *TrkLevel2::GetSingletX(int is){ |
866 |
|
|
|
867 |
|
|
if(is >= this->nclsx()){ |
868 |
|
|
cout << "** TrkLevel2 ** Singlet "<< is << "doen not exits! " << endl; |
869 |
|
|
cout << " Stored x-singlets nclsx() = "<< this->nclsx() << endl; |
870 |
|
|
return 0; |
871 |
|
|
} |
872 |
|
|
TClonesArray &t = *(SingletX); |
873 |
|
|
TrkSinglet *singlet = (TrkSinglet*)t[is]; |
874 |
|
|
return singlet; |
875 |
|
|
} |
876 |
|
|
//-------------------------------------- |
877 |
|
|
// |
878 |
|
|
// |
879 |
|
|
//-------------------------------------- |
880 |
|
|
/** |
881 |
|
|
* Retrieves the is-th stored Y singlet. |
882 |
|
|
* @param it Singlet number, ranging from 0 to nclsx(). |
883 |
|
|
*/ |
884 |
|
|
TrkSinglet *TrkLevel2::GetSingletY(int is){ |
885 |
|
|
|
886 |
|
|
if(is >= this->nclsy()){ |
887 |
|
|
cout << "** TrkLevel2 ** Singlet "<< is << "doen not exits! " << endl; |
888 |
|
|
cout << " Stored y-singlets nclsy() = "<< this->nclsx() << endl; |
889 |
|
|
return 0; |
890 |
|
|
} |
891 |
|
|
TClonesArray &t = *(SingletY); |
892 |
|
|
TrkSinglet *singlet = (TrkSinglet*)t[is]; |
893 |
|
|
return singlet; |
894 |
|
|
} |
895 |
|
|
//-------------------------------------- |
896 |
|
|
// |
897 |
|
|
// |
898 |
|
|
//-------------------------------------- |
899 |
|
|
/** |
900 |
mocchiut |
1.1 |
* Retrieves the it-th "physical" track, sorted by the method GetNTracks(). |
901 |
|
|
* @param it Track number, ranging from 0 to GetNTracks(). |
902 |
|
|
*/ |
903 |
pam-fi |
1.10 |
|
904 |
pam-fi |
1.8 |
TrkTrack *TrkLevel2::GetTrack(int it){ |
905 |
|
|
|
906 |
|
|
if(it >= this->GetNTracks()){ |
907 |
|
|
cout << "** TrkLevel2 ** Track "<< it << "does not exits! " << endl; |
908 |
|
|
cout << " Physical tracks GetNTracks() = "<< this->ntrk() << endl; |
909 |
|
|
return 0; |
910 |
|
|
} |
911 |
|
|
|
912 |
|
|
TRefArray *sorted = GetTracks(); //TEMPORANEO |
913 |
|
|
TrkTrack *track = (TrkTrack*)sorted->At(it); |
914 |
|
|
sorted->Delete(); |
915 |
|
|
return track; |
916 |
mocchiut |
1.1 |
} |
917 |
pam-fi |
1.6 |
/** |
918 |
|
|
* Give the number of "physical" tracks, sorted by the method GetTracks(). |
919 |
|
|
*/ |
920 |
pam-fi |
1.5 |
Int_t TrkLevel2::GetNTracks(){ |
921 |
pam-fi |
1.8 |
|
922 |
|
|
Float_t ntot=0; |
923 |
|
|
TClonesArray &t = *Track; |
924 |
mocchiut |
1.12 |
for(int i=0; i<ntrk(); i++) { |
925 |
pam-fi |
1.8 |
if( ((TrkTrack *)t[i])->GetImageSeqNo() == -1 ) ntot+=1.; |
926 |
|
|
else ntot+=0.5; |
927 |
|
|
} |
928 |
|
|
return (Int_t)ntot; |
929 |
|
|
|
930 |
pam-fi |
1.5 |
}; |
931 |
mocchiut |
1.1 |
//-------------------------------------- |
932 |
|
|
// |
933 |
|
|
// |
934 |
|
|
//-------------------------------------- |
935 |
|
|
/** |
936 |
|
|
* Retrieves (if present) the image of the it-th "physical" track, sorted by the method GetNTracks(). |
937 |
|
|
* @param it Track number, ranging from 0 to GetNTracks(). |
938 |
|
|
*/ |
939 |
pam-fi |
1.8 |
TrkTrack *TrkLevel2::GetTrackImage(int it){ |
940 |
|
|
|
941 |
|
|
if(it >= this->GetNTracks()){ |
942 |
|
|
cout << "** TrkLevel2 ** Track "<< it << "does not exits! " << endl; |
943 |
|
|
cout << " Physical tracks GetNTracks() = "<< this->ntrk() << endl; |
944 |
|
|
return 0; |
945 |
|
|
} |
946 |
|
|
|
947 |
|
|
TRefArray* sorted = GetTracks(); //TEMPORANEO |
948 |
|
|
TrkTrack *track = (TrkTrack*)sorted->At(it); |
949 |
|
|
|
950 |
|
|
if(!track->HasImage()){ |
951 |
|
|
cout << "** TrkLevel2 ** Track "<< it << "does not have image! " << endl; |
952 |
|
|
return 0; |
953 |
|
|
} |
954 |
|
|
TrkTrack *image = (TrkTrack*)(*Track)[track->image]; |
955 |
|
|
|
956 |
|
|
sorted->Delete(); |
957 |
|
|
|
958 |
|
|
return image; |
959 |
|
|
|
960 |
mocchiut |
1.1 |
} |
961 |
|
|
//-------------------------------------- |
962 |
|
|
// |
963 |
|
|
// |
964 |
|
|
//-------------------------------------- |
965 |
|
|
/** |
966 |
|
|
* Loads the magnetic field. |
967 |
|
|
* @param s Path of the magnetic-field files. |
968 |
|
|
*/ |
969 |
pam-fi |
1.16 |
void TrkLevel2::LoadField(TString path){ |
970 |
|
|
// |
971 |
|
|
strcpy(path_.path,path.Data()); |
972 |
|
|
path_.pathlen = path.Length(); |
973 |
|
|
path_.error = 0; |
974 |
|
|
readb_(); |
975 |
|
|
// |
976 |
mocchiut |
1.1 |
}; |
977 |
|
|
//-------------------------------------- |
978 |
|
|
// |
979 |
|
|
// |
980 |
|
|
//-------------------------------------- |
981 |
|
|
/** |
982 |
pam-fi |
1.6 |
* Get tracker-plane (mechanical) z-coordinate |
983 |
|
|
* @param plane_id plane index (1=TOP,2,3,4,5,6=BOTTOM) |
984 |
|
|
*/ |
985 |
|
|
Float_t TrkLevel2::GetZTrk(Int_t plane_id){ |
986 |
|
|
switch(plane_id){ |
987 |
|
|
case 1: return ZTRK1; |
988 |
|
|
case 2: return ZTRK2; |
989 |
|
|
case 3: return ZTRK3; |
990 |
|
|
case 4: return ZTRK4; |
991 |
|
|
case 5: return ZTRK5; |
992 |
|
|
case 6: return ZTRK6; |
993 |
|
|
default: return 0.; |
994 |
|
|
}; |
995 |
|
|
}; |
996 |
|
|
//-------------------------------------- |
997 |
|
|
// |
998 |
|
|
// |
999 |
|
|
//-------------------------------------- |
1000 |
|
|
/** |
1001 |
pam-fi |
1.2 |
* Trajectory default constructor. |
1002 |
|
|
* (By default is created with z-coordinates inside the tracking volume) |
1003 |
|
|
*/ |
1004 |
|
|
Trajectory::Trajectory(){ |
1005 |
|
|
npoint = 10; |
1006 |
|
|
x = new float[npoint]; |
1007 |
|
|
y = new float[npoint]; |
1008 |
|
|
z = new float[npoint]; |
1009 |
|
|
thx = new float[npoint]; |
1010 |
|
|
thy = new float[npoint]; |
1011 |
|
|
tl = new float[npoint]; |
1012 |
pam-fi |
1.6 |
float dz = ((ZTRK1)-(ZTRK6))/(npoint-1); |
1013 |
pam-fi |
1.2 |
for(int i=0; i<npoint; i++){ |
1014 |
|
|
x[i] = 0; |
1015 |
|
|
y[i] = 0; |
1016 |
pam-fi |
1.6 |
z[i] = (ZTRK1) - i*dz; |
1017 |
pam-fi |
1.2 |
thx[i] = 0; |
1018 |
|
|
thy[i] = 0; |
1019 |
|
|
tl[i] = 0; |
1020 |
|
|
} |
1021 |
|
|
} |
1022 |
|
|
//-------------------------------------- |
1023 |
|
|
// |
1024 |
|
|
// |
1025 |
|
|
//-------------------------------------- |
1026 |
|
|
/** |
1027 |
mocchiut |
1.1 |
* Trajectory constructor. |
1028 |
pam-fi |
1.2 |
* (By default is created with z-coordinates inside the tracking volume) |
1029 |
mocchiut |
1.1 |
* \param n Number of points |
1030 |
|
|
*/ |
1031 |
|
|
Trajectory::Trajectory(int n){ |
1032 |
pam-fi |
1.2 |
if(n<=0){ |
1033 |
|
|
cout << "NB! Trajectory must have at least 1 point >>> created with 10 points" << endl; |
1034 |
|
|
n=10; |
1035 |
|
|
} |
1036 |
mocchiut |
1.1 |
npoint = n; |
1037 |
|
|
x = new float[npoint]; |
1038 |
|
|
y = new float[npoint]; |
1039 |
|
|
z = new float[npoint]; |
1040 |
pam-fi |
1.2 |
thx = new float[npoint]; |
1041 |
|
|
thy = new float[npoint]; |
1042 |
|
|
tl = new float[npoint]; |
1043 |
pam-fi |
1.6 |
float dz = ((ZTRK1)-(ZTRK6))/(npoint-1); |
1044 |
mocchiut |
1.1 |
for(int i=0; i<npoint; i++){ |
1045 |
pam-fi |
1.2 |
x[i] = 0; |
1046 |
mocchiut |
1.1 |
y[i] = 0; |
1047 |
pam-fi |
1.6 |
z[i] = (ZTRK1) - i*dz; |
1048 |
pam-fi |
1.2 |
thx[i] = 0; |
1049 |
|
|
thy[i] = 0; |
1050 |
|
|
tl[i] = 0; |
1051 |
mocchiut |
1.1 |
} |
1052 |
|
|
} |
1053 |
|
|
//-------------------------------------- |
1054 |
|
|
// |
1055 |
|
|
// |
1056 |
|
|
//-------------------------------------- |
1057 |
|
|
/** |
1058 |
|
|
* Trajectory constructor. |
1059 |
|
|
* \param n Number of points |
1060 |
|
|
* \param pz Pointer to float array, defining z coordinates |
1061 |
|
|
*/ |
1062 |
|
|
Trajectory::Trajectory(int n, float* zin){ |
1063 |
pam-fi |
1.2 |
npoint = 10; |
1064 |
|
|
if(n>0)npoint = n; |
1065 |
mocchiut |
1.1 |
x = new float[npoint]; |
1066 |
|
|
y = new float[npoint]; |
1067 |
|
|
z = new float[npoint]; |
1068 |
pam-fi |
1.2 |
thx = new float[npoint]; |
1069 |
|
|
thy = new float[npoint]; |
1070 |
|
|
tl = new float[npoint]; |
1071 |
|
|
int i=0; |
1072 |
|
|
do{ |
1073 |
pam-fi |
1.9 |
x[i] = 0; |
1074 |
|
|
y[i] = 0; |
1075 |
|
|
z[i] = zin[i]; |
1076 |
|
|
thx[i] = 0; |
1077 |
|
|
thy[i] = 0; |
1078 |
|
|
tl[i] = 0; |
1079 |
|
|
i++; |
1080 |
pam-fi |
1.2 |
}while(zin[i-1] > zin[i] && i < npoint); |
1081 |
|
|
npoint=i; |
1082 |
|
|
if(npoint != n)cout << "NB! Trajectory created with "<<npoint<<" points"<<endl; |
1083 |
mocchiut |
1.1 |
} |
1084 |
|
|
//-------------------------------------- |
1085 |
|
|
// |
1086 |
|
|
// |
1087 |
|
|
//-------------------------------------- |
1088 |
|
|
/** |
1089 |
|
|
* Dump the trajectory coordinates. |
1090 |
|
|
*/ |
1091 |
|
|
void Trajectory::Dump(){ |
1092 |
|
|
cout <<endl<< "Trajectory ========== "<<endl; |
1093 |
|
|
for (int i=0; i<npoint; i++){ |
1094 |
pam-fi |
1.2 |
cout << i <<" >> " << x[i] <<" "<< y[i] <<" "<< z[i] ; |
1095 |
|
|
cout <<" -- " << thx[i] <<" "<< thy[i] ; |
1096 |
|
|
cout <<" -- " << tl[i] << endl; |
1097 |
mocchiut |
1.1 |
}; |
1098 |
|
|
} |
1099 |
pam-fi |
1.2 |
//-------------------------------------- |
1100 |
|
|
// |
1101 |
|
|
// |
1102 |
|
|
//-------------------------------------- |
1103 |
|
|
/** |
1104 |
|
|
* Get trajectory length between two points |
1105 |
|
|
* @param ifirst first point (default 0) |
1106 |
|
|
* @param ilast last point (default npoint) |
1107 |
|
|
*/ |
1108 |
|
|
float Trajectory::GetLength(int ifirst, int ilast){ |
1109 |
|
|
if( ifirst<0 ) ifirst = 0; |
1110 |
|
|
if( ilast>=npoint) ilast = npoint-1; |
1111 |
|
|
float l=0; |
1112 |
|
|
for(int i=ifirst;i<=ilast;i++){ |
1113 |
|
|
l=l+tl[i]; |
1114 |
|
|
}; |
1115 |
|
|
if(z[ilast] > ZINI)l=l-tl[ilast]; |
1116 |
|
|
if(z[ifirst] < ZINI) l=l-tl[ifirst]; |
1117 |
|
|
|
1118 |
|
|
return l; |
1119 |
mocchiut |
1.1 |
|
1120 |
pam-fi |
1.2 |
} |
1121 |
pam-fi |
1.6 |
|
1122 |
pam-fi |
1.19 |
/** |
1123 |
|
|
* Evaluates the trajectory in the apparatus associated to the track. |
1124 |
|
|
* 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. |
1125 |
|
|
* @param t pointer to an object of the class Trajectory, |
1126 |
|
|
* which z coordinates should be previously initialized by calling the proper constructor ( Trajectory::Trajectory(int n, float* zin) ). |
1127 |
|
|
* @return error flag. |
1128 |
|
|
*/ |
1129 |
|
|
int Trajectory::DoTrack2(float* al){ |
1130 |
|
|
|
1131 |
|
|
double *dxout = new double[npoint]; |
1132 |
|
|
double *dyout = new double[npoint]; |
1133 |
|
|
double *dthxout = new double[npoint]; |
1134 |
|
|
double *dthyout = new double[npoint]; |
1135 |
|
|
double *dtlout = new double[npoint]; |
1136 |
|
|
double *dzin = new double[npoint]; |
1137 |
|
|
double dal[5]; |
1138 |
|
|
|
1139 |
|
|
int ifail = 0; |
1140 |
|
|
|
1141 |
|
|
for (int i=0; i<5; i++) dal[i] = (double)al[i]; |
1142 |
|
|
for (int i=0; i<npoint; i++) dzin[i] = (double)z[i]; |
1143 |
|
|
|
1144 |
|
|
dotrack2_(&(npoint),dzin,dxout,dyout,dthxout,dthyout,dtlout,dal,&ifail); |
1145 |
|
|
|
1146 |
|
|
for (int i=0; i<npoint; i++){ |
1147 |
|
|
x[i] = (float)*dxout++; |
1148 |
|
|
y[i] = (float)*dyout++; |
1149 |
|
|
thx[i] = (float)*dthxout++; |
1150 |
|
|
thy[i] = (float)*dthyout++; |
1151 |
|
|
tl[i] = (float)*dtlout++; |
1152 |
|
|
} |
1153 |
|
|
|
1154 |
|
|
return ifail; |
1155 |
|
|
}; |
1156 |
pam-fi |
1.10 |
|
1157 |
mocchiut |
1.1 |
ClassImp(TrkLevel2); |
1158 |
|
|
ClassImp(TrkSinglet); |
1159 |
|
|
ClassImp(TrkTrack); |
1160 |
|
|
ClassImp(Trajectory); |