From ebdf889b2e6938103ec08aa8565ee249a38902a2 Mon Sep 17 00:00:00 2001 From: Marko Petric <marko.petric@cern.ch> Date: Thu, 12 Sep 2019 13:15:01 +0200 Subject: [PATCH] Replace usage of deprecated SystemOfUnits with g4units --- DDCore/python/lcdd.py | 4 ++-- DDG4/examples/CLICSidSimuLCIO.py | 2 +- DDG4/examples/CLICSidSimuMarkus.py | 4 ++-- DDG4/examples/SiDSim.py | 2 +- DDG4/examples/SiDSim_MT.py | 2 +- DDG4/examples/SiD_Markus.py | 2 +- DDG4/python/DDG4.py | 16 +++++++------- DDG4/python/g4MaterialScan.py | 4 ++-- examples/ClientTests/scripts/Assemblies.py | 2 +- examples/ClientTests/scripts/DDG4TestSetup.py | 2 +- examples/ClientTests/scripts/FCC_Hcal.py | 2 +- examples/ClientTests/scripts/LheD_tracker.py | 2 +- .../ClientTests/scripts/MultiCollections.py | 2 +- .../scripts/MultiSegmentCollections.py | 2 +- .../ClientTests/scripts/NestedDetectors.py | 2 +- examples/ClientTests/scripts/SiliconBlock.py | 2 +- examples/DDCMS/scripts/CMSTrackerSim.py | 2 +- examples/DDCodex/python/CODEX-b-alone.py | 2 +- .../DDG4_MySensDet/scripts/MyTrackerSD_sim.py | 2 +- examples/LHeD/scripts/LHeD.py | 2 +- examples/LHeD/scripts/LHeDScan.py | 4 ++-- examples/LHeD/scripts/LheSimu.py | 22 +++++++++---------- examples/OpticalSurfaces/scripts/OpNovice.py | 2 +- 23 files changed, 44 insertions(+), 44 deletions(-) diff --git a/DDCore/python/lcdd.py b/DDCore/python/lcdd.py index 84255f82a..5e4f8ba31 100644 --- a/DDCore/python/lcdd.py +++ b/DDCore/python/lcdd.py @@ -14,7 +14,7 @@ import xml.etree.ElementTree as xml from math import cos, sin, pi, tan from os import path, listdir from functools import partial -import SystemOfUnits +import g4units import math import logging from ddsix.moves import range @@ -57,7 +57,7 @@ unique_mat_id = 0x7FFEFEED current_xmlfile = None constants = {} -constants.update(SystemOfUnits.__dict__) +constants.update(g4units.__dict__) constants.update(math.__dict__) drivers = {} drivers.update(math.__dict__) diff --git a/DDG4/examples/CLICSidSimuLCIO.py b/DDG4/examples/CLICSidSimuLCIO.py index 7fe648ecc..b07587c98 100644 --- a/DDG4/examples/CLICSidSimuLCIO.py +++ b/DDG4/examples/CLICSidSimuLCIO.py @@ -11,7 +11,7 @@ import os import time import DDG4 from DDG4 import OutputLevel as Output -from SystemOfUnits import * +from g4units import * import logging logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.INFO) diff --git a/DDG4/examples/CLICSidSimuMarkus.py b/DDG4/examples/CLICSidSimuMarkus.py index 7303d7f06..247f94fda 100644 --- a/DDG4/examples/CLICSidSimuMarkus.py +++ b/DDG4/examples/CLICSidSimuMarkus.py @@ -6,7 +6,7 @@ import time import logging import DDG4 from DDG4 import OutputLevel as Output -from SystemOfUnits import * +from g4units import * # logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.INFO) logger = logging.getLogger(__name__) @@ -20,7 +20,7 @@ logger = logging.getLogger(__name__) import os, time, DDG4 from DDG4 import OutputLevel as Output -from SystemOfUnits import * +from g4units import * kernel = DDG4.Kernel() description = kernel.detectorDescription() diff --git a/DDG4/examples/SiDSim.py b/DDG4/examples/SiDSim.py index 3975d2ef4..369af4a21 100644 --- a/DDG4/examples/SiDSim.py +++ b/DDG4/examples/SiDSim.py @@ -6,7 +6,7 @@ import time import logging import DDG4 from DDG4 import OutputLevel as Output -from SystemOfUnits import * +from g4units import * # # logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.INFO) diff --git a/DDG4/examples/SiDSim_MT.py b/DDG4/examples/SiDSim_MT.py index a7d2ce86f..ce97d489f 100644 --- a/DDG4/examples/SiDSim_MT.py +++ b/DDG4/examples/SiDSim_MT.py @@ -6,7 +6,7 @@ import time import logging import DDG4 from DDG4 import OutputLevel as Output -from SystemOfUnits import * +from g4units import * # logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.INFO) logger = logging.getLogger(__name__) diff --git a/DDG4/examples/SiD_Markus.py b/DDG4/examples/SiD_Markus.py index 1f237df44..971b55950 100644 --- a/DDG4/examples/SiD_Markus.py +++ b/DDG4/examples/SiD_Markus.py @@ -6,7 +6,7 @@ import time import logging import DDG4 from DDG4 import OutputLevel as Output -from SystemOfUnits import * +from g4units import * # global geant4 logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.INFO) diff --git a/DDG4/python/DDG4.py b/DDG4/python/DDG4.py index ea5da4a54..e09e3a44f 100644 --- a/DDG4/python/DDG4.py +++ b/DDG4/python/DDG4.py @@ -624,16 +624,16 @@ class Geant4: return self.setupDetector(name, type, collections) def _private_setupField(self, field, stepper, equation, prt): - import SystemOfUnits + import g4units field.stepper = stepper field.equation = equation - field.eps_min = 5e-05 * SystemOfUnits.mm - field.eps_max = 0.001 * SystemOfUnits.mm - field.min_chord_step = 0.01 * SystemOfUnits.mm - field.delta_chord = 0.25 * SystemOfUnits.mm - field.delta_intersection = 0.001 * SystemOfUnits.mm - field.delta_one_step = 0.01 * SystemOfUnits.mm - field.largest_step = 1000 * SystemOfUnits.m + field.eps_min = 5e-05 * g4units.mm + field.eps_max = 0.001 * g4units.mm + field.min_chord_step = 0.01 * g4units.mm + field.delta_chord = 0.25 * g4units.mm + field.delta_intersection = 0.001 * g4units.mm + field.delta_one_step = 0.01 * g4units.mm + field.largest_step = 1000 * g4units.m if prt: logger.info('+++++> %s %s %s %s ', field.name, '-> stepper = ', str(field.stepper), '') logger.info('+++++> %s %s %s %s ', field.name, '-> equation = ', str(field.equation), '') diff --git a/DDG4/python/g4MaterialScan.py b/DDG4/python/g4MaterialScan.py index 34baa1c0f..27483d692 100644 --- a/DDG4/python/g4MaterialScan.py +++ b/DDG4/python/g4MaterialScan.py @@ -51,7 +51,7 @@ def materialScan(opts): gun = geant4.setupGun("Gun", Standalone=True, particle='geantino', - energy=20 * SystemOfUnits.GeV, + energy=20 * g4units.GeV, position=opts.position, direction=opts.direction, multiplicity=1, @@ -120,7 +120,7 @@ except ImportError as X: try: import DDG4 - import SystemOfUnits + import g4units except ImportError as X: logger.error('DDG4 python interface not accessible: %s', X) logger.info(parser.format_help()) diff --git a/examples/ClientTests/scripts/Assemblies.py b/examples/ClientTests/scripts/Assemblies.py index 72d60ab0c..71b377085 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 SystemOfUnits import * +from g4units import * # """ dd4hep example setup using the python configuration diff --git a/examples/ClientTests/scripts/DDG4TestSetup.py b/examples/ClientTests/scripts/DDG4TestSetup.py index 185ae6c7b..c69258c92 100644 --- a/examples/ClientTests/scripts/DDG4TestSetup.py +++ b/examples/ClientTests/scripts/DDG4TestSetup.py @@ -5,7 +5,7 @@ import time import logging import DDG4 from DDG4 import OutputLevel as Output -from SystemOfUnits import * +from g4units import * 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 57b421b23..6f962cf90 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 SystemOfUnits import * +from g4units import * # # """ diff --git a/examples/ClientTests/scripts/LheD_tracker.py b/examples/ClientTests/scripts/LheD_tracker.py index 176fcaec6..0c0c6260b 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 SystemOfUnits import * +from g4units import * import logging logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.INFO) diff --git a/examples/ClientTests/scripts/MultiCollections.py b/examples/ClientTests/scripts/MultiCollections.py index 32d5298cf..dc18a10db 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 SystemOfUnits import * +from g4units import * from ddsix.moves import range # # diff --git a/examples/ClientTests/scripts/MultiSegmentCollections.py b/examples/ClientTests/scripts/MultiSegmentCollections.py index 68edb8d20..d98b9edc0 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 SystemOfUnits import * +from g4units import * from ddsix.moves import range # # diff --git a/examples/ClientTests/scripts/NestedDetectors.py b/examples/ClientTests/scripts/NestedDetectors.py index 042484673..44d9c4983 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 SystemOfUnits import * +from g4units import * # # """ diff --git a/examples/ClientTests/scripts/SiliconBlock.py b/examples/ClientTests/scripts/SiliconBlock.py index b0e302733..b4ad34f95 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 SystemOfUnits import * +from g4units import * # # """ diff --git a/examples/DDCMS/scripts/CMSTrackerSim.py b/examples/DDCMS/scripts/CMSTrackerSim.py index e8307c40d..5c5e68497 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 SystemOfUnits import * +from g4units import * import logging from ddsix.moves import range diff --git a/examples/DDCodex/python/CODEX-b-alone.py b/examples/DDCodex/python/CODEX-b-alone.py index e6192b9cf..100cfcd05 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 SystemOfUnits import * +from g4units import * # # """ diff --git a/examples/DDG4_MySensDet/scripts/MyTrackerSD_sim.py b/examples/DDG4_MySensDet/scripts/MyTrackerSD_sim.py index 9ca80432b..7d238f724 100644 --- a/examples/DDG4_MySensDet/scripts/MyTrackerSD_sim.py +++ b/examples/DDG4_MySensDet/scripts/MyTrackerSD_sim.py @@ -7,7 +7,7 @@ import time import DDG4 import dd4hep from DDG4 import OutputLevel as Output -from SystemOfUnits import * +from g4units import * # # """ diff --git a/examples/LHeD/scripts/LHeD.py b/examples/LHeD/scripts/LHeD.py index 40f4b43fe..b0dad099f 100644 --- a/examples/LHeD/scripts/LHeD.py +++ b/examples/LHeD/scripts/LHeD.py @@ -2,7 +2,7 @@ from __future__ import absolute_import, unicode_literals import sys import logging import DDG4 -from SystemOfUnits import * +from g4units import * logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.INFO) logger = logging.getLogger(__name__) diff --git a/examples/LHeD/scripts/LHeDScan.py b/examples/LHeD/scripts/LHeDScan.py index daa854da4..12a15badb 100644 --- a/examples/LHeD/scripts/LHeDScan.py +++ b/examples/LHeD/scripts/LHeDScan.py @@ -17,7 +17,7 @@ def run(): import os import sys import DDG4 - import SystemOfUnits + import g4units kernel = DDG4.Kernel() install_dir = os.environ['DD4hepExamplesINSTALL'] @@ -29,7 +29,7 @@ def run(): gun = geant4.setupGun("Gun", Standalone=True, particle='geantino', - energy=20 * SystemOfUnits.GeV, + energy=20 * g4units.GeV, position=(0, 0, 0), multiplicity=1, isotrop=False) diff --git a/examples/LHeD/scripts/LheSimu.py b/examples/LHeD/scripts/LheSimu.py index 0ec55ea7e..f7699ad8d 100644 --- a/examples/LHeD/scripts/LheSimu.py +++ b/examples/LHeD/scripts/LheSimu.py @@ -18,7 +18,7 @@ def run(): import LHeD import DDG4 import os - import SystemOfUnits + import g4units from DDG4 import OutputLevel as Output lhed = LHeD.LHeD() @@ -41,12 +41,12 @@ def run(): field = geant4.addConfig('Geant4FieldTrackingSetupAction/MagFieldTrackingSetup') field.stepper = "HelixGeant4Runge" field.equation = "Mag_UsualEqRhs" - field.eps_min = 5e-0520 * SystemOfUnits.mm - field.eps_max = 0.001 * SystemOfUnits.mm - field.min_chord_step = 0.01 * SystemOfUnits.mm - field.delta_chord = 0.25 * SystemOfUnits.mm - field.delta_intersection = 1e-05 * SystemOfUnits.mm - field.delta_one_step = 0.001 * SystemOfUnits.mm + field.eps_min = 5e-0520 * g4units.mm + field.eps_max = 0.001 * g4units.mm + field.min_chord_step = 0.01 * g4units.mm + field.delta_chord = 0.25 * g4units.mm + field.delta_intersection = 1e-05 * g4units.mm + field.delta_one_step = 0.001 * g4units.mm logger.info('+++++> %s -> stepper = %s', field.name, field.stepper) logger.info('+++++> %s -> equation = %s', field.name, field.equation) logger.info('+++++> %s -> eps_min = %s', field.name, field.eps_min) @@ -170,8 +170,8 @@ def run(): gen = DDG4.GeneratorAction(kernel, "Geant4InteractionVertexSmear/Smear1") gen.OutputLevel = 4 # generator_output_level gen.Mask = 1 - gen.Offset = (-20 * SystemOfUnits.mm, -10 * SystemOfUnits.mm, -10 * SystemOfUnits.mm, 0 * SystemOfUnits.ns) - gen.Sigma = (12 * SystemOfUnits.mm, 8 * SystemOfUnits.mm, 8 * SystemOfUnits.mm, 0 * SystemOfUnits.ns) + gen.Offset = (-20 * g4units.mm, -10 * g4units.mm, -10 * g4units.mm, 0 * g4units.ns) + gen.Sigma = (12 * g4units.mm, 8 * g4units.mm, 8 * g4units.mm, 0 * g4units.ns) gen.enableUI() kernel.generatorAction().adopt(gen) @@ -194,7 +194,7 @@ def run(): kernel.generatorAction().adopt(part) #part.SaveProcesses = ['conv','Decay'] part.SaveProcesses = ['Decay'] - part.MinimalKineticEnergy = 10 * SystemOfUnits.MeV + part.MinimalKineticEnergy = 10 * g4units.MeV part.OutputLevel = 5 # generator_output_level part.enableUI() @@ -225,7 +225,7 @@ def run(): kernel.registerGlobalFilter(f3) f4 = DDG4.Filter(kernel, 'EnergyDepositMinimumCut') - f4.Cut = 0.5 * SystemOfUnits.MeV + f4.Cut = 0.5 * g4units.MeV f4.enableUI() kernel.registerGlobalFilter(f4) diff --git a/examples/OpticalSurfaces/scripts/OpNovice.py b/examples/OpticalSurfaces/scripts/OpNovice.py index fb75d3361..2fc2aeff3 100644 --- a/examples/OpticalSurfaces/scripts/OpNovice.py +++ b/examples/OpticalSurfaces/scripts/OpNovice.py @@ -6,7 +6,7 @@ import sys import time import DDG4 from DDG4 import OutputLevel as Output -from SystemOfUnits import * +from g4units import * # # """ -- GitLab