diff --git a/examples/ClientTests/scripts/FCC_Hcal.C b/examples/ClientTests/scripts/FCC_Hcal.C index 1999c095f965e023c840b41787ea5cb4c0d4692e..1035c342db808b50157cc88924de7f92f46e6b65 100644 --- a/examples/ClientTests/scripts/FCC_Hcal.C +++ b/examples/ClientTests/scripts/FCC_Hcal.C @@ -37,6 +37,7 @@ int setupG4_CINT() { EventAction evt_root(kernel,"Geant4Output2ROOT/RootOutput"); evt_root["Control"] = true; evt_root["Output"] = (const char*)text; + evt_root["HandleMCTruth"] = false; evt_root->enableUI(); kernel.eventAction().adopt(evt_root); diff --git a/examples/ClientTests/scripts/FCC_Hcal.py b/examples/ClientTests/scripts/FCC_Hcal.py index 4be027936623c2b93eff36e477c95ae7d3719831..6e1541488c1257b6fbb4e3c5834ee4f19ece035a 100644 --- a/examples/ClientTests/scripts/FCC_Hcal.py +++ b/examples/ClientTests/scripts/FCC_Hcal.py @@ -1,5 +1,3 @@ -# -# import os, time, DDG4 from DDG4 import OutputLevel as Output from SystemOfUnits import * @@ -9,79 +7,39 @@ from SystemOfUnits import * DD4hep example setup using the python configuration - @author M.Frank - @version 1.0 + \author M.Frank + \version 1.0 """ def run(): + kernel = DDG4.Kernel() install_dir = os.environ['DD4hepINSTALL'] example_dir = install_dir+'/examples/DDG4/examples'; - kernel = DDG4.Kernel() kernel.setOutputLevel('Geant4Converter',Output.DEBUG) kernel.setOutputLevel('RootOutput',Output.INFO) kernel.setOutputLevel('ShellHandler',Output.DEBUG) kernel.setOutputLevel('Gun',Output.INFO) - kernel.UI = "UI" kernel.loadGeometry("file:"+install_dir+"/examples/ClientTests/compact/FCC_HcalBarrel.xml") kernel.loadXML("file:"+example_dir+"/DDG4_field.xml") - kernel.printProperties() - lcdd = kernel.lcdd() - print '+++ List of sensitive detectors:' - for i in lcdd.detectors(): - print i.second - o = DDG4.DetElement(i.second) - sd = lcdd.sensitiveDetector(o.name()) - if sd.isValid(): - print '+++ %-32s type:%s'%(o.name(), sd.type(), ) - # Configure UI - ui = DDG4.Action(kernel,"Geant4UIManager/UI") - ui.HaveVIS = True - ui.HaveUI = True - ui.SessionType = 'csh' - kernel.registerGlobalAction(ui) - - # Configure I/O - evt_root = DDG4.EventAction(kernel,'Geant4Output2ROOT/RootOutput') - evt_root.Control = True - evt_root.Output = "FCC_HCAL_"+time.strftime("%Y-%m-%d_%H-%M")+".root" - evt_root.enableUI() - kernel.eventAction().add(evt_root) + simple = DDG4.Simple(kernel) + simple.printDetectors() + simple.setupCshUI() + # Configure I/O + evt_root = simple.setupROOTOutput('RootOutput','FCC_'+time.strftime('%Y-%m-%d_%H-%M'),mc_truth=False) # Setup particle gun - gun = DDG4.GeneratorAction(kernel,"Geant4ParticleGun/Gun") - gun.energy = 100*GeV - gun.particle = 'pi-' - gun.multiplicity = 1 - gun.position = (0*mm,0*mm,0*mm) - gun.isotrop = True - gun.enableUI() - kernel.generatorAction().add(gun) - - # Setup global filters fur use in sensntive detectors - f1 = DDG4.Filter(kernel,'GeantinoRejectFilter/GeantinoRejector') - kernel.registerGlobalFilter(f1) - + simple.setupGun("Gun",particle='pi-',energy=100*GeV,multiplicity=1) # Now the calorimeters - seq = DDG4.SensitiveSequence(kernel,'Geant4SensDetActionSequence/HcalBarrel') - act = DDG4.SensitiveAction(kernel,'Geant4SimpleCalorimeterAction/HcalBarrelHandler','HcalBarrel') - seq.add(f1) # ignore geantinos - seq.add(act) - - seq = DDG4.SensitiveSequence(kernel,'Geant4SensDetActionSequence/ContainmentShell') - act = DDG4.SensitiveAction(kernel,'Geant4EscapeCounter/ShellHandler','ContainmentShell') - seq.add(act) - + seq,act = simple.setupTracker('HcalBarrel') + seq,act = simple.setupDetector('ContainmentShell','Geant4EscapeCounter') # Now build the physics list: phys = kernel.physicsList() phys.extends = 'QGSP_BERT' phys.enableUI() phys.dump() - - kernel.configure() - kernel.initialize() - kernel.run() - kernel.terminate() + # and run + simple.execute() if __name__ == "__main__": run() diff --git a/examples/ClientTests/scripts/Geant4Assemblies.py b/examples/ClientTests/scripts/Geant4Assemblies.py index a17c45182a72cc9cc296cea6884c79b5d6d9eb36..9da68f795d75a7c8d2428b2e5652cc47a91393ea 100644 --- a/examples/ClientTests/scripts/Geant4Assemblies.py +++ b/examples/ClientTests/scripts/Geant4Assemblies.py @@ -1,72 +1,38 @@ -# -# -import os, DDG4 +import os, time, DDG4 from SystemOfUnits import * # -# """ - DD4hep example setup using the python configuration - @author M.Frank - @version 1.0 + \author M.Frank + \version 1.0 """ def run(): + kernel = DDG4.Kernel() install_dir = os.environ['DD4hepINSTALL'] example_dir = install_dir+'/examples/DDG4/examples'; - kernel = DDG4.Kernel() - kernel.UI = "UI" kernel.loadGeometry("file:"+install_dir+"/examples/ClientTests/compact/Assemblies.xml") kernel.loadXML("file:"+example_dir+"/DDG4_field.xml") - - lcdd = kernel.lcdd() - print '+++ List of sensitive detectors:' - for i in lcdd.detectors(): - o = DDG4.DetElement(i.second) - sd = lcdd.sensitiveDetector(o.name()) - if sd.isValid(): - print '+++ %-32s type:%s'%(o.name(), sd.type(), ) - + # + simple = DDG4.Simple(kernel,tracker='Geant4TrackerCombineAction') + simple.printDetectors() # Configure UI - ui = DDG4.Action(kernel,"Geant4UIManager/UI") - ui.HaveVIS = True - ui.HaveUI = True - ui.SessionType = 'csh' - kernel.registerGlobalAction(ui) - + simple.setupCshUI() # Configure I/O - evt_root = DDG4.EventAction(kernel,'Geant4Output2ROOT/RootOutput') - evt_root.Control = True - evt_root.Output = "simple.root" - evt_root.enableUI() - kernel.eventAction().add(evt_root) - + simple.setupROOTOutput('RootOutput','Assemblies_'+time.strftime('%Y-%m-%d_%H-%M'),mc_truth=False) # Setup particle gun - gun = DDG4.GeneratorAction(kernel,"Geant4ParticleGun/Gun") - gun.energy = 0.5*GeV - gun.particle = 'e-' - gun.multiplicity = 1 - gun.position = (0.15*mm,0.12*mm,0.1*cm) - gun.enableUI() - kernel.generatorAction().add(gun) - + simple.setupGun("Gun",particle='e-',energy=2*GeV,position=(0.15*mm,0.12*mm,0.1*cm),multiplicity=1) # First the tracking detectors - seq = DDG4.SensitiveSequence(kernel,'Geant4SensDetActionSequence/VXD') - act = DDG4.SensitiveAction(kernel,'Geant4SimpleTrackerAction/VXDHandler','VXD') - + seq,act = simple.setupTracker('VXD') # Now build the physics list: phys = kernel.physicsList() phys.extends = 'QGSP_BERT' phys.enableUI() - phys.dump() DDG4.setPrintLevel(DDG4.OutputLevel.DEBUG) - kernel.configure() - kernel.initialize() - kernel.run() - kernel.terminate() + simple.execute() if __name__ == "__main__": run() diff --git a/examples/ClientTests/scripts/SiliconBlock.py b/examples/ClientTests/scripts/SiliconBlock.py index a89b937fe84dec1cca2e9d3d49a95110c531954e..1e6ae4d1b3c59bef9a79dedfdd4e609b23246804 100644 --- a/examples/ClientTests/scripts/SiliconBlock.py +++ b/examples/ClientTests/scripts/SiliconBlock.py @@ -15,12 +15,11 @@ from SystemOfUnits import * """ def run(): kernel = DDG4.Kernel() - lcdd = kernel.lcdd() install_dir = os.environ['DD4hepINSTALL'] example_dir = install_dir+'/examples/DDG4/examples'; kernel.loadGeometry("file:"+install_dir+"/examples/ClientTests/compact/SiliconBlock.xml") kernel.loadXML("file:"+example_dir+"/DDG4_field.xml") - DDG4.importConstants(lcdd,debug=False) + DDG4.importConstants(kernel.lcdd(),debug=False) simple = DDG4.Simple(kernel,tracker='Geant4TrackerCombineAction') simple.printDetectors() # Configure UI @@ -38,19 +37,11 @@ def run(): generator_output_level = Output.INFO # Configure I/O - ##evt_lcio = simple.setupLCIOOutput('LcioOutput','SiliconBlock_'+time.strftime('%Y-%m-%d_%H-%M')) - ##evt_lcio.OutputLevel = generator_output_level evt_root = simple.setupROOTOutput('RootOutput','SiliconBlock_'+time.strftime('%Y-%m-%d_%H-%M')) - """ - Generation of primary particles from LCIO input files: particle file reader - """ - gen = DDG4.GeneratorAction(kernel,"LCIOInputAction/LCIO1"); - gen.Input = "LCIOFileReader|/afs/cern.ch/user/n/nikiforo/public/Markus/muons.slcio" - gen.MomentumScale = 1.0 - gen.Mask = 1 - - simple.buildInputStage([gen],output_level=generator_output_level) + # Setup particle gun + gun = simple.setupGun("Gun",particle='mu-',energy=20*GeV,multiplicity=1) + gun.output_level = generator_output_level # And handle the simulation particles. part = DDG4.GeneratorAction(kernel,"Geant4ParticleHandler/ParticleHandler") @@ -77,12 +68,7 @@ def run(): phys.adopt(ph) phys.dump() - kernel.configure() - kernel.initialize() - - #DDG4.setPrintLevel(Output.DEBUG) - kernel.run() - kernel.terminate() + simple.execute() if __name__ == "__main__": run()