Skip to content

Conversation

@SimonHeybrock
Copy link
Member

@SimonHeybrock SimonHeybrock commented Sep 1, 2025

This is not complete, put together quickly to assist with Loki detector tests.

Expanded the LokiWorkflow to use the GenericTofWorkflow.
The Larmor workflow still uses the old simple conversion tof = event_time_offset.

We remove the ScatteringRunType as it is not compatible with the GenericTofWorkflow which compute TofDetector[RunType] instead of TofDetector[ScatteringRunType].
The workflow seems to be happy without it.

Needs: scipp/essreduce#292

@nvaytet
Copy link
Member

nvaytet commented Sep 2, 2025

This is good, it's what I was going to start with to implement a tof workflow for Loki 👍

@nvaytet nvaytet changed the title Add notebook with LokiWorkflow LokiWorkflow with time-of-flight calculation Dec 5, 2025
@nvaytet nvaytet marked this pull request as ready for review December 10, 2025 15:22
@nvaytet
Copy link
Member

nvaytet commented Dec 11, 2025

@SimonHeybrock I would like you to review but I can't select you as a reviewer since you opened the PR...

TransmissionRun,
)

bank_size = {'layer': 4, 'tube': -1, 'straw': 7, 'pixel': 512}
Copy link
Member Author

Choose a reason for hiding this comment

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

Why did you choose to make tube the free param? If I remember correctly, pixel was the one that they could configure freely.

Copy link
Member

Choose a reason for hiding this comment

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

You wrote that part 😉 (5cdbd72)

I think it's because all banks have 7 straws, and 4 layers, but they don't all have the same number of tubes.
I can look up the number of tubes for each bank and then set the pixel to -1 if you think that is more future-proof?

Comment on lines 173 to 178
# class TofDetector(sciline.Scope[RunType, sc.DataArray], sc.DataArray):
# """Data with a time-of-flight coordinate"""


class TofMonitor(sciline.Scope[RunType, MonitorType, sc.DataGroup], sc.DataGroup):
"""Monitor data with a time-of-flight coordinate"""
# class TofMonitor(sciline.Scope[RunType, MonitorType, sc.DataGroup], sc.DataGroup):
# """Monitor data with a time-of-flight coordinate"""
Copy link
Member Author

Choose a reason for hiding this comment

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

commented code

# For simplicity, insert a fake beam center instead of computing it.
wf[BeamCenter] = sc.vector([0.0, 0.0, 0.0], unit='m')
wf[NeXusDetectorName] = f'loki_detector_{bank}'
with pytest.raises(UnsatisfiedRequirement, match='TimeOfFlightLookupTableFilename'):
Copy link
Member Author

Choose a reason for hiding this comment

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

Makes me wonder once again why you chose not to abbreviate these types. We use Tof elsewhere, so this you be TofLookupTableFilename, or even just TofLUTFilename. But of course this is unrelated to this PR, so ignore!

Copy link
Member

Choose a reason for hiding this comment

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

👍 for TofLookupTableFilename

Copy link
Member

Choose a reason for hiding this comment

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

Do you know if it would be possible to change the name without breaking everything downstream?
E.g. by adding an alias TimeOfFlightLookupTableFilename = TofLookupTableFilename?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes that should work, only confusing bit might be what shows up in visualizations, but I suppose that would be temporary.

Copy link
Member

Choose a reason for hiding this comment

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

"source": [
"## Setting up the workflow\n",
"\n",
"Note here that for no, we have no chopper in the beamline.\n",
Copy link
Member Author

Choose a reason for hiding this comment

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

Suggested change
"Note here that for no, we have no chopper in the beamline.\n",
"Note here that for now, we have no chopper in the beamline.\n",

"wf[Filename[SampleRun]] = loki.data.loki_coda_file_one_event()\n",
"\n",
"# Visualize the workflow\n",
"wf.visualize(BackgroundSubtractedIofQ, graph_attr={'rankdir': 'LR'})"
Copy link
Member Author

Choose a reason for hiding this comment

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

Suggested change
"wf.visualize(BackgroundSubtractedIofQ, graph_attr={'rankdir': 'LR'})"
"wf.visualize(IntensityQ, graph_attr={'rankdir': 'LR'})"

since you only set the sample run above, so background subtraction wouldn't work?

"metadata": {},
"outputs": [],
"source": [
"wf.compute(RawDetector[SampleRun])"
Copy link
Member Author

Choose a reason for hiding this comment

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

Can't we at least compute tof and wavelength? Also, direct beam was optional iirc, and transmission can be computed from monitors?

Copy link
Member

Choose a reason for hiding this comment

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

In the end, I use the same file for all runs, and compute the IntensityQ.
It's all NaNs at the end, but the workflow still runs.

Copy link
Member Author

@SimonHeybrock SimonHeybrock left a comment

Choose a reason for hiding this comment

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

LGTM (cannot approve).

@nvaytet nvaytet merged commit 8299ee5 into main Dec 11, 2025
4 checks passed
@nvaytet nvaytet deleted the loki-detector-test branch December 11, 2025 10:04
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.

3 participants