Changeset 2517 in Sophya for trunk/SophyaPI/PIext/pigfd1.cc


Ignore:
Timestamp:
Mar 17, 2004, 7:04:57 PM (22 years ago)
Author:
cmv
Message:

GetDistanceToPoint cmv 17/03/04

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaPI/PIext/pigfd1.cc

    r2115 r2517  
    1010SelectX(0);
    1111SelectErrBar(false,false);
     12NptDraw = 0;
    1213}
    1314
     
    6061if(GetGraphicAtt().GetLineAtt()!=PI_NotDefLineAtt) SelectErrBar(true,true);
    6162double xp,yp,er;
     63NptDraw = 0;
    6264for (int i=0; i<mGFD->NData(); i++) {
    6365  xp = mGFD->Absc(VarX,i);
    6466  yp = mGFD->Val(i);
    6567  if(xp<xmin || xp>xmax || yp<ymin || yp>ymax)  continue;
     68  NptDraw++;
    6669  if(ErrX) {
    6770    er = mGFD->EAbsc(VarX,i);
     
    7679return;
    7780}
     81
     82/* --Methode-- */
     83double PIGenFitDat::GetDistanceToPoint(double x, double y)
     84{
     85 if(!mGFD) return 1.e+9;
     86 if(mGFD->NData()<=0) return 1.e+9;
     87 if(VarX<0) return 1.e+9;
     88
     89 const int nessai = 100;
     90 long inc = (NptDraw>nessai) ? (long)(NptDraw/nessai)+1 : 1;
     91
     92 double dist = -1.e+18;
     93 long n = 0;
     94 for(long i=0; i<mGFD->NData(); i++) {
     95   double xp=mGFD->Absc(VarX,i);
     96   if(xp<XMin() || xp>XMax()) continue;
     97   double yp=mGFD->Val(i);
     98   if(yp<YMin() || yp>YMax()) continue;
     99   if(n%inc==0) {
     100     xp = (xp-x)/(XMax()-XMin())/0.5;
     101     yp = (yp-y)/(YMax()-YMin())/0.5;
     102     xp = xp*xp+yp*yp;
     103     if(dist<0. || xp<dist) dist = xp;
     104   }
     105   n++;
     106 }
     107 dist=sqrt(fabs(dist));
     108 //cout<<"PIGenFitDat: xlim="<<XMin()<<","<<XMax()<<" ylim="<<YMin()<<","<<YMax()
     109 //    <<" NData="<<mGFD->NData()<<" inc="<<inc<<endl;
     110 //cout<<"....d="<<dist<<" x="<<x<<" y="<<y<<" NptDraw="<<NptDraw<<endl;
     111
     112 return dist;
     113}
Note: See TracChangeset for help on using the changeset viewer.