File indexing completed on 2025-02-23 09:22:35
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026 #ifdef USE_INFERENCE
0027 # include "Par04MLFastSimModel.hh"
0028
0029 # include "Par04InferenceSetup.hh" // for Par04InferenceSetup
0030
0031 # include "G4Electron.hh" // for G4Electron
0032 # include "G4FastHit.hh" // for G4FastHit
0033 # include "G4FastSimHitMaker.hh" // for G4FastSimHitMaker
0034 # include "G4Gamma.hh" // for G4Gamma
0035 # include "G4Positron.hh" // for G4Positron
0036
0037 # include <G4FastStep.hh> // for G4FastStep
0038 # include <G4FastTrack.hh> // for G4FastTrack
0039 # include <G4Track.hh> // for G4Track
0040 # include <G4VFastSimulationModel.hh> // for G4VFastSimulationModel
0041 # include <stddef.h> // for size_t
0042 class G4ParticleDefinition;
0043 class G4Region;
0044
0045
0046
0047 Par04MLFastSimModel::Par04MLFastSimModel(G4String aModelName, G4Region* aEnvelope)
0048 : G4VFastSimulationModel(aModelName, aEnvelope),
0049 fInference(new Par04InferenceSetup),
0050 fHitMaker(new G4FastSimHitMaker),
0051 fParallelHitMaker(new G4FastSimHitMaker)
0052 {
0053 fParallelHitMaker->SetNameOfWorldWithSD("parallelWorldFastSim");
0054 }
0055
0056
0057
0058 Par04MLFastSimModel::Par04MLFastSimModel(G4String aModelName)
0059 : G4VFastSimulationModel(aModelName),
0060 fInference(new Par04InferenceSetup),
0061 fHitMaker(new G4FastSimHitMaker),
0062 fParallelHitMaker(new G4FastSimHitMaker)
0063 {
0064 fParallelHitMaker->SetNameOfWorldWithSD("parallelWorldFastSim");
0065 }
0066
0067
0068
0069 Par04MLFastSimModel::~Par04MLFastSimModel() {}
0070
0071
0072
0073 G4bool Par04MLFastSimModel::IsApplicable(const G4ParticleDefinition& aParticleType)
0074 {
0075 return &aParticleType == G4Electron::ElectronDefinition()
0076 || &aParticleType == G4Positron::PositronDefinition()
0077 || &aParticleType == G4Gamma::GammaDefinition();
0078 }
0079
0080
0081
0082 G4bool Par04MLFastSimModel::ModelTrigger(const G4FastTrack& aFastTrack)
0083 {
0084 return fInference->IfTrigger(aFastTrack.GetPrimaryTrack()->GetKineticEnergy());
0085 }
0086
0087
0088
0089 void Par04MLFastSimModel::DoIt(const G4FastTrack& aFastTrack, G4FastStep& aFastStep)
0090 {
0091
0092 aFastStep.KillPrimaryTrack();
0093 aFastStep.SetPrimaryTrackPathLength(0.0);
0094 G4double energy = aFastTrack.GetPrimaryTrack()->GetKineticEnergy();
0095 aFastStep.SetTotalEnergyDeposited(energy);
0096 G4ThreeVector position = aFastTrack.GetPrimaryTrack()->GetPosition();
0097 G4ThreeVector direction = aFastTrack.GetPrimaryTrack()->GetMomentumDirection();
0098
0099
0100 G4float angle = direction.theta();
0101
0102
0103
0104 fInference->GetEnergies(fEnergies, energy, angle);
0105 fInference->GetPositions(fPositions, position, direction);
0106
0107
0108
0109 for (size_t iHit = 0; iHit < fPositions.size(); iHit++) {
0110 if (fEnergies[iHit] > 0.0005) {
0111
0112 fParallelHitMaker->make(G4FastHit(fPositions[iHit], fEnergies[iHit]), aFastTrack);
0113
0114 fHitMaker->make(G4FastHit(fPositions[iHit], fEnergies[iHit]), aFastTrack);
0115 }
0116 }
0117 }
0118 #endif