1#include "Biasing/MidShowerNuclearBkgdFilter.h"
3#include "G4EventManager.hh"
4#include "G4RunManager.hh"
6#include "SimCore/G4User/PtrRetrieval.h"
7#include "SimCore/G4User/UserTrackInformation.h"
13 :
simcore::UserAction(name, parameters) {
14 threshold_ = parameters.getParameter<
double>(
"threshold");
36 double pre_energy = step->GetPreStepPoint()->GetTotalEnergy();
37 double post_energy = step->GetPostStepPoint()->GetTotalEnergy();
40 const G4Track* track = step->GetTrack();
55 }
else if (
const G4Track * track{step->GetTrack()};
56 track->GetCurrentStepNumber() == 1 and
71 AbortEvent(
"Not enough energy went to the input process.");
76 const G4Step* step)
const {
77 static auto calorimeter_region =
78 simcore::g4user::ptrretrieval::getRegion(
"CalorimeterRegion");
79 if (!calorimeter_region) {
81 <<
"Region 'CalorimeterRegion' not found in Geant4 region store";
84 auto phys_vol{step->GetTrack()->GetVolume()};
85 auto log_vol{phys_vol ? phys_vol->GetLogicalVolume() :
nullptr};
86 auto reg{log_vol ? log_vol->GetRegion() :
nullptr};
87 return (reg != calorimeter_region);
91 const G4VProcess* proc)
const {
93 const G4String& proc_name{proc->GetProcessName()};
95 if (proc_name.contains(option))
return true;
103 track_info->setSaveFlag(
true);
108 if (G4RunManager::GetRunManager()->GetVerboseLevel() > 1) {
109 std::cout <<
"[ MidShowerNuclearBkgdFilter ]: " <<
"("
110 << G4EventManager::GetEventManager()
111 ->GetConstCurrentEvent()
113 <<
") " << reason <<
" Aborting event." << std::endl;
115 G4RunManager::GetRunManager()->AbortEvent();
#define DECLARE_ACTION(CLASS)
register a new UserAction with its factory
The basic premis of this filter is to add up all of the energy "lost" to the configured process.
void save(const G4Track *track) const
Helper to save the passed track.
void AbortEvent(const std::string &reason) const
Helper to abort an event with a message.
void BeginOfEventAction(const G4Event *event) override
Reset the total energy going to the configured process.
bool isOutsideCalorimeterRegion(const G4Step *step) const
Checks if the passed step is outside of the CalorimeterRegion.
void NewStage() override
When using the PartialEnergySorter, the first time that a new stage begins is when all particles are ...
MidShowerNuclearBkgdFilter(const std::string &name, framework::config::Parameters ¶meters)
Class constructor.
bool isNuclearProcess(const G4VProcess *proc) const
Checks if the passed process is any of the nuclear interactions.
void stepping(const G4Step *step) override
We follow the simulation along each step and check if any secondaries of the input process were creat...
double threshold_
Minimum energy [MeV] that the process products need to have to keep the event.
std::vector< std::string > nuclear_processes_
Processes to look for.
double total_process_energy_
Total energy gone to the process in the current event.
Class encapsulating parameters for configuring a processor.
UserEventInformation * getEventInfo() const
Get a handle to the event information.
Dynamically loadable photonuclear models either from SimCore or external libraries implementing this ...