/[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.32 by pam-fi, Fri Apr 27 10:39:57 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*);
15       void mini2_(int*,int*,int*);      void mini2_(int*,int*,int*);
16       void guess_();      void guess_();
17       void gufld_(float*, float*);      void gufld_(float*, float*);
18        float risxeta2_(float *);
19        float risxeta3_(float *);
20        float risxeta4_(float *);
21        float risyeta2_(float *);
22  }  }
23    
24  //--------------------------------------  //--------------------------------------
# Line 48  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  //    clx = new TRefArray(6,0); //forse causa memory leak???      TrkParams::SetPrecisionFactor();
66  //    cly = new TRefArray(6,0); //forse causa memory leak???      TrkParams::SetStepMin();
67  //    clx = TRefArray(6,0);      TrkParams::SetPFA();
 //    cly = TRefArray(6,0);  
68    
69  };  };
70  //--------------------------------------  //--------------------------------------
# Line 87  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  //    clx = TRefArray(t.clx);      TrkParams::SetPFA();
 //    cly = TRefArray(t.cly);  
112    
113  };  };
114  //--------------------------------------  //--------------------------------------
# Line 127  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    
 //    t.clx = TRefArray(clx);  
 //    t.cly = TRefArray(cly);  
154            
155  };  };
156  //--------------------------------------  //--------------------------------------
# Line 351  Int_t TrkTrack::GetLeverArmY(){ Line 370  Int_t TrkTrack::GetLeverArmY(){
370      }      }
371      return (last_plane-first_plane+1);      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  //--------------------------------------  //--------------------------------------
471  //  //
472  //  //
# Line 372  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 379  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 397  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      // NB! si perdera` l'informazione sul numero del cluster  
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 415  void TrkTrack::LoadField(TString path){ Line 621  void TrkTrack::LoadField(TString path){
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);      TrkParams::Set(path,1);
629      TrkParams::Load(1);      TrkParams::Load(1);
630    
# Line 428  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);          track.xgood[i]=XGood(i);
644          track.ygood[i]=YGood(i);          track.ygood[i]=YGood(i);
645                    
# Line 455  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 486  void TrkTrack::SetFromMiniStruct(cMini2t Line 698  void TrkTrack::SetFromMiniStruct(cMini2t
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 514  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);  //     TrkParams::Load(1);
822      if( !TrkParams::IsLoaded(1) ){  //     if( !TrkParams::IsLoaded(1) ){
823          cout << "void TrkTrack::Fit(double pfixed, int& fail, int iprint) --- ERROR --- m.field not loaded"<<endl;  //      cout << "void TrkTrack::Fit(double pfixed, int& fail, int iprint) --- ERROR --- m.field not loaded"<<endl;
824          return;  //      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 529  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   * Set the tracking mode
861   */   */
862  void TrkTrack::SetTrackingMode(int trackmode){  void TrkTrack::SetTrackingMode(int trackmode){
863      extern cMini2track track_;      extern cMini2track track_;
864      track_.trackmode = trackmode;      track_.trackmode = trackmode;
865  }  }
866  /*  /**
867   * Set the factor scale for tracking precision   * Set the factor scale for tracking precision
868   */   */
869  void TrkTrack::SetPrecisionFactor(double fact){  void TrkTrack::SetPrecisionFactor(double fact){
870      extern cMini2track track_;      extern cMini2track track_;
871      track_.fact = fact;      track_.fact = fact;
872  }  }
873  /*  /**
874   * Set the factor scale for tracking precision   * Set the minimum number of steps for tracking precision
875   */   */
876  void TrkTrack::SetStepMin(int istepmin){  void TrkTrack::SetStepMin(int istepmin){
877      extern cMini2track track_;      extern cMini2track track_;
878      track_.istepmin = istepmin;      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.   * Method to retrieve ID (0,1,...) of x-cluster (if any) associated to this track.
898   * If no cluster is associated, ID=-1.   * If no cluster is associated, ID=-1.
899   * @param ip Tracker plane (0-5)   * @param ip Tracker plane (0-5)
# Line 596  void TrkTrack::SetStepMin(int istepmin){ Line 901  void TrkTrack::SetStepMin(int istepmin){
901  Int_t TrkTrack::GetClusterX_ID(int ip){  Int_t TrkTrack::GetClusterX_ID(int ip){
902      return ((Int_t)fabs(xgood[ip]))%10000000-1;      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.   * Method to retrieve ID (0-xxx) of y-cluster (if any) associated to this track.
906   * If no cluster is associated, ID=-1.   * If no cluster is associated, ID=-1.
907   * @param ip Tracker plane (0-5)   * @param ip Tracker plane (0-5)
# Line 604  Int_t TrkTrack::GetClusterX_ID(int ip){ Line 909  Int_t TrkTrack::GetClusterX_ID(int ip){
909  Int_t TrkTrack::GetClusterY_ID(int ip){  Int_t TrkTrack::GetClusterY_ID(int ip){
910      return ((Int_t)fabs(ygood[ip]))%10000000-1;      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.   * 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.   * If no ladder is traversed (dead area) the metod retuns -1.
916   * @param ip Tracker plane (0-5)   * @param ip Tracker plane (0-5)
# Line 614  Int_t TrkTrack::GetLadder(int ip){ Line 920  Int_t TrkTrack::GetLadder(int ip){
920      if(YGood(ip))return (Int_t)fabs(ygood[ip]/100000000)-1;      if(YGood(ip))return (Int_t)fabs(ygood[ip]/100000000)-1;
921      return -1;      return -1;
922  };  };
923  /*  /**
924   * Method to retrieve the sensor (0-1, increasing y) traversed by the track on this plane.   * 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.   * If no sensor is traversed (dead area) the metod retuns -1.
926   * @param ip Tracker plane (0-5)   * @param ip Tracker plane (0-5)
# Line 625  Int_t TrkTrack::GetSensor(int ip){ Line 931  Int_t TrkTrack::GetSensor(int ip){
931      return -1;      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 761  void TrkLevel2::Dump(){ Line 1093  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();
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  //  //
# Line 893  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->multmaxx[ip] = l2->multmaxx[i][ip];
1257                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              //-----------------------------------------------------              //-----------------------------------------------------
# Line 1245  void TrkLevel2::LoadField(TString path){ Line 1611  void TrkLevel2::LoadField(TString path){
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);      TrkParams::Set(path,1);
1619      TrkParams::Load(1);      TrkParams::Load(1);
1620    
1621  //  //
1622  };  };
1623  /**  // /**
1624   * Get BY (kGauss)  //  * Get BY (kGauss)
1625   * @param v (x,y,z) coordinates in cm  //  * @param v (x,y,z) coordinates in cm
1626   */  //  */
1627  float TrkLevel2::GetBX(float* v){  // float TrkLevel2::GetBX(float* v){
1628      float b[3];  //     float b[3];
1629      gufld_(v,b);  //     gufld_(v,b);
1630      return b[0]/10.;  //     return b[0]/10.;
1631  }  // }
1632  /**  // /**
1633   * Get BY (kGauss)  //  * Get BY (kGauss)
1634   * @param v (x,y,z) coordinates in cm  //  * @param v (x,y,z) coordinates in cm
1635   */  //  */
1636  float TrkLevel2::GetBY(float* v){  // float TrkLevel2::GetBY(float* v){
1637      float b[3];  //     float b[3];
1638      gufld_(v,b);  //     gufld_(v,b);
1639      return b[1]/10.;  //     return b[1]/10.;
1640  }  // }
1641  /**  // /**
1642   * Get BY (kGauss)  //  * Get BY (kGauss)
1643   * @param v (x,y,z) coordinates in cm  //  * @param v (x,y,z) coordinates in cm
1644   */  //  */
1645  float TrkLevel2::GetBZ(float* v){  // float TrkLevel2::GetBZ(float* v){
1646      float b[3];  //     float b[3];
1647      gufld_(v,b);  //     gufld_(v,b);
1648      return b[2]/10.;  //     return b[2]/10.;
1649  }  // }
1650  //--------------------------------------  //--------------------------------------
1651  //  //
1652  //  //

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

  ViewVC Help
Powered by ViewVC 1.1.23