\(\renewcommand\AA{\unicode{x212B}}\)
Table of Contents
| Name | Direction | Type | Default | Description | 
|---|---|---|---|---|
| InputWorkspace | Input | EventWorkspace | Mandatory | An input event workspace to use as a source for the events. | 
| RangeStart | Input | number | Optional | Set the lower bound for sampling the background. | 
| RangeEnd | Input | number | Optional | Set the upper bound for sampling the background. | 
| OutputWorkspace | Output | MatrixWorkspace | Mandatory | Output event workspace containing a flat background. | 
This creates a new event workspace from an existing one by sampling an area of the source workspaces background and then using this to create a new workspace that covers the same data range as the input workspace.
Example: Extract the background into another workspace
ws = CreateSampleWorkspace("Event","Multiple Peaks")
wsOut=CreateFlatEventWorkspace(ws,RangeStart=15000,RangeEnd=18000)
#to compare we need to match the bins
wsOut=RebinToWorkspace(wsOut,ws,PreserveEvents=True)
print("The values for every 10th bin.")
print("bin\tws\twsOut")
for i in range (0,ws.blocksize(),10):
    print("{}\t{:.2f}\t{:.2f}".format(i,ws.readY(0)[i],wsOut.readY(0)[i]))
Output:
The values for every 10th bin.
bin     ws      wsOut
0       6.00    6.00
10      6.00    6.00
20      6.00    6.00
30      214.00  6.00
40      6.00   6.00
50      6.00   6.00
60      172.00  6.00
70      6.00   6.00
80      6.00   6.00
90      6.00   6.00
Categories: AlgorithmIndex | CorrectionFunctions\BackgroundCorrections
C++ header: CreateFlatEventWorkspace.h (last modified: 2020-03-20)
C++ source: CreateFlatEventWorkspace.cpp (last modified: 2021-03-31)