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
86a8b8cb
Commit
86a8b8cb
authored
Feb 20, 2017
by
Samuel Jackson
Browse files
Refs #18920 Apply clang-format patch
parent
6c6e276e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Framework/Crystal/src/PredictPeaks.cpp
View file @
86a8b8cb
...
...
@@ -432,16 +432,17 @@ void PredictPeaks::calculateQAndAddToOutput(const V3D &hkl,
/* The constructor calls setQLabFrame, which already calls findDetector, which
is expensive. It's not necessary to call it again, instead it's enough to
check whether a detector has already been set.
check whether a detector has already been set.
Peaks are added if they fall on a detector OR is the extended detector
space component is defined which can be used to approximate a peak's
Peaks are added if they fall on a detector OR is the extended detector
space component is defined which can be used to approximate a peak's
position in detector space.
*/
bool
useExtendedDetectorSpace
=
getProperty
(
"PredictPeaksOutsideDetectors"
);
if
(
!
p
.
getDetector
()
&&
!
(
useExtendedDetectorSpace
&&
m_inst
->
getComponentByName
(
"extended-detector-space"
)))
return
;
if
(
!
p
.
getDetector
()
&&
!
(
useExtendedDetectorSpace
&&
m_inst
->
getComponentByName
(
"extended-detector-space"
)))
return
;
// Only add peaks that hit the detector
p
.
setGoniometerMatrix
(
goniometerMatrix
);
...
...
@@ -450,7 +451,7 @@ void PredictPeaks::calculateQAndAddToOutput(const V3D &hkl,
p
.
setHKL
(
hkl
*
m_qConventionFactor
);
if
(
m_sfCalculator
)
{
p
.
setIntensity
(
m_sfCalculator
->
getFSquared
(
hkl
));
p
.
setIntensity
(
m_sfCalculator
->
getFSquared
(
hkl
));
}
// Add it to the workspace
...
...
Framework/DataObjects/inc/MantidDataObjects/Peak.h
View file @
86a8b8cb
...
...
@@ -154,7 +154,7 @@ public:
Peak
&
operator
=
(
const
Peak
&
other
);
/// Get the approximate position of a peak that falls off the detectors
Kernel
::
V3D
getVirtualDetectorPosition
(
const
Kernel
::
V3D
&
detectorDir
)
const
;
Kernel
::
V3D
getVirtualDetectorPosition
(
const
Kernel
::
V3D
&
detectorDir
)
const
;
private:
bool
findDetector
(
const
Mantid
::
Kernel
::
V3D
&
beam
);
...
...
Framework/DataObjects/src/Peak.cpp
View file @
86a8b8cb
...
...
@@ -607,10 +607,11 @@ void Peak::setQLabFrame(const Mantid::Kernel::V3D &QLabFrame,
}
}
V3D
Peak
::
getVirtualDetectorPosition
(
const
V3D
&
detectorDir
)
const
{
const
auto
component
=
getInstrument
()
->
getComponentByName
(
"extended-detector-space"
);
V3D
Peak
::
getVirtualDetectorPosition
(
const
V3D
&
detectorDir
)
const
{
const
auto
component
=
getInstrument
()
->
getComponentByName
(
"extended-detector-space"
);
if
(
!
component
)
{
return
detectorDir
;
// the best idea we have is just the direction
return
detectorDir
;
// the best idea we have is just the direction
}
auto
c
=
boost
::
dynamic_pointer_cast
<
const
ObjComponent
>
(
component
);
...
...
Framework/DataObjects/test/PeakTest.h
View file @
86a8b8cb
...
...
@@ -365,47 +365,50 @@ public:
void
test_setQSampleFrameVirtualDetectorWithQLab
()
{
constexpr
auto
radius
=
10.
;
auto
sphereInst
=
ComponentCreationHelper
::
createTestInstrumentRectangular
(
5
,
100
);
auto
extendedSpaceObj
=
ComponentCreationHelper
::
createSphere
(
10.
,
V3D
(
0
,
0
,
0
));
auto
extendedSpace
=
new
ObjComponent
(
"extended-detector-space"
,
extendedSpaceObj
,
sphereInst
.
get
());
auto
sphereInst
=
ComponentCreationHelper
::
createTestInstrumentRectangular
(
5
,
100
);
auto
extendedSpaceObj
=
ComponentCreationHelper
::
createSphere
(
10.
,
V3D
(
0
,
0
,
0
));
auto
extendedSpace
=
new
ObjComponent
(
"extended-detector-space"
,
extendedSpaceObj
,
sphereInst
.
get
());
extendedSpace
->
setPos
(
V3D
(
0.0
,
0.0
,
0.0
));
sphereInst
->
add
(
extendedSpace
);
const
auto
refFrame
=
sphereInst
->
getReferenceFrame
();
const
auto
refBeamDir
=
refFrame
->
vecPointingAlongBeam
();
// test with & without extended detector space
// extended space is a sphere, so all points should fall radius*detector
// extended space is a sphere, so all points should fall radius*detector
// direction away from the detector direction with extended space
auto
testQ
=
[
this
,
&
sphereInst
,
&
refFrame
,
&
refBeamDir
](
const
auto
q
)
{
// Compute expected direction
const
auto
qBeam
=
q
.
scalar_prod
(
refBeamDir
);
const
double
norm_q
=
q
.
norm
();
const
double
one_over_wl
=
(
norm_q
*
norm_q
)
/
(
2.0
*
qBeam
);
V3D
detectorDir
=
q
*
-
1.0
;
detectorDir
[
refFrame
->
pointingAlongBeam
()]
=
one_over_wl
-
qBeam
;
detectorDir
.
normalize
();
// test without extended detector space
// should be a unit vector in the direction of the virtual detector position
Peak
peak1
(
inst
,
q
);
// skip tests for which Q actually does intersect with a valid detector
if
(
peak1
.
getDetectorID
()
>
0
)
{
return
;
}
TS_ASSERT_EQUALS
(
peak1
.
getDetectorID
(),
-
1
)
TS_ASSERT_EQUALS
(
peak1
.
getDetPos
(),
detectorDir
)
// test with extended detector space
// should be the full vector to the virtual detector position
Peak
peak2
(
sphereInst
,
q
);
TS_ASSERT_EQUALS
(
peak2
.
getDetectorID
(),
-
1
)
TS_ASSERT_EQUALS
(
peak2
.
getDetPos
(),
detectorDir
*
radius
)
// Compute expected direction
const
auto
qBeam
=
q
.
scalar_prod
(
refBeamDir
);
const
double
norm_q
=
q
.
norm
();
const
double
one_over_wl
=
(
norm_q
*
norm_q
)
/
(
2.0
*
qBeam
);
V3D
detectorDir
=
q
*
-
1.0
;
detectorDir
[
refFrame
->
pointingAlongBeam
()]
=
one_over_wl
-
qBeam
;
detectorDir
.
normalize
();
// test without extended detector space
// should be a unit vector in the direction of the virtual detector
// position
Peak
peak1
(
inst
,
q
);
// skip tests for which Q actually does intersect with a valid detector
if
(
peak1
.
getDetectorID
()
>
0
)
{
return
;
}
TS_ASSERT_EQUALS
(
peak1
.
getDetectorID
(),
-
1
)
TS_ASSERT_EQUALS
(
peak1
.
getDetPos
(),
detectorDir
)
// test with extended detector space
// should be the full vector to the virtual detector position
Peak
peak2
(
sphereInst
,
q
);
TS_ASSERT_EQUALS
(
peak2
.
getDetectorID
(),
-
1
)
TS_ASSERT_EQUALS
(
peak2
.
getDetPos
(),
detectorDir
*
radius
)
};
// Make hemisphere of q vectors to test
std
::
vector
<
double
>
xDirections
(
20
);
std
::
vector
<
double
>
yDirections
(
20
);
...
...
@@ -414,59 +417,65 @@ public:
// create x values of the range -1 to 1
int
index
=
0
;
double
startValue
=
-
1
;
std
::
generate
(
xDirections
.
begin
(),
xDirections
.
end
(),
[
&
index
,
&
startValue
]()
{
return
startValue
+
index
++*
0.1
;
});
std
::
generate
(
xDirections
.
begin
(),
xDirections
.
end
(),
[
&
index
,
&
startValue
]()
{
return
startValue
+
index
++
*
0.1
;
});
// create z values of the range 0.1 to 1
// ignore negative z values as these are not physical!
index
=
0
;
startValue
=
0.1
;
std
::
generate
(
zDirections
.
begin
(),
zDirections
.
end
(),
[
&
index
,
&
startValue
]()
{
return
startValue
+
index
++*
0.1
;
});
std
::
generate
(
zDirections
.
begin
(),
zDirections
.
end
(),
[
&
index
,
&
startValue
]()
{
return
startValue
+
index
++
*
0.1
;
});
yDirections
=
xDirections
;
for
(
auto
&
x
:
xDirections
)
{
for
(
auto
&
y
:
yDirections
)
{
for
(
auto
&
z
:
zDirections
)
{
testQ
(
V3D
(
x
,
y
,
z
));
}
for
(
auto
&
x
:
xDirections
)
{
for
(
auto
&
y
:
yDirections
)
{
for
(
auto
&
z
:
zDirections
)
{
testQ
(
V3D
(
x
,
y
,
z
));
}
}
}
}
void
test_setQSampleFrameVirtualDetectorWithScatteringAngle
()
{
constexpr
auto
radius
=
10.
;
auto
sphereInst
=
ComponentCreationHelper
::
createTestInstrumentRectangular
(
5
,
100
);
auto
extendedSpaceObj
=
ComponentCreationHelper
::
createSphere
(
10.
,
V3D
(
0
,
0
,
0
));
auto
extendedSpace
=
new
ObjComponent
(
"extended-detector-space"
,
extendedSpaceObj
,
sphereInst
.
get
());
auto
sphereInst
=
ComponentCreationHelper
::
createTestInstrumentRectangular
(
5
,
100
);
auto
extendedSpaceObj
=
ComponentCreationHelper
::
createSphere
(
10.
,
V3D
(
0
,
0
,
0
));
auto
extendedSpace
=
new
ObjComponent
(
"extended-detector-space"
,
extendedSpaceObj
,
sphereInst
.
get
());
extendedSpace
->
setPos
(
V3D
(
0.0
,
0.0
,
0.0
));
sphereInst
->
add
(
extendedSpace
);
// test with & without extended detector space
// extended space is a sphere, so all points should fall radius*detector
// extended space is a sphere, so all points should fall radius*detector
// direction away from the detector direction with extended space
auto
testTheta
=
[
this
,
&
sphereInst
,
&
radius
](
const
auto
theta
)
{
const
auto
expectedDir
=
V3D
(
sin
(
theta
),
0.
,
cos
(
theta
));
// test without extended detector space
// should be {sin(theta), 0, cos(theta)}
Peak
p1
(
this
->
inst
,
theta
,
2.0
);
V3D
detPos1
=
p1
.
getDetPos
();
TS_ASSERT_EQUALS
(
detPos1
,
expectedDir
);
// test with extended detector space
// should be radius*{sin(theta), 0, cos(theta)}
Peak
p2
(
sphereInst
,
theta
,
2.0
);
V3D
detPos2
=
p2
.
getDetPos
();
TS_ASSERT_EQUALS
(
detPos2
,
expectedDir
*
radius
);
const
auto
expectedDir
=
V3D
(
sin
(
theta
),
0.
,
cos
(
theta
));
// test without extended detector space
// should be {sin(theta), 0, cos(theta)}
Peak
p1
(
this
->
inst
,
theta
,
2.0
);
V3D
detPos1
=
p1
.
getDetPos
();
TS_ASSERT_EQUALS
(
detPos1
,
expectedDir
);
// test with extended detector space
// should be radius*{sin(theta), 0, cos(theta)}
Peak
p2
(
sphereInst
,
theta
,
2.0
);
V3D
detPos2
=
p2
.
getDetPos
();
TS_ASSERT_EQUALS
(
detPos2
,
expectedDir
*
radius
);
};
// generate & test a range of angles from 0 - 360
int
index
=
0
;
std
::
vector
<
double
>
angles
(
8
);
std
::
generate
(
angles
.
begin
(),
angles
.
end
(),
[
&
index
,
&
angles
]()
{
return
index
++*
M_PI
/
angles
.
size
();});
std
::
generate
(
angles
.
begin
(),
angles
.
end
(),
[
&
index
,
&
angles
]()
{
return
index
++
*
M_PI
/
angles
.
size
();
});
std
::
for_each
(
angles
.
begin
(),
angles
.
end
(),
testTheta
);
}
...
...
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