diff --git a/Framework/Algorithms/src/CalMuonDetectorPhases.cpp b/Framework/Algorithms/src/CalMuonDetectorPhases.cpp index 01de6b57df8999ecfceb226ffa2ed4ca3cc16ef0..68de5827141ecdae591b4554693bba4ba0672233 100644 --- a/Framework/Algorithms/src/CalMuonDetectorPhases.cpp +++ b/Framework/Algorithms/src/CalMuonDetectorPhases.cpp @@ -17,9 +17,10 @@ namespace { bool isZero(double value) { - bool result = value == 0; - return result; + return value == 0; } +int phaseRow = 2; +double asymError = 999.0; } namespace Mantid { @@ -179,10 +180,10 @@ void CalMuonDetectorPhases::fitWorkspace(const API::MatrixWorkspace_sptr &ws, tab->addColumn("double", "Error"); for (int j = 0; j < 4; j++) { API::TableRow row = tab->appendRow(); - if (j == 2) { + if (j == phaseRow) { row << "dummy" << 0.0 << 0.0; } else { - row << "dummy" << 999. << 0.0; + row << "dummy" << asymError << 0.0; } } diff --git a/Framework/Algorithms/src/PhaseQuadMuon.cpp b/Framework/Algorithms/src/PhaseQuadMuon.cpp index 2859396369a5d4e7ac514cba145403a0561e04e6..3e56de0ed9407ec3316b0ebbb2c75d85442572f9 100644 --- a/Framework/Algorithms/src/PhaseQuadMuon.cpp +++ b/Framework/Algorithms/src/PhaseQuadMuon.cpp @@ -29,8 +29,7 @@ int findName(const T1 &patterns, const T2 &names) { return -1; } bool isZero(double value) { - bool result = value == 0; - return result; + return value == 0; } } @@ -243,6 +242,7 @@ PhaseQuadMuon::squash(const API::MatrixWorkspace_sptr &ws, throw std::invalid_argument("Invalid detector asymmetries"); } std::vector<bool> emptySpectrum; + emptySpectrum.reserve(nspec); std::vector<double> aj, bj; { // Calculate coefficients aj, bj diff --git a/Framework/Algorithms/src/RemoveExpDecay.cpp b/Framework/Algorithms/src/RemoveExpDecay.cpp index 10944bc87da9d848f6f397e816a4f962cdbd0104..4e50341f0f6eacffab1eaf479e91b549a6628479 100644 --- a/Framework/Algorithms/src/RemoveExpDecay.cpp +++ b/Framework/Algorithms/src/RemoveExpDecay.cpp @@ -21,8 +21,7 @@ constexpr double MUON_LIFETIME_MICROSECONDS{ Mantid::PhysicalConstants::MuonLifetime * MICROSECONDS_PER_SECOND}; bool isZero(double value) { - bool result = value == 0; - return result; + return value == 0; } } @@ -110,7 +109,7 @@ void MuonRemoveExpDecay::exec() { inputWS->y(specNum).end(), isZero); if (emptySpectrum) { // if the y values are all zero do not change them - m_log.warning("waaa " + std::to_string(specNum)); + m_log.warning("Dead detector found at spectrum number " + std::to_string(specNum)); outputWS->setHistogram(specNum, inputWS->histogram(specNum)); } else { // Remove decay from Y and E diff --git a/Framework/Algorithms/test/PhaseQuadMuonTest.h b/Framework/Algorithms/test/PhaseQuadMuonTest.h index 5948a2dc854fc7f48800a8735038deee84166c95..84ba2ae004976c35b04e49aa758f4b91349da24c 100644 --- a/Framework/Algorithms/test/PhaseQuadMuonTest.h +++ b/Framework/Algorithms/test/PhaseQuadMuonTest.h @@ -20,7 +20,7 @@ namespace { const int dead1 = 4; const int dead2 = 12; -void populatePhaseTable2(ITableWorkspace_sptr phaseTable, +void populatePhaseTableWithDeadDetectors(ITableWorkspace_sptr phaseTable, const MatrixWorkspace_sptr ws) { phaseTable->addColumn("int", "DetectprID"); phaseTable->addColumn("double", "Asymmetry"); @@ -96,7 +96,7 @@ IAlgorithm_sptr setupAlgDead(MatrixWorkspace_sptr m_loadedData) { // Create and populate a detector table boost::shared_ptr<ITableWorkspace> phaseTable( new Mantid::DataObjects::TableWorkspace); - populatePhaseTable2(phaseTable, m_loadedData); + populatePhaseTableWithDeadDetectors(phaseTable, m_loadedData); return setupAlg(m_loadedData, true, phaseTable); } @@ -106,7 +106,7 @@ MatrixWorkspace_sptr setupWS(MatrixWorkspace_sptr m_loadedData) { new Mantid::DataObjects::TableWorkspace); MatrixWorkspace_sptr ws = m_loadedData->clone(); // create toy data set - populatePhaseTable2(phaseTable, ws); + populatePhaseTableWithDeadDetectors(phaseTable, ws); auto xData = ws->points(0); for (size_t spec = 0; spec < ws->getNumberHistograms(); spec++) { for (size_t j = 0; j < xData.size(); j++) { diff --git a/Framework/PythonInterface/plugins/algorithms/MuonMaxent.py b/Framework/PythonInterface/plugins/algorithms/MuonMaxent.py index 9d93f21ed4fc73d3295b4e05f0178c30a1308cca..134fac4df1a21436b5d3ca402aa9ad927ca170a8 100644 --- a/Framework/PythonInterface/plugins/algorithms/MuonMaxent.py +++ b/Framework/PythonInterface/plugins/algorithms/MuonMaxent.py @@ -229,11 +229,12 @@ class MuonMaxent(PythonAlgorithm): IDLabel = None asymmLabel = None for name in names: - if name.lower() == "phi" or name.lower() == "phase": + name_lower = name.lower() + if name_lower in {"phi", "phase"}: phaseLabel = name - if name.lower() == "detid" or name.lower() == "spectrum number": + if name_lower in {"detid", "spectrum number"}: IDLabel = name - if name.lower() == "asymmetry" or name.lower() == "asymm" or name.lower() == "asasym": + if name_lower in{"asymmetry", "asymm", "asym"}: asymmLabel = name if phaseLabel is None: raise ValueError( @@ -255,7 +256,6 @@ class MuonMaxent(PythonAlgorithm): phaseLabel] else: # muat be some dead Detectors offset = 0 - print(POINTS_ngroups, "nnn") for row in pt: if row[asymmLabel] == 999: offset += 1 diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/MuonMaxEntTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/MuonMaxEntTest.py index 711bd6881d5da27828c3f653a7496c2fa20e7023..90d92b57f8416d052b13821948224d76b5d96d54 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/MuonMaxEntTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/MuonMaxEntTest.py @@ -39,7 +39,7 @@ class MuonMaxEntTest(unittest.TestCase): UnitX='Time') return inputData - def genData3(self): + def genDataWithDeadDetectors(self): inputData = CreateSimulationWorkspace("MUSR", "0,1,32") xData = (inputData.dataX(0)[1:] + inputData.dataX(0)[:-1]) / 2. for j in range(inputData.getNumberHistograms()): @@ -80,7 +80,7 @@ class MuonMaxEntTest(unittest.TestCase): self.cleanUp() def test_deadDetectors(self): - inputData = self.genData3() + inputData = self.genDataWithDeadDetectors() # check input data has 2 dead detectors for k in range(inputData.getNumberHistograms()): if k == 24 or k == 42: diff --git a/docs/source/release/v3.13.0/muon.rst b/docs/source/release/v3.13.0/muon.rst index e8cd0f2afd3fa848c8dae0e42378cfcdc3df5a43..2333aaccce368c6644684e009528db74353c5d56 100644 --- a/docs/source/release/v3.13.0/muon.rst +++ b/docs/source/release/v3.13.0/muon.rst @@ -33,8 +33,8 @@ Improvements Bug fixes ######### -- :ref:`MuonMaxent <algm-MuonMaxent>` and :ref:`PhaseQuad <algm-PhaseQuad>` no longer include dead detecotrs (zero counts) when calculating the frequency spectrum. -- :ref:`RemoveExpDecay <algm-RemoveExpDecay>` will not alter data from a dead detecotrs (zero counts). -- :ref:`CalMuonDetectorPhases <algm-CalMuonDetectorPhases>` will give an error code for dead detecotrs (zero counts) in the phase table. +- :ref:`MuonMaxent <algm-MuonMaxent>` and :ref:`PhaseQuad <algm-PhaseQuad>` no longer include dead detectors (zero counts) when calculating the frequency spectrum. +- :ref:`RemoveExpDecay <algm-RemoveExpDecay>` will not alter data from a dead detectors (zero counts). +- :ref:`CalMuonDetectorPhases <algm-CalMuonDetectorPhases>` will give an error code for dead detectors (zero counts) in the phase table. :ref:`Release 3.13.0 <v3.13.0>`