-
Notifications
You must be signed in to change notification settings - Fork 6
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
Fix mapping of reflected volumes to VecGeom logical volume instances #22
Conversation
I have tested with |
Happy to check basics and do the eventual merge, but @JuanGonzalezCaminero, @agheata should give final approval to merge as they're best placed to confirm this fixes the Issue! |
@JuanGonzalezCaminero I'm continuing to dig into this and I think the problem may be that the physical rather than logical volumes aren't being correctly mapped from VecGeom to Geant4... |
Thanks Seth, I think I have an idea of what's happening now. During conversion of course the deepest volumes are placed first, and they are mapped just after they are placed: However, if their mother is reflected, the vecgeom reflection factory will go over the daughters, apply the transformation, and actually replace them with a new volume, which will have a different ID: So I believe this may be the reason why the original mappings don't work |
So maybe instead of
we also need to look up the g4pv in the reflection factory and use the equivalent there? EDIT: actually you can't look up the physical volume. Maybe @agheata can help us out? He certainly understands the reflection process better than I do. |
I think mapping the volumes that way is fine since it works for all volumes that don't have a reflection in their path. If a volume is reflected we could propagate that information and skip mapping any placements below them. Then, we probably need to visit and map everything below when we place a reflected volume, only in the first reflection in the path to avoid visiting the same subtree multiple times. |
@JuanGonzalezCaminero I think I've got it working with your and @agheata 's suggestion. The only weirdness is that capacities for the reflected volumes show as negative, but I think this is just a bug in VecGeom. (Previously we were using the underlying volume so we wouldn't have seen the scaled volume's representation, and the capacity implementation multiplies by the scaling factor products which includes the -1 factor.) |
I can confirm that this fixes the issue! While testing it I noticed that the g4vg tests fail to link when using |
@JuanGonzalezCaminero That's great! Can you please take a moment to review the code so I can merge? Also, can you describe your link error? I seem to have no problem building with shared libs (though I generally develop without CUDA...) |
And the CI also builds with shared libs plus CUDA and has no issues... |
The errors don't give much information unfortunately, it fails to find calls from |
OK that sounds like some RDC stuff @pcanal ... |
Enables the new G4VG option to avoid using VecGeom's reflection factory (celeritas-project/g4vg#22), which solves the wrong mapping of the daughters of reflected volumes in G4VG's PlacedVolume ID to G4 physical volume map. Note that since we don't build the map on AdePT side anymore this change is incompatible with any previous G4VG commits.
This adds the reflected (rather than solely the constituent) volumes to the VecGeom -> Geant4 map. It still leaves the mapping in place that points to the unreflected ("constituent") volumes from the reflected VecGeom LVs.
@JuanGonzalezCaminero
Fixes #16 .