Skip to content
Snippets Groups Projects
Commit 79d3ed4a authored by Anders Markvardsen's avatar Anders Markvardsen
Browse files

Fix to CalMuonDeadTime. Re #4337

Turned out that muon data with count equal to zero have zero errors (at least an EMU dataset).
Zero errors are no good when fitting.
parent 6df7bfba
No related branches found
No related tags found
No related merge requests found
...@@ -60,6 +60,14 @@ void CalMuonDeadTime::exec() ...@@ -60,6 +60,14 @@ void CalMuonDeadTime::exec()
const double lastgooddata = getProperty("LastGoodData"); const double lastgooddata = getProperty("LastGoodData");
// Seem to have to do this to avoid MantidPlot to crash when
// running this algorithm where the "DataFitted" WS already exists
std::string dataFittedName = getPropertyValue("DataFitted");
if (API::AnalysisDataService::Instance().doesExist(dataFittedName))
API::AnalysisDataService::Instance().remove(dataFittedName);
// Get number of good frames from Run object. This also serves as // Get number of good frames from Run object. This also serves as
// a test to see if valid input workspace has been provided // a test to see if valid input workspace has been provided
...@@ -84,7 +92,8 @@ void CalMuonDeadTime::exec() ...@@ -84,7 +92,8 @@ void CalMuonDeadTime::exec()
// Start created a temperary workspace with data we are going to fit // Start created a temperary workspace with data we are going to fit
// against. First step is to crop to only include data from firstgooddata // against. First step is to crop to only include data between firstgooddata
// and lastgooddata
std::string wsName = "TempForMuonCalDeadTime"; std::string wsName = "TempForMuonCalDeadTime";
API::IAlgorithm_sptr cropWS; API::IAlgorithm_sptr cropWS;
...@@ -95,6 +104,8 @@ void CalMuonDeadTime::exec() ...@@ -95,6 +104,8 @@ void CalMuonDeadTime::exec()
cropWS->setProperty("XMax", lastgooddata); cropWS->setProperty("XMax", lastgooddata);
cropWS->executeAsSubAlg(); cropWS->executeAsSubAlg();
// get cropped input workspace
boost::shared_ptr<API::MatrixWorkspace> wsCrop = boost::shared_ptr<API::MatrixWorkspace> wsCrop =
cropWS->getProperty("OutputWorkspace"); cropWS->getProperty("OutputWorkspace");
...@@ -111,6 +122,8 @@ void CalMuonDeadTime::exec() ...@@ -111,6 +122,8 @@ void CalMuonDeadTime::exec()
convertToPW->setPropertyValue("OutputWorkspace", wsName); convertToPW->setPropertyValue("OutputWorkspace", wsName);
convertToPW->executeAsSubAlg(); convertToPW->executeAsSubAlg();
// get pointworkspace
boost::shared_ptr<API::MatrixWorkspace> wsFitAgainst = boost::shared_ptr<API::MatrixWorkspace> wsFitAgainst =
convertToPW->getProperty("OutputWorkspace"); convertToPW->getProperty("OutputWorkspace");
...@@ -122,11 +135,26 @@ void CalMuonDeadTime::exec() ...@@ -122,11 +135,26 @@ void CalMuonDeadTime::exec()
{ {
const double time = wsFitAgainst->dataX(i)[t]; // mid-point time value because point WS const double time = wsFitAgainst->dataX(i)[t]; // mid-point time value because point WS
const double decayFac = exp(time/muonDecay); const double decayFac = exp(time/muonDecay);
wsFitAgainst->dataY(i)[t] = wsCrop->dataY(i)[t]*decayFac; if ( wsCrop->dataY(i)[t] > 0 )
wsFitAgainst->dataX(i)[t] = wsCrop->dataY(i)[t]; {
wsFitAgainst->dataE(i)[t] = wsCrop->dataE(i)[t]*decayFac; wsFitAgainst->dataY(i)[t] = wsCrop->dataY(i)[t]*decayFac;
wsFitAgainst->dataX(i)[t] = wsCrop->dataY(i)[t];
wsFitAgainst->dataE(i)[t] = wsCrop->dataE(i)[t]*decayFac;
}
else
{
// For the Muon data which I have looked at when zero counts
// the errors are zero which is likely nonsense. Hence to get
// around this problem treat such counts to be 0.1 with standard
// of one........
wsFitAgainst->dataY(i)[t] = 0.1*decayFac;
wsFitAgainst->dataX(i)[t] = 1.0;
wsFitAgainst->dataE(i)[t] = decayFac;
}
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment