Skip to content
Snippets Groups Projects
Select Git revision
  • e521e8d8ba623691d4358e7e1c19cd1ced0a80f8
  • master default protected
  • 59-detailed-forward-gem-trd
  • 147-fix-dirc-overlaps-and-make-it-great-again
  • test-drich-tracker
  • 144-irt-geometry
  • deathvalley
  • drich-two-mirrors
  • zji-ScFiCal
  • deathvalley-1.5T
  • irt-init-v01
  • tmp_viz
  • test_tof_zy
  • canyonlands
  • update_becal_nlayers
  • 131-update-tof-for-canyonlands
  • zdc_prim_fix
  • rich-photos
  • backward_ecal_cleanup
  • 134-make-new-3d-views-of-ff-region-and-detectors
  • sly2j-master-patch-62318
  • deathvalley-v1.1
  • deathvalley-v1.0-1.5T
  • deathvalley-v1.0
  • canyonlands-v2.2
  • canyonlands-v2.1
  • canyonlands-v2.0
  • canyonlands-v1.2
  • canyonlands-v1.1
  • acadia-v2.1
  • canyonlands-v1.0
  • acadia-v2.0
  • acadia-v1.1
  • acadia-v1.0
  • acadia-v1.0-alpha
  • v0.2.0
  • v0.1.0
37 results

convert_to_gdml.py

Blame
  • Forked from EIC / detectors / athena
    24 commits behind the upstream repository.
    convert_to_gdml.py 1.22 KiB
    from __future__ import absolute_import, unicode_literals
    import os
    import time
    import logging
    
    import argparse
    parser = argparse.ArgumentParser(
         prog='convert_to_gdml.py',
         description='''Convert DD4Hep description to GDML''',
         epilog='''
         This program converts the compact detector file to a single GDML file.
             ''')
    parser.add_argument("-c", "--compact", help="compact detector file",default="athena.xml")
    parser.add_argument("-o", "--output", help="gdml detector file",default="athena.gdml")
    
    args = parser.parse_args()
    
    import DDG4
    from g4units import keV, GeV, mm, ns, MeV
    
    def run():
      kernel = DDG4.Kernel()
      description = kernel.detectorDescription()
      kernel.loadGeometry(str("file:" + args.compact))
    
      DDG4.importConstants(description)
    
      geant4 = DDG4.Geant4(kernel)
      ui = geant4.setupCshUI(ui=None)
      #
      # Setup the GDML writer action
      writer = DDG4.Action(kernel, 'Geant4GDMLWriteAction/Writer')
      writer.enableUI()
      kernel.registerGlobalAction(writer)
      ui.Commands = [
          '/ddg4/Writer/Output {}'.format(args.output),
          '/ddg4/Writer/OverWrite 1',
          '/ddg4/Writer/write'
          ]
      kernel.configure()
      kernel.initialize()
      kernel.run()
      kernel.terminate()
    
    
    if __name__ == "__main__":
      run()