1#include "Biasing/MidShowerDiMuonBkgdFilter.h"
3#include "G4EventManager.hh"
5#include "G4RunManager.hh"
7#include "SimCore/UserTrackInformation.h"
13 : simcore::UserAction(name, parameters) {
38 if (step->GetTrack()->GetParticleDefinition() != G4Gamma::Gamma())
return;
42 const G4TrackVector* secondaries{step->GetSecondary()};
43 if (secondaries ==
nullptr or secondaries->size() == 0)
return;
45 bool found_muon{
false};
46 for (
const G4Track* secondary : *secondaries) {
47 if (abs(secondary->GetParticleDefinition()->GetPDGEncoding()) == 13) {
52 if (not found_muon)
return;
54 double pre_energy = step->GetPreStepPoint()->GetTotalEnergy();
55 double post_energy = step->GetPostStepPoint()->GetTotalEnergy();
57 const G4Track* track = step->GetTrack();
83 AbortEvent(
"Not enough energy went to the input process.");
88 const G4Step* step)
const {
90 auto reg{step->GetTrack()->GetVolume()->GetLogicalVolume()->GetRegion()};
91 if (reg)
return (reg->GetName() !=
"CalorimeterRegion");
104 if (G4RunManager::GetRunManager()->GetVerboseLevel() > 1) {
105 std::cout <<
"[ MidShowerDiMuonBkgdFilter ]: "
107 << G4EventManager::GetEventManager()
108 ->GetConstCurrentEvent()
110 <<
") " << reason <<
" Aborting event." << std::endl;
112 G4RunManager::GetRunManager()->AbortEvent();
117DECLARE_ACTION(biasing, MidShowerDiMuonBkgdFilter)
bool isOutsideCalorimeterRegion(const G4Step *step) const
Checks if the passed step is outside of the CalorimeterRegion.
double total_process_energy_
Total energy gone to the process in the current event.
MidShowerDiMuonBkgdFilter(const std::string &name, framework::config::Parameters ¶meters)
Class constructor.
void AbortEvent(const std::string &reason) const
Helper to abort an event with a message.
void save(const G4Track *track) const
Helper to save the passed track.
double threshold_
Minimum energy [MeV] that the process products need to have to keep the event.
void NewStage() override
When using the PartialEnergySorter, the first time that a new stage begins is when all particles are ...
void BeginOfEventAction(const G4Event *event) override
Reset the total energy going to the muons.
void stepping(const G4Step *step) override
We follow the simulation along each step and check if any secondaries of the input process were creat...
Class encapsulating parameters for configuring a processor.
T getParameter(const std::string &name) const
Retrieve the parameter of the given name.