Skip to content
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 using ORANGE geometry with pointer-appended GDML #960

Merged
merged 6 commits into from
Sep 29, 2023

Conversation

sethrj
Copy link
Member

@sethrj sethrj commented Sep 26, 2023

I created a new testem3 GDML file with @stognini 's generator, and updated the equivalent ORANGE file, but it failed to run:

celeritas/src/celeritas/geo/GeoMaterialParams.cc:159: warning: Some geometry volumes do not have known material IDs: world@world, ....
celeritas/src/celeritas/geo/GeoMaterialParams.cc:187:
celeritas: runtime error: num_missing != geo.num_volumes() failed:
    no geometry volumes matched the available materials:
 materials: ..., {world@0x600001b3cd20,0}, ...
volumes: ..., world@world, ...

This is because the geo-material mapper only considered the options that either the name+extension match exactly (e.g. when loading with vecgeom gdml + vecgeom geometry), or when only the name matches (can happen when using geant with pointer stripping?), but it didn't allow for the case when loading a GDML through geant4 for physics but using the ORANGE geometry for tracking.

I've refactored the geomaterial code to do a better job of mapping volume names. Hopefully the code is clearer, and I've updated one of the tests to ensure it still works. Before merging I'd like to make sure that both the celer-sim and accel pathways work with geometries that have duplicate names (but uniquifying extensions) like in cms.

@sethrj sethrj added bug Something isn't working internal labels Sep 26, 2023
@sethrj sethrj requested a review from amandalund September 26, 2023 00:36
@amandalund
Copy link
Contributor

What was the reason for regenerating the GDML?

@sethrj
Copy link
Member Author

sethrj commented Sep 27, 2023

@amandalund I'm finally running a benchmark problem with simple CMS divided into r,z,theta to see how the scaling works. The geometry exporter by @stognini saves pointers (and it's reasonable to assume other user inputs will do the same). I regenerated the testem3 gdml only inside the test directory in order to check that leaving the pointers still works with GDML+ORANGE.

@sethrj sethrj requested a review from pcanal September 28, 2023 01:41
Comment on lines 119 to 131
if (std::distance(start, stop) == 1)
{
return start->second.second;
}

// Multiple labels match
CELER_LOG(warning)
<< "Multiple materials match the volume '" << vol_label << "': "
<< join_stream(
start, stop, ", ", [](std::ostream& os, auto&& mliter) {
os << mliter.second.second.unchecked_get();
});
return start->second.second;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe I'm reading this wrong, but since from this point on we return start->second.second for the MaterialId, might be easier to read if we simply do:

if (std::distance(start, stop) > 1)
{
    // Multiple labels match
    CELER_LOG(warning)
        << "Multiple materials match the volume '" << vol_label << "': "
        << join_stream(
                start, stop, ", ", [](std::ostream& os, auto&& mliter) {
                    os << mliter.second.second.unchecked_get();
                });
}
return start->second.second;

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Thanks! With the output @amandalund got though, it'll make even more sense to build a temporary 'set' and only print if more than one ID exists in the set.

Copy link
Contributor

@amandalund amandalund left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @sethrj, I think the logic is easier to follow now. I tried loading the cms2018, cms-run3, and cms-hllhc geometries through celer-sim and celer-g4. I didn't notice any changes with celer-g4; with celer-sim the warnings are slightly different, but as long as that's expected I think this looks good.

cms2018 has the additional warnings:

/home/alund/celeritas_project/celeritas/src/celeritas/geo/GeoMaterialParams.cc:125: warning: Multiple materials match the volume 'PixelForwardHoldersConnector@0x7f4a8f51d600': 277, 277, 277, 277
/home/alund/celeritas_project/celeritas/src/celeritas/geo/GeoMaterialParams.cc:125: warning: Multiple materials match the volume 'PixelForwardHoldersConnector@0x7f4a8f4d5840': 277, 277, 277, 277
/home/alund/celeritas_project/celeritas/src/celeritas/geo/GeoMaterialParams.cc:125: warning: Multiple materials match the volume 'PixelForwardBladeBase@0x7f4a8f4cb7c0': 277, 277, 277, 277
/home/alund/celeritas_project/celeritas/src/celeritas/geo/GeoMaterialParams.cc:125: warning: Multiple materials match the volume 'PixelForwardModule@0x7f4a9a7ccb10': 277, 277, 277, 277
/home/alund/celeritas_project/celeritas/src/celeritas/geo/GeoMaterialParams.cc:125: warning: Multiple materials match the volume 'PixelForwardHoldersConnector@0x7f4a8f4d5a80': 277, 277, 277, 277
...
/home/alund/celeritas_project/celeritas/src/celeritas/geo/GeoMaterialParams.cc:125: warning: Multiple materials match the volume 'PixelForwardModule@0x7f4a9a7cfcf0': 277, 277, 277, 277

and all three geometries had fewer volumes without known material IDs.

src/celeritas/geo/GeoMaterialParams.cc Outdated Show resolved Hide resolved
@sethrj
Copy link
Member Author

sethrj commented Sep 29, 2023

I think all the warnings @amandalund showed should be gone. It'll only warn if materials are different.

@sethrj sethrj merged commit d60ffc5 into celeritas-project:develop Sep 29, 2023
@sethrj sethrj deleted the geomat-labels branch September 29, 2023 22:15
@sethrj sethrj added orange Work on ORANGE geometry engine and removed internal labels Nov 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working orange Work on ORANGE geometry engine
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants