diff --git a/examples/AlignDet/drivers/BoxSegment.py b/examples/AlignDet/drivers/BoxSegment.py index e63e7324f2a904aef149681f01ed3570fcce6db4..d99da92bc0d5b9b213d69f50d5fe66c3f08742c0 100644 --- a/examples/AlignDet/drivers/BoxSegment.py +++ b/examples/AlignDet/drivers/BoxSegment.py @@ -7,11 +7,11 @@ def detector_BoxSegment(description, det): pos = det.find('position') rot = det.find('rotation') mother = description.worldVolume() - de = DetElement(description, det.name, det.type, det.id) - sha = Box(description, det.name + '_envelope', box.x, box.y, box.z) - vol = Volume(description, det.name + '_envelope_volume', sha, description.material(mat.name)) - phv = mother.placeVolume(vol, Position(pos.x, pos.y, pos.z), - Rotation(rot.x, rot.y, rot.z)) + de = DetElement(description, det.name, det.type, det.id) # noqa: F821 + sha = Box(description, det.name + '_envelope', box.x, box.y, box.z) # noqa: F821 + vol = Volume(description, det.name + '_envelope_volume', sha, description.material(mat.name)) # noqa: F821 + phv = mother.placeVolume(vol, Position(pos.x, pos.y, pos.z), # noqa: F821 + Rotation(rot.x, rot.y, rot.z)) # noqa: F821 vol.setVisAttributes(description, det.vis) phv.addPhysVolID('id', det.id) de.addPlacement(phv) diff --git a/examples/AlignDet/drivers/Shelf.py b/examples/AlignDet/drivers/Shelf.py index 50955d7a4d60d64b36cc7c085f14e1bb94c37a76..2ee52f6f2cd732226b3b3d3751d6c5da8c9ec3b3 100644 --- a/examples/AlignDet/drivers/Shelf.py +++ b/examples/AlignDet/drivers/Shelf.py @@ -6,40 +6,45 @@ def detector_Shelf(description, det): plane = det.find('planes') mat = det.find('material') - #pos = det.find('position') - #rot = det.find('rotation') + # pos = det.find('position') + # rot = det.find('rotation') book = det.find('books') # ---Construct the ensamble plane+books volume------------------------------------------------------------- - e_vol = Volume(description, 'ensemble', Box(description, 'box', plane.x, - plane.y + book.y, plane.z), description.material('Air')) + e_vol = Volume(description, 'ensemble', # noqa: F821 + Box(description, 'box', plane.x, plane.y + book.y, plane.z), # noqa: F821 + description.material('Air')) e_vol.setVisAttributes(description, 'InvisibleWithDaughters') # ---Construct the plane and place it---------------------------------------------------------------------- - p_vol = Volume(description, 'plane', Box(description, 'plane', plane.x, - plane.y, plane.z), description.material(mat.name)) + p_vol = Volume(description, 'plane', # noqa: F821 + Box(description, 'plane', plane.x, plane.y, plane.z), # noqa: F821 + description.material(mat.name)) p_vol.setVisAttributes(description, plane.vis) - e_vol.placeVolume(p_vol, Position(0, -book.y, 0)) + e_vol.placeVolume(p_vol, Position(0, -book.y, 0)) # noqa: F821 # ---Construct a book and place it number of times--------------------------------------------------------- - b_vol = Volume(description, 'book', Box(description, 'book', book.x, book.y, book.z), description.material('Carbon')) + b_vol = Volume(description, 'book', # noqa: F821 + Box(description, 'book', book.x, book.y, book.z), # noqa: F821 + description.material('Carbon')) b_vol.setVisAttributes(description, book.vis) x, y, z = plane.x - book.x, plane.y, -plane.z + book.z for n in range(book.number): - e_vol.placeVolume(b_vol, Position(x, y, z)) + e_vol.placeVolume(b_vol, Position(x, y, z)) # noqa: F821 z += 2 * book.z + book.getF('dz') # --Construct the overal envelope and Detector element----------------------------------------------------- g_x, g_y, g_z = plane.x, plane.number * plane.getF('dy'), plane.z - g_vol = Volume(description, det.name, Box(description, 'box', g_x, g_y, g_z), description.material('Air')) + g_vol = Volume(description, det.name, # noqa: F821 + Box(description, 'box', g_x, g_y, g_z), description.material('Air')) # noqa: F821 g_vol.setVisAttributes(description, 'InvisibleWithDaughters') - de = DetElement(description, det.name, det.type, det.id) - phv = description.worldVolume().placeVolume(g_vol, Position(g_x, g_y, g_z)) + de = DetElement(description, det.name, det.type, det.id) # noqa: F821 + phv = description.worldVolume().placeVolume(g_vol, Position(g_x, g_y, g_z)) # noqa: F821 phv.addPhysVolID('id', det.id) de.addPlacement(phv) x, y, z = 0, book.y + plane.y - 2 * plane.getF('dy'), 0 for n in range(plane.number): - g_vol.placeVolume(e_vol, Position(x, y, z)) + g_vol.placeVolume(e_vol, Position(x, y, z)) # noqa: F821 y += plane.getF('dy') # ---Return detector element--------------------------------------------------------------------------------- return de diff --git a/examples/CLICSiD/scripts/CLICRandom.py b/examples/CLICSiD/scripts/CLICRandom.py index 362fe94dcd7a0d31d47e867a8de82581c0cea219..54565d54b97e18d515f9028705c2a7ffa9df02c8 100644 --- a/examples/CLICSiD/scripts/CLICRandom.py +++ b/examples/CLICSiD/scripts/CLICRandom.py @@ -6,7 +6,6 @@ """ from __future__ import absolute_import, unicode_literals -from ROOT import TRandom from ROOT import gRandom import logging diff --git a/examples/CLICSiD/scripts/CLICSiDScan.py b/examples/CLICSiD/scripts/CLICSiDScan.py index 47d8a9fecd3b5bd26beb41e1461398a7250c9910..f80adfbc53de80cd34f4a39c98df8d2afac1b96c 100644 --- a/examples/CLICSiD/scripts/CLICSiDScan.py +++ b/examples/CLICSiD/scripts/CLICSiDScan.py @@ -14,8 +14,6 @@ logger = logging.getLogger(__name__) def run(): - import os - import sys import DDG4 import CLICSid import g4units @@ -23,7 +21,6 @@ def run(): sid = CLICSid.CLICSid() sid.loadGeometry() DDG4.Core.setPrintFormat(str("%-32s %6s %s")) - geant4 = sid.geant4 # Configure UI sid.geant4.setupCshUI(ui=None) gun = sid.geant4.setupGun("Gun", @@ -37,7 +34,7 @@ def run(): sid.kernel.steppingAction().adopt(scan) # Now build the physics list: - phys = sid.setupPhysics('QGSP_BERT') + sid.setupPhysics('QGSP_BERT') sid.test_config() sid.kernel.NumEvents = 1 diff --git a/examples/CLICSiD/scripts/CLICSid.py b/examples/CLICSiD/scripts/CLICSid.py index 425c13e648e2a6f601dab156cce854c8d456efeb..f71e1798c83dbd5065f60f60d9811daca3d25e3e 100644 --- a/examples/CLICSiD/scripts/CLICSid.py +++ b/examples/CLICSiD/scripts/CLICSid.py @@ -2,7 +2,6 @@ from __future__ import absolute_import, unicode_literals import sys import logging import DDG4 -from g4units import * logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.INFO) logger = logging.getLogger(__name__) diff --git a/examples/CLICSiD/scripts/CLIC_GDML.py b/examples/CLICSiD/scripts/CLIC_GDML.py index c0861e828e65b62b454ced9ee73b5d4a9557ab76..fcd7327c0bb9916bba103ca7a324defba8a6aff7 100644 --- a/examples/CLICSiD/scripts/CLIC_GDML.py +++ b/examples/CLICSiD/scripts/CLIC_GDML.py @@ -7,13 +7,12 @@ """ from __future__ import absolute_import, unicode_literals -from g4units import * +from g4units import GeV def run(): import CLICSid import DDG4 - from DDG4 import OutputLevel as Output sid = CLICSid.CLICSid() sid.loadGeometry() @@ -28,7 +27,7 @@ def run(): kernel.registerGlobalAction(writer) sid.setupPhysics('QGSP_BERT') # - gen = sid.geant4.setupGun('Gun', 'pi-', 10 * GeV, Standalone=True) + sid.geant4.setupGun('Gun', 'pi-', 10 * GeV, Standalone=True) # Now initialize. At the Geant4 command prompt we can write the geometry: # Idle> /ddg4/Writer/write # or by configuring the UI using ui.Commands diff --git a/examples/CLICSiD/scripts/testDDPython.py b/examples/CLICSiD/scripts/testDDPython.py index cce38dd478fe17cdff2099eee9b0f2c8bdafe56d..f38fcd6372a206ed2544fac6cff55ab85bb78e9e 100644 --- a/examples/CLICSiD/scripts/testDDPython.py +++ b/examples/CLICSiD/scripts/testDDPython.py @@ -67,7 +67,7 @@ logger.info('+++++ Test: object method call with non callable') try: ret = py.instance().call(1, None) logger.info('ret: %s', str(ret)) -except: +except Exception: traceback.print_exc() logger.info('\n') @@ -75,7 +75,7 @@ logger.info('+++++ Test: object method call with exception in python callback') try: ret = py.instance().call(obj.fcn_except, (1, [1, 2, 3, 4, 5, 6],)) logger.info('ret: %s', str(ret)) -except: +except Exception: traceback.print_exc() logger.info('\n') logger.info('+++++ All Done....\n\n') diff --git a/examples/ClientTests/scripts/Assemblies.py b/examples/ClientTests/scripts/Assemblies.py index 71b3770852462c7cac2fb34950f9de5837a47f66..df7ddbc640be568c21b25d29079f2a2780668d1d 100644 --- a/examples/ClientTests/scripts/Assemblies.py +++ b/examples/ClientTests/scripts/Assemblies.py @@ -3,7 +3,7 @@ import os import sys import time import DDG4 -from g4units import * +from g4units import GeV, mm, cm # """ dd4hep example setup using the python configuration @@ -27,7 +27,7 @@ def run(): kernel.UI = '' # Configure field - field = geant4.setupTrackingField(prt=True) + geant4.setupTrackingField(prt=True) # Configure I/O geant4.setupROOTOutput('RootOutput', 'Assemblies_' + time.strftime('%Y-%m-%d_%H-%M'), mc_truth=False) # Setup particle gun diff --git a/examples/ClientTests/scripts/DDG4TestSetup.py b/examples/ClientTests/scripts/DDG4TestSetup.py index c69258c92fbbc9af2c950ae7468561ad59920f5c..ad2bc531daed14832ef9660bfa4dec907ca8fec5 100644 --- a/examples/ClientTests/scripts/DDG4TestSetup.py +++ b/examples/ClientTests/scripts/DDG4TestSetup.py @@ -1,11 +1,9 @@ from __future__ import absolute_import, unicode_literals -import os import sys -import time import logging import DDG4 from DDG4 import OutputLevel as Output -from g4units import * +from g4units import GeV, MeV logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.INFO) logger = logging.getLogger(__name__) diff --git a/examples/ClientTests/scripts/FCC_Hcal.py b/examples/ClientTests/scripts/FCC_Hcal.py index 6f962cf906bf11211a5738d37bdc252a5cace731..16a6f2f769c6afbc8688c9cc228d925aa0ab7e33 100644 --- a/examples/ClientTests/scripts/FCC_Hcal.py +++ b/examples/ClientTests/scripts/FCC_Hcal.py @@ -3,7 +3,7 @@ import os import time import DDG4 from DDG4 import OutputLevel as Output -from g4units import * +from g4units import GeV # # """ @@ -19,7 +19,6 @@ from g4units import * def run(): kernel = DDG4.Kernel() install_dir = os.environ['DD4hepINSTALL'] - example_dir = install_dir + '/examples/DDG4/examples' kernel.setOutputLevel(str('Geant4Converter'), Output.DEBUG) kernel.setOutputLevel(str('RootOutput'), Output.INFO) kernel.setOutputLevel(str('ShellHandler'), Output.DEBUG) @@ -31,9 +30,9 @@ def run(): geant4.setupCshUI() # Configure field - field = geant4.setupTrackingField(prt=True) + geant4.setupTrackingField(prt=True) # Configure I/O - evt_root = geant4.setupROOTOutput('RootOutput', 'FCC_' + time.strftime('%Y-%m-%d_%H-%M'), mc_truth=False) + geant4.setupROOTOutput('RootOutput', 'FCC_' + time.strftime('%Y-%m-%d_%H-%M'), mc_truth=False) # Setup particle gun geant4.setupGun("Gun", particle='pi-', energy=100 * GeV, multiplicity=1) # Now the calorimeters diff --git a/examples/ClientTests/scripts/LheD_tracker.py b/examples/ClientTests/scripts/LheD_tracker.py index 0c0c6260bba20a0cbd0b4f9e6e276470b6a6ea19..6415e1d88e4539d8f2e6aa67a031fd5bb3edc335 100644 --- a/examples/ClientTests/scripts/LheD_tracker.py +++ b/examples/ClientTests/scripts/LheD_tracker.py @@ -6,7 +6,7 @@ import sys import time import DDG4 from DDG4 import OutputLevel as Output -from g4units import * +from g4units import GeV, mm, cm import logging logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.INFO) @@ -43,7 +43,7 @@ def run(): kernel.UI = '' # Configure field - field = geant4.setupTrackingField(prt=True) + geant4.setupTrackingField(prt=True) # Configure Event actions prt = DDG4.EventAction(kernel, 'Geant4ParticlePrint/ParticlePrint') prt.OutputLevel = Output.WARNING # Output.WARNING @@ -51,13 +51,13 @@ def run(): kernel.eventAction().adopt(prt) # Configure I/O - evt_root = geant4.setupROOTOutput('RootOutput', 'LHeD_tracker_' + time.strftime('%Y-%m-%d_%H-%M')) + geant4.setupROOTOutput('RootOutput', 'LHeD_tracker_' + time.strftime('%Y-%m-%d_%H-%M')) gen = geant4.setupGun("Gun", particle='geantino', energy=20 * GeV, position=(0 * mm, 0 * mm, 0 * cm), multiplicity=3) gen.isotrop = False gen.direction = (1, 0, 0) gen.OutputLevel = Output.WARNING - #seq,act = geant4.setupTracker('SiVertexBarrel') + # seq,act = geant4.setupTracker('SiVertexBarrel') # Now build the physics list: phys = geant4.setupPhysics('QGSP_BERT') diff --git a/examples/ClientTests/scripts/MiniTel.py b/examples/ClientTests/scripts/MiniTel.py index 6a5b2fdec93e87fc7516e72a4084a2678986f036..5b216c478c2ab00f3626fa484da7bbd994dd0a8a 100644 --- a/examples/ClientTests/scripts/MiniTel.py +++ b/examples/ClientTests/scripts/MiniTel.py @@ -1,5 +1,4 @@ from __future__ import absolute_import, unicode_literals -import os import sys import DDG4 # diff --git a/examples/ClientTests/scripts/MiniTelEnergyDeposits.py b/examples/ClientTests/scripts/MiniTelEnergyDeposits.py index 27b77d1eba3da6d751a30fb74d7c9e2cdcac3223..c338bc3cc6d4245ec36dde779fa5e273d5d80646 100644 --- a/examples/ClientTests/scripts/MiniTelEnergyDeposits.py +++ b/examples/ClientTests/scripts/MiniTelEnergyDeposits.py @@ -24,7 +24,7 @@ def run(): DDG4.setPrintLevel(Output.WARNING) m.configure() - gun = m.setupGun() + m.setupGun() part = m.setupGenerator() part.OutputLevel = Output.DEBUG # This is the actual test: diff --git a/examples/ClientTests/scripts/MiniTelSetup.py b/examples/ClientTests/scripts/MiniTelSetup.py index 74ddd51d59a8e2386b0926b532cc7977fb43b754..afaae0a12e4a90b39c3683885a37f82d7b015f17 100644 --- a/examples/ClientTests/scripts/MiniTelSetup.py +++ b/examples/ClientTests/scripts/MiniTelSetup.py @@ -32,7 +32,7 @@ class Setup(DDG4TestSetup.Setup): seq, act = self.geant4.setupTracker('MyLHCBdetector4') if output_level: act.OutputLevel = output_level - #act.OutputLevel = 4 + # act.OutputLevel = 4 seq, act = self.geant4.setupTracker('MyLHCBdetector5') if output_level: act.OutputLevel = output_level diff --git a/examples/ClientTests/scripts/MultiCollections.py b/examples/ClientTests/scripts/MultiCollections.py index dc18a10dbd1f90fb962419eb99ce69b3afdcb298..74dd7bbf44477740442db48618b455e7a7d6cb65 100644 --- a/examples/ClientTests/scripts/MultiCollections.py +++ b/examples/ClientTests/scripts/MultiCollections.py @@ -4,7 +4,7 @@ import sys import time import DDG4 from DDG4 import OutputLevel as Output -from g4units import * +from g4units import GeV, MeV from ddsix.moves import range # # @@ -43,9 +43,9 @@ def run(): kernel.UI = '' # Configure field - field = geant4.setupTrackingField(prt=True) + geant4.setupTrackingField(prt=True) # Configure I/O - evt_root = geant4.setupROOTOutput('RootOutput', 'Multi_coll_' + time.strftime('%Y-%m-%d_%H-%M'), mc_truth=True) + geant4.setupROOTOutput('RootOutput', 'Multi_coll_' + time.strftime('%Y-%m-%d_%H-%M'), mc_truth=True) # Setup particle gun geant4.setupGun("Gun", particle='pi-', energy=10 * GeV, multiplicity=1) diff --git a/examples/ClientTests/scripts/MultiSegmentCollections.py b/examples/ClientTests/scripts/MultiSegmentCollections.py index d98b9edc06e2bbafbe14fcf1015685094cfe7cb8..798553d2d5001188dce85e65c1e8500ce6a7dc07 100644 --- a/examples/ClientTests/scripts/MultiSegmentCollections.py +++ b/examples/ClientTests/scripts/MultiSegmentCollections.py @@ -4,7 +4,7 @@ import sys import time import DDG4 from DDG4 import OutputLevel as Output -from g4units import * +from g4units import GeV, MeV from ddsix.moves import range # # @@ -43,7 +43,7 @@ def run(): kernel.UI = '' # Configure field - field = geant4.setupTrackingField(prt=True) + geant4.setupTrackingField(prt=True) # Setup particle gun geant4.setupGun("Gun", particle='pi-', energy=50 * GeV, multiplicity=1) diff --git a/examples/ClientTests/scripts/NestedDetectors.py b/examples/ClientTests/scripts/NestedDetectors.py index 44d9c49834d884f587231ed379255b9dde1eed4d..b329999fcc89051341eb05164c8df50e85b9dbad 100644 --- a/examples/ClientTests/scripts/NestedDetectors.py +++ b/examples/ClientTests/scripts/NestedDetectors.py @@ -4,7 +4,7 @@ import sys import time import DDG4 from DDG4 import OutputLevel as Output -from g4units import * +from g4units import GeV, MeV # # """ @@ -31,9 +31,9 @@ def run(): kernel.UI = '' # Configure field - field = geant4.setupTrackingField(prt=True) + geant4.setupTrackingField(prt=True) # Configure I/O - evt_root = geant4.setupROOTOutput('RootOutput', 'Nested_' + time.strftime('%Y-%m-%d_%H-%M'), mc_truth=True) + geant4.setupROOTOutput('RootOutput', 'Nested_' + time.strftime('%Y-%m-%d_%H-%M'), mc_truth=True) # Setup particle gun geant4.setupGun("Gun", particle='pi-', energy=100 * GeV, multiplicity=1) # Now the calorimeters diff --git a/examples/ClientTests/scripts/SiliconBlock.py b/examples/ClientTests/scripts/SiliconBlock.py index b4ad34f95e66b5a3b56ffd7f4c2f5321b2cc4a4c..bdda06fa0f5cd275abf722ff6ff99995f27c59c0 100644 --- a/examples/ClientTests/scripts/SiliconBlock.py +++ b/examples/ClientTests/scripts/SiliconBlock.py @@ -6,7 +6,7 @@ import sys import time import DDG4 from DDG4 import OutputLevel as Output -from g4units import * +from g4units import GeV, MeV, m # # """ @@ -34,7 +34,7 @@ def run(): geant4.setupCshUI() # Configure field - field = geant4.setupTrackingField(prt=True) + geant4.setupTrackingField(prt=True) # Configure Event actions prt = DDG4.EventAction(kernel, 'Geant4ParticlePrint/ParticlePrint') prt.OutputLevel = Output.DEBUG @@ -51,7 +51,7 @@ def run(): act.DebugShapes = True # Configure I/O - evt_root = geant4.setupROOTOutput('RootOutput', 'SiliconBlock_' + time.strftime('%Y-%m-%d_%H-%M')) + geant4.setupROOTOutput('RootOutput', 'SiliconBlock_' + time.strftime('%Y-%m-%d_%H-%M')) # Setup particle gun gun = geant4.setupGun("Gun", particle='mu-', energy=20 * GeV, multiplicity=1) diff --git a/examples/ClientTests/scripts/TrackingRegion.py b/examples/ClientTests/scripts/TrackingRegion.py index ae5b25e9de3446543d2416df700612018c77acfd..2bc29895ac3eaea3c3e8f2d9e5ed708943d187e5 100644 --- a/examples/ClientTests/scripts/TrackingRegion.py +++ b/examples/ClientTests/scripts/TrackingRegion.py @@ -3,7 +3,6 @@ from __future__ import absolute_import, unicode_literals import os import sys -import time import DDG4 # """ @@ -22,7 +21,7 @@ def run(): kernel.loadGeometry(str("file:" + install_dir + "/examples/ClientTests/compact/TrackingRegion.xml")) geant4 = DDG4.Geant4(kernel, tracker='Geant4TrackerCombineAction') # Configure field - ##field = geant4.setupTrackingField(prt=True) + # field = geant4.setupTrackingField(prt=True) # Configure G4 geometry setup seq, act = geant4.addDetectorConstruction("Geant4DetectorGeometryConstruction/ConstructGeo") act.DebugVolumes = True diff --git a/examples/DDCMS/scripts/CMSTrackerSim.py b/examples/DDCMS/scripts/CMSTrackerSim.py index 5c5e6849701425134a14021ec371d4f399d05be8..3fca5215e89b3acca2a24438ffe9507cb7817e3c 100644 --- a/examples/DDCMS/scripts/CMSTrackerSim.py +++ b/examples/DDCMS/scripts/CMSTrackerSim.py @@ -4,7 +4,7 @@ import sys import time import DDG4 from DDG4 import OutputLevel as Output -from g4units import * +from g4units import GeV, MeV import logging from ddsix.moves import range @@ -47,9 +47,9 @@ def run(): kernel.UI = '' # Configure field - field = geant4.setupTrackingField(prt=True) + geant4.setupTrackingField(prt=True) # Configure I/O - evt_root = geant4.setupROOTOutput('RootOutput', 'CMSTracker_' + time.strftime('%Y-%m-%d_%H-%M'), mc_truth=True) + geant4.setupROOTOutput('RootOutput', 'CMSTracker_' + time.strftime('%Y-%m-%d_%H-%M'), mc_truth=True) # Setup particle gun generators = [] generators.append(geant4.setupGun("GunPi-", particle='pi-', energy=300 * GeV, diff --git a/examples/DDCodex/python/CODEX-b-alone.py b/examples/DDCodex/python/CODEX-b-alone.py index 100cfcd05a8d7d63bfe51e855cbcd611b81d3ae4..6e358c444f4b7cac4212d0b695a936ef3df4b2e7 100755 --- a/examples/DDCodex/python/CODEX-b-alone.py +++ b/examples/DDCodex/python/CODEX-b-alone.py @@ -6,7 +6,7 @@ import sys import time import DDG4 from DDG4 import OutputLevel as Output -from g4units import * +from g4units import GeV, m # # """ @@ -34,7 +34,7 @@ def run(): geant4.setupCshUI() # Configure field - field = geant4.setupTrackingField(prt=True) + geant4.setupTrackingField(prt=True) # Configure Event actions prt = DDG4.EventAction(kernel, 'Geant4ParticlePrint/ParticlePrint') prt.OutputLevel = Output.WARNING @@ -42,7 +42,7 @@ def run(): kernel.eventAction().adopt(prt) # Configure I/O - evt_root = geant4.setupROOTOutput('RootOutput', 'CodexB_' + time.strftime('%Y-%m-%d_%H-%M')) + geant4.setupROOTOutput('RootOutput', 'CodexB_' + time.strftime('%Y-%m-%d_%H-%M')) # Setup particle gun @@ -58,17 +58,19 @@ def run(): setattr(gun, 'print', True) """ gen = DDG4.GeneratorAction(kernel,"Geant4InputAction/Input") - ##gen.Input = "Geant4EventReaderHepMC|"+ "/afs/cern.ch/work/j/jongho/Project_DD4hep/Test/DD4hep/examples/DDG4/data/hepmc_geant4.dat" - gen.Input = "Geant4EventReaderHepMC|"+ "/afs/cern.ch/work/j/jongho/Project_DD4hep/Test/DD4hep/DDG4/examples/MinBias_HepMC.txt" + # gen.Input = "Geant4EventReaderHepMC|"+ + # "/afs/cern.ch/work/j/jongho/Project_DD4hep/Test/DD4hep/examples/DDG4/data/hepmc_geant4.dat" + gen.Input = "Geant4EventReaderHepMC|"+ + "/afs/cern.ch/work/j/jongho/Project_DD4hep/Test/DD4hep/DDG4/examples/MinBias_HepMC.txt" gen.MomentumScale = 1.0 gen.Mask = 1 geant4.buildInputStage([gen],output_level=Output.DEBUG) """ seq, action = geant4.setupTracker('CODEXb') - #action.OutputLevel = Output.ERROR - #seq,action = geant4.setupTracker('Shield') - #action.OutputLevel = Output.ERROR + # action.OutputLevel = Output.ERROR + # seq,action = geant4.setupTracker('Shield') + # action.OutputLevel = Output.ERROR # And handle the simulation particles. part = DDG4.GeneratorAction(kernel, "Geant4ParticleHandler/ParticleHandler") @@ -82,7 +84,7 @@ def run(): part.adopt(user) # Now build the physics list: - ##phys = kernel.physicsList() + # phys = kernel.physicsList() phys = geant4.setupPhysics('QGSP_BERT') ph = DDG4.PhysicsList(kernel, 'Geant4PhysicsList/Myphysics') ph.addParticleConstructor('G4LeptonConstructor') diff --git a/examples/DDCodex/python/GeoExtract.py b/examples/DDCodex/python/GeoExtract.py index bf3fceeddea3498a498466d68a4e0a16931a0f85..34cea53aae34b11275e460e0fbdb885771516520 100755 --- a/examples/DDCodex/python/GeoExtract.py +++ b/examples/DDCodex/python/GeoExtract.py @@ -5,11 +5,11 @@ # gaudirun.py Brunel-Default.py <someDataFiles>.py ############################################################################### from __future__ import absolute_import, unicode_literals +import os from GaudiConf import IOHelper -from Gaudi.Configuration import * +from Gaudi.Configuration import * # noqa: F403 from Configurables import LHCbConfigurableUser, LHCbApp, CondDB, ToolSvc, EventSelector from Configurables import LoadDD4hepDet, LbDD4hepExample -import GaudiKernel.ProcessJobOptions # import DD4hep # DD4hep.setPrintLevel(DD4hep.OutputLevel.DEBUG) @@ -17,59 +17,63 @@ import GaudiKernel.ProcessJobOptions class MyTest(LHCbConfigurableUser): # Steering options - __slots__ = { - "DDDBtag": "", "CondDBtag": "", "UseDBSnapshot": False, "PartitionName": "LHCb", "DBSnapshotDirectory": "/group/online/hlt/conditions" - } + __slots__ = {"DDDBtag": "", "CondDBtag": "", "UseDBSnapshot": False, + "PartitionName": "LHCb", "DBSnapshotDirectory": "/group/online/hlt/conditions" + } - _propertyDocDct = { - 'DDDBtag': """ Tag for DDDB """, 'CondDBtag': """ Tag for CondDB """, "UseDBSnapshot": """Use a snapshot for velo position and rich pressure""", "PartitionName": """Name of the partition when running (needed to find DB: '', 'FEST', or 'LHCb'""", "DBSnapshotDirectory": """Local Directory where the snapshot is""" - } + _propertyDocDct = {'DDDBtag': """ Tag for DDDB """, 'CondDBtag': """ Tag for CondDB """, + "UseDBSnapshot": + """Use a snapshot for velo position and rich pressure""", + "PartitionName": + """Name of the partition when running (needed to find DB: '', 'FEST', or 'LHCb'""", + "DBSnapshotDirectory": """Local Directory where the snapshot is""" + } # Apply the configuration def __apply_configuration__(self): actor = LoadDD4hepDet() - actor.OutputLevel = DEBUG - #actor.SetupPlugins = ['DDCondDetElementMapping','DDDB_AssignConditions','DDDB_DetectorConditionKeysDump'] + actor.OutputLevel = DEBUG # noqa: F405 + # actor.SetupPlugins = ['DDCondDetElementMapping','DDDB_AssignConditions','DDDB_DetectorConditionKeysDump'] actor.SetupPlugins = ['DDDB_DetectorDump', 'DD4hep_InteractiveUI', 'DD4hep_Rint'] actor.DumpDetElements = 0 actor.DumpDetVolumes = 0 actor.DumpConditions = "" - #actor.DumpConditions = "DDDB_DetElementConditionDump" - #actor.DumpAlignments = "DDDB_AlignmentDump" - #actor.DumpAlignments = "DDDB_DerivedCondTest" + # actor.DumpConditions = "DDDB_DetElementConditionDump" + # actor.DumpAlignments = "DDDB_AlignmentDump" + # actor.DumpAlignments = "DDDB_DerivedCondTest" actor.ScanConditions = 0 pxml = None try: pxml = os.path.join(os.path.dirname(os.path.realpath(__file__)), "Parameters.xml") - except: + except Exception: pxml = os.path.join(os.getcwd(), "Parameters.xml") actor.Parameters = "file://" + pxml actor.VisAttrs = os.path.join(os.getcwd(), "Visattrs.xml") - #actor.Config = [os.path.join(os.getcwd(), "apps/DD4hep/examples/DDDB/data/VPOnly.xml")] + # actor.Config = [os.path.join(os.getcwd(), "apps/DD4hep/examples/DDDB/data/VPOnly.xml")] example_alg = LbDD4hepExample() - ApplicationMgr().TopAlg = [actor, example_alg] + ApplicationMgr().TopAlg = [actor, example_alg] # noqa: F405 # Just instantiate the configurable... theApp = MyTest() -ToolSvc.LogLevel = DEBUG +ToolSvc.LogLevel = DEBUG # noqa: F405 cdb = CondDB() -tag = {"DDDB": '', "LHCBCOND": 'default' # , "SIMCOND" : 'upgrade/dd4hep' - , "SIMCOND": '', "ONLINE": 'fake' +tag = {"DDDB": '', "LHCBCOND": 'default', # "SIMCOND" : 'upgrade/dd4hep', + "SIMCOND": '', "ONLINE": 'fake' } cdb.Tags = tag cdb.setProp('IgnoreHeartBeat', True) cdb.setProp('EnableRunChangeHandler', True) -#cdb.LogFile = "/tmp/cdb.log" +# cdb.LogFile = "/tmp/cdb.log" cdb.Upgrade = True theApp.setOtherProps(cdb, ['UseDBSnapshot', 'DBSnapshotDirectory', 'PartitionName']) # -- Use latest database tags for real data -#LHCbApp().DDDBtag = "" -#LHCbApp().CondDBtag = "default" +# LHCbApp().DDDBtag = "" +# LHCbApp().CondDBtag = "default" LHCbApp().EvtMax = 5 LHCbApp().DataType = "Upgrade" LHCbApp().Simulation = True @@ -77,4 +81,4 @@ EventSelector().PrintFreq = 1 IOHelper('ROOT').inputFiles([ 'PFN:Gauss/Boole.xdigi', -]) + ]) diff --git a/examples/DDDigi/scripts/TestFramework.py b/examples/DDDigi/scripts/TestFramework.py index 90a58202ded925948a8a464f5ad954b3ec62b9bc..e1ebc88d67cecbdf3662d6c7bf125570acd6bb4b 100644 --- a/examples/DDDigi/scripts/TestFramework.py +++ b/examples/DDDigi/scripts/TestFramework.py @@ -2,7 +2,6 @@ from __future__ import absolute_import, unicode_literals import os -import sys import DDDigi DDDigi.setPrintFormat(str('%-32s %5s %s')) diff --git a/examples/DDG4_MySensDet/scripts/MyTrackerSD_sim.py b/examples/DDG4_MySensDet/scripts/MyTrackerSD_sim.py index 7d238f7249b63da9f47d68c38582849cec87466a..f0d00511feb56e9ef0ba15d497cb20a67b421e5d 100644 --- a/examples/DDG4_MySensDet/scripts/MyTrackerSD_sim.py +++ b/examples/DDG4_MySensDet/scripts/MyTrackerSD_sim.py @@ -2,12 +2,10 @@ # from __future__ import absolute_import, unicode_literals import os -import sys import time import DDG4 -import dd4hep from DDG4 import OutputLevel as Output -from g4units import * +from g4units import GeV # # """ @@ -35,7 +33,7 @@ def run(): kernel.UI = '' # Configure field - field = geant4.setupTrackingField(prt=True) + geant4.setupTrackingField(prt=True) # Configure Event actions prt = DDG4.EventAction(kernel, 'Geant4ParticlePrint/ParticlePrint') prt.OutputLevel = Output.WARNING @@ -43,9 +41,9 @@ def run(): kernel.eventAction().adopt(prt) # Configure I/O - evt_root = geant4.setupROOTOutput('RootOutput', 'MySD_' + time.strftime('%Y-%m-%d_%H-%M'), mc_truth=False) + geant4.setupROOTOutput('RootOutput', 'MySD_' + time.strftime('%Y-%m-%d_%H-%M'), mc_truth=False) # Setup particle gun - gun = geant4.setupGun("Gun", particle='mu-', energy=5 * GeV, multiplicity=1, Standalone=True, position=(0, 0, 0)) + geant4.setupGun("Gun", particle='mu-', energy=5 * GeV, multiplicity=1, Standalone=True, position=(0, 0, 0)) seq, act = geant4.setupTracker('SiliconBlockUpper') act.OutputLevel = Output.INFO seq, act = geant4.setupTracker('SiliconBlockDown') diff --git a/examples/LHeD/scripts/LHeD.py b/examples/LHeD/scripts/LHeD.py index b0dad099f5350986f38a9bb06b6d5955a8a5596e..0343f885331c3d59e211a5d290264c741d88b3ee 100644 --- a/examples/LHeD/scripts/LHeD.py +++ b/examples/LHeD/scripts/LHeD.py @@ -2,7 +2,6 @@ from __future__ import absolute_import, unicode_literals import sys import logging import DDG4 -from g4units import * logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.INFO) logger = logging.getLogger(__name__) diff --git a/examples/LHeD/scripts/LHeDRandom.py b/examples/LHeD/scripts/LHeDRandom.py index 7de87bcab992b2d6ff11fe258deccc128ac15190..793b3810508448ee6d4743d7906e3128e998892e 100644 --- a/examples/LHeD/scripts/LHeDRandom.py +++ b/examples/LHeD/scripts/LHeDRandom.py @@ -6,7 +6,6 @@ """ from __future__ import absolute_import, unicode_literals -from ROOT import TRandom from ROOT import gRandom import logging from ddsix.moves import range diff --git a/examples/LHeD/scripts/LHeDScan.py b/examples/LHeD/scripts/LHeDScan.py index 12a15badb08899b4fc6f7cbe093f0340348c2cdf..4a8eb5763dd937bd5af4eca6b3854699f798bc48 100644 --- a/examples/LHeD/scripts/LHeDScan.py +++ b/examples/LHeD/scripts/LHeDScan.py @@ -15,7 +15,6 @@ logger = logging.getLogger(__name__) def run(): import os - import sys import DDG4 import g4units @@ -37,7 +36,7 @@ def run(): kernel.steppingAction().adopt(scan) # Now build the physics list: - phys = geant4.setupPhysics('QGSP_BERT') + geant4.setupPhysics('QGSP_BERT') kernel.configure() kernel.initialize() kernel.NumEvents = 1 diff --git a/examples/LHeD/scripts/LheSimu.py b/examples/LHeD/scripts/LheSimu.py index f7699ad8dcd2cd20a208b45c5fd05086b0922a28..562db5761166897d45749149ae9ee7e9c0beaf20 100644 --- a/examples/LHeD/scripts/LheSimu.py +++ b/examples/LHeD/scripts/LheSimu.py @@ -5,7 +5,7 @@ @author M.Frank @version 1.0 modified for LHeC - + """ from __future__ import absolute_import, unicode_literals import logging @@ -80,8 +80,8 @@ def run(): kernel.eventAction().adopt(prt) # Configure I/O - #evt_lcio = geant4.setupLCIOOutput('LcioOutput','Lhe_dip_sol_circ-higgs-bb') - #evt_lcio.OutputLevel = Output.ERROR + # evt_lcio = geant4.setupLCIOOutput('LcioOutput','Lhe_dip_sol_circ-higgs-bb') + # evt_lcio.OutputLevel = Output.ERROR evt_root = geant4.setupROOTOutput('RootOutput', 'Lhe_dip_sol_circ-higgs-bb') evt_root.OutputLevel = Output.INFO @@ -90,7 +90,7 @@ def run(): kernel.generatorAction().adopt(gen) """ - # First particle generator: e- non-isotropic generation using Gun: + # First particle generator: e- non-isotropic generation using Gun: gun = DDG4.GeneratorAction(kernel,"Geant4ParticleGenerator/Gun"); gun.Particle = 'e-' gun.Energy = 60 * GeV @@ -151,8 +151,9 @@ def run(): # First particle file reader gen = DDG4.GeneratorAction(kernel, "LCIOInputAction/LCIO1") - # gen.Input = "LCIOStdHepReader|/afs/.cern.ch/project/lhec/software/aidasoft/DD4hep/DD4hep/files/NC_bb_tag_2_pythia_events.hep" - #gen.Input = "LCIOStdHepReader|/opt/DD4hep/files/NC_bb_tag_2_pythia_events.hep" + # gen.Input = "LCIOStdHepReader|/afs/.cern.ch/project/lhec/" + # "software/aidasoft/DD4hep/DD4hep/files/NC_bb_tag_2_pythia_events.hep" + # gen.Input = "LCIOStdHepReader|/opt/DD4hep/files/NC_bb_tag_2_pythia_events.hep" gen.Input = "LCIOStdHepReader|/opt/DD4hep/files/lhec_for_peter/tag_2_pythia_events.hep" # gen.Input = "LCIOStdHepReader|/opt/DD4hep/files/single-top-tag_1_pythia_events.hep" @@ -192,7 +193,7 @@ def run(): # And handle the simulation particles. part = DDG4.GeneratorAction(kernel, "Geant4ParticleHandler/ParticleHandler") kernel.generatorAction().adopt(part) - #part.SaveProcesses = ['conv','Decay'] + # part.SaveProcesses = ['conv','Decay'] part.SaveProcesses = ['Decay'] part.MinimalKineticEnergy = 10 * g4units.MeV part.OutputLevel = 5 # generator_output_level diff --git a/examples/OpticalSurfaces/scripts/OpNovice.py b/examples/OpticalSurfaces/scripts/OpNovice.py index 2fc2aeff3f011bbcca7eb3c08323984573058201..e4f6ee836f833b1b5a6ef26a5196297c51ea96be 100644 --- a/examples/OpticalSurfaces/scripts/OpNovice.py +++ b/examples/OpticalSurfaces/scripts/OpNovice.py @@ -3,10 +3,9 @@ from __future__ import absolute_import, unicode_literals import os import sys -import time import DDG4 from DDG4 import OutputLevel as Output -from g4units import * +from g4units import keV # # """ @@ -34,7 +33,7 @@ def run(): geant4.setupCshUI() # Configure field - field = geant4.setupTrackingField(prt=True) + geant4.setupTrackingField(prt=True) # Configure Event actions prt = DDG4.EventAction(kernel, 'Geant4ParticlePrint/ParticlePrint') prt.OutputLevel = Output.DEBUG @@ -52,7 +51,7 @@ def run(): act.DebugSurfaces = True # Configure I/O - ###evt_root = geant4.setupROOTOutput('RootOutput','OpNovice_'+time.strftime('%Y-%m-%d_%H-%M')) + # evt_root = geant4.setupROOTOutput('RootOutput','OpNovice_'+time.strftime('%Y-%m-%d_%H-%M')) # Setup particle gun gun = geant4.setupGun("Gun", particle='gamma', energy=5 * keV, multiplicity=1) diff --git a/examples/OpticalSurfaces/scripts/OpNovice_GDML.py b/examples/OpticalSurfaces/scripts/OpNovice_GDML.py index c4a4a06a543c570f648dc4b01f4a326567dbfb01..881f851e166a2d78b377aa80df05c5f2f0300f67 100644 --- a/examples/OpticalSurfaces/scripts/OpNovice_GDML.py +++ b/examples/OpticalSurfaces/scripts/OpNovice_GDML.py @@ -8,11 +8,7 @@ """ from __future__ import absolute_import, unicode_literals import os -import sys -import time -import logging import DDG4 -from DDG4 import OutputLevel as Output def run(): @@ -20,9 +16,6 @@ def run(): install_dir = os.environ['DD4hepExamplesINSTALL'] kernel.loadGeometry("file:" + install_dir + "/examples/OpticalSurfaces/compact/OpNovice.xml") - logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.INFO) - logger = logging.getLogger(__name__) - if __name__ == "__main__": run()