Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-07-04 07:50:54

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 DDG4
0012 #
0013 """
0014 
0015    dd4hep example setup using the python configuration
0016 
0017    \author  M.Frank
0018    \version 1.0
0019 
0020 """
0021 
0022 
0023 def run():
0024   from g4units import GeV
0025   from MiniTelSetup import Setup
0026   args = DDG4.CommandLine()
0027   m = Setup(geometry="/examples/ClientTests/compact/MiniTelGenerate.xml")
0028   kernel = m.kernel
0029   if args.batch:
0030     run = '/run/beamOn ' + str(args.events)
0031     DDG4.setPrintLevel(DDG4.OutputLevel.WARNING)
0032     cmds = []
0033     if not args.runs:
0034       args.runs = 1
0035     for _i in range(int(args.runs)):
0036       cmds.append(run)
0037     cmds.append('/ddg4/UI/terminate')
0038     m.ui.Commands = cmds
0039   m.configure()
0040   if args.output and str(args.output).lower().find('edm4hep') >= 0:
0041     wr = m.defineEdm4hepOutput(args.output)
0042   else:
0043     wr = m.defineOutput(output='MiniTel')
0044   wr.FilesByRun = True
0045 
0046   gen = DDG4.GeneratorAction(kernel, "Geant4GeneratorActionInit/GenerationInit")
0047   kernel.generatorAction().adopt(gen)
0048 
0049   gun = DDG4.GeneratorAction(kernel, "Geant4IsotropeGenerator/IsotropPi+1")
0050   gun.Mask = 1 << 0
0051   gun.Particle = 'pi+'
0052   gun.Energy = 100 * GeV
0053   gun.Multiplicity = 1
0054   gun.Distribution = 'cos(theta)'
0055   kernel.generatorAction().adopt(gun)
0056 
0057   gun = DDG4.GeneratorAction(kernel, "Geant4IsotropeGenerator/IsotropPi+2")
0058   gun.Mask = 1 << 1
0059   gun.Particle = 'pi+'
0060   gun.Energy = 100 * GeV
0061   gun.Multiplicity = 1
0062   gun.Distribution = 'cos(theta)'
0063   kernel.generatorAction().adopt(gun)
0064 
0065   gun = DDG4.GeneratorAction(kernel, "Geant4IsotropeGenerator/IsotropPi+3")
0066   gun.Mask = 1 << 2
0067   gun.Particle = 'pi+'
0068   gun.Energy = 100 * GeV
0069   gun.Multiplicity = 1
0070   gun.Distribution = 'cos(theta)'
0071   kernel.generatorAction().adopt(gun)
0072 
0073   gun = DDG4.GeneratorAction(kernel, "Geant4IsotropeGenerator/IsotropPi-")
0074   gun.Mask = 1 << 3
0075   gun.Particle = 'pi-'
0076   gun.Energy = 100 * GeV
0077   gun.Multiplicity = 1
0078   gun.Distribution = 'cos(theta)'
0079   kernel.generatorAction().adopt(gun)
0080 
0081   gun = DDG4.GeneratorAction(kernel, "Geant4IsotropeGenerator/IsotropE+1")
0082   gun.Mask = 1 << 4
0083   gun.Particle = 'e+'
0084   gun.Energy = 50 * GeV
0085   gun.Multiplicity = 1
0086   gun.Distribution = 'cos(theta)'
0087   kernel.generatorAction().adopt(gun)
0088 
0089   gun = DDG4.GeneratorAction(kernel, "Geant4IsotropeGenerator/IsotropE+2")
0090   gun.Mask = 1 << 5
0091   gun.Particle = 'e+'
0092   gun.Energy = 100 * GeV
0093   gun.Multiplicity = 1
0094   gun.Distribution = 'cos(theta)'
0095   kernel.generatorAction().adopt(gun)
0096 
0097   gun = DDG4.GeneratorAction(kernel, "Geant4IsotropeGenerator/IsotropE+3")
0098   gun.Mask = 1 << 6
0099   gun.Particle = 'e+'
0100   gun.Energy = 50 * GeV
0101   gun.Multiplicity = 1
0102   gun.Distribution = 'cos(theta)'
0103   kernel.generatorAction().adopt(gun)
0104 
0105   gun = DDG4.GeneratorAction(kernel, "Geant4IsotropeGenerator/IsotropE+4")
0106   gun.Mask = 1 << 7
0107   gun.Particle = 'e+'
0108   gun.Energy = 100 * GeV
0109   gun.Multiplicity = 1
0110   gun.Distribution = 'cos(theta)'
0111   kernel.generatorAction().adopt(gun)
0112 
0113   gun = DDG4.GeneratorAction(kernel, "Geant4IsotropeGenerator/IsotropE+5")
0114   gun.Mask = 1 << 8
0115   gun.Particle = 'e+'
0116   gun.Energy = 100 * GeV
0117   gun.Multiplicity = 1
0118   gun.Distribution = 'cos(theta)'
0119   kernel.generatorAction().adopt(gun)
0120 
0121   gun = None
0122 
0123   gen = DDG4.GeneratorAction(kernel, "Geant4InteractionMerger/InteractionMerger")
0124   gen.enableUI()
0125   kernel.generatorAction().adopt(gen)
0126 
0127   gen = DDG4.GeneratorAction(kernel, "Geant4PrimaryHandler/PrimaryHandler")
0128   gen.enableUI()
0129   kernel.generatorAction().adopt(gen)
0130   gen = None
0131 
0132   m.setupGenerator()
0133   m.setupPhysics()
0134   m.run()
0135 
0136 
0137 if __name__ == "__main__":
0138   run()