Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-06-06 07:52:23

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 import logging
0022 
0023 logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.INFO)
0024 logger = logging.getLogger(__name__)
0025 
0026 
0027 def run():
0028   import sys
0029   import CLICSid
0030   import DDG4
0031   from DDG4 import OutputLevel as Output
0032 
0033   sid = CLICSid.CLICSid()
0034   geant4 = sid.geant4
0035   kernel = sid.kernel
0036   sid.loadGeometry(str('CLICSiD_geometry.root'))
0037   geant4.printDetectors()
0038 
0039   if len(sys.argv) >= 2 and sys.argv[1] == "batch":
0040     kernel.UI = ''
0041 
0042   geant4.setupCshUI()
0043   sid.setupField(quiet=False)
0044   DDG4.importConstants(kernel.detectorDescription(), debug=False)
0045 
0046   prt = DDG4.EventAction(kernel, 'Geant4ParticlePrint/ParticlePrint')
0047   prt.OutputLevel = Output.INFO
0048   prt.OutputType = 3  # Print both: table and tree
0049   kernel.eventAction().adopt(prt)
0050 
0051   gen = DDG4.GeneratorAction(kernel, "Geant4GeneratorActionInit/GenerationInit")
0052   kernel.generatorAction().adopt(gen)
0053   logger.info("#  First particle generator: gun")
0054   gun = DDG4.GeneratorAction(kernel, "Geant4GeneratorWrapper/Gun")
0055   gun.Uses = 'G4ParticleGun'
0056   gun.Mask = 1
0057   kernel.generatorAction().adopt(gun)
0058 
0059   # Merge all existing interaction records
0060   merger = DDG4.GeneratorAction(kernel, "Geant4InteractionMerger/InteractionMerger")
0061   merger.enableUI()
0062   kernel.generatorAction().adopt(merger)
0063 
0064   # And handle the simulation particles.
0065   part = DDG4.GeneratorAction(kernel, "Geant4ParticleHandler/ParticleHandler")
0066   kernel.generatorAction().adopt(part)
0067   part.OutputLevel = Output.INFO
0068   part.enableUI()
0069   user = DDG4.Action(kernel, "Geant4TCUserParticleHandler/UserParticleHandler")
0070   user.TrackingVolume_Zmax = DDG4.EcalEndcap_zmin
0071   user.TrackingVolume_Rmax = DDG4.EcalBarrel_rmin
0072   user.enableUI()
0073   part.adopt(user)
0074 
0075   sid.setupDetectors()
0076   sid.setupPhysics('QGSP_BERT')
0077   sid.test_config()
0078   gun.generator()  # Instantiate gun to be able to set properties from G4 prompt
0079   kernel.run()
0080   kernel.terminate()
0081 
0082 
0083 if __name__ == "__main__":
0084   run()