Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /DD4hep/examples/ClientTests/scripts/MultiSegmentCollections.py was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

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 import os
0012 import sys
0013 import time
0014 import DDG4
0015 from DDG4 import OutputLevel as Output
0016 from g4units import GeV, MeV
0017 #
0018 #
0019 """
0020 
0021    dd4hep example setup using the python configuration
0022 
0023    \author  M.Frank
0024    \version 1.0
0025 
0026 """
0027 
0028 
0029 def run():
0030   batch = False
0031   kernel = DDG4.Kernel()
0032   install_dir = os.environ['DD4hepExamplesINSTALL']
0033   geometry = "file:" + install_dir + "/examples/ClientTests/compact/MultiSegmentCollections.xml"
0034   kernel.setOutputLevel(str('Geant4Converter'), Output.DEBUG)
0035   kernel.setOutputLevel(str('Gun'), Output.INFO)
0036   for i in range(len(sys.argv)):
0037     if sys.argv[i] == '-compact':
0038       geometry = sys.argv[i + 1]
0039     elif sys.argv[i] == '-input':
0040       geometry = sys.argv[i + 1]
0041     elif sys.argv[i] == '-batch':
0042       batch = True
0043     elif sys.argv[i] == 'batch':
0044       batch = True
0045 
0046   kernel.loadGeometry(str(geometry))
0047   geant4 = DDG4.Geant4(kernel)
0048   geant4.printDetectors()
0049   geant4.setupCshUI()
0050   if batch:
0051     kernel.UI = ''
0052 
0053   # Configure field
0054   geant4.setupTrackingField(prt=True)
0055   # Setup particle gun
0056   geant4.setupGun("Gun", particle='pi-', energy=50 * GeV, multiplicity=1)
0057 
0058   # Now the test calorimeter with multiple collections
0059   seq, act = geant4.setupCalorimeter('TestCal')
0060 
0061   # And handle the simulation particles.
0062   part = DDG4.GeneratorAction(kernel, "Geant4ParticleHandler/ParticleHandler")
0063   kernel.generatorAction().adopt(part)
0064   part.MinimalKineticEnergy = 1 * MeV
0065   part.enableUI()
0066 
0067   # Add the particle dumper to associate the MC truth
0068   evt = DDG4.EventAction(kernel, "Geant4ParticleDumpAction/ParticleDump")
0069   kernel.eventAction().adopt(evt)
0070   evt.enableUI()
0071 
0072   # Add the hit dumper BEFORE any hit truth is fixed
0073   evt = DDG4.EventAction(kernel, "Geant4HitDumpAction/RawDump")
0074   kernel.eventAction().adopt(evt)
0075   evt.enableUI()
0076 
0077   # Add the hit dumper to the event action sequence
0078   evt = DDG4.EventAction(kernel, "Geant4HitTruthHandler/HitTruth")
0079   kernel.eventAction().adopt(evt)
0080   evt.enableUI()
0081 
0082   # Add the hit dumper AFTER any hit truth is fixed. We should see the reduced track references
0083   evt = DDG4.EventAction(kernel, "Geant4HitDumpAction/HitDump")
0084   kernel.eventAction().adopt(evt)
0085   evt.enableUI()
0086 
0087   # Configure I/O
0088   evt_root = geant4.setupROOTOutput('RootOutput', 'Multi_coll_' + time.strftime('%Y-%m-%d_%H-%M'), mc_truth=True)
0089   evt_root.HandleMCTruth = False
0090 
0091   # Now build the physics list:
0092   phys = kernel.physicsList()
0093   phys.extends = 'QGSP_BERT'
0094   phys.enableUI()
0095   phys.dump()
0096   # and run
0097   geant4.execute()
0098 
0099 
0100 if __name__ == "__main__":
0101   run()