diff --git a/Framework/Algorithms/src/CalculateCountRate.cpp b/Framework/Algorithms/src/CalculateCountRate.cpp index cfa85736e5f1c60aaee4fbaa2cb1ee6ffbd9dec9..129cf2f368ff8a1564453bb2cf619e8678464d71 100644 --- a/Framework/Algorithms/src/CalculateCountRate.cpp +++ b/Framework/Algorithms/src/CalculateCountRate.cpp @@ -1,12 +1,12 @@ #include "MantidAlgorithms/CalculateCountRate.h" -#include "MantidKernel/PropertyWithValue.h" #include "MantidKernel/BoundedValidator.h" -#include "MantidKernel/TimeSeriesProperty.h" #include "MantidKernel/ListValidator.h" +#include "MantidKernel/MandatoryValidator.h" +#include "MantidKernel/PropertyWithValue.h" +#include "MantidKernel/TimeSeriesProperty.h" #include "MantidKernel/Unit.h" #include "MantidKernel/UnitFactory.h" -#include "MantidKernel/MandatoryValidator.h" #include "MantidKernel/make_unique.h" #include "MantidAPI/AlgorithmManager.h" @@ -18,6 +18,8 @@ #include "MantidDataObjects/Workspace2D.h" #include <numeric> +using Mantid::Types::TofEvent; + namespace Mantid { namespace Algorithms { @@ -184,14 +186,14 @@ void CalculateCountRate::exec() { } /** Process input workspace to calculate instrument counting rate as function of -*experiment time -*@param InputWorkspace :: shared pointer to the input workspace to process -*@param targLog :: pointer to time series property containing count rate -*log. -* Property should exist on input and will be modified -*with -* counting rate log on output. -*/ + *experiment time + *@param InputWorkspace :: shared pointer to the input workspace to process + *@param targLog :: pointer to time series property containing count rate + *log. + * Property should exist on input and will be modified + *with + * counting rate log on output. + */ void CalculateCountRate::calcRateLog( DataObjects::EventWorkspace_sptr &InputWorkspace, Kernel::TimeSeriesProperty<double> *const targLog) { @@ -267,17 +269,17 @@ void CalculateCountRate::calcRateLog( double dt = (dTRangeMax - dTRangeMin) / static_cast<double>(m_numLogSteps); auto t0 = m_TRangeMin.totalNanoseconds(); for (auto i = 0; i < m_numLogSteps; i++) { - times[i] = - Mantid::Types::DateAndTime(t0 + static_cast<int64_t>((0.5 + double(i)) * dt)); + times[i] = Mantid::Types::DateAndTime( + t0 + static_cast<int64_t>((0.5 + double(i)) * dt)); } // store calculated values within the target log. targLog->replaceValues(times, countRate); } /** histogram event list into visualization workspace -* @param el :: event list to rebin into visualization workspace -* @param spectraLocks :: pointer to the array of mutexes to lock modifyed -* visualization workspace spectra for a thread -*/ + * @param el :: event list to rebin into visualization workspace + * @param spectraLocks :: pointer to the array of mutexes to lock modifyed + * visualization workspace spectra for a thread + */ void CalculateCountRate::histogramEvents(const DataObjects::EventList &el, std::mutex *spectraLocks) { @@ -285,7 +287,7 @@ void CalculateCountRate::histogramEvents(const DataObjects::EventList &el, return; auto events = el.getEvents(); - for (const DataObjects::TofEvent &ev : events) { + for (const TofEvent &ev : events) { double pulsetime = static_cast<double>(ev.pulseTime().totalNanoseconds()); double tof = ev.tof(); if (pulsetime < m_visT0 || pulsetime >= m_visTmax) @@ -499,7 +501,7 @@ void CalculateCountRate::setOutLogParameters( *@return -- the input workspace cropped according to XMin-XMax ranges in units, * requested by the user * -*/ + */ void CalculateCountRate::setSourceWSandXRanges( DataObjects::EventWorkspace_sptr &InputWorkspace) { @@ -583,15 +585,15 @@ void CalculateCountRate::setSourceWSandXRanges( if (m_XRangeMin > m_XRangeMax) { throw std::invalid_argument(" Minimal spurion search data limit is bigger " "than the maximal limit. ( Min: " + - std::to_string(m_XRangeMin) + "> Max: " + - std::to_string(m_XRangeMax) + ")"); + std::to_string(m_XRangeMin) + + "> Max: " + std::to_string(m_XRangeMax) + ")"); } } /**Check if visualization workspace is necessary and initiate it if requested. -* Sets or clears up internal m_visWS pointer and "do-visualization workspace" -* option. -*/ + * Sets or clears up internal m_visWS pointer and "do-visualization workspace" + * option. + */ void CalculateCountRate::checkAndInitVisWorkspace() { std::string visWSName = getProperty("VisualizationWs"); if (visWSName.empty()) { @@ -684,13 +686,13 @@ void CalculateCountRate::checkAndInitVisWorkspace() { bool CalculateCountRate::buildVisWS() const { return m_doVis; } /** Helper function, mainly for testing -* @return true if count rate should be normalized and false -* otherwise */ + * @return true if count rate should be normalized and false + * otherwise */ bool CalculateCountRate::normalizeCountRate() const { return m_normalizeResult; } /** Helper function, mainly for testing -* @return true if log derivative is used instead of log itself */ + * @return true if log derivative is used instead of log itself */ bool CalculateCountRate::useLogDerivative() const { return m_useLogDerivative; } /** method to prepare normalization vector for the visualisation workspace using diff --git a/Framework/Algorithms/src/CompareWorkspaces.cpp b/Framework/Algorithms/src/CompareWorkspaces.cpp index e98c756f72fd2c21f24d9e062a729f9b71597267..f438bf6b1d7a4d8155028488a72f30bbdae6604a 100644 --- a/Framework/Algorithms/src/CompareWorkspaces.cpp +++ b/Framework/Algorithms/src/CompareWorkspaces.cpp @@ -23,6 +23,7 @@ using namespace Mantid::API; using namespace Mantid::Kernel; using namespace Mantid::DataObjects; using namespace Mantid::Geometry; +using Mantid::Types::TofEvent; // Register the algorithm into the AlgorithmFactory DECLARE_ALGORITHM(CompareWorkspaces) diff --git a/Framework/Algorithms/src/EQSANSTofStructure.cpp b/Framework/Algorithms/src/EQSANSTofStructure.cpp index 7e8d339778348fce067c999c77aecad29b43c2e7..7496b53f2a6a48b0e8a2f275688ce8b7cd9784a3 100644 --- a/Framework/Algorithms/src/EQSANSTofStructure.cpp +++ b/Framework/Algorithms/src/EQSANSTofStructure.cpp @@ -2,9 +2,9 @@ #include "MantidAPI/Run.h" #include "MantidAPI/SpectrumInfo.h" #include "MantidAPI/WorkspaceUnitValidator.h" -#include "MantidDataObjects/Events.h" #include "MantidDataObjects/EventList.h" #include "MantidDataObjects/EventWorkspace.h" +#include "MantidDataObjects/Events.h" #include "MantidGeometry/Instrument.h" #include "MantidKernel/TimeSeriesProperty.h" @@ -13,6 +13,7 @@ using namespace Mantid::Kernel; using namespace Mantid::DataObjects; using namespace Mantid::Geometry; +using Mantid::Types::TofEvent; namespace Mantid { namespace Algorithms { @@ -36,13 +37,15 @@ void EQSANSTofStructure::init() { declareProperty("FlightPathCorrection", false, "If True, the neutron flight path correction will be applied", Kernel::Direction::Input); - declareProperty("LowTOFCut", 0.0, "Width of the TOF margin to cut on the " - "lower end of the TOF distribution of each " - "frame", + declareProperty("LowTOFCut", 0.0, + "Width of the TOF margin to cut on the " + "lower end of the TOF distribution of each " + "frame", Kernel::Direction::Input); - declareProperty("HighTOFCut", 0.0, "Width of the TOF margin to cut on the " - "upper end of the TOF distribution of " - "each frame", + declareProperty("HighTOFCut", 0.0, + "Width of the TOF margin to cut on the " + "upper end of the TOF distribution of " + "each frame", Kernel::Direction::Input); // Output parameters @@ -349,12 +352,12 @@ double EQSANSTofStructure::getTofOffset(EventWorkspace_const_sptr inputWS, bool passed = false; do { - frame_wl_1 = c_wl_1[0] = - chopper_wl_1[0] + - 3.9560346 * n_frame[0] * tof_frame_width / CHOPPER_LOCATION[0]; - frame_wl_2 = c_wl_2[0] = - chopper_wl_2[0] + - 3.9560346 * n_frame[0] * tof_frame_width / CHOPPER_LOCATION[0]; + frame_wl_1 = c_wl_1[0] = chopper_wl_1[0] + 3.9560346 * n_frame[0] * + tof_frame_width / + CHOPPER_LOCATION[0]; + frame_wl_2 = c_wl_2[0] = chopper_wl_2[0] + 3.9560346 * n_frame[0] * + tof_frame_width / + CHOPPER_LOCATION[0]; for (int i = 1; i < 4; i++) { n_frame[i] = n_frame[i - 1] - 1; @@ -362,12 +365,12 @@ double EQSANSTofStructure::getTofOffset(EventWorkspace_const_sptr inputWS, do { n_frame[i] += 1; - c_wl_1[i] = - chopper_wl_1[i] + - 3.9560346 * n_frame[i] * tof_frame_width / CHOPPER_LOCATION[i]; - c_wl_2[i] = - chopper_wl_2[i] + - 3.9560346 * n_frame[i] * tof_frame_width / CHOPPER_LOCATION[i]; + c_wl_1[i] = chopper_wl_1[i] + 3.9560346 * n_frame[i] * + tof_frame_width / + CHOPPER_LOCATION[i]; + c_wl_2[i] = chopper_wl_2[i] + 3.9560346 * n_frame[i] * + tof_frame_width / + CHOPPER_LOCATION[i]; if (frame_wl_1 < c_wl_2[i] && frame_wl_2 > c_wl_1[i]) { passed = true; @@ -401,12 +404,12 @@ double EQSANSTofStructure::getTofOffset(EventWorkspace_const_sptr inputWS, chopper_wl_1[i] = c_wl_1[i]; chopper_wl_2[i] = c_wl_2[i]; if (frame_skipping) { - chopper_frameskip_wl_1[i] = - c_wl_1[i] + - 3.9560346 * 2. * tof_frame_width / CHOPPER_LOCATION[i]; - chopper_frameskip_wl_2[i] = - c_wl_2[i] + - 3.9560346 * 2. * tof_frame_width / CHOPPER_LOCATION[i]; + chopper_frameskip_wl_1[i] = c_wl_1[i] + 3.9560346 * 2. * + tof_frame_width / + CHOPPER_LOCATION[i]; + chopper_frameskip_wl_2[i] = c_wl_2[i] + 3.9560346 * 2. * + tof_frame_width / + CHOPPER_LOCATION[i]; if (i == 0) { frameskip_wl_1 = chopper_frameskip_wl_1[i]; frameskip_wl_2 = chopper_frameskip_wl_2[i]; diff --git a/Framework/Algorithms/src/ExtractSpectra.cpp b/Framework/Algorithms/src/ExtractSpectra.cpp index bff8830bd560868d63d4548db0f865df761de895..ba3e41e43172c6cd07f79ba92ca2c47e31119a4a 100644 --- a/Framework/Algorithms/src/ExtractSpectra.cpp +++ b/Framework/Algorithms/src/ExtractSpectra.cpp @@ -23,6 +23,7 @@ namespace Algorithms { using namespace Kernel; using namespace API; using namespace DataObjects; +using Mantid::Types::TofEvent; // Register the algorithm into the AlgorithmFactory DECLARE_ALGORITHM(ExtractSpectra) diff --git a/Framework/Algorithms/test/DiffractionFocussing2Test.h b/Framework/Algorithms/test/DiffractionFocussing2Test.h index df4762852c2a30c380907bb6c5963c17a17b77cc..a114b8de97d854002be5d23e0a5009030334b074 100644 --- a/Framework/Algorithms/test/DiffractionFocussing2Test.h +++ b/Framework/Algorithms/test/DiffractionFocussing2Test.h @@ -23,6 +23,7 @@ using namespace Mantid::Kernel; using namespace Mantid::Algorithms; using namespace Mantid::DataObjects; using Mantid::HistogramData::BinEdges; +using Mantid::Types::TofEvent; class DiffractionFocussing2Test : public CxxTest::TestSuite { public: diff --git a/Framework/Algorithms/test/FilterEventsTest.h b/Framework/Algorithms/test/FilterEventsTest.h index be386fe941cbc0110266da9a16e409d7c26cf66c..16cb63b6f81ff4b4a76b5d4b28b0b74aa23ddba7 100644 --- a/Framework/Algorithms/test/FilterEventsTest.h +++ b/Framework/Algorithms/test/FilterEventsTest.h @@ -24,6 +24,7 @@ using namespace Mantid::Algorithms; using namespace Mantid::API; using namespace Mantid::DataObjects; using namespace Mantid::Geometry; +using Mantid::Types::TofEvent; using namespace std; diff --git a/Framework/Algorithms/test/ModeratorTzeroLinearTest.h b/Framework/Algorithms/test/ModeratorTzeroLinearTest.h index 9291aad794806971e1a0f791f12ea6dfb744065c..beaf1c707b6093332ca68656d8531030c31f52b9 100644 --- a/Framework/Algorithms/test/ModeratorTzeroLinearTest.h +++ b/Framework/Algorithms/test/ModeratorTzeroLinearTest.h @@ -16,6 +16,7 @@ using namespace Mantid::API; using namespace Mantid::DataObjects; using Mantid::HistogramData::BinEdges; using Mantid::HistogramData::LinearGenerator; +using Mantid::Types::TofEvent; namespace { void addToInstrument(MatrixWorkspace_sptr testWS, diff --git a/Framework/Algorithms/test/ModeratorTzeroTest.h b/Framework/Algorithms/test/ModeratorTzeroTest.h index 679ba8c9a8cdf024050616ee955cf945c6aafcd1..459baf950bbb4c2733fbc8a4d7dc8ebe727345bd 100644 --- a/Framework/Algorithms/test/ModeratorTzeroTest.h +++ b/Framework/Algorithms/test/ModeratorTzeroTest.h @@ -19,6 +19,7 @@ using namespace Mantid::DataObjects; using namespace Mantid::Algorithms; using Mantid::HistogramData::BinEdges; using Mantid::HistogramData::LinearGenerator; +using Mantid::Types::TofEvent; namespace { void AddToIndirectInstrument(MatrixWorkspace_sptr &testWS, diff --git a/Framework/Algorithms/test/RebinByTimeAtSampleTest.h b/Framework/Algorithms/test/RebinByTimeAtSampleTest.h index c71e9e7536fc81329935d1899c12f3a11e836aa2..c25495b7b65a71d808e753289e1de1c14e910725 100644 --- a/Framework/Algorithms/test/RebinByTimeAtSampleTest.h +++ b/Framework/Algorithms/test/RebinByTimeAtSampleTest.h @@ -10,6 +10,7 @@ #include <cmath> using Mantid::Algorithms::RebinByTimeAtSample; +using Mantid::Types::TofEvent; namespace { diff --git a/Framework/Algorithms/test/RebinByTimeBaseTest.h b/Framework/Algorithms/test/RebinByTimeBaseTest.h index 3db670f5791567f2056cb62cee9226b00aff6451..d8386e3491717a122b6303a6277c0a98801518bb 100644 --- a/Framework/Algorithms/test/RebinByTimeBaseTest.h +++ b/Framework/Algorithms/test/RebinByTimeBaseTest.h @@ -25,6 +25,7 @@ using namespace Mantid::Kernel; using namespace Mantid::API; using namespace Mantid::DataObjects; using Mantid::Types::DateAndTime; +using Mantid::Types::TofEvent; namespace { /** diff --git a/Framework/Algorithms/test/SortEventsTest.h b/Framework/Algorithms/test/SortEventsTest.h index a4594137bff4d0294c5ecafa5d7ff01b927776e1..47a6ff2f414ac6b6280717806f87e4f0f4d7fbb8 100644 --- a/Framework/Algorithms/test/SortEventsTest.h +++ b/Framework/Algorithms/test/SortEventsTest.h @@ -15,6 +15,7 @@ using namespace Mantid::DataObjects; using namespace Mantid::API; using namespace Mantid::Algorithms; using namespace Mantid::DataHandling; +using Mantid::Types::TofEvent; class SortEventsTest : public CxxTest::TestSuite { public: diff --git a/Framework/DataHandling/inc/MantidDataHandling/FilterEventsByLogValuePreNexus.h b/Framework/DataHandling/inc/MantidDataHandling/FilterEventsByLogValuePreNexus.h index 4d8a1bdd63361224de30b2e9f00e7089ac2ef16b..0fe742ebcb450f566e067ab5840b250077c6a8ec 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/FilterEventsByLogValuePreNexus.h +++ b/Framework/DataHandling/inc/MantidDataHandling/FilterEventsByLogValuePreNexus.h @@ -141,7 +141,7 @@ private: void procEvents(DataObjects::EventWorkspace_sptr &workspace); void procEventsLinear(DataObjects::EventWorkspace_sptr &workspace, - std::vector<DataObjects::TofEvent> **arrayOfVectors, + std::vector<Types::TofEvent> **arrayOfVectors, DasEvent *event_buffer, size_t current_event_buffer_size, size_t fileOffset); @@ -161,7 +161,7 @@ private: void filterEvents(); /// void filterEventsLinear(DataObjects::EventWorkspace_sptr &workspace, - std::vector<DataObjects::TofEvent> **arrayOfVectors, + std::vector<Types::TofEvent> **arrayOfVectors, DasEvent *event_buffer, size_t current_event_buffer_size, size_t fileOffset); @@ -180,7 +180,7 @@ private: std::unique_ptr<Mantid::API::Progress> m_progress = nullptr; DataObjects::EventWorkspace_sptr m_localWorkspace; //< Output EventWorkspace - std::vector<int64_t> m_spectraList; ///<the list of Spectra + std::vector<int64_t> m_spectraList; ///< the list of Spectra /// The times for each pulse. std::vector<Mantid::Types::DateAndTime> pulsetimes; @@ -202,15 +202,16 @@ private: /// Handles loading from the event file Mantid::Kernel::BinaryFile<DasEvent> *m_eventFile; std::size_t m_numEvents; ///< The number of events in the file - std::size_t m_numPulses; ///<the number of pulses - uint32_t m_numPixel; ///<the number of pixels + std::size_t m_numPulses; ///< the number of pulses + uint32_t m_numPixel; ///< the number of pixels std::size_t m_numGoodEvents; ///< The number of good events loaded std::size_t m_numErrorEvents; ///< The number of error events encountered - std::size_t m_numBadEvents; ///<The number of bad events. Part of error events - std::size_t m_numWrongdetidEvents; ///<The number of events with wrong + std::size_t m_numBadEvents; ///< The number of bad events. Part of error + ///< events + std::size_t m_numWrongdetidEvents; ///< The number of events with wrong /// detector IDs. Part of error events. - std::set<PixelType> wrongdetids; ///<set of all wrong detector IDs + std::set<PixelType> wrongdetids; ///< set of all wrong detector IDs std::map<PixelType, size_t> wrongdetidmap; std::vector<std::vector<Mantid::Types::DateAndTime>> wrongdetid_pulsetimes; std::vector<std::vector<double>> wrongdetid_tofs; @@ -284,6 +285,6 @@ private: bool m_corretctTOF; }; -} -} +} // namespace DataHandling +} // namespace Mantid #endif /*FILTEREVENTSBYLOGVALUEPRENEXUS_H_*/ diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadANSTOHelper.h b/Framework/DataHandling/inc/MantidDataHandling/LoadANSTOHelper.h index 9a9f630ab134848d66a52979d6985e441c65f156..209edee3fcdb5dcdf25aea0f568bc10b534f2896 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadANSTOHelper.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadANSTOHelper.h @@ -24,7 +24,7 @@ namespace DataHandling { namespace ANSTO { /// pointer to the vector of events -typedef std::vector<DataObjects::TofEvent> *EventVector_pt; +typedef std::vector<Types::TofEvent> *EventVector_pt; /// helper class to keep track of progress class ProgressTracker { diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadEventNexus.h b/Framework/DataHandling/inc/MantidDataHandling/LoadEventNexus.h index edc25644ad036b9fa12325b4b0aa08f8e864791b..8c4a5605ea1e869af08a22d90565aeb9fcf4914a 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadEventNexus.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadEventNexus.h @@ -183,7 +183,7 @@ public: double compressTolerance; /// Pointer to the vector of events - typedef std::vector<Mantid::DataObjects::TofEvent> *EventVector_pt; + typedef std::vector<Mantid::Types::TofEvent> *EventVector_pt; /// Vector where index = event_id; value = ptr to std::vector<TofEvent> in the /// event list. @@ -219,8 +219,8 @@ public: bool m_haveWeights; /// Pointer to the vector of weighted events - typedef std::vector<Mantid::DataObjects::WeightedEvent> * - WeightedEventVector_pt; + typedef std::vector<Mantid::DataObjects::WeightedEvent> + *WeightedEventVector_pt; /// Vector where index = event_id; value = ptr to std::vector<WeightedEvent> /// in the event list. @@ -291,14 +291,14 @@ private: //----------------------------------------------------------------------------- /** Load the instrument definition file specified by info in the NXS file. -* -* @param nexusfilename :: Used to pick the instrument. -* @param localWorkspace :: Templated workspace in which to put the instrument -*geometry -* @param top_entry_name :: entry name at the top of the NXS file -* @param alg :: Handle of the algorithm -* @return true if successful -*/ + * + * @param nexusfilename :: Used to pick the instrument. + * @param localWorkspace :: Templated workspace in which to put the instrument + *geometry + * @param top_entry_name :: entry name at the top of the NXS file + * @param alg :: Handle of the algorithm + * @return true if successful + */ template <typename T> bool LoadEventNexus::runLoadInstrument(const std::string &nexusfilename, T localWorkspace, @@ -315,8 +315,8 @@ bool LoadEventNexus::runLoadInstrument(const std::string &nexusfilename, try { nxfile.openData("name"); instrument = nxfile.getStrData(); - alg->getLogger().debug() << "Instrument name read from NeXus file is " - << instrument << '\n'; + alg->getLogger().debug() + << "Instrument name read from NeXus file is " << instrument << '\n'; } catch (::NeXus::Exception &) { // Try to fall back to isis compatibility options nxfile.closeGroup(); @@ -546,15 +546,15 @@ void LoadEventNexus::loadEntryMetadata(const std::string &nexusfilename, T WS, //----------------------------------------------------------------------------- /** Load the instrument from the nexus file or if not found from the IDF file -* specified by the info in the Nexus file -* -* @param nexusfilename :: The Nexus file name -* @param localWorkspace :: templated workspace in which to put the instrument -*geometry -* @param top_entry_name :: entry name at the top of the Nexus file -* @param alg :: Handle of the algorithm -* @return true if successful -*/ + * specified by the info in the Nexus file + * + * @param nexusfilename :: The Nexus file name + * @param localWorkspace :: templated workspace in which to put the instrument + *geometry + * @param top_entry_name :: entry name at the top of the Nexus file + * @param alg :: Handle of the algorithm + * @return true if successful + */ template <typename T> bool LoadEventNexus::loadInstrument(const std::string &nexusfilename, T localWorkspace, @@ -570,14 +570,14 @@ bool LoadEventNexus::loadInstrument(const std::string &nexusfilename, //----------------------------------------------------------------------------- /** Load the instrument from the nexus file -* -* @param nexusfilename :: The name of the nexus file being loaded -* @param localWorkspace :: templated workspace in which to put the instrument -*geometry -* @param top_entry_name :: entry name at the top of the Nexus file -* @param alg :: Handle of the algorithm -* @return true if successful -*/ + * + * @param nexusfilename :: The name of the nexus file being loaded + * @param localWorkspace :: templated workspace in which to put the instrument + *geometry + * @param top_entry_name :: entry name at the top of the Nexus file + * @param alg :: Handle of the algorithm + * @return true if successful + */ template <typename T> bool LoadEventNexus::runLoadIDFFromNexus(const std::string &nexusfilename, T localWorkspace, diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadEventPreNexus2.h b/Framework/DataHandling/inc/MantidDataHandling/LoadEventPreNexus2.h index 2ae9b85106df0e63862f3775a966fa6b776c9d81..9227e72ff5c5c110c0fa03834af69a0e002a62cf 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadEventPreNexus2.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadEventPreNexus2.h @@ -207,7 +207,7 @@ private: void procEvents(DataObjects::EventWorkspace_sptr &workspace); void procEventsLinear(DataObjects::EventWorkspace_sptr &workspace, - std::vector<DataObjects::TofEvent> **arrayOfVectors, + std::vector<Types::TofEvent> **arrayOfVectors, DasEvent *event_buffer, size_t current_event_buffer_size, size_t fileOffset, bool dbprint); diff --git a/Framework/DataHandling/src/FilterEventsByLogValuePreNexus.cpp b/Framework/DataHandling/src/FilterEventsByLogValuePreNexus.cpp index 9104ff22e30d40b8ba2003714bb17c19d8ab0f15..958f32a567a8b7d602b8ec1e4b0a60c15e8c7972 100644 --- a/Framework/DataHandling/src/FilterEventsByLogValuePreNexus.cpp +++ b/Framework/DataHandling/src/FilterEventsByLogValuePreNexus.cpp @@ -57,7 +57,7 @@ using boost::posix_time::time_duration; using DataObjects::EventList; using DataObjects::EventWorkspace; using DataObjects::EventWorkspace_sptr; -using DataObjects::TofEvent; +using Mantid::Types::TofEvent; using std::cout; using std::ifstream; using std::runtime_error; diff --git a/Framework/DataHandling/src/LoadEventNexus.cpp b/Framework/DataHandling/src/LoadEventNexus.cpp index 43723a635f214c8467233ea691ce9768d22774d0..c834d9e43e3f312d7bc1fe329f4dff3a439c2053 100644 --- a/Framework/DataHandling/src/LoadEventNexus.cpp +++ b/Framework/DataHandling/src/LoadEventNexus.cpp @@ -30,6 +30,7 @@ #include <functional> using Mantid::Types::DateAndTime; +using Mantid::Types::TofEvent; using std::map; using std::string; using std::vector; diff --git a/Framework/DataHandling/src/LoadEventPreNexus2.cpp b/Framework/DataHandling/src/LoadEventPreNexus2.cpp index 6d4d40f5fe5e4ed6704905b091310fa4fe801b3d..31e5dfc2d0326a82fd06b41e6eb31704a79d3f9a 100644 --- a/Framework/DataHandling/src/LoadEventPreNexus2.cpp +++ b/Framework/DataHandling/src/LoadEventPreNexus2.cpp @@ -56,7 +56,7 @@ using boost::posix_time::time_duration; using DataObjects::EventList; using DataObjects::EventWorkspace; using DataObjects::EventWorkspace_sptr; -using DataObjects::TofEvent; +using Mantid::Types::TofEvent; using std::cout; using std::ifstream; using std::runtime_error; diff --git a/Framework/DataHandling/src/LoadNexusMonitors2.cpp b/Framework/DataHandling/src/LoadNexusMonitors2.cpp index 74c96f4a33fd521fafcd710873a33cd2c467c566..daf04a7219b605d3eeed16bfc4c26c17b520cc53 100644 --- a/Framework/DataHandling/src/LoadNexusMonitors2.cpp +++ b/Framework/DataHandling/src/LoadNexusMonitors2.cpp @@ -826,8 +826,7 @@ void LoadNexusMonitors2::readEventMonitorEntry(NeXus::File &file, size_t i) { if (pulsetime < lastpulsetime) pulsetimesincreasing = false; lastpulsetime = pulsetime; - event_list.addEventQuickly( - DataObjects::TofEvent(time_of_flight[j], pulsetime)); + event_list.addEventQuickly(Types::TofEvent(time_of_flight[j], pulsetime)); } if (pulsetimesincreasing) event_list.setSortOrder(DataObjects::PULSETIME_SORT); diff --git a/Framework/DataHandling/src/LoadNexusProcessed.cpp b/Framework/DataHandling/src/LoadNexusProcessed.cpp index d1ae7fab3f4b008a70526f9ae47c79cb4d2e2fef..81e19171bcef4c29c3a8eddd0b3bd4cbbcb99b4c 100644 --- a/Framework/DataHandling/src/LoadNexusProcessed.cpp +++ b/Framework/DataHandling/src/LoadNexusProcessed.cpp @@ -39,6 +39,7 @@ #include <vector> using Mantid::Types::DateAndTime; +using Mantid::Types::TofEvent; namespace Mantid { namespace DataHandling { diff --git a/Framework/DataHandling/src/LoadSwans.cpp b/Framework/DataHandling/src/LoadSwans.cpp index ec795c96df59d985530d63d89ac64c029c9011a6..da2b408bca14eaef79ac4437fae6cb6a37ba5b11 100644 --- a/Framework/DataHandling/src/LoadSwans.cpp +++ b/Framework/DataHandling/src/LoadSwans.cpp @@ -5,11 +5,11 @@ #include "MantidKernel/OptionalBool.h" #include "MantidKernel/StringTokenizer.h" -#include <map> -#include <iostream> -#include <fstream> #include <algorithm> #include <boost/tokenizer.hpp> +#include <fstream> +#include <iostream> +#include <map> namespace Mantid { namespace DataHandling { @@ -18,6 +18,7 @@ using namespace Mantid::Kernel; using namespace Mantid::Geometry; using namespace Mantid::API; using namespace Mantid::DataObjects; +using Mantid::Types::TofEvent; // Register the algorithm into the AlgorithmFactory DECLARE_ALGORITHM(LoadSwans) @@ -201,8 +202,9 @@ std::vector<double> LoadSwans::loadMetaData() { if (!line.empty() && line[0] != '#') { g_log.debug() << "Metadata parsed line: " << line << '\n'; auto tokenizer = Mantid::Kernel::StringTokenizer( - line, "\t ", Mantid::Kernel::StringTokenizer::TOK_TRIM | - Mantid::Kernel::StringTokenizer::TOK_IGNORE_EMPTY); + line, "\t ", + Mantid::Kernel::StringTokenizer::TOK_TRIM | + Mantid::Kernel::StringTokenizer::TOK_IGNORE_EMPTY); for (const auto &token : tokenizer) { metadata.push_back(boost::lexical_cast<double>(token)); } diff --git a/Framework/DataHandling/src/ProcessBankData.cpp b/Framework/DataHandling/src/ProcessBankData.cpp index 74cdec211a2bd87708948bddbe72981c150f85c7..1a6d96d1b50dda9e5572f0ccb52375c3aa57220c 100644 --- a/Framework/DataHandling/src/ProcessBankData.cpp +++ b/Framework/DataHandling/src/ProcessBankData.cpp @@ -28,7 +28,7 @@ ProcessBankData::ProcessBankData( //---------------------------------------------------------------------------------------------- /** Run the data processing * FIXME/TODO - split run() into readable methods -*/ + */ void ProcessBankData::run() { // override { // Local tof limits double my_shortest_tof = @@ -164,7 +164,7 @@ void ProcessBankData::run() { // override { } } else { // We have cached the vector of events for this detector ID - std::vector<Mantid::DataObjects::TofEvent> *eventVector = + std::vector<Mantid::Types::TofEvent> *eventVector = alg->eventVectors[periodIndex][detId]; // NULL eventVector indicates a bad spectrum lookup if (eventVector) { @@ -262,5 +262,5 @@ size_t ProcessBankData::getWorkspaceIndexFromPixelID(const detid_t pixID) { } return pixelID_to_wi_vector[offset_pixID]; } -} // namespace Mantid{ -} // namespace DataHandling{ +} // namespace DataHandling +} // namespace Mantid diff --git a/Framework/DataHandling/test/GroupDetectors2Test.h b/Framework/DataHandling/test/GroupDetectors2Test.h index 2304821a6f5049b681c52fb2cc5e39388060e428..265d619da078c1addc533806a85ce5885064fc79 100644 --- a/Framework/DataHandling/test/GroupDetectors2Test.h +++ b/Framework/DataHandling/test/GroupDetectors2Test.h @@ -36,6 +36,7 @@ using Mantid::HistogramData::HistogramX; using Mantid::HistogramData::Counts; using Mantid::HistogramData::CountStandardDeviations; using Mantid::HistogramData::LinearGenerator; +using Mantid::Types::TofEvent; class GroupDetectors2Test : public CxxTest::TestSuite { public: diff --git a/Framework/DataHandling/test/MaskDetectorsTest.h b/Framework/DataHandling/test/MaskDetectorsTest.h index 8a9a8dcd3fa0f0476433411ce73bd050ecec3072..9251dccd7054de0a49f70a719eae73054940312c 100644 --- a/Framework/DataHandling/test/MaskDetectorsTest.h +++ b/Framework/DataHandling/test/MaskDetectorsTest.h @@ -31,6 +31,7 @@ using Mantid::HistogramData::BinEdges; using Mantid::HistogramData::Counts; using Mantid::HistogramData::CountStandardDeviations; using Mantid::HistogramData::LinearGenerator; +using Mantid::Types::TofEvent; class MaskDetectorsTest : public CxxTest::TestSuite { public: diff --git a/Framework/DataObjects/CMakeLists.txt b/Framework/DataObjects/CMakeLists.txt index 64c3428740bba11d35d9c4c780b352631950caf1..b9a065d1afe30590005f047b1be54ceff64adc68 100644 --- a/Framework/DataObjects/CMakeLists.txt +++ b/Framework/DataObjects/CMakeLists.txt @@ -184,7 +184,6 @@ set ( TEST_FILES TableColumnTest.h TableWorkspacePropertyTest.h TableWorkspaceTest.h - TofEventTest.h VectorColumnTest.h WeightedEventNoTimeTest.h WeightedEventTest.h diff --git a/Framework/DataObjects/inc/MantidDataObjects/EventList.h b/Framework/DataObjects/inc/MantidDataObjects/EventList.h index 1426e3ba401de3cdc580052f01a186be77773c99..5a7b2a9c84439c87651ad3757c313fd05cc4647b 100644 --- a/Framework/DataObjects/inc/MantidDataObjects/EventList.h +++ b/Framework/DataObjects/inc/MantidDataObjects/EventList.h @@ -78,7 +78,7 @@ public: EventList(const EventList &rhs); - EventList(const std::vector<TofEvent> &events); + EventList(const std::vector<Types::TofEvent> &events); EventList(const std::vector<WeightedEvent> &events); @@ -91,9 +91,9 @@ public: EventList &operator=(const EventList &); - EventList &operator+=(const TofEvent &event); + EventList &operator+=(const Types::TofEvent &event); - EventList &operator+=(const std::vector<TofEvent> &more_events); + EventList &operator+=(const std::vector<Types::TofEvent> &more_events); EventList &operator+=(const WeightedEvent &event); @@ -115,9 +115,9 @@ public: *faster. * NOTE: Only call this on a un-weighted event list! * - * @param event :: TofEvent to add at the end of the list. + * @param event :: Types::TofEvent to add at the end of the list. * */ - inline void addEventQuickly(const TofEvent &event) { + inline void addEventQuickly(const Types::TofEvent &event) { this->events.push_back(event); this->order = UNSORTED; } @@ -148,8 +148,8 @@ public: WeightedEvent getEvent(size_t event_number); - std::vector<TofEvent> &getEvents(); - const std::vector<TofEvent> &getEvents() const; + std::vector<Types::TofEvent> &getEvents(); + const std::vector<Types::TofEvent> &getEvents() const; std::vector<WeightedEvent> &getWeightedEvents(); const std::vector<WeightedEvent> &getWeightedEvents() const; @@ -372,8 +372,8 @@ private: /// Histogram object holding the histogram data. Currently only X. HistogramData::Histogram m_histogram; - /// List of TofEvent (no weights). - mutable std::vector<TofEvent> events; + /// List of Types::TofEvent (no weights). + mutable std::vector<Types::TofEvent> events; /// List of WeightedEvent's mutable std::vector<WeightedEvent> weightedEvents; @@ -545,9 +545,10 @@ private: }; // Methods overloaded to get event vectors. -DLLExport void getEventsFrom(EventList &el, std::vector<TofEvent> *&events); +DLLExport void getEventsFrom(EventList &el, + std::vector<Types::TofEvent> *&events); DLLExport void getEventsFrom(const EventList &el, - std::vector<TofEvent> const *&events); + std::vector<Types::TofEvent> const *&events); DLLExport void getEventsFrom(EventList &el, std::vector<WeightedEvent> *&events); DLLExport void getEventsFrom(const EventList &el, diff --git a/Framework/DataObjects/inc/MantidDataObjects/Events.h b/Framework/DataObjects/inc/MantidDataObjects/Events.h index 05af104f3514002b0198bc04570bafbaf1abd1f0..d6d04faa74c41c2e5d67a34b50cad26ae1f5f0d5 100644 --- a/Framework/DataObjects/inc/MantidDataObjects/Events.h +++ b/Framework/DataObjects/inc/MantidDataObjects/Events.h @@ -4,15 +4,16 @@ #ifdef _WIN32 /* _WIN32 */ #include <time.h> #endif -#include <cstddef> -#include <iosfwd> -#include <vector> #include "MantidAPI/MatrixWorkspace_fwd.h" // get MantidVec declaration -#include "MantidKernel/cow_ptr.h" #include "MantidKernel/System.h" -#include "MantidTypes/DateAndTime.h" #include "MantidKernel/TimeSplitter.h" +#include "MantidKernel/cow_ptr.h" +#include "MantidTypes/DateAndTime.h" +#include "MantidTypes/TofEvent.h" +#include <cstddef> +#include <iosfwd> #include <set> +#include <vector> namespace Mantid { // Forward declaration needed while this needs to be a friend of TofEvent (see @@ -23,75 +24,6 @@ class LoadEventNexus; namespace DataObjects { -//========================================================================================== -/** Info about a single neutron detection event: - * - * - the time of flight of the neutron (can be converted to other units) - * - the absolute time of the pulse at which it was produced - */ -#pragma pack(push, 4) // Ensure the structure is no larger than it needs to -class DLLExport TofEvent { - - /// EventList has the right to mess with TofEvent. - friend class EventList; - friend class WeightedEvent; - friend class WeightedEventNoTime; - friend class tofGreaterOrEqual; - friend class tofGreater; - friend class DataHandling::LoadEventNexus; // Needed while the ISIS hack of - // spreading events out in a bin - // remains - -protected: - /** The 'x value' of the event. This will be in a unit available from the - * UnitFactory. - * Initially (prior to any unit conversion on the holding workspace), this - * will have - * the unit of time-of-flight in microseconds. - */ - double m_tof; - - /** - * The absolute time of the start of the pulse that generated this event. - * This is saved as the number of ticks (1 nanosecond if boost is compiled - * for nanoseconds) since a specified epoch: we use the GPS epoch of Jan 1, - *1990. - * - * 64 bits gives 1 ns resolution up to +- 292 years around 1990. Should be - *enough. - */ - Mantid::Types::DateAndTime m_pulsetime; - -public: - /// Constructor, specifying only the time of flight in microseconds - TofEvent(double tof); - - /// Constructor, specifying the time of flight in microseconds and the frame - /// id - TofEvent(double tof, const Mantid::Types::DateAndTime pulsetime); - - /// Empty constructor - TofEvent(); - - bool operator==(const TofEvent &rhs) const; - bool operator<(const TofEvent &rhs) const; - bool operator<(const double rhs_tof) const; - bool operator>(const TofEvent &rhs) const; - bool equals(const TofEvent &rhs, const double tolTof, - const int64_t tolPulse) const; - - double operator()() const; - double tof() const; - Mantid::Types::DateAndTime pulseTime() const; - double weight() const; - double error() const; - double errorSquared() const; - - /// Output a string representation of the event to a stream - friend std::ostream &operator<<(std::ostream &os, const TofEvent &event); -}; -#pragma pack(pop) - //========================================================================================== /** Info about a single neutron detection event, including a weight and error *value: @@ -101,7 +33,7 @@ public: * - weight of the neutron (float, can be */ #pragma pack(push, 4) // Ensure the structure is no larger than it needs to -class DLLExport WeightedEvent : public TofEvent { +class DLLExport WeightedEvent : public Types::TofEvent { /// EventList has the right to mess with WeightedEvent. friend class EventList; @@ -187,12 +119,14 @@ public: WeightedEventNoTime(double tof, const Mantid::Types::DateAndTime pulsetime, float weight, float errorSquared); - WeightedEventNoTime(const TofEvent &, double weight, double errorSquared); - WeightedEventNoTime(const TofEvent &, float weight, float errorSquared); + WeightedEventNoTime(const Types::TofEvent &, double weight, + double errorSquared); + WeightedEventNoTime(const Types::TofEvent &, float weight, + float errorSquared); WeightedEventNoTime(const WeightedEvent &); - WeightedEventNoTime(const TofEvent &); + WeightedEventNoTime(const Types::TofEvent &); WeightedEventNoTime(); @@ -214,36 +148,6 @@ public: }; #pragma pack(pop) -//========================================================================================== -// TofEvent inlined member function definitions -//========================================================================================== - -/** () operator: return the tof (X value) of the event. - * This is useful for std operations like comparisons and std::lower_bound - * @return :: double, the tof (X value) of the event. - */ -inline double TofEvent::operator()() const { return m_tof; } - -/** @return The 'x value'. Despite the name, this can be in any unit in the - * UnitFactory. - * If it is time-of-flight, it will be in microseconds. - */ -inline double TofEvent::tof() const { return m_tof; } - -/// Return the pulse time -inline Mantid::Types::DateAndTime TofEvent::pulseTime() const { - return m_pulsetime; -} - -/// Return the weight of the event - exactly 1.0 always -inline double TofEvent::weight() const { return 1.0; } - -/// Return the error of the event - exactly 1.0 always -inline double TofEvent::error() const { return 1.0; } - -/// Return the errorSquared of the event - exactly 1.0 always -inline double TofEvent::errorSquared() const { return 1.0; } - //========================================================================================== // WeightedEvent inlined member function definitions //========================================================================================== @@ -277,7 +181,9 @@ inline double WeightedEventNoTime::tof() const { return m_tof; } /** Return the pulse time; this returns 0 since this * type of Event has no time associated. */ -inline Mantid::Types::DateAndTime WeightedEventNoTime::pulseTime() const { return 0; } +inline Mantid::Types::DateAndTime WeightedEventNoTime::pulseTime() const { + return 0; +} /// Return the weight of the neutron, as a double (it is saved as a float). inline double WeightedEventNoTime::weight() const { return m_weight; } @@ -292,6 +198,6 @@ inline double WeightedEventNoTime::errorSquared() const { return m_errorSquared; } -} // DataObjects -} // Mantid +} // namespace DataObjects +} // namespace Mantid #endif /// MANTID_DATAOBJECTS_EVENTS_H_ diff --git a/Framework/DataObjects/src/EventList.cpp b/Framework/DataObjects/src/EventList.cpp index 60b9f895100c036e6c938b82107c2819fc794cc9..77999da08a7e22d8d0ccbccd33e4cd9905e5b6ba 100644 --- a/Framework/DataObjects/src/EventList.cpp +++ b/Framework/DataObjects/src/EventList.cpp @@ -30,6 +30,7 @@ namespace Mantid { namespace DataObjects { using Kernel::Exception::NotImplementedError; using Mantid::Types::DateAndTime; +using Mantid::Types::TofEvent; using namespace Mantid::API; namespace { diff --git a/Framework/DataObjects/src/Events.cpp b/Framework/DataObjects/src/Events.cpp index d7d2c5813d1ee19fe76491470ab8465967cc1a71..fa54cdc4005333365b73c45ab4f7e85c56e71cfa 100644 --- a/Framework/DataObjects/src/Events.cpp +++ b/Framework/DataObjects/src/Events.cpp @@ -1,8 +1,8 @@ #include "MantidDataObjects/Events.h" #include "MantidAPI/MatrixWorkspace.h" #include "MantidDataObjects/EventList.h" -#include "MantidTypes/DateAndTime.h" #include "MantidKernel/Exception.h" +#include "MantidTypes/DateAndTime.h" #include <cmath> #include <functional> #include <stdexcept> @@ -16,80 +16,7 @@ namespace Mantid { namespace DataObjects { using Kernel::Exception::NotImplementedError; using Mantid::Types::DateAndTime; - -//========================================================================== -/// --------------------- TofEvent stuff ---------------------------------- -//========================================================================== -/** Constructor, specifying the time of flight only - * @param tof :: time of flight, in microseconds - */ -TofEvent::TofEvent(const double tof) : m_tof(tof), m_pulsetime(0) {} - -/** Constructor, specifying the time of flight and the frame id - * @param tof :: time of flight, in microseconds - * @param pulsetime :: absolute pulse time of the neutron. - */ -TofEvent::TofEvent(const double tof, const DateAndTime pulsetime) - : m_tof(tof), m_pulsetime(pulsetime) {} - -/// Empty constructor -TofEvent::TofEvent() : m_tof(0), m_pulsetime(0) {} - -/** Comparison operator. - * @param rhs: the other TofEvent to compare. - * @return true if the TofEvent's are identical.*/ -bool TofEvent::operator==(const TofEvent &rhs) const { - return (this->m_tof == rhs.m_tof) && (this->m_pulsetime == rhs.m_pulsetime); -} - -/** < comparison operator, using the TOF to do the comparison. - * @param rhs: the other TofEvent to compare. - * @return true if this->m_tof < rhs.m_tof*/ -bool TofEvent::operator<(const TofEvent &rhs) const { - return (this->m_tof < rhs.m_tof); -} - -/** < comparison operator, using the TOF to do the comparison. - * @param rhs: the other TofEvent to compare. - * @return true if this->m_tof < rhs.m_tof*/ -bool TofEvent::operator>(const TofEvent &rhs) const { - return (this->m_tof > rhs.m_tof); -} - -/** < comparison operator, using the TOF to do the comparison. - * @param rhs_tof: the other time of flight to compare. - * @return true if this->m_tof < rhs.m_tof*/ -bool TofEvent::operator<(const double rhs_tof) const { - return (this->m_tof < rhs_tof); -} - -/** - * Compare two events within the specified tolerance - * - * @param rhs the other TofEvent to compare - * @param tolTof the tolerance of a difference in m_tof. - * @param tolPulse the tolerance of a difference in m_pulsetime - * in nanoseconds. - * - * @return True if the are the same within the specifed tolerances - */ -bool TofEvent::equals(const TofEvent &rhs, const double tolTof, - const int64_t tolPulse) const { - // compare m_tof - if (std::fabs(this->m_tof - rhs.m_tof) > tolTof) - return false; - // then it is just if the pulse-times are equal - return (this->m_pulsetime.equals(rhs.m_pulsetime, tolPulse)); -} - -/** Output a string representation of the event to a stream - * @param os :: Stream - * @param event :: TofEvent to output to the stream - */ -ostream &operator<<(ostream &os, const TofEvent &event) { - os << event.m_tof << "," << event.m_pulsetime.toSimpleString(); - return os; -} +using Mantid::Types::TofEvent; //========================================================================== /// --------------------- WeightedEvent stuff ------------------------------ @@ -129,7 +56,7 @@ WeightedEvent::WeightedEvent(double tof, * @param rhs: TofEvent to copy into this. * @param weight: weight of this neutron event. * @param errorSquared: the square of the error on the event -*/ + */ WeightedEvent::WeightedEvent(const TofEvent &rhs, double weight, double errorSquared) : TofEvent(rhs.m_tof, rhs.m_pulsetime), @@ -140,7 +67,7 @@ WeightedEvent::WeightedEvent(const TofEvent &rhs, double weight, * @param rhs: TofEvent to copy into this. * @param weight: weight of this neutron event. * @param errorSquared: the square of the error on the event -*/ + */ WeightedEvent::WeightedEvent(const TofEvent &rhs, float weight, float errorSquared) : TofEvent(rhs.m_tof, rhs.m_pulsetime), m_weight(weight), @@ -258,7 +185,7 @@ WeightedEventNoTime::WeightedEventNoTime(double tof, * @param rhs: TofEvent to copy into this. * @param weight: weight of this neutron event. * @param errorSquared: the square of the error on the event -*/ + */ WeightedEventNoTime::WeightedEventNoTime(const TofEvent &rhs, double weight, double errorSquared) : m_tof(rhs.m_tof), m_weight(static_cast<float>(weight)), @@ -268,7 +195,7 @@ WeightedEventNoTime::WeightedEventNoTime(const TofEvent &rhs, double weight, * @param rhs: TofEvent to copy into this. * @param weight: weight of this neutron event. * @param errorSquared: the square of the error on the event -*/ + */ WeightedEventNoTime::WeightedEventNoTime(const TofEvent &rhs, float weight, float errorSquared) : m_tof(rhs.m_tof), m_weight(weight), m_errorSquared(errorSquared) {} @@ -336,5 +263,5 @@ bool WeightedEventNoTime::equals(const WeightedEventNoTime &rhs, return true; } -} // DataObjects -} // Mantid +} // namespace DataObjects +} // namespace Mantid diff --git a/Framework/DataObjects/test/CMakeLists.txt b/Framework/DataObjects/test/CMakeLists.txt index 70da5ac765cfa7d6e48c9e4d250c531294f0bff0..a264a7f8914e77a9402a8189cc43c6ce320964d5 100644 --- a/Framework/DataObjects/test/CMakeLists.txt +++ b/Framework/DataObjects/test/CMakeLists.txt @@ -18,6 +18,7 @@ if ( CXXTEST_FOUND ) cxxtest_add_test ( DataObjectsTest ${TEST_FILES} ) target_link_libraries( DataObjectsTest LINK_PRIVATE ${TCMALLOC_LIBRARIES_LINKTIME} ${MANTIDLIBS} + Types DataObjects ${NEXUS_LIBRARIES} ${JSONCPP_LIBRARIES} diff --git a/Framework/DataObjects/test/EventListTest.h b/Framework/DataObjects/test/EventListTest.h index 236e8789225675832ad8ed68af90ec06bea3a692..ab06626bab63b11c70e1a67c6700a8801947e9f6 100644 --- a/Framework/DataObjects/test/EventListTest.h +++ b/Framework/DataObjects/test/EventListTest.h @@ -17,6 +17,7 @@ using namespace Mantid::Kernel; using namespace Mantid::HistogramData; using namespace Mantid::DataObjects; using Mantid::Types::DateAndTime; +using Mantid::Types::TofEvent; using std::runtime_error; diff --git a/Framework/DataObjects/test/EventWorkspaceTest.h b/Framework/DataObjects/test/EventWorkspaceTest.h index 3e8ea385b2370c12abf76e0e8ee84a21f580d80a..d7d7d81bd9654db4216e89e7e46e18de79ad9b95 100644 --- a/Framework/DataObjects/test/EventWorkspaceTest.h +++ b/Framework/DataObjects/test/EventWorkspaceTest.h @@ -43,6 +43,7 @@ using Mantid::HistogramData::Histogram; using Mantid::HistogramData::HistogramX; using Mantid::HistogramData::LinearGenerator; using Mantid::Types::DateAndTime; +using Mantid::Types::TofEvent; class EventWorkspaceTest : public CxxTest::TestSuite { private: diff --git a/Framework/DataObjects/test/EventsTest.h b/Framework/DataObjects/test/EventsTest.h index efd22f1818f9316452d7293bc605254882b122ae..965daebbb2dde9bb742271600fb8204670d37839 100644 --- a/Framework/DataObjects/test/EventsTest.h +++ b/Framework/DataObjects/test/EventsTest.h @@ -3,12 +3,14 @@ #include "MantidDataObjects/Events.h" #include "MantidKernel/DateAndTimeHelpers.h" +#include "MantidTypes/TofEvent.h" #include <cxxtest/TestSuite.h> using namespace Mantid; using namespace Mantid::API; using namespace Mantid::Kernel; using namespace Mantid::DataObjects; +using Mantid::Types::TofEvent; using std::runtime_error; using std::size_t; diff --git a/Framework/DataObjects/test/WeightedEventNoTimeTest.h b/Framework/DataObjects/test/WeightedEventNoTimeTest.h index 5a2463af868707bb2c5a6731f1a40283d356a94e..d14e0680897b075ca85f3656fcf6da67a0cefae2 100644 --- a/Framework/DataObjects/test/WeightedEventNoTimeTest.h +++ b/Framework/DataObjects/test/WeightedEventNoTimeTest.h @@ -9,6 +9,7 @@ using namespace Mantid; using namespace Mantid::Kernel; using namespace Mantid::DataObjects; +using Mantid::Types::TofEvent; using std::runtime_error; using std::size_t; diff --git a/Framework/DataObjects/test/WeightedEventTest.h b/Framework/DataObjects/test/WeightedEventTest.h index 96cd4738adb030e9bf89c689f1214285e8a10158..4e73740183bf285a69e82fbd20f3d6cde693b0d1 100644 --- a/Framework/DataObjects/test/WeightedEventTest.h +++ b/Framework/DataObjects/test/WeightedEventTest.h @@ -9,6 +9,7 @@ using namespace Mantid; using namespace Mantid::Kernel; using namespace Mantid::DataObjects; +using Mantid::Types::TofEvent; using std::runtime_error; using std::size_t; diff --git a/Framework/LiveData/src/FakeEventDataListener.cpp b/Framework/LiveData/src/FakeEventDataListener.cpp index e06559d5554c4f197539c52fa78fd3e7d810b71d..64e0de030627efba024b443b32bdcc5b2c946922 100644 --- a/Framework/LiveData/src/FakeEventDataListener.cpp +++ b/Framework/LiveData/src/FakeEventDataListener.cpp @@ -11,6 +11,7 @@ using namespace Mantid::Kernel; using namespace Mantid::API; using Mantid::Types::DateAndTime; +using Mantid::Types::TofEvent; namespace Mantid { namespace LiveData { @@ -138,10 +139,8 @@ boost::shared_ptr<Workspace> FakeEventDataListener::extractData() { void FakeEventDataListener::generateEvents(Poco::Timer &) { std::lock_guard<std::mutex> _lock(m_mutex); for (long i = 0; i < m_callbackloop; ++i) { - m_buffer->getSpectrum(0).addEventQuickly( - DataObjects::TofEvent(m_rand->nextValue())); - m_buffer->getSpectrum(1).addEventQuickly( - DataObjects::TofEvent(m_rand->nextValue())); + m_buffer->getSpectrum(0).addEventQuickly(TofEvent(m_rand->nextValue())); + m_buffer->getSpectrum(1).addEventQuickly(TofEvent(m_rand->nextValue())); } } } // namespace LiveData diff --git a/Framework/LiveData/src/ISIS/ISISLiveEventDataListener.cpp b/Framework/LiveData/src/ISIS/ISISLiveEventDataListener.cpp index edf7c2edcdbfff1a70dce78968a496c71c92ab28..83f4330e2bc1e4cfd158591392cd0e447c708dca 100644 --- a/Framework/LiveData/src/ISIS/ISISLiveEventDataListener.cpp +++ b/Framework/LiveData/src/ISIS/ISISLiveEventDataListener.cpp @@ -10,11 +10,11 @@ #include "MantidAPI/WorkspaceFactory.h" #include "MantidAPI/WorkspaceGroup.h" -#include "MantidTypes/DateAndTime.h" #include "MantidKernel/OptionalBool.h" #include "MantidKernel/TimeSeriesProperty.h" #include "MantidKernel/UnitFactory.h" #include "MantidKernel/WarningSuppressions.h" +#include "MantidTypes/DateAndTime.h" #ifdef GCC_VERSION // Avoid compiler warnings on gcc from unused static constants in @@ -25,6 +25,8 @@ GCC_DIAG_OFF(unused-variable) #endif #include "DAE/idc.h" +using Mantid::Types::TofEvent; + const char *PROTON_CHARGE_PROPERTY = "proton_charge"; const char *RUN_NUMBER_PROPERTY = "run_number"; @@ -36,7 +38,7 @@ DECLARE_LISTENER(ISISLiveEventDataListener) namespace { /// static logger Kernel::Logger g_log("ISISLiveEventDataListener"); -} +} // namespace /** * The constructor @@ -282,8 +284,8 @@ void ISISLiveEventDataListener::run() { saveEvents(events.data, pulseTime, events.head_n.period); } - } catch (std::runtime_error & - e) { // exception handler for generic runtime exceptions + } catch (std::runtime_error + &e) { // exception handler for generic runtime exceptions g_log.error() << "Caught a runtime exception.\nException message: " << e.what() << '\n'; @@ -291,8 +293,8 @@ void ISISLiveEventDataListener::run() { m_backgroundException = boost::make_shared<std::runtime_error>(e); - } catch (std::invalid_argument & - e) { // TimeSeriesProperty (and possibly some other things) can + } catch (std::invalid_argument + &e) { // TimeSeriesProperty (and possibly some other things) can // can throw these errors g_log.error() << "Caught an invalid argument exception.\nException message: " @@ -388,7 +390,7 @@ void ISISLiveEventDataListener::saveEvents( } for (const auto &streamEvent : data) { - Mantid::DataObjects::TofEvent event(streamEvent.time_of_flight, pulseTime); + TofEvent event(streamEvent.time_of_flight, pulseTime); m_eventBuffer[period] ->getSpectrum(streamEvent.spectrum) .addEventQuickly(event); @@ -396,8 +398,8 @@ void ISISLiveEventDataListener::saveEvents( } /** - * Set the spectra-detector map to the buffer workspace. - */ + * Set the spectra-detector map to the buffer workspace. + */ void ISISLiveEventDataListener::loadSpectraMap() { // Read in the number of detectors int ndet = getInt("NDET"); @@ -412,9 +414,9 @@ void ISISLiveEventDataListener::loadSpectraMap() { } /** - * Load the instrument - * @param instrName :: Instrument name - */ + * Load the instrument + * @param instrName :: Instrument name + */ void ISISLiveEventDataListener::loadInstrument(const std::string &instrName) { // try to load the instrument. if it doesn't load give a warning and carry on if (instrName.empty()) { @@ -464,16 +466,16 @@ void ISISLiveEventDataListener::getIntArray(const std::string &par, } /** Function called by IDC routines to report an error. Passes the error through -* to the logger -* @param status :: The status code of the error (disregarded) -* @param code :: The error code (disregarded) -* @param message :: The error message - passed to the logger at error level -*/ + * to the logger + * @param status :: The status code of the error (disregarded) + * @param code :: The error code (disregarded) + * @param message :: The error message - passed to the logger at error level + */ void ISISLiveEventDataListener::IDCReporter(int status, int code, const char *message) { (void)status; (void)code; // Avoid compiler warning g_log.error(message); } -} -} +} // namespace LiveData +} // namespace Mantid diff --git a/Framework/LiveData/src/Kafka/KafkaEventStreamDecoder.cpp b/Framework/LiveData/src/Kafka/KafkaEventStreamDecoder.cpp index 08e0d34884f0a927e8eb6f6f705c9fddaa9f3d6d..4afda639a95ebe283bb85f0650b69e4bc8674514 100644 --- a/Framework/LiveData/src/Kafka/KafkaEventStreamDecoder.cpp +++ b/Framework/LiveData/src/Kafka/KafkaEventStreamDecoder.cpp @@ -102,7 +102,7 @@ void addSampleEnvLogs( namespace Mantid { namespace LiveData { -using DataObjects::TofEvent; + using Mantid::Types::TofEvent; // ----------------------------------------------------------------------------- // Public members diff --git a/Framework/LiveData/src/SNSLiveEventDataListener.cpp b/Framework/LiveData/src/SNSLiveEventDataListener.cpp index 8c31d740148e73c6bd7110ffe5bd522586bcb209..3e0e7e2e190c622f7d364a1e236b769bdf043c6a 100644 --- a/Framework/LiveData/src/SNSLiveEventDataListener.cpp +++ b/Framework/LiveData/src/SNSLiveEventDataListener.cpp @@ -38,6 +38,7 @@ using namespace Mantid::Kernel; using namespace Mantid::API; using Mantid::Types::DateAndTime; +using Mantid::Types::TofEvent; namespace { // anonymous namespace // Time we'll wait on a receive call (in seconds) @@ -519,7 +520,7 @@ bool SNSLiveEventDataListener::rxPacket(const ADARA::BeamMonitorPkt &pkt) { // Add the event. Note that they're in units of 100 ns in the packet, // need to change to microseconds. monitorBuffer->getSpectrum(it->second) - .addEventQuickly(DataObjects::TofEvent(tof / 10.0, pktTime)); + .addEventQuickly(TofEvent(tof / 10.0, pktTime)); } } else { g_log.error() << "Event from unknown monitor ID (" << monitorID @@ -1349,7 +1350,7 @@ void SNSLiveEventDataListener::appendEvent( const auto it = m_indexMap.find(pixelId); if (it != m_indexMap.end()) { const std::size_t workspaceIndex = it->second; - Mantid::DataObjects::TofEvent event(tof, pulseTime); + TofEvent event(tof, pulseTime); m_eventBuffer->getSpectrum(workspaceIndex).addEventQuickly(event); } else { g_log.warning() << "Invalid pixel ID: " << pixelId << " (TofF: " << tof diff --git a/Framework/LiveData/src/TOPAZLiveEventDataListener.cpp b/Framework/LiveData/src/TOPAZLiveEventDataListener.cpp index 8cd3124888b97e57b8c2330a541e302d9b9ae757..7bbb3d44c20c15440cd834b61c65d49a14b894e7 100644 --- a/Framework/LiveData/src/TOPAZLiveEventDataListener.cpp +++ b/Framework/LiveData/src/TOPAZLiveEventDataListener.cpp @@ -22,6 +22,7 @@ using namespace Mantid::Kernel; using namespace Mantid::API; +using Mantid::Types::TofEvent; #if 0 // Port numbers @@ -528,7 +529,7 @@ void TOPAZLiveEventDataListener::appendEvent( auto it = m_indexMap.find(pixelId); if (it != m_indexMap.end()) { std::size_t workspaceIndex = it->second; - Mantid::DataObjects::TofEvent event(tof, pulseTime); + TofEvent event(tof, pulseTime); m_eventBuffer->getSpectrum(workspaceIndex).addEventQuickly(event); } else { // TODO: do we want to disable this warning? Most of the time, we diff --git a/Framework/LiveData/test/TestDataListener.cpp b/Framework/LiveData/test/TestDataListener.cpp index 2193349e3638fd5245047e24a70733b09492123c..f3066f81a319350e10d2cdcfc405d1a46f3a6102 100644 --- a/Framework/LiveData/test/TestDataListener.cpp +++ b/Framework/LiveData/test/TestDataListener.cpp @@ -12,6 +12,7 @@ using namespace Mantid::API; using namespace Mantid::DataObjects; using namespace Mantid::Geometry; using Mantid::Kernel::ConfigService; +using Mantid::Types::TofEvent; namespace Mantid { namespace LiveData { diff --git a/Framework/MDAlgorithms/src/ConvToMDEventsWS.cpp b/Framework/MDAlgorithms/src/ConvToMDEventsWS.cpp index fd7f66222f7ad6b597869f9be2da002a82ec3ece..4048cc12664566ab7305e7d06634d3db68bc987d 100644 --- a/Framework/MDAlgorithms/src/ConvToMDEventsWS.cpp +++ b/Framework/MDAlgorithms/src/ConvToMDEventsWS.cpp @@ -2,6 +2,8 @@ #include "MantidMDAlgorithms/UnitsConversionHelper.h" +using Mantid::Types::TofEvent; + namespace Mantid { namespace MDAlgorithms { /**function converts particular list of events of type T into MD workspace and @@ -74,7 +76,7 @@ size_t ConvToMDEventsWS::conversionChunk(size_t workspaceIndex) { switch (m_EventWS->getSpectrum(workspaceIndex).getEventType()) { case Mantid::API::TOF: - return this->convertEventList<Mantid::DataObjects::TofEvent>( + return this->convertEventList<TofEvent>( workspaceIndex); case Mantid::API::WEIGHTED: return this->convertEventList<Mantid::DataObjects::WeightedEvent>( diff --git a/Framework/MDAlgorithms/src/ConvertToDetectorFaceMD.cpp b/Framework/MDAlgorithms/src/ConvertToDetectorFaceMD.cpp index b863c49c5157ec73ae80074f03a61fc29c047fa4..4625070e79a41116e576b937b705395f479cd748 100644 --- a/Framework/MDAlgorithms/src/ConvertToDetectorFaceMD.cpp +++ b/Framework/MDAlgorithms/src/ConvertToDetectorFaceMD.cpp @@ -16,6 +16,7 @@ using namespace Mantid::API; using namespace Mantid::DataObjects; using namespace Mantid::DataObjects; using namespace Mantid::Geometry; +using Mantid::Types::TofEvent; namespace Mantid { namespace MDAlgorithms { diff --git a/Framework/MDAlgorithms/src/ConvertToDiffractionMDWorkspace.cpp b/Framework/MDAlgorithms/src/ConvertToDiffractionMDWorkspace.cpp index 64ba21d3ccb2175e7b50dc71231f44ff5ff21cbe..ff2743dc277579e36a4ac659732ab3f425b29cb1 100644 --- a/Framework/MDAlgorithms/src/ConvertToDiffractionMDWorkspace.cpp +++ b/Framework/MDAlgorithms/src/ConvertToDiffractionMDWorkspace.cpp @@ -31,6 +31,7 @@ using namespace Mantid::Kernel; using namespace Mantid::API; using namespace Mantid::DataObjects; using namespace Mantid::Geometry; +using Mantid::Types::TofEvent; namespace Mantid { namespace MDAlgorithms { diff --git a/Framework/MDAlgorithms/src/IntegrateFlux.cpp b/Framework/MDAlgorithms/src/IntegrateFlux.cpp index 57a49a574344d54995b65a8ef368c76c4cd96088..6c0355a8e16745ed1e2f7482f08824201ca1e974 100644 --- a/Framework/MDAlgorithms/src/IntegrateFlux.cpp +++ b/Framework/MDAlgorithms/src/IntegrateFlux.cpp @@ -146,7 +146,7 @@ void IntegrateFlux::integrateSpectra(const API::MatrixWorkspace &inputWS, integrateSpectraEvents<DataObjects::WeightedEvent>(*eventWS, integrWS); return; case (API::TOF): - integrateSpectraEvents<DataObjects::TofEvent>(*eventWS, integrWS); + integrateSpectraEvents<Types::TofEvent>(*eventWS, integrWS); return; } } else { diff --git a/Framework/MDAlgorithms/src/SaveIsawQvector.cpp b/Framework/MDAlgorithms/src/SaveIsawQvector.cpp index 46a11fb73ecb2445fd06282101ebd16766864913..f1598e6b99bae00a392598ce0b62e14e96931c7d 100644 --- a/Framework/MDAlgorithms/src/SaveIsawQvector.cpp +++ b/Framework/MDAlgorithms/src/SaveIsawQvector.cpp @@ -13,6 +13,7 @@ using namespace Mantid::API; using namespace Mantid::Kernel; using namespace Mantid::DataObjects; +using Mantid::Types::TofEvent; namespace Mantid { namespace MDAlgorithms { diff --git a/Framework/MDAlgorithms/test/IntegrateEllipsoidsTest.h b/Framework/MDAlgorithms/test/IntegrateEllipsoidsTest.h index 256eea32928080d837ea029d7d01cc5f87be0ebe..fed327a934f761aa47a51ba61c8ea2d2bc037cc4 100644 --- a/Framework/MDAlgorithms/test/IntegrateEllipsoidsTest.h +++ b/Framework/MDAlgorithms/test/IntegrateEllipsoidsTest.h @@ -18,6 +18,7 @@ using namespace Mantid::MDAlgorithms; using namespace Mantid::Kernel; using namespace Mantid::Geometry; using namespace Mantid::DataObjects; +using Mantid::Types::TofEvent; namespace { // Add A Fake 'Peak' to both the event data and to the peaks workspace diff --git a/Framework/PythonInterface/mantid/dataobjects/src/Exports/EventList.cpp b/Framework/PythonInterface/mantid/dataobjects/src/Exports/EventList.cpp index eacc63c5efaba753c69d5ce1b3ced823032aa006..3f8c1c4be2a435a79b7578291b9581c03dea1870 100644 --- a/Framework/PythonInterface/mantid/dataobjects/src/Exports/EventList.cpp +++ b/Framework/PythonInterface/mantid/dataobjects/src/Exports/EventList.cpp @@ -11,7 +11,7 @@ GET_POINTER_SPECIALIZATION(EventList) namespace { void addEventToEventList(EventList &self, double tof, Mantid::Types::DateAndTime pulsetime) { - self.addEventQuickly(Mantid::DataObjects::TofEvent(tof, pulsetime)); + self.addEventQuickly(Mantid::Types::TofEvent(tof, pulsetime)); } } diff --git a/Framework/TestHelpers/src/SingleCrystalDiffractionTestHelper.cpp b/Framework/TestHelpers/src/SingleCrystalDiffractionTestHelper.cpp index 85ff75f5bc7df7138f85c56ae3a4fab14f58e2c0..618c1bc8d44ba4707d4bc58015395f88059df229 100644 --- a/Framework/TestHelpers/src/SingleCrystalDiffractionTestHelper.cpp +++ b/Framework/TestHelpers/src/SingleCrystalDiffractionTestHelper.cpp @@ -21,6 +21,7 @@ using namespace Mantid::API; using namespace Mantid::DataObjects; using namespace Mantid::Geometry; using namespace Mantid::Kernel; +using Mantid::Types::TofEvent; namespace Mantid { namespace SingleCrystalDiffractionTestHelper { diff --git a/Framework/Types/CMakeLists.txt b/Framework/Types/CMakeLists.txt index 615fcf90c5c4788e6ea887ee1590236c90611278..186e5973f4005509303a4e859f547a00adc08a84 100644 --- a/Framework/Types/CMakeLists.txt +++ b/Framework/Types/CMakeLists.txt @@ -1,16 +1,19 @@ # This is not a module, there are no source files. Types in this folder must be header-only! set ( SRC_FILES src/DateAndTime.cpp + src/TofEvent.cpp ) set ( INC_FILES inc/MantidTypes/DateAndTime.h inc/MantidTypes/DllConfig.h inc/MantidTypes/SpectrumDefinition.h + inc/MantidTypes/TofEvent.h ) set ( TEST_FILES DateAndTimeTest.h SpectrumDefinitionTest.h + TofEventTest.h ) if (COVERALLS) diff --git a/Framework/Types/inc/MantidTypes/TofEvent.h b/Framework/Types/inc/MantidTypes/TofEvent.h index 8660a1852b8472e4bcf303ecaed67905326408d8..e2928ea72715ac080b44e961317b1f0bc5905c78 100644 --- a/Framework/Types/inc/MantidTypes/TofEvent.h +++ b/Framework/Types/inc/MantidTypes/TofEvent.h @@ -4,6 +4,17 @@ #include "MantidTypes/DateAndTime.h" namespace Mantid { +namespace DataObjects { +class EventList; +class WeightedEvent; +class WeightedEventNoTime; +class tofGreaterOrEqual; +class tofGreater; +} // namespace DataObjects + +namespace DataHandling { +class LoadEventNexus; +} namespace Types { //========================================================================================== /** Info about a single neutron detection event: @@ -15,14 +26,14 @@ namespace Types { class _declspec(dllexport) TofEvent { /// EventList has the right to mess with TofEvent. - friend class EventList; - friend class WeightedEvent; - friend class WeightedEventNoTime; - friend class tofGreaterOrEqual; - friend class tofGreater; - friend class DataHandling::LoadEventNexus; // Needed while the ISIS hack of - // spreading events out in a bin - // remains + friend class Mantid::DataObjects::EventList; + friend class Mantid::DataObjects::WeightedEvent; + friend class Mantid::DataObjects::WeightedEventNoTime; + friend class Mantid::DataObjects::tofGreaterOrEqual; + friend class Mantid::DataObjects::tofGreater; + friend class Mantid::DataHandling::LoadEventNexus; // Needed while the ISIS + // hack of spreading events + // out in a bin remains protected: /** The 'x value' of the event. This will be in a unit available from the diff --git a/Framework/Types/src/TofEvent.cpp b/Framework/Types/src/TofEvent.cpp index d5a577cacb5c28565b33e09583d3987e5cd63aff..7e264e0636ef1f015b40b5ae50829dcf33dc6c00 100644 --- a/Framework/Types/src/TofEvent.cpp +++ b/Framework/Types/src/TofEvent.cpp @@ -1,4 +1,6 @@ -#include "MantidTypes/TofEvents.h" +#include "MantidTypes/TofEvent.h" + +using std::ostream; namespace Mantid { namespace Types { diff --git a/Framework/Types/test/TofEventTest.h b/Framework/Types/test/TofEventTest.h index 5e82a28f4b46e8ddecb86b2a40cff605c3387532..58f2529b470482e8e4182d4cb442b447c5b03ce3 100644 --- a/Framework/Types/test/TofEventTest.h +++ b/Framework/Types/test/TofEventTest.h @@ -3,16 +3,9 @@ #include <cxxtest/TestSuite.h> #include "MantidTypes/TofEvent.h" -#include "MantidKernel/Timer.h" -#include <cmath> using namespace Mantid; -using namespace Mantid::Kernel; -using namespace Mantid::Types - -using std::runtime_error; -using std::size_t; -using std::vector; +using namespace Mantid::Types; //========================================================================================== class TofEventTest : public CxxTest::TestSuite {