Skip to content

CAD->TGeo: Add first support for material mapping#15127

Open
sawenzel wants to merge 1 commit intoAliceO2Group:devfrom
sawenzel:swenzel/cad-materials
Open

CAD->TGeo: Add first support for material mapping#15127
sawenzel wants to merge 1 commit intoAliceO2Group:devfrom
sawenzel:swenzel/cad-materials

Conversation

@sawenzel
Copy link
Collaborator

@sawenzel sawenzel commented Mar 6, 2026

The present commit adds support to complement
the geometry created from CAD STEP files with materials.

For now the script can process materials mentioned in a CSV
file, where each line maps the CAD part name to a material string.

An example is this

,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
CAD,Mechanical/Part,ST1782525_01,AA.04,FIRST PART,1.51881,St. Steel EN 1.4306 (304L)
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
CAD,Mechanical/Part,ST2487461_01,AA.04,SECOND PART,2.344,Alu EN AW-5083 (H116)
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
CAD,Mechanical/Part,ST2487721_01,AA.02,THIRD PART,0.313133,Carbon Fiber

where ST2487721_01 are the part names referenced in the STEP file.

The conversion script will read the material names (e.g., Alu EN AW-5083 (H116)) and attempt a mapping to known materials in the Geant4 NIST database of materials based on string matching as well as material density.

The user should check the emitted materials in the resulting geometry file (geom.C) and possibly edit/correct the code. Another possibility would be to fix the CSV file from the start and only reference Geant4 NIST names.

The commit also contains a small utility to extract a JSON G4 NIST database from the Geant4 engine. The resulting JSON file G4_NIST_DB.json is also part of the commit and can be extended by the user with further definitions.

A complete conversion example, including materials would like this:

python3 O2_CADtoTGeo.py STEPFILE.stp --mesh [--mesh-prec 1.2]    \
         --out-path tgeo_geometry_output_folder -o geom.C        \
	 --materials-csv MATERIALS.csv                           \
	 --g4-nist-json G4_NIST_DB.json

Code generated with help of a code assistant.

The present commit adds support to complement
the geometry created from CAD STEP files with materials.

For now the script can process materials in a CSV
file, where each line maps the CAD part name to a material string.

An example is this
```
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
CAD,Mechanical/Part,ST1782525_01,AA.04,FIRST PART,1.51881,St. Steel EN 1.4306 (304L)
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
CAD,Mechanical/Part,ST2487461_01,AA.04,SECOND PART,2.344,Alu EN AW-5083 (H116)
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
CAD,Mechanical/Part,ST2487721_01,AA.02,THIRD PART,0.313133,Carbon Fiber
```
where `ST2487721_01` are the part names referenced in the STEP file.

The conversion script will read the material names (e.g., Alu EN AW-5083 (H116))
and attempt a mapping to known materials in the Geant4 NIST database of materials
based on string matching as well as material density.

The user should check the emitted materials in the resulting geometry
file (geom.C) and possibly edit/correct the code. Another possibility
would be to fix the CSV file from the start and only reference Geant4 NIST
names.

The commit also contains a small utility to extract a JSON G4 NIST database
from the Geant4 engine. The resulting JSON file `G4_NIST_DB.json` is also
part of the commit and can be extended by the user with further definitions.

A complete conversion example, including materials would like this:
```bash
python3 O2_CADtoTGeo.py STEPFILE.stp --mesh [--mesh-prec 1.2]    \
         --out-path tgeo_geometry_output_folder -o geom.C        \
	 --materials-csv MATERIALS.csv                           \
	 --g4-nist-json G4_NIST_DB.json
```

Code generated with help of a code assistent.
@sawenzel sawenzel requested a review from a team as a code owner March 6, 2026 08:23
@github-actions
Copy link
Contributor

github-actions bot commented Mar 6, 2026

REQUEST FOR PRODUCTION RELEASES:
To request your PR to be included in production software, please add the corresponding labels called "async-" to your PR. Add the labels directly (if you have the permissions) or add a comment of the form (note that labels are separated by a ",")

+async-label <label1>, <label2>, !<label3> ...

This will add <label1> and <label2> and removes <label3>.

The following labels are available
async-2023-pbpb-apass4
async-2023-pp-apass4
async-2024-pp-apass1
async-2022-pp-apass7
async-2024-pp-cpass0
async-2024-PbPb-apass1
async-2024-ppRef-apass1
async-2024-PbPb-apass2
async-2023-PbPb-apass5

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant