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
2db727fc
Commit
2db727fc
authored
Mar 28, 2014
by
Anders Markvardsen
Browse files
store store as IComponent. re #9133
and added unit test to test ok
parent
3c6f26cd
Changes
31
Hide whitespace changes
Inline
Side-by-side
Code/Mantid/Framework/API/src/MatrixWorkspace.cpp
View file @
2db727fc
...
...
@@ -750,7 +750,7 @@ namespace Mantid
{
Instrument_const_sptr
instrument
=
getInstrument
();
Geometry
::
I
Obj
Component_const_sptr
source
=
instrument
->
getSource
();
Geometry
::
IComponent_const_sptr
source
=
instrument
->
getSource
();
Geometry
::
IComponent_const_sptr
sample
=
instrument
->
getSample
();
if
(
source
==
NULL
||
sample
==
NULL
)
{
...
...
@@ -776,7 +776,7 @@ namespace Mantid
*/
double
MatrixWorkspace
::
detectorTwoTheta
(
Geometry
::
IDetector_const_sptr
det
)
const
{
Geometry
::
I
Obj
Component_const_sptr
source
=
getInstrument
()
->
getSource
();
Geometry
::
IComponent_const_sptr
source
=
getInstrument
()
->
getSource
();
Geometry
::
IComponent_const_sptr
sample
=
getInstrument
()
->
getSample
();
if
(
source
==
NULL
||
sample
==
NULL
)
{
...
...
Code/Mantid/Framework/Algorithms/src/AddPeak.cpp
View file @
2db727fc
...
...
@@ -75,7 +75,7 @@ namespace Algorithms
const
double
count
=
getProperty
(
"BinCount"
);
Mantid
::
Geometry
::
Instrument_const_sptr
instr
=
runWS
->
getInstrument
();
Mantid
::
Geometry
::
I
Obj
Component_const_sptr
source
=
instr
->
getSource
();
Mantid
::
Geometry
::
IComponent_const_sptr
source
=
instr
->
getSource
();
Mantid
::
Geometry
::
IComponent_const_sptr
sample
=
instr
->
getSample
();
Mantid
::
Geometry
::
IDetector_const_sptr
det
=
instr
->
getDetector
(
detID
);
...
...
Code/Mantid/Framework/Algorithms/src/ConvertSpectrumAxis.cpp
View file @
2db727fc
...
...
@@ -86,7 +86,7 @@ namespace Algorithms
{
Kernel
::
Unit_sptr
fromUnit
=
inputWS
->
getAxis
(
0
)
->
unit
();
Kernel
::
Unit_sptr
toUnit
=
UnitFactory
::
Instance
().
create
(
unitTarget
);
I
Obj
Component_const_sptr
source
=
inputWS
->
getInstrument
()
->
getSource
();
IComponent_const_sptr
source
=
inputWS
->
getInstrument
()
->
getSource
();
IComponent_const_sptr
sample
=
inputWS
->
getInstrument
()
->
getSample
();
std
::
vector
<
double
>
emptyVector
;
const
double
l1
=
source
->
getDistance
(
*
sample
);
...
...
Code/Mantid/Framework/Algorithms/src/ConvertSpectrumAxis2.cpp
View file @
2db727fc
...
...
@@ -134,7 +134,7 @@ namespace Algorithms
void
ConvertSpectrumAxis2
::
createElasticQMap
(
const
std
::
string
&
targetUnit
)
{
I
Obj
Component_const_sptr
source
=
m_inputWS
->
getInstrument
()
->
getSource
();
IComponent_const_sptr
source
=
m_inputWS
->
getInstrument
()
->
getSource
();
IComponent_const_sptr
sample
=
m_inputWS
->
getInstrument
()
->
getSample
();
const
std
::
string
emodeStr
=
getProperty
(
"EMode"
);
...
...
Code/Mantid/Framework/Algorithms/src/ConvertUnits.cpp
View file @
2db727fc
...
...
@@ -394,7 +394,7 @@ void ConvertUnits::convertViaTOF(Kernel::Unit_const_sptr fromUnit, API::MatrixWo
Kernel
::
Unit_const_sptr
outputUnit
=
outputWS
->
getAxis
(
0
)
->
unit
();
// Get the distance between the source and the sample (assume in metres)
I
Obj
Component_const_sptr
source
=
instrument
->
getSource
();
IComponent_const_sptr
source
=
instrument
->
getSource
();
IComponent_const_sptr
sample
=
instrument
->
getSample
();
if
(
source
==
NULL
||
sample
==
NULL
)
{
...
...
Code/Mantid/Framework/Algorithms/src/CreateLogTimeCorrection.cpp
View file @
2db727fc
...
...
@@ -124,7 +124,7 @@ namespace Algorithms
}
V3D
samplepos
=
sample
->
getPos
();
I
Obj
Component_const_sptr
source
=
m_instrument
->
getSource
();
IComponent_const_sptr
source
=
m_instrument
->
getSource
();
if
(
!
source
)
{
throw
runtime_error
(
"No source has been set."
);
...
...
Code/Mantid/Framework/Algorithms/src/DiffractionEventCalibrateDetectors.cpp
View file @
2db727fc
...
...
@@ -409,7 +409,7 @@ namespace Algorithms
outfile
<<
"# "
<<
DateAndTime
::
getCurrentTime
().
toFormattedString
(
"%c"
)
<<
"
\n
"
;
outfile
<<
"#
\n
"
;
outfile
<<
"6 L1 T0_SHIFT
\n
"
;
I
Obj
Component_const_sptr
source
=
inst
->
getSource
();
IComponent_const_sptr
source
=
inst
->
getSource
();
IComponent_const_sptr
sample
=
inst
->
getSample
();
outfile
<<
"7 "
<<
source
->
getDistance
(
*
sample
)
*
100
<<
" 0
\n
"
;
outfile
<<
"4 DETNUM NROWS NCOLS WIDTH HEIGHT DEPTH DETD CenterX CenterY CenterZ BaseX BaseY BaseZ UpX UpY UpZ
\n
"
;
...
...
Code/Mantid/Framework/Algorithms/src/EditInstrumentGeometry.cpp
View file @
2db727fc
...
...
@@ -207,7 +207,7 @@ namespace Algorithms
g_log
.
error
(
errmsg
);
throw
std
::
runtime_error
(
errmsg
);
}
Geometry
::
I
Obj
Component_const_sptr
source
=
originstrument
->
getSource
();
Geometry
::
IComponent_const_sptr
source
=
originstrument
->
getSource
();
Geometry
::
IComponent_const_sptr
sample
=
originstrument
->
getSample
();
l1
=
source
->
getDistance
(
*
sample
);
g_log
.
information
()
<<
"Retrieve L1 from input data workspace.
\n
"
;
...
...
Code/Mantid/Framework/Algorithms/src/GetEi.cpp
View file @
2db727fc
...
...
@@ -151,7 +151,7 @@ void GetEi::exec()
*/
void
GetEi
::
getGeometry
(
API
::
MatrixWorkspace_const_sptr
WS
,
specid_t
mon0Spec
,
specid_t
mon1Spec
,
double
&
monitor0Dist
,
double
&
monitor1Dist
)
const
{
const
I
Obj
Component_const_sptr
source
=
WS
->
getInstrument
()
->
getSource
();
const
IComponent_const_sptr
source
=
WS
->
getInstrument
()
->
getSource
();
// retrieve a pointer to the first detector and get its distance
size_t
monWI
=
0
;
...
...
Code/Mantid/Framework/Algorithms/src/GetEi2.cpp
View file @
2db727fc
...
...
@@ -295,7 +295,7 @@ double GetEi2::getDistanceFromSource(size_t ws_index) const
{
g_log
.
debug
()
<<
"Computing distance between spectrum at index '"
<<
ws_index
<<
"' and the source
\n
"
;
const
I
Obj
Component_const_sptr
source
=
m_input_ws
->
getInstrument
()
->
getSource
();
const
IComponent_const_sptr
source
=
m_input_ws
->
getInstrument
()
->
getSource
();
// Retrieve a pointer detector
IDetector_const_sptr
det
=
m_input_ws
->
getDetector
(
ws_index
);
if
(
!
det
)
...
...
Code/Mantid/Framework/Algorithms/src/MultipleScatteringCylinderAbsorption.cpp
View file @
2db727fc
...
...
@@ -144,7 +144,7 @@ void MultipleScatteringCylinderAbsorption::exec()
Instrument_const_sptr
instrument
=
in_WS
->
getInstrument
();
if
(
instrument
==
NULL
)
throw
std
::
runtime_error
(
"Failed to find instrument attached to InputWorkspace"
);
I
Obj
Component_const_sptr
source
=
instrument
->
getSource
();
IComponent_const_sptr
source
=
instrument
->
getSource
();
IComponent_const_sptr
sample
=
instrument
->
getSample
();
if
(
source
==
NULL
)
throw
std
::
runtime_error
(
"Failed to find source in the instrument for InputWorkspace"
);
...
...
Code/Mantid/Framework/Algorithms/src/SofQW.cpp
View file @
2db727fc
...
...
@@ -114,7 +114,7 @@ void SofQW::exec()
Instrument_const_sptr
instrument
=
inputWorkspace
->
getInstrument
();
// Get the distance between the source and the sample (assume in metres)
I
Obj
Component_const_sptr
source
=
instrument
->
getSource
();
IComponent_const_sptr
source
=
instrument
->
getSource
();
IComponent_const_sptr
sample
=
instrument
->
getSample
();
V3D
beamDir
=
sample
->
getPos
()
-
source
->
getPos
();
beamDir
.
normalize
();
...
...
Code/Mantid/Framework/Crystal/inc/MantidCrystal/SCDCalibratePanels.h
View file @
2db727fc
...
...
@@ -197,7 +197,7 @@ namespace Crystal
*
*/
static
void
updateSourceParams
(
boost
::
shared_ptr
<
const
Geometry
::
I
Obj
Component
>
bank_const
,
boost
::
shared_ptr
<
const
Geometry
::
IComponent
>
bank_const
,
boost
::
shared_ptr
<
Geometry
::
ParameterMap
>
pmap
,
boost
::
shared_ptr
<
const
Geometry
::
ParameterMap
>
pmapSv
);
...
...
Code/Mantid/Framework/Crystal/src/SCDCalibratePanels.cpp
View file @
2db727fc
...
...
@@ -1145,7 +1145,7 @@ namespace Mantid
double
mL1
;
stringstream
(
line
)
>>
count
>>
mL1
>>
T0
;
double
scaleL0
=
.01
*
mL1
/
beamlineLen
;
const
I
Obj
Component_const_sptr
source
=
instrument
->
getSource
();
const
IComponent_const_sptr
source
=
instrument
->
getSource
();
V3D
NewSourcePos
=
samplePos
-
beamline
*
scaleL0
*
2.0
;
//beamLine is 2*length.
L0
=
beamline
.
norm
()
*
scaleL0
*
2.0
;
V3D
RelSourcePos
=
source
->
getRelativePos
()
+
NewSourcePos
-
source
->
getPos
();
...
...
@@ -1617,7 +1617,7 @@ namespace Mantid
}
void
SCDCalibratePanels
::
updateSourceParams
(
boost
::
shared_ptr
<
const
Geometry
::
I
Obj
Component
>
bank_const
,
void
SCDCalibratePanels
::
updateSourceParams
(
boost
::
shared_ptr
<
const
Geometry
::
IComponent
>
bank_const
,
boost
::
shared_ptr
<
Geometry
::
ParameterMap
>
pmap
,
boost
::
shared_ptr
<
const
Geometry
::
ParameterMap
>
pmapSv
)
{
vector
<
V3D
>
posv
=
pmapSv
->
getV3D
(
bank_const
->
getName
(),
"pos"
);
...
...
@@ -1642,7 +1642,7 @@ namespace Mantid
boost
::
shared_ptr
<
const
ParameterMap
>
const
pmapOld
)
{
boost
::
shared_ptr
<
ParameterMap
>
pmap
=
NewInstrument
->
getParameterMap
();
I
Obj
Component_const_sptr
source
=
NewInstrument
->
getSource
();
IComponent_const_sptr
source
=
NewInstrument
->
getSource
();
updateSourceParams
(
source
,
pmap
,
pmapOld
);
IComponent_const_sptr
sample
=
NewInstrument
->
getSample
();
...
...
@@ -1801,7 +1801,7 @@ namespace Mantid
}
// for each group
// write out the source
I
Obj
Component_const_sptr
source
=
instrument
->
getSource
();
IComponent_const_sptr
source
=
instrument
->
getSource
();
oss3
<<
"<component-link name=
\"
"
<<
source
->
getName
()
<<
"
\"
>"
<<
endl
;
IComponent_const_sptr
sample
=
instrument
->
getSample
();
...
...
Code/Mantid/Framework/DataHandling/src/AppendGeometryToSNSNexus.cpp
View file @
2db727fc
...
...
@@ -194,7 +194,7 @@ namespace DataHandling
// Get the sample (needed to calculate distances)
Geometry
::
IComponent_const_sptr
sample
=
instrument
->
getSample
();
// Get the source (moderator)
Geometry
::
I
Obj
Component_const_sptr
source
=
instrument
->
getSource
();
Geometry
::
IComponent_const_sptr
source
=
instrument
->
getSource
();
// Open the NeXus file
::
NeXus
::
File
nxfile
(
m_filename
,
NXACC_RDWR
);
...
...
Code/Mantid/Framework/DataHandling/src/SaveFocusedXYE.cpp
View file @
2db727fc
...
...
@@ -333,7 +333,7 @@ void SaveFocusedXYE::getFocusedPos(Mantid::API::MatrixWorkspace_const_sptr wksp,
tth
=
0.
;
return
;
}
Geometry
::
I
Obj
Component_const_sptr
source
=
instrument
->
getSource
();
Geometry
::
IComponent_const_sptr
source
=
instrument
->
getSource
();
Geometry
::
IComponent_const_sptr
sample
=
instrument
->
getSample
();
if
(
source
==
NULL
||
sample
==
NULL
)
{
...
...
Code/Mantid/Framework/DataHandling/src/SaveGSS.cpp
View file @
2db727fc
...
...
@@ -93,7 +93,7 @@ namespace Mantid
tth
=
0.
;
return
;
}
Geometry
::
I
Obj
Component_const_sptr
source
=
instrument
->
getSource
();
Geometry
::
IComponent_const_sptr
source
=
instrument
->
getSource
();
Geometry
::
IComponent_const_sptr
sample
=
instrument
->
getSample
();
if
(
source
==
NULL
||
sample
==
NULL
)
{
...
...
@@ -143,7 +143,7 @@ namespace Mantid
Progress
p
(
this
,
0.0
,
1.0
,
nHist
);
double
l1
,
l2
,
tth
;
Geometry
::
Instrument_const_sptr
instrument
=
inputWS
->
getInstrument
();
Geometry
::
I
Obj
Component_const_sptr
source
;
Geometry
::
IComponent_const_sptr
source
;
Geometry
::
IComponent_const_sptr
sample
;
if
(
instrument
!=
NULL
)
{
...
...
Code/Mantid/Framework/DataHandling/test/LoadInstrumentTest.h
View file @
2db727fc
...
...
@@ -178,7 +178,7 @@ public:
void
evaluate_GEM
(
MatrixWorkspace_sptr
output
)
{
boost
::
shared_ptr
<
const
Instrument
>
i
=
output
->
getInstrument
();
boost
::
shared_ptr
<
const
I
Obj
Component
>
source
=
i
->
getSource
();
boost
::
shared_ptr
<
const
IComponent
>
source
=
i
->
getSource
();
TS_ASSERT_EQUALS
(
source
->
getName
(),
"undulator"
);
TS_ASSERT_DELTA
(
source
->
getPos
().
Z
(),
-
17.0
,
0.01
);
...
...
@@ -292,7 +292,7 @@ public:
TS_ASSERT_THROWS_NOTHING
(
output
=
AnalysisDataService
::
Instance
().
retrieveWS
<
MatrixWorkspace
>
(
wsName
));
boost
::
shared_ptr
<
const
Instrument
>
i
=
output
->
getInstrument
();
boost
::
shared_ptr
<
const
I
Obj
Component
>
source
=
i
->
getSource
();
boost
::
shared_ptr
<
const
IComponent
>
source
=
i
->
getSource
();
TS_ASSERT_EQUALS
(
source
->
getName
(),
"undulator"
);
TS_ASSERT_DELTA
(
source
->
getPos
().
Z
(),
-
11.016
,
0.01
);
...
...
Code/Mantid/Framework/DataObjects/src/Peak.cpp
View file @
2db727fc
...
...
@@ -319,7 +319,7 @@ namespace DataObjects
if
(
!
inst
)
throw
std
::
runtime_error
(
"Peak::setInstrument(): No instrument is set!"
);
// Cache some positions
const
Geometry
::
I
Obj
Component_const_sptr
sourceObj
=
m_inst
->
getSource
();
const
Geometry
::
IComponent_const_sptr
sourceObj
=
m_inst
->
getSource
();
if
(
sourceObj
==
NULL
)
throw
Exception
::
InstrumentDefinitionError
(
"Peak::setInstrument(): Failed to get source component from instrument"
);
const
Geometry
::
IComponent_const_sptr
sampleObj
=
m_inst
->
getSample
();
...
...
Code/Mantid/Framework/Geometry/inc/MantidGeometry/Instrument.h
View file @
2db727fc
...
...
@@ -75,7 +75,7 @@ namespace Mantid
Instrument
*
clone
()
const
;
I
Obj
Component_const_sptr
getSource
()
const
;
IComponent_const_sptr
getSource
()
const
;
IObjComponent_const_sptr
getChopperPoint
(
const
size_t
index
=
0
)
const
;
size_t
getNumberOfChopperPoints
()
const
;
IComponent_const_sptr
getSample
()
const
;
...
...
@@ -107,7 +107,7 @@ namespace Mantid
/// mark a Component which has already been added to the Instrument (as a child comp.)
/// to be 'the' source Component. For now it is assumed that we have
/// at most one of these.
void
markAsSource
(
const
Obj
Component
*
);
void
markAsSource
(
const
I
Component
*
);
/// mark a Component which has already been added to the Instrument (as a child comp.)
/// to be a Detector component by adding it to _detectorCache
...
...
@@ -245,7 +245,7 @@ namespace Mantid
std
::
map
<
detid_t
,
IDetector_const_sptr
>
m_detectorCache
;
/// Purpose to hold copy of source component. For now assumed to be just one component
const
Obj
Component
*
m_sourceCache
;
const
I
Component
*
m_sourceCache
;
/// Hold a list of places where a chopper can be situated
/// A pointer so that parameterized intruments are still fast to create.
...
...
Prev
1
2
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