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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.22 by pam-fi, Mon Jan 15 12:49:05 2007 UTC revision 1.40 by pam-fi, Fri Aug 31 14:56:51 2007 UTC
# Line 12  using namespace std; Line 12  using namespace std;
12  extern "C" {      extern "C" {    
13      void dotrack_(int*, double*, double*, double*, double*, int*);      void dotrack_(int*, double*, double*, double*, double*, int*);
14      void dotrack2_(int*, double*, double*, double*, double*,double*, double*, double*,int*);      void dotrack2_(int*, double*, double*, double*, double*,double*, double*, double*,int*);
 //    int  readb_(const char*);  
     int  readb_();  
15      void mini2_(int*,int*,int*);      void mini2_(int*,int*,int*);
16      void guess_();      void guess_();
17        void gufld_(float*, float*);
18        float risxeta2_(float *);
19        float risxeta3_(float *);
20        float risxeta4_(float *);
21        float risyeta2_(float *);
22  }  }
23    
24  //--------------------------------------  //--------------------------------------
25  //  //
26  //  //
# Line 39  TrkTrack::TrkTrack(){ Line 43  TrkTrack::TrkTrack(){
43          zm[ip]     = 0;          zm[ip]     = 0;
44          resx[ip]   = 0;          resx[ip]   = 0;
45          resy[ip]   = 0;          resy[ip]   = 0;
46            tailx[ip]   = 0;
47            taily[ip]   = 0;
48          xv[ip]     = 0;          xv[ip]     = 0;
49          yv[ip]     = 0;          yv[ip]     = 0;
50          zv[ip]     = 0;          zv[ip]     = 0;
# Line 46  TrkTrack::TrkTrack(){ Line 52  TrkTrack::TrkTrack(){
52          ayv[ip]    = 0;          ayv[ip]    = 0;
53          dedx_x[ip] = 0;          dedx_x[ip] = 0;
54          dedx_y[ip] = 0;          dedx_y[ip] = 0;
55            multmaxx[ip] = 0;
56            multmaxy[ip] = 0;
57            seedx[ip]  = 0;  
58            seedy[ip]  = 0;
59            xpu[ip]    = 0;  
60            ypu[ip]    = 0;  
61    
62      };      };
63      clx = 0;  
64      cly = 0;      TrkParams::SetTrackingMode();
65        TrkParams::SetPrecisionFactor();
66        TrkParams::SetStepMin();
67        TrkParams::SetPFA();
68    
69  };  };
70  //--------------------------------------  //--------------------------------------
71  //  //
# Line 71  TrkTrack::TrkTrack(const TrkTrack& t){ Line 88  TrkTrack::TrkTrack(const TrkTrack& t){
88          zm[ip]     = t.zm[ip];          zm[ip]     = t.zm[ip];
89          resx[ip]   = t.resx[ip];          resx[ip]   = t.resx[ip];
90          resy[ip]   = t.resy[ip];          resy[ip]   = t.resy[ip];
91            tailx[ip]  = t.tailx[ip];
92            taily[ip]  = t.taily[ip];
93          xv[ip]     = t.xv[ip];          xv[ip]     = t.xv[ip];
94          yv[ip]     = t.yv[ip];          yv[ip]     = t.yv[ip];
95          zv[ip]     = t.zv[ip];          zv[ip]     = t.zv[ip];
# Line 78  TrkTrack::TrkTrack(const TrkTrack& t){ Line 97  TrkTrack::TrkTrack(const TrkTrack& t){
97          ayv[ip]    = t.ayv[ip];          ayv[ip]    = t.ayv[ip];
98          dedx_x[ip] = t.dedx_x[ip];          dedx_x[ip] = t.dedx_x[ip];
99          dedx_y[ip] = t.dedx_y[ip];          dedx_y[ip] = t.dedx_y[ip];
100            multmaxx[ip] = t.multmaxx[ip];
101            multmaxy[ip] = t.multmaxy[ip];
102            seedx[ip]    = t.seedx[ip];  
103            seedy[ip]    = t.seedy[ip];
104            xpu[ip]      = t.xpu[ip];  
105            ypu[ip]      = t.ypu[ip];  
106      };      };
107      clx = 0;  
108      cly = 0;      TrkParams::SetTrackingMode();
109      if(t.clx)clx = new TRefArray(*(t.clx));      TrkParams::SetPrecisionFactor();
110      if(t.cly)cly = new TRefArray(*(t.cly));      TrkParams::SetStepMin();  
111                TrkParams::SetPFA();
112    
113  };  };
114  //--------------------------------------  //--------------------------------------
115  //  //
# Line 107  void TrkTrack::Copy(TrkTrack& t){ Line 133  void TrkTrack::Copy(TrkTrack& t){
133          t.zm[ip]     = zm[ip];          t.zm[ip]     = zm[ip];
134          t.resx[ip]   = resx[ip];          t.resx[ip]   = resx[ip];
135          t.resy[ip]   = resy[ip];          t.resy[ip]   = resy[ip];
136            t.tailx[ip]  = tailx[ip];
137            t.taily[ip]  = taily[ip];
138          t.xv[ip]     = xv[ip];          t.xv[ip]     = xv[ip];
139          t.yv[ip]     = yv[ip];          t.yv[ip]     = yv[ip];
140          t.zv[ip]     = zv[ip];          t.zv[ip]     = zv[ip];
# Line 114  void TrkTrack::Copy(TrkTrack& t){ Line 142  void TrkTrack::Copy(TrkTrack& t){
142          t.ayv[ip]    = ayv[ip];          t.ayv[ip]    = ayv[ip];
143          t.dedx_x[ip] = dedx_x[ip];          t.dedx_x[ip] = dedx_x[ip];
144          t.dedx_y[ip] = dedx_y[ip];          t.dedx_y[ip] = dedx_y[ip];
145            t.multmaxx[ip] = multmaxx[ip];
146            t.multmaxy[ip] = multmaxy[ip];
147            t.seedx[ip]    = seedx[ip];  
148            t.seedy[ip]    = seedy[ip];
149            t.xpu[ip]      = xpu[ip];  
150            t.ypu[ip]      = ypu[ip];  
151                            
152      };      };
153    
154            
155  };  };
156  //--------------------------------------  //--------------------------------------
# Line 141  int TrkTrack::DoTrack(Trajectory* t){ Line 176  int TrkTrack::DoTrack(Trajectory* t){
176      for (int i=0; i<5; i++)         dal[i]  = (double)al[i];      for (int i=0; i<5; i++)         dal[i]  = (double)al[i];
177      for (int i=0; i<t->npoint; i++) dzin[i] = (double)t->z[i];      for (int i=0; i<t->npoint; i++) dzin[i] = (double)t->z[i];
178    
179        TrkParams::Load(1);
180        if( !TrkParams::IsLoaded(1) ){
181            cout << "int TrkTrack::DoTrack(Trajectory* t) --- ERROR --- m.field not loaded"<<endl;
182            return 0;
183        }
184      dotrack_(&(t->npoint),dzin,dxout,dyout,dal,&ifail);      dotrack_(&(t->npoint),dzin,dxout,dyout,dal,&ifail);
185            
186      for (int i=0; i<t->npoint; i++){      for (int i=0; i<t->npoint; i++){
# Line 180  int TrkTrack::DoTrack2(Trajectory* t){ Line 220  int TrkTrack::DoTrack2(Trajectory* t){
220      for (int i=0; i<5; i++)         dal[i]  = (double)al[i];      for (int i=0; i<5; i++)         dal[i]  = (double)al[i];
221      for (int i=0; i<t->npoint; i++) dzin[i] = (double)t->z[i];      for (int i=0; i<t->npoint; i++) dzin[i] = (double)t->z[i];
222    
223        TrkParams::Load(1);
224        if( !TrkParams::IsLoaded(1) ){
225            cout << "int TrkTrack::DoTrack2(Trajectory* t) --- ERROR --- m.field not loaded"<<endl;
226            return 0;
227        }
228      dotrack2_(&(t->npoint),dzin,dxout,dyout,dthxout,dthyout,dtlout,dal,&ifail);      dotrack2_(&(t->npoint),dzin,dxout,dyout,dthxout,dthyout,dtlout,dal,&ifail);
229            
230      for (int i=0; i<t->npoint; i++){      for (int i=0; i<t->npoint; i++){
# Line 219  Float_t TrkTrack::GetDeflection(){ Line 264  Float_t TrkTrack::GetDeflection(){
264          return def;          return def;
265  };  };
266  //  //
267    /**
268     * Method to retrieve the dE/dx measured on a tracker view.
269     * @param ip plane (0-5)
270     * @param iv view (0=x 1=y)
271     */
272    Float_t TrkTrack::GetDEDX(int ip, int iv){
273        if(iv==0 && ip>=0 && ip<6)return fabs(dedx_x[ip]);
274        else if(iv==1 && ip>=0 && ip<6)return fabs(dedx_y[ip]);
275        else {
276            cout << "TrkTrack::GetDEDX(int ip, int iv) -- wrong input parameters "<<ip<<iv<<endl;
277            return 0.;
278        }
279    }
280    /**
281     * Method to evaluate the dE/dx measured on a tracker plane.
282     * The two measurements on x- and y-view are averaged.
283     * @param ip plane (0-5)
284     */
285    Float_t TrkTrack::GetDEDX(int ip){
286        if( (Int_t)XGood(ip)+(Int_t)YGood(ip) == 0 ) return 0;
287        return (GetDEDX(ip,0)+GetDEDX(ip,1))/((Int_t)XGood(ip)+(Int_t)YGood(ip));
288    };
289    
290    /**
291     * Method to evaluate the dE/dx averaged over all planes.
292     */
293  Float_t TrkTrack::GetDEDX(){  Float_t TrkTrack::GetDEDX(){
294          Float_t dedx=0;      Float_t dedx=0;
295          for(Int_t i=0; i<6; i++)dedx+=dedx_x[i]*xgood[i]+dedx_y[i]*ygood[i];      for(Int_t ip=0; ip<6; ip++)dedx+=GetDEDX(ip,0)*XGood(ip)+GetDEDX(ip,1)*YGood(ip);
296          dedx = dedx/(this->GetNX()+this->GetNY());      dedx = dedx/(GetNX()+GetNY());
297          return dedx;      return dedx;
298    };
299    /**
300     * Returns 1 if the cluster on a tracker view includes bad strips.
301     * @param ip plane (0-5)
302     * @param iv view (0=x 1=y)
303     */
304    Bool_t TrkTrack::IsBad(int ip,int iv){
305        if(iv==0 && ip>=0 && ip<6)return (xgood[ip]<0) ;
306        else if(iv==1 && ip>=0 && ip<6)return (ygood[ip]<0) ;
307        else {
308            cout << "TrkTrack::IsBad(int ip, int iv) -- wrong input parameters "<<ip<<iv<<endl;
309            return 0.;
310        }
311    };
312    /**
313     * Returns 1 if the signal on a tracker view is saturated.
314     * @param ip plane (0-5)
315     * @param iv view (0=x 1=y)
316     */
317    Bool_t TrkTrack::IsSaturated(int ip,int iv){
318        if(iv==0 && ip>=0 && ip<6)return (dedx_x[ip]<0) ;
319        else if(iv==1 && ip>=0 && ip<6)return (dedx_y[ip]<0) ;
320        else {
321            cout << "TrkTrack::IsSaturated(int ip, int iv) -- wrong input parameters "<<ip<<iv<<endl;
322            return 0.;
323        }
324    };
325    /**
326     * Returns 1 if either the x or the y signal on a tracker plane is saturated.
327     * @param ip plane (0-5)
328     */
329    Bool_t TrkTrack::IsSaturated(int ip){
330        return (IsSaturated(ip,0)||IsSaturated(ip,1));
331    };
332    /**
333     * Returns 1 if there is at least a saturated signal along the track.
334     */
335    Bool_t TrkTrack::IsSaturated(){
336        for(int ip=0; ip<6; ip++)for(int iv=0; iv<2; iv++)if(IsSaturated(ip,iv))return true;
337        return false;
338    }
339    /**
340     * Returns the track "lever-arm" on the x view, defined as the distance (in planes) between
341     * the upper and lower x measurements (the maximum value of lever-arm is 6).
342     */
343    Int_t TrkTrack::GetLeverArmX(){
344        int first_plane = -1;
345        int last_plane  = -1;
346        for(Int_t ip=0; ip<6; ip++){
347            if( XGood(ip) && first_plane == -1 )first_plane = ip;
348            if( XGood(ip) && first_plane != -1 )last_plane = ip;
349        }
350        if( first_plane == -1 || last_plane == -1){
351            cout<< "Int_t TrkTrack::GetLeverArmX() -- XGood(ip) always false ??? "<<endl;
352            return 0;
353        }
354        return (last_plane-first_plane+1);
355    }
356    /**
357     * Returns the track "lever-arm" on the y view, defined as the distance (in planes) between
358     * the upper and lower y measurements (the maximum value of lever-arm is 6).
359     */
360    Int_t TrkTrack::GetLeverArmY(){
361        int first_plane = -1;
362        int last_plane  = -1;
363        for(Int_t ip=0; ip<6; ip++){
364            if( YGood(ip) && first_plane == -1 )first_plane = ip;
365            if( YGood(ip) && first_plane != -1 )last_plane = ip;
366        }
367        if( first_plane == -1 || last_plane == -1){
368            cout<< "Int_t TrkTrack::GetLeverArmY() -- YGood(ip) always false ??? "<<endl;
369            return 0;
370        }
371        return (last_plane-first_plane+1);
372    }
373    /**
374     * Returns the reduced chi-square of track x-projection
375     */
376    Float_t  TrkTrack::GetChi2X(){
377        float chiq=0;
378        for(int ip=0; ip<6; ip++)if(XGood(ip))chiq+= pow((xv[ip]-xm[ip])/resx[ip],2.);
379        if(GetNX()>3)chiq=chiq/(GetNX()-3);
380        else chiq=0;
381        if(chiq==0)cout << " Float_t  TrkTrack::GetChi2X() -- WARNING -- value not defined "<<chiq<<endl;
382        return chiq;
383    }
384    /**
385     * Returns the reduced chi-square of track y-projection
386     */
387    Float_t  TrkTrack::GetChi2Y(){
388        float chiq=0;
389        for(int ip=0; ip<6; ip++)if(YGood(ip))chiq+= pow((yv[ip]-ym[ip])/resy[ip],2.);
390        if(GetNY()>2)chiq=chiq/(GetNY()-2);
391        else chiq=0;
392        if(chiq==0)cout << " Float_t  TrkTrack::GetChi2Y() -- WARNING -- value not defined "<<chiq<<endl;
393        return chiq;
394    }
395    /**
396     * Returns the logarythm of the likeliwood-function of  track x-projection
397     */
398    Float_t TrkTrack::GetLnLX(){
399        float lnl=0;
400        for(int ip=0; ip<6; ip++)
401            if( XGood(ip) && tailx[ip]!=0 )
402                lnl += (tailx[ip]+1.) * log( (tailx[ip]*pow(resx[ip],2.) + pow(xv[ip]-xm[ip],2.)) / (tailx[ip]*pow(resx[ip],2)) );
403        if(GetNX()>3)lnl=lnl/(GetNX()-3);
404        else lnl=0;
405        if(lnl==0){
406            cout << " Float_t  TrkTrack::GetLnLX() -- WARNING -- value not defined "<<lnl<<endl;
407            Dump();
408        }
409        return lnl;
410        
411    }
412    /**
413     * Returns the logarythm of the likeliwood-function of  track y-projection
414     */
415    Float_t TrkTrack::GetLnLY(){
416        float lnl=0;
417        for(int ip=0; ip<6; ip++)
418            if( YGood(ip) && taily[ip]!=0 )
419                lnl += (taily[ip]+1.) * log( (taily[ip]*pow(resy[ip],2.) + pow(yv[ip]-ym[ip],2.)) / (taily[ip]*pow(resy[ip],2)) );
420        if(GetNY()>2)lnl=lnl/(GetNY()-2);
421        else lnl=0;
422        if(lnl==0){
423            cout << " Float_t  TrkTrack::GetLnLY() -- WARNING -- value not defined "<<lnl<<endl;
424            Dump();
425        }
426        return lnl;
427        
428    }
429    /**
430     * Returns the effective angle, relative to the sensor, on each plane.
431     * @param ip plane (0-5)
432     * @param iv view (0=x 1=y)
433     */
434    Float_t TrkTrack::GetEffectiveAngle(int ip, int iv){
435    
436        if(ip<0 || ip>5){
437            cout << "Float_t TrkTrack::GetEffectiveAngle(int "<<ip<<", int "<<iv<<") ==> wrong input"<<endl;
438            return 0.;
439        }
440    
441        float v[3]={xv[ip],yv[ip],zv[ip]};
442        //-----------------------------------------
443        // effective angle (relative to the sensor)
444        //-----------------------------------------
445        float axv_geo  = axv[ip];
446        float muhall_h = 297.61; //cm**2/Vs
447        float BY = TrkParams::GetBY(v);
448        float axv_eff = 0;
449        if(ip==5) axv_geo = -1*axv_geo;
450        if(ip==5) BY      = -1*BY;
451        axv_eff = 180.*atan( tan(axv_geo*acos(-1.)/180.) + muhall_h * BY * 0.0001)/acos(-1.);
452        //-----------------------------------------
453        // effective angle (relative to the sensor)
454        //-----------------------------------------
455        float ayv_geo = ayv[ip];
456        float muhall_e = 1258.18; //cm**2/Vs
457        float BX = TrkParams::GetBX(v);
458        float ayv_eff = 0;
459        ayv_eff = 180.*atan( tan(ayv_geo*acos(-1.)/180.) + muhall_e * BX * 0.0001)/acos(-1.);
460      
461        if     (iv==0)return axv_eff;
462        else if(iv==1)return ayv_eff;
463        else{
464            cout << "Float_t TrkTrack::GetEffectiveAngle(int "<<ip<<", int "<<iv<<") ==> wrong input"<<endl;
465            return 0.;
466        }
467      
468  };  };
469    
470  //--------------------------------------  //--------------------------------------
# Line 237  void TrkTrack::Dump(){ Line 478  void TrkTrack::Dump(){
478      cout << endl << "al       : "; for(int i=0; i<5; i++)cout << al[i] << " ";      cout << endl << "al       : "; for(int i=0; i<5; i++)cout << al[i] << " ";
479      cout << endl << "chi^2    : "<< chi2;      cout << endl << "chi^2    : "<< chi2;
480      cout << endl << "n.step   : "<< nstep;      cout << endl << "n.step   : "<< nstep;
481      cout << endl << "xgood    : "; for(int i=0; i<6; i++)cout << xgood[i] ;      cout << endl << "xgood    : "; for(int i=0; i<6; i++)cout << XGood(i) ;
482      cout << endl << "ygood    : "; for(int i=0; i<6; i++)cout << ygood[i] ;      cout << endl << "ygood    : "; for(int i=0; i<6; i++)cout << YGood(i) ;
483      cout << endl << "xm       : "; for(int i=0; i<6; i++)cout << xm[i] << " ";      cout << endl << "xm       : "; for(int i=0; i<6; i++)cout << xm[i] << " ";
484      cout << endl << "ym       : "; for(int i=0; i<6; i++)cout << ym[i] << " ";      cout << endl << "ym       : "; for(int i=0; i<6; i++)cout << ym[i] << " ";
485      cout << endl << "zm       : "; for(int i=0; i<6; i++)cout << zm[i] << " ";      cout << endl << "zm       : "; for(int i=0; i<6; i++)cout << zm[i] << " ";
# Line 247  void TrkTrack::Dump(){ Line 488  void TrkTrack::Dump(){
488      cout << endl << "zv       : "; for(int i=0; i<6; i++)cout << zv[i] << " ";      cout << endl << "zv       : "; for(int i=0; i<6; i++)cout << zv[i] << " ";
489      cout << endl << "resx     : "; for(int i=0; i<6; i++)cout << resx[i] << " ";      cout << endl << "resx     : "; for(int i=0; i<6; i++)cout << resx[i] << " ";
490      cout << endl << "resy     : "; for(int i=0; i<6; i++)cout << resy[i] << " ";      cout << endl << "resy     : "; for(int i=0; i<6; i++)cout << resy[i] << " ";
491        cout << endl << "tailx    : "; for(int i=0; i<6; i++)cout << tailx[i] << " ";
492        cout << endl << "taily    : "; for(int i=0; i<6; i++)cout << taily[i] << " ";
493      cout << endl << "coval    : "; for(int i=0; i<5; i++)cout << coval[0][i]<<" ";      cout << endl << "coval    : "; for(int i=0; i<5; i++)cout << coval[0][i]<<" ";
494      cout << endl << "           "; for(int i=0; i<5; i++)cout << coval[1][i]<<" ";      cout << endl << "           "; for(int i=0; i<5; i++)cout << coval[1][i]<<" ";
495      cout << endl << "           "; for(int i=0; i<5; i++)cout << coval[2][i]<<" ";      cout << endl << "           "; for(int i=0; i<5; i++)cout << coval[2][i]<<" ";
# Line 254  void TrkTrack::Dump(){ Line 497  void TrkTrack::Dump(){
497      cout << endl << "           "; for(int i=0; i<5; i++)cout << coval[4][i]<<" ";      cout << endl << "           "; for(int i=0; i<5; i++)cout << coval[4][i]<<" ";
498      cout << endl << "dedx_x   : "; for(int i=0; i<6; i++)cout << dedx_x[i] << " ";      cout << endl << "dedx_x   : "; for(int i=0; i<6; i++)cout << dedx_x[i] << " ";
499      cout << endl << "dedx_y   : "; for(int i=0; i<6; i++)cout << dedx_y[i] << " ";      cout << endl << "dedx_y   : "; for(int i=0; i<6; i++)cout << dedx_y[i] << " ";
500        cout << endl << "maxs x   : "; for(int i=0; i<6; i++)cout << GetClusterX_MaxStrip(i) << " ";
501        cout << endl << "maxs y   : "; for(int i=0; i<6; i++)cout << GetClusterY_MaxStrip(i) << " ";
502        cout << endl << "mult x   : "; for(int i=0; i<6; i++)cout << GetClusterX_Multiplicity(i) << " ";
503        cout << endl << "mult y   : "; for(int i=0; i<6; i++)cout << GetClusterY_Multiplicity(i) << " ";
504        cout << endl << "seed x   : "; for(int i=0; i<6; i++)cout << GetClusterX_Seed(i) << " ";
505        cout << endl << "seed y   : "; for(int i=0; i<6; i++)cout << GetClusterY_Seed(i) << " ";
506        cout << endl << "xpu      : "; for(int i=0; i<6; i++)cout << xpu[i] << " ";
507        cout << endl << "ypu      : "; for(int i=0; i<6; i++)cout << ypu[i] << " ";
508    
509      cout << endl;      cout << endl;
510  }  }
511  /**  /**
# Line 272  void TrkTrack::SetResolution(double *rx, Line 524  void TrkTrack::SetResolution(double *rx,
524      for(int i=0; i<6; i++) resy[i]=*ry++;      for(int i=0; i<6; i++) resy[i]=*ry++;
525  }  }
526  /**  /**
527     * Set the TrkTrack tails position resolution
528     */
529    void TrkTrack::SetTail(double *tx, double *ty, double factor){
530        for(int i=0; i<6; i++) tailx[i]=factor*(*tx++);
531        for(int i=0; i<6; i++) taily[i]=factor*(*ty++);
532    }
533    /**
534     * Set the TrkTrack Student parameter (resx,resy,tailx,taily)
535     * from previous gausian fit
536     *@param flag =0 standard, =1 with noise correction
537     */
538    void TrkTrack::SetStudentParam(int flag){
539        float sx[11]={0.000128242,
540                       0.000136942,
541                       0.000162718,
542                       0.000202644,
543                       0.00025597,
544                       0.000317456,
545                       0.000349048,
546                       0.000384638,
547                       0.000457295,
548                       0.000512319,
549                       0.000538573};
550        float tx[11]={1.79402,
551                       2.04876,
552                       2.88376,
553                       3.3,
554                       3.14084,
555                       4.07686,
556                       4.44736,
557                       3.5179,
558                       3.38697,
559                       3.45739,
560                       3.18627};
561        float sy[11]={0.000483075,
562                       0.000466925,
563                       0.000431658,
564                       0.000428317,
565                       0.000433854,
566                       0.000444044,
567                       0.000482098,
568                       0.000537579,
569                       0.000636279,
570                       0.000741998,
571                       0.000864261};
572        float ty[11]={0.997032,
573                       1.11147,
574                       1.18526,
575                       1.61404,
576                       2.21908,
577                       3.08959,
578                       4.48833,
579                       4.42687,
580                       4.65253,
581                       4.52043,
582                       4.29926};
583        int index;
584        float fact;
585        for(int i=0; i<6; i++) {
586            index = int((fabs(axv[i])+1.)/2.);
587            if(index>10) index=10;
588            tailx[i]=tx[index];
589            if(flag==1) {
590                if(fabs(axv[i])<=10.) fact = resx[i]/risxeta2_(&(axv[i]));
591                if(fabs(axv[i])>10.&&fabs(axv[i])<=15.) fact = resx[i]/risxeta3_(&(axv[i]));
592                if(fabs(axv[i])>15.) fact = resx[i]/risxeta4_(&(axv[i]));
593            } else fact = 1.;
594            resx[i] = sx[index]*fact;
595        }
596        for(int i=0; i<6; i++) {
597            index = int((fabs(ayv[i])+1.)/2.);
598            if(index>10) index=10;
599            taily[i]=ty[index];
600            if(flag==1) fact = resy[i]/risyeta2_(&(ayv[i]));
601            else fact = 1.;
602            resy[i] = sy[index]*fact;
603        }
604    }
605    /**
606   * Set the TrkTrack good measurement   * Set the TrkTrack good measurement
607   */   */
608  void TrkTrack::SetGood(int *xg, int *yg){  void TrkTrack::SetGood(int *xg, int *yg){
609    
610      for(int i=0; i<6; i++) xgood[i]=*xg++;      for(int i=0; i<6; i++) xgood[i]=*xg++;
611      for(int i=0; i<6; i++) ygood[i]=*yg++;      for(int i=0; i<6; i++) ygood[i]=*yg++;
612  }  }
# Line 284  void TrkTrack::SetGood(int *xg, int *yg) Line 616  void TrkTrack::SetGood(int *xg, int *yg)
616   */   */
617  void TrkTrack::LoadField(TString path){  void TrkTrack::LoadField(TString path){
618            
619      strcpy(path_.path,path.Data());  //     strcpy(path_.path,path.Data());
620      path_.pathlen = path.Length();  //     path_.pathlen = path.Length();
621      path_.error   = 0;  //     path_.error   = 0;
622      readb_();  //     readb_();
623    
624        TrkParams::SetTrackingMode();
625        TrkParams::SetPrecisionFactor();
626        TrkParams::SetStepMin();
627    
628        TrkParams::Set(path,1);
629        TrkParams::Load(1);
630    
631  };  };
632    
633    
634  /**  /**
635   * Method to fill minimization-routine common   * Method to fill minimization-routine common
636   */   */
# Line 298  void TrkTrack::FillMiniStruct(cMini2trac Line 638  void TrkTrack::FillMiniStruct(cMini2trac
638    
639      for(int i=0; i<6; i++){      for(int i=0; i<6; i++){
640    
641          track.xgood[i]=xgood[i];  //      cout << i<<" - "<<xgood[i]<<" "<<XGood(i)<<endl;
642          track.ygood[i]=ygood[i];  //      cout << i<<" - "<<ygood[i]<<" "<<YGood(i)<<endl;
643            track.xgood[i]=XGood(i);
644            track.ygood[i]=YGood(i);
645                    
646          track.xm[i]=xm[i];          track.xm[i]=xm[i];
647          track.ym[i]=ym[i];          track.ym[i]=ym[i];
# Line 312  void TrkTrack::FillMiniStruct(cMini2trac Line 654  void TrkTrack::FillMiniStruct(cMini2trac
654          track.xm_b[i]=xm[i];          track.xm_b[i]=xm[i];
655          track.ym_a[i]=ym[i];          track.ym_a[i]=ym[i];
656          track.ym_b[i]=ym[i];          track.ym_b[i]=ym[i];
657          if(       xgood[i] && !ygood[i] ){          if(       XGood(i) && !YGood(i) ){
658              track.ym_a[i] = track.ym_a[i]+segment;              track.ym_a[i] = track.ym_a[i]+segment;
659              track.ym_b[i] = track.ym_b[i]-segment;              track.ym_b[i] = track.ym_b[i]-segment;
660          }else if( !xgood[i] && ygood[i]){          }else if( !XGood(i) && YGood(i)){
661              track.xm_a[i] = track.xm_a[i]+segment;              track.xm_a[i] = track.xm_a[i]+segment;
662              track.xm_b[i] = track.xm_b[i]-segment;              track.xm_b[i] = track.xm_b[i]-segment;
663          }          }
# Line 323  void TrkTrack::FillMiniStruct(cMini2trac Line 665  void TrkTrack::FillMiniStruct(cMini2trac
665                    
666          track.resx[i]=resx[i];          track.resx[i]=resx[i];
667          track.resy[i]=resy[i];          track.resy[i]=resy[i];
668            track.tailx[i]=tailx[i];
669            track.taily[i]=taily[i];
670      }      }
671    
672      for(int i=0; i<5; i++) track.al[i]=al[i];      for(int i=0; i<5; i++) track.al[i]=al[i];
# Line 351  void TrkTrack::SetFromMiniStruct(cMini2t Line 695  void TrkTrack::SetFromMiniStruct(cMini2t
695          axv[i] = track->axv[i];          axv[i] = track->axv[i];
696          ayv[i] = track->ayv[i];          ayv[i] = track->ayv[i];
697      }      }
   
698            
699  }  }
700  /**  /**
701   * Tracking method. It calls F77 mini routine.   * \brief Method to re-evaluate coordinates of clusters associated with a track.
702     *
703     * The method can be applied only after recovering level1 information
704     * (either by reprocessing single events from level0 or from  
705     * the TrkLevel1 branch, if present); it calls F77 subroutines that
706     * read the level1 common and fill the minimization-routine common.
707     * Some clusters can be excluded or added by means of the methods:
708     *
709     * TrkTrack::ResetXGood(int ip)
710     * TrkTrack::ResetYGood(int ip)
711     * TrkTrack::SetXGood(int ip, int cid, int is)
712     * TrkTrack::SetYGood(int ip, int cid, int is)
713     *
714     * NB! The method TrkTrack::SetGood(int *xg, int *yg) set the plane-mask (0-1)
715     * for the minimization-routine common. It deletes the cluster information
716     * (at least for the moment...) thus cannot be applied before
717     * TrkTrack::EvaluateClusterPositions().  
718     *
719     * Different p.f.a. can be applied by calling (once) the method:
720     *
721     * TrkParams::SetPFA(0); //Set ETA p.f.a.
722     *
723     * @see TrkParams::SetPFA(int)
724     */
725    Bool_t TrkTrack::EvaluateClusterPositions(){
726        
727    //     cout << "void TrkTrack::GetClusterPositions() "<<endl;
728    
729        TrkParams::Load( );
730        if( !TrkParams::IsLoaded() )return false;
731        
732        for(int ip=0; ip<6; ip++){
733    //      cout << ip<<" ** "<<xm[ip]<<" / "<<ym[ip]<<endl;;
734            int icx = GetClusterX_ID(ip)+1;
735            int icy = GetClusterY_ID(ip)+1;
736            int sensor = GetSensor(ip)+1;//<< convenzione "Paolo"
737            if(ip==5 && sensor!=0)sensor=3-sensor;//<< convenzione "Elena"
738            int ladder = GetLadder(ip)+1;
739            float ax = axv[ip];
740            float ay = ayv[ip];
741            float v[3];
742            v[0]=xv[ip];
743            v[1]=yv[ip];
744            v[2]=zv[ip];
745            float bfx = 10*TrkParams::GetBX(v);//Tesla
746            float bfy = 10*TrkParams::GetBY(v);//Tesla
747            int ipp=ip+1;
748            xyzpam_(&ipp,&icx,&icy,&ladder,&sensor,&ax,&ay,&bfx,&bfy);
749            if(icx<0 || icy<0)return false;
750        }
751        return true;
752    }
753    /**
754     * \brief Tracking method. It calls F77 mini routine.
755     *
756     * @param pfixed Particle momentum. If pfixed=0 the momentum
757     * is left as a free parameter, otherwise it is fixed to the input value.
758     * @param fail Output flag (!=0 if the fit failed).
759     * @param iprint Flag to set debug mode ( 0 = no output; 1 = verbose; 2 = debug).
760     * @param froml1 Flag to re-evaluate positions (see TrkTrack::GetClusterPositions()).
761     *
762     * The option to re-evaluate positions can be used only after recovering
763     * level1 information, eg. by reprocessing the single event.
764     *
765     * Example:
766     *
767     * if( !event->GetTrkLevel0() )return false;
768     * event->GetTrkLevel0()->ProcessEvent(); // re-processing level0->level1
769     * int fail=0;
770     * event->GetTrkLevel2()->GetTrack(0)->Fit(0.,fail,0,1);
771     *
772     * @see EvaluateClusterPositions()
773     *
774     * The fitting procedure can be varied by changing the tracking mode,
775     * the fit-precision factor and the minimum number of step.
776     * @see SetTrackingMode(int)
777     * @see SetPrecisionFactor(double)
778     * @see SetStepMin(int)
779   */   */
780  void TrkTrack::Fit(double pfixed, int& fail, int iprint){  void TrkTrack::Fit(double pfixed, int& fail, int iprint, int froml1){
781    
782      float al_ini[] = {0.,0.,0.,0.,0.};      float al_ini[] = {0.,0.,0.,0.,0.};
783    
784        TrkParams::Load( );
785        if( !TrkParams::IsLoaded() )return;
786    
787      extern cMini2track track_;      extern cMini2track track_;
788      fail = 0;      fail = 0;
     FillMiniStruct(track_);  
789    
790        FillMiniStruct(track_);
791            
792        if(froml1!=0){
793            if( !EvaluateClusterPositions() ){
794                cout << "void TrkTrack::Fit("<<pfixed<<","<<fail<<","<<iprint<<","<<froml1<<") --- ERROR evaluating cluster positions "<<endl;
795                FillMiniStruct(track_) ;
796                fail = 1;
797                return;
798            }
799        }else{
800            FillMiniStruct(track_);
801        }
802        
803      // if fit variables have been reset, evaluate the initial guess      // if fit variables have been reset, evaluate the initial guess
804      if(al[0]==-9999.&&al[1]==-9999.&&al[2]==-9999.&&al[3]==-9999.&&al[4]==-9999.)guess_();      if(al[0]==-9999.&&al[1]==-9999.&&al[2]==-9999.&&al[3]==-9999.&&al[4]==-9999.)guess_();
805    
# Line 383  void TrkTrack::Fit(double pfixed, int& f Line 818  void TrkTrack::Fit(double pfixed, int& f
818    
819      //  ------------------------------------------      //  ------------------------------------------
820      //  call mini routine      //  call mini routine
821    //     TrkParams::Load(1);
822    //     if( !TrkParams::IsLoaded(1) ){
823    //      cout << "void TrkTrack::Fit(double pfixed, int& fail, int iprint) --- ERROR --- m.field not loaded"<<endl;
824    //      return;
825    //     }
826      int istep=0;      int istep=0;
827      int ifail=0;      int ifail=0;
828      mini2_(&istep,&ifail, &iprint);      mini2_(&istep,&ifail, &iprint);
# Line 393  void TrkTrack::Fit(double pfixed, int& f Line 833  void TrkTrack::Fit(double pfixed, int& f
833      //  ------------------------------------------      //  ------------------------------------------
834            
835      SetFromMiniStruct(&track_);      SetFromMiniStruct(&track_);
 //    cout << endl << "eta ===> " << track_.al[4] << endl;  
   
 //     for(int i=0; i<5; i++) al[i]=track_.al[i];  
 //     chi2=track_.chi2;  
 //     nstep=track_.nstep;  
 //     for(int i=0; i<6; i++) xv[i]=track_.xv[i];  
 //     for(int i=0; i<6; i++) yv[i]=track_.yv[i];  
 //     for(int i=0; i<6; i++) zv[i]=track_.zv[i];  
 //     for(int i=0; i<6; i++) axv[i]=track_.axv[i];  
 //     for(int i=0; i<6; i++) ayv[i]=track_.ayv[i];  
 //     for(int i=0; i<5; i++) {  
 //      for(int j=0; j<5; j++) coval[i][j]=track_.cov[i][j];  
 //     }  
836    
837      if(fail){      if(fail){
838          if(iprint)cout << " >>>> fit failed >>>> drawing initial par"<<endl;          if(iprint)cout << " >>>> fit failed "<<endl;
839          for(int i=0; i<5; i++) al[i]=al_ini[i];          for(int i=0; i<5; i++) al[i]=al_ini[i];
840      }      }
841    
842  };  };
843  /*  /**
844   * Reset the fit parameters   * Reset the fit parameters
845   */   */
846  void TrkTrack::FitReset(){  void TrkTrack::FitReset(){
847      for(int i=0; i<5; i++) al[i]=-9999.;      for(int i=0; i<5; i++) al[i]=-9999.;
848      chi2=0.;      chi2=0.;
849      nstep=0;      nstep=0;
850      for(int i=0; i<6; i++) xv[i]=0.;  //     for(int i=0; i<6; i++) xv[i]=0.;
851      for(int i=0; i<6; i++) yv[i]=0.;  //     for(int i=0; i<6; i++) yv[i]=0.;
852      for(int i=0; i<6; i++) zv[i]=0.;  //     for(int i=0; i<6; i++) zv[i]=0.;
853      for(int i=0; i<6; i++) axv[i]=0.;  //     for(int i=0; i<6; i++) axv[i]=0.;
854      for(int i=0; i<6; i++) ayv[i]=0.;  //     for(int i=0; i<6; i++) ayv[i]=0.;
855      for(int i=0; i<5; i++) {      for(int i=0; i<5; i++) {
856          for(int j=0; j<5; j++) coval[i][j]=0.;          for(int j=0; j<5; j++) coval[i][j]=0.;
857      }      }
858  }  }
859    /**
860     * Set the tracking mode
861     */
862    void TrkTrack::SetTrackingMode(int trackmode){
863        extern cMini2track track_;
864        track_.trackmode = trackmode;
865    }
866    /**
867     * Set the factor scale for tracking precision
868     */
869    void TrkTrack::SetPrecisionFactor(double fact){
870        extern cMini2track track_;
871        track_.fact = fact;
872    }
873    /**
874     * Set the minimum number of steps for tracking precision
875     */
876    void TrkTrack::SetStepMin(int istepmin){
877        extern cMini2track track_;
878        track_.istepmin = istepmin;
879    }
880    /**
881     * Returns 1 if the track is inside the magnet cavity
882     * Set the minimum number of steps for tracking precision
883     */
884    Bool_t TrkTrack::IsInsideCavity(){
885        float xmagntop, ymagntop, xmagnbottom, ymagnbottom;
886        xmagntop = xv[0] + (ZMAGNHIGH-zv[0])*tan(cos(-1.0)*axv[0]/180.);
887        ymagntop = yv[0] + (ZMAGNHIGH-zv[0])*tan(cos(-1.0)*ayv[0]/180.);
888        xmagnbottom = xv[5] + (ZMAGNLOW-zv[5])*tan(cos(-1.0)*axv[5]/180.);
889        ymagnbottom = yv[5] + (ZMAGNLOW-zv[5])*tan(cos(-1.0)*ayv[5]/180.);
890        if( xmagntop>XMAGNLOW && xmagntop<XMAGNHIGH &&
891            ymagntop>YMAGNLOW && ymagntop<YMAGNHIGH &&
892            xmagnbottom>XMAGNLOW && xmagnbottom<XMAGNHIGH &&
893            ymagnbottom>YMAGNLOW && ymagnbottom<YMAGNHIGH ) return(true);
894        else return(false);
895    }
896    /**
897     * Method to retrieve ID (0,1,...) of x-cluster (if any) associated to this track.
898     * If no cluster is associated, ID=-1.
899     * @param ip Tracker plane (0-5)
900     */
901    Int_t TrkTrack::GetClusterX_ID(int ip){
902        return ((Int_t)fabs(xgood[ip]))%10000000-1;
903    };
904    /**
905     * Method to retrieve ID (0-xxx) of y-cluster (if any) associated to this track.
906     * If no cluster is associated, ID=-1.
907     * @param ip Tracker plane (0-5)
908     */
909    Int_t TrkTrack::GetClusterY_ID(int ip){
910        return ((Int_t)fabs(ygood[ip]))%10000000-1;
911    };
912    
913    /**
914     * Method to retrieve the ladder (0-4, increasing x) traversed by the track on this plane.
915     * If no ladder is traversed (dead area) the metod retuns -1.
916     * @param ip Tracker plane (0-5)
917     */
918    Int_t TrkTrack::GetLadder(int ip){
919        if(XGood(ip))return (Int_t)fabs(xgood[ip]/100000000)-1;
920        if(YGood(ip))return (Int_t)fabs(ygood[ip]/100000000)-1;
921        return -1;
922    };
923    /**
924     * Method to retrieve the sensor (0-1, increasing y) traversed by the track on this plane.
925     * If no sensor is traversed (dead area) the metod retuns -1.
926     * @param ip Tracker plane (0-5)
927     */
928    Int_t TrkTrack::GetSensor(int ip){
929        if(XGood(ip))return (Int_t)((Int_t)fabs(xgood[ip]/10000000)%10)-1;
930        if(YGood(ip))return (Int_t)((Int_t)fabs(ygood[ip]/10000000)%10)-1;
931        return -1;
932    };
933    
934    /**
935     * \brief Method to include a x-cluster to the track.
936     * @param ip Tracker plane (0-5)
937     * @param clid Cluster ID (0,1,...)
938     * @param is Sensor (0-1, increasing y)
939     * @see Fit(double pfixed, int& fail, int iprint, int froml1)
940     */
941    void TrkTrack::SetXGood(int ip, int clid, int is){
942        int il=0;       //ladder (temporary)
943        bool bad=false; //ladder (temporary)
944        xgood[ip]=il*100000000+is*10000000+clid;
945        if(bad)xgood[ip]=-xgood[ip];
946    };
947    /**
948     * \brief Method to include a y-cluster to the track.
949     * @param ip Tracker plane (0-5)
950     * @param clid Cluster ID (0,1,...)
951     * @param is Sensor (0-1)
952     * @see Fit(double pfixed, int& fail, int iprint, int froml1)
953     */
954    void TrkTrack::SetYGood(int ip, int clid, int is){
955        int il=0;       //ladder (temporary)
956        bool bad=false; //ladder (temporary)
957        ygood[ip]=il*100000000+is*10000000+clid;
958        if(bad)ygood[ip]=-ygood[ip];
959    };
960    
961  //--------------------------------------  //--------------------------------------
962  //  //
# Line 452  void TrkTrack::Clear(){ Line 980  void TrkTrack::Clear(){
980          zm[ip]     = 0;          zm[ip]     = 0;
981          resx[ip]   = 0;          resx[ip]   = 0;
982          resy[ip]   = 0;          resy[ip]   = 0;
983            tailx[ip]  = 0;
984            taily[ip]  = 0;
985          xv[ip]     = 0;          xv[ip]     = 0;
986          yv[ip]     = 0;          yv[ip]     = 0;
987          zv[ip]     = 0;          zv[ip]     = 0;
# Line 461  void TrkTrack::Clear(){ Line 991  void TrkTrack::Clear(){
991          dedx_y[ip] = 0;          dedx_y[ip] = 0;
992    
993      };      };
994      if(clx)clx->Clear();  //     if(clx)clx->Clear();
995      if(cly)cly->Clear();  //     if(cly)cly->Clear();
996    //    clx.Clear();
997    //    cly.Clear();
998  };  };
999  //--------------------------------------  //--------------------------------------
1000  //  //
# Line 470  void TrkTrack::Clear(){ Line 1002  void TrkTrack::Clear(){
1002  //--------------------------------------  //--------------------------------------
1003  void TrkTrack::Delete(){  void TrkTrack::Delete(){
1004  //    cout << "TrkTrack::Delete()"<<endl;  //    cout << "TrkTrack::Delete()"<<endl;
1005  //    Clear();      Clear();
1006      if(clx)delete clx;  //    if(clx)delete clx;
1007      if(cly)delete cly;  //    if(cly)delete cly;
1008  };  };
1009  //--------------------------------------  //--------------------------------------
1010  //  //
# Line 502  TrkSinglet::TrkSinglet(const TrkSinglet& Line 1034  TrkSinglet::TrkSinglet(const TrkSinglet&
1034      coord[1] = s.coord[1];      coord[1] = s.coord[1];
1035      sgnl     = s.sgnl;      sgnl     = s.sgnl;
1036  //      cls      = 0;//<<<<pointer  //      cls      = 0;//<<<<pointer
1037      cls      = TRef(s.cls);  //    cls      = TRef(s.cls);
1038  };  };
1039  //--------------------------------------  //--------------------------------------
1040  //  //
# Line 533  void TrkSinglet::Clear(){ Line 1065  void TrkSinglet::Clear(){
1065  //  //
1066  //--------------------------------------  //--------------------------------------
1067  TrkLevel2::TrkLevel2(){  TrkLevel2::TrkLevel2(){
1068  //    cout <<"TrkLevel2::TrkLevel2()"<<endl;    //    cout <<"TrkLevel2::TrkLevel2()"<<endl;
1069      for(Int_t i=0; i<12 ; i++){      for(Int_t i=0; i<12 ; i++){
1070                  good[i] = -1;          good[i] = -1;
1071          };          VKmask[i] = 0;
1072  //    Track    = new TClonesArray("TrkTrack");          VKflag[i] = 0;  
1073  //    SingletX = new TClonesArray("TrkSinglet");      };
 //    SingletY = new TClonesArray("TrkSinglet");  
1074      Track    = 0;      Track    = 0;
1075      SingletX = 0;      SingletX = 0;
1076      SingletY = 0;      SingletY = 0;
# Line 549  TrkLevel2::TrkLevel2(){ Line 1080  TrkLevel2::TrkLevel2(){
1080  //  //
1081  //  //
1082  //--------------------------------------  //--------------------------------------
1083    void TrkLevel2::Set(){
1084        if(!Track)Track    = new TClonesArray("TrkTrack");
1085        if(!SingletX)SingletX = new TClonesArray("TrkSinglet");
1086        if(!SingletY)SingletY = new TClonesArray("TrkSinglet");
1087    }
1088    //--------------------------------------
1089    //
1090    //
1091    //--------------------------------------
1092  void TrkLevel2::Dump(){  void TrkLevel2::Dump(){
1093                    
1094          //          //
1095      cout << endl << endl << "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-";      cout << endl << endl << "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-";
1096      cout << endl << "good     : "; for(int i=0; i<12; i++) cout << good[i]<<" ";      cout << endl << "good     : "; for(int i=0; i<12; i++) cout << hex <<" 0x"<< good[i]<<dec;
1097      cout << endl << "ntrk()   : " << this->ntrk() ;      cout << endl << "ntrk()   : " << ntrk() ;
1098      cout << endl << "nclsx()  : " << this->nclsx();      cout << endl << "nclsx()  : " << nclsx();
1099      cout << endl << "nclsy()  : " << this->nclsy();      cout << endl << "nclsy()  : " << nclsy();
 //     TClonesArray &t  = *Track;  
 //     TClonesArray &sx = *SingletX;  
 //     TClonesArray &sy = *SingletY;  
 //     for(int i=0; i<ntrk(); i++)     ((TrkTrack *)t[i])->Dump();  
 //     for(int i=0; i<nclsx(); i++) ((TrkSinglet *)sx[i])->Dump();  
 //     for(int i=0; i<nclsy(); i++) ((TrkSinglet *)sy[i])->Dump();  
1100      if(Track){      if(Track){
1101          TClonesArray &t  = *Track;          TClonesArray &t  = *Track;
1102          for(int i=0; i<ntrk(); i++)     ((TrkTrack *)t[i])->Dump();          for(int i=0; i<ntrk(); i++)     ((TrkTrack *)t[i])->Dump();
1103      }            }      
1104      if(SingletX){  //     if(SingletX){
1105          TClonesArray &sx = *SingletX;  //      TClonesArray &sx = *SingletX;
1106          for(int i=0; i<nclsx(); i++) ((TrkSinglet *)sx[i])->Dump();  //      for(int i=0; i<nclsx(); i++) ((TrkSinglet *)sx[i])->Dump();
1107      }  //     }
1108      if(SingletY){  //     if(SingletY){
1109          TClonesArray &sy = *SingletY;  //      TClonesArray &sy = *SingletY;
1110          for(int i=0; i<nclsy(); i++) ((TrkSinglet *)sy[i])->Dump();  //      for(int i=0; i<nclsy(); i++) ((TrkSinglet *)sy[i])->Dump();
1111      }  //     }
1112        cout << endl;
1113  }  }
1114    /**
1115     * \brief Dump processing status
1116     */
1117    void TrkLevel2::StatusDump(int view){
1118        cout << "DSP n. "<<view+1<<" status: "<<hex<<good[view]<<endl;    
1119    };
1120    /**
1121     * \brief Check event status
1122     *
1123     * Check the event status, according to a flag-mask given as input.
1124     * Return true if the view passes the check.
1125     *
1126     * @param view View number (0-11)
1127     * @param flagmask Mask of flags to check (eg. flagmask=0x111 no missing packet,
1128     *  no crc error, no software alarm)
1129     *
1130     * @see TrkLevel2 class definition to know how the status flag is defined
1131     *
1132     */
1133    Bool_t TrkLevel2::StatusCheck(int view, int flagmask){
1134    
1135        if( view<0 || view >= 12)return false;
1136        return !(good[view]&flagmask);
1137    
1138    };
1139    
1140    
1141  //--------------------------------------  //--------------------------------------
1142  //  //
1143  //  //
1144  //--------------------------------------  //--------------------------------------
1145  /**  /**
1146   * Fills a TrkLevel2 object with values from a struct cTrkLevel2 (to get data from F77 common).   * The method returns false if the viking-chip was masked  
1147     * either apriori ,on the basis of the mask read from the DB,
1148     * or run-by-run, on the basis of the calibration parameters)
1149     * @param iv Tracker view (0-11)
1150     * @param ivk Viking-chip number (0-23)
1151     */
1152    Bool_t TrkLevel2::GetVKMask(int iv, int ivk){
1153        Int_t whichbit = (Int_t)pow(2,ivk);
1154        return (whichbit&VKmask[iv])!=0;    
1155    }
1156    /**
1157     * The method returns false if the viking-chip was masked  
1158     * for this event due to common-noise computation failure.
1159     * @param iv Tracker view (0-11)
1160     * @param ivk Viking-chip number (0-23)
1161     */
1162    Bool_t TrkLevel2::GetVKFlag(int iv, int ivk){
1163        Int_t whichbit = (Int_t)pow(2,ivk);
1164        return (whichbit&VKflag[iv])!=0;    
1165    }
1166    /**
1167     * The method returns true if the viking-chip was masked, either
1168     * forced (see TrkLevel2::GetVKMask(int,int)) or
1169     * for this event only (TrkLevel2::GetVKFlag(int,int)).
1170     * @param iv Tracker view (0-11)
1171     * @param ivk Viking-chip number (0-23)
1172   */   */
1173  void TrkLevel2::SetFromLevel2Struct(cTrkLevel2 *l2){  Bool_t TrkLevel2::IsMaskedVK(int iv, int ivk){
1174        return !(GetVKMask(iv,ivk)&&GetVKFlag(iv,ivk) );
1175    };
1176    
1177          //  temporary objects:  //--------------------------------------
1178    //
1179    //
1180    //--------------------------------------
1181    /**
1182     * Fills a TrkLevel2 object with values from a struct cTrkLevel2 (to get data from F77 common).
1183     * Ref to Level1 data (clusters) is also set. If l1==NULL no references are set.
1184     * (NB It make sense to set references only if events are stored in a tree that contains also the Level1 branch)
1185     */
1186    void TrkLevel2::SetFromLevel2Struct(cTrkLevel2 *l2, TrkLevel1 *l1){
1187    
1188    //    cout << "void TrkLevel2::SetFromLevel2Struct(cTrkLevel2 *l2, TrkLevel1 *l1)"<<endl;
1189        Clear();
1190    
1191    //  temporary objects:
1192      TrkSinglet* t_singlet = new TrkSinglet();      TrkSinglet* t_singlet = new TrkSinglet();
1193      TrkTrack*   t_track   = new TrkTrack();      TrkTrack*   t_track   = new TrkTrack();
1194    
1195          //  **** general variables ****  //  -----------------
1196  //    good2 = l2->good2;  //  general variables
1197    //  -----------------
1198      for(Int_t i=0; i<12 ; i++){      for(Int_t i=0; i<12 ; i++){
1199  //              crc[i] = l2->crc[i];          good[i] = l2->good[i];
1200                  good[i] = l2->good[i];          VKmask[i]=0;
1201            VKflag[i]=0;
1202            for(Int_t ii=0; ii<24 ; ii++){
1203                Int_t setbit = (Int_t)pow(2,ii);
1204                if( l2->vkflag[ii][i]!=-1 )VKmask[i]=VKmask[i]|setbit;
1205                if( l2->vkflag[ii][i]!=0  )VKflag[i]=VKflag[i]|setbit;
1206          };          };
1207          //  *** TRACKS ***      };
1208    //  --------------
1209    //  *** TRACKS ***
1210    //  --------------
1211      if(!Track) Track = new TClonesArray("TrkTrack");      if(!Track) Track = new TClonesArray("TrkTrack");
1212      TClonesArray &t = *Track;      TClonesArray &t = *Track;
1213    
1214      for(int i=0; i<l2->ntrk; i++){      for(int i=0; i<l2->ntrk; i++){
1215          t_track->seqno = i;// NBNBNBNB deve sempre essere = i          t_track->seqno = i;// NBNBNBNB deve sempre essere = i
1216          t_track->image = l2->image[i]-1;          t_track->image = l2->image[i]-1;
         //      cout << "track "<<i<<t_track->seqno << t_track->image<<endl;  
1217          t_track->chi2  = l2->chi2_nt[i];          t_track->chi2  = l2->chi2_nt[i];
1218          t_track->nstep = l2->nstep_nt[i];          t_track->nstep = l2->nstep_nt[i];
1219          for(int it1=0;it1<5;it1++){          for(int it1=0;it1<5;it1++){
# Line 610  void TrkLevel2::SetFromLevel2Struct(cTrk Line 1222  void TrkLevel2::SetFromLevel2Struct(cTrk
1222                  t_track->coval[it1][it2] = l2->coval[i][it2][it1];                  t_track->coval[it1][it2] = l2->coval[i][it2][it1];
1223          };          };
1224          for(int ip=0;ip<6;ip++){          for(int ip=0;ip<6;ip++){
1225              t_track->xgood[ip]  = l2->xgood_nt[i][ip];              // ---------------------------------
1226              t_track->ygood[ip]  = l2->ygood_nt[i][ip];              // new implementation of xgood/ygood
1227                // ---------------------------------
1228                t_track->xgood[ip]  = l2->cltrx[i][ip]; //cluster ID
1229                t_track->ygood[ip]  = l2->cltry[i][ip]; //cluster ID
1230                t_track->xgood[ip] += 10000000*l2->ls[i][ip]; // ladder+sensor
1231                t_track->ygood[ip] += 10000000*l2->ls[i][ip]; // ladder+sensor
1232                if(l2->xbad[i][ip]>0)t_track->xgood[ip]=-t_track->xgood[ip];
1233                if(l2->ybad[i][ip]>0)t_track->ygood[ip]=-t_track->ygood[ip];
1234    //          if(l2->xbad[i][ip]>0 || l2->ybad[i][ip]>0){
1235    //          if(l2->dedx_x[i][ip]<0 || l2->dedx_y[i][ip]<0){
1236    //              cout << ip << " - "<< l2->cltrx[i][ip] << " "<<l2->cltry[i][ip]<<" "<<l2->ls[i][ip]<<endl;
1237    //              cout << ip << " - "<<t_track->xgood[ip]<<" "<<t_track->ygood[ip]<<endl;
1238    //              cout << ip << " - "<<t_track->GetClusterX_ID(ip)<<" "<<t_track->GetClusterY_ID(ip)<<" "<<t_track->GetLadder(ip)<<" "<<t_track->GetSensor(ip)<<endl;
1239    //              cout << ip << " - "<<t_track->BadClusterX(ip)<<" "<<t_track->BadClusterY(ip)<<endl;
1240    //              cout << ip << " - "<<t_track->SaturatedClusterX(ip)<<" "<<t_track->SaturatedClusterY(ip)<<endl;
1241    //          }
1242              t_track->xm[ip]     = l2->xm_nt[i][ip];              t_track->xm[ip]     = l2->xm_nt[i][ip];
1243              t_track->ym[ip]     = l2->ym_nt[i][ip];              t_track->ym[ip]     = l2->ym_nt[i][ip];
1244              t_track->zm[ip]     = l2->zm_nt[i][ip];              t_track->zm[ip]     = l2->zm_nt[i][ip];
1245              t_track->resx[ip]   = l2->resx_nt[i][ip];              t_track->resx[ip]   = l2->resx_nt[i][ip];
1246              t_track->resy[ip]   = l2->resy_nt[i][ip];              t_track->resy[ip]   = l2->resy_nt[i][ip];
1247                t_track->tailx[ip]  = l2->tailx[i][ip];
1248                t_track->taily[ip]  = l2->taily[i][ip];
1249              t_track->xv[ip]     = l2->xv_nt[i][ip];              t_track->xv[ip]     = l2->xv_nt[i][ip];
1250              t_track->yv[ip]     = l2->yv_nt[i][ip];              t_track->yv[ip]     = l2->yv_nt[i][ip];
1251              t_track->zv[ip]     = l2->zv_nt[i][ip];              t_track->zv[ip]     = l2->zv_nt[i][ip];
# Line 624  void TrkLevel2::SetFromLevel2Struct(cTrk Line 1253  void TrkLevel2::SetFromLevel2Struct(cTrk
1253              t_track->ayv[ip]    = l2->ayv_nt[i][ip];              t_track->ayv[ip]    = l2->ayv_nt[i][ip];
1254              t_track->dedx_x[ip] = l2->dedx_x[i][ip];              t_track->dedx_x[ip] = l2->dedx_x[i][ip];
1255              t_track->dedx_y[ip] = l2->dedx_y[i][ip];              t_track->dedx_y[ip] = l2->dedx_y[i][ip];
1256  //                      t_track->clx[ip] = 0;              t_track->multmaxx[ip] = l2->multmaxx[i][ip];
1257  //                      t_track->cly[ip] = 0;              t_track->multmaxy[ip] = l2->multmaxy[i][ip];
1258                t_track->seedx[ip]  = l2->seedx[i][ip];  
1259                t_track->seedy[ip]  = l2->seedy[i][ip];
1260                t_track->xpu[ip]    = l2->xpu[i][ip];  
1261                t_track->ypu[ip]    = l2->ypu[i][ip];  
1262                //-----------------------------------------------------
1263                //-----------------------------------------------------
1264                //-----------------------------------------------------
1265                //-----------------------------------------------------
1266          };          };
1267    //      if(t_track->IsSaturated())t_track->Dump();
1268          new(t[i]) TrkTrack(*t_track);          new(t[i]) TrkTrack(*t_track);
1269          t_track->Clear();          t_track->Clear();
1270      };      };
1271    
1272    //  ----------------
1273  //  *** SINGLETS ***  //  *** SINGLETS ***
1274    //  ----------------
1275      if(!SingletX)SingletX = new TClonesArray("TrkSinglet");      if(!SingletX)SingletX = new TClonesArray("TrkSinglet");
1276      TClonesArray &sx = *SingletX;      TClonesArray &sx = *SingletX;
1277      for(int i=0; i<l2->nclsx; i++){      for(int i=0; i<l2->nclsx; i++){
# Line 638  void TrkLevel2::SetFromLevel2Struct(cTrk Line 1279  void TrkLevel2::SetFromLevel2Struct(cTrk
1279          t_singlet->coord[0] = l2->xs[i][0];          t_singlet->coord[0] = l2->xs[i][0];
1280          t_singlet->coord[1] = l2->xs[i][1];          t_singlet->coord[1] = l2->xs[i][1];
1281          t_singlet->sgnl     = l2->signlxs[i];          t_singlet->sgnl     = l2->signlxs[i];
1282  //              t_singlet->cls      = 0;          //-----------------------------------------------------
1283    //      if(l1) t_singlet->cls      = l1->GetCluster(l2->clsx[i]-1);
1284            //-----------------------------------------------------
1285          new(sx[i]) TrkSinglet(*t_singlet);          new(sx[i]) TrkSinglet(*t_singlet);
1286          t_singlet->Clear();          t_singlet->Clear();
1287      }      }
# Line 649  void TrkLevel2::SetFromLevel2Struct(cTrk Line 1292  void TrkLevel2::SetFromLevel2Struct(cTrk
1292          t_singlet->coord[0] = l2->ys[i][0];          t_singlet->coord[0] = l2->ys[i][0];
1293          t_singlet->coord[1] = l2->ys[i][1];          t_singlet->coord[1] = l2->ys[i][1];
1294          t_singlet->sgnl     = l2->signlys[i];          t_singlet->sgnl     = l2->signlys[i];
1295  //              t_singlet->cls      = 0;          //-----------------------------------------------------
1296    //      if(l1) t_singlet->cls      = l1->GetCluster(l2->clsy[i]-1);
1297            //-----------------------------------------------------
1298          new(sy[i]) TrkSinglet(*t_singlet);          new(sy[i]) TrkSinglet(*t_singlet);
1299          t_singlet->Clear();          t_singlet->Clear();
1300      };      };
# Line 657  void TrkLevel2::SetFromLevel2Struct(cTrk Line 1302  void TrkLevel2::SetFromLevel2Struct(cTrk
1302      delete t_track;      delete t_track;
1303      delete t_singlet;      delete t_singlet;
1304  }  }
 //--------------------------------------  
 //  
 //  
 //--------------------------------------  
 /**  
  * Fills a TrkLevel2 object with values from a struct cTrkLevel2 (to get data from F77 common).  
  * Ref to Level1 data (clusters) is also set.  
  */  
 void TrkLevel2::SetFromLevel2Struct(cTrkLevel2 *l2, TrkLevel1 *l1){  
   
 //  temporary objects:  
         TrkSinglet* t_singlet = new TrkSinglet();  
         TrkTrack*   t_track   = new TrkTrack();  
 // general variables  
 //      good2 = l2->good2;  
         for(Int_t i=0; i<12 ; i++){  
 //              crc[i] = l2->crc[i];  
                 good[i] = l2->good[i];  
         };  
 // *** TRACKS ***  
         if(!Track) Track = new TClonesArray("TrkTrack");  
         TClonesArray &t = *Track;  
         if(!t_track->clx)t_track->clx = new TRefArray(6,0);  
         if(!t_track->cly)t_track->cly = new TRefArray(6,0);  
         for(int i=0; i<l2->ntrk; i++){  
                 t_track->seqno = i;// NBNBNBNB deve sempre essere = i  
                 t_track->image = l2->image[i]-1;  
 //              cout << "track "<<i<<t_track->seqno << t_track->image<<endl;  
                 t_track->chi2  = l2->chi2_nt[i];  
                 t_track->nstep = l2->nstep_nt[i];  
                 for(int it1=0;it1<5;it1++){  
                         t_track->al[it1] = l2->al_nt[i][it1];  
                         for(int it2=0;it2<5;it2++)  
                                 t_track->coval[it1][it2] = l2->coval[i][it2][it1];  
                 };  
                 for(int ip=0;ip<6;ip++){  
                         t_track->xgood[ip]  = l2->xgood_nt[i][ip];  
                         t_track->ygood[ip]  = l2->ygood_nt[i][ip];  
                         t_track->xm[ip]     = l2->xm_nt[i][ip];  
                         t_track->ym[ip]     = l2->ym_nt[i][ip];  
                         t_track->zm[ip]     = l2->zm_nt[i][ip];  
                         t_track->resx[ip]   = l2->resx_nt[i][ip];  
                         t_track->resy[ip]   = l2->resy_nt[i][ip];  
                         t_track->xv[ip]     = l2->xv_nt[i][ip];  
                         t_track->yv[ip]     = l2->yv_nt[i][ip];  
                         t_track->zv[ip]     = l2->zv_nt[i][ip];  
                         t_track->axv[ip]    = l2->axv_nt[i][ip];  
                         t_track->ayv[ip]    = l2->ayv_nt[i][ip];  
                         t_track->dedx_x[ip] = l2->dedx_x[i][ip];  
                         t_track->dedx_y[ip] = l2->dedx_y[i][ip];  
 //                      cout << "traccia "<<i<<"  --  "<< ip << " "<< l2->cltrx[i][ip] <<" "<< l2->cltry[i][ip] <<" "<< t_track->xgood[ip] << t_track->ygood[ip]<<endl;  
                         //-----------------------------------------------------  
                         //-----------------------------------------------------  
                         if(t_track->xgood[ip])t_track->clx->AddAt(l1->GetCluster(l2->cltrx[i][ip]-1),ip);  
                         if(t_track->ygood[ip])t_track->cly->AddAt(l1->GetCluster(l2->cltry[i][ip]-1),ip);  
 //                      if(t_track->ygood[ip])cout<<" i "<<i<<" ip "<<ip<<" l2->cltry[i][ip] "<<l2->cltry[i][ip]<< " l1->GetCluster(l2->cltry[i][ip]-1) "<<l1->GetCluster(l2->cltry[i][ip]-1)<<endl;  
 //                      if(t_track->xgood[ip])cout<<" i "<<i<<" ip "<<ip<<" l2->cltrx[i][ip] "<<l2->cltrx[i][ip]<< " l1->GetCluster(l2->cltrx[i][ip]-1) "<<l1->GetCluster(l2->cltrx[i][ip]-1)<<endl;  
                         //-----------------------------------------------------  
                         //-----------------------------------------------------  
                 };  
                 new(t[i]) TrkTrack(*t_track);  
                 t_track->Clear();  
         };  
 // *** SINGLETS ***  
         if(!SingletX)SingletX = new TClonesArray("TrkSinglet");  
         TClonesArray &sx = *SingletX;  
         for(int i=0; i<l2->nclsx; i++){  
                 t_singlet->plane    = l2->planex[i];  
                 t_singlet->coord[0] = l2->xs[i][0];  
                 t_singlet->coord[1] = l2->xs[i][1];  
                 t_singlet->sgnl     = l2->signlxs[i];  
                 //-----------------------------------------------------  
 //              cout << "singolo x "<<i<<"  --  "<<  l2->clsx[i] <<endl;  
                 t_singlet->cls      = l1->GetCluster(l2->clsx[i]-1);  
 //              cout<<" i "<<i<<" l2->clsx[i] "<<l2->clsx[i]<< " l1->GetCluster(l2->clsx[i]-1) "<<l1->GetCluster(l2->clsx[i]-1)<<endl;            
                 //-----------------------------------------------------  
                 new(sx[i]) TrkSinglet(*t_singlet);  
                 t_singlet->Clear();  
         }  
         if(!SingletY)SingletY = new TClonesArray("TrkSinglet");  
         TClonesArray &sy = *SingletY;  
         for(int i=0; i<l2->nclsy; i++){  
                 t_singlet->plane    = l2->planey[i];  
                 t_singlet->coord[0] = l2->ys[i][0];  
                 t_singlet->coord[1] = l2->ys[i][1];  
                 t_singlet->sgnl     = l2->signlys[i];  
                 //-----------------------------------------------------  
 //              cout << "singolo y "<<i<<"  --  "<<  l2->clsy[i] <<endl;  
                 t_singlet->cls      = l1->GetCluster(l2->clsy[i]-1);  
 //              cout<<" i "<<i<<" l2->clsy[i] "<<l2->clsy[i]<< " l1->GetCluster(l2->clsy[i]-1) "<<l1->GetCluster(l2->clsy[i]-1)<<endl;            
                 //-----------------------------------------------------  
                 new(sy[i]) TrkSinglet(*t_singlet);  
                 t_singlet->Clear();  
         };  
           
         delete t_track;  
         delete t_singlet;  
 }  
1305  /**  /**
1306   * Fills a struct cTrkLevel2 with values from a TrkLevel2 object (to put data into a F77 common).   * Fills a struct cTrkLevel2 with values from a TrkLevel2 object (to put data into a F77 common).
1307   */   */
# Line 781  void TrkLevel2::GetLevel2Struct(cTrkLeve Line 1328  void TrkLevel2::GetLevel2Struct(cTrkLeve
1328                      l2->coval[i][it2][it1] = ((TrkTrack *)Track->At(i))->coval[it1][it2];                      l2->coval[i][it2][it1] = ((TrkTrack *)Track->At(i))->coval[it1][it2];
1329              };              };
1330              for(int ip=0;ip<6;ip++){              for(int ip=0;ip<6;ip++){
1331                  l2->xgood_nt[i][ip] = ((TrkTrack *)Track->At(i))->xgood[ip];                  l2->xgood_nt[i][ip] = ((TrkTrack *)Track->At(i))->XGood(ip);
1332                  l2->ygood_nt[i][ip] = ((TrkTrack *)Track->At(i))->ygood[ip];                  l2->ygood_nt[i][ip] = ((TrkTrack *)Track->At(i))->YGood(ip);
1333                  l2->xm_nt[i][ip]    = ((TrkTrack *)Track->At(i))->xm[ip];                  l2->xm_nt[i][ip]    = ((TrkTrack *)Track->At(i))->xm[ip];
1334                  l2->ym_nt[i][ip]    = ((TrkTrack *)Track->At(i))->ym[ip];                  l2->ym_nt[i][ip]    = ((TrkTrack *)Track->At(i))->ym[ip];
1335                  l2->zm_nt[i][ip]    = ((TrkTrack *)Track->At(i))->zm[ip];                  l2->zm_nt[i][ip]    = ((TrkTrack *)Track->At(i))->zm[ip];
1336                  l2->resx_nt[i][ip]  = ((TrkTrack *)Track->At(i))->resx[ip];                  l2->resx_nt[i][ip]  = ((TrkTrack *)Track->At(i))->resx[ip];
1337                  l2->resy_nt[i][ip]  = ((TrkTrack *)Track->At(i))->resy[ip];                  l2->resy_nt[i][ip]  = ((TrkTrack *)Track->At(i))->resy[ip];
1338                    l2->tailx[i][ip]  = ((TrkTrack *)Track->At(i))->tailx[ip];
1339                    l2->taily[i][ip]  = ((TrkTrack *)Track->At(i))->taily[ip];
1340                  l2->xv_nt[i][ip]    = ((TrkTrack *)Track->At(i))->xv[ip];                  l2->xv_nt[i][ip]    = ((TrkTrack *)Track->At(i))->xv[ip];
1341                  l2->yv_nt[i][ip]    = ((TrkTrack *)Track->At(i))->yv[ip];                  l2->yv_nt[i][ip]    = ((TrkTrack *)Track->At(i))->yv[ip];
1342                  l2->zv_nt[i][ip]    = ((TrkTrack *)Track->At(i))->zv[ip];                  l2->zv_nt[i][ip]    = ((TrkTrack *)Track->At(i))->zv[ip];
# Line 826  void TrkLevel2::GetLevel2Struct(cTrkLeve Line 1375  void TrkLevel2::GetLevel2Struct(cTrkLeve
1375  void TrkLevel2::Clear(){  void TrkLevel2::Clear(){
1376      for(Int_t i=0; i<12 ; i++){      for(Int_t i=0; i<12 ; i++){
1377          good[i] = -1;          good[i] = -1;
1378            VKflag[i] = 0;
1379            VKmask[i] = 0;
1380      };      };
1381  //    if(Track)Track->Clear("C");  //    if(Track)Track->Clear("C");
1382  //    if(SingletX)SingletX->Clear("C");  //    if(SingletX)SingletX->Clear("C");
# Line 869  TRefArray *TrkLevel2::GetTracks_NFitSort Line 1420  TRefArray *TrkLevel2::GetTracks_NFitSort
1420                    
1421      int indo=0;      int indo=0;
1422      int indi=0;      int indi=0;
1423      while(N != 0){      while(N > 0){
1424    //    while(N != 0){
1425          int nfit =0;          int nfit =0;
1426          float chi2ref = numeric_limits<float>::max();          float chi2ref = numeric_limits<float>::max();
1427                                    
# Line 880  TRefArray *TrkLevel2::GetTracks_NFitSort Line 1432  TRefArray *TrkLevel2::GetTracks_NFitSort
1432              }              }
1433          }          }
1434          //second loop to search minimum chi2 among selected          //second loop to search minimum chi2 among selected
1435          for(int i=0; i<this->ntrk(); i++){          for(int i=0; i<ntrk(); i++){
1436              Float_t chi2 = ((TrkTrack *)t[i])->chi2;              Float_t chi2 = ((TrkTrack *)t[i])->chi2;
1437              if(chi2 < 0) chi2 = chi2*1000;              if(chi2 < 0) chi2 = -chi2*1000;
1438              if(    chi2 < chi2ref              if(    chi2 < chi2ref
1439                     && ((TrkTrack *)t[i])->GetNtot() == nfit                     && ((TrkTrack *)t[i])->GetNtot() == nfit
1440                     && m[i]==1){                     && m[i]==1){
# Line 894  TRefArray *TrkLevel2::GetTracks_NFitSort Line 1446  TRefArray *TrkLevel2::GetTracks_NFitSort
1446              m[((TrkTrack *)t[indi])->image] = 0;              m[((TrkTrack *)t[indi])->image] = 0;
1447              N--;              N--;
1448                    
1449              //      cout << "i** "<< ((TrkTrack *)t[indi])->image << " " << nfiti <<" "<<chi2i<<endl;  //          cout << "i** "<< ((TrkTrack *)t[indi])->image << " " << nfiti <<" "<<chi2i<<endl;
1450          };          };
1451          sorted->Add( (TrkTrack*)t[indi] );                sorted->Add( (TrkTrack*)t[indi] );      
1452                                    
1453          m[indi] = 0;          m[indi] = 0;
1454  //              cout << "SORTED "<< indo << " "<< indi << " "<< N << endl;  //      cout << "SORTED "<< indo << " "<< indi << " "<< N << " "<<((TrkTrack *)t[indi])->image<<" "<<chi2ref<<endl;
1455          N--;              N--;    
1456          indo++;          indo++;
1457      }      }
1458      m.clear();      m.clear();
1459  //      cout << "GetTracks_NFitSorted(it): Done"<< endl;  //    cout << "GetTracks_NFitSorted(it): Done"<< endl;
1460    
1461      return sorted;      return sorted;
1462  //    return PhysicalTrack;  //    return PhysicalTrack;
# Line 1054  TrkTrack *TrkLevel2::GetTrackImage(int i Line 1606  TrkTrack *TrkLevel2::GetTrackImage(int i
1606   */   */
1607  void TrkLevel2::LoadField(TString path){  void TrkLevel2::LoadField(TString path){
1608  //  //
1609      strcpy(path_.path,path.Data());  //     strcpy(path_.path,path.Data());
1610      path_.pathlen = path.Length();  //     path_.pathlen = path.Length();
1611      path_.error   = 0;  //     path_.error   = 0;
1612      readb_();  //     readb_();
1613    
1614        TrkParams::SetTrackingMode();
1615        TrkParams::SetPrecisionFactor();
1616        TrkParams::SetStepMin();
1617    
1618        TrkParams::Set(path,1);
1619        TrkParams::Load(1);
1620    
1621  //  //
1622  };  };
1623    // /**
1624    //  * Get BY (kGauss)
1625    //  * @param v (x,y,z) coordinates in cm
1626    //  */
1627    // float TrkLevel2::GetBX(float* v){
1628    //     float b[3];
1629    //     gufld_(v,b);
1630    //     return b[0]/10.;
1631    // }
1632    // /**
1633    //  * Get BY (kGauss)
1634    //  * @param v (x,y,z) coordinates in cm
1635    //  */
1636    // float TrkLevel2::GetBY(float* v){
1637    //     float b[3];
1638    //     gufld_(v,b);
1639    //     return b[1]/10.;
1640    // }
1641    // /**
1642    //  * Get BY (kGauss)
1643    //  * @param v (x,y,z) coordinates in cm
1644    //  */
1645    // float TrkLevel2::GetBZ(float* v){
1646    //     float b[3];
1647    //     gufld_(v,b);
1648    //     return b[2]/10.;
1649    // }
1650  //--------------------------------------  //--------------------------------------
1651  //  //
1652  //  //
# Line 1237  int Trajectory::DoTrack2(float* al){ Line 1824  int Trajectory::DoTrack2(float* al){
1824      for (int i=0; i<5; i++)      dal[i]  = (double)al[i];      for (int i=0; i<5; i++)      dal[i]  = (double)al[i];
1825      for (int i=0; i<npoint; i++) dzin[i] = (double)z[i];      for (int i=0; i<npoint; i++) dzin[i] = (double)z[i];
1826    
1827        TrkParams::Load(1);
1828        if( !TrkParams::IsLoaded(1) ){
1829            cout << "int Trajectory::DoTrack2(float* al) --- ERROR --- m.field not loaded"<<endl;
1830            return 0;
1831        }
1832      dotrack2_(&(npoint),dzin,dxout,dyout,dthxout,dthyout,dtlout,dal,&ifail);      dotrack2_(&(npoint),dzin,dxout,dyout,dthxout,dthyout,dtlout,dal,&ifail);
1833            
1834      for (int i=0; i<npoint; i++){      for (int i=0; i<npoint; i++){

Legend:
Removed from v.1.22  
changed lines
  Added in v.1.40

  ViewVC Help
Powered by ViewVC 1.1.23