Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-18 09:41:52

0001 #!/usr/bin/env python
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   RUNNER = DD4hepSimulation()
0022 
0023   # Parse remaining options (command line and steering file override above)
0024   # This is done before updating the settings to workaround issue reported in
0025   # https://github.com/AIDASoft/DD4hep/pull/1376
0026   RUNNER.parseOptions()
0027 
0028   # Ensure that Cerenkov and optical physics are always loaded
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   RUNNER.physics.setupUserPhysics(setupCerenkov)
0046 
0047   # Disable warnings for unstable resonances with off-shell mass
0048   if hasattr(RUNNER.physics, "ESeverity"):
0049     RUNNER.physics.ESeverity = "IgnoreTheIssue"
0050 
0051   # Allow energy depositions to 0 energy in trackers (which include optical detectors)
0052   RUNNER.filter.tracker = 'edep0'
0053 
0054   # Some detectors are only sensitive to optical photons
0055   RUNNER.filter.filters['opticalphotons'] = dict(
0056     name='ParticleSelectFilter/OpticalPhotonSelector',
0057     parameter={"particle": "opticalphoton"},
0058   )
0059   # This could probably be a substring
0060   RUNNER.filter.mapDetFilter['DRICH'] = 'opticalphotons'
0061   RUNNER.filter.mapDetFilter['RICHEndcapN'] = 'opticalphotons'
0062   RUNNER.filter.mapDetFilter['DIRC'] = 'opticalphotons'
0063 
0064   # Use the optical tracker for the DRICH
0065   RUNNER.action.mapActions['DRICH'] = 'Geant4OpticalTrackerAction'
0066   RUNNER.action.mapActions['RICHEndcapN'] = 'Geant4OpticalTrackerAction'
0067   RUNNER.action.mapActions['DIRC'] = 'Geant4OpticalTrackerAction'
0068 
0069   # Use the optical photon efficiency stacking action for hpDIRC
0070   RUNNER.action.stack = [
0071     {
0072       "name": "OpticalPhotonEfficiencyStackingAction",
0073       "parameter": {
0074         "LambdaMin": "180*nm",
0075         "LambdaMax": "678*nm",
0076         "LogicalVolume": "bar_vol",
0077         "Efficiency": [e/100. for e in [
0078           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,
0079           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,
0080           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,
0081           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,
0082           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,
0083           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,
0084           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,
0085           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,
0086           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,
0087           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,
0088           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,
0089           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,
0090           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,
0091           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,
0092           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,
0093           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,
0094           0.5,  0.3,  0.4,  0.3,  0.1,  0.2,  0.1,  0.2,  0.3,  0.0
0095         ]]
0096       }
0097     }
0098   ]
0099 
0100   try:
0101     sys.exit(RUNNER.run())
0102   except NameError as e:
0103     if "global name" in str(e):
0104       globalToSet = str(e).split("'")[1]
0105       logger.fatal("Unknown global variable, please add\nglobal %s\nto your steeringFile" % globalToSet)