diff --git a/examples/DDCAD/compact/DD4hep_Issue_1134.xml b/examples/DDCAD/compact/DD4hep_Issue_1134.xml new file mode 100644 index 0000000000000000000000000000000000000000..fce01b072096a3725d050e8f8dfaaeb0f1523d8a --- /dev/null +++ b/examples/DDCAD/compact/DD4hep_Issue_1134.xml @@ -0,0 +1,48 @@ +<lccdd> +<!-- #========================================================================== + # AIDA Detector description implementation + #========================================================================== + # Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) + # All rights reserved. + # + # For the licensing terms see $DD4hepINSTALL/LICENSE. + # For the list of contributors see $DD4hepINSTALL/doc/CREDITS. + # + #========================================================================== + +--> + + <includes> + <gdmlFile ref="../../ClientTests/compact/CheckShape.xml"/> + </includes> + + <define> + <constant name="tracker_region_zmax" value="10*m"/> + <constant name="tracker_region_rmax" value="5*m"/> + </define> + + <detectors> + <detector id="1" name="Shape_STL" type="DD4hep_TestShape_Creator"> + <check> + <!-- If you supply materials and visualisation attributes to the shape: + 1) The material attribute in the <shape/> element will be applied + to all sub-volumes without an explicit material attribute in the + <volume/> element. + 2) dto. the material cchild in the <shape/> element. + 3) The material attribute in the <volume/> element applies + ONLY to the volume specified. This allows to specify a separate + material for each sub-volume in multi-volume CADs. + 4) The vis attribute in the <volume/> element applies + ONLY to the volume specified. The name identifies a dd4hep vis object. + --> + <shape type="CAD_MultiVolume" + ref="${DD4hepExamplesINSTALL}/examples/DDCAD/models/STL/DD4hep_Issue_1134.stl" + unit="cm" + material="Iron"> + <volume id="0" name="s1" vis="Shape3_vis" material="Gold"/> + </shape> + </check> + + </detector> + </detectors> +</lccdd> diff --git a/examples/DDCAD/models/STL/DD4hep_Issue_1134.stl b/examples/DDCAD/models/STL/DD4hep_Issue_1134.stl new file mode 100644 index 0000000000000000000000000000000000000000..c35bfa552d612533f7c3c0b1d9363e9a9444f329 Binary files /dev/null and b/examples/DDCAD/models/STL/DD4hep_Issue_1134.stl differ diff --git a/examples/DDCAD/scripts/DD4hep_Issue_1134.py b/examples/DDCAD/scripts/DD4hep_Issue_1134.py new file mode 100644 index 0000000000000000000000000000000000000000..761b9e2f49187be80360f03e717372e9f363f94a --- /dev/null +++ b/examples/DDCAD/scripts/DD4hep_Issue_1134.py @@ -0,0 +1,76 @@ +# ========================================================================== +# AIDA Detector description implementation +# -------------------------------------------------------------------------- +# Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) +# All rights reserved. +# +# For the licensing terms see $DD4hepINSTALL/LICENSE. +# For the list of contributors see $DD4hepINSTALL/doc/CREDITS. +# +# ========================================================================== +# +from __future__ import absolute_import, unicode_literals +import os +import time +import DDG4 +from DDG4 import OutputLevel as Output +from g4units import GeV, MeV, m + +""" + + dd4hep simulation example setup using the python configuration + + @author M.Frank + @version 1.0 + +""" + + +def run(): + args = DDG4.CommandLine() + kernel = DDG4.Kernel() + install_dir = os.environ['DD4hepExamplesINSTALL'] + kernel.loadGeometry(str("file:" + install_dir + "/examples/DDCAD/compact/DD4hep_Issue_1134.xml")) + + DDG4.importConstants(kernel.detectorDescription(), debug=False) + geant4 = DDG4.Geant4(kernel, tracker='Geant4TrackerCombineAction') + geant4.printDetectors() + # Configure UI + if args.macro: + ui = geant4.setupCshUI(macro=args.macro) + else: + ui = geant4.setupCshUI() + if args.batch: + ui.Commands = ['/run/beamOn ' + str(args.events), '/ddg4/UI/terminate'] + + # Configure field + geant4.setupTrackingField(prt=True) + # Configure Event actions + prt = DDG4.EventAction(kernel, 'Geant4ParticlePrint/ParticlePrint') + prt.OutputLevel = Output.DEBUG + prt.OutputType = 3 # Print both: table and tree + kernel.eventAction().adopt(prt) + + # Configure G4 geometry setup + seq, act = geant4.addDetectorConstruction("Geant4DetectorGeometryConstruction/ConstructGeo") + act.DebugVolumes = True + act.DebugShapes = True + seq, act = geant4.addDetectorConstruction("Geant4DetectorSensitivesConstruction/ConstructSD") + + # Configure I/O + geant4.setupROOTOutput('RootOutput', 'DD4hep_Issue_1134_' + time.strftime('%Y-%m-%d_%H-%M')) + + # Setup particle gun + gun = geant4.setupGun("Gun", particle='e+', energy=20 * GeV, multiplicity=1) + + # Now build the physics list: + phys = geant4.setupPhysics('QGSP_BERT') + ph = DDG4.PhysicsList(kernel, str('Geant4PhysicsList/Myphysics')) + ph.addParticleConstructor(str('G4Geantino')) + ph.enableUI() + phys.adopt(ph) + geant4.execute() + + +if __name__ == "__main__": + run()