Skip to content

Commit

Permalink
Merge pull request #73 from mantidproject/feature/10470_grouped_dets_…
Browse files Browse the repository at this point in the history
…sxdnorm

Support for multiple detectors in MDNormSXD
  • Loading branch information
AndreiSavici committed Nov 27, 2014
2 parents a5bd790 + bbe3809 commit 053f141
Show file tree
Hide file tree
Showing 4 changed files with 778 additions and 666 deletions.
1 change: 0 additions & 1 deletion Code/Mantid/Framework/API/src/ExperimentInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,6 @@ namespace API
{
if(m_detgroups.empty())
{
g_log.debug("No detector mapping cached, getting detector from instrument");
return getInstrument()->getDetector(detID);
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ namespace VectorHelper
/// Return the average of the two arguments
T operator()(const T & x, const T & y) const
{
return 0.5 * (x + y);
return static_cast<T>(0.5) * (x + y);
}
};

Expand Down
133 changes: 74 additions & 59 deletions Code/Mantid/Framework/MDAlgorithms/inc/MantidMDAlgorithms/MDNormSXD.h
Original file line number Diff line number Diff line change
@@ -1,84 +1,99 @@
#ifndef MANTID_MDALGORITHMS_MDNORMSXD_H_
#define MANTID_MDALGORITHMS_MDNORMSXD_H_

#include "MantidKernel/System.h"
#include "MantidAPI/Algorithm.h"
#include "MantidMDAlgorithms/SlicingAlgorithm.h"

namespace Mantid
{
namespace DataObjects
{
class EventWorkspace;
}
namespace MDAlgorithms
{

namespace MDAlgorithms
{
/** MDNormSXD : Generate MD normalization for single crystal diffraction
Copyright &copy; 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.
Copyright &copy; 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.
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/>.
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>
*/
File change history is stored at: <https://github.com/mantidproject/mantid>
Code Documentation is available at: <http://doxygen.mantidproject.org>
*/
class DLLExport MDNormSXD :public SlicingAlgorithm
{
public:
{
public:
MDNormSXD();
virtual ~MDNormSXD();

virtual const std::string name() const;
virtual int version() const;
virtual const std::string category() const;
virtual const std::string summary() const;

private:
void init();
void exec();

virtual const std::string name() const;
virtual int version() const;
virtual const std::string category() const;
virtual const std::string summary() const;

private:
void init();
void exec();

/// function to calculate intersections of teh trajectory with MDBoxes
std::vector<Mantid::Kernel::VMD> calculateIntersections(Mantid::Geometry::IDetector_const_sptr detector);
/// Integrate flux spectra
void integrateFlux( const DataObjects::EventWorkspace& flux, API::MatrixWorkspace &integrFlux );
/// Use interpolation to calculate integrals
void calcIntegralsForIntersections( const std::vector<double> &xValues, const API::MatrixWorkspace &integrFlux, size_t sp, std::vector<double> &yValues ) const;
void cacheInputs();
std::string inputEnergyMode() const;

/// number of MD dimensions
size_t m_nDims;
/// Normalization workspace
Mantid::MDEvents::MDHistoWorkspace_sptr m_normWS;
/// Input workspace
Mantid::API::IMDEventWorkspace_sptr m_inputWS;
///limits for h,k,l dimensions
coord_t hMin,hMax,kMin,kMax,lMin,lMax;
///flag for integrated h,k,l dimensions
bool hIntegrated,kIntegrated,lIntegrated;
///(2*PiRUBW)^-1
Mantid::Kernel::DblMatrix transf;
/// limits for momentum
double KincidentMin,KincidentMax;
///index of h,k,l dimensions in the output workspaces
size_t hIndex,kIndex,lIndex;
/// cached x values along dimensions h,k,l
std::vector<double> m_hX, m_kX, m_lX;
};
MDEvents::MDHistoWorkspace_sptr binInputWS();
void createNormalizationWS(const MDEvents::MDHistoWorkspace & dataWS);
std::vector<coord_t> getValuesFromOtherDimensions(bool & skipNormalization) const;
Kernel::Matrix<coord_t> findIntergratedDimensions(const std::vector<coord_t> & otherDimValues,
bool & skipNormalization);
void cacheDimensionXValues();
void calculateNormalization(const std::vector<coord_t> &otherValues,
const Kernel::Matrix<coord_t> &affineTrans);
void calcIntegralsForIntersections( const std::vector<double> &xValues, const API::MatrixWorkspace &integrFlux,
size_t sp, std::vector<double> &yValues ) const;
std::vector<detid_t> removeGroupedIDs(const API::ExperimentInfo & exptInfo,
const std::vector<detid_t> &detIDs);
Geometry::IDetector_const_sptr getThetaPhi(const detid_t detID,
const API::ExperimentInfo & exptInfo,
double &theta, double &phi);
std::vector<Kernel::VMD> calculateIntersections(const double theta, const double phi);

/// number of MD dimensions
size_t m_nDims;
/// Normalization workspace
MDEvents::MDHistoWorkspace_sptr m_normWS;
/// Input workspace
API::IMDEventWorkspace_sptr m_inputWS;
/// limits for h,k,l dimensions
coord_t m_hmin, m_hmax, m_kmin, m_kmax, m_lmin, m_lmax;
/// flag for integrated h,k,l dimensions
bool m_hIntegrated, m_kIntegrated, m_lIntegrated;
/// (2*PiRUBW)^-1
Mantid::Kernel::DblMatrix m_rubw;
/// limits for momentum
double m_kiMin, m_kiMax;
///index of h,k,l dimensions in the output workspaces
size_t m_hIdx, m_kIdx, m_lIdx;
/// cached X values along dimensions h,k,l
std::vector<double> m_hX, m_kX, m_lX;
/// Sample position
Kernel::V3D m_samplePos;
/// Beam direction
Kernel::V3D m_beamDir;
};

} // namespace MDAlgorithms
} // namespace MDAlgorithms
} // namespace Mantid

#endif /* MANTID_MDALGORITHMS_MDNORMSXD_H_ */

0 comments on commit 053f141

Please sign in to comment.