Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refs #9194. Refactor PeakBackground into separate physical location.
- Loading branch information
1 parent
bc80092
commit 7102ddb
Showing
5 changed files
with
307 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
Code/Mantid/Framework/Crystal/inc/MantidCrystal/PeakBackground.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#ifndef MANTID_CRYSTAL_PEAKBACKGROUND_H_ | ||
#define MANTID_CRYSTAL_PEAKBACKGROUND_H_ | ||
|
||
#include "MantidKernel/System.h" | ||
#include "MantidAPI/IPeaksWorkspace.h" | ||
#include "MantidAPI/IMDIterator.h" | ||
#include "MantidAPI/IMDWorkspace.h" | ||
#include "MantidCrystal/HardThresholdBackground.h" | ||
|
||
|
||
|
||
namespace Mantid | ||
{ | ||
namespace Crystal | ||
{ | ||
|
||
/** PeakBackground : Extension of HardThresholdBackground to consider regions of the image as background if they are outside | ||
the peaks radius limits (no mater what their theshold is). For pixels inside the radius, they must also be above the threshold value. | ||
Copyright © 2014 ISIS Rutherford Appleton Laboratory & NScD Oak Ridge National Laboratory | ||
This file is part of Mantid. | ||
Mantid is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation; either version 3 of the License, or | ||
(at your option) any later version. | ||
Mantid is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
File change history is stored at: <https://github.com/mantidproject/mantid> | ||
Code Documentation is available at: <http://doxygen.mantidproject.org> | ||
*/ | ||
|
||
class DLLExport PeakBackground : public HardThresholdBackground | ||
{ | ||
private: | ||
|
||
/// Peak workspace containing peaks of interest | ||
Mantid::API::IPeaksWorkspace_const_sptr m_peaksWS; | ||
/// Radius estimate | ||
const double m_radiusEstimate; | ||
/// MD coordinates to use | ||
const Mantid::API::SpecialCoordinateSystem m_mdCoordinates; | ||
|
||
public: | ||
/// Constructor | ||
PeakBackground(Mantid::API::IPeaksWorkspace_const_sptr peaksWS, const double& radiusEstimate, const double& thresholdSignal, const Mantid::API::MDNormalization normalisation, const Mantid::API::SpecialCoordinateSystem coordinates); | ||
|
||
/// Overriden is background function | ||
virtual bool isBackground(Mantid::API::IMDIterator* iterator) const; | ||
|
||
/// Overriden configure iterator function. | ||
virtual void configureIterator(Mantid::API::IMDIterator* const iterator) const; | ||
|
||
/// Destructor | ||
virtual ~PeakBackground(); | ||
}; | ||
|
||
|
||
} // namespace Crystal | ||
} // namespace Mantid | ||
|
||
#endif /* MANTID_CRYSTAL_PEAKBACKGROUND_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#include "MantidCrystal/PeakBackground.h" | ||
#include "MantidAPI/IPeak.h" | ||
|
||
using namespace Mantid::API; | ||
using namespace Mantid::Kernel; | ||
using Mantid::API::IPeak; | ||
|
||
namespace Mantid | ||
{ | ||
namespace Crystal | ||
{ | ||
|
||
|
||
//---------------------------------------------------------------------------------------------- | ||
/** Constructor | ||
*/ | ||
PeakBackground::PeakBackground(IPeaksWorkspace_const_sptr peaksWS, const double& radiusEstimate, const double& thresholdSignal, const Mantid::API::MDNormalization normalisation, const SpecialCoordinateSystem coordinates) | ||
: HardThresholdBackground(thresholdSignal, normalisation), m_peaksWS(peaksWS), m_radiusEstimate(radiusEstimate), m_mdCoordinates(coordinates) | ||
{ | ||
} | ||
|
||
//---------------------------------------------------------------------------------------------- | ||
/** Destructor | ||
*/ | ||
PeakBackground::~PeakBackground() | ||
{ | ||
} | ||
|
||
|
||
bool PeakBackground::isBackground(Mantid::API::IMDIterator* iterator) const | ||
{ | ||
if(!HardThresholdBackground::isBackground(iterator) ) | ||
{ | ||
const VMD& center = iterator->getCenter(); | ||
V3D temp(center[0], center[1], center[2]); // This assumes dims 1, 2, and 3 in the workspace correspond to positions. | ||
|
||
for(size_t i = 0; i < m_peaksWS->getNumberPeaks(); ++i) | ||
{ | ||
V3D coords; | ||
if(m_mdCoordinates==QLab) | ||
{ | ||
coords= m_peaksWS->getPeak(i).getQLabFrame(); | ||
} | ||
else if(m_mdCoordinates==QSample) | ||
{ | ||
coords= m_peaksWS->getPeak(i).getQSampleFrame(); | ||
} | ||
else if(m_mdCoordinates==Mantid::API::HKL) | ||
{ | ||
coords= m_peaksWS->getPeak(i).getHKL(); | ||
} | ||
if(coords.distance(temp) < m_radiusEstimate) | ||
{ | ||
return false; | ||
} | ||
|
||
} | ||
|
||
} | ||
return true; | ||
} | ||
|
||
void PeakBackground::configureIterator(Mantid::API::IMDIterator* const ) const | ||
{ | ||
} | ||
|
||
} // namespace Crystal | ||
} // namespace Mantid |
Oops, something went wrong.