Skip to content

Commit

Permalink
RE 7011 Fixes select cell bug
Browse files Browse the repository at this point in the history
The SelectCellOfType and SelectCellWithForm algorithms now actually
re-index the peaks with the new UB matrix, if the Apply parameter is
true.  Previously, a transformation was applied to the previously
calculated hkl values, however, in some cases the transformation
applied was not correct.

 refs #7011
  • Loading branch information
DennisMikkelson committed May 7, 2013
1 parent bde1f2d commit 2fae3e4
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 34 deletions.
29 changes: 12 additions & 17 deletions Code/Mantid/Framework/Crystal/src/SelectCellOfType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,31 +166,26 @@ namespace Crystal
std::vector<Peak> &peaks = ws->getPeaks();
size_t n_peaks = ws->getNumberPeaks();

// transform the HKLs and record the new HKL
// and q-vectors for peaks ORIGINALLY indexed
DblMatrix hkl_tran = info.GetHKL_Tran();
int num_indexed = 0;
int num_indexed = 0;
double average_error = 0.0;
std::vector<V3D> miller_indices;
std::vector<V3D> q_vectors;
for ( size_t i = 0; i < n_peaks; i++ )
{
V3D hkl( peaks[i].getHKL() );
if ( IndexingUtils::ValidIndex(hkl,tolerance ) )
{
num_indexed++;
miller_indices.push_back( hkl_tran * hkl );
q_vectors.push_back( peaks[i].getQSampleFrame() );
peaks[i].setHKL( hkl_tran * hkl );
}
else // mark as NOT indexed
peaks[i].setHKL( V3D(0.0,0.0,0.0) );
q_vectors.push_back( peaks[i].getQSampleFrame() );
}

double average_error = IndexingUtils::IndexingError( newUB, miller_indices, q_vectors );
num_indexed = IndexingUtils::CalculateMillerIndices( newUB, q_vectors,
tolerance,
miller_indices,
average_error );
for ( size_t i = 0; i < n_peaks; i++ )
{
peaks[i].setHKL( miller_indices[i] );
}

// Tell the user what happened.
g_log.notice() << "Transformed Miller indices on previously valid indexed Peaks. " << std::endl;
g_log.notice() << "Set hkl to 0,0,0 on peaks previously indexed out of tolerance. " << std::endl;
g_log.notice() << "Re-indexed the peaks with the new UB. " << std::endl;
g_log.notice() << "Now, " << num_indexed << " are indexed with average error " << average_error << std::endl;

// Save output properties
Expand Down
30 changes: 13 additions & 17 deletions Code/Mantid/Framework/Crystal/src/SelectCellWithForm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,31 +145,27 @@ namespace Crystal
std::vector<Peak> &peaks = ws->getPeaks();
size_t n_peaks = ws->getNumberPeaks();

// transform the HKLs and record the new HKL
// and q-vectors for peaks ORIGINALLY indexed
DblMatrix hkl_tran = info.GetHKL_Tran();
int num_indexed = 0;
int num_indexed = 0;
double average_error = 0.0;
std::vector<V3D> miller_indices;
std::vector<V3D> q_vectors;
for ( size_t i = 0; i < n_peaks; i++ )
{
V3D hkl( peaks[i].getHKL() );
if ( IndexingUtils::ValidIndex(hkl,tolerance ) )
{
num_indexed++;
miller_indices.push_back( hkl_tran * hkl );
q_vectors.push_back( peaks[i].getQSampleFrame() );
peaks[i].setHKL( hkl_tran * hkl );
}
else // mark as NOT indexed
peaks[i].setHKL( V3D(0.0,0.0,0.0) );
q_vectors.push_back( peaks[i].getQSampleFrame() );
}

double average_error = IndexingUtils::IndexingError( newUB, miller_indices, q_vectors );
num_indexed = IndexingUtils::CalculateMillerIndices( newUB, q_vectors,
tolerance,
miller_indices,
average_error );

for ( size_t i = 0; i < n_peaks; i++ )
{
peaks[i].setHKL( miller_indices[i] );
}

// Tell the user what happened.
g_log.notice() << "Transformed Miller indices on previously valid indexed Peaks. " << std::endl;
g_log.notice() << "Set hkl to 0,0,0 on peaks previously indexed out of tolerance. " << std::endl;
g_log.notice() << "Re-indexed the peaks with the new UB. " << std::endl;
g_log.notice() << "Now, " << num_indexed << " are indexed with average error " << average_error << std::endl;

// Save output properties
Expand Down

0 comments on commit 2fae3e4

Please sign in to comment.