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

Geant4 sensitive assignment action depending on regex rather than brute force Geant4VolumeManager #1288

Merged
merged 10 commits into from
Jul 5, 2024

Conversation

MarkusFrankATcernch
Copy link
Contributor

BEGINRELEASENOTES

  • As reported in this issue Memory Consumption of Sensitive Detectors #1285 under certain circumstances the memory usage of DDG4 goes through the roof. This was traced back to the creation of excessive maps in the Geant4VolumeManager, if the number of sensitive pathes is very high like e.g. for straw detectors.
  • To solve the problem, geometry constructors may not declare any sensitive volumes. Hence the Geant4VolumeManager will not be populated. To still make Geant4 functioning, the sensitive volumes may be declared a posterior after conversion using regular expressions as implemented in the class Geant4RegexSensitivesConstruction. This class is only an example how such functionality may be achieved: other solutions are possible as well. This functionality can be switched at the level of each subdetector participating in the experiment setup.
  • To illustrate, an example detector BoxOfStraws was constructed with a flag in the xml description:
    <detector id="1" name="BoxOfStrawsDet" type="DD4hep_BoxOfStraws" readout="BoxOfStrawsHits" vis="VisibleGreen" region="StrawRegion" limits="BoxOfStrawsLimitSet">
      <box      x="1*m"    y="1*m" z="1000*mm"  limits="BoxOfStrawsLimitSet" vis="VisibleRed"/>
      <straw rmax="0.5*mm" y="1*m" thickness="0.1*mm" vis="VisibleBlue">
        <material name="Iron"/>
      </straw>
      <gas vis="VisibleGreen">
        <material name="Argon"/>
        <non_sensitive/>
      </gas>
      <position x="0*m"   y="0*m"   z="0*m"/>
      <rotation x="0"     y="0"     z="0"/>
    </detector>

Change <non_sensitive/> to <sensitive/> and the different behavor of memory allocation when starting Geant4 can be observed.
The corresponding Geant4 python script can be found here:

<DD4hep>/examples/ClientTests/scripts/BoxOfStraws.py

The memory consumption differs then as follows (depending on the thickness of the straws, which determine the number of sensitive pathes):

With explicit sensitive volumes:   
before Geant4VolumeManager:    Virtual: 903.3m   resident: 690.5m
after Geant4VolumeManager:     Virtual: 1848.2m  resident: 1.6g   


With Sensitives matching regex and not sensitive volumes declared:
before Geant4VolumeManager:    Virtual: 903.3m   Resident: 690.6m 
after Geant4VolumeManager:     Virtual: 903.3m   Resident: 690.6m 
Simulating:                    Virtual: 903.5m   Resident: 692.6m 

Hence this is a possibility to significantly reduce memory consumption for highly granular subdetectors.
ENDRELEASENOTES

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.

1 participant