The EventWorkspace is a type of MatrixWorkspace, where the information about each individual neutron detection event is maintained. For you as a user, this means that:
The following information will be useful to you if you want to write an algorithm that is EventWorkspace-aware.
The TofEvent class holds information for each neutron detection event data:
The += operator can be used to append two EventList’s together. The lists of TofEvent’s get appended, as is the list of detector ID’s. Don’t mess with the udetmap manually if you start appending event lists - just call EventWorkpspace->makeSpectraMap to generate the spectra map (map between spectrum # and detector IDs) by using the info in each EventList.
An EventWorkspace contains a list of the 100 most-recently used histograms, a MRUList. This MRU caches the last histogram data generated for fastest display.
The loading algorithms match the workspace index and spectrum number in the EventWorkspace. Therefore, in an EventWorkspace, the two numbers will be the same, and your workspace’s Axis[1] is a simple 1:1 map. As mentioned above, the detectorID is saved in EventList, but the makeSpectraMap() method generates the usual SpectraDetectorMap object.
EventWorkspace is designed to be able to be read (but not written to) like a Workspace2D. By default, if an algorithm performs an operation and outputs a new workspace, the WorkspaceFactory will create a Workspace2D copy of your EventWorkspace’s histogram representation. If you attempt to change an EventWorkspace’s Y or E data in place, you will get an error message, since that is not possible.
Thread safety can be surprising when using an EventWorkspace:
If two threads read a Y histogram at the same time, this can cause problems. This is because the histogramming code will try to sort the event list. If two threads try to sort the same event list, you can get segfaults.
Remember that the PARALLEL_FOR1(), PARALLEL_FOR2() etc. macros will perform the check Workspace->threadSafe() on the input EventWorkspace. This function will return false (thereby disabling parallelization) if any of the event lists are unsorted.
You can go around this by forcing the parallel loop with a plain PARALLEL_FOR() macro. Make sure you do not read from the same spectrum in parallel!
Category: Concepts