Skip to content

Commit

Permalink
Fix bug in TobyFit mosaic calculation.
Browse files Browse the repository at this point in the history
Refs #7548
  • Loading branch information
martyngigg committed Oct 28, 2013
1 parent 29132ac commit ae99fb0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -229,13 +229,13 @@ namespace Mantid
const QOmegaPoint & eventPoint) const
{
const std::vector<double> & randomNums = generateRandomNumbers();
const size_t nvars = m_yvector[PARALLEL_THREAD_NUMBER].recalculate(randomNums, observation, eventPoint);
const size_t nRandUsed = m_yvector[PARALLEL_THREAD_NUMBER].recalculate(randomNums, observation, eventPoint);

// Calculate crystal mosaic contribution
if(m_mosaicActive)
{
const double & r1 = randomNums[nvars];
const double & r2 = randomNums[nvars+1];
const double r1 = randomNums[nRandUsed];
const double r2 = randomNums[nRandUsed+1];
const double small(1e-20);
const double fwhhToStdDev = M_PI/180./std::sqrt(log(256.0)); // degrees FWHH -> st.dev. in radians

Expand Down Expand Up @@ -322,6 +322,7 @@ namespace Mantid
{
const double & etaInPlane = m_etaInPlane[PARALLEL_THREAD_NUMBER];
const double & etaOutPlane = m_etaOutPlane[PARALLEL_THREAD_NUMBER];

const double qx(qOmega.qx + deltaQE[1]),qy(qOmega.qy + deltaQE[2]),qz(qOmega.qz + deltaQE[0]);
const double qipmodSq = qy*qy + qz*qz;
const double qmod = std::sqrt(qx*qx + qipmodSq);
Expand Down Expand Up @@ -509,7 +510,11 @@ namespace Mantid
// Clear out any old ones
deleteRandomNumberGenerator();

const unsigned int nrand = m_yvector[0].requiredRandomNums() + 2; // Extra 2 for mosaic
unsigned int nrand = m_yvector[0].requiredRandomNums();
if(m_mosaicActive)
{
nrand += 2; // Extra 2 for mosaic
}
const size_t ngenerators(m_yvector.size());
if(m_mcType % 2 == 0)// Pseudo-random
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,14 @@ namespace Mantid
calculateSampleContribution();
calculateDetectorContribution();
calculateTimeBinContribution();
size_t randUsed = m_randIndex;

m_curRandNums = NULL;
m_randIndex = 0;
m_curObs = NULL;
m_curQOmega = NULL;

return length();
return randUsed;
}

//-----------------------------------------------------------------------
Expand Down

0 comments on commit ae99fb0

Please sign in to comment.