diff --git a/Detector/DetCRD/compact/CRD_common_v01/Ecal_Crystal_Barrel_v01_01.xml b/Detector/DetCRD/compact/CRD_common_v01/Ecal_Crystal_Barrel_v01_01.xml index b408c7a37428fe631e4889ba64ca262b970ff4df..6d3b3a7fd640577efeb8d5b56930e0ea551d06a7 100644 --- a/Detector/DetCRD/compact/CRD_common_v01/Ecal_Crystal_Barrel_v01_01.xml +++ b/Detector/DetCRD/compact/CRD_common_v01/Ecal_Crystal_Barrel_v01_01.xml @@ -6,8 +6,13 @@ <constant name="ecalbarrel_zlength" value="Ecal_barrel_half_length*2"/> <!--Must be n*10*mm! --> </define> + <regions> + <region name="EcalBarrelRegion"> + </region> + </regions> + <detectors> - <detector id="DetID_ECAL" name="CaloDetector" type="CRDEcalBarrel" readout="EcalBarrelCollection" vis="Invisible" sensitive="true"> + <detector id="DetID_ECAL" name="CaloDetector" type="CRDEcalBarrel" readout="EcalBarrelCollection" vis="Invisible" sensitive="true" region="EcalBarrelRegion"> <!-- Use cm as unit if you want to use Pandora for reconstruction --> </detector> </detectors> diff --git a/Detector/DetCRD/src/Calorimeter/CRDEcal.cpp b/Detector/DetCRD/src/Calorimeter/CRDEcal.cpp index 2fa11cff9d35adf5f48064227d63d52a55349d72..9d1b6b79d8733d0977925bd1c5c429bf9bbe9eb7 100644 --- a/Detector/DetCRD/src/Calorimeter/CRDEcal.cpp +++ b/Detector/DetCRD/src/Calorimeter/CRDEcal.cpp @@ -67,6 +67,7 @@ static dd4hep::Ref_t create_detector(dd4hep::Detector& theDetector, dd4hep::Volume envelopeVol(det_name, envelope, air); dd4hep::PlacedVolume envelopePlv = motherVol.placeVolume(envelopeVol, Position(0,0,0)); envelopeVol.setVisAttributes(theDetector, "InvisibleWithChildren" ); + envelopeVol.setRegion(theDetector,x_det.regionStr()); ECAL.setPlacement(envelopePlv); //Define specific material and volumen for detElement diff --git a/Simulation/DetSimCore/src/DetSimAlg.cpp b/Simulation/DetSimCore/src/DetSimAlg.cpp index 29e32f62b86866fd7d5d575dc500e0c579e6c547..655d921c2742cd2b066000275f79baa1113cc558 100644 --- a/Simulation/DetSimCore/src/DetSimAlg.cpp +++ b/Simulation/DetSimCore/src/DetSimAlg.cpp @@ -84,6 +84,20 @@ DetSimAlg::initialize() { fastsim_physics->ActivateFastSimulation("e-"); fastsim_physics->ActivateFastSimulation("e+"); fastsim_physics->ActivateFastSimulation("gamma"); + fastsim_physics->ActivateFastSimulation("mu-"); + fastsim_physics->ActivateFastSimulation("pi0"); + fastsim_physics->ActivateFastSimulation("pi+"); + fastsim_physics->ActivateFastSimulation("pi-"); + fastsim_physics->ActivateFastSimulation("tau+"); + fastsim_physics->ActivateFastSimulation("tau-"); + fastsim_physics->ActivateFastSimulation("K0"); + fastsim_physics->ActivateFastSimulation("K-"); + fastsim_physics->ActivateFastSimulation("K+"); + fastsim_physics->ActivateFastSimulation("Z0"); + fastsim_physics->ActivateFastSimulation("W-"); + fastsim_physics->ActivateFastSimulation("h0"); + fastsim_physics->ActivateFastSimulation("nu_mu"); + fastsim_physics->ActivateFastSimulation("nu_ebar"); modularPhysicsList->RegisterPhysics(fastsim_physics); physicsList = modularPhysicsList; diff --git a/Simulation/DetSimFastModel/CMakeLists.txt b/Simulation/DetSimFastModel/CMakeLists.txt index 50ceb1e33fdd4634f93dffb710a1d020dc58aea4..30dced2b32f4c9c07a05dc02e9ba9b6c6355d3a4 100644 --- a/Simulation/DetSimFastModel/CMakeLists.txt +++ b/Simulation/DetSimFastModel/CMakeLists.txt @@ -6,6 +6,8 @@ include(${Geant4_USE_FILE}) gaudi_add_module(DetSimFastModel SOURCES src/DummyFastSimG4Tool.cpp src/DummyFastSimG4Model.cpp + src/EcalFastSimG4Model.cpp + src/EcalFastSimG4Tool.cpp LINK DetSimInterface ${DD4hep_COMPONENT_LIBRARIES} Gaudi::GaudiKernel diff --git a/Simulation/DetSimFastModel/src/EcalFastSimG4Model.cpp b/Simulation/DetSimFastModel/src/EcalFastSimG4Model.cpp new file mode 100644 index 0000000000000000000000000000000000000000..dae2c4399220a114f957c63dce49e24083f14686 --- /dev/null +++ b/Simulation/DetSimFastModel/src/EcalFastSimG4Model.cpp @@ -0,0 +1,40 @@ +#include "EcalFastSimG4Model.h" + +#include "G4Track.hh" +#include "G4FastTrack.hh" + +EcalFastSimG4Model::EcalFastSimG4Model(G4String aModelName, G4Region* aEnvelope) + : G4VFastSimulationModel(aModelName, aEnvelope) { + +} + +EcalFastSimG4Model::~EcalFastSimG4Model() { + +} + +G4bool EcalFastSimG4Model::IsApplicable(const G4ParticleDefinition& aParticle) { +// return aParticle.GetPDGCharge() != 0; + return true; +} + +G4bool EcalFastSimG4Model::ModelTrigger(const G4FastTrack& aFastTrack) { + //G4cout << __FILE__ << __LINE__ << ": ModelTrigger." << G4endl; + +// bool istrigged = false; + bool istrigged = true; + // only select the secondaries + const G4Track* track = aFastTrack.GetPrimaryTrack(); + // secondaries +//G4cout << "trackID = " << track->GetTrackID() <<G4endl; +// if (track->GetTrackID() != 0) { +// istrigged = true; +// } +//G4cout << "istrigged = " << istrigged <<G4endl; + return istrigged; +} + +void EcalFastSimG4Model::DoIt(const G4FastTrack& aFastTrack, G4FastStep& aFastStep) { + //G4cout << __FILE__ << __LINE__ << ": DoIt." << G4endl; + + aFastStep.ProposeTrackStatus(fStopAndKill); +} diff --git a/Simulation/DetSimFastModel/src/EcalFastSimG4Model.h b/Simulation/DetSimFastModel/src/EcalFastSimG4Model.h new file mode 100644 index 0000000000000000000000000000000000000000..fc378343cbc47a4eae75be07aaccd5381c53807b --- /dev/null +++ b/Simulation/DetSimFastModel/src/EcalFastSimG4Model.h @@ -0,0 +1,19 @@ +#ifndef EcalFastSimG4Model_h +#define EcalFastSimG4Model_h + +#include "G4VFastSimulationModel.hh" + +class EcalFastSimG4Model: public G4VFastSimulationModel { +public: + + EcalFastSimG4Model(G4String aModelName, G4Region* aEnvelope); + ~EcalFastSimG4Model(); + + virtual G4bool IsApplicable( const G4ParticleDefinition& aParticle ); + virtual G4bool ModelTrigger( const G4FastTrack& aFastTrack ); + virtual void DoIt( const G4FastTrack& aFastTrack, G4FastStep& aFastStep ); + +}; + +#endif + diff --git a/Simulation/DetSimFastModel/src/EcalFastSimG4Tool.cpp b/Simulation/DetSimFastModel/src/EcalFastSimG4Tool.cpp new file mode 100644 index 0000000000000000000000000000000000000000..2ac48086b8bdb4909ca4c98d3c913cc14feecc01 --- /dev/null +++ b/Simulation/DetSimFastModel/src/EcalFastSimG4Tool.cpp @@ -0,0 +1,41 @@ +#include "EcalFastSimG4Tool.h" + +#include "G4Region.hh" +#include "G4RegionStore.hh" + +#include "G4VFastSimulationModel.hh" +#include "EcalFastSimG4Model.h" + +DECLARE_COMPONENT(EcalFastSimG4Tool); + +StatusCode EcalFastSimG4Tool::initialize() { + StatusCode sc; + + return sc; +} + +StatusCode EcalFastSimG4Tool::finalize() { + StatusCode sc; + + return sc; +} + +bool EcalFastSimG4Tool::CreateFastSimulationModel() { + // In this method: + // * Retrieve the G4Region + // * Create Model + // * Associate model and region + + G4String model_name = "EcalFastSimG4Model"; + for (auto region_name: m_regions.value()) { + G4Region* aEnvelope = G4RegionStore::GetInstance()->GetRegion(region_name); + if (!aEnvelope) { + error() << "Failed to find G4Region '" << region_name << "'" << endmsg; + return false; + } + + EcalFastSimG4Model* model = new EcalFastSimG4Model(model_name+region_name, aEnvelope); + info() << "Create Model " << model_name << " for G4Region " << region_name << endmsg; + } + return true; +} diff --git a/Simulation/DetSimFastModel/src/EcalFastSimG4Tool.h b/Simulation/DetSimFastModel/src/EcalFastSimG4Tool.h new file mode 100644 index 0000000000000000000000000000000000000000..4f21f8cfb8124cd42bfcf547d34b044f4ee9026d --- /dev/null +++ b/Simulation/DetSimFastModel/src/EcalFastSimG4Tool.h @@ -0,0 +1,21 @@ +#ifndef EcalFastSimG4Tool_h +#define EcalFastSimG4Tool_h + +#include "GaudiKernel/AlgTool.h" +#include "DetSimInterface/IFastSimG4Tool.h" + +class EcalFastSimG4Tool: public extends<AlgTool, IFastSimG4Tool> { +public: + using extends::extends; + + StatusCode initialize() override; + StatusCode finalize() override; + + bool CreateFastSimulationModel() override; + +private: + // the regions will be associated with the fast sim model + Gaudi::Property<std::vector<std::string>> m_regions{this, "Regions"}; +}; + +#endif