diff --git a/DDG4/examples/physics.xml b/DDG4/examples/physics.xml index 0aa910f4dc73feb8099a78ad44bbb37587805075..3c9a206183e0c43db4e46ec5b5c41c4c9466e641 100644 --- a/DDG4/examples/physics.xml +++ b/DDG4/examples/physics.xml @@ -10,31 +10,26 @@ --> <sequences> - <sequence name="Geant4PhysicsListSequence/PhysicsList"/> - </sequences> + <sequence name="Geant4PhysicsListSequence/PhysicsList" decays="true" extends="FTFP_BERT"/> - <physicslist name="Geant4PhysicsList/MyPhysics.0"> - <extends name="QGSP_BERT"/> - <particles> - <construct name="G4Geantino"/> - <construct name="G4ChargedGeantino"/> - <construct name="G4Electron"/> - <construct name="G4Gamma"/> - <construct name="G4BosonConstructor"/> - <construct name="G4LeptonConstructor"/> - <construct name="G4MesonConstructor"/> - <construct name="G4BaryonConstructor"/> - </particles> - </physicslist> <!-- - <sequences> - // No transportation nor decays if you are already extending an existing physics list! - <sequence name="Geant4PhysicsListSequence/PhysicsList" transportation="true" decays="true" extends="QGSP_BERT"/> - </sequences> + <physicslist name="Geant4PhysicsList/MyPhysics.0" decays="true"> + <extends name="FTFP_BERT"/> + <particles> + <construct name="G4BosonConstructor"/> + <construct name="G4LeptonConstructor"/> + </particles> + <processes> + <particle name="e[+-]" cut="0.001*mm"> + <process name="G4eMultipleScattering" ordAtRestDoIt="-1" ordAlongSteptDoIt="1" ordPostStepDoIt="1"/> + <process name="G4eIonisation" ordAtRestDoIt="-1" ordAlongSteptDoIt="2" ordPostStepDoIt="2"/> + </particle> + </processes> + </physicslist> --> - <!-- - + </sequences> + <!-- <physicslist name="Geant4PhysicsList/MyPhysics.0"> diff --git a/DDG4/examples/sequences.xml b/DDG4/examples/sequences.xml index 909624ab8899c755d3444784578a542a0145127f..363520c5a21b87ec1250f0f974e021f3824ec5df 100644 --- a/DDG4/examples/sequences.xml +++ b/DDG4/examples/sequences.xml @@ -3,6 +3,17 @@ + <!-- Kernel parameters + -- UI="UI" is default, + -- + -- Note: + -- NumEvents is ignored in interactive sessions, but used + -- in batch mode without ui nor vis. + -- + -- To run batch: set UI="" + --> + <kernel UI="UI" NumEvents="1"/> + <!-- List of globally known actions. These actions will be registered with the Geant4Kernel -- object and may be retrieved by there using the action name. -- @@ -21,6 +32,15 @@ Property_double="5e15" Property_string="Hello_2"/> </action> + + <!-- UI handler initializing vis and ui. NAME IS FIXED/COMMON KNOWLEDGE --> + <action name="Geant4UIManager/UI"> + <properties HaveVIS="1" + HaveUI="1" + SessionType="csh"/> + </action> + <!-- void and empty for the time being.... NAME IS FIXED/COMMON KNOWLEDGE --> + <action name="Geant4DummyTruthHandler/MonteCarloTruthHandler"/> </actions> <!-- List of known phases. @@ -92,7 +112,7 @@ </sequence> <sequence name="Geant4GeneratorActionSequence/GeneratorAction"> <action name="Geant4ParticleGun/Gun"> - <properties energy="500*GeV" + <properties energy="500*MeV" particle="'e-'" multiplicity="1"/> </action> diff --git a/DDG4/include/DDG4/Geant4MonteCarloTruth.h b/DDG4/include/DDG4/Geant4MonteCarloTruth.h index cce5b1296496e994cf73504c5e264dc87afc2e10..bd1d90f2eecf3e8581022c201bc134c93ce6ea11 100644 --- a/DDG4/include/DDG4/Geant4MonteCarloTruth.h +++ b/DDG4/include/DDG4/Geant4MonteCarloTruth.h @@ -10,6 +10,7 @@ #define DD4HEP_DDG4_GEANT4MONTECARLOTRUTH_H // Framework include files +#include "DDG4/Geant4Action.h" // C/C++ include files @@ -51,6 +52,32 @@ namespace DD4hep { /// Store a track produced in a step to be kept for later MC truth analysis virtual void mark(const G4Step* step, bool created_hit) = 0; }; + + /** @class Geant4DummyTruthHandler Geant4DummyTruthHandler.h DDG4/Geant4DummyTruthHandler.h + * + * Void implementation doing nothing at all. + * + * @author M.Frank + * @version 1.0 + */ + class Geant4DummyTruthHandler : + public Geant4Action, public Geant4MonteCarloTruth + { + public: + /// Standard constructor + Geant4DummyTruthHandler(Geant4Context* ctxt,const std::string& nam); + /// Default destructor + virtual ~Geant4DummyTruthHandler(); + /// Mark a Geant4 track to be kept for later MC truth analysis + virtual void mark(const G4Track* track); + /// Store a track, with a flag + virtual void mark(const G4Track* track, bool created_hit); + /// Mark a Geant4 track of the step to be kept for later MC truth analysis + virtual void mark(const G4Step* step); + /// Store a track produced in a step to be kept for later MC truth analysis + virtual void mark(const G4Step* step, bool created_hit); + }; + } // End namespace Simulation } // End namespace DD4hep diff --git a/DDG4/plugins/Geant4Factories.cpp b/DDG4/plugins/Geant4Factories.cpp index 624eb7acb7bde2ce0d6adfc98cb59d8018c61363..f64104bfdd410b8f7589b0763ad376fdefe9b6a7 100644 --- a/DDG4/plugins/Geant4Factories.cpp +++ b/DDG4/plugins/Geant4Factories.cpp @@ -37,8 +37,12 @@ DECLARE_GEANT4ACTION(Geant4SensDetActionSequence) #include "DDG4/Geant4UIManager.h" DECLARE_GEANT4ACTION(Geant4UIManager) +#include "DDG4/Geant4MonteCarloTruth.h" +DECLARE_GEANT4ACTION(Geant4DummyTruthHandler) + #include "DDG4/Geant4TrackPersistency.h" DECLARE_GEANT4ACTION(Geant4TrackPersistency) + #include "DDG4/Geant4MonteCarloRecordManager.h" DECLARE_GEANT4ACTION(Geant4MonteCarloRecordManager) diff --git a/DDG4/plugins/Geant4SDActions.cpp b/DDG4/plugins/Geant4SDActions.cpp index d529b5d8eb162b661e157b5d6c615288ad58b5eb..02929b0a0e77cdcc7c77a674d1976be445f55d58 100644 --- a/DDG4/plugins/Geant4SDActions.cpp +++ b/DDG4/plugins/Geant4SDActions.cpp @@ -132,7 +132,7 @@ namespace DD4hep { double new_len = mean_length(h.preMom(),h.postMom())/hit_len; direction *= new_len/hit_len; } - printout(INFO,"SimpleTracker","%s> Add hit with deposit:%f Pos:%f %f %f", + printout(DEBUG,"SimpleTracker","%s> Add hit with deposit:%f Pos:%f %f %f", c_name(),step->GetTotalEnergyDeposit(),position.X(),position.Y(),position.Z()); Hit* hit = new Hit(h.track->GetTrackID(), h.track->GetDefinition()->GetPDGEncoding(), @@ -171,11 +171,11 @@ namespace DD4hep { hit = new Hit(pos) ; hit->cellID = volumeID( step ) ; coll->add(hit) ; - printout(INFO,"SimpleTracker","%s> CREATE hit with deposit:%f Pos:%f %f %f", + printout(DEBUG,"SimpleTracker","%s> CREATE hit with deposit:%f Pos:%f %f %f", c_name(),contrib.deposit,pos.X(),pos.Y(),pos.Z()); } else { - printout(INFO,"SimpleTracker","%s> UPDATE hit with deposit:%f Pos:%f %f %f", + printout(DEBUG,"SimpleTracker","%s> UPDATE hit with deposit:%f Pos:%f %f %f", c_name(),contrib.deposit,pos.X(),pos.Y(),pos.Z()); } hit->truth.push_back(contrib); diff --git a/DDG4/plugins/Geant4XMLSetup.cpp b/DDG4/plugins/Geant4XMLSetup.cpp index 4b612987b9a7d78df54475f51d091df699dea634..fa182a966ac00a2f3501e2dc951446c2340740be 100644 --- a/DDG4/plugins/Geant4XMLSetup.cpp +++ b/DDG4/plugins/Geant4XMLSetup.cpp @@ -407,10 +407,20 @@ namespace DD4hep { kernel.physicsList().adopt(handle); } + template <> void Converter<Kernel>::operator()(xml_h e) const { + Kernel& kernel = Kernel::access(lcdd); + xml_comp_t k(e); + if ( k.hasAttr(_Unicode(NumEvents)) ) + kernel.property("NumEvents").str(k.attr<string>(_Unicode(NumEvents))); + if ( k.hasAttr(_Unicode(UI)) ) + kernel.property("UI").str(k.attr<string>(_Unicode(UI))); + } + template <> void Converter<XMLSetup>::operator()(xml_h seq) const { xml_elt_t compact(seq); // First execute the basic setup from the plugins module ROOT::Reflex::PluginService::Create<TNamed*>("geant4_xml_setup",&lcdd,&seq); + xml_coll_t(compact,_Unicode(kernel)).for_each(Converter<Kernel>(lcdd,param)); // Now deal with the new stuff..... xml_coll_t(compact,_Unicode(actions) ).for_each(_Unicode(action),Converter<Action>(lcdd,param)); xml_coll_t(compact,_Unicode(filters) ).for_each(_Unicode(filter),Converter<Filter>(lcdd,param)); diff --git a/DDG4/src/Geant4Kernel.cpp b/DDG4/src/Geant4Kernel.cpp index 3cab6f7e74e8a9ec6e79a971e0553b613da8460a..cd3d71dbbabf196d2a3ed6aef9ce58bf1a4690fe 100644 --- a/DDG4/src/Geant4Kernel.cpp +++ b/DDG4/src/Geant4Kernel.cpp @@ -98,8 +98,10 @@ Geant4Kernel::~Geant4Kernel() { for_each(m_globalFilters.begin(), m_globalFilters.end(), releaseObjects(m_globalFilters)); for_each(m_globalActions.begin(), m_globalActions.end(), releaseObjects(m_globalActions)); deletePtr (m_runManager); - deletePtr (m_mcTruthMgr); - releasePtr (m_mcRecordMgr); + m_mcTruthMgr = 0; + m_mcRecordMgr = 0; // These are already released by the global actions.... + //deletePtr (m_mcTruthMgr); + //releasePtr (m_mcRecordMgr); releasePtr (m_physicsList); releasePtr (m_stackingAction); releasePtr (m_steppingAction); @@ -181,8 +183,10 @@ void Geant4Kernel::terminate() { for_each(m_globalFilters.begin(), m_globalFilters.end(), releaseObjects(m_globalFilters)); for_each(m_globalActions.begin(), m_globalActions.end(), releaseObjects(m_globalActions)); deletePtr (m_runManager); - deletePtr (m_mcTruthMgr); - releasePtr (m_mcRecordMgr); + m_mcTruthMgr = 0; + m_mcRecordMgr = 0; // These are already released by the global actions.... + //deletePtr (m_mcTruthMgr); + //releasePtr (m_mcRecordMgr); releasePtr (m_physicsList); releasePtr (m_stackingAction); releasePtr (m_steppingAction); diff --git a/DDG4/src/Geant4MonteCarloTruth.cpp b/DDG4/src/Geant4MonteCarloTruth.cpp index b597e40c3f201bb92c5d50051b374b09fd0fc405..2dad969fda58333a4ce3dcc18014fefc75e57c7a 100644 --- a/DDG4/src/Geant4MonteCarloTruth.cpp +++ b/DDG4/src/Geant4MonteCarloTruth.cpp @@ -22,3 +22,30 @@ Geant4MonteCarloTruth::Geant4MonteCarloTruth() { Geant4MonteCarloTruth::~Geant4MonteCarloTruth() { InstanceCount::decrement(this); } + +/// Standard constructor +Geant4DummyTruthHandler::Geant4DummyTruthHandler(Geant4Context* ctxt,const std::string& nam) : Geant4Action(ctxt,nam), Geant4MonteCarloTruth() +{ +} + +/// Default destructor +Geant4DummyTruthHandler::~Geant4DummyTruthHandler() +{ +} + +/// Mark a Geant4 track to be kept for later MC truth analysis +void Geant4DummyTruthHandler::mark(const G4Track* ) { +} + +/// Store a track, with a flag +void Geant4DummyTruthHandler::mark(const G4Track* , bool ) { +} + +/// Mark a Geant4 track of the step to be kept for later MC truth analysis +void Geant4DummyTruthHandler::mark(const G4Step* ) { +} + +/// Store a track produced in a step to be kept for later MC truth analysis +void Geant4DummyTruthHandler::mark(const G4Step* , bool ) { +} +