Skip to content

[essdiffraction] Add initial MagicMcStasWorkflow providers for loading mcstas simulation - #809

Open
MridulS wants to merge 9 commits into
scipp:mainfrom
MridulS:codex/magic-mcstas-reader-geometry
Open

MridulS wants to merge 9 commits into
scipp:mainfrom
MridulS:codex/magic-mcstas-reader-geometry

Conversation

@MridulS

@MridulS MridulS commented Oct 20, 2026

Copy link
Copy Markdown
Member

No description provided.

Construct bank A/B pixel IDs and positions independently of event loading. Reuse the common EmptyDetector type and McStasToX placement transform, with the MAGIC reference shared-plane cassette geometry.

Add reference-coordinate, placement, metadata-validation, and workflow tests, plus user-guide documentation.
@MridulS MridulS changed the title Add initial MagicMcStasWorkflow providers for loading mcstas simulation [essdiffraction] Add initial MagicMcStasWorkflow providers for loading mcstas simulation Oct 20, 2026
@jokasimr jokasimr self-assigned this Oct 23, 2026

@jokasimr jokasimr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall 👍 I think the docs page should be trimmed of the details a bit. Especially those about the detector geometry in the McStas simulation.
We also don't need to list the variance separately in the list of fields, or comment about the assumptions of the estimate, because it is part of the data variable and uses the standard McStas variance estimate.


For comparison with Mantid's sample-centred instrument definition, subtract the global sample position from these pixel positions.
Mantid fixes bank A's radius, length and spacing to 1 m, 0.53 m and 1.05 degrees; comparisons with other values require adapting the reference model.
This provider constructs geometry only; assigning the raw events to these pixels is a separate step.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems a bit superfluous to mention this again, it's already inn the first line after the heading.

Both banks require their absorption logger's position and rotation.
Missing parameters are not replaced with defaults.

For comparison with Mantid's sample-centred instrument definition, subtract the global sample position from these pixel positions.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally we don't assume a specific coordinate system. The workflows should be written to work as long as the components are positioned in a common coordinate system.

I also don't think the loader docs need to tell the user how to convert the positions to the mantid convention, unless this is particularly relevant in this package? (Is the workflow using mantid?)

Similarly, below it is mentioned that mantid fixes some geometry parameters of the bank. Does mantid determine the geometry of the bank in the McStas model? I think I might be missing some context here.

component = _LOGGERS[bank]
filename = Path(filename)
with mcstastox.Read(filename.parent, filename.name) as reader:
translation, rotation = reader.get_component_placement(component)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to me the translation and rotation are only read to be validated. Can't we leave that to McStasToX, since it is anyway used to apply the positioning later?

weights = values.pop('p')
data = sc.array(dims=['event'], values=weights, variances=weights**2, unit='counts')
del weights
return RawMcStasEvents[RunType](

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is t converted to event_time_offset by the Mantid event data loader?
The benefit of using event_time_offset instead of the McStas time is that it makes the data more realistic and forces us to deal with the frame-unwrapping issues. But that can also be done later.

(We can still keep both t and event_time_offset in the dataset if t is useful for diagnostics.)

detector_b = 'detector_b'


class RawMcStasEvents(sl.Scope[RunType, sc.DataArray], sc.DataArray):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typically we try to keep most "McStas concepts" contained in a mcstas module, and the McStas loader returns RawDetectorData just like a regular nexus detector.

That way the workflow does not need to know if it operates on McStas data or real nexus data.
Which one is used depends on what provider is used for the raw detector data domain type.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants