/[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.33 by pam-fi, Mon May 14 11:03:05 2007 UTC revision 1.36 by pam-fi, Thu May 24 16:45:48 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*);
18        float risxeta2_(float *);
19        float risxeta3_(float *);
20        float risxeta4_(float *);
21        float risyeta2_(float *);
22  }  }
23    
24  //--------------------------------------  //--------------------------------------
# Line 381  void TrkTrack::Dump(){ Line 386  void TrkTrack::Dump(){
386      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] << " ";
387      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] << " ";
388      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] << " ";
389        cout << endl << "tailx    : "; for(int i=0; i<6; i++)cout << tailx[i] << " ";
390        cout << endl << "taily    : "; for(int i=0; i<6; i++)cout << taily[i] << " ";
391      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]<<" ";
392      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]<<" ";
393      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 406  void TrkTrack::SetResolution(double *rx, Line 413  void TrkTrack::SetResolution(double *rx,
413      for(int i=0; i<6; i++) resy[i]=*ry++;      for(int i=0; i<6; i++) resy[i]=*ry++;
414  }  }
415  /**  /**
416   * Set the TrkTrack good measurement.   * Set the TrkTrack tails position resolution
417     */
418    void TrkTrack::SetTail(double *tx, double *ty, double factor){
419        for(int i=0; i<6; i++) tailx[i]=factor*(*tx++);
420        for(int i=0; i<6; i++) taily[i]=factor*(*ty++);
421    }
422    /**
423     * Set the TrkTrack Student parameter (resx,resy,tailx,taily)
424     * from previous gausian fit
425     *@param flag =0 standard, =1 with noise correction
426     */
427    void TrkTrack::SetStudentParam(int flag){
428        float sx[11]={0.000128242,
429                       0.000136942,
430                       0.000162718,
431                       0.000202644,
432                       0.00025597,
433                       0.000317456,
434                       0.000349048,
435                       0.000384638,
436                       0.000457295,
437                       0.000512319,
438                       0.000538573};
439        float tx[11]={1.79402,
440                       2.04876,
441                       2.88376,
442                       3.3,
443                       3.14084,
444                       4.07686,
445                       4.44736,
446                       3.5179,
447                       3.38697,
448                       3.45739,
449                       3.18627};
450        float sy[11]={0.000483075,
451                       0.000466925,
452                       0.000431658,
453                       0.000428317,
454                       0.000433854,
455                       0.000444044,
456                       0.000482098,
457                       0.000537579,
458                       0.000636279,
459                       0.000741998,
460                       0.000864261};
461        float ty[11]={0.997032,
462                       1.11147,
463                       1.18526,
464                       1.61404,
465                       2.21908,
466                       3.08959,
467                       4.48833,
468                       4.42687,
469                       4.65253,
470                       4.52043,
471                       4.29926};
472        int index;
473        float fact;
474        for(int i=0; i<6; i++) {
475            index = int((fabs(axv[i])+1.)/2.);
476            if(index>10) index=10;
477            tailx[i]=tx[index];
478            if(flag==1) {
479                if(fabs(axv[i])<=10.) fact = resx[i]/risxeta2_(&(axv[i]));
480                if(fabs(axv[i])>10.&&fabs(axv[i])<=15.) fact = resx[i]/risxeta3_(&(axv[i]));
481                if(fabs(axv[i])>15.) fact = resx[i]/risxeta4_(&(axv[i]));
482            } else fact = 1.;
483            resx[i] = sx[index]*fact;
484        }
485        for(int i=0; i<6; i++) {
486            index = int((fabs(ayv[i])+1.)/2.);
487            if(index>10) index=10;
488            taily[i]=ty[index];
489            if(flag==1) fact = resy[i]/risyeta2_(&(ayv[i]));
490            else fact = 1.;
491            resy[i] = sy[index]*fact;
492        }
493    }
494    /**
495     * Set the TrkTrack good measurement
496   */   */
497  void TrkTrack::SetGood(int *xg, int *yg){  void TrkTrack::SetGood(int *xg, int *yg){
498    
# Line 468  void TrkTrack::FillMiniStruct(cMini2trac Line 554  void TrkTrack::FillMiniStruct(cMini2trac
554                    
555          track.resx[i]=resx[i];          track.resx[i]=resx[i];
556          track.resy[i]=resy[i];          track.resy[i]=resy[i];
557            track.tailx[i]=tailx[i];
558            track.taily[i]=taily[i];
559      }      }
560    
561      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 523  void TrkTrack::SetFromMiniStruct(cMini2t Line 611  void TrkTrack::SetFromMiniStruct(cMini2t
611   *   *
612   * @see TrkParams::SetPFA(int)   * @see TrkParams::SetPFA(int)
613   */   */
614  void TrkTrack::EvaluateClusterPositions(){  Bool_t TrkTrack::EvaluateClusterPositions(){
615            
616  //     cout << "void TrkTrack::GetClusterPositions() "<<endl;  //     cout << "void TrkTrack::GetClusterPositions() "<<endl;
617    
618      TrkParams::Load( );      TrkParams::Load( );
619      if( !TrkParams::IsLoaded() )return;      if( !TrkParams::IsLoaded() )return false;
620            
621      for(int ip=0; ip<6; ip++){      for(int ip=0; ip<6; ip++){
622  //      cout << ip<<" ** "<<xm[ip]<<" / "<<ym[ip]<<endl;;  //      cout << ip<<" ** "<<xm[ip]<<" / "<<ym[ip]<<endl;;
# Line 547  void TrkTrack::EvaluateClusterPositions( Line 635  void TrkTrack::EvaluateClusterPositions(
635          float bfy = 10*TrkParams::GetBY(v);//Tesla          float bfy = 10*TrkParams::GetBY(v);//Tesla
636          int ipp=ip+1;          int ipp=ip+1;
637          xyzpam_(&ipp,&icx,&icy,&ladder,&sensor,&ax,&ay,&bfx,&bfy);          xyzpam_(&ipp,&icx,&icy,&ladder,&sensor,&ax,&ay,&bfx,&bfy);
638            if(icx<0 || icy<0)return false;
639      }      }
640        return true;
641  }  }
642  /**  /**
643   * \brief Tracking method. It calls F77 mini routine.   * \brief Tracking method. It calls F77 mini routine.
# Line 585  void TrkTrack::Fit(double pfixed, int& f Line 675  void TrkTrack::Fit(double pfixed, int& f
675    
676      extern cMini2track track_;      extern cMini2track track_;
677      fail = 0;      fail = 0;
678    
679      FillMiniStruct(track_);      FillMiniStruct(track_);
680                
681      if(froml1!=0)EvaluateClusterPositions();      if(froml1!=0){
682            if( !EvaluateClusterPositions() ){
683                cout << "void TrkTrack::Fit("<<pfixed<<","<<fail<<","<<iprint<<","<<froml1<<") --- ERROR evaluating cluster positions "<<endl;
684                FillMiniStruct(track_) ;
685                fail = 1;
686                return;
687            }
688        }else{
689            FillMiniStruct(track_);
690        }
691            
692      // if fit variables have been reset, evaluate the initial guess      // if fit variables have been reset, evaluate the initial guess
693      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_();
# Line 660  void TrkTrack::SetPrecisionFactor(double Line 760  void TrkTrack::SetPrecisionFactor(double
760      track_.fact = fact;      track_.fact = fact;
761  }  }
762  /**  /**
763   * Set the factor scale for tracking precision   * Set the minimum number of steps for tracking precision
764   */   */
765  void TrkTrack::SetStepMin(int istepmin){  void TrkTrack::SetStepMin(int istepmin){
766      extern cMini2track track_;      extern cMini2track track_;
767      track_.istepmin = istepmin;      track_.istepmin = istepmin;
768  }  }
769    /**
770     * Returns 1 if the track is inside the magnet cavity
771     * Set the minimum number of steps for tracking precision
772     */
773    Bool_t TrkTrack::IsInsideCavity(){
774        float xmagntop, ymagntop, xmagnbottom, ymagnbottom;
775        xmagntop = xv[0] + (ZMAGNHIGH-zv[0])*tan(cos(-1.0)*axv[0]/180.);
776        ymagntop = yv[0] + (ZMAGNHIGH-zv[0])*tan(cos(-1.0)*ayv[0]/180.);
777        xmagnbottom = xv[5] + (ZMAGNLOW-zv[5])*tan(cos(-1.0)*axv[5]/180.);
778        ymagnbottom = yv[5] + (ZMAGNLOW-zv[5])*tan(cos(-1.0)*ayv[5]/180.);
779        if( xmagntop>XMAGNLOW && xmagntop<XMAGNHIGH &&
780            ymagntop>YMAGNLOW && ymagntop<YMAGNHIGH &&
781            xmagnbottom>XMAGNLOW && xmagnbottom<XMAGNHIGH &&
782            ymagnbottom>YMAGNLOW && ymagnbottom<YMAGNHIGH ) return(true);
783        else return(false);
784    }
785  /**  /**
786   * 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.
787   * If no cluster is associated, ID=-1.   * If no cluster is associated, ID=-1.
# Line 884  void TrkLevel2::Dump(){ Line 998  void TrkLevel2::Dump(){
998          for(int i=0; i<nclsy(); i++) ((TrkSinglet *)sy[i])->Dump();          for(int i=0; i<nclsy(); i++) ((TrkSinglet *)sy[i])->Dump();
999      }      }
1000  }  }
1001    /**
1002     * \brief Dump processing status
1003     */
1004    void TrkLevel2::StatusDump(int view){
1005        cout << "DSP n. "<<view+1<<" status: "<<hex<<good[view]<<endl;    
1006    };
1007    /**
1008     * \brief Check event status
1009     *
1010     * Check the event status, according to a flag-mask given as input.
1011     * Return true if the view passes the check.
1012     *
1013     * @param view View number (0-11)
1014     * @param flagmask Mask of flags to check (eg. flagmask=0x111 no missing packet,
1015     *  no crc error, no software alarm)
1016     *
1017     * @see TrkLevel2 class definition to know how the status flag is defined
1018     *
1019     */
1020    Bool_t TrkLevel2::StatusCheck(int view, int flagmask){
1021    
1022        if( view<0 || view >= 12)return false;
1023        return !(good[view]&flagmask);
1024    
1025    };
1026    
1027    
1028  //--------------------------------------  //--------------------------------------
1029  //  //
1030  //  //

Legend:
Removed from v.1.33  
changed lines
  Added in v.1.36

  ViewVC Help
Powered by ViewVC 1.1.23