-
Notifications
You must be signed in to change notification settings - Fork 5
Calculate world coordinate for plot axes #2283
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds the capability to display plot axes in centimeters (cm) instead of bin numbers for Geant4 simulation results. Since Geant4 returns data in CSV format with bin numbers and doesn't provide a straightforward way to include cm coordinates, the solution parses the macro file to extract detector dimensions and translates bin numbers to world coordinates.
Key Changes:
- Added macro file parsing to extract scorer metadata (detector dimensions, translations, bin counts) for both box and cylinder geometries
- Implemented bin-to-coordinate conversion logic that calculates actual world positions based on detector size and bin counts
- Updated result file parsing to use cm units for plot axes instead of empty unit strings
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 9 comments.
| File | Description |
|---|---|
| src/services/Geant4ResultsFileParser.ts | Added macro file parsing logic, scorer metadata tracking, and bin-to-coordinate conversion; updated axis units from empty string to 'cm' |
| src/services/Geant4LocalWorkerSimulationService.ts | Updated constructor call to pass macro file content to the parser |
Comments suppressed due to low confidence (1)
src/services/Geant4ResultsFileParser.ts:1
- Unused import meta.
import { meta } from 'eslint-plugin-simple-import-sort';
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
See also #2287 |
Looks good overall, but please remove the "Pr" tab.
I cleaned it in a previous PR: https://github.com//pull/2289
I would also suggest to increase number of primaries to 10000 when recalculating this example |



This PR adds plot axis display in cm instead of bin numbers for Geant4.
Geant4 returns data in a CSV format with each datapoint corresponding to bin number. There is no (to my knowledge, at least) straightforward way to put coordinates in cm there instead.
We still want to display cm for plots in the UI, so we need to translate the bin number. To get the sizes of the detectors, we need to parse the macro file again in JS. We cannot rely on the editor data that is parsed to get the macro file. This is because the editor data is not always present. Users can input their macro commands to the editor in the UI and run from this file.