diff --git a/DDG4/plugins/Geant4.10.PhysicsConstructors.h b/DDG4/plugins/Geant4.10.PhysicsConstructors.h index cb68d68dfb1fea484855c10b6ceac7fad1b1598b..c334f6fe938eda64eb47da4a4d0779ccb2814070 100644 --- a/DDG4/plugins/Geant4.10.PhysicsConstructors.h +++ b/DDG4/plugins/Geant4.10.PhysicsConstructors.h @@ -15,100 +15,100 @@ //========================================================================== // EM physics -#include "G4EmStandardPhysics_option1.hh" +#include <G4EmStandardPhysics_option1.hh> DECLARE_GEANT4_PHYSICS(G4EmStandardPhysics_option1) -#include "G4EmStandardPhysics_option2.hh" +#include <G4EmStandardPhysics_option2.hh> DECLARE_GEANT4_PHYSICS(G4EmStandardPhysics_option2) -#include "G4EmStandardPhysics_option3.hh" +#include <G4EmStandardPhysics_option3.hh> DECLARE_GEANT4_PHYSICS(G4EmStandardPhysics_option3) -#include "G4EmStandardPhysics.hh" +#include <G4EmStandardPhysics.hh> DECLARE_GEANT4_PHYSICS(G4EmStandardPhysics) -#include "G4EmStandardPhysicsSS.hh" +#include <G4EmStandardPhysicsSS.hh> DECLARE_GEANT4_PHYSICS(G4EmStandardPhysicsSS) -#include "G4EmStandardPhysicsWVI.hh" +#include <G4EmStandardPhysicsWVI.hh> DECLARE_GEANT4_PHYSICS(G4EmStandardPhysicsWVI) -#include "G4EmExtraPhysics.hh" +#include <G4EmExtraPhysics.hh> DECLARE_GEANT4_PHYSICS(G4EmExtraPhysics) -#include "G4EmDNAPhysics.hh" +#include <G4EmDNAPhysics.hh> DECLARE_GEANT4_PHYSICS(G4EmDNAPhysics) -#include "G4EmLowEPPhysics.hh" +#include <G4EmLowEPPhysics.hh> DECLARE_GEANT4_PHYSICS(G4EmLowEPPhysics) -#include "G4EmLivermorePhysics.hh" +#include <G4EmLivermorePhysics.hh> DECLARE_GEANT4_PHYSICS(G4EmLivermorePhysics) -#include "G4ChargeExchangePhysics.hh" +#include <G4ChargeExchangePhysics.hh> DECLARE_GEANT4_PHYSICS(G4ChargeExchangePhysics) -#include "G4GenericBiasingPhysics.hh" +#include <G4GenericBiasingPhysics.hh> DECLARE_GEANT4_PHYSICS(G4GenericBiasingPhysics) -#include "G4HadronDElasticPhysics.hh" +#include <G4HadronDElasticPhysics.hh> DECLARE_GEANT4_PHYSICS(G4HadronDElasticPhysics) -#include "G4HadronElasticPhysics.hh" +#include <G4HadronElasticPhysics.hh> DECLARE_GEANT4_PHYSICS(G4HadronElasticPhysics) -#include "G4HadronElasticPhysicsHP.hh" +#include <G4HadronElasticPhysicsHP.hh> DECLARE_GEANT4_PHYSICS(G4HadronElasticPhysicsHP) -#include "G4HadronElasticPhysicsLEND.hh" +#include <G4HadronElasticPhysicsLEND.hh> DECLARE_GEANT4_PHYSICS(G4HadronElasticPhysicsLEND) -#include "G4HadronElasticPhysicsPHP.hh" +#include <G4HadronElasticPhysicsPHP.hh> DECLARE_GEANT4_PHYSICS(G4HadronElasticPhysicsPHP) -#include "G4HadronElasticPhysicsXS.hh" +#include <G4HadronElasticPhysicsXS.hh> DECLARE_GEANT4_PHYSICS(G4HadronElasticPhysicsXS) -#include "G4HadronHElasticPhysics.hh" +#include <G4HadronHElasticPhysics.hh> DECLARE_GEANT4_PHYSICS(G4HadronHElasticPhysics) -#include "G4HadronPhysicsFTF_BIC.hh" +#include <G4HadronPhysicsFTF_BIC.hh> DECLARE_GEANT4_PHYSICS(G4HadronPhysicsFTF_BIC) -#include "G4HadronPhysicsFTFP_BERT.hh" +#include <G4HadronPhysicsFTFP_BERT.hh> DECLARE_GEANT4_PHYSICS(G4HadronPhysicsFTFP_BERT) -#include "G4HadronPhysicsFTFP_BERT_HP.hh" +#include <G4HadronPhysicsFTFP_BERT_HP.hh> DECLARE_GEANT4_PHYSICS(G4HadronPhysicsFTFP_BERT_HP) -#include "G4HadronPhysicsFTFP_BERT_TRV.hh" +#include <G4HadronPhysicsFTFP_BERT_TRV.hh> DECLARE_GEANT4_PHYSICS(G4HadronPhysicsFTFP_BERT_TRV) -#include "G4HadronPhysicsINCLXX.hh" +#include <G4HadronPhysicsINCLXX.hh> DECLARE_GEANT4_PHYSICS(G4HadronPhysicsINCLXX) -#include "G4HadronPhysicsNuBeam.hh" +#include <G4HadronPhysicsNuBeam.hh> DECLARE_GEANT4_PHYSICS(G4HadronPhysicsNuBeam) -#include "G4HadronPhysicsQGS_BIC.hh" +#include <G4HadronPhysicsQGS_BIC.hh> DECLARE_GEANT4_PHYSICS(G4HadronPhysicsQGS_BIC) -#include "G4HadronPhysicsQGSP_BERT.hh" +#include <G4HadronPhysicsQGSP_BERT.hh> DECLARE_GEANT4_PHYSICS(G4HadronPhysicsQGSP_BERT) -#include "G4HadronPhysicsQGSP_BERT_HP.hh" +#include <G4HadronPhysicsQGSP_BERT_HP.hh> DECLARE_GEANT4_PHYSICS(G4HadronPhysicsQGSP_BERT_HP) -#include "G4HadronPhysicsQGSP_BIC_AllHP.hh" +#include <G4HadronPhysicsQGSP_BIC_AllHP.hh> DECLARE_GEANT4_PHYSICS(G4HadronPhysicsQGSP_BIC_AllHP) -#include "G4HadronPhysicsQGSP_FTFP_BERT.hh" +#include <G4HadronPhysicsQGSP_FTFP_BERT.hh> DECLARE_GEANT4_PHYSICS(G4HadronPhysicsQGSP_FTFP_BERT) -#include "G4HadronPhysicsShielding.hh" +#include <G4HadronPhysicsShielding.hh> DECLARE_GEANT4_PHYSICS(G4HadronPhysicsShielding) // Ion and hadrons -#include "G4IonBinaryCascadePhysics.hh" +#include <G4IonBinaryCascadePhysics.hh> DECLARE_GEANT4_PHYSICS(G4IonBinaryCascadePhysics) -#include "G4IonElasticPhysics.hh" +#include <G4IonElasticPhysics.hh> DECLARE_GEANT4_PHYSICS(G4IonElasticPhysics) -#include "G4IonINCLXXPhysics.hh" +#include <G4IonINCLXXPhysics.hh> DECLARE_GEANT4_PHYSICS(G4IonINCLXXPhysics) -#include "G4IonPhysics.hh" +#include <G4IonPhysics.hh> DECLARE_GEANT4_PHYSICS(G4IonPhysics) -#include "G4IonQMDPhysics.hh" +#include <G4IonQMDPhysics.hh> DECLARE_GEANT4_PHYSICS(G4IonQMDPhysics) -#include "G4RadioactiveDecayPhysics.hh" +#include <G4RadioactiveDecayPhysics.hh> DECLARE_GEANT4_PHYSICS(G4RadioactiveDecayPhysics) -#include "G4StepLimiterPhysics.hh" +#include <G4StepLimiterPhysics.hh> DECLARE_GEANT4_PHYSICS(G4StepLimiterPhysics) -#include "G4StoppingPhysics.hh" +#include <G4StoppingPhysics.hh> DECLARE_GEANT4_PHYSICS(G4StoppingPhysics) -#include "G4NeutronTrackingCut.hh" +#include <G4NeutronTrackingCut.hh> DECLARE_GEANT4_PHYSICS(G4NeutronTrackingCut) // Optical physics -#include "G4OpticalPhysics.hh" +#include <G4OpticalPhysics.hh> DECLARE_GEANT4_PHYSICS(G4OpticalPhysics) // Fast simulation -#include "G4FastSimulationPhysics.hh" +#include <G4FastSimulationPhysics.hh> DECLARE_GEANT4_PHYSICS(G4FastSimulationPhysics) #endif diff --git a/DDG4/plugins/Geant4FastPhysics.cpp b/DDG4/plugins/Geant4FastPhysics.cpp index dd4e8c6792531688e367be2c170441c7991ab64c..31ee544a4a64bb7530bf937e7cbb3ce372b18d74 100644 --- a/DDG4/plugins/Geant4FastPhysics.cpp +++ b/DDG4/plugins/Geant4FastPhysics.cpp @@ -14,7 +14,7 @@ #define DDG4_GEANT4FASTPHYSICS_H // Framework include files -#include <DDG4/Geant4PhysicsList.h> +#include <DDG4/Geant4Action.h> // Geant4 include files #include <G4FastSimulationPhysics.hh> @@ -28,8 +28,6 @@ namespace dd4hep { /// Namespace for the Geant4 based simulation part of the AIDA detector description toolkit namespace sim { - class Geant4InputAction; - /// Wrapper for G4FastSimulationPhysics with properties /** * Wrapper for G4FastSimulationPhysics with properties. @@ -48,13 +46,15 @@ namespace dd4hep { /// Vector of particle names for which fast simulation is enabled std::vector<std::string> m_enabledParticles; + /// Property to set verbosity flag on G4FastSimulationPhysics + bool m_verbose { false }; public: /// Standard constructor Geant4FastPhysics(Geant4Context* context, const std::string& nam); /// Default destructor - virtual ~Geant4FastPhysics(); + virtual ~Geant4FastPhysics() = default; /// This method will be invoked in the Construct() method. virtual void ConstructProcess() override; @@ -87,20 +87,20 @@ Geant4FastPhysics::Geant4FastPhysics(Geant4Context* ctxt, const std::string& nam : Geant4Action(ctxt, nam), G4FastSimulationPhysics() { declareProperty("EnabledParticles", m_enabledParticles); + declareProperty("BeVerbose", m_verbose); } -/// Default destructor -Geant4FastPhysics::~Geant4FastPhysics() { -} - - /// This method will be invoked in the Construct() method. void Geant4FastPhysics::ConstructProcess() { + if ( this->m_verbose ) this->BeVerbose(); + for( const auto& part_name : m_enabledParticles ) { + this->info("Enable fast simulation for particle type: %s", part_name.c_str()); + this->ActivateFastSimulation(part_name); + } // -- Create a fast simulation physics constructor, used to augment // -- the above physics list to allow for fast simulation this->G4FastSimulationPhysics::ConstructProcess(); - for( const auto& part_name : m_enabledParticles ) - this->ActivateFastSimulation(part_name); + this->info("Constructed and initialized Geant4 Fast Physics."); } #include "DDG4/Factories.h" diff --git a/DDG4/plugins/Geant4FieldTrackingSetup.cpp b/DDG4/plugins/Geant4FieldTrackingSetup.cpp index 3aef6274d51eb04b0d35eab0b00715bffd7b9a2c..0c153099a5d43bb1f4c88044677bb77afb91c983 100644 --- a/DDG4/plugins/Geant4FieldTrackingSetup.cpp +++ b/DDG4/plugins/Geant4FieldTrackingSetup.cpp @@ -15,9 +15,9 @@ #define DD4HEP_DDG4_GEANT4FIELDTRACKINGSETUP_H 1 // Framework include files -#include "DD4hep/Detector.h" -#include "DDG4/Geant4ActionPhase.h" -#include "DDG4/Geant4DetectorConstruction.h" +#include <DD4hep/Detector.h> +#include <DDG4/Geant4ActionPhase.h> +#include <DDG4/Geant4DetectorConstruction.h> /// Namespace for the AIDA detector description toolkit namespace dd4hep { @@ -134,17 +134,17 @@ namespace dd4hep { //========================================================================== // Framework include files -#include "DD4hep/Handle.h" -#include "DD4hep/Fields.h" -#include "DDG4/Factories.h" -#include "DDG4/Geant4Field.h" -#include "DDG4/Geant4Converter.h" +#include <DD4hep/Handle.h> +#include <DD4hep/Fields.h> +#include <DDG4/Factories.h> +#include <DDG4/Geant4Field.h> +#include <DDG4/Geant4Converter.h> -#include "G4TransportationManager.hh" -#include "G4MagIntegratorStepper.hh" -#include "G4Mag_EqRhs.hh" -#include "G4ChordFinder.hh" -#include "G4PropagatorInField.hh" +#include <G4TransportationManager.hh> +#include <G4MagIntegratorStepper.hh> +#include <G4Mag_EqRhs.hh> +#include <G4ChordFinder.hh> +#include <G4PropagatorInField.hh> #include <limits> using namespace std; diff --git a/DDG4/plugins/Geant4GDMLWriteAction.cpp b/DDG4/plugins/Geant4GDMLWriteAction.cpp index 2f330d1cfa41224d16f3b68712f88a0695d38b27..0696f24ce099dce0f6d71b5a7b5089e54954a626 100644 --- a/DDG4/plugins/Geant4GDMLWriteAction.cpp +++ b/DDG4/plugins/Geant4GDMLWriteAction.cpp @@ -14,7 +14,7 @@ #define DD4HEP_DDG4_GEANT4GDMLWRITEACTION_H // Framework include files -#include "DDG4/Geant4Action.h" +#include <DDG4/Geant4Action.h> /// Namespace for the AIDA detector description toolkit namespace dd4hep { @@ -82,17 +82,17 @@ namespace dd4hep { //==================================================================== // Framework include files -#include "DD4hep/InstanceCount.h" -#include "DD4hep/Printout.h" -#include "DD4hep/Primitives.h" -#include "DDG4/Geant4DataDump.h" -#include "DDG4/Geant4UIMessenger.h" +#include <DD4hep/InstanceCount.h> +#include <DD4hep/Printout.h> +#include <DD4hep/Primitives.h> +#include <DDG4/Geant4DataDump.h> +#include <DDG4/Geant4UIMessenger.h> // Geant 4 includes #ifndef GEANT4_NO_GDML -#include "G4GDMLParser.hh" +#include <G4GDMLParser.hh> #endif -#include "G4Version.hh" +#include <G4Version.hh> // C/C++ include files #include <sys/types.h> @@ -159,5 +159,5 @@ void Geant4GDMLWriteAction::writeGDML() { #endif } -#include "DDG4/Factories.h" +#include <DDG4/Factories.h> DECLARE_GEANT4ACTION(Geant4GDMLWriteAction) diff --git a/DDG4/plugins/Geant4GFlashShowerModel.cpp b/DDG4/plugins/Geant4GFlashShowerModel.cpp index 635917348f4223e59b03bdef62b406e8d81832bc..0603c7139138a3b88410496b304ec3c11853ddf1 100644 --- a/DDG4/plugins/Geant4GFlashShowerModel.cpp +++ b/DDG4/plugins/Geant4GFlashShowerModel.cpp @@ -51,15 +51,18 @@ namespace dd4hep { */ class Geant4GFlashShowerModel : public Geant4DetectorConstruction { protected: - /// Define standard assignments and constructors - DDG4_DEFINE_ACTION_CONSTRUCTORS(Geant4GFlashShowerModel); - /// Property: Region name to which this parametrization should be applied std::string m_regionName { "Region-name-not-specified"}; - /// Property: Name of the shower model constructor - std::string m_modelName; /// Property: Name of the Geant4Action implementing the parametrization std::string m_paramName; + /// Property: Material name for GFlashHomoShowerParameterisation + std::string m_material; + /// Property: Material 2 name for GFlashSamplingShowerParameterisation + std::string m_material_2; + /// Property: Parameter 1 name for GFlashSamplingShowerParameterisation + double m_parameter_1; + /// Property: Parameter 2 name for GFlashSamplingShowerParameterisation + double m_parameter_2; /// Reference to the shower model GFlashShowerModel* m_showerModel { nullptr }; @@ -70,6 +73,13 @@ namespace dd4hep { /// Reference to the hit maker GFlashHitMaker* m_hitMaker { nullptr }; + protected: + /// Define standard assignments and constructors + DDG4_DEFINE_ACTION_CONSTRUCTORS(Geant4GFlashShowerModel); + + /// Get parametrization material + G4Material* getMaterial(const std::string& name) const; + public: /// Standard constructor Geant4GFlashShowerModel(Geant4Context* context, const std::string& nam); @@ -113,11 +123,15 @@ namespace dd4hep { // Geant4 include files #include "GVFlashShowerParameterisation.hh" +#include "GFlashHomoShowerParameterisation.hh" +#include "GFlashSamplingShowerParameterisation.hh" #include "G4FastSimulationManager.hh" #include "GFlashShowerModel.hh" #include "GFlashHitMaker.hh" #include "GFlashParticleBounds.hh" +#include <sstream> + using namespace dd4hep; using namespace dd4hep::sim; @@ -125,19 +139,41 @@ using namespace dd4hep::sim; Geant4GFlashShowerModel::Geant4GFlashShowerModel(Geant4Context* ctxt, const std::string& nam) : Geant4DetectorConstruction(ctxt, nam) { - declareProperty("Region", m_regionName); + declareProperty("RegionName", m_regionName); declareProperty("Parametrization", m_paramName); - declareProperty("Model", m_modelName); + declareProperty("Material", m_material); + declareProperty("Material_1", m_material); + declareProperty("Material_2", m_material_2); + declareProperty("Parameter_1", m_parameter_1); + declareProperty("Parameter_2", m_parameter_2); } /// Default destructor Geant4GFlashShowerModel::~Geant4GFlashShowerModel() { - auto* a = dynamic_cast<Geant4Action*>(this->m_parametrization); + if ( this->m_parametrization ) { + auto* a = dynamic_cast<Geant4Action*>(this->m_parametrization); + if ( a ) detail::releasePtr(a); + else detail::deletePtr(this->m_parametrization); + } this->m_parametrization = nullptr; - detail::releasePtr(a); detail::deletePtr(m_particleBounds); detail::deletePtr(m_showerModel); - detail::deletePtr(m_hitMaker); + //detail::deletePtr(m_hitMaker); + m_hitMaker = nullptr; +} + +G4Material* Geant4GFlashShowerModel::getMaterial(const std::string& mat_name) const { + auto& kernel = this->context()->kernel(); + Geant4GeometryInfo& mapping = Geant4Mapping::instance().data(); + Material material = kernel.detectorDescription().material(mat_name); + if ( material.isValid() ) { + auto mat_iter = mapping.g4Materials.find(material); + if ( mat_iter != mapping.g4Materials.end() ) { + return (*mat_iter).second; + } + } + except("Failed to access shower parametrization material: %s", mat_name.c_str()); + return nullptr; } /// Adopt shower parametrization object @@ -180,11 +216,33 @@ void Geant4GFlashShowerModel::constructSensitives(Geant4DetectorConstructionCont } G4Region* region = (*region_iter).second; this->m_showerModel = new GFlashShowerModel(this->name(), region); + std::stringstream logger; + logger << "Geant4 shower model initialized with parametrization: "; if ( !this->m_parametrization ) { if ( this->m_paramName.empty() ) { except("No proper parametrization name supplied in the properties: %s",this->m_paramName.c_str()); } - this->adoptShowerParametrization(kernel.globalAction(this->m_paramName, false)); + if ( this->m_paramName == "GFlashHomoShowerParameterisation" ) { + G4Material* mat = this->getMaterial(m_material); + this->m_parametrization = new GFlashHomoShowerParameterisation(mat, nullptr); + logger << "GFlashHomoShowerParameterisation Material: " << mat->GetName(); + } + else if ( this->m_paramName == "GFlashSamplingShowerParameterisation" ) { + G4Material* mat1 = this->getMaterial(m_material); + G4Material* mat2 = this->getMaterial(m_material_2); + this->m_parametrization = + new GFlashSamplingShowerParameterisation(mat1, mat2, m_parameter_1, m_parameter_2, nullptr); + logger << "GFlashSamplingShowerParameterisation Material: " << mat1->GetName() + << " " << mat2->GetName() << " Params: " << m_parameter_1 << " " << m_parameter_2; + } + else { + auto* action = kernel.globalAction(this->m_paramName, false); + this->adoptShowerParametrization(action); + if ( action ) logger << typeName(typeid(*action)); + } + } + else { + logger << typeName(typeid(*this->m_parametrization)); } if ( !this->m_parametrization ) { except("No proper parametrization supplied. Failed to construct shower model."); @@ -194,4 +252,8 @@ void Geant4GFlashShowerModel::constructSensitives(Geant4DetectorConstructionCont this->m_showerModel->SetParameterisation(*this->m_parametrization); this->m_showerModel->SetParticleBounds(*this->m_particleBounds); this->m_showerModel->SetHitMaker(*this->m_hitMaker); + this->info(logger.str().c_str()); } + +#include "DDG4/Factories.h" +DECLARE_GEANT4ACTION(Geant4GFlashShowerModel) diff --git a/DDG4/plugins/Geant4GeometryScanner.cpp b/DDG4/plugins/Geant4GeometryScanner.cpp index b21aae7d12ef6c9c794621ec0934b7db33a02139..717de5f80b9ae18ae18d6abd9cc314bbf2a3700d 100644 --- a/DDG4/plugins/Geant4GeometryScanner.cpp +++ b/DDG4/plugins/Geant4GeometryScanner.cpp @@ -12,9 +12,9 @@ //========================================================================== // Framework include files -#include "DD4hep/Objects.h" -#include "DDG4/Defs.h" -#include "DDG4/Geant4SteppingAction.h" +#include <DD4hep/Objects.h> +#include <DDG4/Defs.h> +#include <DDG4/Geant4SteppingAction.h> // Forward declarations class G4LogicalVolume; @@ -85,21 +85,21 @@ namespace dd4hep { //==================================================================== // Framework include files -#include "DD4hep/InstanceCount.h" -#include "DD4hep/Printout.h" -#include "DDG4/Geant4TouchableHandler.h" -#include "DDG4/Geant4StepHandler.h" -#include "DDG4/Geant4EventAction.h" -#include "DDG4/Geant4TrackingAction.h" -#include "CLHEP/Units/SystemOfUnits.h" -#include "G4LogicalVolume.hh" -#include "G4Material.hh" -#include "G4VSolid.hh" +#include <DD4hep/InstanceCount.h> +#include <DD4hep/Printout.h> +#include <DDG4/Geant4TouchableHandler.h> +#include <DDG4/Geant4StepHandler.h> +#include <DDG4/Geant4EventAction.h> +#include <DDG4/Geant4TrackingAction.h> +#include <CLHEP/Units/SystemOfUnits.h> +#include <G4LogicalVolume.hh> +#include <G4Material.hh> +#include <G4VSolid.hh> using namespace std; using namespace dd4hep::sim; -#include "DDG4/Factories.h" +#include <DDG4/Factories.h> DECLARE_GEANT4ACTION(Geant4GeometryScanner) /// Initializing constructor diff --git a/DDG4/plugins/Geant4HitDumpAction.cpp b/DDG4/plugins/Geant4HitDumpAction.cpp index e5889ed7e44590629a2ada429351850e8132875e..507e710ce721f00381ecb415812b32139bc1350b 100644 --- a/DDG4/plugins/Geant4HitDumpAction.cpp +++ b/DDG4/plugins/Geant4HitDumpAction.cpp @@ -14,7 +14,7 @@ #define DD4HEP_DDG4_GEANT4HITDUMPACTION_H // Framework include files -#include "DDG4/Geant4EventAction.h" +#include <DDG4/Geant4EventAction.h> // Forward declarations class G4VHitsCollection; @@ -75,13 +75,13 @@ namespace dd4hep { //==================================================================== // Framework include files -#include "DD4hep/InstanceCount.h" -#include "DDG4/Geant4DataDump.h" -#include "DDG4/Geant4HitCollection.h" +#include <DD4hep/InstanceCount.h> +#include <DDG4/Geant4DataDump.h> +#include <DDG4/Geant4HitCollection.h> // Geant 4 includes -#include "G4HCofThisEvent.hh" -#include "G4Event.hh" +#include <G4HCofThisEvent.hh> +#include <G4Event.hh> using namespace std; using namespace dd4hep; @@ -148,5 +148,5 @@ void Geant4HitDumpAction::end(const G4Event* event) { warning("+++ [Event:%d] The value of G4HCofThisEvent is NULL.",event->GetEventID()); } -#include "DDG4/Factories.h" +#include <DDG4/Factories.h> DECLARE_GEANT4ACTION(Geant4HitDumpAction) diff --git a/DDG4/plugins/Geant4RunManagers.cpp b/DDG4/plugins/Geant4RunManagers.cpp index 784054341a9937978b1033dd91fcc4bcb7ee7f05..2f6151bcf8f9cdac1ec4222164a49732d2432106 100644 --- a/DDG4/plugins/Geant4RunManagers.cpp +++ b/DDG4/plugins/Geant4RunManagers.cpp @@ -14,10 +14,10 @@ #define DDG4_GEANT4RUNMANAGER_H 1 /// Framework include files -#include "DDG4/Geant4Action.h" +#include <DDG4/Geant4Action.h> /// Geant4 include files -#include "G4RunManager.hh" +#include <G4RunManager.hh> /// Namespace for the AIDA detector description toolkit namespace dd4hep { @@ -71,12 +71,12 @@ namespace dd4hep { } #endif // DDG4_GEANT4RUNMANAGER_H -#include "DDG4/Factories.h" +#include <DDG4/Factories.h> using namespace dd4hep::sim; DD4HEP_PLUGINSVC_FACTORY(Geant4STRunManager,G4RunManager,dd4hep::sim::Geant4Action*(_ns::CT*,std::string),__LINE__) #ifdef G4MULTITHREADED -#include "G4MTRunManager.hh" +#include <G4MTRunManager.hh> /// Namespace for the AIDA detector description toolkit namespace dd4hep { diff --git a/DDG4/plugins/Geant4SensDet.cpp b/DDG4/plugins/Geant4SensDet.cpp index 79d8f604035eb43bd78d0aa2f3ac0452ac60d53f..a02a4d98fd83ed5a983e38f4c8f8589e3897d653 100644 --- a/DDG4/plugins/Geant4SensDet.cpp +++ b/DDG4/plugins/Geant4SensDet.cpp @@ -12,19 +12,20 @@ //========================================================================== // Framework include files -#include "DD4hep/Printout.h" -#include "DD4hep/Primitives.h" -#include "DD4hep/InstanceCount.h" +#include <DD4hep/Printout.h> +#include <DD4hep/Primitives.h> +#include <DD4hep/InstanceCount.h> -#include "DDG4/Geant4Kernel.h" -#include "DDG4/Geant4Context.h" -#include "DDG4/Geant4HitCollection.h" -#include "DDG4/Geant4SensDetAction.h" +#include <DDG4/Geant4Kernel.h> +#include <DDG4/Geant4Context.h> +#include <DDG4/Geant4HitCollection.h> +#include <DDG4/Geant4SensDetAction.h> // Geant4 include files -#include "G4VSensitiveDetector.hh" -#include "G4Event.hh" -#include "G4Run.hh" +#include <G4VSensitiveDetector.hh> +#include <G4VGFlashSensitiveDetector.hh> +#include <G4Event.hh> +#include <G4Run.hh> /// Namespace for the AIDA detector description toolkit namespace dd4hep { @@ -65,6 +66,7 @@ namespace dd4hep { * \ingroup DD4HEP_SIMULATION */ class Geant4SensDet : virtual public G4VSensitiveDetector, + virtual public G4VGFlashSensitiveDetector, virtual public G4VSDFilter, virtual public Geant4ActionSD, virtual public RefCountedSequence<Geant4SensDetActionSequence> @@ -75,8 +77,11 @@ namespace dd4hep { public: /// Constructor. The detector element is identified by the name Geant4SensDet(const std::string& nam, Detector& description) - : G4VSensitiveDetector(nam), G4VSDFilter(nam), - Geant4Action(0,nam), Geant4ActionSD(nam), + : G4VSensitiveDetector(nam), + G4VGFlashSensitiveDetector(), + G4VSDFilter(nam), + Geant4Action(0,nam), + Geant4ActionSD(nam), RefCountedSequence<Geant4SensDetActionSequence>() { Geant4Kernel& master = Geant4Kernel::instance(description); @@ -91,48 +96,51 @@ namespace dd4hep { } /// Destructor - virtual ~Geant4SensDet() { } + virtual ~Geant4SensDet() = default; /// Overload to avoid ambiguity between G4VSensitiveDetector and G4VSDFilter - inline G4String GetName() const + inline G4String GetName() const { return this->G4VSensitiveDetector::SensitiveDetectorName; } /// G4VSensitiveDetector internals: Access to the detector path name - virtual std::string path() const + virtual std::string path() const override { return this->G4VSensitiveDetector::GetPathName(); } /// G4VSensitiveDetector internals: Access to the detector path name - virtual std::string fullPath() const + virtual std::string fullPath() const override { return this->G4VSensitiveDetector::GetFullPathName(); } /// Is the detector active? - virtual bool isActive() const + virtual bool isActive() const override { return this->G4VSensitiveDetector::isActive(); } /// This is a utility method which returns the hits collection ID - virtual G4int GetCollectionID(G4int i) + virtual G4int GetCollectionID(G4int i) override { return this->G4VSensitiveDetector::GetCollectionID(i); } /// Access to the readout geometry of the sensitive detector - virtual G4VReadOutGeometry* readoutGeometry() const + virtual G4VReadOutGeometry* readoutGeometry() const override { return this->G4VSensitiveDetector::GetROgeometry(); } /// Access to the Detector sensitive detector handle - virtual SensitiveDetector sensitiveDetector() const + virtual SensitiveDetector sensitiveDetector() const override { return m_sensitive; } /// Access to the sensitive type of the detector - virtual const std::string& sensitiveType() const + virtual const std::string& sensitiveType() const override { return m_sequence->sensitiveType(); } /// Callback if the sequence should be accepted or filtered off - virtual G4bool Accept(const G4Step* step) const + virtual G4bool Accept(const G4Step* step) const override { return m_sequence->accept(step); } /// Method invoked at the begining of each event. - virtual void Initialize(G4HCofThisEvent* hce) + virtual void Initialize(G4HCofThisEvent* hce) override { m_sequence->begin(hce); } /// Method invoked at the end of each event. - virtual void EndOfEvent(G4HCofThisEvent* hce) + virtual void EndOfEvent(G4HCofThisEvent* hce) override { m_sequence->end(hce); } /// Method for generating hit(s) using the information of G4Step object. - virtual G4bool ProcessHits(G4Step* step,G4TouchableHistory* hist) + virtual G4bool ProcessHits(G4Step* step,G4TouchableHistory* hist) override { return m_sequence->process(step,hist); } + // Separate GFLASH interface + virtual G4bool ProcessHits(G4GFlashSpot* spot ,G4TouchableHistory* hist) override + { return m_sequence->processGFlash(spot,hist); } /// G4VSensitiveDetector interface: Method invoked if the event was aborted. - virtual void clear() + virtual void clear() override { m_sequence->clear(); } /// Initialize the usage of a hit collection. Returns the collection identifier - virtual size_t defineCollection(const std::string& coll) { + virtual size_t defineCollection(const std::string& coll) override { if ( coll.empty() ) { except("Geant4Sensitive: No collection defined for %s [Invalid name]",c_name()); } @@ -145,7 +153,7 @@ namespace dd4hep { } // End namespace dd4hep -#include "DDG4/Factories.h" +#include <DDG4/Factories.h> typedef dd4hep::sim::Geant4SensDet Geant4SensDet; typedef dd4hep::sim::Geant4SensDet Geant4tracker; diff --git a/examples/ClientTests/compact/SiliconBlock.xml b/examples/ClientTests/compact/SiliconBlock.xml index d8f86668b97673a301292698415d0bff56531eb8..6e0d4431a2d288f9c6c7cca8e0f45b6e0954a960 100644 --- a/examples/ClientTests/compact/SiliconBlock.xml +++ b/examples/ClientTests/compact/SiliconBlock.xml @@ -26,6 +26,15 @@ <gdmlFile ref="${DD4hepINSTALL}/DDDetectors/compact/materials.xml"/> </includes> + <materials> + <material name="G4_PbWO4"> + <D type="density" unit="g/cm3" value="8.28"/> + <composite n="4" ref="O"/> + <composite n="1" ref="Pb"/> + <composite n="1" ref="W"/> + </material> + </materials> + <define> <constant name="world_size" value="30*m"/> <constant name="world_x" value="world_size"/> @@ -56,16 +65,16 @@ <detectors> <detector id="1" name="SiliconBlockUpper" type="DD4hep_BoxSegment" readout="SiliconUpperHits" vis="VisibleGreen" sensitive="true" region="SiRegion" limits="SiRegionLimitSet"> - <material name="Silicon"/> + <material name="G4_PbWO4"/> <sensitive type="tracker"/> - <box x="20*mm" y="20*cm" z="20*cm"/> - <position x="4*cm" y="0" z="0"/> - <rotation x="0" y="0" z="0"/> + <box x="30*mm" y="100*cm" z="100*cm"/> + <position x="4*cm" y="0" z="0"/> + <rotation x="0" y="0" z="0"/> </detector> <detector id="2" name="SiliconBlockDown" type="DD4hep_BoxSegment" readout="SiliconDownHits" vis="VisibleRed" sensitive="true" region="SiRegion" limits="SiRegionLimitSet"> - <material name="Silicon"/> + <material name="G4_PbWO4"/> <sensitive type="tracker"/> - <box x="20*mm" y="20*cm" z="20*cm"/> + <box x="30*mm" y="100*cm" z="100*cm"/> <position x="-4*cm" y="0" z="0"/> <rotation x="0" y="0" z="0"/> </detector> @@ -73,10 +82,12 @@ <readouts> <readout name="SiliconUpperHits"> - <id>system:8</id> + <segmentation type="CartesianGridXY" grid_size_x="5*mm" grid_size_y="5*mm"/> + <id>system:8,x:16:-8,y:-16</id> </readout> <readout name="SiliconDownHits"> - <id>system:8</id> + <segmentation type="CartesianGridXY" grid_size_x="5*mm" grid_size_y="5*mm"/> + <id>system:8,x:16:-8,y:-16</id> </readout> </readouts> diff --git a/examples/ClientTests/scripts/SiliconBlock.py b/examples/ClientTests/scripts/SiliconBlock.py index 1de5926446c32ab31249d01925d189884bec619c..987a5139c983da57ce8e01d43ca4f55fdf29a6c2 100644 --- a/examples/ClientTests/scripts/SiliconBlock.py +++ b/examples/ClientTests/scripts/SiliconBlock.py @@ -59,12 +59,13 @@ def run(): act.DebugElements = False act.DebugVolumes = True act.DebugShapes = True + seq, act = geant4.addDetectorConstruction("Geant4DetectorSensitivesConstruction/ConstructSD") # Configure I/O geant4.setupROOTOutput('RootOutput', 'SiliconBlock_' + time.strftime('%Y-%m-%d_%H-%M')) # Setup particle gun - gun = geant4.setupGun("Gun", particle='mu-', energy=20 * GeV, multiplicity=1) + gun = geant4.setupGun("Gun", particle='e+', energy=20 * GeV, multiplicity=1) gun.OutputLevel = generator_output_level # And handle the simulation particles. diff --git a/examples/ClientTests/scripts/SiliconBlockGFlash.py b/examples/ClientTests/scripts/SiliconBlockGFlash.py new file mode 100644 index 0000000000000000000000000000000000000000..ecce98cc3b3b4b4a1943aa2b713bb03e46ba59bd --- /dev/null +++ b/examples/ClientTests/scripts/SiliconBlockGFlash.py @@ -0,0 +1,112 @@ +# ========================================================================== +# AIDA Detector description implementation +# -------------------------------------------------------------------------- +# Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) +# All rights reserved. +# +# For the licensing terms see $DD4hepINSTALL/LICENSE. +# For the list of contributors see $DD4hepINSTALL/doc/CREDITS. +# +# ========================================================================== +# +# +from __future__ import absolute_import, unicode_literals +import os +import sys +import time +import DDG4 +from DDG4 import OutputLevel as Output +from g4units import GeV, MeV, m +# +# +""" + + dd4hep simulation example setup using the python configuration + + @author M.Frank + @version 1.0 + +""" + + +def run(): + kernel = DDG4.Kernel() + install_dir = os.environ['DD4hepExamplesINSTALL'] + kernel.loadGeometry(str("file:" + install_dir + "/examples/ClientTests/compact/SiliconBlock.xml")) + + DDG4.importConstants(kernel.detectorDescription(), debug=False) + geant4 = DDG4.Geant4(kernel, tracker='Geant4TrackerCombineAction') + geant4.printDetectors() + # Configure UI + if len(sys.argv) > 1: + geant4.setupCshUI(macro=sys.argv[1]) + else: + geant4.setupCshUI() + + # Configure field + geant4.setupTrackingField(prt=True) + # Configure Event actions + prt = DDG4.EventAction(kernel, 'Geant4ParticlePrint/ParticlePrint') + prt.OutputLevel = Output.DEBUG + prt.OutputType = 3 # Print both: table and tree + kernel.eventAction().adopt(prt) + + generator_output_level = Output.INFO + + # Configure G4 geometry setup + seq, act = geant4.addDetectorConstruction("Geant4DetectorGeometryConstruction/ConstructGeo") + act.DebugMaterials = True + act.DebugElements = False + act.DebugVolumes = True + act.DebugShapes = True + + model = DDG4.DetectorConstruction(kernel, str('Geant4GFlashShowerModel/ShowerModel')) + model.Parametrization = 'GFlashHomoShowerParameterisation' + model.RegionName = 'SiRegion' + model.Material = 'Silicon' + model.enableUI() + seq.adopt(model) + + # Configure I/O + geant4.setupROOTOutput('RootOutput', 'SiliconBlock_' + time.strftime('%Y-%m-%d_%H-%M')) + + # Setup particle gun + gun = geant4.setupGun("Gun", particle='e-', energy=20 * GeV, multiplicity=1) + gun.OutputLevel = generator_output_level + + # And handle the simulation particles. + part = DDG4.GeneratorAction(kernel, "Geant4ParticleHandler/ParticleHandler") + kernel.generatorAction().adopt(part) + part.SaveProcesses = ['Decay'] + part.MinimalKineticEnergy = 100 * MeV + part.OutputLevel = Output.INFO # generator_output_level + part.enableUI() + user = DDG4.Action(kernel, "Geant4TCUserParticleHandler/UserParticleHandler") + user.TrackingVolume_Zmax = 3.0 * m + user.TrackingVolume_Rmax = 3.0 * m + user.enableUI() + part.adopt(user) + + geant4.setupTracker('SiliconBlockUpper') + geant4.setupTracker('SiliconBlockDown') + + # Now build the physics list: + phys = geant4.setupPhysics('QGSP_BERT') + ph = DDG4.PhysicsList(kernel, str('Geant4PhysicsList/Myphysics')) + ph.addParticleConstructor(str('G4Geantino')) + ph.addParticleConstructor(str('G4BosonConstructor')) + ph.enableUI() + phys.adopt(ph) + + ph = DDG4.PhysicsList(kernel, str('Geant4PhysicsList/FastPhysicsList')) + fast = DDG4.Action(kernel, str('Geant4FastPhysics/FastPhysics')) + ph.adoptPhysicsConstructor(fast) + ph.enableUI() + phys.adopt(ph) + phys.dump() + + geant4.execute() + + +if __name__ == "__main__": + run()