diff --git a/DDCore/include/DD4hep/ShapeTags.h b/DDCore/include/DD4hep/ShapeTags.h index f6e877aeea5667c8963690978e81b31b6d96fab5..75c5f855032fdf51c5ed2f9383069f3052b3e83b 100644 --- a/DDCore/include/DD4hep/ShapeTags.h +++ b/DDCore/include/DD4hep/ShapeTags.h @@ -30,6 +30,7 @@ #define SPHERE_TAG "Sphere" #define TORUS_TAG "Torus" #define TRAP_TAG "Trap" +#define SCALE_TAG "Scale" #define POLYHEDRA_TAG "Polyhedra" #define EXTRUDEDPOLYGON_TAG "ExtrudedPolygon" #define EIGHTPOINTSOLID_TAG "EightPointSolid" diff --git a/DDCore/include/DD4hep/Shapes.h b/DDCore/include/DD4hep/Shapes.h index 9983299ee7b226947d724e9d55130808a6ea0bd7..ae9102ee9f3bb03cd1c2f12d39f48c2151874ac4 100644 --- a/DDCore/include/DD4hep/Shapes.h +++ b/DDCore/include/DD4hep/Shapes.h @@ -42,6 +42,7 @@ #include <TGeoSphere.h> #include <TGeoHalfSpace.h> #include <TGeoParaboloid.h> +#include <TGeoScaledShape.h> #include <TGeoCompositeShape.h> #include <TGeoShapeAssembly.h> #if ROOT_VERSION_CODE > ROOT_VERSION(6,21,0) @@ -223,6 +224,61 @@ namespace dd4hep { ShapelessSolid& operator=(const ShapelessSolid& copy) = default; }; + /// Class describing a Scale shape + /** + * For any further documentation please see the following ROOT documentation: + * \see http://root.cern.ch/root/html/TGeoScaledShape.html + * + * + * \author M.Frank + * \version 1.0 + * \ingroup DD4HEP_CORE + */ + class Scale : public Solid_type<TGeoScaledShape> { + protected: + /// Internal helper method to support object construction + void make(const std::string& name, Solid base_solid, double x_scale, double y_scale, double z_scale); + + public: + /// Default constructor + Scale() = default; + /// Move constructor + Scale(Scale&& e) = default; + /// Copy constructor + Scale(const Scale& e) = default; + /// Constructor to be used with an existing object + template <typename Q> Scale(const Q* p) : Solid_type<TGeoScaledShape>(p) { } + /// Copy Constructor to be used with an existing object handle + template <typename Q> Scale(const Handle<Q>& e) : Solid_type<TGeoScaledShape>(e) { } + + /// Constructor to create an anonymous new Scale object (retrieves name from volume) + Scale(Solid base_solid, double x_scale, double y_scale, double z_scale) + { make("", base_solid, x_scale, y_scale, z_scale); } + /// Constructor to create a named new Scale object (retrieves name from volume) + Scale(const std::string& nam, Solid base_solid, double x_scale, double y_scale, double z_scale) + { make(nam.c_str(), base_solid, x_scale, y_scale, z_scale); } + + /// Constructor to create an anonymous new Scale object (retrieves name from volume) + template <typename X, typename Y, typename Z> + Scale(Solid base_solid, const X& x_scale, const Y& y_scale, const Z& z_scale) + { make("", base_solid, _toDouble(x_scale), _toDouble(y_scale), _toDouble(z_scale)); } + /// Constructor to create a named new Scale object (retrieves name from volume) + template <typename X, typename Y, typename Z> + Scale(const std::string& nam, Solid base_solid, const X& x_scale, const Y& y_scale, const Z& z_scale) + { make(nam.c_str(), base_solid, _toDouble(x_scale), _toDouble(y_scale), _toDouble(z_scale)); } + + /// Move Assignment operator + Scale& operator=(Scale&& copy) = default; + /// Copy Assignment operator + Scale& operator=(const Scale& copy) = default; + /// Access x-scale factor + double scale_x() const; + /// Access y-scale factor + double scale_y() const; + /// Access z-scale factor + double scale_z() const; + }; + /// Class describing a box shape /** * For any further documentation please see the following ROOT documentation: diff --git a/DDCore/src/Handle.cpp b/DDCore/src/Handle.cpp index b327c009d1b11e389ecf37f2eaa4a5891dc05f4d..5b58f34ccf01b2963f43c60718866773de4d976a 100644 --- a/DDCore/src/Handle.cpp +++ b/DDCore/src/Handle.cpp @@ -370,6 +370,7 @@ DD4HEP_INSTANTIATE_HANDLE(TGeoNodeOffset); #include "TGeoTorus.h" #include "TGeoBoolNode.h" #include "TGeoVolume.h" +#include "TGeoScaledShape.h" #include "TGeoCompositeShape.h" #include "TGeoShapeAssembly.h" #include "DD4hep/detail/ShapesInterna.h" @@ -387,6 +388,7 @@ DD4HEP_INSTANTIATE_SHAPE_HANDLE(TGeoParaboloid); DD4HEP_INSTANTIATE_SHAPE_HANDLE(TGeoPcon); DD4HEP_INSTANTIATE_SHAPE_HANDLE(TGeoPgon,TGeoPcon); DD4HEP_INSTANTIATE_SHAPE_HANDLE(TGeoXtru); +DD4HEP_INSTANTIATE_SHAPE_HANDLE(TGeoScaledShape); DD4HEP_INSTANTIATE_SHAPE_HANDLE(TGeoTube); DD4HEP_INSTANTIATE_SHAPE_HANDLE(TGeoHype,TGeoTube); diff --git a/DDCore/src/ShapeUtilities.cpp b/DDCore/src/ShapeUtilities.cpp index 864cf59e2859bdcc938b5d09ada8dc11d9505f28..74551857fbf9aa65516052e74a89dd82357d680d 100644 --- a/DDCore/src/ShapeUtilities.cpp +++ b/DDCore/src/ShapeUtilities.cpp @@ -62,6 +62,7 @@ namespace dd4hep { return check_shape_type<typename SOLID::Object>(solid); } template bool isInstance<Box> (const Handle<TGeoShape>& solid); + template bool isInstance<Scale> (const Handle<TGeoShape>& solid); template bool isInstance<ShapelessSolid> (const Handle<TGeoShape>& solid); template bool isInstance<HalfSpace> (const Handle<TGeoShape>& solid); template bool isInstance<ConeSegment> (const Handle<TGeoShape>& solid); @@ -132,6 +133,7 @@ namespace dd4hep { return check_shape_type<typename SOLID::Object>(solid); } template bool isA<Box>(const Handle<TGeoShape>& solid); + template bool isA<Scale>(const Handle<TGeoShape>& solid); template bool isA<ShapelessSolid>(const Handle<TGeoShape>& solid); template bool isA<HalfSpace>(const Handle<TGeoShape>& solid); template bool isA<Cone>(const Handle<TGeoShape>& solid); @@ -397,6 +399,7 @@ namespace dd4hep { { return dimensions<typename T::Object>(get_ptr<typename T::Object>(shape.ptr())); } template vector<double> dimensions<ShapelessSolid> (const Handle<TGeoShape>& shape); template vector<double> dimensions<Box> (const Handle<TGeoShape>& shape); + template vector<double> dimensions<Scale> (const Handle<TGeoShape>& shape); template vector<double> dimensions<HalfSpace> (const Handle<TGeoShape>& shape); template vector<double> dimensions<Polycone> (const Handle<TGeoShape>& shape); template vector<double> dimensions<ConeSegment> (const Handle<TGeoShape>& shape); @@ -799,6 +802,8 @@ namespace dd4hep { { set_dimensions(shape.ptr(), params); } template <> void set_dimensions(Box shape, const std::vector<double>& params) { set_dimensions(shape.ptr(), params); } + template <> void set_dimensions(Scale shape, const std::vector<double>& params) + { set_dimensions(shape.ptr(), params); } template <> void set_dimensions(HalfSpace shape, const std::vector<double>& params) { set_dimensions(shape.ptr(), params); } template <> void set_dimensions(Polycone shape, const std::vector<double>& params) diff --git a/DDCore/src/Shapes.cpp b/DDCore/src/Shapes.cpp index 57176cf7586e365f2cbe7188fc06bed44e93fe46..14d4eb66462ede89798dc1d3898c464e8f30252b 100644 --- a/DDCore/src/Shapes.cpp +++ b/DDCore/src/Shapes.cpp @@ -116,6 +116,26 @@ ShapelessSolid::ShapelessSolid(const string& nam) { _assign(new TGeoShapeAssembly(), nam, SHAPELESS_TAG, true); } +void Scale::make(const string& nam, Solid base, double x_scale, double y_scale, double z_scale) { + auto scale = make_unique<TGeoScale>(x_scale, y_scale, z_scale); + _assign(new TGeoScaledShape(nam.c_str(), base.access(), scale.release()), "", SCALE_TAG, true); +} + +/// Access x-scale factor +double Scale::scale_x() const { + return this->access()->GetScale()->GetScale()[0]; +} + +/// Access y-scale factor +double Scale::scale_y() const { + return this->access()->GetScale()->GetScale()[1]; +} + +/// Access z-scale factor +double Scale::scale_z() const { + return this->access()->GetScale()->GetScale()[2]; +} + void Box::make(const string& nam, double x_val, double y_val, double z_val) { _assign(new TGeoBBox(nam.c_str(), x_val, y_val, z_val), "", BOX_TAG, true); } @@ -1010,6 +1030,7 @@ INSTANTIATE(TGeoHype); INSTANTIATE(TGeoTrap); INSTANTIATE(TGeoTrd1); INSTANTIATE(TGeoTrd2); +INSTANTIATE(TGeoScaledShape); INSTANTIATE(TGeoCompositeShape); #if ROOT_VERSION_CODE > ROOT_VERSION(6,21,0) diff --git a/DDCore/src/plugins/ShapePlugins.cpp b/DDCore/src/plugins/ShapePlugins.cpp index a199a269cdc3e92c67de906d5b3a8543c7c82867..b66cdedbb751cf8e3e4c37f21233ed00db0f2630 100644 --- a/DDCore/src/plugins/ShapePlugins.cpp +++ b/DDCore/src/plugins/ShapePlugins.cpp @@ -16,17 +16,28 @@ #include <DD4hep/Printout.h> #include <XML/Utilities.h> #include <DD4hep/ShapeTags.h> +#include <TGeoScaledShape.h> #include <TGeoShapeAssembly.h> #include <TSystem.h> #include <TClass.h> // C/C++ include files #include <fstream> +#include <memory> using namespace std; using namespace dd4hep; using namespace dd4hep::detail; +static Handle<TObject> create_Scaled(Detector&, xml_h e) { + xml_dim_t scale(e); + Solid shape(xml_comp_t(scale.child(_U(shape))).createShape()); + Solid solid = Scale(shape.ptr(), scale.x(1.0), scale.y(1.0), scale.z(1.0)); + if ( e.hasAttr(_U(name)) ) solid->SetName(e.attr<string>(_U(name)).c_str()); + return solid; +} +DECLARE_XML_SHAPE(Scale__shape_constructor,create_Scaled) + static Handle<TObject> create_Assembly(Detector&, xml_h e) { xml_dim_t dim(e); Solid solid = Handle<TNamed>(new TGeoShapeAssembly()); @@ -631,15 +642,21 @@ TGeoCombiTrans* createPlacement(const Rotation3D& iRot, const Position& iTrans) return new TGeoCombiTrans(t, r); } -static Ref_t create_shape(Detector& description, xml_h e, Ref_t /* sens */) { +static Ref_t create_shape(Detector& description, xml_h e, SensitiveDetector sens) { xml_det_t x_det = e; string name = x_det.nameStr(); xml_dim_t x_reflect = x_det.child(_U(reflect), false); xml_comp_t x_test = x_det.child(xml_tag_t("test"), false); DetElement det (name,x_det.id()); + Material mat = description.air(); Assembly assembly (name); PlacedVolume pv; int count = 0; + + if ( x_det.hasChild(_U(material)) ) { + mat = description.material(x_det.child(_U(material)).attr<string>(_U(name))); + printout(INFO,"TestShape","+++ Volume material is %s", mat.name()); + } for ( xml_coll_t itm(e, _U(check)); itm; ++itm, ++count ) { xml_dim_t x_check = itm; xml_comp_t shape (x_check.child(_U(shape))); @@ -659,7 +676,13 @@ static Ref_t create_shape(Detector& description, xml_h e, Ref_t /* sens */) { } else { solid = xml::createShape(description, shape_type, shape); - volume = Volume(name+_toString(count,"_vol_%d"),solid, description.air()); + volume = Volume(name+_toString(count,"_vol_%d"),solid, mat); + } + if ( x_det.hasChild(_U(sensitive)) ) { + string sens_type = x_det.child(_U(sensitive)).attr<string>(_U(type)); + volume.setSensitiveDetector(sens); + sens.setType(sens_type); + printout(INFO,"TestShape","+++ Sensitive type is %s", sens_type.c_str()); } volume.setVisAttributes(description, x_check.visStr()); solid->SetName(shape_type.c_str()); @@ -694,6 +717,7 @@ static Ref_t create_shape(Detector& description, xml_h e, Ref_t /* sens */) { if ( x_check.hasAttr(_U(id)) ) { pv.addPhysVolID("check",x_check.id()); + printout(INFO,"TestShape","+++ Volume id is %d", x_check.id()); } printout(INFO,"TestShape","Created successfull shape of type: %s", @@ -731,6 +755,8 @@ static Ref_t create_shape(Detector& description, xml_h e, Ref_t /* sens */) { instance_test = isInstance<EllipticalTube>(solid); else if ( 0 == strcasecmp(solid->GetTitle(),EXTRUDEDPOLYGON_TAG) ) instance_test = isInstance<ExtrudedPolygon>(solid); + else if ( 0 == strcasecmp(solid->GetTitle(),SCALE_TAG) ) + instance_test = isInstance<Scale>(solid); #if ROOT_VERSION_CODE > ROOT_VERSION(6,21,0) else if ( 0 == strcasecmp(solid->GetTitle(),TESSELLATEDSOLID_TAG) ) { instance_test = isInstance<TessellatedSolid>(solid); @@ -813,7 +839,7 @@ static Ref_t create_shape(Detector& description, xml_h e, Ref_t /* sens */) { if ( x_reflect ) { xml_dim_t x_pos(x_reflect.child(_U(position), false)); xml_dim_t x_rot(x_reflect.child(_U(rotation), false)); - DetElement full_detector(name+"_full",x_det.id()); + DetElement full_detector(name+"_full",100+x_det.id()); Assembly full_assembly(name+"_full"); RotationZYX refl_rot; Position refl_pos; @@ -828,7 +854,7 @@ static Ref_t create_shape(Detector& description, xml_h e, Ref_t /* sens */) { det.setPlacement(pv); /// Place reflected object - auto reflected = det.reflect(name+"_reflected",x_det.id()); + auto reflected = det.reflect(name+"_reflected",100+x_det.id()); pv = full_assembly.placeVolume(reflected.second, refl_trafo); full_detector.add(reflected.first); reflected.first.setPlacement(pv); @@ -841,6 +867,7 @@ static Ref_t create_shape(Detector& description, xml_h e, Ref_t /* sens */) { } else { pv = description.worldVolume().placeVolume(assembly); + pv.addPhysVolID("system", x_det.id()); det.setPlacement(pv); } diff --git a/DDG4/src/Geant4Converter.cpp b/DDG4/src/Geant4Converter.cpp index 32030dd31935e2fdd066b24d917636af357a179b..17e587311c415848de1df987f57a1ba5a0a9056a 100644 --- a/DDG4/src/Geant4Converter.cpp +++ b/DDG4/src/Geant4Converter.cpp @@ -66,6 +66,7 @@ #include "G4Transform3D.hh" #include "G4ThreeVector.hh" #include "G4PVPlacement.hh" +#include "G4ScaledSolid.hh" #include "G4ElectroMagneticField.hh" #include "G4FieldManager.hh" #include "G4ReflectionFactory.hh" @@ -585,12 +586,11 @@ void* Geant4Converter::handleSolid(const string& name, const TGeoShape* shape) c solid = convertShape<TGeoTessellated>(shape); #endif else if (isa == TGeoScaledShape::Class()) { - TGeoScaledShape* sh = (TGeoScaledShape*) shape; + TGeoScaledShape* sh = (TGeoScaledShape*) shape; + TGeoShape* sol = sh->GetShape(); const double* vals = sh->GetScale()->GetScale(); - Solid s_sh(sh->GetShape()); - G4VSolid* scaled = (G4VSolid*)handleSolid(s_sh.name(), s_sh.ptr()); - solid = new G4ReflectedSolid(scaled->GetName() + "_refl", - scaled, G4Scale3D(vals[0],vals[1],vals[2])); + G4VSolid* g4solid = (G4VSolid*)handleSolid(sol->GetName(), sol); + solid = new G4ScaledSolid(sh->GetName(), g4solid, {vals[0], vals[1], vals[2]}); } else if (isa == TGeoCompositeShape::Class()) { const TGeoCompositeShape* sh = (const TGeoCompositeShape*) shape; diff --git a/examples/ClientTests/CMakeLists.txt b/examples/ClientTests/CMakeLists.txt index 49cb73c6362232629d810db883bdd731bb2849d2..f17c669b83cab316088348e5d5a5d12feb8a63b1 100644 --- a/examples/ClientTests/CMakeLists.txt +++ b/examples/ClientTests/CMakeLists.txt @@ -194,7 +194,7 @@ set(ClientTests_ShapeTests) list(APPEND ClientTests_ShapeTests Box Cone ConeSegment Tube ElTube CutTube Hyperboloid Paraboloid) list(APPEND ClientTests_ShapeTests EightPointSolid Eightpoint_Reflect_Volume Eightpoint_Reflect_DetElement) list(APPEND ClientTests_ShapeTests Polycone Polyhedra PseudoTrap PseudoTrap2 Sphere Torus Trap Trd1 Trd2) -list(APPEND ClientTests_ShapeTests TruncatedTube ExtrudedPolygon) +list(APPEND ClientTests_ShapeTests TruncatedTube ExtrudedPolygon Scaled_Cone) if(${ROOT_VERSION} VERSION_GREATER 6.21.00) list(APPEND ClientTests_ShapeTests Tessellated) endif() diff --git a/examples/ClientTests/compact/CheckShape.xml b/examples/ClientTests/compact/CheckShape.xml index afeec1e11343289b75ac7565d06f4ea46b9c1e1f..b8bc9b65ca498486d03aa0a1a7baa26fb4080e26 100644 --- a/examples/ClientTests/compact/CheckShape.xml +++ b/examples/ClientTests/compact/CheckShape.xml @@ -51,4 +51,11 @@ <vis name="Shape8_vis" alpha="0.5" r="0.0" g="0.4" b="0.4" showDaughters="true" visible="true"/> <vis name="Shape_grey" alpha="0.5" r="0.0" g="0.4" b="0.4" showDaughters="true" visible="true"/> </display> + + <readouts> + <readout name="CheckHits"> + <id>system:8,check:24</id> + </readout> + </readouts> + </lccdd> diff --git a/examples/ClientTests/compact/Check_Shape_Scaled_Cone.xml b/examples/ClientTests/compact/Check_Shape_Scaled_Cone.xml new file mode 100644 index 0000000000000000000000000000000000000000..3aacbbc8d3cc7c67251fd2bf5973dd8c60bf0fb6 --- /dev/null +++ b/examples/ClientTests/compact/Check_Shape_Scaled_Cone.xml @@ -0,0 +1,41 @@ +<?xml version="1.0" encoding="UTF-8"?> +<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="CheckShape.xml"/> + </includes> + + <detectors> + <detector id="1" name="Test_Shape_Scaled_Cone" type="DD4hep_TestShape_Creator" readout="CheckHits"> + <sensitive type="tracker"/> + <material name="Silicon"/> + <check id="1" vis="Shape1_vis"> + <shape type="Scale" x="1.0" y="0.3" z="1.0"> + <shape type="Cone" rmin1="5*cm" rmax1="30*cm" rmin2="20*cm" rmax2="90*cm" z="40*cm"/> + </shape> + <position x="0" y="0*cm" z="50*cm"/> + <rotation x="-0.1" y="0" z="0"/> + </check> + <check id="2" vis="Shape2_vis"> + <shape type="Scale" x="0.6" y="0.4" z="1.0"> + <shape type="Cone" rmin1="5*cm" rmax1="30*cm" rmin2="20*cm" rmax2="90*cm" z="40*cm"/> + </shape> + <position x="0*cm" y="-50*cm" z="0*cm"/> + <rotation x="1" y="0" z="0"/> + </check> + <test type="DD4hep_Mesh_Verifier" ref="${DD4hepExamplesINSTALL}/examples/ClientTests/ref/Ref_Scaled_Cone.txt" create="CheckShape_create"/> + <testn type="DD4hep_Mesh_Verifier" ref="${DD4hepExamplesINSTALL}/examples/ClientTests/ref/Ref_Scaled_Cone.txt" create="1"/> + </detector> + </detectors> +</lccdd> diff --git a/examples/ClientTests/scripts/Check_shape.py b/examples/ClientTests/scripts/Check_shape.py index 6f6cf286e75b3c834b52c758fefe30320ce90004..069e59306e00e10f8cd771fd0f13074dfeb9156b 100644 --- a/examples/ClientTests/scripts/Check_shape.py +++ b/examples/ClientTests/scripts/Check_shape.py @@ -17,10 +17,15 @@ """ from __future__ import absolute_import, unicode_literals import logging +import math +import time import sys +import os +from g4units import rad, GeV, MeV, mm, m from ddsix.moves import range logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.INFO) +logger = logging.getLogger(__name__) def help(): @@ -34,6 +39,7 @@ def run(): geo = None vis = False batch = False + install_dir = os.environ['DD4hepINSTALL'] for i in list(range(len(sys.argv))): c = sys.argv[i].upper() if c.find('BATCH') < 2 and c.find('BATCH') >= 0: @@ -48,6 +54,7 @@ def run(): sys.exit(1) import DDG4 + Output = DDG4.OutputLevel kernel = DDG4.Kernel() # Configure UI geant4 = DDG4.Geant4(kernel, tracker='Geant4TrackerCombineAction') @@ -59,14 +66,81 @@ def run(): kernel.loadGeometry(geo) # Configure field geant4.setupTrackingField(prt=True) + + logger.info("# Setup random generator") + rndm = DDG4.Action(kernel, 'Geant4Random/Random') + rndm.Seed = 987654321 + rndm.initialize() + # + # Setup detector + seq, act = geant4.setupDetectors() + # + # Configure I/O + geant4.setupROOTOutput('RootOutput', 'CheckShape_' + time.strftime('%Y-%m-%d_%H-%M'), mc_truth=True) + # + # Setup particle gun + geant4.setupGun(name="Gun", + particle='e-', + energy=100 * GeV, + isotrop=True, + multiplicity=1, + position=(0 * m, 0 * m, 0 * m), + PhiMin=0.0 * rad, + PhiMax=math.pi * 2.0 * rad, + ThetaMin=0.0 * rad, + ThetaMax=math.pi * rad) + # + prt = DDG4.EventAction(kernel, str('Geant4ParticlePrint/ParticlePrint')) + prt.OutputLevel = Output.INFO + prt.OutputType = 3 # Print both: table and tree + kernel.eventAction().adopt(prt) + part = DDG4.GeneratorAction(kernel, str('Geant4ParticleHandler/ParticleHandler')) + kernel.generatorAction().adopt(part) + part.MinimalKineticEnergy = 100 * MeV + part.SaveProcesses = ['Decay'] + part.OutputLevel = 5 # generator_output_level + part.enableUI() + user = DDG4.Action(kernel, str('Geant4TCUserParticleHandler/UserParticleHandler')) + user.TrackingVolume_Rmax = 3.0 * m + user.TrackingVolume_Zmax = 2.0 * m + user.enableUI() + part.adopt(user) + # + # + prt = DDG4.EventAction(kernel, str('Geant4ParticlePrint/ParticlePrint')) + prt.OutputLevel = Output.INFO + prt.OutputType = 3 # Print both: table and tree + kernel.eventAction().adopt(prt) + # # Now build the physics list: - geant4.setupPhysics('') - kernel.physicsList().enableUI() - DDG4.setPrintLevel(DDG4.OutputLevel.DEBUG) + phys = geant4.setupPhysics(str('QGSP_BERT')) + ph = geant4.addPhysics(str('Geant4PhysicsList/Myphysics')) + ph.addPhysicsConstructor(str('G4StepLimiterPhysics')) + ph.addParticleConstructor(str('G4Geantino')) + ph.addParticleConstructor(str('G4BosonConstructor')) + # + # Add special particle types from specialized physics constructor + part = geant4.addPhysics('Geant4ExtraParticles/ExtraParticles') + part.pdgfile = os.path.join(install_dir, 'examples/DDG4/examples/particle.tbl') + # + # Add global range cut + rg = geant4.addPhysics('Geant4DefaultRangeCut/GlobalRangeCut') + rg.RangeCut = 0.7 * mm + # + phys.dump() # cmds = [] - cmds.append('/ddg4/ConstructGeometry/printVolume /world_volume_1/Shape_Test_0/Shape_Test_vol_0_0') - cmds.append('/ddg4/UI/exit') + if vis: + cmds.append('/control/verbose 2') + cmds.append('/run/initialize') + cmds.append('/vis/open OGL') + cmds.append('/vis/verbose errors') + cmds.append('/vis/drawVolume') + cmds.append('/vis/viewer/set/viewpointThetaPhi 55. 11.') + cmds.append('/vis/scene/add/axes 0 0 0 1 m') + #else: + # cmds.append('/ddg4/ConstructGeometry/printVolume /world_volume_1/Shape_Test_0/Shape_Test_vol_0_0') + # cmds.append('/ddg4/UI/exit') ui.Commands = cmds kernel.NumEvents = 0 kernel.configure()