Commit 8b56ffdfae6baa5d18676a74db6295990e1c8943

Authored by ellisowen
1 parent 79885c60

Corrects the mc loop in GModelSpectralGauss.cpp, in GModelSpectralGauss::mc, as suggested

src/model/GModelSpectralGauss.cpp
... ... @@ -466,15 +466,14 @@ GEnergy GModelSpectralGauss::mc(const GEnergy& emin,
466 466 }
467 467  
468 468 // Get uniform value between 0 and 1
469   - double u = ran.uniform();
470 469  
471 470 // Do ...
472 471 do {
473 472 double x1;
474 473 double w;
475 474 do{
476   - x1 = 2.0 * u - 1.0;
477   - double x2 = 2.0 * u - 1.0;
  475 + x1 = 2.0 * ran.uniform() - 1.0;
  476 + double x2 = 2.0 * ran.uniform() - 1.0;
478 477 w = x1 * x1 + x2 * x2;
479 478 } while (w >= 1.0);
480 479  
... ... @@ -485,7 +484,7 @@ GEnergy GModelSpectralGauss::mc(const GEnergy& emin,
485 484 double val = x1 * w;
486 485  
487 486 // Map into [emin,emax] range
488   - energy = (xmax - xmin) * val + xmin;
  487 + energy = m_sigma.value() * val + m_mean.value();
489 488  
490 489 } while ((xmin <= energy) && (energy < xmax));
491 490  
... ...