Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 09:17:45

0001 # ==========================================================================
0002 #  AIDA Detector description implementation
0003 # --------------------------------------------------------------------------
0004 # Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
0005 # All rights reserved.
0006 #
0007 # For the licensing terms see $DD4hepINSTALL/LICENSE.
0008 # For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
0009 #
0010 # ==========================================================================
0011 #
0012 """
0013 
0014    Subtest using CLICSid showing the usage of the G4Particle gun using
0015    the Geant4GeneratorWrapper object.
0016 
0017    @author  M.Frank
0018    @version 1.0
0019 
0020 """
0021 from __future__ import absolute_import, unicode_literals
0022 import logging
0023 
0024 logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.INFO)
0025 logger = logging.getLogger(__name__)
0026 
0027 
0028 def run():
0029   import sys
0030   import CLICSid
0031   import DDG4
0032   from DDG4 import OutputLevel as Output
0033 
0034   sid = CLICSid.CLICSid()
0035   geant4 = sid.geant4
0036   kernel = sid.kernel
0037   sid.loadGeometry(str('CLICSiD_geometry.root'))
0038   geant4.printDetectors()
0039 
0040   if len(sys.argv) >= 2 and sys.argv[1] == "batch":
0041     kernel.UI = ''
0042 
0043   geant4.setupCshUI()
0044   sid.setupField(quiet=False)
0045   DDG4.importConstants(kernel.detectorDescription(), debug=False)
0046 
0047   prt = DDG4.EventAction(kernel, 'Geant4ParticlePrint/ParticlePrint')
0048   prt.OutputLevel = Output.INFO
0049   prt.OutputType = 3  # Print both: table and tree
0050   kernel.eventAction().adopt(prt)
0051 
0052   gen = DDG4.GeneratorAction(kernel, "Geant4GeneratorActionInit/GenerationInit")
0053   kernel.generatorAction().adopt(gen)
0054   logger.info("#  First particle generator: gun")
0055   gun = DDG4.GeneratorAction(kernel, "Geant4GeneratorWrapper/Gun")
0056   gun.Uses = 'G4ParticleGun'
0057   gun.Mask = 1
0058   kernel.generatorAction().adopt(gun)
0059 
0060   # Merge all existing interaction records
0061   merger = DDG4.GeneratorAction(kernel, "Geant4InteractionMerger/InteractionMerger")
0062   merger.enableUI()
0063   kernel.generatorAction().adopt(merger)
0064 
0065   # And handle the simulation particles.
0066   part = DDG4.GeneratorAction(kernel, "Geant4ParticleHandler/ParticleHandler")
0067   kernel.generatorAction().adopt(part)
0068   part.OutputLevel = Output.INFO
0069   part.enableUI()
0070   user = DDG4.Action(kernel, "Geant4TCUserParticleHandler/UserParticleHandler")
0071   user.TrackingVolume_Zmax = DDG4.EcalEndcap_zmin
0072   user.TrackingVolume_Rmax = DDG4.EcalBarrel_rmin
0073   user.enableUI()
0074   part.adopt(user)
0075 
0076   sid.setupDetectors()
0077   sid.setupPhysics('QGSP_BERT')
0078   sid.test_config()
0079   gun.generator()  # Instantiate gun to be able to set properties from G4 prompt
0080   kernel.run()
0081   kernel.terminate()
0082 
0083 
0084 if __name__ == "__main__":
0085   run()