47 auto track{step->GetTrack()};
49 if (G4EventManager::GetEventManager()->GetConstCurrentEvent()->IsAborted())
54 if ((trackInfo !=
nullptr) && !trackInfo->isBremCandidate())
return;
57 auto secondaries{step->GetSecondary()};
61 static auto target_region =
62 simcore::g4user::ptrretrieval::getRegion(
"target");
64 ldmx_log(warn) <<
"Region 'target' not found in Geant4 region store";
66 auto phy_vol{track->GetVolume()};
67 auto log_vol{phy_vol ? phy_vol->GetLogicalVolume() :
nullptr};
68 auto current_region{log_vol ? log_vol->GetRegion() :
nullptr};
69 if (current_region != target_region) {
73 if (secondaries->size() != 0) {
75 track->SetTrackStatus(fKillTrackAndSecondaries);
76 G4RunManager::GetRunManager()->AbortEvent();
80 track->SetTrackStatus(fSuspend);
82 trackInfo->tagBremCandidate(
false);
91 if (secondaries->size() == 0) {
104 static auto recoil_physical_volume =
105 simcore::g4user::ptrretrieval::getPhysicalVolume(
"recoil_PV");
106 static auto world_physical_volume =
107 simcore::g4user::ptrretrieval::getPhysicalVolume(
"World_PV");
109 if (!recoil_physical_volume) {
110 ldmx_log(warn) <<
"Volume 'recoil_PV' not found in Geant4 volume store";
112 if (!world_physical_volume) {
113 ldmx_log(warn) <<
"Volume 'World_PV' not found in Geant4 volume store";
116 auto current_volume = track->GetNextVolume();
117 if (current_volume == recoil_physical_volume or
118 current_volume == world_physical_volume) {
120 track->SetTrackStatus(fKillTrackAndSecondaries);
121 G4RunManager::GetRunManager()->AbortEvent();
125 track->SetTrackStatus(fSuspend);
127 trackInfo->tagBremCandidate(
false);
134 G4String processName =
135 secondaries->at(0)->GetCreatorProcess()->GetProcessName();
138 if (!processName.contains(
process_)) {
140 track->SetTrackStatus(fKillTrackAndSecondaries);
141 G4RunManager::GetRunManager()->AbortEvent();
145 track->SetTrackStatus(fSuspend);
147 trackInfo->tagBremCandidate(
false);
152 if (G4RunManager::GetRunManager()->GetVerboseLevel() > 1) {
153 std::cout <<
"[ TargetProcessFilter ]: "
154 << G4EventManager::GetEventManager()
155 ->GetConstCurrentEvent()
157 <<
" Brem photon produced " << secondaries->size()
158 <<
" particle via " << processName <<
" process." << std::endl;
160 trackInfo->tagBremCandidate(
false);
161 trackInfo->setSaveFlag(
true);
162 trackInfo->tagPNGamma();