Commit 2db727fc authored by Anders Markvardsen's avatar Anders Markvardsen
Browse files

store store as IComponent. re #9133

and added unit test to test ok
parent 3c6f26cd
......@@ -750,7 +750,7 @@ namespace Mantid
{
Instrument_const_sptr instrument = getInstrument();
Geometry::IObjComponent_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::IObjComponent_const_sptr source = getInstrument()->getSource();
Geometry::IComponent_const_sptr source = getInstrument()->getSource();
Geometry::IComponent_const_sptr sample = getInstrument()->getSample();
if ( source == NULL || sample == NULL )
{
......
......@@ -75,7 +75,7 @@ namespace Algorithms
const double count = getProperty("BinCount");
Mantid::Geometry::Instrument_const_sptr instr = runWS->getInstrument();
Mantid::Geometry::IObjComponent_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);
......
......@@ -86,7 +86,7 @@ namespace Algorithms
{
Kernel::Unit_sptr fromUnit = inputWS->getAxis(0)->unit();
Kernel::Unit_sptr toUnit = UnitFactory::Instance().create(unitTarget);
IObjComponent_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);
......
......@@ -134,7 +134,7 @@ namespace Algorithms
void ConvertSpectrumAxis2::createElasticQMap(const std::string & targetUnit)
{
IObjComponent_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");
......
......@@ -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)
IObjComponent_const_sptr source = instrument->getSource();
IComponent_const_sptr source = instrument->getSource();
IComponent_const_sptr sample = instrument->getSample();
if ( source == NULL || sample == NULL )
{
......
......@@ -124,7 +124,7 @@ namespace Algorithms
}
V3D samplepos = sample->getPos();
IObjComponent_const_sptr source = m_instrument->getSource();
IComponent_const_sptr source = m_instrument->getSource();
if (!source)
{
throw runtime_error("No source has been set.");
......
......@@ -409,7 +409,7 @@ namespace Algorithms
outfile << "# "<< DateAndTime::getCurrentTime().toFormattedString("%c") <<"\n";
outfile << "#\n";
outfile << "6 L1 T0_SHIFT\n";
IObjComponent_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";
......
......@@ -207,7 +207,7 @@ namespace Algorithms
g_log.error(errmsg);
throw std::runtime_error(errmsg);
}
Geometry::IObjComponent_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";
......
......@@ -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 IObjComponent_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;
......
......@@ -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 IObjComponent_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 )
......
......@@ -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");
IObjComponent_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");
......
......@@ -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)
IObjComponent_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();
......
......@@ -197,7 +197,7 @@ namespace Crystal
*
*/
static void updateSourceParams(
boost::shared_ptr<const Geometry::IObjComponent> bank_const,
boost::shared_ptr<const Geometry::IComponent> bank_const,
boost::shared_ptr<Geometry::ParameterMap> pmap,
boost::shared_ptr<const Geometry::ParameterMap> pmapSv);
......
......@@ -1145,7 +1145,7 @@ namespace Mantid
double mL1;
stringstream(line) >> count >> mL1 >> T0;
double scaleL0= .01*mL1/beamlineLen;
const IObjComponent_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::IObjComponent> 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();
IObjComponent_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
IObjComponent_const_sptr source = instrument->getSource();
IComponent_const_sptr source = instrument->getSource();
oss3 << "<component-link name=\"" << source->getName() << "\">" << endl;
IComponent_const_sptr sample = instrument->getSample();
......
......@@ -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::IObjComponent_const_sptr source = instrument->getSource();
Geometry::IComponent_const_sptr source = instrument->getSource();
// Open the NeXus file
::NeXus::File nxfile(m_filename, NXACC_RDWR);
......
......@@ -333,7 +333,7 @@ void SaveFocusedXYE::getFocusedPos(Mantid::API::MatrixWorkspace_const_sptr wksp,
tth = 0.;
return;
}
Geometry::IObjComponent_const_sptr source = instrument->getSource();
Geometry::IComponent_const_sptr source = instrument->getSource();
Geometry::IComponent_const_sptr sample = instrument->getSample();
if (source == NULL || sample == NULL)
{
......
......@@ -93,7 +93,7 @@ namespace Mantid
tth = 0.;
return;
}
Geometry::IObjComponent_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::IObjComponent_const_sptr source;
Geometry::IComponent_const_sptr source;
Geometry::IComponent_const_sptr sample;
if (instrument != NULL)
{
......
......@@ -178,7 +178,7 @@ public:
void evaluate_GEM(MatrixWorkspace_sptr output)
{
boost::shared_ptr<const Instrument> i = output->getInstrument();
boost::shared_ptr<const IObjComponent> 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 IObjComponent> 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);
......
......@@ -319,7 +319,7 @@ namespace DataObjects
if (!inst) throw std::runtime_error("Peak::setInstrument(): No instrument is set!");
// Cache some positions
const Geometry::IObjComponent_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();
......
......@@ -75,7 +75,7 @@ namespace Mantid
Instrument* clone() const;
IObjComponent_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 ObjComponent*);
void markAsSource(const IComponent*);
/// 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 ObjComponent* m_sourceCache;
const IComponent* m_sourceCache;
/// Hold a list of places where a chopper can be situated
/// A pointer so that parameterized intruments are still fast to create.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment