Skip to content
Snippets Groups Projects
Commit 9e64d8af authored by myliu@ihep.ac.cn's avatar myliu@ihep.ac.cn
Browse files

Ecal fast simlation

parent 75948737
No related branches found
No related tags found
No related merge requests found
find_package(Geant4 REQUIRED ui_all vis_all)
include(${Geant4_USE_FILE})
gaudi_add_module(DetSimFastEcal
SOURCES src/EcalFastSimG4Tool.cpp
src/EcalFastSimG4Model.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;
}
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