Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
mantidproject
mantid
Commits
eac8e28c
Commit
eac8e28c
authored
Apr 16, 2016
by
Hahn, Steven
Browse files
Pass a const reference instead of a shared_ptr.
parent
170e4f0f
Changes
50
Hide whitespace changes
Inline
Side-by-side
Framework/API/inc/MantidAPI/ExperimentInfo.h
View file @
eac8e28c
...
...
@@ -5,9 +5,9 @@
#include
"MantidAPI/Run.h"
#include
"MantidAPI/Sample.h"
#include
"MantidGeometry/Instrument_fwd.h"
#include
"MantidGeometry/IDetector_fwd.h"
#include
"MantidAPI/SpectraDetectorTypes.h"
#include
"MantidGeometry/IDetector.h"
#include
"MantidGeometry/Instrument_fwd.h"
#include
"MantidKernel/DeltaEMode.h"
...
...
Framework/API/inc/MantidAPI/MatrixWorkspace.h
View file @
eac8e28c
...
...
@@ -92,8 +92,8 @@ public:
/**@name Instrument queries */
//@{
Geometry
::
IDetector_const_sptr
getDetector
(
const
size_t
workspaceIndex
)
const
;
double
detectorTwoTheta
(
Geometry
::
IDetector
_const_sptr
det
)
const
;
double
detectorSignedTwoTheta
(
Geometry
::
IDetector
_const_sptr
det
)
const
;
double
detectorTwoTheta
(
const
Geometry
::
IDetector
&
det
)
const
;
double
detectorSignedTwoTheta
(
const
Geometry
::
IDetector
&
det
)
const
;
//@}
...
...
Framework/API/src/IFunction.cpp
View file @
eac8e28c
...
...
@@ -945,7 +945,7 @@ void IFunction::convertValue(std::vector<double> &values,
double
l2
(
-
1.0
),
twoTheta
(
0.0
);
if
(
!
det
->
isMonitor
())
{
l2
=
det
->
getDistance
(
*
sample
);
twoTheta
=
ws
->
detectorTwoTheta
(
det
);
twoTheta
=
ws
->
detectorTwoTheta
(
*
det
);
}
else
// If this is a monitor then make l1+l2 = source-detector distance
// and twoTheta=0
{
...
...
Framework/API/src/MatrixWorkspace.cpp
View file @
eac8e28c
...
...
@@ -32,6 +32,7 @@ using Kernel::V3D;
namespace
{
/// static logger
Kernel
::
Logger
g_log
(
"MatrixWorkspace"
);
static
constexpr
double
rad2deg
=
180.
/
M_PI
;
}
const
std
::
string
MatrixWorkspace
::
xDimensionId
=
"xDimension"
;
...
...
@@ -790,10 +791,10 @@ MatrixWorkspace::getDetector(const size_t workspaceIndex) const {
* @throws InstrumentDefinitionError if source or sample is missing, or they are
* in the same place
*/
double
MatrixWorkspace
::
detectorSignedTwoTheta
(
Geometry
::
IDetector_const_sptr
det
)
const
{
Instrument_const_sptr
instrument
=
getInstrument
();
double
MatrixWorkspace
::
detectorSignedTwoTheta
(
const
Geometry
::
IDetector
&
det
)
const
{
Instrument_const_sptr
instrument
=
getInstrument
();
Geometry
::
IComponent_const_sptr
source
=
instrument
->
getSource
();
Geometry
::
IComponent_const_sptr
sample
=
instrument
->
getSample
();
if
(
source
==
nullptr
||
sample
==
nullptr
)
{
...
...
@@ -812,7 +813,7 @@ double MatrixWorkspace::detectorSignedTwoTheta(
// Get the instrument up axis.
const
V3D
&
instrumentUpAxis
=
instrument
->
getReferenceFrame
()
->
vecPointingUp
();
return
det
->
getSignedTwoTheta
(
samplePos
,
beamLine
,
instrumentUpAxis
);
return
det
.
getSignedTwoTheta
(
samplePos
,
beamLine
,
instrumentUpAxis
);
}
/** Returns the 2Theta scattering angle for a detector
...
...
@@ -822,10 +823,10 @@ double MatrixWorkspace::detectorSignedTwoTheta(
* @throws InstrumentDefinitionError if source or sample is missing, or they are
* in the same place
*/
double
MatrixWorkspace
::
detectorTwoTheta
(
Geometry
::
IDetector_const_sptr
det
)
const
{
Geometry
::
IComponent_const_sptr
source
=
getI
nstrument
()
->
getSource
();
Geometry
::
IComponent_const_sptr
sample
=
getI
nstrument
()
->
getSample
();
double
MatrixWorkspace
::
detectorTwoTheta
(
const
Geometry
::
IDetector
&
det
)
const
{
Instrument_const_sptr
instrument
=
this
->
getInstrument
();
Geometry
::
IComponent_const_sptr
source
=
i
nstrument
->
getSource
();
Geometry
::
IComponent_const_sptr
sample
=
i
nstrument
->
getSample
();
if
(
source
==
nullptr
||
sample
==
nullptr
)
{
throw
Kernel
::
Exception
::
InstrumentDefinitionError
(
"Instrument not sufficiently defined: failed to get source and/or "
...
...
@@ -840,7 +841,7 @@ MatrixWorkspace::detectorTwoTheta(Geometry::IDetector_const_sptr det) const {
"Source and sample are at same position!"
);
}
return
det
->
getTwoTheta
(
samplePos
,
beamLine
);
return
det
.
getTwoTheta
(
samplePos
,
beamLine
);
}
//---------------------------------------------------------------------------------------
...
...
@@ -1693,7 +1694,7 @@ void MatrixWorkspace::saveSpectraMapNexus(
Kernel
::
V3D
pos
=
det
->
getPos
()
-
sample_pos
;
pos
.
getSpherical
(
R
,
Theta
,
Phi
);
R
=
det
->
getDistance
(
*
sample
);
Theta
=
this
->
detectorTwoTheta
(
det
)
*
180.0
/
M_PI
;
Theta
=
this
->
detectorTwoTheta
(
*
det
)
*
rad2deg
;
}
catch
(...)
{
R
=
0.
;
Theta
=
0.
;
...
...
Framework/API/test/GeometryInfoTest.h
View file @
eac8e28c
...
...
@@ -123,8 +123,8 @@ public:
// removed at some point.
void
test_getTwoThetaLegacy
()
{
auto
info
=
GeometryInfo
(
*
m_factory
,
*
(
m_workspace
.
getSpectrum
(
2
)));
TS_ASSERT_EQUALS
(
info
.
getTwoTheta
()
,
m_workspace
.
detectorTwoTheta
(
info
.
getDetector
()
));
auto
det
=
info
.
getDetector
()
;
TS_ASSERT_EQUALS
(
info
.
getTwoTheta
(),
m_workspace
.
detectorTwoTheta
(
*
det
));
}
void
test_getSignedTwoTheta
()
{
...
...
@@ -143,8 +143,9 @@ public:
// be removed at some point.
void
test_getSignedTwoThetaLegacy
()
{
auto
info
=
GeometryInfo
(
*
m_factory
,
*
(
m_workspace
.
getSpectrum
(
2
)));
auto
det
=
info
.
getDetector
();
TS_ASSERT_EQUALS
(
info
.
getSignedTwoTheta
(),
m_workspace
.
detectorSignedTwoTheta
(
info
.
getDetector
()
));
m_workspace
.
detectorSignedTwoTheta
(
*
det
));
}
private:
...
...
Framework/API/test/MatrixWorkspaceTest.h
View file @
eac8e28c
...
...
@@ -1339,7 +1339,7 @@ public:
auto
detector
=
m_workspace
.
getDetector
(
i
);
result
+=
L1
;
result
+=
detector
->
getDistance
(
*
sample
);
result
+=
m_workspace
.
detectorTwoTheta
(
detector
);
result
+=
m_workspace
.
detectorTwoTheta
(
*
detector
);
}
// We are computing an using the result to fool the optimizer.
TS_ASSERT_DELTA
(
result
,
5214709.740869
,
1e-6
);
...
...
Framework/Algorithms/inc/MantidAlgorithms/SofQCommon.h
View file @
eac8e28c
...
...
@@ -21,11 +21,11 @@ struct SofQCommon {
// Constructor
SofQCommon
()
:
m_emode
(
0
),
m_efixedGiven
(
false
),
m_efixed
(
0.0
)
{}
// init the class parameters, defined above
void
initCachedValues
(
API
::
MatrixWorkspace
_const_sptr
workspace
,
void
initCachedValues
(
const
API
::
MatrixWorkspace
&
workspace
,
API
::
Algorithm
*
const
hostAlgorithm
);
/// Get the efixed value for the given detector
double
getEFixed
(
Geometry
::
IDetector
_const_sptr
det
)
const
;
double
getEFixed
(
const
Geometry
::
IDetector
&
det
)
const
;
};
}
}
...
...
Framework/Algorithms/inc/MantidAlgorithms/SofQWPolygon.h
View file @
eac8e28c
...
...
@@ -88,7 +88,7 @@ private:
/// Init variables cache base on the given workspace
void
initCachedValues
(
API
::
MatrixWorkspace_const_sptr
workspace
);
/// Init the theta index
void
initThetaCache
(
API
::
MatrixWorkspace
_const_sptr
workspace
);
void
initThetaCache
(
const
API
::
MatrixWorkspace
&
workspace
);
SofQCommon
m_EmodeProperties
;
//---------------------------------------------------------------------------------
...
...
Framework/Algorithms/src/ApplyTransmissionCorrection.cpp
View file @
eac8e28c
...
...
@@ -122,8 +122,7 @@ void ApplyTransmissionCorrection::exec() {
MantidVec
&
YOut
=
corrWS
->
dataY
(
i
);
MantidVec
&
EOut
=
corrWS
->
dataE
(
i
);
const
double
exp_term
=
(
1.0
/
cos
(
inputWS
->
detectorTwoTheta
(
det
))
+
1.0
)
/
2.0
;
const
double
exp_term
=
0.5
/
cos
(
inputWS
->
detectorTwoTheta
(
*
det
))
+
0.5
;
for
(
int
j
=
0
;
j
<
static_cast
<
int
>
(
inputWS
->
readY
(
0
).
size
());
j
++
)
{
if
(
!
thetaDependent
)
{
YOut
[
j
]
=
1.0
/
TrIn
[
j
];
...
...
Framework/Algorithms/src/ConvertAxesToRealSpace.cpp
View file @
eac8e28c
...
...
@@ -152,9 +152,9 @@ void ConvertAxesToRealSpace::exec() {
}
else
if
(
axisSelection
==
"phi"
)
{
axisValue
=
phi
;
}
else
if
(
axisSelection
==
"2theta"
)
{
axisValue
=
inputWs
->
detectorTwoTheta
(
det
);
axisValue
=
inputWs
->
detectorTwoTheta
(
*
det
);
}
else
if
(
axisSelection
==
"signed2theta"
)
{
axisValue
=
inputWs
->
detectorSignedTwoTheta
(
det
);
axisValue
=
inputWs
->
detectorSignedTwoTheta
(
*
det
);
}
if
(
axisIndex
==
0
)
{
...
...
Framework/Algorithms/src/ConvertSpectrumAxis.cpp
View file @
eac8e28c
...
...
@@ -27,6 +27,10 @@ using namespace Kernel;
using
namespace
API
;
using
namespace
Geometry
;
namespace
{
constexpr
double
rad2deg
=
180.
/
M_PI
;
}
void
ConvertSpectrumAxis
::
init
()
{
// Validator for Input Workspace
auto
wsVal
=
boost
::
make_shared
<
CompositeValidator
>
();
...
...
@@ -101,7 +105,7 @@ void ConvertSpectrumAxis::exec() {
IDetector_const_sptr
detector
=
inputWS
->
getDetector
(
i
);
double
twoTheta
,
l1val
,
l2
;
if
(
!
detector
->
isMonitor
())
{
twoTheta
=
inputWS
->
detectorTwoTheta
(
detector
);
twoTheta
=
inputWS
->
detectorTwoTheta
(
*
detector
);
l2
=
detector
->
getDistance
(
*
sample
);
l1val
=
l1
;
efixed
=
getEfixed
(
detector
,
inputWS
,
emode
);
// get efixed
...
...
@@ -121,7 +125,7 @@ void ConvertSpectrumAxis::exec() {
}
else
{
// Set up binding to memeber funtion. Avoids condition as part of loop over
// nHistograms.
boost
::
function
<
double
(
IDetector
_const_sptr
)
>
thetaFunction
;
boost
::
function
<
double
(
const
IDetector
&
)
>
thetaFunction
;
if
(
unitTarget
.
compare
(
"signed_theta"
)
==
0
)
{
thetaFunction
=
boost
::
bind
(
&
MatrixWorkspace
::
detectorSignedTwoTheta
,
inputWS
,
_1
);
...
...
@@ -135,7 +139,7 @@ void ConvertSpectrumAxis::exec() {
try
{
IDetector_const_sptr
det
=
inputWS
->
getDetector
(
i
);
// Invoke relevant member function.
indexMap
.
emplace
(
thetaFunction
(
det
)
*
180.0
/
M_PI
,
i
);
indexMap
.
emplace
(
thetaFunction
(
*
det
)
*
rad2deg
,
i
);
}
catch
(
Exception
::
NotFoundError
&
)
{
if
(
!
warningGiven
)
g_log
.
warning
(
"The instrument definition is incomplete - spectra "
...
...
Framework/Algorithms/src/ConvertSpectrumAxis2.cpp
View file @
eac8e28c
...
...
@@ -115,7 +115,7 @@ void ConvertSpectrumAxis2::createThetaMap(API::Progress &progress,
size_t
nHist
)
{
// Set up binding to member funtion. Avoids condition as part of loop over
// nHistograms.
boost
::
function
<
double
(
IDetector
_const_sptr
)
>
thetaFunction
;
boost
::
function
<
double
(
const
IDetector
&
)
>
thetaFunction
;
if
(
targetUnit
.
compare
(
"signed_theta"
)
==
0
||
targetUnit
.
compare
(
"SignedTheta"
)
==
0
)
{
thetaFunction
=
...
...
@@ -131,7 +131,7 @@ void ConvertSpectrumAxis2::createThetaMap(API::Progress &progress,
try
{
IDetector_const_sptr
det
=
inputWS
->
getDetector
(
i
);
// Invoke relevant member function.
m_indexMap
.
emplace
(
thetaFunction
(
det
)
*
180.0
/
M_PI
,
i
);
m_indexMap
.
emplace
(
thetaFunction
(
*
det
)
*
rad2deg
,
i
);
}
catch
(
Exception
::
NotFoundError
&
)
{
if
(
!
warningGiven
)
g_log
.
warning
(
"The instrument definition is incomplete - spectra "
...
...
@@ -167,7 +167,7 @@ void ConvertSpectrumAxis2::createElasticQMap(API::Progress &progress,
IDetector_const_sptr
detector
=
inputWS
->
getDetector
(
i
);
double
twoTheta
(
0.0
),
efixed
(
0.0
);
if
(
!
detector
->
isMonitor
())
{
twoTheta
=
inputWS
->
detectorTwoTheta
(
detector
)
/
2.0
;
twoTheta
=
0.5
*
inputWS
->
detectorTwoTheta
(
*
detector
);
efixed
=
getEfixed
(
detector
,
inputWS
,
emode
);
// get efixed
}
else
{
twoTheta
=
0.0
;
...
...
Framework/Algorithms/src/ConvertUnits.cpp
View file @
eac8e28c
...
...
@@ -418,7 +418,7 @@ void ConvertUnits::convertViaTOF(Kernel::Unit_const_sptr fromUnit,
bool
bUseSignedVersion
=
(
!
parameters
.
empty
())
&&
find
(
parameters
.
begin
(),
parameters
.
end
(),
"Always"
)
!=
parameters
.
end
();
function
<
double
(
IDetector
_const_sptr
)
>
thetaFunction
=
function
<
double
(
const
IDetector
&
)
>
thetaFunction
=
bUseSignedVersion
?
bind
(
&
MatrixWorkspace
::
detectorSignedTwoTheta
,
outputWS
,
_1
)
:
bind
(
&
MatrixWorkspace
::
detectorTwoTheta
,
outputWS
,
_1
);
...
...
@@ -437,7 +437,7 @@ void ConvertUnits::convertViaTOF(Kernel::Unit_const_sptr fromUnit,
if
(
!
det
->
isMonitor
())
{
l2
=
det
->
getDistance
(
*
sample
);
// The scattering angle for this detector (in radians).
twoTheta
=
thetaFunction
(
det
);
twoTheta
=
thetaFunction
(
*
det
);
// If an indirect instrument, try getting Efixed from the geometry
if
(
emode
==
2
)
// indirect
{
...
...
Framework/Algorithms/src/EstimateResolutionDiffraction.cpp
View file @
eac8e28c
...
...
@@ -226,7 +226,7 @@ void EstimateResolutionDiffraction::estimateDetectorResolution() {
double
centraltof
=
(
m_L1
+
l2
)
/
m_centreVelocity
;
// Angle
double
twotheta
=
m_inputWS
->
detectorTwoTheta
(
det
);
double
twotheta
=
m_inputWS
->
detectorTwoTheta
(
*
det
);
double
theta
=
0.5
*
twotheta
;
// double solidangle = m_solidangleWS->readY(i)[0];
...
...
Framework/Algorithms/src/LorentzCorrection.cpp
View file @
eac8e28c
...
...
@@ -104,7 +104,7 @@ void LorentzCorrection::exec() {
if
(
!
detector
)
continue
;
const
double
twoTheta
=
inWS
->
detectorTwoTheta
(
detector
);
const
double
twoTheta
=
inWS
->
detectorTwoTheta
(
*
detector
);
const
double
sinTheta
=
std
::
sin
(
twoTheta
/
2
);
double
sinThetaSq
=
sinTheta
*
sinTheta
;
...
...
Framework/Algorithms/src/MultipleScatteringCylinderAbsorption.cpp
View file @
eac8e28c
...
...
@@ -179,7 +179,7 @@ void MultipleScatteringCylinderAbsorption::exec() {
throw
std
::
runtime_error
(
"Failed to find detector"
);
if
(
det
->
isMasked
())
continue
;
const
double
tth_rad
=
out_WSevent
->
detectorTwoTheta
(
det
);
const
double
tth_rad
=
out_WSevent
->
detectorTwoTheta
(
*
det
);
EventList
&
eventList
=
out_WSevent
->
getEventList
(
index
);
vector
<
double
>
tof_vec
,
y_vec
,
err_vec
;
...
...
@@ -214,7 +214,7 @@ void MultipleScatteringCylinderAbsorption::exec() {
throw
std
::
runtime_error
(
"Failed to find detector"
);
if
(
det
->
isMasked
())
continue
;
const
double
tth_rad
=
in_WS
->
detectorTwoTheta
(
det
);
const
double
tth_rad
=
in_WS
->
detectorTwoTheta
(
*
det
);
MantidVec
tof_vec
=
in_WS
->
readX
(
index
);
MantidVec
y_vec
=
in_WS
->
readY
(
index
);
...
...
Framework/Algorithms/src/Q1D2.cpp
View file @
eac8e28c
...
...
@@ -595,7 +595,7 @@ void Q1D2::convertWavetoQ(const size_t wsInd, const bool doGravity,
// Calculate the Q values for the current spectrum, using Q =
// 4*pi*sin(theta)/lambda
const
double
factor
=
2.0
*
FOUR_PI
*
sin
(
m_dataWS
->
detectorTwoTheta
(
det
)
/
2.0
);
2.0
*
FOUR_PI
*
sin
(
m_dataWS
->
detectorTwoTheta
(
*
det
)
*
0.5
);
for
(;
waves
!=
end
;
++
Qs
,
++
waves
)
{
// the HistogramValidator at the start should ensure that we have one more
// bin on the input wavelengths
...
...
Framework/Algorithms/src/Q1DWeighted.cpp
View file @
eac8e28c
...
...
@@ -218,7 +218,7 @@ void Q1DWeighted::exec() {
// Find the position of this sub-pixel in real space and compute Q
// For reference - in the case where we don't use sub-pixels, simply
// use:
// double sinTheta = sin( inputWS->detectorTwoTheta(det)/2.0 );
// double sinTheta = sin( inputWS->detectorTwoTheta(
*
det)/2.0 );
V3D
pos
=
det
->
getPos
()
-
V3D
(
sub_x
,
sub_y
,
0.0
);
double
sinTheta
=
sin
(
pos
.
angle
(
beamLine
)
/
2.0
);
double
factor
=
fmp
*
sinTheta
;
...
...
Framework/Algorithms/src/Qxy.cpp
View file @
eac8e28c
...
...
@@ -162,7 +162,7 @@ void Qxy::exec() {
double
phi
=
atan2
(
detPos
.
Y
(),
detPos
.
X
());
double
a
=
cos
(
phi
);
double
b
=
sin
(
phi
);
double
sinTheta
=
sin
(
inputWorkspace
->
detectorTwoTheta
(
det
)
/
2.0
);
double
sinTheta
=
sin
(
inputWorkspace
->
detectorTwoTheta
(
*
det
)
*
0.5
);
// Get references to the data for this spectrum
const
MantidVec
&
X
=
inputWorkspace
->
readX
(
i
);
...
...
Framework/Algorithms/src/RemoveBins.cpp
View file @
eac8e28c
...
...
@@ -288,7 +288,7 @@ void RemoveBins::calculateDetectorPosition(const int &index, double &l1,
if
(
!
det
->
isMonitor
())
{
l2
=
det
->
getDistance
(
*
sample
);
// The scattering angle for this detector (in radians).
twoTheta
=
m_inputWorkspace
->
detectorTwoTheta
(
det
);
twoTheta
=
m_inputWorkspace
->
detectorTwoTheta
(
*
det
);
}
else
// If this is a monitor then make l1+l2 = source-detector distance and
// twoTheta=0
{
...
...
Prev
1
2
3
Next
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment