Changeset 3461 in Sophya for trunk/SophyaPI/PI/parradapter.cc
- Timestamp:
- Feb 13, 2008, 12:24:11 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaPI/PI/parradapter.cc
r3458 r3461 335 335 q = phis+binmax; 336 336 while ( ((*q) > hmin) && (sigr < (nbin-binmax)) ) { sigr++; q++; } 337 if (sigr < 1) sigr = 1 .;337 if (sigr < 1) sigr = 1; 338 338 int sigl = 0; 339 339 q = phis+binmax; 340 340 while ( ((*q) > hmin) && (sigl < binmax) ) { sigl++; q--; } 341 if (sigl < 1) sigl = 1 .;341 if (sigl < 1) sigl = 1; 342 342 343 343 if (nbsig <= 0.) nbsig = 1.; 344 344 if (htail == false) { /* On recherche le min/max autour du pic de l'histo */ 345 if ( (bin = binmax- (nbsig*sigl)) < 0 ) bin = 0;345 if ( (bin = binmax-int(nbsig*sigl)) < 0 ) bin = 0; 346 346 min = minhis + (double)bin*binwidth; 347 if ( (bin = binmax+ (nbsig*sigr)) >= nbin ) bin = nbin-1;347 if ( (bin = binmax+int(nbsig*sigr)) >= nbin ) bin = nbin-1; 348 348 max = minhis + (double)bin*binwidth; 349 349 if (max < (min+MINDYNAMIC)) max = min+MINDYNAMIC; … … 352 352 353 353 // On recherche le min/max en supprimant le pic de l'histo (la queue, > pic) 354 if ( (bin = binmax+ (nbsig*sigl)) >= nbin ) {354 if ( (bin = binmax+int(nbsig*sigl)) >= nbin ) { 355 355 min = minhis + binmax*binwidth; 356 356 max = maxhis; … … 380 380 int P2DArrayAdapter::ComputeLut_Range(double& min, double& max, double fracmin, double fracmax,int nmax) 381 381 // Compute min and max by throwing away the "fracmin" lowest values and the "fracmax" greatest values 382 // Use 1 value over "vit". Maximum number values to be used is "nmax". 383 // Si echec alors min,max restent inchanges. 384 { 385 int lp=0; 382 // .."fracmin" in [0,1[ and "fracmax" in [0,1[. If not they are set to zero. 383 // ..If min<max, use only the values inside [min,max] 384 // ..Maximum number values to be used is "nmax" (uniformly spread) 385 // if "nmax" is in [-100,0[ take "-nmax%" values (-nmax/100*sX*sY) 386 // if "nmax=0" or "nmax<-100" take all the values (sX*sY) 387 // ..If failed: min,max stay unchanged. 388 { 389 int lp=0; 386 390 if(fracmin<0. || fracmin>=1.) fracmin=0.; 387 391 if(fracmax<0. || fracmax>=1.) fracmax=0.; 388 if(nmax<10) nmax = 5000; 392 if(nmax>=-100 && nmax<0) nmax = int(-nmax/100. * sX*sY); 393 if(nmax<=2) nmax = sX*sY; 389 394 390 395 int vit = sX*sY/nmax; // Not too many values, we are using qsort ! … … 398 403 nmax = sX*sY/vit; 399 404 400 double *buff = new double[nmax ];405 double *buff = new double[nmax+1]; // +1 pour protection si sX=sY=0 401 406 402 407 if(lp) {printf("ComputeLut_Range: sX*sY=%d fracmin=%g fracmax=%g nmax=%d min=%g max=%g\n" … … 411 416 } 412 417 413 if(nfill< 1) {delete [] buff; return nfill;}418 if(nfill<=1) {delete [] buff; return nfill;} 414 419 415 420 qsort(buff,(size_t) nfill,sizeof(double),qSort_Dble);
Note:
See TracChangeset
for help on using the changeset viewer.