diff --git a/Code/Mantid/Framework/SINQ/inc/MantidSINQ/PoldiAutoCorrelation5.h b/Code/Mantid/Framework/SINQ/inc/MantidSINQ/PoldiAutoCorrelation5.h index 484385e256ad..87cd373f02f1 100644 --- a/Code/Mantid/Framework/SINQ/inc/MantidSINQ/PoldiAutoCorrelation5.h +++ b/Code/Mantid/Framework/SINQ/inc/MantidSINQ/PoldiAutoCorrelation5.h @@ -12,6 +12,7 @@ #include "MantidKernel/PhysicalConstants.h" #include "MantidSINQ/PoldiUtilities/PoldiAutoCorrelationCore.h" +#include "MantidSINQ/PoldiUtilities/PoldiDeadWireDecorator.h" @@ -76,15 +77,11 @@ class MANTID_SINQ_DLL PoldiAutoCorrelation5 : public API::Algorithm /// Algorithm's category for identification overriding a virtual method virtual const std::string category() const { return "SINQ\\Poldi"; } - - protected: /// Overwrites Algorithm method void exec(); - - - + void logConfigurationInformation(boost::shared_ptr cleanDetector, PoldiAbstractChopper_sptr chopper); private: /// Overwrites Algorithm method. diff --git a/Code/Mantid/Framework/SINQ/src/PoldiAutoCorrelation5.cpp b/Code/Mantid/Framework/SINQ/src/PoldiAutoCorrelation5.cpp index 3e2e71a53886..078e4663460b 100644 --- a/Code/Mantid/Framework/SINQ/src/PoldiAutoCorrelation5.cpp +++ b/Code/Mantid/Framework/SINQ/src/PoldiAutoCorrelation5.cpp @@ -7,15 +7,8 @@ #include "MantidDataObjects/MaskWorkspace.h" #include "MantidDataObjects/TableWorkspace.h" -#include "MantidSINQ/PoldiUtilities/PoldiDetectorFactory.h" #include "MantidSINQ/PoldiUtilities/PoldiDeadWireDecorator.h" -#include "MantidSINQ/PoldiUtilities/PoldiAutoCorrelationCore.h" -#include "MantidSINQ/PoldiUtilities/PoldiChopperFactory.h" - -#include "MantidGeometry/IComponent.h" -#include "MantidGeometry/Instrument.h" -#include "MantidGeometry/Instrument/FitParameter.h" -#include "MantidGeometry/Instrument/DetectorGroup.h" +#include "MantidSINQ/PoldiUtilities/PoldiInstrumentAdapter.h" #include @@ -84,60 +77,15 @@ void PoldiAutoCorrelation5::exec() double wlen_min = this->getProperty("wlenmin"); double wlen_max = this->getProperty("wlenmax"); - double chopperSpeed = 0.0; - - try { - chopperSpeed = localWorkspace->run().getPropertyValueAsType >("chopperspeed").front(); - } catch(std::invalid_argument&) { - throw(std::runtime_error("Chopper speed could not be extracted from Workspace '" + localWorkspace->name() + "'. Aborting.")); - } - // Instrument definition - Instrument_const_sptr poldiInstrument = localWorkspace->getInstrument(); - - // Chopper configuration - PoldiChopperFactory chopperFactory; - boost::shared_ptr chopper(chopperFactory.createChopper(std::string("default-chopper"))); - chopper->loadConfiguration(poldiInstrument); - chopper->setRotationSpeed(chopperSpeed); - - g_log.information() << "____________________________________________________ " << std::endl; - g_log.information() << "_Poldi chopper conf ------------------------------ " << std::endl; - g_log.information() << "_Poldi - Chopper speed: " << chopper->rotationSpeed() << " rpm" << std::endl; - g_log.information() << "_Poldi - Number of slits: " << chopper->slitPositions().size() << std::endl; - g_log.information() << "_Poldi - Cycle time: " << chopper->cycleTime() << " µs" << std::endl; - g_log.information() << "_Poldi - Zero offset: " << chopper->zeroOffset() << " µs" << std::endl; - g_log.information() << "_Poldi - Distance: " << chopper->distanceFromSample() << " mm" << std::endl; - - if(g_log.is(Poco::Message::PRIO_DEBUG)) { - for(size_t i = 0; i < chopper->slitPositions().size(); ++i) { - g_log.information() << "_Poldi - Slits: " << i - << ": Position = " << chopper->slitPositions()[i] - << "\t Time = " << chopper->slitTimes()[i] << " µs" << std::endl; - } - } + PoldiInstrumentAdapter instrumentAdapter(localWorkspace); + PoldiAbstractChopper_sptr chopper = instrumentAdapter.chopper(); - // Detector configuration - PoldiDetectorFactory detectorFactory; - boost::shared_ptr detector(detectorFactory.createDetector(std::string("helium3-detector"))); - detector->loadConfiguration(poldiInstrument); - - g_log.information() << "_Poldi detector conf ------------------------------ " << std::endl; - g_log.information() << "_Poldi - Element count: " << detector->elementCount() << std::endl; - g_log.information() << "_Poldi - Central element: " << detector->centralElement() << std::endl; - g_log.information() << "_Poldi - 2Theta(central): " << detector->twoTheta(199) / M_PI * 180.0 << "°" << std::endl; - g_log.information() << "_Poldi - Distance(central): " << detector->distanceFromSample(199) << " mm" << std::endl; - - boost::shared_ptr cleanDetector(new PoldiDeadWireDecorator(poldiInstrument, detector)); - - std::set deadWires = cleanDetector->deadWires(); - g_log.information() << "_Poldi - Number of dead wires: " << deadWires.size() << std::endl; - g_log.information() << "_Poldi - Wire indices: "; - for(std::set::const_iterator dw = deadWires.begin(); dw != deadWires.end(); ++dw) { - g_log.information() << *dw << " "; - } - g_log.information() << std::endl; + PoldiAbstractDetector_sptr detector = instrumentAdapter.detector(); + boost::shared_ptr cleanDetector(new PoldiDeadWireDecorator(localWorkspace->getInstrument(), detector)); + // log configuration information + logConfigurationInformation(cleanDetector, chopper); // putting together POLDI instrument for calculations m_core->setInstrument(cleanDetector, chopper); @@ -160,5 +108,41 @@ void PoldiAutoCorrelation5::exec() } } +void PoldiAutoCorrelation5::logConfigurationInformation(boost::shared_ptr cleanDetector, PoldiAbstractChopper_sptr chopper) +{ + if(cleanDetector && chopper) { + g_log.information() << "____________________________________________________ " << std::endl; + g_log.information() << "_Poldi chopper conf ------------------------------ " << std::endl; + g_log.information() << "_Poldi - Chopper speed: " << chopper->rotationSpeed() << " rpm" << std::endl; + g_log.information() << "_Poldi - Number of slits: " << chopper->slitPositions().size() << std::endl; + g_log.information() << "_Poldi - Cycle time: " << chopper->cycleTime() << " µs" << std::endl; + g_log.information() << "_Poldi - Zero offset: " << chopper->zeroOffset() << " µs" << std::endl; + g_log.information() << "_Poldi - Distance: " << chopper->distanceFromSample() << " mm" << std::endl; + + if(g_log.is(Poco::Message::PRIO_DEBUG)) { + for(size_t i = 0; i < chopper->slitPositions().size(); ++i) { + g_log.information() << "_Poldi - Slits: " << i + << ": Position = " << chopper->slitPositions()[i] + << "\t Time = " << chopper->slitTimes()[i] << " µs" << std::endl; + } + } + + g_log.information() << "_Poldi detector conf ------------------------------ " << std::endl; + g_log.information() << "_Poldi - Element count: " << cleanDetector->elementCount() << std::endl; + g_log.information() << "_Poldi - Central element: " << cleanDetector->centralElement() << std::endl; + g_log.information() << "_Poldi - 2Theta(central): " << cleanDetector->twoTheta(199) / M_PI * 180.0 << "°" << std::endl; + g_log.information() << "_Poldi - Distance(central): " << cleanDetector->distanceFromSample(199) << " mm" << std::endl; + + + std::set deadWires = cleanDetector->deadWires(); + g_log.information() << "_Poldi - Number of dead wires: " << deadWires.size() << std::endl; + g_log.information() << "_Poldi - Wire indices: "; + for(std::set::const_iterator dw = deadWires.begin(); dw != deadWires.end(); ++dw) { + g_log.information() << *dw << " "; + } + g_log.information() << std::endl; + } +} + } // namespace Poldi } // namespace Mantid