feat: pull CAD generated service meshes into simulation
Briefly, what does this PR introduce?
This merges the meshes at https://github.com/eic/epic-data/tree/meshes/meshes/tracking, generated from the EIC project's CAD model of ePIC, courtesy Roland Wimmer. The meshes are stored externally to the epic repository and pulled on-demand only.
Motivation
Because of the way the CAD model is developed (independently), we anticipate many overlaps with structures in the DD4hep geometry, for good reasons (as well as probably some for bad reasons which will have to get fixed). Instead of expecting this to work out of the box, it is a tool to run material scans on the support services only, which can then be turned into effective models of services materials.
This is intended as a way for someone else to generate some material maps or other interface based on these meshes, e.g.
g4MaterialScan -c ${DETECTOR_PATH}/epic_services_only.xml --position=0,0,0 --direction=0.2,0.01,1
This only produces 1 line of materials scans:
+--------------------------------------------------------------------------------------------------------------------------------------------------
+ Material scan between: x_0 = ( 0.00, 0.00, 0.00) [cm] and x_1 = (2000.00, 100.00,10000.00) [cm] TrackID:1:
+--------------------------------------------------------------------------------------------------------------------------------------------------
| \ Material Atomic Radiation Interaction Path Integrated Integrated Material
| Num. \ Name Number/Z Mass/A Density Length Length Thickness Length X0 Lambda Endpoint
| Layer \ [g/mole] [g/cm3] [cm] [cm] [cm] [cm] [cm] [cm] ( cm, cm, cm)
+--------------------------------------------------------------------------------------------------------------------------------------------------
| 1 Air 7 14.784 0.0012 30528.8402 71282.7920 293.718 293.72 0.009621 0.004120 ( 57.60, 2.88, 288.00)
| 2 1.000000_0.000000_0.000000_0.000000_0.000000 26 55.845 7.8500 1.7629 17.0422 16.735 310.45 9.502559 0.986079 ( 60.88, 3.04, 304.41)
| 3 1.000000_0.501961_0.000000_0.000000_0.000000 26 55.845 7.8500 1.7629 17.0422 6.861 317.31 13.394683 1.388684 ( 62.23, 3.11, 311.14)
| 4 Air 7 14.784 0.0012 30528.8402 71282.7920 0.385 317.70 13.394695 1.388690 ( 62.30, 3.12, 311.52)
| 5 0.000000_0.000000_1.000000_0.000000_0.000000 26 55.845 7.8500 1.7629 17.0422 6.535 324.23 17.101945 1.772171 ( 63.58, 3.18, 317.92)
| 6 Air 7 14.784 0.0012 30528.8402 71282.7920 0.189 324.42 17.101951 1.772174 ( 63.62, 3.18, 318.11)
| 7 1.000000_0.501961_0.000000_0.000000_0.000000 26 55.845 7.8500 1.7629 17.0422 3.450 327.87 19.059236 1.974637 ( 64.30, 3.21, 321.49)
| 8 Air 7 14.784 0.0012 30528.8402 71282.7920 0.098 327.97 19.059239 1.974639 ( 64.32, 3.22, 321.59)
| 9 1.000000_0.000000_0.000000_0.000000_0.000000 26 55.845 7.8500 1.7629 17.0422 8.787 336.76 24.043793 2.490246 ( 66.04, 3.30, 330.20)
| 10 Air 7 14.784 0.0012 30528.8402 71282.7920 9861.769 10198.53 24.366825 2.628593 (2000.00, 100.00,10000.00)
That's not like materialScan or materialBudget which can produces eta histograms of stacked contributions or eta/phi histograms of integrated radiation lengths. So, this needs a bit more work to get into an effective model through some scripting (inside or outside g4MaterialScan, which is just a python tool and where we can likely read the geometry once and use it many times).
Additional details on meshing
The CAD model is provided in STEP format, exported to the tessellated obj format (because it can handle multiple volumes), cleaned up interactively in meshlab or as a non-graphical batch job with pymeshlab:
import pymeshlab
ms = pymeshlab.MeshSet()
ms.load_new_mesh("meshes/FullCableSpaceEstimate.obj")
ms.meshing_remove_t_vertices()
ms.save_current_mesh("meshes/FullCableSpaceEstimate_v2.obj")
The materials in the original file are essentially the colors in the STEP file, R_G_B_?_?. These correspond to materials names that can be defined in the xml reader in DD4hep, e.g. blue can be defined a iron:
<material name="0.000000_0.000000_1.000000_0.000000_0.000000">
<D value="7.85" unit="g/cm3"/>
<fraction n="1" ref="Fe"/>
</material>
Naturally this is not correct, but can be tweaked (meshlab annoyingly renames the materials...).
Adjusted the material_scan script for the material map (X0) of the imported geometry over eta. The X0 value seems too high so I suspect there are some units inconsistency from the import, doing some checks now. Do we also need a scan over phi? Another issue is that the material names are not human-readable.
FYI, https://github.com/AIDASoft/DD4hep/pull/1105 has been backported into our environment so rotations should now be respected.
FYI, AIDASoft/DD4hep#1105 has been backported into our environment so rotations should now be respected.
That's nice!
hmmm, my local test with service structure simulation failed... (it took a very long time)
It gives thousands of "Polyhedron::SetReferences: List xxx is not empty" error and then simply ends with "simulation failed"
Is there a way we can cherry pick the material scan script into a separate PR and merge it independently?
Is there a way we can cherry pick the material scan script into a separate PR and merge it independently?
Yes, I was also thinking about a separate PR for this script. Will do it soon.