Skip to content

Commit

Permalink
Re #11868 Handle detector phases in a more compact way
Browse files Browse the repository at this point in the history
  • Loading branch information
raquelalvarezbanos committed Sep 29, 2015
1 parent 8ff84f8 commit 4e5ebeb
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions Code/Mantid/Framework/Algorithms/src/CalMuonDetectorPhases.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include "MantidAPI/IFunction.h"
#include "MantidAPI/MultiDomainFunction.h"
#include "MantidAPI/TableRow.h"
#include "MantidAPI/WorkspaceFactory.h"

namespace Mantid {
namespace Algorithms {
Expand Down Expand Up @@ -174,18 +173,17 @@ API::ITableWorkspace_sptr CalMuonDetectorPhases::extractDetectorInfo(
size_t specRow = s * 3;
double asym = paramTab->Double(specRow,1);
double phase = paramTab->Double(specRow+2,1);
// Handle phases greather (less) than 2*PI (-2*PI)
if (phase > 2 * M_PI) {
phase = phase - 2 * M_PI;
} else if (phase < -2 * M_PI) {
phase = phase + 2 * M_PI;
}
// If asym<0, take the absolute value and add \pi to phase
// f(x) = A * sin( w * x + p) = -A * sin( w * x + p + PI)
if (asym<0) {
asym = -asym;
phase = phase + M_PI;
}
// Now convert phases to interval [0, 2PI)
int factor = static_cast<int>(floor(phase / 2 / M_PI));
if (factor) {
phase = phase - factor * 2 * M_PI;
}
// Copy parameters to new table
API::TableRow row = tab->appendRow();
row << s << asym << phase;
Expand Down

0 comments on commit 4e5ebeb

Please sign in to comment.