File indexing completed on 2026-09-16 08:30:38
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
0027
0028
0029 #ifdef USE_INFERENCE
0030 # include "Par04MLFastSimModel.hh"
0031
0032 # include "Par04InferenceSetup.hh" // for Par04InferenceSetup
0033
0034 # include "G4Electron.hh" // for G4Electron
0035 # include "G4FastHit.hh" // for G4FastHit
0036 # include "G4FastSimHitMaker.hh" // for G4FastSimHitMaker
0037 # include "G4Gamma.hh" // for G4Gamma
0038 # include "G4Positron.hh" // for G4Positron
0039
0040 # include <G4FastStep.hh> // for G4FastStep
0041 # include <G4FastTrack.hh> // for G4FastTrack
0042 # include <G4Track.hh> // for G4Track
0043 # include <G4VFastSimulationModel.hh> // for G4VFastSimulationModel
0044 # include <stddef.h> // for size_t
0045 class G4ParticleDefinition;
0046 class G4Region;
0047
0048
0049
0050 Par04MLFastSimModel::Par04MLFastSimModel(G4String aModelName, G4Region* aEnvelope)
0051 : G4VFastSimulationModel(aModelName, aEnvelope),
0052 fInference(new Par04InferenceSetup),
0053 fHitMaker(new G4FastSimHitMaker),
0054 fParallelHitMaker(new G4FastSimHitMaker)
0055 {
0056 fParallelHitMaker->SetNameOfWorldWithSD("parallelWorldFastSim");
0057 }
0058
0059
0060
0061 Par04MLFastSimModel::Par04MLFastSimModel(G4String aModelName)
0062 : G4VFastSimulationModel(aModelName),
0063 fInference(new Par04InferenceSetup),
0064 fHitMaker(new G4FastSimHitMaker),
0065 fParallelHitMaker(new G4FastSimHitMaker)
0066 {
0067 fParallelHitMaker->SetNameOfWorldWithSD("parallelWorldFastSim");
0068 }
0069
0070
0071
0072 Par04MLFastSimModel::~Par04MLFastSimModel() {}
0073
0074
0075
0076 G4bool Par04MLFastSimModel::IsApplicable(const G4ParticleDefinition& aParticleType)
0077 {
0078 return &aParticleType == G4Electron::ElectronDefinition()
0079 || &aParticleType == G4Positron::PositronDefinition()
0080 || &aParticleType == G4Gamma::GammaDefinition();
0081 }
0082
0083
0084
0085 G4bool Par04MLFastSimModel::ModelTrigger(const G4FastTrack& aFastTrack)
0086 {
0087 return fInference->IfTrigger(aFastTrack.GetPrimaryTrack()->GetKineticEnergy());
0088 }
0089
0090
0091
0092 void Par04MLFastSimModel::DoIt(const G4FastTrack& aFastTrack, G4FastStep& aFastStep)
0093 {
0094
0095 aFastStep.KillPrimaryTrack();
0096 aFastStep.ProposePrimaryTrackPathLength(0.);
0097 G4double energy = aFastTrack.GetPrimaryTrack()->GetKineticEnergy();
0098 aFastStep.ProposeTotalEnergyDeposited(energy);
0099 G4ThreeVector position = aFastTrack.GetPrimaryTrack()->GetPosition();
0100 G4ThreeVector direction = aFastTrack.GetPrimaryTrack()->GetMomentumDirection();
0101
0102
0103 G4float theta = direction.theta();
0104 G4float phi = direction.phi();
0105
0106
0107
0108 fInference->GetEnergies(fEnergies, energy, theta, phi);
0109 fInference->GetPositions(fPositions, position, direction);
0110
0111
0112
0113 for (size_t iHit = 0; iHit < fPositions.size(); iHit++) {
0114 if (fEnergies[iHit] > 0.0005) {
0115
0116 fParallelHitMaker->make(G4FastHit(fPositions[iHit], fEnergies[iHit]), aFastTrack);
0117
0118 fHitMaker->make(G4FastHit(fPositions[iHit], fEnergies[iHit]), aFastTrack);
0119 }
0120 }
0121 }
0122 #endif