diff --git a/DDG4/examples/CLICSidSimuLCIO.py b/DDG4/examples/CLICSidSimuLCIO.py index b07587c98684cef09efb7debbfcf5bf0ddfd7992..679a1852de8a6a8b9d8ff90516c0b632aea0ca1f 100644 --- a/DDG4/examples/CLICSidSimuLCIO.py +++ b/DDG4/examples/CLICSidSimuLCIO.py @@ -10,8 +10,7 @@ from __future__ import absolute_import, unicode_literals import os import time import DDG4 -from DDG4 import OutputLevel as Output -from g4units import * +from g4units import keV, GeV, MeV import logging logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.INFO) @@ -21,7 +20,6 @@ logger = logging.getLogger(__name__) def run(): kernel = DDG4.Kernel() install_dir = os.environ['DD4hepINSTALL'] - example_dir = install_dir + '/examples/DDG4/examples' kernel.loadGeometry(str("file:" + install_dir + "/examples/CLICSiD/compact/compact.xml")) simple = DDG4.Simple(kernel, tracker='LcioTestTrackerAction') @@ -64,13 +62,13 @@ def run(): mc.release() """ # Configure I/O - evt_lcio = simple.setupLCIOOutput('LcioOutput', 'CLICSiD_' + time.strftime('%Y-%m-%d_%H-%M')) + simple.setupLCIOOutput('LcioOutput', 'CLICSiD_' + time.strftime('%Y-%m-%d_%H-%M')) gen = DDG4.GeneratorAction(kernel, "Geant4TestGeneratorAction/Generate") kernel.generatorAction().add(gen) # Setup particle gun - gun = simple.setupGun('Gun', 'pi-', 100 * GeV, True) + simple.setupGun('Gun', 'pi-', 100 * GeV, True) """ rdr = DDG4.GeneratorAction(kernel,"LcioGeneratorAction/Reader") diff --git a/DDG4/examples/CLICSidSimuMarkus.py b/DDG4/examples/CLICSidSimuMarkus.py index 247f94fda3c6dae703d53f2610421c5dd303e43b..94f1aeb5753ef13daeb9de4343a142621f115177 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 g4units import * +from g4units import GeV, mm, cm # logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.INFO) logger = logging.getLogger(__name__) @@ -47,7 +47,7 @@ def run(): kernel = DDG4.Kernel() description = kernel.detectorDescription() install_dir = os.environ['DD4hepINSTALL'] - example_dir = install_dir + '/examples/DDG4/examples' + # example_dir = install_dir + '/examples/DDG4/examples' kernel.loadGeometry(str("file:" + install_dir + "/DDDetectors/compact/SiD_Markus.xml")) # kernel.loadXML("file:"+example_dir+"/DDG4_field.xml") DDG4.importConstants(description, debug=False) @@ -73,9 +73,9 @@ def run(): generator_output_level = Output.WARNING # Configure I/O - evt_lcio = geant4.setupLCIOOutput('LcioOutput', 'CLICSiD_' + time.strftime('%Y-%m-%d_%H-%M')) - ##evt_lcio.OutputLevel = generator_output_level - #evt_root = geant4.setupROOTOutput('RootOutput','CLICSiD_'+time.strftime('%Y-%m-%d_%H-%M')) + geant4.setupLCIOOutput('LcioOutput', 'CLICSiD_' + time.strftime('%Y-%m-%d_%H-%M')) + # evt_lcio.OutputLevel = generator_output_level + # evt_root = geant4.setupROOTOutput('RootOutput','CLICSiD_'+time.strftime('%Y-%m-%d_%H-%M')) prim = DDG4.GeneratorAction(kernel, "Geant4GeneratorActionInit/GenerationInit") # VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV diff --git a/DDG4/examples/SiDSim.py b/DDG4/examples/SiDSim.py index 369af4a21ba100d2784e17ef27bdb884f4a71638..6b2a24c04e7d77bb87808cdf91bdf85d26742ca7 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 g4units import * +from g4units import keV, GeV, mm, ns, MeV # # logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.INFO) @@ -61,12 +61,10 @@ def run(): logger.info(""" Configure I/O """) - #evt_lcio = geant4.setupLCIOOutput('LcioOutput','CLICSiD_'+time.strftime('%Y-%m-%d_%H-%M')) - #evt_lcio.OutputLevel = Output.ERROR + # evt_lcio = geant4.setupLCIOOutput('LcioOutput','CLICSiD_'+time.strftime('%Y-%m-%d_%H-%M')) + # evt_lcio.OutputLevel = Output.ERROR - evt_root = geant4.setupROOTOutput('RootOutput', 'CLICSiD_' + time.strftime('%Y-%m-%d_%H-%M')) - - generator_output_level = Output.INFO + geant4.setupROOTOutput('RootOutput', 'CLICSiD_' + time.strftime('%Y-%m-%d_%H-%M')) gen = DDG4.GeneratorAction(kernel, "Geant4GeneratorActionInit/GenerationInit") kernel.generatorAction().adopt(gen) @@ -121,7 +119,7 @@ def run(): logger.info("# ....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 = 100 * MeV part.OutputLevel = 5 # generator_output_level @@ -172,7 +170,7 @@ def run(): logger.info("# Now build the physics list:") phys = geant4.setupPhysics('QGSP_BERT') - ph = geant4.addPhysics(str('Geant4PhysicsList/Myphysics')) + geant4.addPhysics(str('Geant4PhysicsList/Myphysics')) # Add special particle types from specialized physics constructor part = geant4.addPhysics('Geant4ExtraParticles/ExtraParticles') diff --git a/DDG4/examples/SiDSim_MT.py b/DDG4/examples/SiDSim_MT.py index ce97d489f78a77c6bbf84bbd82b15d05d058fd27..cf87a315173df3a52d7aee983197c4afc73ce584 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 g4units import * +from g4units import keV, GeV, mm, ns, MeV # logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.INFO) logger = logging.getLogger(__name__) @@ -41,12 +41,10 @@ def setupWorker(geant4): kernel.eventAction().adopt(prt) logger.info("\n#PYTHON: Configure I/O\n") - #evt_lcio = geant4.setupLCIOOutput('LcioOutput','CLICSiD_'+time.strftime('%Y-%m-%d_%H-%M')) - #evt_lcio.OutputLevel = Output.ERROR + # evt_lcio = geant4.setupLCIOOutput('LcioOutput','CLICSiD_'+time.strftime('%Y-%m-%d_%H-%M')) + # evt_lcio.OutputLevel = Output.ERROR - evt_root = geant4.setupROOTOutput('RootOutput', 'CLICSiD_' + time.strftime('%Y-%m-%d_%H-%M')) - - generator_output_level = Output.INFO + geant4.setupROOTOutput('RootOutput', 'CLICSiD_' + time.strftime('%Y-%m-%d_%H-%M')) gen = DDG4.GeneratorAction(kernel, "Geant4GeneratorActionInit/GenerationInit") kernel.generatorAction().adopt(gen) @@ -96,7 +94,7 @@ def setupWorker(geant4): logger.info("#PYTHON: ....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 = 100 * MeV part.OutputLevel = 5 # generator_output_level diff --git a/DDG4/examples/SiD_Markus.py b/DDG4/examples/SiD_Markus.py index 971b55950f622c78b6cd14faa69f4b06c569a0a6..087b32715ba845ab1a1a8dce7b1738157a6cbd30 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 g4units import * +from g4units import keV, GeV, mm, ns, MeV # global geant4 logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.INFO) @@ -52,8 +52,8 @@ def setupWorker(): evt_lcio = geant4.setupLCIOOutput('LcioOutput', 'CLICSiD_' + time.strftime('%Y-%m-%d_%H-%M')) evt_lcio.OutputLevel = Output.DEBUG - #evt_root = geant4.setupROOTOutput('RootOutput','CLICSiD_'+time.strftime('%Y-%m-%d_%H-%M')) - #generator_output_level = Output.INFO + # evt_root = geant4.setupROOTOutput('RootOutput','CLICSiD_'+time.strftime('%Y-%m-%d_%H-%M')) + # generator_output_level = Output.INFO gen = DDG4.GeneratorAction(kernel, "Geant4GeneratorActionInit/GenerationInit") kernel.generatorAction().adopt(gen) @@ -113,7 +113,7 @@ def setupWorker(): # 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 = 100 * MeV part.OutputLevel = Output.DEBUG # generator_output_level @@ -178,7 +178,7 @@ def run(): seq, act = geant4.addDetectorConstruction("Geant4DetectorGeometryConstruction/ConstructGeo") # Configure G4 magnetic field tracking - self.setupTrackingFieldMT() + self.setupTrackingFieldMT() # noqa: F821 seq, act = geant4.addDetectorConstruction("Geant4PythonDetectorConstruction/DummyDet", geometry=dummy_geom, @@ -200,19 +200,19 @@ def run(): f1 = DDG4.Filter(kernel, 'GeantinoRejectFilter/GeantinoRejector') kernel.registerGlobalFilter(f1) - #seq,act = geant4.setupTracker('SiTrackerBarrel') - #seq,act = geant4.setupTracker('SiTrackerEndcap') - #seq,act = geant4.setupTracker('SiTrackerForward') + # seq,act = geant4.setupTracker('SiTrackerBarrel') + # seq,act = geant4.setupTracker('SiTrackerEndcap') + # seq,act = geant4.setupTracker('SiTrackerForward') # Now the calorimeters - #seq,act = geant4.setupCalorimeter('EcalBarrel') - #seq,act = geant4.setupCalorimeter('EcalEndcap') - #seq,act = geant4.setupCalorimeter('HcalBarrel') - #seq,act = geant4.setupCalorimeter('HcalEndcap') - #seq,act = geant4.setupCalorimeter('HcalPlug') - #seq,act = geant4.setupCalorimeter('MuonBarrel') - #seq,act = geant4.setupCalorimeter('MuonEndcap') - #seq,act = geant4.setupCalorimeter('LumiCal') - #seq,act = geant4.setupCalorimeter('BeamCal') + # seq,act = geant4.setupCalorimeter('EcalBarrel') + # seq,act = geant4.setupCalorimeter('EcalEndcap') + # seq,act = geant4.setupCalorimeter('HcalBarrel') + # seq,act = geant4.setupCalorimeter('HcalEndcap') + # seq,act = geant4.setupCalorimeter('HcalPlug') + # seq,act = geant4.setupCalorimeter('MuonBarrel') + # seq,act = geant4.setupCalorimeter('MuonEndcap') + # seq,act = geant4.setupCalorimeter('LumiCal') + # seq,act = geant4.setupCalorimeter('BeamCal') # Now build the physics list: seq = geant4.setupPhysics('QGSP_BERT') diff --git a/DDG4/examples/readHEPMC.py b/DDG4/examples/readHEPMC.py index 052cdee640a2c49999a4eb7fb5a7942b90661540..e43f235df75d6e6bbd866b96e67838e15900e370 100644 --- a/DDG4/examples/readHEPMC.py +++ b/DDG4/examples/readHEPMC.py @@ -17,7 +17,7 @@ def run(input_file): import DDG4 from DDG4 import OutputLevel as Output kernel = DDG4.Kernel() - description = kernel.detectorDescription() + kernel.detectorDescription() gen = DDG4.GeneratorAction(kernel, "Geant4InputAction/Input") kernel.generatorAction().adopt(gen) gen.Input = "Geant4EventReaderHepMC|" + input_file diff --git a/DDG4/python/DDG4.py b/DDG4/python/DDG4.py index e09e3a44f23c79b90f01a6e2630ee7f99ddc4757..2fafba3303b2eafef400f2f82576cf747115eced 100644 --- a/DDG4/python/DDG4.py +++ b/DDG4/python/DDG4.py @@ -9,17 +9,15 @@ # # ========================================================================== from __future__ import absolute_import, unicode_literals -import g4units as G4Units -from dd4hep_base import std, std_vector, std_list, std_map, std_pair import logging -from dd4hep_base import * +from dd4hep_base import * # noqa: F403 import ddsix as six logger = logging.getLogger(__name__) def loadDDG4(): - # import ROOT ## done in import * above + import ROOT from ROOT import gSystem # Try to load libglapi to avoid issues with TLS Static @@ -81,7 +79,6 @@ def importConstants(description, namespace=None, debug=False): """ Import the Detector constants into the DDG4 namespace """ - scope = current ns = current if namespace is not None and not hasattr(current, namespace): import imp @@ -233,7 +230,8 @@ def SensitiveSequence(kernel, nam): def _setup(obj): - def _adopt(self, action): self.__adopt(action.get()) + def _adopt(self, action): + self.__adopt(action.get()) _import_class('Sim', obj) o = getattr(current, obj) setattr(o, '__adopt', getattr(o, 'adopt')) @@ -242,7 +240,8 @@ def _setup(obj): def _setup_callback(obj): - def _adopt(self, action): self.__adopt(action.get(), action.callback()) + def _adopt(self, action): + self.__adopt(action.get(), action.callback()) _import_class('Sim', obj) o = getattr(current, obj) setattr(o, '__adopt', getattr(o, 'add')) @@ -282,7 +281,6 @@ _import_class('CLHEP', 'HepRandomEngine') def _get(self, name): - import traceback a = Interface.toAction(self) ret = Interface.getProperty(a, name) if ret.status > 0: @@ -418,7 +416,6 @@ class Geant4: \author M.Frank """ - import sys init_seq = self.master().userInitialization(True) init_action = UserInitialization(self.master(), 'Geant4PythonInitialization/PyG4Init') # @@ -539,7 +536,7 @@ class Geant4: def printDetectors(self): logger.info('+++ List of sensitive detectors:') for i in self.description.detectors(): - o = DetElement(i.second.ptr()) + o = DetElement(i.second.ptr()) # noqa: F405 sd = self.description.sensitiveDetector(str(o.name())) if sd.isValid(): typ = sd.type() @@ -548,15 +545,6 @@ class Geant4: sdtyp = self.sensitive_types[typ] logger.info('+++ %-32s type:%-12s --> Sensitive type: %s', o.name(), typ, sdtyp) - def setupSensitiveSequencer(self, name, action): - if isinstance(action, tuple): - sensitive_type = action[0] - else: - sensitive_type = action - seq = SensitiveSequence(self.kernel(), 'Geant4SensDetActionSequence/' + name) - seq.enableUI() - return seq - def setupDetector(self, name, action, collections=None): # fg: allow the action to be a tuple with parameter dictionary sensitive_type = "" @@ -610,14 +598,14 @@ class Geant4: return (seq, acts[0]) def setupCalorimeter(self, name, type=None, collections=None): - sd = self.description.sensitiveDetector(str(name)) + self.description.sensitiveDetector(str(name)) # sd.setType('calorimeter') if type is None: type = self.sensitive_types['calorimeter'] return self.setupDetector(name, type, collections) def setupTracker(self, name, type=None, collections=None): - sd = self.description.sensitiveDetector(str(name)) + self.description.sensitiveDetector(str(name)) # sd.setType('tracker') if type is None: type = self.sensitive_types['tracker'] @@ -646,12 +634,14 @@ class Geant4: logger.info('+++++> %s %s %s %s ', field.name, '-> largest_step = ', str(field.largest_step), '[mm]') return field - def setupTrackingFieldMT(self, name='MagFieldTrackingSetup', stepper='ClassicalRK4', equation='Mag_UsualEqRhs', prt=False): + def setupTrackingFieldMT(self, name='MagFieldTrackingSetup', + stepper='ClassicalRK4', equation='Mag_UsualEqRhs', prt=False): seq, fld = self.addDetectorConstruction("Geant4FieldTrackingConstruction/" + name) self._private_setupField(fld, stepper, equation, prt) return (seq, fld) - def setupTrackingField(self, name='MagFieldTrackingSetup', stepper='ClassicalRK4', equation='Mag_UsualEqRhs', prt=False): + def setupTrackingField(self, name='MagFieldTrackingSetup', + stepper='ClassicalRK4', equation='Mag_UsualEqRhs', prt=False): field = self.addConfig('Geant4FieldTrackingSetupAction/' + name) self._private_setupField(field, stepper, equation, prt) return field @@ -671,7 +661,8 @@ class Geant4: phys.adopt(opt) return opt - def setupGun(self, name, particle, energy, isotrop=True, multiplicity=1, position=(0.0, 0.0, 0.0), register=True, **args): + def setupGun(self, name, particle, energy, isotrop=True, + multiplicity=1, position=(0.0, 0.0, 0.0), register=True, **args): gun = GeneratorAction(self.kernel(), "Geant4ParticleGun/" + name, True) for i in args.items(): setattr(gun, i[0], i[1]) diff --git a/DDG4/python/DDSim/DD4hepSimulation.py b/DDG4/python/DDSim/DD4hepSimulation.py index 545fb8ebdf68d65f929a8dadcd5692046be28f13..d4dad1b973c1f99510c28ab3a1563ae4c3e2849f 100644 --- a/DDG4/python/DDSim/DD4hepSimulation.py +++ b/DDG4/python/DDSim/DD4hepSimulation.py @@ -8,7 +8,6 @@ Based on M. Frank and F. Gaede runSim.py """ from __future__ import absolute_import, unicode_literals, division __RCSID__ = "$Id$" -import datetime import sys import os from DDSim.Helper.Meta import Meta @@ -24,7 +23,6 @@ from DDSim.Helper.ParticleHandler import ParticleHandler from DDSim.Helper.Gun import Gun import argparse import ddsix as six -from g4units import * import logging from io import open @@ -174,13 +172,16 @@ class DD4hepSimulation(object): parser.add_argument("--physicsList", action="store", dest="physicsList", default=self.physicsList, help="Physics list to use in simulation") - parser.add_argument("--crossingAngleBoost", action="store", dest="crossingAngleBoost", default=self.crossingAngleBoost, + parser.add_argument("--crossingAngleBoost", action="store", dest="crossingAngleBoost", + default=self.crossingAngleBoost, type=float, help="Lorentz boost for the crossing angle, in radian!") - parser.add_argument("--vertexSigma", nargs=4, action="store", dest="vertexSigma", default=self.vertexSigma, metavar=('X', 'Y', 'Z', 'T'), + parser.add_argument("--vertexSigma", nargs=4, action="store", dest="vertexSigma", + default=self.vertexSigma, metavar=('X', 'Y', 'Z', 'T'), type=float, help="FourVector of the Sigma for the Smearing of the Vertex position: x y z t") - parser.add_argument("--vertexOffset", nargs=4, action="store", dest="vertexOffset", default=self.vertexOffset, metavar=('X', 'Y', 'Z', 'T'), + parser.add_argument("--vertexOffset", nargs=4, action="store", dest="vertexOffset", + default=self.vertexOffset, metavar=('X', 'Y', 'Z', 'T'), type=float, help="FourVector of translation for the Smearing of the Vertex position: x y z t") parser.add_argument("--macroFile", "-M", action="store", dest="macroFile", default=self.macroFile, @@ -190,19 +191,22 @@ class DD4hepSimulation(object): help="enable the DDG4 particle gun") parser.add_argument("--enableG4GPS", action="store_true", dest="enableG4GPS", default=self.enableG4GPS, - help="enable the Geant4 GeneralParticleSource. Needs a macroFile (runType run) or use it with the shell (runType shell)") + help="enable the Geant4 GeneralParticleSource. Needs a macroFile (runType run)" + "or use it with the shell (runType shell)") parser.add_argument("--enableG4Gun", action="store_true", dest="enableG4Gun", default=self.enableG4Gun, - help="enable the Geant4 particle gun. Needs a macroFile (runType run) or use it with the shell (runType shell)") + help="enable the Geant4 particle gun. Needs a macroFile (runType run)" + " or use it with the shell (runType shell)") - parser.add_argument("--dumpParameter", "--dump", action="store_true", dest="dumpParameter", default=self._dumpParameter, - help="Print all configuration Parameters and exit") + parser.add_argument("--dumpParameter", "--dump", action="store_true", dest="dumpParameter", + default=self._dumpParameter, help="Print all configuration Parameters and exit") - parser.add_argument("--enableDetailedShowerMode", action="store_true", dest="enableDetailedShowerMode", default=self.enableDetailedShowerMode, + parser.add_argument("--enableDetailedShowerMode", action="store_true", dest="enableDetailedShowerMode", + default=self.enableDetailedShowerMode, help="use detailed shower mode") - parser.add_argument("--dumpSteeringFile", action="store_true", dest="dumpSteeringFile", default=self._dumpSteeringFile, - help="print an example steering file to stdout") + parser.add_argument("--dumpSteeringFile", action="store_true", dest="dumpSteeringFile", + default=self._dumpSteeringFile, help="print an example steering file to stdout") # output, or do something smarter with fullHelp only for example ConfigHelper.addAllHelper(self, parser) @@ -238,7 +242,7 @@ class DD4hepSimulation(object): self._consistencyChecks() - #self.__treatUnknownArgs( parsed, unknown ) + # self.__treatUnknownArgs( parsed, unknown ) self.__parseAllHelper(parsed) if self._errorMessages and not (self._dumpParameter or self._dumpSteeringFile): parser.epilog = "\n".join(self._errorMessages) @@ -299,8 +303,8 @@ class DD4hepSimulation(object): # ---------------------------------------------------------------------------------- - #simple = DDG4.Geant4( kernel, tracker='Geant4TrackerAction',calo='Geant4CalorimeterAction') - #simple = DDG4.Geant4( kernel, tracker='Geant4TrackerCombineAction',calo='Geant4ScintillatorCalorimeterAction') + # simple = DDG4.Geant4( kernel, tracker='Geant4TrackerAction',calo='Geant4CalorimeterAction') + # simple = DDG4.Geant4( kernel, tracker='Geant4TrackerCombineAction',calo='Geant4ScintillatorCalorimeterAction') simple = DDG4.Geant4(kernel, tracker=self.action.tracker, calo=self.action.calo) simple.printDetectors() @@ -332,13 +336,14 @@ class DD4hepSimulation(object): kernel.runAction().add(run1) # Configure the random seed, do it before the I/O because we might change the seed! - _rndm = self.random.initialize(DDG4, kernel, self.output.random) + self.random.initialize(DDG4, kernel, self.output.random) # Configure I/O if self.outputFile.endswith(".slcio"): lcOut = simple.setupLCIOOutput('LcioOutput', self.outputFile) lcOut.RunHeader = self.meta.addParametersToRunHeader(self) - lcOut.EventParametersString, lcOut.EventParametersInt, lcOut.EventParametersFloat = self.meta.parseEventParameters() + eventPars = self.meta.parseEventParameters() + lcOut.EventParametersString, lcOut.EventParametersInt, lcOut.EventParametersFloat = eventPars lcOut.RunNumberOffset = self.meta.runNumberOffset if self.meta.runNumberOffset > 0 else 0 lcOut.EventNumberOffset = self.meta.eventNumberOffset if self.meta.eventNumberOffset > 0 else 0 elif self.outputFile.endswith(".root"): @@ -409,7 +414,7 @@ class DD4hepSimulation(object): # 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 = self.part.saveProcesses part.MinimalKineticEnergy = self.part.minimalKineticEnergy part.KeepAllParticles = self.part.keepAllParticles diff --git a/DDG4/python/DDSim/Helper/Action.py b/DDG4/python/DDSim/Helper/Action.py index afa52ad3d303836b54a7fc33740d036a806a8a8e..a9def61568c69c24c772570d241c240450447e8b 100644 --- a/DDG4/python/DDSim/Helper/Action.py +++ b/DDG4/python/DDSim/Helper/Action.py @@ -12,8 +12,8 @@ class Action(ConfigHelper): The default tracker and calorimeter actions can be set with >>> SIM = DD4hepSimulation() - >>> SIM.action.tracker = ('Geant4TrackerWeightedAction', {'HitPositionCombination': 2, 'CollectSingleDeposits': False}) - >>> SIM.action.calo = "Geant4CalorimeterAction" + >>> SIM.action.tracker=('Geant4TrackerWeightedAction', {'HitPositionCombination': 2, 'CollectSingleDeposits': False}) + >>> SIM.action.calo = "Geant4CalorimeterAction" for specific subdetectors specific sensitive detectors can be set based on pattern matching diff --git a/DDG4/python/DDSim/Helper/ConfigHelper.py b/DDG4/python/DDSim/Helper/ConfigHelper.py index 179a84f46983e1dd1f24dccdd926e9769f030882..8eb4e62c8b7484e7e5309d68a1f2a3fe45695bbe 100644 --- a/DDG4/python/DDSim/Helper/ConfigHelper.py +++ b/DDG4/python/DDSim/Helper/ConfigHelper.py @@ -13,7 +13,6 @@ call for the parser object create an additional member:: """ from __future__ import absolute_import, unicode_literals -from pprint import pprint import ddsix as six diff --git a/DDG4/python/DDSim/Helper/Filter.py b/DDG4/python/DDSim/Helper/Filter.py index 7f4d00b876450fe06bf6109f74250fe2bac46a91..10ccd2a6800683a9132564b28e630c387cf69e5e 100644 --- a/DDG4/python/DDSim/Helper/Filter.py +++ b/DDG4/python/DDSim/Helper/Filter.py @@ -55,7 +55,10 @@ class Filter(ConfigHelper): @property def calo(self): - """ default filter for calorimeter sensitive detectors; this is applied if no other filter is used for a calorimeter """ + """ + default filter for calorimeter sensitive detectors; + this is applied if no other filter is used for a calorimeter + """ return self._calo @calo.setter diff --git a/DDG4/python/DDSim/Helper/Meta.py b/DDG4/python/DDSim/Helper/Meta.py index ace1bd20ceb97c6851b543c036a60a5307baa590..019ca0de684613abd7e46036c5cd5d826803e922 100644 --- a/DDG4/python/DDSim/Helper/Meta.py +++ b/DDG4/python/DDSim/Helper/Meta.py @@ -17,7 +17,8 @@ class Meta(ConfigHelper): def __init__(self): super(Meta, self).__init__() self._eventParameters_EXTRA = {'help': "Event parameters to write in every event. " - "Use C/F/I ids to specify parameter type. E.g parameterName/F=0.42 to set a float parameter", + "Use C/F/I ids to specify parameter type. " + "E.g parameterName/F=0.42 to set a float parameter", 'nargs': '+'} self.eventParameters = [] self._runNumberOffset_EXTRA = {'help': "The run number offset to write in slcio output file. " @@ -28,7 +29,10 @@ class Meta(ConfigHelper): self.eventNumberOffset = 0 def parseEventParameters(self): - """Parse the event parameters and return 3 event parameter dictionnaries, respectively for string, int and float parameters""" + """ + Parse the event parameters and return 3 event parameter dictionnaries, respectively + for string, int and float parameters + """ stringParameters, intParameters, floatParameters, allParameters = {}, {}, {}, [] for p in self.eventParameters: parameterAndValue = p.split("=", 1) diff --git a/DDG4/python/checkGeometry.py b/DDG4/python/checkGeometry.py index b5458f433ead8f0385b45fa96edbe41749371896..3f414f852adf5b3749e758c800fae15e4c3a1b75 100755 --- a/DDG4/python/checkGeometry.py +++ b/DDG4/python/checkGeometry.py @@ -62,7 +62,6 @@ if opts.compact is None: sys.exit(1) try: - import ROOT from ROOT import gROOT gROOT.SetBatch(1) except ImportError as X: diff --git a/DDG4/python/checkOverlaps.py b/DDG4/python/checkOverlaps.py index 1704afd628b342bb8848cb5c695433c9defb34ac..717ccfaa060bae03d842bebd584bd6818c095ba0 100755 --- a/DDG4/python/checkOverlaps.py +++ b/DDG4/python/checkOverlaps.py @@ -46,7 +46,6 @@ if opts.compact is None: sys.exit(1) try: - import ROOT from ROOT import gROOT gROOT.SetBatch(1) except ImportError as X: diff --git a/DDG4/python/g4MaterialScan.py b/DDG4/python/g4MaterialScan.py index 27483d692c91dca85cf2ffbd1fa0efee03afc6a5..8df59a90715697fb0ddd1c1309840b3a0734a70d 100644 --- a/DDG4/python/g4MaterialScan.py +++ b/DDG4/python/g4MaterialScan.py @@ -30,7 +30,6 @@ def printOpts(opts): def materialScan(opts): kernel = DDG4.Kernel() - install_dir = os.environ['DD4hepINSTALL'] kernel.loadGeometry(str(opts.compact)) DDG4.Core.setPrintFormat(str("%-32s %6s %s")) geant4 = DDG4.Geant4(kernel) @@ -48,19 +47,19 @@ def materialScan(opts): logger.error('+++ %-32s type:%-12s --> Unknown Sensitive type: %s', o.name(), typ, sdtyp) sys.exit(errno.EINVAL) - gun = geant4.setupGun("Gun", - Standalone=True, - particle='geantino', - energy=20 * g4units.GeV, - position=opts.position, - direction=opts.direction, - multiplicity=1, - isotrop=False) + geant4.setupGun("Gun", + Standalone=True, + particle='geantino', + energy=20 * g4units.GeV, + position=opts.position, + direction=opts.direction, + multiplicity=1, + isotrop=False) scan = DDG4.SteppingAction(kernel, 'Geant4MaterialScanner/MaterialScan') kernel.steppingAction().adopt(scan) # Now build the physics list: - phys = geant4.setupPhysics('QGSP_BERT') + geant4.setupPhysics('QGSP_BERT') """ phys = geant4.setupPhysics('') ph = DDG4.PhysicsList(kernel,'Geant4PhysicsList/Myphysics') @@ -69,7 +68,7 @@ def materialScan(opts): ph.addParticleConstructor('G4LeptonConstructor') phys.transportation = True phys.decays = True - phys.adopt(ph) + phys.adopt(ph) """ kernel.configure() @@ -110,7 +109,6 @@ opts.direction = eval('(' + opts.direction + ')') printOpts(opts) try: - import ROOT from ROOT import gROOT gROOT.SetBatch(1) except ImportError as X: