File indexing completed on 2025-01-18 10:18:15
0001
0002 """
0003 DD4hep simulation with some argument parsing
0004 Based on M. Frank and F. Gaede runSim.py
0005 @author A.Sailer
0006 @version 0.1
0007
0008 Modified with standard EIC EPIC requirements.
0009 """
0010 from __future__ import absolute_import, unicode_literals
0011 import logging
0012 import sys
0013
0014 from DDSim.DD4hepSimulation import DD4hepSimulation
0015
0016
0017 if __name__ == "__main__":
0018 logging.basicConfig(format='%(name)-16s %(levelname)s %(message)s', level=logging.INFO, stream=sys.stdout)
0019 logger = logging.getLogger('DDSim')
0020
0021 SIM = DD4hepSimulation()
0022
0023
0024
0025
0026 SIM.parseOptions()
0027
0028
0029 def setupCerenkov(kernel):
0030 from DDG4 import PhysicsList
0031 seq = kernel.physicsList()
0032 cerenkov = PhysicsList(kernel, 'Geant4CerenkovPhysics/CerenkovPhys')
0033 cerenkov.MaxNumPhotonsPerStep = 10
0034 cerenkov.MaxBetaChangePerStep = 10.0
0035 cerenkov.TrackSecondariesFirst = False
0036 cerenkov.VerboseLevel = 0
0037 cerenkov.enableUI()
0038 seq.adopt(cerenkov)
0039 ph = PhysicsList(kernel, 'Geant4OpticalPhotonPhysics/OpticalGammaPhys')
0040 ph.addParticleConstructor('G4OpticalPhoton')
0041 ph.VerboseLevel = 0
0042 ph.enableUI()
0043 seq.adopt(ph)
0044 return None
0045 SIM.physics.setupUserPhysics(setupCerenkov)
0046
0047
0048 SIM.filter.tracker = 'edep0'
0049
0050
0051 SIM.filter.filters['opticalphotons'] = dict(
0052 name='ParticleSelectFilter/OpticalPhotonSelector',
0053 parameter={"particle": "opticalphoton"},
0054 )
0055
0056 SIM.filter.mapDetFilter['DRICH'] = 'opticalphotons'
0057 SIM.filter.mapDetFilter['RICHEndcapN'] = 'opticalphotons'
0058 SIM.filter.mapDetFilter['DIRC'] = 'opticalphotons'
0059
0060
0061 SIM.action.mapActions['DRICH'] = 'Geant4OpticalTrackerAction'
0062 SIM.action.mapActions['RICHEndcapN'] = 'Geant4OpticalTrackerAction'
0063 SIM.action.mapActions['DIRC'] = 'Geant4OpticalTrackerAction'
0064
0065
0066 SIM.action.stack = [
0067 {
0068 "name": "OpticalPhotonEfficiencyStackingAction",
0069 "parameter": {
0070 "LambdaMin": "180*nm",
0071 "LambdaMax": "678*nm",
0072 "LogicalVolume": "bar_vol",
0073 "Efficiency": [e/100. for e in [
0074 0, 0, 14.0, 14.8, 14.5, 14.9, 14.4, 14.2, 13.9, 14.6, 15.2, 15.7, 16.4, 16.9, 17.5,
0075 17.7, 18.1, 18.8, 19.3, 19.8, 20.6, 21.4, 22.4, 23.1, 23.6, 24.1, 24.2, 24.6, 24.8, 25.2,
0076 25.7, 26.5, 27.1, 28.2, 29.0, 29.9, 30.8, 31.1, 31.7, 31.8, 31.6, 31.5, 31.5, 31.3, 31.0,
0077 30.8, 30.8, 30.4, 30.2, 30.3, 30.2, 30.1, 30.1, 30.1, 29.8, 29.9, 29.8, 29.7, 29.7, 29.7,
0078 29.8, 29.8, 29.9, 29.9, 29.8, 29.9, 29.8, 29.9, 29.8, 29.7, 29.8, 29.7, 29.8, 29.6, 29.5,
0079 29.7, 29.7, 29.8, 30.1, 30.4, 31.0, 31.3, 31.5, 31.8, 31.8, 31.9, 32.0, 32.0, 32.0, 32.0,
0080 32.2, 32.2, 32.1, 31.8, 31.8, 31.8, 31.7, 31.6, 31.6, 31.7, 31.5, 31.5, 31.4, 31.3, 31.3,
0081 31.2, 30.8, 30.7, 30.5, 30.3, 29.9, 29.5, 29.3, 29.2, 28.6, 28.2, 27.9, 27.8, 27.3, 27.0,
0082 26.6, 26.1, 25.9, 25.5, 25.0, 24.6, 24.2, 23.8, 23.4, 23.0, 22.7, 22.4, 21.9, 21.4, 21.2,
0083 20.7, 20.3, 19.8, 19.6, 19.3, 18.9, 18.7, 18.3, 17.9, 17.8, 17.8, 16.7, 16.5, 16.4, 16.0,
0084 15.6, 15.6, 15.2, 14.9, 14.6, 14.4, 14.1, 13.8, 13.6, 13.3, 13.0, 12.8, 12.6, 12.3, 12.0,
0085 11.9, 11.7, 11.5, 11.2, 11.1, 10.9, 10.7, 10.4, 10.3, 9.9, 9.8, 9.6, 9.3, 9.1, 9.0,
0086 8.8, 8.5, 8.3, 8.3, 8.2, 7.9, 7.8, 7.7, 7.5, 7.3, 7.1, 6.9, 6.7, 6.6, 6.3,
0087 6.2, 6.0, 5.8, 5.7, 5.6, 5.4, 5.2, 5.1, 4.9, 4.8, 4.6, 4.5, 4.4, 4.2, 4.1,
0088 4.0, 3.8, 3.7, 3.5, 3.3, 3.2, 3.1, 3.0, 2.9, 2.5, 2.4, 2.4, 2.3, 2.3, 2.1,
0089 1.8, 1.6, 1.5, 1.5, 1.6, 1.8, 1.9, 1.4, 0.8, 0.9, 0.8, 0.7, 0.6, 0.3, 0.3,
0090 0.5, 0.3, 0.4, 0.3, 0.1, 0.2, 0.1, 0.2, 0.3, 0.0
0091 ]]
0092 }
0093 }
0094 ]
0095
0096 try:
0097 SIM.run()
0098 except NameError as e:
0099 if "global name" in str(e):
0100 globalToSet = str(e).split("'")[1]
0101 logger.fatal("Unknown global variable, please add\nglobal %s\nto your steeringFile" % globalToSet)