/[PAMELA software]/DarthVader/TrackerLevel2/src/TrkLevel2.cpp
ViewVC logotype

Contents of /DarthVader/TrackerLevel2/src/TrkLevel2.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.56 - (show annotations) (download)
Thu Feb 27 11:24:43 2014 UTC (10 years, 11 months ago) by pam-fi
Branch: MAIN
Changes since 1.55: +15 -7 lines
Added new tracking algorythm

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

  ViewVC Help
Powered by ViewVC 1.1.23