1 |
mocchiut |
1.1 |
/** |
2 |
|
|
* \file TrkLevel2.cpp |
3 |
|
|
* \author Elena Vannuccini |
4 |
|
|
*/ |
5 |
|
|
#include <TrkLevel2.h> |
6 |
|
|
#include <iostream> |
7 |
|
|
using namespace std; |
8 |
|
|
//...................................... |
9 |
|
|
// F77 routines |
10 |
|
|
//...................................... |
11 |
|
|
extern "C" { |
12 |
|
|
void dotrack_(int*, double*, double*, double*, double*, int*); |
13 |
pam-fi |
1.2 |
void dotrack2_(int*, double*, double*, double*, double*,double*, double*, double*,int*); |
14 |
mocchiut |
1.1 |
int readb_(const char*); |
15 |
|
|
} |
16 |
|
|
//-------------------------------------- |
17 |
|
|
// |
18 |
|
|
// |
19 |
|
|
//-------------------------------------- |
20 |
|
|
TrkTrack::TrkTrack(){ |
21 |
pam-fi |
1.3 |
seqno = -1; |
22 |
|
|
image = -1; |
23 |
mocchiut |
1.1 |
chi2 = 0; |
24 |
|
|
for(int it1=0;it1<5;it1++){ |
25 |
|
|
al[it1] = 0; |
26 |
|
|
for(int it2=0;it2<5;it2++) |
27 |
|
|
coval[it1][it2] = 0; |
28 |
|
|
}; |
29 |
|
|
for(int ip=0;ip<6;ip++){ |
30 |
|
|
xgood[ip] = 0; |
31 |
|
|
ygood[ip] = 0; |
32 |
|
|
xm[ip] = 0; |
33 |
|
|
ym[ip] = 0; |
34 |
|
|
zm[ip] = 0; |
35 |
|
|
resx[ip] = 0; |
36 |
|
|
resy[ip] = 0; |
37 |
|
|
xv[ip] = 0; |
38 |
|
|
yv[ip] = 0; |
39 |
|
|
zv[ip] = 0; |
40 |
|
|
axv[ip] = 0; |
41 |
|
|
ayv[ip] = 0; |
42 |
|
|
dedx_x[ip] = 0; |
43 |
|
|
dedx_y[ip] = 0; |
44 |
|
|
}; |
45 |
|
|
}; |
46 |
|
|
//-------------------------------------- |
47 |
|
|
// |
48 |
|
|
// |
49 |
|
|
//-------------------------------------- |
50 |
|
|
TrkTrack::TrkTrack(const TrkTrack& t){ |
51 |
pam-fi |
1.3 |
seqno = t.seqno; |
52 |
mocchiut |
1.1 |
image = t.image; |
53 |
|
|
chi2 = t.chi2; |
54 |
|
|
for(int it1=0;it1<5;it1++){ |
55 |
|
|
al[it1] = t.al[it1]; |
56 |
|
|
for(int it2=0;it2<5;it2++) |
57 |
|
|
coval[it1][it2] = t.coval[it1][it2]; |
58 |
|
|
}; |
59 |
|
|
for(int ip=0;ip<6;ip++){ |
60 |
|
|
xgood[ip] = t.xgood[ip]; |
61 |
|
|
ygood[ip] = t.ygood[ip]; |
62 |
|
|
xm[ip] = t.xm[ip]; |
63 |
|
|
ym[ip] = t.ym[ip]; |
64 |
|
|
zm[ip] = t.zm[ip]; |
65 |
|
|
resx[ip] = t.resx[ip]; |
66 |
|
|
resy[ip] = t.resy[ip]; |
67 |
|
|
xv[ip] = t.xv[ip]; |
68 |
|
|
yv[ip] = t.yv[ip]; |
69 |
|
|
zv[ip] = t.zv[ip]; |
70 |
|
|
axv[ip] = t.axv[ip]; |
71 |
|
|
ayv[ip] = t.ayv[ip]; |
72 |
|
|
dedx_x[ip] = t.dedx_x[ip]; |
73 |
|
|
dedx_y[ip] = t.dedx_y[ip]; |
74 |
|
|
}; |
75 |
|
|
}; |
76 |
|
|
//-------------------------------------- |
77 |
|
|
// |
78 |
|
|
// |
79 |
|
|
//-------------------------------------- |
80 |
|
|
/** |
81 |
|
|
* Evaluates the trajectory in the apparatus associated to the track. |
82 |
|
|
* 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. |
83 |
|
|
* @param t pointer to an object of the class Trajectory, |
84 |
|
|
* which z coordinates should be previously initialized by calling the proper constructor ( Trajectory::Trajectory(int n, float* zin) ). |
85 |
|
|
* @return error flag. |
86 |
|
|
*/ |
87 |
|
|
int TrkTrack::DoTrack(Trajectory* t){ |
88 |
|
|
|
89 |
|
|
double *dxout = new double[t->npoint]; |
90 |
|
|
double *dyout = new double[t->npoint]; |
91 |
|
|
double *dzin = new double[t->npoint]; |
92 |
|
|
double dal[5]; |
93 |
|
|
|
94 |
|
|
int ifail = 0; |
95 |
|
|
|
96 |
|
|
for (int i=0; i<5; i++) dal[i] = (double)al[i]; |
97 |
|
|
for (int i=0; i<t->npoint; i++) dzin[i] = (double)t->z[i]; |
98 |
|
|
|
99 |
|
|
dotrack_(&(t->npoint),dzin,dxout,dyout,dal,&ifail); |
100 |
|
|
|
101 |
|
|
for (int i=0; i<t->npoint; i++){ |
102 |
|
|
t->x[i] = (float)*dxout++; |
103 |
|
|
t->y[i] = (float)*dyout++; |
104 |
|
|
} |
105 |
|
|
|
106 |
|
|
// delete [] dxout; |
107 |
|
|
// delete [] dyout; |
108 |
|
|
// delete [] dzin; |
109 |
|
|
|
110 |
|
|
return ifail; |
111 |
|
|
}; |
112 |
|
|
//-------------------------------------- |
113 |
|
|
// |
114 |
|
|
// |
115 |
|
|
//-------------------------------------- |
116 |
pam-fi |
1.2 |
/** |
117 |
|
|
* Evaluates the trajectory in the apparatus associated to the track. |
118 |
|
|
* 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. |
119 |
|
|
* @param t pointer to an object of the class Trajectory, |
120 |
|
|
* which z coordinates should be previously initialized by calling the proper constructor ( Trajectory::Trajectory(int n, float* zin) ). |
121 |
|
|
* @return error flag. |
122 |
|
|
*/ |
123 |
|
|
int TrkTrack::DoTrack2(Trajectory* t){ |
124 |
|
|
|
125 |
|
|
double *dxout = new double[t->npoint]; |
126 |
|
|
double *dyout = new double[t->npoint]; |
127 |
|
|
double *dthxout = new double[t->npoint]; |
128 |
|
|
double *dthyout = new double[t->npoint]; |
129 |
|
|
double *dtlout = new double[t->npoint]; |
130 |
|
|
double *dzin = new double[t->npoint]; |
131 |
|
|
double dal[5]; |
132 |
|
|
|
133 |
|
|
int ifail = 0; |
134 |
|
|
|
135 |
|
|
for (int i=0; i<5; i++) dal[i] = (double)al[i]; |
136 |
|
|
for (int i=0; i<t->npoint; i++) dzin[i] = (double)t->z[i]; |
137 |
|
|
|
138 |
|
|
dotrack2_(&(t->npoint),dzin,dxout,dyout,dthxout,dthyout,dtlout,dal,&ifail); |
139 |
|
|
|
140 |
|
|
for (int i=0; i<t->npoint; i++){ |
141 |
|
|
t->x[i] = (float)*dxout++; |
142 |
|
|
t->y[i] = (float)*dyout++; |
143 |
|
|
t->thx[i] = (float)*dthxout++; |
144 |
|
|
t->thy[i] = (float)*dthyout++; |
145 |
|
|
t->tl[i] = (float)*dtlout++; |
146 |
|
|
} |
147 |
|
|
|
148 |
|
|
// delete [] dxout; |
149 |
|
|
// delete [] dyout; |
150 |
|
|
// delete [] dzin; |
151 |
|
|
|
152 |
|
|
return ifail; |
153 |
|
|
}; |
154 |
|
|
//-------------------------------------- |
155 |
|
|
// |
156 |
|
|
// |
157 |
|
|
//-------------------------------------- |
158 |
mocchiut |
1.1 |
//float TrkTrack::BdL(){ |
159 |
|
|
//}; |
160 |
|
|
//-------------------------------------- |
161 |
|
|
// |
162 |
|
|
// |
163 |
|
|
//-------------------------------------- |
164 |
|
|
Float_t TrkTrack::GetRigidity(){ |
165 |
|
|
Float_t rig=0; |
166 |
|
|
if(chi2>0)rig=1./al[4]; |
167 |
|
|
if(rig<0) rig=-rig; |
168 |
|
|
return rig; |
169 |
|
|
}; |
170 |
|
|
// |
171 |
|
|
Float_t TrkTrack::GetDeflection(){ |
172 |
|
|
Float_t def=0; |
173 |
|
|
if(chi2>0)def=al[4]; |
174 |
|
|
return def; |
175 |
|
|
}; |
176 |
|
|
// |
177 |
|
|
Float_t TrkTrack::GetDEDX(){ |
178 |
|
|
Float_t dedx=0; |
179 |
|
|
for(Int_t i=0; i<6; i++)dedx+=dedx_x[i]*xgood[i]+dedx_y[i]*ygood[i]; |
180 |
|
|
dedx = dedx/(this->GetNX()+this->GetNY()); |
181 |
|
|
return dedx; |
182 |
|
|
}; |
183 |
|
|
|
184 |
|
|
//-------------------------------------- |
185 |
|
|
// |
186 |
|
|
// |
187 |
|
|
//-------------------------------------- |
188 |
|
|
void TrkTrack::Dump(){ |
189 |
|
|
cout << endl << "========== Track " ; |
190 |
|
|
cout << endl << "al : "; for(int i=0; i<5; i++)cout << al[i] << " "; |
191 |
|
|
cout << endl << "chi^2 : "<< chi2; |
192 |
|
|
cout << endl << "xgood : "; for(int i=0; i<6; i++)cout << xgood[i] ; |
193 |
|
|
cout << endl << "ygood : "; for(int i=0; i<6; i++)cout << ygood[i] ; |
194 |
|
|
cout << endl << "xm : "; for(int i=0; i<6; i++)cout << xm[i] << " "; |
195 |
|
|
cout << endl << "ym : "; for(int i=0; i<6; i++)cout << ym[i] << " "; |
196 |
|
|
cout << endl << "zm : "; for(int i=0; i<6; i++)cout << zm[i] << " "; |
197 |
|
|
cout << endl << "dedx_x : "; for(int i=0; i<6; i++)cout << dedx_x[i] << " "; |
198 |
|
|
cout << endl << "dedx_y : "; for(int i=0; i<6; i++)cout << dedx_y[i] << " "; |
199 |
|
|
} |
200 |
|
|
//-------------------------------------- |
201 |
|
|
// |
202 |
|
|
// |
203 |
|
|
//-------------------------------------- |
204 |
|
|
TrkSinglet::TrkSinglet(){ |
205 |
|
|
plane = 0; |
206 |
|
|
coord[0] = 0; |
207 |
|
|
coord[1] = 0; |
208 |
|
|
sgnl = 0; |
209 |
|
|
}; |
210 |
|
|
//-------------------------------------- |
211 |
|
|
// |
212 |
|
|
// |
213 |
|
|
//-------------------------------------- |
214 |
|
|
TrkSinglet::TrkSinglet(const TrkSinglet& s){ |
215 |
|
|
plane = s.plane; |
216 |
|
|
coord[0] = s.coord[0]; |
217 |
|
|
coord[1] = s.coord[1]; |
218 |
|
|
sgnl = s.sgnl; |
219 |
|
|
}; |
220 |
|
|
//-------------------------------------- |
221 |
|
|
// |
222 |
|
|
// |
223 |
|
|
//-------------------------------------- |
224 |
|
|
void TrkSinglet::Dump(){ |
225 |
|
|
int i=0; |
226 |
|
|
cout << endl << "========== Singlet " ; |
227 |
|
|
cout << endl << "plane : " << plane; |
228 |
|
|
cout << endl << "coord[2] : "; while( i<2 && cout << coord[i] << " ") i++; |
229 |
|
|
cout << endl << "sgnl : " << sgnl; |
230 |
|
|
} |
231 |
|
|
//-------------------------------------- |
232 |
|
|
// |
233 |
|
|
// |
234 |
|
|
//-------------------------------------- |
235 |
|
|
TrkLevel2::TrkLevel2(){ |
236 |
|
|
good2 = -1; |
237 |
|
|
for(Int_t i=0; i<12 ; i++){ |
238 |
|
|
crc[i] = -1; |
239 |
|
|
}; |
240 |
|
|
Track = new TClonesArray("TrkTrack"); |
241 |
|
|
SingletX = new TClonesArray("TrkSinglet"); |
242 |
|
|
SingletY = new TClonesArray("TrkSinglet"); |
243 |
pam-fi |
1.6 |
|
244 |
|
|
// PhysicalTrack = new TClonesArray("TrkTrack"); |
245 |
|
|
//sostituire con TRefArray... appena ho capito come si usa |
246 |
mocchiut |
1.1 |
} |
247 |
|
|
//-------------------------------------- |
248 |
|
|
// |
249 |
|
|
// |
250 |
|
|
//-------------------------------------- |
251 |
|
|
void TrkLevel2::Dump(){ |
252 |
|
|
TClonesArray &t = *Track; |
253 |
|
|
TClonesArray &sx = *SingletX; |
254 |
|
|
TClonesArray &sy = *SingletY; |
255 |
|
|
|
256 |
|
|
cout << endl << endl << "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"; |
257 |
|
|
cout << endl << "good2 : " << good2; |
258 |
|
|
cout << endl << "crc : "; for(int i=0; i<12; i++) cout << crc[i]; |
259 |
|
|
cout << endl << "ntrk() : " << this->ntrk() ; |
260 |
|
|
cout << endl << "nclsx() : " << this->nclsx(); |
261 |
|
|
cout << endl << "nclsy() : " << this->nclsy(); |
262 |
|
|
for(int i=0; i<this->ntrk(); i++) ((TrkTrack *)t[i])->Dump(); |
263 |
|
|
for(int i=0; i<this->nclsx(); i++) ((TrkSinglet *)sx[i])->Dump(); |
264 |
|
|
for(int i=0; i<this->nclsy(); i++) ((TrkSinglet *)sy[i])->Dump(); |
265 |
|
|
} |
266 |
|
|
//-------------------------------------- |
267 |
|
|
// |
268 |
|
|
// |
269 |
|
|
//-------------------------------------- |
270 |
|
|
/** |
271 |
|
|
* Fills a TrkLevel2 object with values from a struct cTrkLevel2 (to get data from F77 common). |
272 |
|
|
*/ |
273 |
pam-fi |
1.7 |
void TrkLevel2::SetFromLevel2Struct(cTrkLevel2 *l2){ |
274 |
pam-fi |
1.3 |
// |
275 |
|
|
// Track = new TClonesArray("TrkTrack"); |
276 |
|
|
// SingletX = new TClonesArray("TrkSinglet"); |
277 |
|
|
// SingletY = new TClonesArray("TrkSinglet"); |
278 |
mocchiut |
1.1 |
// temporary objects: |
279 |
|
|
TrkSinglet* t_singlet = new TrkSinglet(); |
280 |
|
|
TrkTrack* t_track = new TrkTrack(); |
281 |
|
|
// general variables |
282 |
|
|
good2 = l2->good2; |
283 |
|
|
for(Int_t i=0; i<12 ; i++){ |
284 |
|
|
crc[i] = l2->crc[i]; |
285 |
|
|
}; |
286 |
|
|
// *** TRACKS *** |
287 |
|
|
TClonesArray &t = *Track; |
288 |
|
|
for(int i=0; i<l2->ntrk; i++){ |
289 |
pam-fi |
1.3 |
t_track->seqno = i; |
290 |
mocchiut |
1.1 |
t_track->image = l2->image[i]-1; |
291 |
pam-fi |
1.3 |
// cout << "track "<<i<<t_track->seqno << t_track->image<<endl; |
292 |
mocchiut |
1.1 |
t_track->chi2 = l2->chi2_nt[i]; |
293 |
|
|
for(int it1=0;it1<5;it1++){ |
294 |
|
|
t_track->al[it1] = l2->al_nt[i][it1]; |
295 |
|
|
for(int it2=0;it2<5;it2++) |
296 |
|
|
t_track->coval[it1][it2] = l2->coval[i][it2][it1]; |
297 |
|
|
}; |
298 |
|
|
for(int ip=0;ip<6;ip++){ |
299 |
|
|
t_track->xgood[ip] = l2->xgood_nt[i][ip]; |
300 |
|
|
t_track->ygood[ip] = l2->ygood_nt[i][ip]; |
301 |
|
|
t_track->xm[ip] = l2->xm_nt[i][ip]; |
302 |
|
|
t_track->ym[ip] = l2->ym_nt[i][ip]; |
303 |
|
|
t_track->zm[ip] = l2->zm_nt[i][ip]; |
304 |
|
|
t_track->resx[ip] = l2->resx_nt[i][ip]; |
305 |
|
|
t_track->resy[ip] = l2->resy_nt[i][ip]; |
306 |
|
|
t_track->xv[ip] = l2->xv_nt[i][ip]; |
307 |
|
|
t_track->yv[ip] = l2->yv_nt[i][ip]; |
308 |
|
|
t_track->zv[ip] = l2->zv_nt[i][ip]; |
309 |
|
|
t_track->axv[ip] = l2->axv_nt[i][ip]; |
310 |
|
|
t_track->ayv[ip] = l2->ayv_nt[i][ip]; |
311 |
|
|
t_track->dedx_x[ip] = l2->dedx_x[i][ip]; |
312 |
|
|
t_track->dedx_y[ip] = l2->dedx_y[i][ip]; |
313 |
|
|
}; |
314 |
|
|
new(t[i]) TrkTrack(*t_track); |
315 |
|
|
t_track->Clear(); |
316 |
|
|
}; |
317 |
|
|
// *** SINGLETS *** |
318 |
|
|
TClonesArray &sx = *SingletX; |
319 |
|
|
for(int i=0; i<l2->nclsx; i++){ |
320 |
|
|
t_singlet->plane = l2->planex[i]; |
321 |
|
|
t_singlet->coord[0] = l2->xs[i][0]; |
322 |
|
|
t_singlet->coord[1] = l2->xs[i][1]; |
323 |
|
|
t_singlet->sgnl = l2->signlxs[i]; |
324 |
|
|
new(sx[i]) TrkSinglet(*t_singlet); |
325 |
|
|
t_singlet->Clear(); |
326 |
|
|
} |
327 |
|
|
TClonesArray &sy = *SingletY; |
328 |
|
|
for(int i=0; i<l2->nclsy; i++){ |
329 |
|
|
t_singlet->plane = l2->planey[i]; |
330 |
|
|
t_singlet->coord[0] = l2->ys[i][0]; |
331 |
|
|
t_singlet->coord[1] = l2->ys[i][1]; |
332 |
|
|
t_singlet->sgnl = l2->signlys[i]; |
333 |
|
|
new(sy[i]) TrkSinglet(*t_singlet); |
334 |
|
|
t_singlet->Clear(); |
335 |
|
|
}; |
336 |
pam-fi |
1.5 |
|
337 |
|
|
delete t_track; |
338 |
|
|
delete t_singlet; |
339 |
mocchiut |
1.1 |
} |
340 |
pam-fi |
1.7 |
/** |
341 |
|
|
* Fills a struct cTrkLevel2 with values from a TrkLevel2 object (to put data into a F77 common). |
342 |
|
|
*/ |
343 |
|
|
|
344 |
|
|
void TrkLevel2::GetLevel2Struct(cTrkLevel2 *l2) const { |
345 |
|
|
|
346 |
|
|
// general variables |
347 |
|
|
l2->good2 = good2 ; |
348 |
|
|
for(Int_t i=0; i<12 ; i++){ |
349 |
|
|
l2->crc[i] = crc[i]; |
350 |
|
|
}; |
351 |
|
|
// *** TRACKS *** |
352 |
|
|
|
353 |
|
|
l2->ntrk = Track->GetEntries(); |
354 |
|
|
for(Int_t i=0;i<l2->ntrk;i++){ |
355 |
|
|
l2->image[i] = 1 + ((TrkTrack *)Track->At(i))->image; |
356 |
|
|
l2->chi2_nt[i] = ((TrkTrack *)Track->At(i))->chi2; |
357 |
|
|
for(int it1=0;it1<5;it1++){ |
358 |
|
|
l2->al_nt[i][it1] = ((TrkTrack *)Track->At(i))->al[it1]; |
359 |
|
|
for(int it2=0;it2<5;it2++) |
360 |
|
|
l2->coval[i][it2][it1] = ((TrkTrack *)Track->At(i))->coval[it1][it2]; |
361 |
|
|
}; |
362 |
|
|
for(int ip=0;ip<6;ip++){ |
363 |
|
|
l2->xgood_nt[i][ip] = ((TrkTrack *)Track->At(i))->xgood[ip]; |
364 |
|
|
l2->ygood_nt[i][ip] = ((TrkTrack *)Track->At(i))->ygood[ip]; |
365 |
|
|
l2->xm_nt[i][ip] = ((TrkTrack *)Track->At(i))->xm[ip]; |
366 |
|
|
l2->ym_nt[i][ip] = ((TrkTrack *)Track->At(i))->ym[ip]; |
367 |
|
|
l2->zm_nt[i][ip] = ((TrkTrack *)Track->At(i))->zm[ip]; |
368 |
|
|
l2->resx_nt[i][ip] = ((TrkTrack *)Track->At(i))->resx[ip]; |
369 |
|
|
l2->resy_nt[i][ip] = ((TrkTrack *)Track->At(i))->resy[ip]; |
370 |
|
|
l2->xv_nt[i][ip] = ((TrkTrack *)Track->At(i))->xv[ip]; |
371 |
|
|
l2->yv_nt[i][ip] = ((TrkTrack *)Track->At(i))->yv[ip]; |
372 |
|
|
l2->zv_nt[i][ip] = ((TrkTrack *)Track->At(i))->zv[ip]; |
373 |
|
|
l2->axv_nt[i][ip] = ((TrkTrack *)Track->At(i))->axv[ip]; |
374 |
|
|
l2->ayv_nt[i][ip] = ((TrkTrack *)Track->At(i))->ayv[ip]; |
375 |
|
|
l2->dedx_x[i][ip] = ((TrkTrack *)Track->At(i))->dedx_x[ip]; |
376 |
|
|
l2->dedx_y[i][ip] = ((TrkTrack *)Track->At(i))->dedx_y[ip]; |
377 |
|
|
}; |
378 |
|
|
} |
379 |
|
|
|
380 |
|
|
// *** SINGLETS *** |
381 |
|
|
l2->nclsx = SingletX->GetEntries(); |
382 |
|
|
for(Int_t i=0;i<l2->nclsx;i++){ |
383 |
|
|
l2->planex[i] = ((TrkSinglet *)SingletX->At(i))->plane; |
384 |
|
|
l2->xs[i][0] = ((TrkSinglet *)SingletX->At(i))->coord[0]; |
385 |
|
|
l2->xs[i][1] = ((TrkSinglet *)SingletX->At(i))->coord[1]; |
386 |
|
|
l2->signlxs[i] = ((TrkSinglet *)SingletX->At(i))->sgnl; |
387 |
|
|
} |
388 |
|
|
l2->nclsy = SingletY->GetEntries(); |
389 |
|
|
for(Int_t i=0;i<l2->nclsy;i++){ |
390 |
|
|
l2->planey[i] = ((TrkSinglet *)SingletY->At(i))->plane; |
391 |
|
|
l2->ys[i][0] = ((TrkSinglet *)SingletY->At(i))->coord[0]; |
392 |
|
|
l2->ys[i][1] = ((TrkSinglet *)SingletY->At(i))->coord[1]; |
393 |
|
|
l2->signlys[i] = ((TrkSinglet *)SingletY->At(i))->sgnl; |
394 |
|
|
} |
395 |
|
|
} |
396 |
mocchiut |
1.1 |
//-------------------------------------- |
397 |
|
|
// |
398 |
|
|
// |
399 |
|
|
//-------------------------------------- |
400 |
|
|
void TrkLevel2::Clear(){ |
401 |
|
|
good2 = -1; |
402 |
|
|
for(Int_t i=0; i<12 ; i++){ |
403 |
|
|
crc[i] = -1; |
404 |
|
|
}; |
405 |
pam-fi |
1.5 |
/* Track->RemoveAll(); |
406 |
mocchiut |
1.1 |
SingletX->RemoveAll(); |
407 |
pam-fi |
1.5 |
SingletY->RemoveAll();*/ |
408 |
|
|
// modify to avoid memory leakage |
409 |
|
|
Track->Clear(); |
410 |
|
|
SingletX->Clear(); |
411 |
|
|
SingletY->Clear(); |
412 |
mocchiut |
1.1 |
} |
413 |
|
|
//-------------------------------------- |
414 |
|
|
// |
415 |
|
|
// |
416 |
|
|
//-------------------------------------- |
417 |
|
|
/** |
418 |
|
|
* 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). |
419 |
|
|
* This method is overridden by PamLevel2::GetTracks(), where calorimeter and TOF information is used. |
420 |
|
|
*/ |
421 |
pam-fi |
1.8 |
// TClonesArray *TrkLevel2::GetTracks(){ |
422 |
|
|
// TClonesArray *sorted = GetTracks_NFitSorted(); |
423 |
|
|
// return sorted; |
424 |
|
|
// }; |
425 |
mocchiut |
1.4 |
|
426 |
pam-fi |
1.6 |
/*TClonesArray *TrkLevel2::GetTracks_Chi2Sorted(){ |
427 |
mocchiut |
1.1 |
|
428 |
|
|
TClonesArray *sorted = new TClonesArray("TrkTrack"); |
429 |
|
|
TClonesArray &t = *Track; |
430 |
|
|
TClonesArray &ts = *sorted; |
431 |
|
|
int N=this->ntrk(); |
432 |
|
|
vector<int> m(N); for(int i=0; i<N; i++)m[i]=1; |
433 |
|
|
|
434 |
|
|
int indo=0; |
435 |
|
|
int indi=0; |
436 |
|
|
while(N != 0){ |
437 |
|
|
float chi2ref=1000000; |
438 |
|
|
for(int i=0; i<this->ntrk(); i++){ |
439 |
|
|
if(((TrkTrack *)t[i])->chi2 < chi2ref && m[i]==1){ |
440 |
|
|
chi2ref = ((TrkTrack *)t[i])->chi2; |
441 |
|
|
indi = i; |
442 |
|
|
} |
443 |
|
|
} |
444 |
|
|
if( ((TrkTrack *)t[indi])->image != -1 ){ |
445 |
|
|
m[((TrkTrack *)t[indi])->image] = 0; |
446 |
|
|
N--; |
447 |
|
|
} |
448 |
|
|
new(ts[indo]) TrkTrack(*(TrkTrack*)t[indi]); |
449 |
|
|
m[indi] = 0; |
450 |
|
|
N--; |
451 |
|
|
indo++; |
452 |
|
|
} |
453 |
|
|
return sorted; |
454 |
pam-fi |
1.6 |
}*/ |
455 |
pam-fi |
1.8 |
/*TClonesArray *TrkLevel2::GetTracks_NFitSorted(){ |
456 |
pam-fi |
1.3 |
|
457 |
pam-fi |
1.6 |
TClonesArray *sorted = new TClonesArray("TrkTrack"); |
458 |
pam-fi |
1.8 |
TClonesArray &t = *Track; |
459 |
pam-fi |
1.6 |
TClonesArray &ts = *sorted; |
460 |
|
|
// TClonesArray &ts = *PhysicalTrack; |
461 |
pam-fi |
1.8 |
int N = ntrk(); |
462 |
pam-fi |
1.3 |
vector<int> m(N); for(int i=0; i<N; i++)m[i]=1; |
463 |
pam-fi |
1.8 |
// int m[50]; for(int i=0; i<N; i++)m[i]=1; |
464 |
|
|
|
465 |
pam-fi |
1.3 |
int indo=0; |
466 |
|
|
int indi=0; |
467 |
|
|
while(N != 0){ |
468 |
pam-fi |
1.8 |
int nfit =0; |
469 |
|
|
float chi2ref = numeric_limits<float>::max(); |
470 |
|
|
// first loop to search maximum num. of fit points |
471 |
|
|
for(int i=0; i < ntrk(); i++){ |
472 |
|
|
// if(N==ntrk())cout << "** "<<i<< " " << ((TrkTrack *)t[i])->GetImageSeqNo()<< " " <<((TrkTrack *)t[i])->GetNtot() << " " <<((TrkTrack *)t[i])->chi2 << endl; |
473 |
|
|
if( ((TrkTrack *)t[i])->GetNtot() >= nfit && m[i]==1){ |
474 |
|
|
nfit = ((TrkTrack *)t[i])->GetNtot(); |
475 |
|
|
} |
476 |
|
|
} |
477 |
|
|
//second loop to search minimum chi2 among selected |
478 |
|
|
for(int i=0; i<this->ntrk(); i++){ |
479 |
|
|
if( ((TrkTrack *)t[i])->chi2 < chi2ref |
480 |
|
|
&& ((TrkTrack *)t[i])->GetNtot()== nfit |
481 |
|
|
&& m[i]==1){ |
482 |
|
|
chi2ref = ((TrkTrack *)t[i])->chi2; |
483 |
|
|
indi = i; |
484 |
|
|
// cout << "2** "<<i<< " " << nfit <<" "<<chi2ref<<endl; |
485 |
|
|
} |
486 |
|
|
} |
487 |
|
|
if( ((TrkTrack *)t[indi])->HasImage() ){ |
488 |
|
|
m[((TrkTrack *)t[indi])->image] = 0; |
489 |
|
|
N--; |
490 |
|
|
|
491 |
|
|
// Int_t nfiti=((TrkTrack *)t[((TrkTrack *)t[indi])->image ])->GetNtot(); |
492 |
|
|
// Float_t chi2i=((TrkTrack *)t[((TrkTrack *)t[indi])->image ])->chi2; |
493 |
|
|
|
494 |
|
|
// cout << "i** "<< ((TrkTrack *)t[indi])->image << " " << nfiti <<" "<<chi2i<<endl; |
495 |
|
|
} |
496 |
|
|
new(ts[indo]) TrkTrack(*(TrkTrack*)t[indi]); |
497 |
|
|
m[indi] = 0; |
498 |
|
|
// cout << "SORTED "<< indo << " "<< indi << " "<< N << endl; |
499 |
|
|
N--; |
500 |
|
|
indo++; |
501 |
|
|
} |
502 |
|
|
m.clear(); |
503 |
|
|
return sorted; |
504 |
|
|
// return PhysicalTrack; |
505 |
|
|
}*/ |
506 |
|
|
//TClonesArray *TrkLevel2::GetTracks_NFitSorted(){ |
507 |
|
|
TRefArray *TrkLevel2::GetTracks_NFitSorted(){ |
508 |
pam-fi |
1.3 |
|
509 |
pam-fi |
1.8 |
// cout << "GetTracks_NFitSorted(it): new TRefArray()"<< endl; |
510 |
|
|
// TClonesArray *sorted = new TClonesArray("TrkTrack"); |
511 |
|
|
// TClonesArray &ts = *sorted; |
512 |
|
|
TRefArray *sorted = new TRefArray(); |
513 |
|
|
|
514 |
|
|
TClonesArray &t = *Track; |
515 |
|
|
// TClonesArray &ts = *PhysicalTrack; |
516 |
|
|
int N = ntrk(); |
517 |
|
|
vector<int> m(N); for(int i=0; i<N; i++)m[i]=1; |
518 |
|
|
// int m[50]; for(int i=0; i<N; i++)m[i]=1; |
519 |
|
|
|
520 |
|
|
int indo=0; |
521 |
|
|
int indi=0; |
522 |
|
|
while(N != 0){ |
523 |
|
|
int nfit =0; |
524 |
|
|
float chi2ref = numeric_limits<float>::max(); |
525 |
|
|
// first loop to search maximum num. of fit points |
526 |
|
|
for(int i=0; i < ntrk(); i++){ |
527 |
|
|
// if(N==ntrk())cout << "** "<<i<< " " << ((TrkTrack *)t[i])->GetImageSeqNo()<< " " <<((TrkTrack *)t[i])->GetNtot() << " " <<((TrkTrack *)t[i])->chi2 << endl; |
528 |
|
|
if( ((TrkTrack *)t[i])->GetNtot() >= nfit && m[i]==1){ |
529 |
|
|
nfit = ((TrkTrack *)t[i])->GetNtot(); |
530 |
|
|
} |
531 |
|
|
} |
532 |
|
|
//second loop to search minimum chi2 among selected |
533 |
|
|
for(int i=0; i<this->ntrk(); i++){ |
534 |
|
|
if( ((TrkTrack *)t[i])->chi2 < chi2ref |
535 |
|
|
&& ((TrkTrack *)t[i])->GetNtot()== nfit |
536 |
|
|
&& m[i]==1){ |
537 |
|
|
chi2ref = ((TrkTrack *)t[i])->chi2; |
538 |
|
|
indi = i; |
539 |
|
|
// cout << "2** "<<i<< " " << nfit <<" "<<chi2ref<<endl; |
540 |
|
|
} |
541 |
|
|
} |
542 |
|
|
if( ((TrkTrack *)t[indi])->HasImage() ){ |
543 |
|
|
m[((TrkTrack *)t[indi])->image] = 0; |
544 |
|
|
N--; |
545 |
|
|
|
546 |
|
|
// Int_t nfiti=((TrkTrack *)t[((TrkTrack *)t[indi])->image ])->GetNtot(); |
547 |
|
|
// Float_t chi2i=((TrkTrack *)t[((TrkTrack *)t[indi])->image ])->chi2; |
548 |
|
|
|
549 |
|
|
// cout << "i** "<< ((TrkTrack *)t[indi])->image << " " << nfiti <<" "<<chi2i<<endl; |
550 |
|
|
} |
551 |
|
|
// new(ts[indo]) TrkTrack(*(TrkTrack*)t[indi]); |
552 |
|
|
// cout << "GetTracks_NFitSorted(it): Add("<<indo<<")"<< endl; |
553 |
|
|
sorted->Add( (TrkTrack*)t[indi] ); |
554 |
pam-fi |
1.3 |
|
555 |
pam-fi |
1.8 |
m[indi] = 0; |
556 |
|
|
// cout << "SORTED "<< indo << " "<< indi << " "<< N << endl; |
557 |
|
|
N--; |
558 |
|
|
indo++; |
559 |
pam-fi |
1.3 |
} |
560 |
pam-fi |
1.8 |
m.clear(); |
561 |
|
|
// cout << "GetTracks_NFitSorted(it): Done"<< endl; |
562 |
|
|
|
563 |
|
|
return sorted; |
564 |
pam-fi |
1.6 |
// return PhysicalTrack; |
565 |
pam-fi |
1.3 |
} |
566 |
mocchiut |
1.1 |
//-------------------------------------- |
567 |
|
|
// |
568 |
|
|
// |
569 |
|
|
//-------------------------------------- |
570 |
|
|
/** |
571 |
|
|
* Retrieves the is-th stored track. |
572 |
|
|
* @param it Track number, ranging from 0 to ntrk(). |
573 |
|
|
* Fitted tracks ( images included ) are stored in a TObjectArray ( TrkLevel2::Track ) in the same order they are returned by the F77 fitting routine. |
574 |
|
|
*/ |
575 |
|
|
TrkTrack *TrkLevel2::GetStoredTrack(int is){ |
576 |
|
|
|
577 |
|
|
if(is >= this->ntrk()){ |
578 |
|
|
cout << "** TrkLevel2 ** Track "<< is << "doen not exits! " << endl; |
579 |
|
|
cout << " Stored tracks ntrk() = "<< this->ntrk() << endl; |
580 |
|
|
return 0; |
581 |
|
|
} |
582 |
|
|
TClonesArray &t = *(Track); |
583 |
|
|
TrkTrack *track = (TrkTrack*)t[is]; |
584 |
|
|
return track; |
585 |
|
|
} |
586 |
|
|
//-------------------------------------- |
587 |
|
|
// |
588 |
|
|
// |
589 |
|
|
//-------------------------------------- |
590 |
|
|
/** |
591 |
pam-fi |
1.6 |
* Retrieves the is-th stored X singlet. |
592 |
|
|
* @param it Singlet number, ranging from 0 to nclsx(). |
593 |
|
|
*/ |
594 |
|
|
TrkSinglet *TrkLevel2::GetSingletX(int is){ |
595 |
|
|
|
596 |
|
|
if(is >= this->nclsx()){ |
597 |
|
|
cout << "** TrkLevel2 ** Singlet "<< is << "doen not exits! " << endl; |
598 |
|
|
cout << " Stored x-singlets nclsx() = "<< this->nclsx() << endl; |
599 |
|
|
return 0; |
600 |
|
|
} |
601 |
|
|
TClonesArray &t = *(SingletX); |
602 |
|
|
TrkSinglet *singlet = (TrkSinglet*)t[is]; |
603 |
|
|
return singlet; |
604 |
|
|
} |
605 |
|
|
//-------------------------------------- |
606 |
|
|
// |
607 |
|
|
// |
608 |
|
|
//-------------------------------------- |
609 |
|
|
/** |
610 |
|
|
* Retrieves the is-th stored Y singlet. |
611 |
|
|
* @param it Singlet number, ranging from 0 to nclsx(). |
612 |
|
|
*/ |
613 |
|
|
TrkSinglet *TrkLevel2::GetSingletY(int is){ |
614 |
|
|
|
615 |
|
|
if(is >= this->nclsy()){ |
616 |
|
|
cout << "** TrkLevel2 ** Singlet "<< is << "doen not exits! " << endl; |
617 |
|
|
cout << " Stored y-singlets nclsy() = "<< this->nclsx() << endl; |
618 |
|
|
return 0; |
619 |
|
|
} |
620 |
|
|
TClonesArray &t = *(SingletY); |
621 |
|
|
TrkSinglet *singlet = (TrkSinglet*)t[is]; |
622 |
|
|
return singlet; |
623 |
|
|
} |
624 |
|
|
//-------------------------------------- |
625 |
|
|
// |
626 |
|
|
// |
627 |
|
|
//-------------------------------------- |
628 |
|
|
/** |
629 |
mocchiut |
1.1 |
* Retrieves the it-th "physical" track, sorted by the method GetNTracks(). |
630 |
|
|
* @param it Track number, ranging from 0 to GetNTracks(). |
631 |
|
|
*/ |
632 |
pam-fi |
1.8 |
/*TrkTrack *TrkLevel2::GetTrack(int it){ |
633 |
mocchiut |
1.1 |
|
634 |
|
|
if(it >= this->GetNTracks()){ |
635 |
|
|
cout << "** TrkLevel2 ** Track "<< it << "does not exits! " << endl; |
636 |
|
|
cout << " Physical tracks GetNTracks() = "<< this->ntrk() << endl; |
637 |
|
|
return 0; |
638 |
|
|
} |
639 |
pam-fi |
1.8 |
TClonesArray* sorted = GetTracks(); |
640 |
|
|
TClonesArray &ts = *sorted; |
641 |
|
|
|
642 |
|
|
// TrkTrack *track = (TrkTrack*)ts[it]; |
643 |
|
|
TrkTrack *track = new TrkTrack( *(TrkTrack*)ts[it] ); //copia |
644 |
|
|
sorted->Delete("all");////TEMPORANEO |
645 |
|
|
return track; |
646 |
|
|
}*/ |
647 |
|
|
TrkTrack *TrkLevel2::GetTrack(int it){ |
648 |
|
|
|
649 |
|
|
if(it >= this->GetNTracks()){ |
650 |
|
|
cout << "** TrkLevel2 ** Track "<< it << "does not exits! " << endl; |
651 |
|
|
cout << " Physical tracks GetNTracks() = "<< this->ntrk() << endl; |
652 |
|
|
return 0; |
653 |
|
|
} |
654 |
|
|
|
655 |
|
|
TRefArray *sorted = GetTracks(); //TEMPORANEO |
656 |
|
|
TrkTrack *track = (TrkTrack*)sorted->At(it); |
657 |
|
|
sorted->Delete(); |
658 |
|
|
return track; |
659 |
mocchiut |
1.1 |
} |
660 |
pam-fi |
1.6 |
/** |
661 |
|
|
* Give the number of "physical" tracks, sorted by the method GetTracks(). |
662 |
|
|
*/ |
663 |
pam-fi |
1.5 |
Int_t TrkLevel2::GetNTracks(){ |
664 |
pam-fi |
1.8 |
|
665 |
|
|
Float_t ntot=0; |
666 |
|
|
TClonesArray &t = *Track; |
667 |
|
|
for(int i=0; i<ntrk(); i++) { |
668 |
|
|
if( ((TrkTrack *)t[i])->GetImageSeqNo() == -1 ) ntot+=1.; |
669 |
|
|
else ntot+=0.5; |
670 |
|
|
} |
671 |
|
|
return (Int_t)ntot; |
672 |
|
|
|
673 |
pam-fi |
1.5 |
}; |
674 |
mocchiut |
1.1 |
//-------------------------------------- |
675 |
|
|
// |
676 |
|
|
// |
677 |
|
|
//-------------------------------------- |
678 |
|
|
/** |
679 |
|
|
* Retrieves (if present) the image of the it-th "physical" track, sorted by the method GetNTracks(). |
680 |
|
|
* @param it Track number, ranging from 0 to GetNTracks(). |
681 |
|
|
*/ |
682 |
pam-fi |
1.8 |
/*TrkTrack *TrkLevel2::GetTrackImage(int it){ |
683 |
mocchiut |
1.1 |
|
684 |
|
|
if(it >= this->GetNTracks()){ |
685 |
|
|
cout << "** TrkLevel2 ** Track "<< it << "does not exits! " << endl; |
686 |
|
|
cout << " Physical tracks GetNTracks() = "<< this->ntrk() << endl; |
687 |
|
|
return 0; |
688 |
|
|
} |
689 |
pam-fi |
1.8 |
|
690 |
|
|
TClonesArray* sorted = GetTracks(); |
691 |
|
|
TClonesArray &ts = *sorted; |
692 |
|
|
TrkTrack *track = (TrkTrack*)ts[it]; |
693 |
|
|
// TrkTrack *track = (TrkTrack*)(*(this->GetTracks()))[it]; |
694 |
|
|
|
695 |
|
|
if(!track->HasImage()){ |
696 |
mocchiut |
1.1 |
cout << "** TrkLevel2 ** Track "<< it << "does not have image! " << endl; |
697 |
|
|
return 0; |
698 |
|
|
} |
699 |
|
|
TrkTrack *image = (TrkTrack*)(*Track)[track->image]; |
700 |
pam-fi |
1.8 |
|
701 |
|
|
// GetTracks()->Delete(); ////TEMPORANEO |
702 |
|
|
sorted->Delete(); ////TEMPORANEO |
703 |
|
|
|
704 |
mocchiut |
1.1 |
return image; |
705 |
|
|
|
706 |
pam-fi |
1.8 |
}*/ |
707 |
|
|
TrkTrack *TrkLevel2::GetTrackImage(int it){ |
708 |
|
|
|
709 |
|
|
if(it >= this->GetNTracks()){ |
710 |
|
|
cout << "** TrkLevel2 ** Track "<< it << "does not exits! " << endl; |
711 |
|
|
cout << " Physical tracks GetNTracks() = "<< this->ntrk() << endl; |
712 |
|
|
return 0; |
713 |
|
|
} |
714 |
|
|
|
715 |
|
|
TRefArray* sorted = GetTracks(); //TEMPORANEO |
716 |
|
|
TrkTrack *track = (TrkTrack*)sorted->At(it); |
717 |
|
|
|
718 |
|
|
if(!track->HasImage()){ |
719 |
|
|
cout << "** TrkLevel2 ** Track "<< it << "does not have image! " << endl; |
720 |
|
|
return 0; |
721 |
|
|
} |
722 |
|
|
TrkTrack *image = (TrkTrack*)(*Track)[track->image]; |
723 |
|
|
|
724 |
|
|
sorted->Delete(); |
725 |
|
|
|
726 |
|
|
return image; |
727 |
|
|
|
728 |
mocchiut |
1.1 |
} |
729 |
|
|
//-------------------------------------- |
730 |
|
|
// |
731 |
|
|
// |
732 |
|
|
//-------------------------------------- |
733 |
|
|
/** |
734 |
|
|
* Loads the magnetic field. |
735 |
|
|
* @param s Path of the magnetic-field files. |
736 |
|
|
*/ |
737 |
|
|
void TrkLevel2::LoadField(TString s){ |
738 |
|
|
readb_(s.Data()); |
739 |
|
|
}; |
740 |
|
|
//-------------------------------------- |
741 |
|
|
// |
742 |
|
|
// |
743 |
|
|
//-------------------------------------- |
744 |
|
|
/** |
745 |
pam-fi |
1.6 |
* Get tracker-plane (mechanical) z-coordinate |
746 |
|
|
* @param plane_id plane index (1=TOP,2,3,4,5,6=BOTTOM) |
747 |
|
|
*/ |
748 |
|
|
Float_t TrkLevel2::GetZTrk(Int_t plane_id){ |
749 |
|
|
switch(plane_id){ |
750 |
|
|
case 1: return ZTRK1; |
751 |
|
|
case 2: return ZTRK2; |
752 |
|
|
case 3: return ZTRK3; |
753 |
|
|
case 4: return ZTRK4; |
754 |
|
|
case 5: return ZTRK5; |
755 |
|
|
case 6: return ZTRK6; |
756 |
|
|
default: return 0.; |
757 |
|
|
}; |
758 |
|
|
}; |
759 |
|
|
//-------------------------------------- |
760 |
|
|
// |
761 |
|
|
// |
762 |
|
|
//-------------------------------------- |
763 |
|
|
/** |
764 |
pam-fi |
1.2 |
* Trajectory default constructor. |
765 |
|
|
* (By default is created with z-coordinates inside the tracking volume) |
766 |
|
|
*/ |
767 |
|
|
Trajectory::Trajectory(){ |
768 |
|
|
npoint = 10; |
769 |
|
|
x = new float[npoint]; |
770 |
|
|
y = new float[npoint]; |
771 |
|
|
z = new float[npoint]; |
772 |
|
|
thx = new float[npoint]; |
773 |
|
|
thy = new float[npoint]; |
774 |
|
|
tl = new float[npoint]; |
775 |
pam-fi |
1.6 |
float dz = ((ZTRK1)-(ZTRK6))/(npoint-1); |
776 |
pam-fi |
1.2 |
for(int i=0; i<npoint; i++){ |
777 |
|
|
x[i] = 0; |
778 |
|
|
y[i] = 0; |
779 |
pam-fi |
1.6 |
z[i] = (ZTRK1) - i*dz; |
780 |
pam-fi |
1.2 |
thx[i] = 0; |
781 |
|
|
thy[i] = 0; |
782 |
|
|
tl[i] = 0; |
783 |
|
|
} |
784 |
|
|
} |
785 |
|
|
//-------------------------------------- |
786 |
|
|
// |
787 |
|
|
// |
788 |
|
|
//-------------------------------------- |
789 |
|
|
/** |
790 |
mocchiut |
1.1 |
* Trajectory constructor. |
791 |
pam-fi |
1.2 |
* (By default is created with z-coordinates inside the tracking volume) |
792 |
mocchiut |
1.1 |
* \param n Number of points |
793 |
|
|
*/ |
794 |
|
|
Trajectory::Trajectory(int n){ |
795 |
pam-fi |
1.2 |
if(n<=0){ |
796 |
|
|
cout << "NB! Trajectory must have at least 1 point >>> created with 10 points" << endl; |
797 |
|
|
n=10; |
798 |
|
|
} |
799 |
mocchiut |
1.1 |
npoint = n; |
800 |
|
|
x = new float[npoint]; |
801 |
|
|
y = new float[npoint]; |
802 |
|
|
z = new float[npoint]; |
803 |
pam-fi |
1.2 |
thx = new float[npoint]; |
804 |
|
|
thy = new float[npoint]; |
805 |
|
|
tl = new float[npoint]; |
806 |
pam-fi |
1.6 |
float dz = ((ZTRK1)-(ZTRK6))/(npoint-1); |
807 |
mocchiut |
1.1 |
for(int i=0; i<npoint; i++){ |
808 |
pam-fi |
1.2 |
x[i] = 0; |
809 |
mocchiut |
1.1 |
y[i] = 0; |
810 |
pam-fi |
1.6 |
z[i] = (ZTRK1) - i*dz; |
811 |
pam-fi |
1.2 |
thx[i] = 0; |
812 |
|
|
thy[i] = 0; |
813 |
|
|
tl[i] = 0; |
814 |
mocchiut |
1.1 |
} |
815 |
|
|
} |
816 |
|
|
//-------------------------------------- |
817 |
|
|
// |
818 |
|
|
// |
819 |
|
|
//-------------------------------------- |
820 |
|
|
/** |
821 |
|
|
* Trajectory constructor. |
822 |
|
|
* \param n Number of points |
823 |
|
|
* \param pz Pointer to float array, defining z coordinates |
824 |
|
|
*/ |
825 |
|
|
Trajectory::Trajectory(int n, float* zin){ |
826 |
pam-fi |
1.2 |
npoint = 10; |
827 |
|
|
if(n>0)npoint = n; |
828 |
mocchiut |
1.1 |
x = new float[npoint]; |
829 |
|
|
y = new float[npoint]; |
830 |
|
|
z = new float[npoint]; |
831 |
pam-fi |
1.2 |
thx = new float[npoint]; |
832 |
|
|
thy = new float[npoint]; |
833 |
|
|
tl = new float[npoint]; |
834 |
|
|
int i=0; |
835 |
|
|
do{ |
836 |
mocchiut |
1.1 |
x[i] = 0; |
837 |
|
|
y[i] = 0; |
838 |
|
|
z[i] = zin[i]; |
839 |
pam-fi |
1.2 |
thx[i] = 0; |
840 |
|
|
thy[i] = 0; |
841 |
|
|
tl[i] = 0; |
842 |
|
|
i++; |
843 |
|
|
}while(zin[i-1] > zin[i] && i < npoint); |
844 |
|
|
npoint=i; |
845 |
|
|
if(npoint != n)cout << "NB! Trajectory created with "<<npoint<<" points"<<endl; |
846 |
mocchiut |
1.1 |
} |
847 |
|
|
//-------------------------------------- |
848 |
|
|
// |
849 |
|
|
// |
850 |
|
|
//-------------------------------------- |
851 |
|
|
/** |
852 |
|
|
* Dump the trajectory coordinates. |
853 |
|
|
*/ |
854 |
|
|
void Trajectory::Dump(){ |
855 |
|
|
cout <<endl<< "Trajectory ========== "<<endl; |
856 |
|
|
for (int i=0; i<npoint; i++){ |
857 |
pam-fi |
1.2 |
cout << i <<" >> " << x[i] <<" "<< y[i] <<" "<< z[i] ; |
858 |
|
|
cout <<" -- " << thx[i] <<" "<< thy[i] ; |
859 |
|
|
cout <<" -- " << tl[i] << endl; |
860 |
mocchiut |
1.1 |
}; |
861 |
|
|
} |
862 |
pam-fi |
1.2 |
//-------------------------------------- |
863 |
|
|
// |
864 |
|
|
// |
865 |
|
|
//-------------------------------------- |
866 |
|
|
/** |
867 |
|
|
* Get trajectory length between two points |
868 |
|
|
* @param ifirst first point (default 0) |
869 |
|
|
* @param ilast last point (default npoint) |
870 |
|
|
*/ |
871 |
|
|
float Trajectory::GetLength(int ifirst, int ilast){ |
872 |
|
|
if( ifirst<0 ) ifirst = 0; |
873 |
|
|
if( ilast>=npoint) ilast = npoint-1; |
874 |
|
|
float l=0; |
875 |
|
|
for(int i=ifirst;i<=ilast;i++){ |
876 |
|
|
l=l+tl[i]; |
877 |
|
|
}; |
878 |
|
|
if(z[ilast] > ZINI)l=l-tl[ilast]; |
879 |
|
|
if(z[ifirst] < ZINI) l=l-tl[ifirst]; |
880 |
|
|
|
881 |
|
|
return l; |
882 |
mocchiut |
1.1 |
|
883 |
pam-fi |
1.2 |
} |
884 |
pam-fi |
1.6 |
|
885 |
mocchiut |
1.1 |
ClassImp(TrkLevel2); |
886 |
|
|
ClassImp(TrkSinglet); |
887 |
|
|
ClassImp(TrkTrack); |
888 |
|
|
ClassImp(Trajectory); |