-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEventWorkspaceDev.html
220 lines (177 loc) · 11.9 KB
/
EventWorkspaceDev.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
<!DOCTYPE html>
<html lang="en" data-content_root="./">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Event Workspace Development</title>
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=03e43079" />
<link rel="stylesheet" type="text/css" href="_static/bootstrap-sphinx.css?v=fadd4351" />
<link rel="stylesheet" type="text/css" href="_static/custom.css?v=77160d70" />
<script src="_static/documentation_options.js?v=a8da1a53"></script>
<script src="_static/doctools.js?v=9bcbadda"></script>
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="Handling XML" href="HandlingXML.html" />
<link rel="prev" title="What is EnumeratedStringProperty?" href="EnumeratedStringProperty.html" />
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-59110517-1', 'auto');
ga('send', 'pageview');
</script>
</head><body>
<div id="navbar" class="navbar navbar-default ">
<div class="container">
<div class="navbar-header">
<!-- .btn-navbar is used as the toggle for collapsed navbar content -->
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="http://www.mantidproject.org">
</a>
<span class="navbar-text navbar-version pull-left"><b>main</b></span>
</div>
<div class="collapse navbar-collapse nav-collapse">
<ul class="nav navbar-nav">
<li class="divider-vertical"></li>
<li><a href="index.html">Home</a></li>
<li><a href="https://download.mantidproject.org">Download</a></li>
<li><a href="https://docs.mantidproject.org">User Documentation</a></li>
<li><a href="http://www.mantidproject.org/contact">Contact Us</a></li>
</ul>
<form class="navbar-form navbar-right" action="search.html" method="get">
<div class="form-group">
<input type="text" name="q" class="form-control" placeholder="Search" />
</div>
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<p>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="nav-item nav-item-0"><a href="index.html">Documentation</a> »</li>
<li class="nav-item nav-item-this"><a href="">Event Workspace Development</a></li>
</ul>
</div> </p>
</div>
<div class="container">
<div class="row">
<div class="body col-md-12 content" role="main">
<section id="event-workspace-development">
<span id="event-workspace-dev"></span><h1>Event Workspace Development<a class="headerlink" href="#event-workspace-development" title="Link to this heading">¶</a></h1>
<nav class="contents local" id="contents">
<ul class="simple">
<li><p><a class="reference internal" href="#individual-neutron-event-data-tofevent" id="id1">Individual Neutron Event Data (TofEvent)</a></p></li>
<li><p><a class="reference internal" href="#lists-of-events-eventlist" id="id2">Lists of Events (EventList)</a></p></li>
<li><p><a class="reference internal" href="#most-recently-used-list-mrulist" id="id3">Most Recently Used List (MRUList)</a></p></li>
<li><p><a class="reference internal" href="#a-note-about-workspace-index-spectrum-number-detector-id" id="id4">A note about workspace index / spectrum number / detector ID</a></p></li>
<li><p><a class="reference internal" href="#workspace2d-compatibility" id="id5">Workspace2D compatibility</a></p></li>
<li><p><a class="reference internal" href="#a-note-about-thread-safety" id="id6">A Note about Thread Safety</a></p></li>
</ul>
</nav>
<p>The following information will be useful to you if you want to write an
<a class="reference external" href="https://docs.mantidproject.org/nightly/concepts/Algorithm.html#algorithm" title="(in MantidProject v6.11)"><span>Algorithm</span></a> that is <a class="reference external" href="https://docs.mantidproject.org/nightly/concepts/EventWorkspace.html#eventworkspace" title="(in MantidProject v6.11)"><span class="xref std std-ref">Event Workspace</span></a> aware.</p>
<section id="individual-neutron-event-data-tofevent">
<h2><a class="toc-backref" href="#id1" role="doc-backlink">Individual Neutron Event Data (TofEvent)</a><a class="headerlink" href="#individual-neutron-event-data-tofevent" title="Link to this heading">¶</a></h2>
<p>The <a class="reference external" href="https://github.com/mantidproject/mantid/blob/main/Framework/Types/inc/MantidTypes/Event/TofEvent.h">TofEvent</a> class holds information for each neutron detection event
data:</p>
<ul class="simple">
<li><p>PulseTime: An absolute time of the pulse that generated this neutron.
This is saved as an INT64 of the number of nanoseconds since Jan 1,
1990; this can be converted to other date and time formats as needed.
Internall the PulseTime is represented as a Kernel::DateAndTime type.</p></li>
<li><p>tof: Time-of-flight of the neutron, in microseconds, as a double.
Note that this field can be converted to other units, e.g. d-spacing.</p></li>
</ul>
<div class="admonition tip">
<p class="admonition-title">Tip</p>
<p>There are in fact several variants of the Event type within Mantid. The common by far is the RAW TOF described above, but there are also <code class="docutils literal notranslate"><span class="pre">Weighted</span></code> events that offer better compression.</p>
</div>
</section>
<section id="lists-of-events-eventlist">
<h2><a class="toc-backref" href="#id2" role="doc-backlink">Lists of Events (EventList)</a><a class="headerlink" href="#lists-of-events-eventlist" title="Link to this heading">¶</a></h2>
<ul class="simple">
<li><p>The EventList class consists of a list of TofEvent’s. The order of
this list is not significant, since various algorithms will resort by
time of flight or pulse time, as needed.</p></li>
<li><p>Also contained in the EventList is a std::set of detector ID’s. This tracks which detector(s) were hit by the events in the list. <code class="docutils literal notranslate"><span class="pre">EventList</span></code> is a subtype of <code class="docutils literal notranslate"><span class="pre">ISpectrum</span></code>, which provides the interface to many of the spectrum level access methods.</p></li>
<li><p>The histogram bins (X axis) are also stored in EventList. The Y and E
histogram data are not, however, as they are calculated on demand by the MRU
(below).</p></li>
</ul>
<p>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.</p>
</section>
<section id="most-recently-used-list-mrulist">
<h2><a class="toc-backref" href="#id3" role="doc-backlink">Most Recently Used List (MRUList)</a><a class="headerlink" href="#most-recently-used-list-mrulist" title="Link to this heading">¶</a></h2>
<p>An Event Workspace contains a list of the 100 most-recently used
histograms, a MRUList. This MRU caches the last histogram
data generated for fastest display.</p>
</section>
<section id="a-note-about-workspace-index-spectrum-number-detector-id">
<h2><a class="toc-backref" href="#id4" role="doc-backlink">A note about workspace index / spectrum number / detector ID</a><a class="headerlink" href="#a-note-about-workspace-index-spectrum-number-detector-id" title="Link to this heading">¶</a></h2>
<p>For event workspaces there is no benefit, and only a drawback to grouping detectors in hardware, therefore most of the loading algorithms for event data <strong>match</strong> the workspace index and spectrum number
in the Event Workspace. Therefore, in an Event Workspace, the two numbers
will often 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.</p>
</section>
<section id="workspace2d-compatibility">
<h2><a class="toc-backref" href="#id5" role="doc-backlink">Workspace2D compatibility</a><a class="headerlink" href="#workspace2d-compatibility" title="Link to this heading">¶</a></h2>
<p>Event Workspace is designed to be able to be read (but not written to)
like a <a class="reference external" href="https://docs.mantidproject.org/nightly/concepts/MatrixWorkspace.html#matrixworkspace" title="(in MantidProject v6.11)"><span class="xref std std-ref">MatrixWorkspace</span></a>. By default, if an algorithm
performs an operation and outputs a new workspace, the
WorkspaceFactory will create a <a class="reference external" href="https://docs.mantidproject.org/nightly/concepts/Workspace2D.html#workspace2d" title="(in MantidProject v6.11)"><span>Workspace2D</span></a> <em>copy</em>
of your Event Workspace’s histogram representation. If you attempt to
change an Event Workspace’s Y or E data in place, you will get an <code class="docutils literal notranslate"><span class="pre">NotImplementedError</span></code> raised, since that is not possible.</p>
</section>
<section id="a-note-about-thread-safety">
<h2><a class="toc-backref" href="#id6" role="doc-backlink">A Note about Thread Safety</a><a class="headerlink" href="#a-note-about-thread-safety" title="Link to this heading">¶</a></h2>
<p>Thread safety can be surprising when using an Event Workspace:</p>
<p>If two threads <em>read</em> a Y histogram at the same time, this <em>can</em> 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.</p>
<p>Remember that the <code class="docutils literal notranslate"><span class="pre">PARALLEL\_FOR1()</span></code>, <code class="docutils literal notranslate"><span class="pre">PARALLEL\_FOR2()</span></code> etc. macros will
perform the check Workspace->threadSafe() on the input Event Workspace.
This function will return <em>false</em> (thereby disabling parallelization) if
any of the event lists are unsorted.</p>
<p>You can go around this by forcing the parallel loop with a plain
<code class="docutils literal notranslate"><span class="pre">PARALLEL\_FOR()</span></code> macro. <strong>Make sure you do not read from the same
spectrum in parallel!</strong></p>
</section>
</section>
</div>
</div>
</div>
<footer class="footer">
<div class="container">
<ul class="nav navbar-nav" style=" float: right;">
<li>
<a href="EnumeratedStringProperty.html" title="Previous Chapter: What is EnumeratedStringProperty?"><span class="glyphicon glyphicon-chevron-left visible-sm"></span><span class="hidden-sm hidden-tablet">« What is Enume...</span>
</a>
</li>
<li>
<a href="HandlingXML.html" title="Next Chapter: Handling XML"><span class="glyphicon glyphicon-chevron-right visible-sm"></span><span class="hidden-sm hidden-tablet">Handling XML »</span>
</a>
</li>
<li><a href="#">Back to top</a></li>
</ul>
<p>
</p>
</div>
</footer>
</body>
</html>