-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Development of an actor which kill a track if this one passes through…
…t the actor volume without any interaction
- Loading branch information
Showing
8 changed files
with
372 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
core/opengate_core/opengate_lib/GateKillNonInteractingParticleActor.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* -------------------------------------------------- | ||
Copyright (C): OpenGATE Collaboration | ||
This software is distributed under the terms | ||
of the GNU Lesser General Public Licence (LGPL) | ||
See LICENSE.md for further details | ||
------------------------------------ -------------- */ | ||
|
||
#include "GateKillNonInteractingParticleActor.h" | ||
#include "G4ios.hh" | ||
#include "GateHelpers.h" | ||
#include "GateHelpersDict.h" | ||
#include "G4PhysicalVolumeStore.hh" | ||
#include "G4LogicalVolumeStore.hh" | ||
|
||
|
||
GateKillNonInteractingParticleActor::GateKillNonInteractingParticleActor(py::dict &user_info) | ||
: GateVActor(user_info, false) { | ||
fActions.insert("StartSimulationAction"); | ||
fActions.insert("SteppingAction"); | ||
fActions.insert("PreUserTrackingAction"); | ||
} | ||
|
||
|
||
|
||
|
||
void GateKillNonInteractingParticleActor::ActorInitialize() {} | ||
|
||
void GateKillNonInteractingParticleActor::StartSimulationAction() { | ||
fNbOfKilledParticles = 0; | ||
} | ||
|
||
|
||
void GateKillNonInteractingParticleActor::PreUserTrackingAction(const G4Track* track) { | ||
fIsFirstStep = true; | ||
fKineticEnergyAtTheEntrance = 0; | ||
ftrackIDAtTheEntrance = 0; | ||
fPassedByTheMotherVolume = false; | ||
|
||
} | ||
|
||
void GateKillNonInteractingParticleActor::SteppingAction(G4Step *step) { | ||
|
||
G4String logicalVolumeNamePostStep = step->GetPostStepPoint()->GetPhysicalVolume()->GetLogicalVolume()->GetName(); | ||
if ((fPassedByTheMotherVolume) && (step->GetPostStepPoint()->GetStepStatus() == 1)){ | ||
if (std::find(fListOfVolumeAncestor.begin(), fListOfVolumeAncestor.end(),logicalVolumeNamePostStep ) !=fListOfVolumeAncestor.end()){ | ||
if ((step->GetTrack()->GetTrackID() == ftrackIDAtTheEntrance) && (step->GetPostStepPoint()->GetKineticEnergy() == fKineticEnergyAtTheEntrance)){ | ||
auto track = step->GetTrack(); | ||
track->SetTrackStatus(fStopAndKill); | ||
fNbOfKilledParticles++; | ||
} | ||
} | ||
} | ||
|
||
G4String logNameMotherVolume = G4LogicalVolumeStore::GetInstance()->GetVolume(fMotherVolumeName)->GetName(); | ||
G4String physicalVolumeNamePreStep = step->GetPreStepPoint()->GetPhysicalVolume()->GetName(); | ||
if ((step->GetTrack()->GetLogicalVolumeAtVertex()->GetName() != logNameMotherVolume) && (fIsFirstStep)){ | ||
if ((fPassedByTheMotherVolume == false) && (physicalVolumeNamePreStep == fMotherVolumeName) && (step->GetPreStepPoint()->GetStepStatus() == 1)){ | ||
fPassedByTheMotherVolume =true; | ||
fKineticEnergyAtTheEntrance = step->GetPreStepPoint()->GetKineticEnergy(); | ||
ftrackIDAtTheEntrance = step->GetTrack()->GetTrackID(); | ||
} | ||
} | ||
|
||
fIsFirstStep = false; | ||
} |
43 changes: 43 additions & 0 deletions
43
core/opengate_core/opengate_lib/GateKillNonInteractingParticleActor.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* -------------------------------------------------- | ||
Copyright (C): OpenGATE Collaboration | ||
This software is distributed under the terms | ||
of the GNU Lesser General Public Licence (LGPL) | ||
See LICENSE.md for further details | ||
-------------------------------------------------- */ | ||
|
||
#ifndef GateKillNonInteractingParticleActor_h | ||
#define GateKillNonInteractingParticleActor_h | ||
|
||
#include "G4Cache.hh" | ||
#include "GateVActor.h" | ||
#include <pybind11/stl.h> | ||
|
||
namespace py = pybind11; | ||
|
||
class GateKillNonInteractingParticleActor : public GateVActor { | ||
|
||
public: | ||
// Constructor | ||
GateKillNonInteractingParticleActor(py::dict &user_info); | ||
|
||
void ActorInitialize() override; | ||
|
||
void StartSimulationAction() override; | ||
|
||
// Main function called every step in attached volume | ||
void SteppingAction(G4Step *) override; | ||
|
||
void PreUserTrackingAction(const G4Track*) override; | ||
|
||
std::vector<G4String> fParticlesTypeToKill; | ||
G4bool fPassedByTheMotherVolume= false; | ||
G4double fKineticEnergyAtTheEntrance = 0; | ||
G4int ftrackIDAtTheEntrance = 0; | ||
G4bool fIsFirstStep = true; | ||
std::vector<std::string> fListOfVolumeAncestor; | ||
|
||
|
||
long fNbOfKilledParticles{}; | ||
}; | ||
|
||
#endif |
19 changes: 19 additions & 0 deletions
19
core/opengate_core/opengate_lib/pyGateKillNonInteractingParticleActor.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* -------------------------------------------------- | ||
Copyright (C): OpenGATE Collaboration | ||
This software is distributed under the terms | ||
of the GNU Lesser General Public Licence (LGPL) | ||
See LICENSE.md for further details | ||
-------------------------------------------------- */ | ||
|
||
#include <pybind11/pybind11.h> | ||
|
||
namespace py = pybind11; | ||
|
||
#include "GateKillNonInteractingParticleActor.h" | ||
|
||
void init_GateKillNonInteractingParticleActor(py::module &m) { | ||
py::class_<GateKillNonInteractingParticleActor, std::unique_ptr<GateKillNonInteractingParticleActor, py::nodelete>, | ||
GateVActor>(m, "GateKillNonInteractingParticleActor") | ||
.def_readwrite("fListOfVolumeAncestor", &GateKillNonInteractingParticleActor::fListOfVolumeAncestor) | ||
.def(py::init<py::dict &>()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.