Skip to content
Snippets Groups Projects
Unverified Commit f3b7a830 authored by lintao@ihep.ac.cn's avatar lintao@ihep.ac.cn Committed by GitHub
Browse files

Merge pull request #145 from myliu-hub/master

Ecal fast simulation
parents aba65ce0 7a952504
No related branches found
No related tags found
No related merge requests found
......@@ -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>
......
......@@ -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
......
......@@ -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;
......
......@@ -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
......
#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);
}
#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
#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;
}
#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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment