Skip to content

Conversation

@kmichalikk
Copy link
Contributor

@kmichalikk kmichalikk commented Nov 25, 2025

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.

image

@kmichalikk kmichalikk self-assigned this Nov 25, 2025
Copy link
Contributor

Copilot AI left a 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.

@kmichalikk kmichalikk requested a review from grzanka November 26, 2025 21:15
@grzanka
Copy link
Contributor

grzanka commented Nov 27, 2025

Can you rename iZ to Position (Z) like in the SHIELD-HIT12A results ?
The same should apply to X and Y.

image image

@grzanka
Copy link
Contributor

grzanka commented Nov 27, 2025

See also #2287

@grzanka
Copy link
Contributor

grzanka commented Dec 1, 2025

image 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

@grzanka grzanka added this pull request to the merge queue Dec 1, 2025
Merged via the queue into master with commit f432b6c Dec 1, 2025
11 checks passed
@grzanka grzanka deleted the @kmichalikk/histogram-x-unit branch December 1, 2025 10:02
@grzanka grzanka mentioned this pull request Dec 2, 2025
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