Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-17 07:37:32

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 the HEPMC file reader
0015 
0016    @author  M.Frank
0017    @version 1.0
0018 
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 CLICSid
0029   import DDG4
0030   import os
0031   import sys
0032   from DDG4 import OutputLevel as Output
0033 
0034   sid = CLICSid.CLICSid(no_physics=False)
0035   geant4 = sid.geant4
0036   kernel = sid.kernel
0037   sid.loadGeometry()
0038   geant4.printDetectors()
0039   kernel.UI = 'UI'
0040   if len(sys.argv) >= 2 and sys.argv[1] == "batch":
0041     DDG4.setPrintLevel(DDG4.OutputLevel.WARNING)
0042     kernel.UI = ''
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   # First particle file reader
0053   gen = DDG4.GeneratorAction(kernel, "Geant4GeneratorActionInit/GenerationInit")
0054   kernel.generatorAction().adopt(gen)
0055   input_action = DDG4.GeneratorAction(kernel, "Geant4InputAction/Input")
0056   fname = os.environ['DD4hepExamplesINSTALL'] + '/examples/DDG4/data/hepmc_geant4.dat'
0057   input_action.Input = "Geant4EventReaderHepMC|" + fname
0058   input_action.MomentumScale = 1.0
0059   input_action.Mask = 1
0060   kernel.generatorAction().adopt(input_action)
0061 
0062   # Merge all existing interaction records
0063   merger = DDG4.GeneratorAction(kernel, "Geant4InteractionMerger/InteractionMerger")
0064   merger.enableUI()
0065   kernel.generatorAction().adopt(merger)
0066 
0067   logger.info("#  Finally generate Geant4 primaries")
0068   gen = DDG4.GeneratorAction(kernel, "Geant4PrimaryHandler/PrimaryHandler")
0069   gen.OutputLevel = 4  # generator_output_level
0070   gen.enableUI()
0071   kernel.generatorAction().adopt(gen)
0072 
0073   # And handle the simulation particles.
0074   part = DDG4.GeneratorAction(kernel, "Geant4ParticleHandler/ParticleHandler")
0075   kernel.generatorAction().adopt(part)
0076   part.OutputLevel = Output.INFO
0077   part.enableUI()
0078 
0079   logger.info("#  Configure Event actions")
0080   prt = DDG4.EventAction(kernel, 'Geant4ParticlePrint/ParticlePrint')
0081   prt.OutputLevel = Output.INFO
0082   prt.OutputType = 3  # Print both: table and tree
0083   kernel.eventAction().adopt(prt)
0084 
0085   user = DDG4.Action(kernel, "Geant4TCUserParticleHandler/UserParticleHandler")
0086   user.TrackingVolume_Zmax = DDG4.EcalEndcap_zmin
0087   user.TrackingVolume_Rmax = DDG4.EcalBarrel_rmin
0088   user.enableUI()
0089   part.adopt(user)
0090   #
0091   sid.setupDetectors()
0092   sid.setupPhysics('QGSP_BERT')
0093   sid.test_run(have_geo=True, num_events=1)
0094 
0095 
0096 if __name__ == "__main__":
0097   run()