From c94c7f847ffdc4eb95d6fb3dceb355ecce2467f4 Mon Sep 17 00:00:00 2001 From: Janik Zikovsky <zikovskyjl@ornl.gov> Date: Tue, 20 Dec 2011 10:26:04 -0500 Subject: [PATCH] Refs #4353 added output properties in IndexPeaks --- .gitignore | 1 + .../Framework/Crystal/src/IndexPeaks.cpp | 25 +++++++++---------- .../Framework/Crystal/test/IndexPeaksTest.h | 7 ++++++ 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/.gitignore b/.gitignore index 472d8907a5e..ef6b7d74972 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ # Ignore text editor (e.g. emacs) autosave files *~ + # Ignore CMake generated files (if someone does an in-source build) CMakeCache.txt CMakeFiles diff --git a/Code/Mantid/Framework/Crystal/src/IndexPeaks.cpp b/Code/Mantid/Framework/Crystal/src/IndexPeaks.cpp index 572b0a322a1..64882c5c4f1 100644 --- a/Code/Mantid/Framework/Crystal/src/IndexPeaks.cpp +++ b/Code/Mantid/Framework/Crystal/src/IndexPeaks.cpp @@ -65,6 +65,11 @@ namespace Crystal this->declareProperty(new PropertyWithValue<double>( "Tolerance",0.15, mustBePositive,Direction::Input),"Indexing Tolerance (0.15)"); + + this->declareProperty(new PropertyWithValue<int>( "NumIndexed", 0, + Direction::Output), "Gets set with the number of indexed peaks."); + this->declareProperty(new PropertyWithValue<double>( "AverageError", 0.0, + Direction::Output), "Gets set with the average HKL indexing error."); } //-------------------------------------------------------------------------- @@ -111,22 +116,16 @@ namespace Crystal miller_indices, average_error ); - // now tell the user how many were indexed - char logInfo[200]; - sprintf( logInfo, - std::string("Indexed %1d Peaks out of %1d with tolerance %5.3f").c_str(), - num_indexed, n_peaks, tolerance ); - g_log.notice( std::string(logInfo) ); - - sprintf( logInfo, - std::string("Average error in h,k,l for indexed peaks = %6.4f").c_str(), - average_error); - g_log.notice( std::string(logInfo) ); + // now tell the user how many were indexed + g_log.notice() << "Indexed " << num_indexed << " Peaks out of " << n_peaks << " with tolerance of " << tolerance << std::endl; + g_log.notice() << "Average error in h,k,l for indexed peaks = " << average_error << std::endl; for ( size_t i = 0; i < n_peaks; i++ ) - { peaks[i].setHKL( miller_indices[i] ); - } + + // Save output properties + this->setProperty("NumIndexed", num_indexed); + this->setProperty("AverageError", average_error); } diff --git a/Code/Mantid/Framework/Crystal/test/IndexPeaksTest.h b/Code/Mantid/Framework/Crystal/test/IndexPeaksTest.h index 7990336d9c7..0694c555c46 100644 --- a/Code/Mantid/Framework/Crystal/test/IndexPeaksTest.h +++ b/Code/Mantid/Framework/Crystal/test/IndexPeaksTest.h @@ -85,6 +85,13 @@ public: { TS_ASSERT( IndexingUtils::ValidIndex( peaks[i].getHKL(), tolerance ) ); } + + // Check the output properties + int numIndexed = alg.getProperty("NumIndexed"); + TS_ASSERT_EQUALS( numIndexed, 43); + double averageError = alg.getProperty("AverageError"); + TS_ASSERT_DELTA( averageError, 0.0097, 1e-3); + // spot check a few peaks V3D peak_0_hkl ( -4, -1, -6 ); // first peak V3D peak_1_hkl ( -3, 1, -4 ); -- GitLab