Skip to content
Snippets Groups Projects
Commit d5877f2e authored by Lynch, Vickie's avatar Lynch, Vickie
Browse files

Refs #3636 Summing 2 MaskWorkspaces for calibration is correct now

parent d665bcee
No related merge requests found
...@@ -94,6 +94,8 @@ namespace Mantid ...@@ -94,6 +94,8 @@ namespace Mantid
OffsetsWorkspace_sptr outputW(new OffsetsWorkspace(inputW->getInstrument())); OffsetsWorkspace_sptr outputW(new OffsetsWorkspace(inputW->getInstrument()));
// Create the output MaskWorkspace // Create the output MaskWorkspace
MatrixWorkspace_sptr maskWS(new SpecialWorkspace2D(inputW->getInstrument())); MatrixWorkspace_sptr maskWS(new SpecialWorkspace2D(inputW->getInstrument()));
//To get the workspace index from the detector ID
detid2index_map * pixel_to_wi = maskWS->getDetectorIDToWorkspaceIndexMap(true);
// Fit all the spectra with a gaussian // Fit all the spectra with a gaussian
Progress prog(this, 0, 1.0, nspec); Progress prog(this, 0, 1.0, nspec);
...@@ -103,11 +105,11 @@ namespace Mantid ...@@ -103,11 +105,11 @@ namespace Mantid
PARALLEL_START_INTERUPT_REGION PARALLEL_START_INTERUPT_REGION
// Fit the peak // Fit the peak
double offset=fitSpectra(wi); double offset=fitSpectra(wi);
maskWS->dataY(wi)[0] = 1.0; double mask=1.0;
if (std::abs(offset) > maxOffset) if (std::abs(offset) > maxOffset)
{ {
offset = 0.0; offset = 0.0;
maskWS->maskWorkspaceIndex(wi); mask = 0.0;
} }
// Get the list of detectors in this pixel // Get the list of detectors in this pixel
...@@ -121,6 +123,8 @@ namespace Mantid ...@@ -121,6 +123,8 @@ namespace Mantid
for (it = dets.begin(); it != dets.end(); it++) for (it = dets.begin(); it != dets.end(); it++)
{ {
outputW->setValue(*it, offset); outputW->setValue(*it, offset);
if (mask == 0.) maskWS->maskWorkspaceIndex((*pixel_to_wi)[*it]);
else maskWS->dataY((*pixel_to_wi)[*it])[0] = mask;
} }
} }
prog.report(); prog.report();
......
...@@ -218,10 +218,12 @@ class CalibrateRectangularDetectors(PythonAlgorithm): ...@@ -218,10 +218,12 @@ class CalibrateRectangularDetectors(PythonAlgorithm):
WorkspaceIndexMin=self._lastpixel+1, WorkspaceIndexMax=wksp.getNumberHistograms()-1, XMin=self._peakmin2, XMax=self._peakmax2) WorkspaceIndexMin=self._lastpixel+1, WorkspaceIndexMax=wksp.getNumberHistograms()-1, XMin=self._peakmin2, XMax=self._peakmax2)
# Get offsets for pixels using interval around cross correlations center and peak at peakpos (d-Spacing) # Get offsets for pixels using interval around cross correlations center and peak at peakpos (d-Spacing)
GetDetectorOffsets(InputWorkspace=str(wksp)+"cc2", OutputWorkspace=str(wksp)+"offset2", Step=abs(self._binning[1]), GetDetectorOffsets(InputWorkspace=str(wksp)+"cc2", OutputWorkspace=str(wksp)+"offset2", Step=abs(self._binning[1]),
DReference=self._peakpos2, XMin=-self._ccnumber, XMax=self._ccnumber, MaxOffset=self._maxoffset, MaskWorkspace=str(wksp)+"mask",) DReference=self._peakpos2, XMin=-self._ccnumber, XMax=self._ccnumber, MaxOffset=self._maxoffset, MaskWorkspace=str(wksp)+"mask2",)
Plus(LHSWorkspace=str(wksp)+"offset", RHSWorkspace=str(wksp)+"offset2",OutputWorkspace=str(wksp)+"offset") Plus(LHSWorkspace=str(wksp)+"offset", RHSWorkspace=str(wksp)+"offset2",OutputWorkspace=str(wksp)+"offset")
Plus(LHSWorkspace=str(wksp)+"mask", RHSWorkspace=str(wksp)+"mask2",OutputWorkspace=str(wksp)+"mask")
mtd.deleteWorkspace(str(wksp)+"cc2") mtd.deleteWorkspace(str(wksp)+"cc2")
mtd.deleteWorkspace(str(wksp)+"offset2") mtd.deleteWorkspace(str(wksp)+"offset2")
mtd.deleteWorkspace(str(wksp)+"mask2")
mtd.releaseFreeMemory() mtd.releaseFreeMemory()
CreateGroupingWorkspace(InputWorkspace=wksp, GroupNames=groups, OutputWorkspace=str(wksp)+"group") CreateGroupingWorkspace(InputWorkspace=wksp, GroupNames=groups, OutputWorkspace=str(wksp)+"group")
lcinst = str(self._instrument) lcinst = str(self._instrument)
......
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