diff --git a/DDG4/examples/ClickSidSimu.py b/DDG4/examples/ClickSidSimu.py new file mode 100644 index 0000000000000000000000000000000000000000..41d6bd83d2548908d0612385a5aeea03d0f25798 --- /dev/null +++ b/DDG4/examples/ClickSidSimu.py @@ -0,0 +1,183 @@ +# +# +import DDG4 +from SystemOfUnits import * +# +# +""" + + DD4hep example setup using the python configuration + + @author M.Frank + @version 1.0 + +""" +def run(): + kernel = DDG4.Kernel() + kernel.loadGeometry("file:../DD4hep.trunk/DDExamples/CLICSiD/compact/compact.xml") + kernel.loadXML("sensitive_detectors.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(), ) + + # Configure Run actions + run1 = DDG4.RunAction(kernel,'Geant4TestRunAction/RunInit') + run1.Property_int = 12345 + run1.Property_double = -5e15*keV + run1.Property_string = 'Startrun: Hello_2' + print run1.Property_string, run1.Property_double, run1.Property_int + run1.enableUI() + kernel.registerGlobalAction(run1) + kernel.runAction().add(run1) + + # Configure Event actions + evt2 = DDG4.EventAction(kernel,'Geant4TestEventAction/UserEvent_2') + evt2.Property_int = 123454321 + evt2.Property_double = 5e15*GeV + evt2.Property_string = 'Hello_2 from the python setup' + evt2.enableUI() + kernel.registerGlobalAction(evt2) + + evt1 = DDG4.EventAction(kernel,'Geant4TestEventAction/UserEvent_1') + evt1.Property_int=01234 + evt1.Property_double=1e11 + evt1.Property_string='Hello_1' + evt1.enableUI() + + kernel.eventAction().add(evt1) + kernel.eventAction().add(evt2) + + # Configure I/O + evt_root = DDG4.EventAction(kernel,'Geant4Output2ROOT/RootOutput') + evt_root.Control = True + evt_root.Output = "simple.root" + evt_root.enableUI() + + evt_lcio = DDG4.EventAction(kernel,'Geant4Output2LCIO/LcioOutput') + evt_lcio.Output = "simple_lcio" + evt_lcio.enableUI() + + kernel.eventAction().add(evt_root) + kernel.eventAction().add(evt_lcio) + + # Setup particle gun + gun = DDG4.GeneratorAction(kernel,"Geant4ParticleGun/Gun") + gun.energy = 0.5*GeV + gun.particle = 'e-' + gun.multiplicity = 1 + gun.enableUI() + kernel.generatorAction().add(gun) + + # Setup global filters fur use in sensntive detectors + f1 = DDG4.Filter(kernel,'GeantinoRejectFilter/GeantinoRejector') + f2 = DDG4.Filter(kernel,'ParticleRejectFilter/OpticalPhotonRejector') + f2.particle = 'opticalphoton' + f3 = DDG4.Filter(kernel,'ParticleSelectFilter/OpticalPhotonSelector') + f3.particle = 'opticalphoton' + f4 = DDG4.Filter(kernel,'EnergyDepositMinimumCut') + f4.Cut = 10*MeV + f4.enableUI() + kernel.registerGlobalFilter(f1) + kernel.registerGlobalFilter(f2) + kernel.registerGlobalFilter(f3) + kernel.registerGlobalFilter(f4) + + # First the tracking detectors + seq = DDG4.SensitiveSequence(kernel,'Geant4SensDetActionSequence/SiVertexBarrel') + act = DDG4.SensitiveAction(kernel,'Geant4SimpleTrackerAction/SiVertexBarrelHandler','SiVertexBarrel') + seq.add(act) + seq.add(f1) + seq.add(f4) + act.add(f1) + + seq = DDG4.SensitiveSequence(kernel,'Geant4SensDetActionSequence/SiVertexEndcap') + act = DDG4.SensitiveAction(kernel,'Geant4SimpleTrackerAction/SiVertexEndcapHandler','SiVertexEndcap') + seq.add(act) + seq.add(f1) + seq.add(f4) + + seq = DDG4.SensitiveSequence(kernel,'Geant4SensDetActionSequence/SiTrackerBarrel') + act = DDG4.SensitiveAction(kernel,'Geant4SimpleTrackerAction/SiTrackerBarrelHandler','SiTrackerBarrel') + seq.add(act) + seq.add(f1) + seq.add(f4) + + seq = DDG4.SensitiveSequence(kernel,'Geant4SensDetActionSequence/SiTrackerEndcap') + act = DDG4.SensitiveAction(kernel,'Geant4SimpleTrackerAction/SiTrackerEndcapHandler','SiTrackerEndcap') + seq.add(act) + + seq = DDG4.SensitiveSequence(kernel,'Geant4SensDetActionSequence/SiTrackerForward') + act = DDG4.SensitiveAction(kernel,'Geant4SimpleTrackerAction/SiTrackerForwardHandler','SiTrackerForward') + seq.add(act) + + # Now the calorimeters + seq = DDG4.SensitiveSequence(kernel,'Geant4SensDetActionSequence/EcalBarrel') + act = DDG4.SensitiveAction(kernel,'Geant4SimpleCalorimeterAction/EcalBarrelHandler','EcalBarrel') + seq.add(act) + + seq = DDG4.SensitiveSequence(kernel,'Geant4SensDetActionSequence/EcalEndcap') + act = DDG4.SensitiveAction(kernel,'Geant4SimpleCalorimeterAction/EcalEndCapHandler','EcalEndcap') + seq.add(act) + + seq = DDG4.SensitiveSequence(kernel,'Geant4SensDetActionSequence/HcalBarrel') + act = DDG4.SensitiveAction(kernel,'Geant4SimpleCalorimeterAction/HcalBarrelHandler','HcalBarrel') + act.adoptFilter(kernel.globalFilter('OpticalPhotonRejector')) + seq.add(act) + + act = DDG4.SensitiveAction(kernel,'Geant4SimpleCalorimeterAction/HcalOpticalBarrelHandler','HcalBarrel') + act.adoptFilter(kernel.globalFilter('OpticalPhotonSelector')) + seq.add(act) + + seq = DDG4.SensitiveSequence(kernel,'Geant4SensDetActionSequence/HcalEndcap') + act = DDG4.SensitiveAction(kernel,'Geant4SimpleCalorimeterAction/HcalEndcapHandler','HcalEndcap') + seq.add(act) + + seq = DDG4.SensitiveSequence(kernel,'Geant4SensDetActionSequence/HcalPlug') + act = DDG4.SensitiveAction(kernel,'Geant4SimpleCalorimeterAction/HcalPlugHandler','HcalPlug') + seq.add(act) + + seq = DDG4.SensitiveSequence(kernel,'Geant4SensDetActionSequence/MuonBarrel') + act = DDG4.SensitiveAction(kernel,'Geant4SimpleCalorimeterAction/MuonBarrelHandler','MuonBarrel') + seq.add(act) + + seq = DDG4.SensitiveSequence(kernel,'Geant4SensDetActionSequence/MuonEndcap') + act = DDG4.SensitiveAction(kernel,'Geant4SimpleCalorimeterAction/MuonEndcapHandler','MuonEndcap') + seq.add(act) + + seq = DDG4.SensitiveSequence(kernel,'Geant4SensDetActionSequence/LumiCal') + act = DDG4.SensitiveAction(kernel,'Geant4SimpleCalorimeterAction/LumiCalHandler','LumiCal') + seq.add(act) + + seq = DDG4.SensitiveSequence(kernel,'Geant4SensDetActionSequence/BeamCal') + act = DDG4.SensitiveAction(kernel,'Geant4SimpleCalorimeterAction/BeamCalHandler','BeamCal') + seq.add(act) + + # Now build the physics list: + phys = kernel.physicsList() + phys.extends = 'FTFP_BERT' + #phys.transportation = True + phys.decays = True + phys.enableUI() + + ph = DDG4.PhysicsList(kernel,'Geant4PhysicsList/Myphysics') + ph.addParticleConstructor('G4BosonConstructor') + ph.addParticleConstructor('G4LeptonConstructor') + ph.addParticleProcess('e[+-]','G4eMultipleScattering',-1,1,1) + ph.addPhysicsConstructor('G4OpticalPhysics') + ph.enableUI() + phys.add(ph) + + phys.dump() + + kernel.configure() + kernel.initialize() + kernel.run() + kernel.terminate() + +if __name__ == "__main__": + run() diff --git a/DDG4/examples/exampleAClick.C b/DDG4/examples/exampleAClick.C index 06340d54f1bf55ffead1a93d7d59e41eabb1ad93..e9c7b6f1efec681dd890bbafcbd3b1c26c4f61ce 100644 --- a/DDG4/examples/exampleAClick.C +++ b/DDG4/examples/exampleAClick.C @@ -29,11 +29,11 @@ SensitiveSeq::handled_type* setupDetector(Kernel& kernel, const std::string& nam } void setupG4_CINT() { - Geant4Kernel& kernel = Geant4Kernel::instance(LCDD::getInstance()); + Kernel kernel(); Phase p; kernel.loadGeometry("file:../DD4hep.trunk/DDExamples/CLICSiD/compact/compact.xml"); - kernel.loadXML("../geant4/sensitive_detectors.xml"); + kernel.loadXML("sensitive_detectors.xml"); GenAction gun(kernel,"Geant4ParticleGun/Gun"); gun["energy"] = 0.5*GeV; diff --git a/DDG4/examples/sensitive_detectors.xml b/DDG4/examples/sensitive_detectors.xml index cfa19ea096509659c5c8c39710c3cc880b974d02..3af2d9a144dd99cba88e7819f9dd881e841fa9c9 100644 --- a/DDG4/examples/sensitive_detectors.xml +++ b/DDG4/examples/sensitive_detectors.xml @@ -1,93 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> <geant4_setup> - <sensitive_detectors> - <sd name="SiVertexBarrel" - type="Geant4SensDet" - ecut="10.0*MeV" - verbose="true" - hit_aggregation="position"> - </sd> - <sd name="SiVertexEndcap" - type="Geant4SensDet" - ecut="10.0*MeV" - verbose="true" - hit_aggregation="position"> - </sd> - <sd name="SiTrackerBarrel" - type="Geant4SensDet" - ecut="10.0*MeV" - verbose="true" - hit_aggregation="position"> - </sd> - <sd name="SiTrackerEndcap" - type="Geant4SensDet" - ecut="10.0*MeV" - verbose="true" - hit_aggregation="position"> - </sd> - <sd name="SiTrackerForward" - type="Geant4SensDet" - ecut="10.0*MeV" - verbose="true" - hit_aggregation="position"> - </sd> - <sd name="EcalBarrel" - type="Geant4SensDet" - ecut="100.0*MeV" - verbose="true" - hit_aggregation="position"> - </sd> - <sd name="EcalEndcap" - type="Geant4SensDet" - ecut="100.0*MeV" - verbose="true" - hit_aggregation="position"> - </sd> - <sd name="HcalBarrel" - type="Geant4SensDet" - ecut="100.0*MeV" - verbose="true" - hit_aggregation="position"> - </sd> - <sd name="HcalEndcap" - type="Geant4SensDet" - ecut="100.0*MeV" - verbose="true" - hit_aggregation="position"> - </sd> - <sd name="HcalPlug" - type="Geant4SensDet" - ecut="100.0*MeV" - verbose="true" - hit_aggregation="position"> - </sd> - <sd name="MuonBarrel" - type="Geant4SensDet" - ecut="100.0*MeV" - limits="cal_limits" - verbose="true" - hit_aggregation="position"> - </sd> - <sd name="MuonEndcap" - type="Geant4SensDet" - ecut="100.0*MeV" - verbose="true" - hit_aggregation="position"> - </sd> - <sd name="LumiCal" - type="Geant4SensDet" - ecut="100.0*MeV" - verbose="true" - hit_aggregation="position"> - </sd> - <sd name="BeamCal" - type="Geant4SensDet" - ecut="100.0*MeV" - verbose="true" - hit_aggregation="position"> - </sd> - </sensitive_detectors> - <properties> <attributes name="geant4_field" id="0" @@ -104,5 +16,4 @@ equation="Mag_UsualEqRhs"> </attributes> </properties> - </geant4_setup> diff --git a/DDG4/examples/sequences.xml b/DDG4/examples/sequences.xml index d5b003dc8ff3e3e68369c122f7524b2a2957c4d8..12977fe0f0da1e642ee4eb7ca8da29787ca77f39 100644 --- a/DDG4/examples/sequences.xml +++ b/DDG4/examples/sequences.xml @@ -65,7 +65,7 @@ <properties particle="opticalphoton"/> </filter> <filter name="EnergyDepositMinimumCut"> - <properties Cut="10*MeV"/> + <properties Cut="10"/> </filter> </filters> @@ -92,7 +92,7 @@ </sequence> <sequence name="Geant4GeneratorActionSequence/GeneratorAction"> <action name="Geant4ParticleGun/Gun"> - <properties energy="0.5*GeV" + <properties energy="500" particle="'e-'" multiplicity="1"/> </action> diff --git a/DDG4/include/DDG4/ComponentProperties.h b/DDG4/include/DDG4/ComponentProperties.h index 2635475752e094ddcd127b2cb3f3916709a2eb9e..1a45bfdcda94056987e978884052d08ed14f740f 100644 --- a/DDG4/include/DDG4/ComponentProperties.h +++ b/DDG4/include/DDG4/ComponentProperties.h @@ -48,6 +48,8 @@ namespace DD4hep { virtual ~PropertyGrammar(); /// Error callback on invalid conversion static void invalidConversion(const std::type_info& from, const std::type_info& to); + /// Error callback on invalid conversion + static void invalidConversion(const std::string& value, const std::type_info& to); /// Access to the type information virtual const std::type_info& type() const = 0; /// Serialize an opaque value to a string @@ -184,6 +186,8 @@ namespace DD4hep { PropertyManager(); /// Default destructor virtual ~PropertyManager(); + /// Check for existence + bool exists(const std::string& name) const; /// Access property by name (CONST) const Property& property(const std::string& name) const; /// Access property by name diff --git a/DDG4/include/DDG4/ComponentProperties_inl.h b/DDG4/include/DDG4/ComponentProperties_inl.h index be54521fd90de9de113a4f950badf34ef39503c8..e15fbfa0e9536918f60595807d3f8216e9cdfc8d 100644 --- a/DDG4/include/DDG4/ComponentProperties_inl.h +++ b/DDG4/include/DDG4/ComponentProperties_inl.h @@ -79,6 +79,7 @@ namespace DD4hep { *(TYPE*)ptr = temp; return true; } + PropertyGrammar::invalidConversion(str, typeid(TYPE)); return false; #else if (!ptr || str.length() == 0) { diff --git a/DDG4/include/DDG4/ComponentUtils.h b/DDG4/include/DDG4/ComponentUtils.h index bb9d0e00180954ebbc9b78c9743a5977d135b230..8d095318b6d140b314f505aeff8c9e503cfb00d1 100644 --- a/DDG4/include/DDG4/ComponentUtils.h +++ b/DDG4/include/DDG4/ComponentUtils.h @@ -35,6 +35,18 @@ namespace DD4hep { } }; + /** @class unrelated_value_error + * + * @author M.Frank + * @date 13.08.2013 + */ + struct unrelated_value_error : public std::runtime_error { + static std::string msg(const std::type_info& typ, const std::string& text); + unrelated_value_error(const std::type_info& typ, const std::string& text = "") + : std::runtime_error(msg(typ, text)) { + } + }; + /** @class * * @author M.Frank @@ -44,7 +56,11 @@ namespace DD4hep { public: typedef void (*destroy_t)(void*); typedef void* (*cast_t)(const void*); +#ifdef __CINT__ + const std::type_info* type; +#else const std::type_info& type; +#endif const void* abi_class; destroy_t destroy; cast_t cast; diff --git a/DDG4/include/DDG4/Geant4Action.h b/DDG4/include/DDG4/Geant4Action.h index d25b4fead2b4286650d0ba0015a7e45eec18abba..dd7db86d6344a07bc571142b754a630dda16a3a3 100644 --- a/DDG4/include/DDG4/Geant4Action.h +++ b/DDG4/include/DDG4/Geant4Action.h @@ -285,15 +285,25 @@ namespace DD4hep { PropertyManager& properties() { return m_properties; } + /// Access to the UI messenger + Geant4UIMessenger* control() const; + /// Enable and install UI messenger + void enableUI(); /// Declare property template <typename T> Geant4Action& declareProperty(const std::string& nam, T& val); /// Declare property template <typename T> Geant4Action& declareProperty(const char* nam, T& val); + /// Check property for existence + bool hasProperty(const std::string& name) const; + /// Access single property + Property& property(const std::string& name); /// Set object properties Geant4Action& setProperties(PropertyConfigurator& setup); /// Install property control messenger if wanted virtual void installMessengers(); + /// Install command control messenger if wanted + virtual void installCommandMessenger(); /// Install property control messenger if wanted void installPropertyMessenger(); diff --git a/DDG4/include/DDG4/Geant4Config.h b/DDG4/include/DDG4/Geant4Config.h index 82dc24b04ca7aa2993d5b64150d5845301ca8a9c..7f90dceff199008f3dccff647b5b4329053bf365 100644 --- a/DDG4/include/DDG4/Geant4Config.h +++ b/DDG4/include/DDG4/Geant4Config.h @@ -51,6 +51,7 @@ namespace DD4hep { namespace Setup { // Basics typedef Geant4Kernel Kernel; + typedef Geant4Handle<Geant4Kernel> KernelH; // Actions typedef Geant4Handle<Geant4Action> Action; typedef Geant4Handle<Geant4Filter> Filter; @@ -64,13 +65,13 @@ namespace DD4hep { typedef Geant4Handle<Geant4ActionPhase> Phase; typedef Geant4Handle<Geant4Sensitive> Sensitive; // Sequences - typedef Geant4Handle<Geant4SensDetActionSequence> SensitiveSeq; - typedef Geant4Handle<Geant4GeneratorActionSequence> GeneratorSeq; - typedef Geant4Handle<Geant4RunActionSequence> RunActionSeq; - typedef Geant4Handle<Geant4EventActionSequence> EventActionSeq; - typedef Geant4Handle<Geant4TrackingActionSequence> TrackActionSeq; - typedef Geant4Handle<Geant4SteppingActionSequence> StepActionSeq; - typedef Geant4Handle<Geant4StackingActionSequence> StackActionSeq; + typedef Geant4Handle<Geant4SensDetActionSequence> SensitiveSeq; + typedef Geant4Handle<Geant4GeneratorActionSequence> GeneratorSeq; + typedef Geant4Handle<Geant4RunActionSequence> RunActionSeq; + typedef Geant4Handle<Geant4EventActionSequence> EventActionSeq; + typedef Geant4Handle<Geant4TrackingActionSequence> TrackActionSeq; + typedef Geant4Handle<Geant4SteppingActionSequence> StepActionSeq; + typedef Geant4Handle<Geant4StackingActionSequence> StackActionSeq; typedef Geant4Handle<Geant4PhysicsListActionSequence> PhysicsActionSeq; } diff --git a/DDG4/include/DDG4/Geant4Handle.h b/DDG4/include/DDG4/Geant4Handle.h index 30f15403004c7043edf72decb9a68e1699c62053..996c3b0317707b42c4655e7fa68ed3e8fc6d89cb 100644 --- a/DDG4/include/DDG4/Geant4Handle.h +++ b/DDG4/include/DDG4/Geant4Handle.h @@ -44,11 +44,11 @@ namespace DD4hep { public: typedef TYPE handled_type; mutable handled_type* value; - Geant4Handle(); + explicit Geant4Handle(); Geant4Handle(handled_type* typ); template <typename T> Geant4Handle(T* typ) : value(0) { - checked_assign(dynamic_cast<TYPE*>(typ)); + checked_assign(dynamic_cast<handled_type*>(typ)); } Geant4Handle(Geant4Handle& handle); Geant4Handle(const Geant4Kernel&, const std::string& type_name); @@ -61,7 +61,27 @@ namespace DD4hep { bool operator!() const; operator handled_type*() const; handled_type* get() const; + handled_type* release(); handled_type* operator->() const; + Geant4Action* action() const; + }; + /** @class Geant4Handle Geant4Handle.h DDG4/Geant4Handle.h + * + * Handle to Geant4 actions with built-in creation mechanism + * + * @author M.Frank + * @version 1.0 + */ + struct KernelHandle { + public: + typedef Geant4Kernel handled_type; + mutable handled_type* value; + explicit KernelHandle(); + ~KernelHandle() {} + operator handled_type*() const { return value; } + handled_type* get() const { return value; } + handled_type* operator->() const { return value; } + void destroy(); }; } // End namespace Simulation diff --git a/DDG4/include/DDG4/Geant4HitCollection.h b/DDG4/include/DDG4/Geant4HitCollection.h index 916bc3e353c7812b9d603dff7e267a037d24a812..b64d570466850292152c6ad229b33cf3e17ec839 100644 --- a/DDG4/include/DDG4/Geant4HitCollection.h +++ b/DDG4/include/DDG4/Geant4HitCollection.h @@ -53,9 +53,13 @@ namespace DD4hep { struct HitManipulator { public: typedef std::pair<void*, HitManipulator*> Wrapper; +#ifdef __CINT__ + const ComponentCast* cast; + const ComponentCast* vec_type; +#else const ComponentCast& cast; const ComponentCast& vec_type; - +#endif /// Initializing Constructor HitManipulator(const ComponentCast& c, const ComponentCast& v); /// Default destructor diff --git a/DDG4/include/DDG4/Geant4Kernel.h b/DDG4/include/DDG4/Geant4Kernel.h index 390f1654595c0be8baff5e0f22aca575f83ff002..0c7c4ba6d6c745d88f13136e6d9d22324ae25b18 100644 --- a/DDG4/include/DDG4/Geant4Kernel.h +++ b/DDG4/include/DDG4/Geant4Kernel.h @@ -131,10 +131,12 @@ namespace DD4hep { }; /// Default destructor virtual ~Geant4Kernel(); +#ifndef __CINT__ /// Instance accessor static Geant4Kernel& instance(LCDD& lcdd); /// Accessof the Geant4Kernel object from the LCDD reference extension (if present and registered) static Geant4Kernel& access(LCDD& lcdd); +#endif /// Access the context Geant4Context* context() const { return m_context; diff --git a/DDG4/include/DDG4/Geant4PhysicsList.h b/DDG4/include/DDG4/Geant4PhysicsList.h index a773fa88334dc214e98a1961bf070d3ab6f14f10..a987c9c8c4b201f66a7cb067fa3df7e6d0cdf186 100644 --- a/DDG4/include/DDG4/Geant4PhysicsList.h +++ b/DDG4/include/DDG4/Geant4PhysicsList.h @@ -104,16 +104,19 @@ namespace DD4hep { }; typedef std::vector<PhysicsConstructor> PhysicsConstructors; - PhysicsProcesses m_processes; + PhysicsProcesses m_processes; ParticleConstructors m_particles; - PhysicsConstructors m_physics; + PhysicsConstructors m_physics; public: /// Standard constructor with initailization parameters Geant4PhysicsList(Geant4Context* context, const std::string& nam); /// Default destructor virtual ~Geant4PhysicsList(); - + /// Dump content to stdout + void dump(); + /// Install command control messenger if wanted + virtual void installCommandMessenger(); /// Access all physics processes PhysicsProcesses& processes() { return m_processes; @@ -143,6 +146,14 @@ namespace DD4hep { return m_physics; } + /// Add physics particle constructor by name + void addParticleConstructor(const std::string& part_name); + /// Add particle process by name with arguments + void addParticleProcess(const std::string& part_name, const std::string& proc_name, + int ordAtRestDoIt,int ordAlongSteptDoIt,int ordPostStepDoIt); + /// Add PhysicsConstructor by name + void addPhysicsConstructor(const std::string& physics_name); + /// Callback to construct the physics constructors virtual void constructProcess(Geant4UserPhysics* interface); @@ -188,6 +199,10 @@ namespace DD4hep { Geant4PhysicsListActionSequence(Geant4Context* context, const std::string& nam); /// Default destructor virtual ~Geant4PhysicsListActionSequence(); + /// Dump content to stdout + void dump(); + /// Install command control messenger if wanted + virtual void installCommandMessenger(); /// Update transportation flag void setTransportation(bool value) { m_transportation = value; diff --git a/DDG4/include/DDG4/Geant4SensDetAction.h b/DDG4/include/DDG4/Geant4SensDetAction.h index 80b6557c5a8deace2a7bb3e5e7822daf96a8e38d..3c9a640b76268e72339b46351d3731387daaae9b 100644 --- a/DDG4/include/DDG4/Geant4SensDetAction.h +++ b/DDG4/include/DDG4/Geant4SensDetAction.h @@ -74,6 +74,7 @@ namespace DD4hep { * @version 1.0 */ struct Geant4Filter: public Geant4Action { + public: /// Standard constructor Geant4Filter(Geant4Context* context, const std::string& name); /// Standard destructor @@ -157,6 +158,9 @@ namespace DD4hep { /// Add an actor responding to all callbacks. Sequence takes ownership. void adopt(Geant4Filter* filter); + /// Add an actor responding to all callbacks. Sequence takes ownership. + void adoptFilter(Geant4Action* filter); + /// Callback before hit processing starts. Invoke all filters. /** Return fals if any filter returns false */ @@ -289,6 +293,9 @@ namespace DD4hep { /// Add an actor responding to all callbacks. Sequence takes ownership. void adopt(Geant4Filter* filter); + /// Add an actor responding to all callbacks. Sequence takes ownership. + void adoptFilter(Geant4Action* filter); + /// Callback before hit processing starts. Invoke all filters. /** Return fals if any filter returns false */ @@ -348,6 +355,8 @@ namespace DD4hep { const Members& sequences() const { return m_sequences; } + /// Clear the sequence list + void clear(); }; /// Initialize the usage of a single hit collection. Returns the collection ID diff --git a/DDG4/plugins/Geant4Particles.cpp b/DDG4/plugins/Geant4Particles.cpp index d352dffe3130cecbab5eec2aa01b0d4cb1a93a74..4f5c9cb402f671c814e416a7eb7c4721813474bb 100644 --- a/DDG4/plugins/Geant4Particles.cpp +++ b/DDG4/plugins/Geant4Particles.cpp @@ -135,6 +135,8 @@ DECLARE_GEANT4_PARTICLE(G4AntiLambdab) DECLARE_GEANT4_PARTICLE(G4XicZero) #include "G4SigmacZero.hh" DECLARE_GEANT4_PARTICLE(G4SigmacZero) +#include "G4BaryonConstructor.hh" +DECLARE_GEANT4_PARTICLEGROUP(G4BaryonConstructor) // ---- ions #include "G4AntiHe3.hh" @@ -217,6 +219,8 @@ DECLARE_GEANT4_PARTICLE(G4PionMinus) DECLARE_GEANT4_PARTICLE(G4Etac) #include "G4BcMesonPlus.hh" DECLARE_GEANT4_PARTICLE(G4BcMesonPlus) +#include "G4MesonConstructor.hh" +DECLARE_GEANT4_PARTICLEGROUP(G4MesonConstructor) // ---- leptons #include "G4MuonPlus.hh" @@ -235,8 +239,6 @@ DECLARE_GEANT4_PARTICLE(G4TauMinus) DECLARE_GEANT4_PARTICLE(G4Positron) #include "G4AntiNeutrinoMu.hh" DECLARE_GEANT4_PARTICLE(G4AntiNeutrinoMu) -#include "G4LeptonConstructor.hh" -DECLARE_GEANT4_PARTICLEGROUP(G4LeptonConstructor) #include "G4NeutrinoMu.hh" DECLARE_GEANT4_PARTICLE(G4NeutrinoMu) #include "G4AntiNeutrinoE.hh" @@ -245,6 +247,8 @@ DECLARE_GEANT4_PARTICLE(G4AntiNeutrinoE) DECLARE_GEANT4_PARTICLE(G4Electron) #include "G4NeutrinoTau.hh" DECLARE_GEANT4_PARTICLE(G4NeutrinoTau) +#include "G4LeptonConstructor.hh" +DECLARE_GEANT4_PARTICLEGROUP(G4LeptonConstructor) // ---- shortlived #include "G4ExcitedXiConstructor.hh" diff --git a/DDG4/plugins/Geant4PhysicsConstructors.cpp b/DDG4/plugins/Geant4PhysicsConstructors.cpp new file mode 100644 index 0000000000000000000000000000000000000000..916ed759d7b9137b9c7e5ffa3a6e4f4ba77d9160 --- /dev/null +++ b/DDG4/plugins/Geant4PhysicsConstructors.cpp @@ -0,0 +1,179 @@ +// $Id: Factories.h 797 2013-10-03 19:20:32Z markus.frank@cern.ch $ +//==================================================================== +// AIDA Detector description implementation +//-------------------------------------------------------------------- +// +// Author : M.Frank +// +//==================================================================== + +// Framework include files +#include "DDG4/Factories.h" + +// Geant4 physics lists +#include "G4Version.hh" +#include "G4DecayPhysics.hh" + +#if G4VERSION_NUMBER>=960 +#define GEANT4_9_6 +#endif + +// ====================================================================== +// Predefined physics constructors +// +// Usage: +// +// <physicslist name="Geant4PhysicsList/MyPhysics.0"> +// <physics> +// <construct name="G4EmStandardPhysics"/> +// <construct name="HadronPhysicsQGSP"/> +// </physics> +// </physicslist> +// +// ====================================================================== + +// EM physics +#include "G4EmStandardPhysics_option1.hh" +DECLARE_GEANT4_PHYSICS(G4EmStandardPhysics_option1) +#include "G4EmStandardPhysics_option2.hh" +DECLARE_GEANT4_PHYSICS(G4EmStandardPhysics_option2) +#include "G4EmStandardPhysics_option3.hh" +DECLARE_GEANT4_PHYSICS(G4EmStandardPhysics_option3) +#include "G4EmStandardPhysics.hh" +DECLARE_GEANT4_PHYSICS(G4EmStandardPhysics) +#include "G4EmExtraPhysics.hh" +DECLARE_GEANT4_PHYSICS(G4EmExtraPhysics) +#include "G4EmLivermorePhysics.hh" +DECLARE_GEANT4_PHYSICS(G4EmLivermorePhysics) + +// Ion and hadrons +#include "G4IonBinaryCascadePhysics.hh" +DECLARE_GEANT4_PHYSICS(G4IonBinaryCascadePhysics) + +#ifdef GEANT4_9_6 + #include "G4IonINCLXXPhysics.hh" + DECLARE_GEANT4_PHYSICS(G4IonINCLXXPhysics) + #include "G4IonLHEPPhysics.hh" + DECLARE_GEANT4_PHYSICS(G4IonLHEPPhysics) +#endif + +#include "G4IonPhysics.hh" +DECLARE_GEANT4_PHYSICS(G4IonPhysics) +#include "G4IonQMDPhysics.hh" +DECLARE_GEANT4_PHYSICS(G4IonQMDPhysics) +#include "G4LHEPStoppingPhysics.hh" +DECLARE_GEANT4_PHYSICS(G4LHEPStoppingPhysics) +#include "G4QStoppingPhysics.hh" +DECLARE_GEANT4_PHYSICS(G4QStoppingPhysics) +#include "G4HadronElasticPhysics.hh" +DECLARE_GEANT4_PHYSICS(G4HadronElasticPhysics) +#include "G4HadronDElasticPhysics.hh" +DECLARE_GEANT4_PHYSICS(G4HadronDElasticPhysics) +#include "G4HadronElasticPhysicsHP.hh" +DECLARE_GEANT4_PHYSICS(G4HadronElasticPhysicsHP) +#include "G4HadronElasticPhysicsLEND.hh" +DECLARE_GEANT4_PHYSICS(G4HadronElasticPhysicsLEND) +#include "G4HadronElasticPhysicsLHEP.hh" +DECLARE_GEANT4_PHYSICS(G4HadronElasticPhysicsLHEP) +#include "G4HadronElasticPhysicsXS.hh" +DECLARE_GEANT4_PHYSICS(G4HadronElasticPhysicsXS) +#include "G4HadronHElasticPhysics.hh" +DECLARE_GEANT4_PHYSICS(G4HadronHElasticPhysics) +#include "G4HadronQElasticPhysics.hh" +DECLARE_GEANT4_PHYSICS(G4HadronQElasticPhysics) +#include "G4NeutronTrackingCut.hh" +DECLARE_GEANT4_PHYSICS(G4NeutronTrackingCut) + +// Optical physics +#include "G4OpticalPhysics.hh" +DECLARE_GEANT4_PHYSICS(G4OpticalPhysics) + +#include "G4QAtomicPhysics.hh" +DECLARE_GEANT4_PHYSICS(G4QAtomicPhysics) +#include "G4QCaptureAtRestPhysics.hh" +DECLARE_GEANT4_PHYSICS(G4QCaptureAtRestPhysics) +#include "G4QElasticPhysics.hh" +DECLARE_GEANT4_PHYSICS(G4QElasticPhysics) +#include "G4QEmExtraPhysics.hh" +DECLARE_GEANT4_PHYSICS(G4QEmExtraPhysics) +#include "G4QNeutrinoPhysics.hh" +DECLARE_GEANT4_PHYSICS(G4QNeutrinoPhysics) +#include "G4QStoppingPhysics.hh" +DECLARE_GEANT4_PHYSICS(G4QStoppingPhysics) +#include "G4QIonPhysics.hh" +DECLARE_GEANT4_PHYSICS(G4QIonPhysics) +#include "G4RadioactiveDecayPhysics.hh" +DECLARE_GEANT4_PHYSICS(G4RadioactiveDecayPhysics) + +// LHEP hadrons +#include "HadronPhysicsLHEP.hh" +DECLARE_GEANT4_PHYSICS(HadronPhysicsLHEP) + +// QGSP hadrons +#include "HadronPhysicsQGSP.hh" +DECLARE_GEANT4_PHYSICS(HadronPhysicsQGSP) +#include "HadronPhysicsQGSP_BERT.hh" +DECLARE_GEANT4_PHYSICS(HadronPhysicsQGSP_BERT) +#include "HadronPhysicsQGSP_BERT_HP.hh" +DECLARE_GEANT4_PHYSICS(HadronPhysicsQGSP_BERT_HP) +#include "HadronPhysicsQGSP_BERT_CHIPS.hh" +DECLARE_GEANT4_PHYSICS(HadronPhysicsQGSP_BERT_CHIPS) +#include "HadronPhysicsQGSP_FTFP_BERT.hh" +DECLARE_GEANT4_PHYSICS(HadronPhysicsQGSP_FTFP_BERT) + +// FTFP hadrons +#include "HadronPhysicsFTFP_BERT.hh" +DECLARE_GEANT4_PHYSICS(HadronPhysicsFTFP_BERT) + +#ifdef GEANT4_9_6 +#include "HadronPhysicsQGSP_INCLXX.hh" +DECLARE_GEANT4_PHYSICS(HadronPhysicsQGSP_INCLXX) +#include "HadronPhysicsFTFP_BERT.hh" +DECLARE_GEANT4_PHYSICS(HadronPhysicsFTFP_BERT) +#include "HadronPhysicsFTFP_BERT_HP.hh" +DECLARE_GEANT4_PHYSICS(HadronPhysicsFTFP_BERT_HP) +#include "HadronPhysicsQGSP_BERT_95.hh" +DECLARE_GEANT4_PHYSICS(HadronPhysicsQGSP_BERT_95) +#include "HadronPhysicsQGSP_FTFP_BERT_95.hh" +DECLARE_GEANT4_PHYSICS(HadronPhysicsQGSP_FTFP_BERT_95) +#endif + +#include "HadronPhysicsCHIPS.hh" +DECLARE_GEANT4_PHYSICS(HadronPhysicsCHIPS) +#include "HadronPhysicsFTF_BIC.hh" +DECLARE_GEANT4_PHYSICS(HadronPhysicsFTF_BIC) +#include "HadronPhysicsFTFP_BERT_TRV.hh" +DECLARE_GEANT4_PHYSICS(HadronPhysicsFTFP_BERT_TRV) +#include "HadronPhysicsLHEP_EMV.hh" +DECLARE_GEANT4_PHYSICS(HadronPhysicsLHEP_EMV) +#include "HadronPhysicsLHEP.hh" +DECLARE_GEANT4_PHYSICS(HadronPhysicsLHEP) +#include "HadronPhysicsQGS_BIC.hh" +DECLARE_GEANT4_PHYSICS(HadronPhysicsQGS_BIC) +#include "HadronPhysicsQGSC_BERT.hh" +DECLARE_GEANT4_PHYSICS(HadronPhysicsQGSC_BERT) +#include "HadronPhysicsQGSC_CHIPS.hh" +DECLARE_GEANT4_PHYSICS(HadronPhysicsQGSC_CHIPS) +#include "HadronPhysicsQGSP_BERT_CHIPS.hh" +DECLARE_GEANT4_PHYSICS(HadronPhysicsQGSP_BERT_CHIPS) +#include "HadronPhysicsQGSP_BERT.hh" +DECLARE_GEANT4_PHYSICS(HadronPhysicsQGSP_BERT) +#include "HadronPhysicsQGSP_BERT_HP.hh" +DECLARE_GEANT4_PHYSICS(HadronPhysicsQGSP_BERT_HP) +#include "HadronPhysicsQGSP_BERT_NOLEP.hh" +DECLARE_GEANT4_PHYSICS(HadronPhysicsQGSP_BERT_NOLEP) +#include "HadronPhysicsQGSP_BERT_TRV.hh" +DECLARE_GEANT4_PHYSICS(HadronPhysicsQGSP_BERT_TRV) +#include "HadronPhysicsQGSP_BIC.hh" +DECLARE_GEANT4_PHYSICS(HadronPhysicsQGSP_BIC) +#include "HadronPhysicsQGSP_BIC_HP.hh" +DECLARE_GEANT4_PHYSICS(HadronPhysicsQGSP_BIC_HP) +#include "HadronPhysicsQGSP_FTFP_BERT.hh" +DECLARE_GEANT4_PHYSICS(HadronPhysicsQGSP_FTFP_BERT) +#include "HadronPhysicsQGSP.hh" +DECLARE_GEANT4_PHYSICS(HadronPhysicsQGSP) + +#if 0 +#include ".hh" +DECLARE_GEANT4_PHYSICS() +#endif diff --git a/DDG4/plugins/Geant4PhysicsLists.cpp b/DDG4/plugins/Geant4PhysicsLists.cpp new file mode 100644 index 0000000000000000000000000000000000000000..10435691ea272a341b5a8a3f0ac81378fe8ecd9a --- /dev/null +++ b/DDG4/plugins/Geant4PhysicsLists.cpp @@ -0,0 +1,116 @@ +// $Id: Factories.h 797 2013-10-03 19:20:32Z markus.frank@cern.ch $ +//==================================================================== +// AIDA Detector description implementation +//-------------------------------------------------------------------- +// +// Author : M.Frank +// +//==================================================================== + +// Framework include files +#include "DDG4/Factories.h" + +// Geant4 physics lists +#include "G4Version.hh" +#include "G4DecayPhysics.hh" + +#if G4VERSION_NUMBER>=960 +#define GEANT4_9_6 +#endif + +// ====================================================================== +// Predefined physics lists +// +// Usage: +// +// <physicslist name="Geant4PhysicsList/MyPhysics.0"> +// <list name="TQGSP_FTFP_BERT_95"/> +// </physicslist> +// +// +// ====================================================================== +#include "DDG4/Geant4UserPhysicsList.h" +namespace { + struct EmptyPhysics : public G4VModularPhysicsList { + EmptyPhysics(int) {} + virtual ~EmptyPhysics() {} + virtual void ConstructProcess() {} + virtual void ConstructParticle() {} + }; +} +DECLARE_GEANT4_PHYSICS_LIST(EmptyPhysics) + +// Physics constructors from source/physics_lists +#include "CHIPS.hh" +DECLARE_GEANT4_PHYSICS_LIST(CHIPS) + +#ifdef GEANT4_9_6 +#include "CHIPS_HP.hh" +DECLARE_GEANT4_PHYSICS_LIST(CHIPS_HP) +#include "FTFP_BERT.hh" +DECLARE_GEANT4_PHYSICS_LIST(FTFP_BERT) +#include "FTFP_BERT_HP.hh" +DECLARE_GEANT4_PHYSICS_LIST(FTFP_BERT_HP) +#include "QGSP_BERT_95.hh" +DECLARE_GEANT4_PHYSICS_LIST(QGSP_BERT_95) +#include "QGSP_BERT_95XS.hh" +DECLARE_GEANT4_PHYSICS_LIST(QGSP_BERT_95XS) +#include "QGSP_INCLXX.hh" +DECLARE_GEANT4_PHYSICS_LIST(QGSP_INCLXX) + +#endif + +#include "FTF_BIC.hh" +DECLARE_GEANT4_PHYSICS_LIST(FTF_BIC) +#include "FTFP_BERT_EMV.hh" +DECLARE_GEANT4_PHYSICS_LIST(FTFP_BERT_EMV) +#include "FTFP_BERT_EMX.hh" +DECLARE_GEANT4_PHYSICS_LIST(FTFP_BERT_EMX) +#include "FTFP_BERT.hh" +DECLARE_GEANT4_PHYSICS_LIST(FTFP_BERT) +#include "FTFP_BERT_TRV.hh" +DECLARE_GEANT4_PHYSICS_LIST(FTFP_BERT_TRV) +#include "LBE.hh" +//DECLARE_GEANT4_PHYSICS_LIST(LBE) takes no verbosity arg! +#include "LHEP_EMV.hh" +DECLARE_GEANT4_PHYSICS_LIST(LHEP_EMV) +#include "LHEP.hh" +DECLARE_GEANT4_PHYSICS_LIST(LHEP) +#include "QBBC.hh" +DECLARE_GEANT4_PHYSICS_LIST(QBBC) +#include "QGS_BIC.hh" +DECLARE_GEANT4_PHYSICS_LIST(QGS_BIC) +#include "QGSC_BERT.hh" +DECLARE_GEANT4_PHYSICS_LIST(QGSC_BERT) +#include "QGSC_CHIPS.hh" +DECLARE_GEANT4_PHYSICS_LIST(QGSC_CHIPS) +#include "QGSP_BERT_CHIPS.hh" +DECLARE_GEANT4_PHYSICS_LIST(QGSP_BERT_CHIPS) +#include "QGSP_BERT_EMV.hh" +DECLARE_GEANT4_PHYSICS_LIST(QGSP_BERT_EMV) +#include "QGSP_BERT_EMX.hh" +DECLARE_GEANT4_PHYSICS_LIST(QGSP_BERT_EMX) +#include "QGSP_BERT.hh" +DECLARE_GEANT4_PHYSICS_LIST(QGSP_BERT) +#include "QGSP_BERT_NOLEP.hh" +DECLARE_GEANT4_PHYSICS_LIST(QGSP_BERT_NOLEP) +#include "QGSP_BERT_TRV.hh" +DECLARE_GEANT4_PHYSICS_LIST(QGSP_BERT_TRV) +#include "QGSP_BIC_EMY.hh" +DECLARE_GEANT4_PHYSICS_LIST(QGSP_BIC_EMY) +#include "QGSP_BIC_HP.hh" +DECLARE_GEANT4_PHYSICS_LIST(QGSP_BIC_HP) +#include "QGSP_BIC.hh" +DECLARE_GEANT4_PHYSICS_LIST(QGSP_BIC) +#include "QGSP_FTFP_BERT.hh" +DECLARE_GEANT4_PHYSICS_LIST(QGSP_FTFP_BERT) +#include "QGSP.hh" +DECLARE_GEANT4_PHYSICS_LIST(QGSP) +#include "QGSP_QEL.hh" +DECLARE_GEANT4_PHYSICS_LIST(QGSP_QEL) +#include "HadronPhysicsCHIPS.hh" + +#if 0 +#include ".hh" +DECLARE_GEANT4_PHYSICS_LIST() +#endif diff --git a/DDG4/plugins/Geant4Processes.cpp b/DDG4/plugins/Geant4Processes.cpp index 3f9f1991b95138e6ee5fe663ee71a78085089fe8..e09de97a7836e5893f6c70e1043d54afba16a8f0 100644 --- a/DDG4/plugins/Geant4Processes.cpp +++ b/DDG4/plugins/Geant4Processes.cpp @@ -9,123 +9,13 @@ // Framework include files #include "DDG4/Factories.h" - // Geant4 physics lists -#include "G4DecayPhysics.hh" - -//fg: uncomment to build for geant4 9.6 -// -> should be handled in cmake files... -//#define GEANT4_9_6 - +#include "G4Version.hh" - -// ====================================================================== -// Predefined physics constructors -// -// Usage: -// -// <physicslist name="Geant4PhysicsList/MyPhysics.0"> -// <physics> -// <construct name="G4EmStandardPhysics"/> -// <construct name="HadronPhysicsQGSP"/> -// </physics> -// </physicslist> -// -// ====================================================================== - -// EM physics -#include "G4EmStandardPhysics_option1.hh" -DECLARE_GEANT4_PHYSICS(G4EmStandardPhysics_option1) -#include "G4EmStandardPhysics_option2.hh" -DECLARE_GEANT4_PHYSICS(G4EmStandardPhysics_option2) -#include "G4EmStandardPhysics_option3.hh" -DECLARE_GEANT4_PHYSICS(G4EmStandardPhysics_option3) -#include "G4EmStandardPhysics.hh" -DECLARE_GEANT4_PHYSICS(G4EmStandardPhysics) -#include "G4EmExtraPhysics.hh" -DECLARE_GEANT4_PHYSICS(G4EmExtraPhysics) -#include "G4EmLivermorePhysics.hh" -DECLARE_GEANT4_PHYSICS(G4EmLivermorePhysics) - -// Ion and hadrons -#include "G4IonBinaryCascadePhysics.hh" -DECLARE_GEANT4_PHYSICS(G4IonBinaryCascadePhysics) - -#ifdef GEANT4_9_6 - #include "G4IonINCLXXPhysics.hh" - DECLARE_GEANT4_PHYSICS(G4IonINCLXXPhysics) - #include "G4IonLHEPPhysics.hh" - DECLARE_GEANT4_PHYSICS(G4IonLHEPPhysics) +#if G4VERSION_NUMBER>=960 +#define GEANT4_9_6 #endif -#include "G4IonPhysics.hh" -DECLARE_GEANT4_PHYSICS(G4IonPhysics) -#include "G4IonQMDPhysics.hh" -DECLARE_GEANT4_PHYSICS(G4IonQMDPhysics) -#include "G4LHEPStoppingPhysics.hh" -DECLARE_GEANT4_PHYSICS(G4LHEPStoppingPhysics) -#include "G4QStoppingPhysics.hh" -DECLARE_GEANT4_PHYSICS(G4QStoppingPhysics) -#include "G4HadronElasticPhysics.hh" -DECLARE_GEANT4_PHYSICS(G4HadronElasticPhysics) -#include "G4HadronDElasticPhysics.hh" -DECLARE_GEANT4_PHYSICS(G4HadronDElasticPhysics) -#include "G4HadronElasticPhysicsHP.hh" -DECLARE_GEANT4_PHYSICS(G4HadronElasticPhysicsHP) -#include "G4HadronElasticPhysicsLEND.hh" -DECLARE_GEANT4_PHYSICS(G4HadronElasticPhysicsLEND) -#include "G4HadronElasticPhysicsLHEP.hh" -DECLARE_GEANT4_PHYSICS(G4HadronElasticPhysicsLHEP) -#include "G4HadronElasticPhysicsXS.hh" -DECLARE_GEANT4_PHYSICS(G4HadronElasticPhysicsXS) -#include "G4HadronHElasticPhysics.hh" -DECLARE_GEANT4_PHYSICS(G4HadronHElasticPhysics) -#include "G4HadronQElasticPhysics.hh" -DECLARE_GEANT4_PHYSICS(G4HadronQElasticPhysics) -#include "G4NeutronTrackingCut.hh" -DECLARE_GEANT4_PHYSICS(G4NeutronTrackingCut) - -// Optical physics -#include "G4OpticalPhysics.hh" -DECLARE_GEANT4_PHYSICS(G4OpticalPhysics) - -#include "G4QAtomicPhysics.hh" -DECLARE_GEANT4_PHYSICS(G4QAtomicPhysics) -#include "G4QCaptureAtRestPhysics.hh" -DECLARE_GEANT4_PHYSICS(G4QCaptureAtRestPhysics) -#include "G4QElasticPhysics.hh" -DECLARE_GEANT4_PHYSICS(G4QElasticPhysics) -#include "G4QEmExtraPhysics.hh" -DECLARE_GEANT4_PHYSICS(G4QEmExtraPhysics) -#include "G4QNeutrinoPhysics.hh" -DECLARE_GEANT4_PHYSICS(G4QNeutrinoPhysics) -#include "G4QStoppingPhysics.hh" -DECLARE_GEANT4_PHYSICS(G4QStoppingPhysics) -#include "G4QIonPhysics.hh" -DECLARE_GEANT4_PHYSICS(G4QIonPhysics) -#include "G4RadioactiveDecayPhysics.hh" -DECLARE_GEANT4_PHYSICS(G4RadioactiveDecayPhysics) - -// LHEP hadrons -#include "HadronPhysicsLHEP.hh" -DECLARE_GEANT4_PHYSICS(HadronPhysicsLHEP) - -// QGSP hadrons -#include "HadronPhysicsQGSP.hh" -DECLARE_GEANT4_PHYSICS(HadronPhysicsQGSP) -#include "HadronPhysicsQGSP_BERT.hh" -DECLARE_GEANT4_PHYSICS(HadronPhysicsQGSP_BERT) -#include "HadronPhysicsQGSP_BERT_HP.hh" -DECLARE_GEANT4_PHYSICS(HadronPhysicsQGSP_BERT_HP) -#include "HadronPhysicsQGSP_BERT_CHIPS.hh" -DECLARE_GEANT4_PHYSICS(HadronPhysicsQGSP_BERT_CHIPS) -#include "HadronPhysicsQGSP_FTFP_BERT.hh" -DECLARE_GEANT4_PHYSICS(HadronPhysicsQGSP_FTFP_BERT) - -// FTFP hadrons -#include "HadronPhysicsFTFP_BERT.hh" -DECLARE_GEANT4_PHYSICS(HadronPhysicsFTFP_BERT) - // ====================================================================== // Predefined physics processes to be attached to particles // @@ -244,150 +134,7 @@ DECLARE_GEANT4_PROCESS(G4hImpactIonisation) //#include "G4IonInverseIonisation.hh" //DECLARE_GEANT4_PROCESS(G4IonInverseIonisation) - -// ====================================================================== -// Predefined physics lists -// -// Usage: -// -// <physicslist name="Geant4PhysicsList/MyPhysics.0"> -// <list name="TQGSP_FTFP_BERT_95"/> -// </physicslist> -// -// -// ====================================================================== -#include "DDG4/Geant4UserPhysicsList.h" -namespace { - struct EmptyPhysics : public G4VModularPhysicsList { - EmptyPhysics(int) {} - virtual ~EmptyPhysics() {} - virtual void ConstructProcess() {} - virtual void ConstructParticle() {} - }; -} -DECLARE_GEANT4_PHYSICS_LIST(EmptyPhysics) - -// Physics constructors from source/physics_lists -#include "CHIPS.hh" -DECLARE_GEANT4_PHYSICS_LIST(CHIPS) -#ifdef GEANT4_9_6 - - #include "CHIPS_HP.hh" - DECLARE_GEANT4_PHYSICS_LIST(CHIPS_HP) - #include "FTFP_BERT.hh" - DECLARE_GEANT4_PHYSICS_LIST(FTFP_BERT) - #include "FTFP_BERT_HP.hh" - DECLARE_GEANT4_PHYSICS_LIST(FTFP_BERT_HP) - #include "QGSP_BERT_95.hh" - DECLARE_GEANT4_PHYSICS_LIST(QGSP_BERT_95) - #include "QGSP_BERT_95XS.hh" - DECLARE_GEANT4_PHYSICS_LIST(QGSP_BERT_95XS) - #include "QGSP_INCLXX.hh" - DECLARE_GEANT4_PHYSICS_LIST(QGSP_INCLXX) - #include "HadronPhysicsQGSP_INCLXX.hh" - DECLARE_GEANT4_PHYSICS(HadronPhysicsQGSP_INCLXX) - #include "HadronPhysicsFTFP_BERT.hh" - DECLARE_GEANT4_PHYSICS(HadronPhysicsFTFP_BERT) - #include "HadronPhysicsFTFP_BERT_HP.hh" - DECLARE_GEANT4_PHYSICS(HadronPhysicsFTFP_BERT_HP) -#include "HadronPhysicsQGSP_BERT_95.hh" -DECLARE_GEANT4_PHYSICS(HadronPhysicsQGSP_BERT_95) -#include "HadronPhysicsQGSP_FTFP_BERT_95.hh" -DECLARE_GEANT4_PHYSICS(HadronPhysicsQGSP_FTFP_BERT_95) - -#endif - -#include "FTF_BIC.hh" -DECLARE_GEANT4_PHYSICS_LIST(FTF_BIC) -#include "FTFP_BERT_EMV.hh" -DECLARE_GEANT4_PHYSICS_LIST(FTFP_BERT_EMV) -#include "FTFP_BERT_EMX.hh" -DECLARE_GEANT4_PHYSICS_LIST(FTFP_BERT_EMX) -#include "FTFP_BERT.hh" -DECLARE_GEANT4_PHYSICS_LIST(FTFP_BERT) -#include "FTFP_BERT_TRV.hh" -DECLARE_GEANT4_PHYSICS_LIST(FTFP_BERT_TRV) -#include "LBE.hh" -//DECLARE_GEANT4_PHYSICS_LIST(LBE) takes no verbosity arg! -#include "LHEP_EMV.hh" -DECLARE_GEANT4_PHYSICS_LIST(LHEP_EMV) -#include "LHEP.hh" -DECLARE_GEANT4_PHYSICS_LIST(LHEP) -#include "QBBC.hh" -DECLARE_GEANT4_PHYSICS_LIST(QBBC) -#include "QGS_BIC.hh" -DECLARE_GEANT4_PHYSICS_LIST(QGS_BIC) -#include "QGSC_BERT.hh" -DECLARE_GEANT4_PHYSICS_LIST(QGSC_BERT) -#include "QGSC_CHIPS.hh" -DECLARE_GEANT4_PHYSICS_LIST(QGSC_CHIPS) -#include "QGSP_BERT_CHIPS.hh" -DECLARE_GEANT4_PHYSICS_LIST(QGSP_BERT_CHIPS) -#include "QGSP_BERT_EMV.hh" -DECLARE_GEANT4_PHYSICS_LIST(QGSP_BERT_EMV) -#include "QGSP_BERT_EMX.hh" -DECLARE_GEANT4_PHYSICS_LIST(QGSP_BERT_EMX) -#include "QGSP_BERT.hh" -DECLARE_GEANT4_PHYSICS_LIST(QGSP_BERT) -#include "QGSP_BERT_NOLEP.hh" -DECLARE_GEANT4_PHYSICS_LIST(QGSP_BERT_NOLEP) -#include "QGSP_BERT_TRV.hh" -DECLARE_GEANT4_PHYSICS_LIST(QGSP_BERT_TRV) -#include "QGSP_BIC_EMY.hh" -DECLARE_GEANT4_PHYSICS_LIST(QGSP_BIC_EMY) -#include "QGSP_BIC_HP.hh" -DECLARE_GEANT4_PHYSICS_LIST(QGSP_BIC_HP) -#include "QGSP_BIC.hh" -DECLARE_GEANT4_PHYSICS_LIST(QGSP_BIC) -#include "QGSP_FTFP_BERT.hh" -DECLARE_GEANT4_PHYSICS_LIST(QGSP_FTFP_BERT) -#include "QGSP.hh" -DECLARE_GEANT4_PHYSICS_LIST(QGSP) -#include "QGSP_QEL.hh" -DECLARE_GEANT4_PHYSICS_LIST(QGSP_QEL) -#include "HadronPhysicsCHIPS.hh" -DECLARE_GEANT4_PHYSICS(HadronPhysicsCHIPS) -#include "HadronPhysicsFTF_BIC.hh" -DECLARE_GEANT4_PHYSICS(HadronPhysicsFTF_BIC) -#include "HadronPhysicsFTFP_BERT_TRV.hh" -DECLARE_GEANT4_PHYSICS(HadronPhysicsFTFP_BERT_TRV) -#include "HadronPhysicsLHEP_EMV.hh" -DECLARE_GEANT4_PHYSICS(HadronPhysicsLHEP_EMV) -#include "HadronPhysicsLHEP.hh" -DECLARE_GEANT4_PHYSICS(HadronPhysicsLHEP) -#include "HadronPhysicsQGS_BIC.hh" -DECLARE_GEANT4_PHYSICS(HadronPhysicsQGS_BIC) -#include "HadronPhysicsQGSC_BERT.hh" -DECLARE_GEANT4_PHYSICS(HadronPhysicsQGSC_BERT) -#include "HadronPhysicsQGSC_CHIPS.hh" -DECLARE_GEANT4_PHYSICS(HadronPhysicsQGSC_CHIPS) -#include "HadronPhysicsQGSP_BERT_CHIPS.hh" -DECLARE_GEANT4_PHYSICS(HadronPhysicsQGSP_BERT_CHIPS) -#include "HadronPhysicsQGSP_BERT.hh" -DECLARE_GEANT4_PHYSICS(HadronPhysicsQGSP_BERT) -#include "HadronPhysicsQGSP_BERT_HP.hh" -DECLARE_GEANT4_PHYSICS(HadronPhysicsQGSP_BERT_HP) -#include "HadronPhysicsQGSP_BERT_NOLEP.hh" -DECLARE_GEANT4_PHYSICS(HadronPhysicsQGSP_BERT_NOLEP) -#include "HadronPhysicsQGSP_BERT_TRV.hh" -DECLARE_GEANT4_PHYSICS(HadronPhysicsQGSP_BERT_TRV) -#include "HadronPhysicsQGSP_BIC.hh" -DECLARE_GEANT4_PHYSICS(HadronPhysicsQGSP_BIC) -#include "HadronPhysicsQGSP_BIC_HP.hh" -DECLARE_GEANT4_PHYSICS(HadronPhysicsQGSP_BIC_HP) -#include "HadronPhysicsQGSP_FTFP_BERT.hh" -DECLARE_GEANT4_PHYSICS(HadronPhysicsQGSP_FTFP_BERT) -#include "HadronPhysicsQGSP.hh" -DECLARE_GEANT4_PHYSICS(HadronPhysicsQGSP) - #if 0 - -#include ".hh" -DECLARE_GEANT4_PHYSICS_LIST() - -#include ".hh" -DECLARE_GEANT4_PHYSICS() - #include ".hh" DECLARE_GEANT4_PROCESS() #endif diff --git a/DDG4/python/DDG4.py b/DDG4/python/DDG4.py new file mode 100644 index 0000000000000000000000000000000000000000..4e2d16fb1afad92e1e5fb0d1e40c5dbe3ee76ab4 --- /dev/null +++ b/DDG4/python/DDG4.py @@ -0,0 +1,183 @@ +import os, sys, imp, exceptions +# Add ROOT to the python path in case it is not yet there.... +sys.path.append(os.environ['ROOTSYS']+os.sep+'lib') +import ROOT +#--------------------------------------------------------------------------- +# We compile the DDG4 plugin on the fly if it does not exist using the AClick mechanism: +def compileAClick(dictionary,g4=True): + from ROOT import gInterpreter, gSystem + dd4hep = os.environ['DD4hep_DIR'] + inc = ' -I'+dd4hep+'/include ' + lib = ' -L'+dd4hep+'/lib -lDD4hepCore -lDD4hepG4 -lDDSegmentation ' + if g4: + geant4 = os.environ['Geant4_DIR'] + inc = inc + ' -I'+geant4+'/include/Geant4 -Wno-shadow -g -O0 ' + lib = lib + ' -L'+geant4+'/lib -L'+geant4+'/lib64 -lG4event -lG4tracking -lG4particles ' + + gSystem.AddIncludePath(inc) + gSystem.AddLinkedLibs(lib) + #####print "Includes: ",gSystem.GetIncludePath(),"\n","Linked libs:",gSystem.GetLinkedLibs() + gInterpreter.ProcessLine('.L '+dictionary+'+') + #####gInterpreter.Load('Geant4Dict_C.so') + from ROOT import DD4hep as module + return module + +# We are nearly there .... +current = __import__(__name__) +def _import_class(ns,nam): + scope = getattr(current,ns) + setattr(current,nam,getattr(scope,nam)) + +#--------------------------------------------------------------------------- +DD4hep = compileAClick(dictionary='DDG4Dict.C',g4=True) +Sim = DD4hep.Simulation +Simulation = DD4hep.Simulation + +Kernel = Sim.KernelHandle +Interface = Sim.Geant4ActionCreation + +def _registerGlobalAction(self,action): + self.get().registerGlobalAction(Interface.toAction(action)) +def _registerGlobalFilter(self,filter): + self.get().registerGlobalFilter(Interface.toAction(filter)) + +Kernel.registerGlobalAction = _registerGlobalAction +Kernel.registerGlobalFilter = _registerGlobalFilter +ActionHandle = Sim.ActionHandle +#--------------------------------------------------------------------------- +def SensitiveAction(kernel,nam,det): return Interface.createSensitive(kernel,nam,det) +#--------------------------------------------------------------------------- +def Filter(kernel,nam): return Interface.createFilter(kernel,nam) +#--------------------------------------------------------------------------- +def RunAction(kernel,nam): return Interface.createRunAction(kernel,nam) +#--------------------------------------------------------------------------- +def EventAction(kernel,nam): return Interface.createEventAction(kernel,nam) +#--------------------------------------------------------------------------- +def GeneratorAction(kernel,nam): return Interface.createGeneratorAction(kernel,nam) +#--------------------------------------------------------------------------- +def TrackingAction(kernel,nam): return Interface.createTrackingAction(kernel,nam) +#--------------------------------------------------------------------------- +def SteppingAction(kernel,nam): return Interface.createSteppingAction(kernel,nam) +#--------------------------------------------------------------------------- +def StackingAction(kernel,nam): return Interface.createStackingAction(kernel,nam) +#--------------------------------------------------------------------------- +def PhysicsList(kernel,nam): return Interface.createPhysicsList(kernel,nam) +#--------------------------------------------------------------------------- +def SensitiveSequence(kernel, nam): return Interface.createSensDetSequence(kernel,nam) +#--------------------------------------------------------------------------- +def _adopt(self,action): self.adopt(action.get()) +def _setup(obj): + _import_class('Sim',obj) + setattr(getattr(current,obj),'add',_adopt) +#--------------------------------------------------------------------------- +_setup('Geant4RunActionSequence') +_setup('Geant4EventActionSequence') +_setup('Geant4GeneratorActionSequence') +_setup('Geant4TrackingActionSequence') +_setup('Geant4SteppingActionSequence') +_setup('Geant4StackingActionSequence') +_setup('Geant4PhysicsListActionSequence') +_setup('Geant4SensDetActionSequence') +_setup('Geant4Sensitive') +_import_class('Sim','Geant4Filter') +_import_class('Sim','Geant4RunAction') + +#--------------------------------------------------------------------------- +def _get(self, name): + #print '_get:',str(type(self)),name + a = Interface.toAction(self) + ret = Interface.getProperty(a,name) + if ret.status > 0: + return ret.data + elif hasattr(self.action,name): + return getattr(self.action,name) + elif hasattr(self,name): + return getattr(self,name) + msg = 'Geant4Action::GetProperty [Unhandled]: Cannot access '+a.name()+'.'+name + raise exceptions.KeyError(msg) + +def _set(self, name, value): + #print '_set:',name,value + a = Interface.toAction(self) + if Interface.setProperty(a,name,str(value)): + return + msg = 'Geant4Action::SetProperty [Unhandled]: Cannot set '+a.name()+'.'+name+' = '+str(value) + raise exceptions.KeyError(msg) + +def _props(obj): + _import_class('Sim',obj) + cl = getattr(current,obj) + cl.__getattr__ = _get + cl.__setattr__ = _set + +_props('FilterHandle') +_props('ActionHandle') +_props('RunActionHandle') +_props('EventActionHandle') +_props('GeneratorActionHandle') +_props('PhysicsListHandle') +_props('TrackingActionHandle') +_props('SteppingActionHandle') +_props('StackingActionHandle') +_props('SensitiveHandle') + +_props('GeneratorActionSequenceHandle') +_props('RunActionSequenceHandle') +_props('EventActionSequenceHandle') +_props('TrackingActionSequenceHandle') +_props('SteppingActionSequenceHandle') +_props('StackingActionSequenceHandle') +_props('PhysicsListActionSequenceHandle') +_props('SensDetActionSequenceHandle') + +_props('Geant4PhysicsListActionSequence') +#--------------------------------------------------------------------------- +Geo = DD4hep.Geometry +Geometry = DD4hep.Geometry + +_import_class('Geo','LCDD') +_import_class('Geo','VolumeManager') +_import_class('Geo','OverlayedField') + +#// Objects.h +_import_class('Geo','Author') +_import_class('Geo','Header') +_import_class('Geo','Constant') +_import_class('Geo','Atom') +_import_class('Geo','Material') +_import_class('Geo','VisAttr') +_import_class('Geo','AlignmentEntry') +_import_class('Geo','Limit') +_import_class('Geo','LimitSet') +_import_class('Geo','Region') + +#// Readout.h +_import_class('Geo','Readout') +_import_class('Geo','Alignment') +_import_class('Geo','Conditions') + +#// DetElement.h +_import_class('Geo','DetElement') +_import_class('Geo','SensitiveDetector') + +#// Volume.h +_import_class('Geo','Volume') +_import_class('Geo','PlacedVolume') + +#// Shapes.h +_import_class('Geo','Polycone') +_import_class('Geo','ConeSegment') +_import_class('Geo','Box') +_import_class('Geo','Torus') +_import_class('Geo','Cone') +_import_class('Geo','Tube') +_import_class('Geo','Trap') +_import_class('Geo','Trapezoid') +_import_class('Geo','Sphere') +_import_class('Geo','Paraboloid') +_import_class('Geo','PolyhedraRegular') +_import_class('Geo','BooleanSolid') +_import_class('Geo','SubtractionSolid') +_import_class('Geo','UnionSolid') +_import_class('Geo','IntersectionSolid') + diff --git a/DDG4/python/DDG4Dict.C b/DDG4/python/DDG4Dict.C new file mode 100644 index 0000000000000000000000000000000000000000..9f712bb5eb233e5a53c9bf2cab30a14f07a3f1d7 --- /dev/null +++ b/DDG4/python/DDG4Dict.C @@ -0,0 +1,337 @@ +// $Id: Geant4Data.h 513 2013-04-05 14:31:53Z gaede $ +//==================================================================== +// AIDA Detector description implementation +//-------------------------------------------------------------------- +// +// Define the ROOT dictionaries for all data classes to be saved +// which are created by the DDG4 examples. +// +// Author : M.Frank +// +//==================================================================== +// FRamework include files +#include "DDG4/Geant4Data.h" +#include <vector> + +using namespace std; +using namespace DD4hep; +using namespace DD4hep::Simulation; + +// CINT configuration +#if defined(__MAKECINT__) +//#pragma link C++ class Position+; +//#pragma link C++ class Direction+; +#pragma link C++ class SimpleRun+; +#pragma link C++ class SimpleEvent+; +//#pragma link C++ class SimpleEvent::Seeds+; +#pragma link C++ class SimpleHit+; +#pragma link C++ class std::vector<SimpleHit*>+; +#pragma link C++ class SimpleHit::Contribution+; +#pragma link C++ class SimpleHit::Contributions+; +#pragma link C++ class SimpleTracker+; +#pragma link C++ class SimpleTracker::Hit+; +#pragma link C++ class std::vector<SimpleTracker::Hit*>+; +#pragma link C++ class SimpleCalorimeter+; +#pragma link C++ class SimpleCalorimeter::Hit+; +#pragma link C++ class std::vector<SimpleCalorimeter::Hit*>+; +//#pragma link C++ class ; +#endif + +#include "DDG4/Geant4Config.h" +#include <iostream> + +namespace DD4hep { + namespace Simulation { + +#define ACTIONHANDLE(x) \ + struct x##Handle { \ + Geant4##x* action; \ + x##Handle(Geant4##x* a) : action(a) { if ( action ) action->addRef();} \ + x##Handle(const x##Handle& h) : action(h.action) { if ( action ) action->addRef();} \ + ~x##Handle() { if ( action) action->release(); } \ + operator Geant4##x* () const { return action; } \ + Geant4##x* operator->() const { return action; } \ + Geant4##x* get() const { return action; } \ + } + + ACTIONHANDLE(Filter); + ACTIONHANDLE(Action); + ACTIONHANDLE(RunAction); + ACTIONHANDLE(EventAction); + ACTIONHANDLE(GeneratorAction); + ACTIONHANDLE(PhysicsList); + ACTIONHANDLE(TrackingAction); + ACTIONHANDLE(SteppingAction); + ACTIONHANDLE(StackingAction); + ACTIONHANDLE(Sensitive); + + ACTIONHANDLE(GeneratorActionSequence); + ACTIONHANDLE(RunActionSequence); + ACTIONHANDLE(EventActionSequence); + ACTIONHANDLE(TrackingActionSequence); + ACTIONHANDLE(SteppingActionSequence); + ACTIONHANDLE(StackingActionSequence); + ACTIONHANDLE(PhysicsListActionSequence); + ACTIONHANDLE(SensDetActionSequence); + + struct PropertyResult { + string data; + int status; + PropertyResult() : status(0) {} + PropertyResult(const string& d, int s) : data(d), status(s) {} + PropertyResult(const PropertyResult& c) : data(c.data), status(c.status) {} + ~PropertyResult() {} + }; + + struct Geant4ActionCreation { + template <typename H,typename T> static H cr(KernelHandle& kernel, const string& name_type) { + T action(*kernel.get(),name_type); + H handle(action.get()); + return handle; + } + static ActionHandle createAction(KernelHandle& kernel, const string& name_type) + { return cr<ActionHandle,Setup::Action>(kernel,name_type); } + static FilterHandle createFilter(KernelHandle& kernel, const string& name_type) + { return cr<FilterHandle,Setup::Filter>(kernel,name_type); } + static PhysicsListHandle createPhysicsList(KernelHandle& kernel, const string& name_type) + { return cr<PhysicsListHandle,Setup::PhysicsList>(kernel,name_type); } + static RunActionHandle createRunAction(KernelHandle& kernel, const string& name_type) + { return cr<RunActionHandle,Setup::RunAction>(kernel,name_type); } + static EventActionHandle createEventAction(KernelHandle& kernel, const string& name_type) + { return cr<EventActionHandle,Setup::EventAction>(kernel,name_type); } + static TrackingActionHandle createTrackingAction(KernelHandle& kernel, const string& name_type) + { return cr<TrackingActionHandle,Setup::TrackAction>(kernel,name_type); } + static SteppingActionHandle createSteppingAction(KernelHandle& kernel, const string& name_type) + { return cr<SteppingActionHandle,Setup::StepAction>(kernel,name_type); } + static StackingActionHandle createStackingAction(KernelHandle& kernel, const string& name_type) + { return cr<StackingActionHandle,Setup::StackAction>(kernel,name_type); } + static GeneratorActionHandle createGeneratorAction(KernelHandle& kernel, const string& name_type) + { return cr<GeneratorActionHandle,Setup::GenAction>(kernel,name_type); } + static SensitiveHandle createSensitive(KernelHandle& kernel, const string& name_type, const string& detector) + { return SensitiveHandle(Setup::Sensitive(*kernel.get(),name_type,detector).get()); } + static SensDetActionSequenceHandle createSensDetSequence(KernelHandle& kernel, const string& name_type) + { return cr<SensDetActionSequenceHandle,Setup::SensitiveSeq>(kernel,name_type); } + + static Geant4Action* toAction(Geant4Filter* f) { return f; } + static Geant4Action* toAction(Geant4Action* f) { return f; } + static Geant4Action* toAction(Geant4Sensitive* f) { return f; } + static Geant4Action* toAction(Geant4PhysicsList* f) { return f; } + static Geant4Action* toAction(Geant4RunAction* f) { return f; } + static Geant4Action* toAction(Geant4EventAction* f) { return f; } + static Geant4Action* toAction(Geant4TrackingAction* f) { return f; } + static Geant4Action* toAction(Geant4SteppingAction* f) { return f; } + static Geant4Action* toAction(Geant4StackingAction* f) { return f; } + static Geant4Action* toAction(Geant4GeneratorAction* f) { return f; } + static Geant4Action* toAction(Geant4GeneratorActionSequence* f) { return f; } + static Geant4Action* toAction(Geant4RunActionSequence* f) { return f; } + static Geant4Action* toAction(Geant4EventActionSequence* f) { return f; } + static Geant4Action* toAction(Geant4TrackingActionSequence* f) { return f; } + static Geant4Action* toAction(Geant4SteppingActionSequence* f) { return f; } + static Geant4Action* toAction(Geant4StackingActionSequence* f) { return f; } + static Geant4Action* toAction(Geant4PhysicsListActionSequence* f){ return f; } + static Geant4Action* toAction(Geant4SensDetActionSequence* f) { return f; } + + static Geant4Action* toAction(FilterHandle f) { return f.action; } + static Geant4Action* toAction(ActionHandle f) { return f.action; } + static Geant4Action* toAction(SensitiveHandle f) { return f.action; } + static Geant4Action* toAction(PhysicsListHandle f) { return f.action; } + static Geant4Action* toAction(RunActionHandle f) { return f.action; } + static Geant4Action* toAction(EventActionHandle f) { return f.action; } + static Geant4Action* toAction(TrackingActionHandle f) { return f.action; } + static Geant4Action* toAction(SteppingActionHandle f) { return f.action; } + static Geant4Action* toAction(StackingActionHandle f) { return f.action; } + static Geant4Action* toAction(GeneratorActionHandle f) { return f.action; } + static Geant4Action* toAction(GeneratorActionSequenceHandle f) { return f.action; } + static Geant4Action* toAction(RunActionSequenceHandle f) { return f.action; } + static Geant4Action* toAction(EventActionSequenceHandle f) { return f.action; } + static Geant4Action* toAction(TrackingActionSequenceHandle f) { return f.action; } + static Geant4Action* toAction(SteppingActionSequenceHandle f) { return f.action; } + static Geant4Action* toAction(StackingActionSequenceHandle f) { return f.action; } + static Geant4Action* toAction(PhysicsListActionSequenceHandle f) { return f.action; } + static Geant4Action* toAction(SensDetActionSequenceHandle f) { return f.action; } + static PropertyResult getProperty(Geant4Action* action, const string& name) { + if ( action->hasProperty(name) ) { + return PropertyResult(action->property(name).str(),1); + } + return PropertyResult("",0); + } + static int setProperty(Geant4Action* action, const string& name, const string& value) { + if ( action->hasProperty(name) ) { + action->property(name).str(value); + return 1; + } + return 0; + } + }; + } +} + +typedef DD4hep::Simulation::Geant4ActionCreation Geant4ActionCreation; + +// CINT configuration for DDG4 +#if defined(__MAKECINT__) +#pragma link C++ class PropertyResult; + +#pragma link C++ class ActionHandle; +#pragma link C++ class FilterHandle; +#pragma link C++ class RunActionHandle; +#pragma link C++ class GeneratorActionHandle; +#pragma link C++ class EventActionHandle; +#pragma link C++ class PhysicsListHandle; +#pragma link C++ class TrackingActionHandle; +#pragma link C++ class SteppingActionHandle; +#pragma link C++ class StackingActionHandle; +#pragma link C++ class SensitiveHandle; +#pragma link C++ class GeneratorActionSequenceHandle; +#pragma link C++ class RunActionSequenceHandle; +#pragma link C++ class EventActionSequenceHandle; +#pragma link C++ class TrackingActionSequenceHandle; +#pragma link C++ class SteppingActionSequenceHandle; +#pragma link C++ class StackingActionSequenceHandle; +#pragma link C++ class PhysicsListActionSequenceHandle; +#pragma link C++ class SensDetActionSequenceHandle; + + +#pragma link C++ class Geant4ActionCreation; +#pragma link C++ class Geant4Action; +#pragma link C++ class Geant4Kernel; +#pragma link C++ class Geant4Context; +#pragma link C++ class KernelHandle; + +#pragma link C++ class Geant4RunActionSequence; +#pragma link C++ class Geant4RunAction; + +#pragma link C++ class Geant4EventActionSequence; +#pragma link C++ class Geant4EventAction; + +#pragma link C++ class Geant4SteppingActionSequence; +#pragma link C++ class Geant4SteppingAction; + +#pragma link C++ class Geant4StackingActionSequence; +#pragma link C++ class Geant4StackingAction; + +#pragma link C++ class Geant4TrackingActionSequence; +#pragma link C++ class Geant4TrackingAction; + +#pragma link C++ class Geant4GeneratorActionSequence; +#pragma link C++ class Geant4GeneratorAction; + +#pragma link C++ class Geant4PhysicsListActionSequence; +#pragma link C++ class Geant4PhysicsList; + +#pragma link C++ class Geant4Filter; +#pragma link C++ class Geant4ActionSD; +#pragma link C++ class Geant4Sensitive; +#pragma link C++ class Geant4SensDetActionSequence; + +#pragma link C++ class Geant4ActionPhase; + +#endif + + +using namespace DD4hep::Geometry; + +// CINT configuration for DD4hep +#if defined(__MAKECINT__) + +//#pragma link C++ class Handle<TObject>; +#pragma link C++ class Handle<TNamed>; +#pragma link C++ class LCDD::HandleMap; +#pragma link C++ class LCDD::HandleMap::iterator; +#pragma link C++ class LCDD::HandleMap::const_iterator; +#pragma link C++ class LCDD::HandleMap::key_type; +#pragma link C++ class LCDD::HandleMap::value_type; +#pragma link C++ class LCDD::PropertyValues; +#pragma link C++ class LCDD::Properties; +#pragma link C++ class LCDD; +#pragma link C++ class VolumeManager; +#pragma link C++ class OverlayedField; + +// Objects.h +#pragma link C++ class Author; +#pragma link C++ class Header; +#pragma link C++ class Constant; +#pragma link C++ class Atom; +#pragma link C++ class Material; +#pragma link C++ class VisAttr; +#pragma link C++ class AlignmentEntry; +#pragma link C++ class Limit; +#pragma link C++ class LimitSet; +#pragma link C++ class Region; + +// Readout.h +#pragma link C++ class Readout; +#pragma link C++ class Alignment; +#pragma link C++ class Conditions; + +// DetElement.h +#pragma link C++ class DetElement; +#pragma link C++ class SensitiveDetector; + +// Volume.h +#pragma link C++ class Volume; +#pragma link C++ class PlacedVolume; + +// Shapes.h +#pragma link C++ class Polycone; +#pragma link C++ class Solid_type<TGeoPcon>; +#pragma link C++ class Handle<TGeoPcon>; + +#pragma link C++ class ConeSegment; +#pragma link C++ class Solid_type<TGeoConeSeg>; +#pragma link C++ class Handle<TGeoConeSeg>; + +#pragma link C++ class Box; +#pragma link C++ class Solid_type<TGeoBBox>; +#pragma link C++ class Handle<TGeoBBox>; + +#pragma link C++ class Torus; +#pragma link C++ class Solid_type<TGeoTorus>; +#pragma link C++ class Handle<TGeoTorus>; + +#pragma link C++ class Cone; +#pragma link C++ class Solid_type<TGeoCone>; +#pragma link C++ class Handle<TGeoCone>; + +#pragma link C++ class Tube; +#pragma link C++ class Solid_type<TGeoTubeSeg>; +#pragma link C++ class Handle<TGeoTubeSeg>; + +#pragma link C++ class Trap; +#pragma link C++ class Solid_type<TGeoTrap>; +#pragma link C++ class Handle<TGeoTrap>; + +#pragma link C++ class Trapezoid; +#pragma link C++ class Solid_type<TGeoTrd2>; +#pragma link C++ class Handle<TGeoTrd2>; + +#pragma link C++ class Sphere; +#pragma link C++ class Solid_type<TGeoSphere>; +#pragma link C++ class Handle<TGeoSphere>; + +#pragma link C++ class Paraboloid; +#pragma link C++ class Solid_type<TGeoParaboloid>; +#pragma link C++ class Handle<TGeoParaboloid>; + +#pragma link C++ class PolyhedraRegular; +#pragma link C++ class Solid_type<TGeoPgon>; +#pragma link C++ class Handle<TGeoPgon>; + +#pragma link C++ class BooleanSolid; +#pragma link C++ class Solid_type<TGeoCompositeShape>; +#pragma link C++ class Handle<TGeoCompositeShape>; + +#pragma link C++ class SubtractionSolid; +#pragma link C++ class UnionSolid; +#pragma link C++ class IntersectionSolid; + + +//#pragma link C++ class Solid_type<>; +//#pragma link C++ class Handle<>; +#endif + + + +int Geant4Dict() { + return 0; +} diff --git a/DDG4/python/SystemOfUnits.py b/DDG4/python/SystemOfUnits.py new file mode 100644 index 0000000000000000000000000000000000000000..894a8048da69939983d41f5f84910e944aa8f0cf --- /dev/null +++ b/DDG4/python/SystemOfUnits.py @@ -0,0 +1,278 @@ +# File: AthenaCommon/share/SystemOfUnits.py +# Author: Wim Lavrijsen (LBNL, WLavrijsen@lbl.gov) +# Created: 01/21/04 +# Last: 01/21/04 + +# This script is a direct adaptation of CLHEP/Units/SystemOfUnits.h +# and the following is the originial CLHEP comment: +# +# ----- +# HEP coherent system of Units +# +# This file has been provided to CLHEP by Geant4 (simulation toolkit for HEP). +# +# The basic units are : +# millimeter (millimeter) +# nanosecond (nanosecond) +# Mega electron Volt (MeV) +# positron charge (eplus) +# degree Kelvin (kelvin) +# the amount of substance (mole) +# luminous intensity (candela) +# radian (radian) +# steradian (steradian) +# +# Below is a non exhaustive list of derived and pratical units +# (i.e. mostly the SI units). +# You can add your own units. +# +# The SI numerical value of the positron charge is defined here, +# as it is needed for conversion factor : positron charge = e_SI (coulomb) +# +# The others physical constants are defined in the header file : +# PhysicalConstants.h +# +# Authors: M.Maire, S.Giani +# +# History: +# +# 06.02.96 Created. +# 28.03.96 Added miscellaneous constants. +# 05.12.97 E.Tcherniaev: Redefined pascal (to avoid warnings on WinNT) +# 20.05.98 names: meter, second, gram, radian, degree +# (from Brian.Lasiuk@yale.edu (STAR)). Added luminous units. +# 05.08.98 angstrom, picobarn, microsecond, picosecond, petaelectronvolt +# 01.03.01 parsec +# ----- + +# +# Length [L] +# +millimeter = 1. +millimeter2 = millimeter*millimeter +millimeter3 = millimeter*millimeter*millimeter + +centimeter = 10.*millimeter +centimeter2 = centimeter*centimeter +centimeter3 = centimeter*centimeter*centimeter + +meter = 1000.*millimeter +meter2 = meter*meter +meter3 = meter*meter*meter + +kilometer = 1000.*meter +kilometer2 = kilometer*kilometer +kilometer3 = kilometer*kilometer*kilometer + +parsec = 3.0856775807e+16*meter + +micrometer = 1.e-6 *meter +nanometer = 1.e-9 *meter +angstrom = 1.e-10*meter +fermi = 1.e-15*meter + +barn = 1.e-28*meter2 +millibarn = 1.e-3 *barn +microbarn = 1.e-6 *barn +nanobarn = 1.e-9 *barn +picobarn = 1.e-12*barn + +# symbols +mm = millimeter +mm2 = millimeter2 +mm3 = millimeter3 + +cm = centimeter +cm2 = centimeter2 +cm3 = centimeter3 + +m = meter +m2 = meter2 +m3 = meter3 + +km = kilometer +km2 = kilometer2 +km3 = kilometer3 + +pc = parsec + +# +# Angle +# +radian = 1. +milliradian = 1.e-3*radian +degree = (3.14159265358979323846/180.0)*radian + +steradian = 1. + +# symbols +rad = radian +mrad = milliradian +sr = steradian +deg = degree + +# +# Time [T] +# +nanosecond = 1. +second = 1.e+9 *nanosecond +millisecond = 1.e-3 *second +microsecond = 1.e-6 *second +picosecond = 1.e-12*second +femtosecond = 1.e-15*second + +hertz = 1./second +kilohertz = 1.e+3*hertz +megahertz = 1.e+6*hertz + +# symbols +ns = nanosecond +s = second +ms = millisecond + +# +# Electric charge [Q] +# +eplus = 1. # positron charge +e_SI = 1.60217733e-19 # positron charge in coulomb +coulomb = eplus/e_SI # coulomb = 6.24150 e+18 * eplus + +# +# Energy [E] +# +megaelectronvolt = 1. +electronvolt = 1.e-6*megaelectronvolt +kiloelectronvolt = 1.e-3*megaelectronvolt +gigaelectronvolt = 1.e+3*megaelectronvolt +teraelectronvolt = 1.e+6*megaelectronvolt +petaelectronvolt = 1.e+9*megaelectronvolt + +joule = electronvolt/e_SI # joule = 6.24150 e+12 * MeV + +# symbols +MeV = megaelectronvolt +eV = electronvolt +keV = kiloelectronvolt +GeV = gigaelectronvolt +TeV = teraelectronvolt +PeV = petaelectronvolt + +# +# Mass [E][T^2][L^-2] +# +kilogram = joule*second*second/(meter*meter) +gram = 1.e-3*kilogram +milligram = 1.e-3*gram + +# symbols +kg = kilogram +g = gram +mg = milligram + +# +# Power [E][T^-1] +# +watt = joule/second # watt = 6.24150 e+3 * MeV/ns + +# +# Force [E][L^-1] +# +newton = joule/meter # newton = 6.24150 e+9 * MeV/mm + +# +# Pressure [E][L^-3] +# +hep_pascal = newton/m2 # pascal = 6.24150 e+3 * MeV/mm3 +pascal = hep_pascal # a trick to avoid warnings +bar = 100000*pascal # bar = 6.24150 e+8 * MeV/mm3 +atmosphere = 101325*pascal # atm = 6.32420 e+8 * MeV/mm3 + +# +# Electric current [Q][T^-1] +# +ampere = coulomb/second # ampere = 6.24150 e+9 * eplus/ns +milliampere = 1.e-3*ampere +microampere = 1.e-6*ampere +nanoampere = 1.e-9*ampere + +# +# Electric potential [E][Q^-1] +# +megavolt = megaelectronvolt/eplus +kilovolt = 1.e-3*megavolt +volt = 1.e-6*megavolt + +# +# Electric resistance [E][T][Q^-2] +# +ohm = volt/ampere # ohm = 1.60217e-16*(MeV/eplus)/(eplus/ns) + +# +# Electric capacitance [Q^2][E^-1] +# +farad = coulomb/volt # farad = 6.24150e+24 * eplus/Megavolt +millifarad = 1.e-3*farad +microfarad = 1.e-6*farad +nanofarad = 1.e-9*farad +picofarad = 1.e-12*farad + +# +# Magnetic Flux [T][E][Q^-1] +# +weber = volt*second # weber = 1000*megavolt*ns + +# +# Magnetic Field [T][E][Q^-1][L^-2] +# +tesla = volt*second/meter2 # tesla =0.001*megavolt*ns/mm2 + +gauss = 1.e-4*tesla +kilogauss = 1.e-1*tesla + +# +# Inductance [T^2][E][Q^-2] +# +henry = weber/ampere # henry = 1.60217e-7*MeV*(ns/eplus)**2 + +# +# Temperature +# +kelvin = 1. + +# +# Amount of substance +# +mole = 1. + +# +# Activity [T^-1] +# +becquerel = 1./second +curie = 3.7e+10 * becquerel + +# +# Absorbed dose [L^2][T^-2] +# +gray = joule/kilogram + +# +# Luminous intensity [I] +# +candela = 1. + +# +# Luminous flux [I] +# +lumen = candela*steradian + +# +# Illuminance [I][L^-2] +# +lux = lumen/meter2 + +# +# Miscellaneous +# +perCent = 0.01 +perThousand = 0.001 +perMillion = 0.000001 diff --git a/DDG4/src/ComponentProperties.cpp b/DDG4/src/ComponentProperties.cpp index 240170a093506e72042337508b8b6a21a9877795..eae34d214c1bc276650530b1a5f6107967a60336 100644 --- a/DDG4/src/ComponentProperties.cpp +++ b/DDG4/src/ComponentProperties.cpp @@ -26,6 +26,13 @@ PropertyGrammar::PropertyGrammar() { PropertyGrammar::~PropertyGrammar() { } +/// Error callback on invalid conversion +void PropertyGrammar::invalidConversion(const string& value, const type_info& to) { + string to_name = typeinfoName(to); + throw unrelated_value_error(to, + "The Property data conversion of '" + value + "' to type " + to_name + " is not defined."); +} + /// Error callback on invalid conversion void PropertyGrammar::invalidConversion(const type_info& from, const type_info& to) { string to_name = typeinfoName(to); @@ -113,6 +120,12 @@ PropertyManager::~PropertyManager() { m_properties.clear(); } +/// Check for existence +bool PropertyManager::exists(const std::string& name) const { + Properties::const_iterator i = m_properties.find(name); + return i != m_properties.end(); +} + /// Verify that this property does not exist (throw exception if the name was found) void PropertyManager::verifyNonExistence(const string& name) const { Properties::const_iterator i = m_properties.find(name); diff --git a/DDG4/src/ComponentUtils.cpp b/DDG4/src/ComponentUtils.cpp index 1e57eb0493d1b53b8c697d6e284afa03d50e2b32..f7007fcd2a03283c71695942563e8d8f0a9e60ba 100644 --- a/DDG4/src/ComponentUtils.cpp +++ b/DDG4/src/ComponentUtils.cpp @@ -171,6 +171,11 @@ string unrelated_type_error::msg(const std::type_info& typ1, const std::type_inf return m; } +string unrelated_value_error::msg(const std::type_info& typ, const string& text) { + std::string m = "The type " + __typename(typ.name()) + " cannot be converted: " + text; + return m; +} + /// Initializing Constructor ComponentCast::ComponentCast(const std::type_info& t, destroy_t d, cast_t c) : type(t), destroy(d), cast(c) { diff --git a/DDG4/src/Geant4Action.cpp b/DDG4/src/Geant4Action.cpp index 0f994289c48c21d25e145581baa59cd6d2fcf92a..f2c8617bb315a3e4844494dfa1407fc2ff7d4f27 100644 --- a/DDG4/src/Geant4Action.cpp +++ b/DDG4/src/Geant4Action.cpp @@ -70,7 +70,10 @@ long Geant4Action::addRef() { long Geant4Action::release() { long count = --m_refCount; if (m_refCount <= 0) { - cout << "Geant4Action: Deleting object " << name() << " of type " << typeinfoName(typeid(*this)) << endl; + cout << "Geant4Action: Deleting object " << name() + << " of type " << typeinfoName(typeid(*this)) + << " Ptr:" << (void*)this + << endl; delete this; } return count; @@ -87,6 +90,16 @@ Geant4Action& Geant4Action::setProperties(PropertyConfigurator& setup) { return *this; } +/// Check property for existence +bool Geant4Action::hasProperty(const std::string& name) const { + return m_properties.exists(name); +} + +/// Access single property +Property& Geant4Action::property(const std::string& name) { + return properties()[name]; +} + /// Install all control messenger if wanted void Geant4Action::installMessengers() { //m_needsControl = true; @@ -95,6 +108,7 @@ void Geant4Action::installMessengers() { path += name() + "/"; m_control = new Geant4UIMessenger(name(), path); installPropertyMessenger(); + installCommandMessenger(); } } @@ -103,6 +117,25 @@ void Geant4Action::installPropertyMessenger() { m_control->exportProperties(m_properties); } +/// Install command control messenger if wanted +void Geant4Action::installCommandMessenger() { +} + +/// Access to the UI messenger +Geant4UIMessenger* Geant4Action::control() const { + if ( m_control ) { + return m_control; + } + except("No control was installed for this action item."); + return 0; +} + +/// Enable and install UI messenger +void Geant4Action::enableUI() { + m_needsControl = true; + installMessengers(); +} + /// Support of debug messages. void Geant4Action::debug(const string& fmt, ...) const { va_list args; diff --git a/DDG4/src/Geant4Handle.cpp b/DDG4/src/Geant4Handle.cpp index 874087e53196fd796ff9f9d25deffcc434e560a1..aa7963cac9e8e6a3ca6afa147ff7cd929562f8d0 100644 --- a/DDG4/src/Geant4Handle.cpp +++ b/DDG4/src/Geant4Handle.cpp @@ -93,6 +93,12 @@ template <typename TYPE> Geant4Handle<TYPE>::~Geant4Handle() { value = 0; } +template <typename TYPE> TYPE* Geant4Handle<TYPE>::release() { + TYPE* temp = value; + value = 0; + return temp; +} + template <typename TYPE> void Geant4Handle<TYPE>::checked_assign(TYPE* p) { if (value) value->release(); @@ -122,6 +128,10 @@ template <typename TYPE> TYPE* Geant4Handle<TYPE>::operator->() const { return checked_value(value); } +template <typename TYPE> Geant4Action* Geant4Handle<TYPE>::action() const { + return checked_value(value); +} + template <typename TYPE> Geant4Handle<TYPE>& Geant4Handle<TYPE>::operator=(Geant4Handle& handle) { if (value) value->release(); @@ -143,6 +153,14 @@ template <typename TYPE> Geant4Handle<TYPE>& Geant4Handle<TYPE>::operator=(TYPE* namespace DD4hep { namespace Simulation { + KernelHandle::KernelHandle() { + value = &Geant4Kernel::instance(Geometry::LCDD::getInstance()); + } + void KernelHandle::destroy() { + if ( value ) delete value; + value = 0; + } + template <> Geant4Handle<Geant4Sensitive>::Geant4Handle(const Geant4Kernel& kernel, const string& type_name, const string& detector) { try { diff --git a/DDG4/src/Geant4Kernel.cpp b/DDG4/src/Geant4Kernel.cpp index 7c9607cd6056431c6f0a2e8e79ac64c9a295903f..08016760d5631562e86245268dfc2567e77074bd 100644 --- a/DDG4/src/Geant4Kernel.cpp +++ b/DDG4/src/Geant4Kernel.cpp @@ -202,7 +202,7 @@ Geant4Action* Geant4Kernel::globalAction(const std::string& action_name, bool th GlobalActions::iterator i = m_globalActions.find(action_name); if (i == m_globalActions.end()) { if (throw_if_not_present) { - throw runtime_error(format("Geant4Kernel", "DDG4: The action '%s' is not already globally " + throw runtime_error(format("Geant4Kernel", "DDG4: The action '%s' is not globally " "registered. [Action-Missing]", action_name.c_str())); } return 0; diff --git a/DDG4/src/Geant4PhysicsList.cpp b/DDG4/src/Geant4PhysicsList.cpp index 410e65d146a89da88e00d85a3ecd60ce02a21985..c7a428887875458551c44c7307b4dddab70f4c71 100644 --- a/DDG4/src/Geant4PhysicsList.cpp +++ b/DDG4/src/Geant4PhysicsList.cpp @@ -9,6 +9,7 @@ // Framework include files #include "DDG4/Geant4PhysicsList.h" +#include "DDG4/Geant4UIMessenger.h" #include "DD4hep/InstanceCount.h" #include "DD4hep/Printout.h" #include "DD4hep/Plugins.h" @@ -96,6 +97,55 @@ Geant4PhysicsList::~Geant4PhysicsList() { InstanceCount::decrement(this); } +/// Install command control messenger if wanted +void Geant4PhysicsList::installCommandMessenger() { + control()->addCall("dump", "Dump content of " + name(), Callback(this).make(&Geant4PhysicsList::dump)); +} + +/// Dump content to stdout +void Geant4PhysicsList::dump() { + printout(ALWAYS,name(),"+++ Geant4PhysicsList Dump"); + for (PhysicsConstructors::const_iterator i = m_physics.begin(); i != m_physics.end(); ++i) + printout(ALWAYS,name(),"+++ PhysicsConstructor: %s",(*i).c_str()); + for (ParticleConstructors::const_iterator i = m_particles.begin(); i != m_particles.end(); ++i) + printout(ALWAYS,name(),"+++ ParticleConstructor: %s",(*i).c_str()); + for (PhysicsProcesses::const_iterator i = m_processes.begin(); i != m_processes.end(); ++i) { + const string& part_name = (*i).first; + const ParticleProcesses& procs = (*i).second; + printout(ALWAYS,name(),"+++ PhysicsProcesses of particle %s",part_name.c_str()); + for (ParticleProcesses::const_iterator ip = procs.begin(); ip != procs.end(); ++ip) { + const Process& p = (*ip); + printout(ALWAYS,name(),"+++ Process %s ordAtRestDoIt=%d ordAlongSteptDoIt=%d ordPostStepDoIt=%d", + p.name.c_str(),p.ordAtRestDoIt,p.ordAlongSteptDoIt,p.ordPostStepDoIt); + } + } +} + +/// Add physics particle constructor by name +void Geant4PhysicsList::addParticleConstructor(const std::string& part_name) { + particles().push_back(part_name); +} + +/// Add particle process by name with arguments +void Geant4PhysicsList::addParticleProcess(const std::string& part_name, + const std::string& proc_name, + int ordAtRestDoIt, + int ordAlongSteptDoIt, + int ordPostStepDoIt) +{ + Process p; + p.name = proc_name; + p.ordAtRestDoIt = ordAtRestDoIt; + p.ordAlongSteptDoIt = ordAlongSteptDoIt; + p.ordPostStepDoIt = ordPostStepDoIt; + processes(part_name).push_back(p); +} + +/// Add PhysicsConstructor by name +void Geant4PhysicsList::addPhysicsConstructor(const std::string& phys_name) { + physics().push_back(phys_name); +} + /// Access processes for one particle type Geant4PhysicsList::ParticleProcesses& Geant4PhysicsList::processes(const string& nam) { PhysicsProcesses::iterator i = m_processes.find(nam); @@ -203,6 +253,20 @@ Geant4PhysicsListActionSequence::~Geant4PhysicsListActionSequence() { InstanceCount::decrement(this); } +/// Install command control messenger if wanted +void Geant4PhysicsListActionSequence::installCommandMessenger() { + control()->addCall("dump", "Dump content of " + name(), Callback(this).make(&Geant4PhysicsListActionSequence::dump)); +} + +/// Dump content to stdout +void Geant4PhysicsListActionSequence::dump() { + printout(ALWAYS,name(),"+++ Dump"); + printout(ALWAYS,name(),"+++ Extension name %s",m_extends.c_str()); + printout(ALWAYS,name(),"+++ Transportation flag: %d",m_transportation); + printout(ALWAYS,name(),"+++ Program decays: %d",m_decays); + m_actors(&Geant4PhysicsList::dump); +} + /// Add an actor responding to all callbacks. Sequence takes ownership. void Geant4PhysicsListActionSequence::adopt(Geant4PhysicsList* action) { if (action) { diff --git a/DDG4/src/Geant4SensDetAction.cpp b/DDG4/src/Geant4SensDetAction.cpp index 3f7311612dd5c933142e8e60d505eac3791009ed..0350b3e855b033f553f9a5be076babccdc1938a9 100644 --- a/DDG4/src/Geant4SensDetAction.cpp +++ b/DDG4/src/Geant4SensDetAction.cpp @@ -82,9 +82,9 @@ Geant4Sensitive::Geant4Sensitive(Geant4Context* ctxt, const string& name, DetEle if (!det.isValid()) { throw runtime_error(format("Geant4Sensitive", "DDG4: Detector elemnt for %s is invalid.", name.c_str())); } - m_sequence = ctxt->kernel().sensitiveAction(m_detector.name()); + m_sequence = ctxt->kernel().sensitiveAction(m_detector.name()); m_sensitive = lcdd.sensitiveDetector(det.name()); - m_readout = m_sensitive.readout(); + m_readout = m_sensitive.readout(); } /// Standard destructor @@ -94,6 +94,12 @@ Geant4Sensitive::~Geant4Sensitive() { InstanceCount::decrement(this); } +/// Add an actor responding to all callbacks. Sequence takes ownership. +void Geant4Sensitive::adoptFilter(Geant4Action* action) { + Geant4Filter* filter = dynamic_cast<Geant4Filter*>(action); + adopt(filter); +} + /// Add an actor responding to all callbacks. Sequence takes ownership. void Geant4Sensitive::adopt(Geant4Filter* filter) { if (filter) { @@ -175,6 +181,9 @@ Geant4SensDetActionSequence::Geant4SensDetActionSequence(Geant4Context* context, : Geant4Action(context, nam), m_hce(0) { m_needsControl = true; context->sensitiveActions().insert(name(), this); + /// Update the sensitive detector type, so that the proper instance is created + Geometry::SensitiveDetector sd = context->lcdd().sensitiveDetector(nam); + sd.setType("Geant4SensDet"); InstanceCount::increment(this); } @@ -187,6 +196,12 @@ Geant4SensDetActionSequence::~Geant4SensDetActionSequence() { InstanceCount::decrement(this); } +/// Add an actor responding to all callbacks. Sequence takes ownership. +void Geant4SensDetActionSequence::adoptFilter(Geant4Action* action) { + Geant4Filter* filter = dynamic_cast<Geant4Filter*>(action); + adopt(filter); +} + /// Add an actor responding to all callbacks void Geant4SensDetActionSequence::adopt(Geant4Sensitive* sensitive) { if (sensitive) { @@ -349,3 +364,7 @@ void Geant4SensDetSequences::insert(const string& name, Geant4SensDetActionSeque "sequence with name:%s", name.c_str())); } +/// Clear the sequence list +void Geant4SensDetSequences::clear() { + m_sequences.clear(); +}