12#include "G4DarkBreM/G4APrime.h"
13#include "G4Electron.hh"
14#include "SimCore/UserTrackInformation.h"
20 : simcore::UserAction(name, parameters) {
30 if (G4EventManager::GetEventManager()->GetConstCurrentEvent()->IsAborted())
34 auto track{step->GetTrack()};
37 auto particle_def{track->GetParticleDefinition()};
38 if (particle_def != G4Electron::Electron()) {
39 if (particle_def == G4APrime::APrime() and
40 track->GetCurrentStepNumber() == 1) {
54 AbortEvent(
"A' was not created within target.");
62 if (track->GetParentID() != 0)
return;
69 track->GetTrackStatus() == fStopAndKill
70 or track->GetKineticEnergy() == 0.
73 const std::vector<G4Track*>* secondaries{step->GetSecondary()};
74 if (not secondaries or secondaries->size() == 0) {
75 AbortEvent(
"Primary electron did not create secondaries.");
79 for (
auto& secondary_track : *secondaries) {
80 if (secondary_track->GetParticleDefinition() == G4APrime::APrime()) {
83 if (secondary_track->GetTotalEnergy() <
threshold_) {
85 "A' was not created with total energy above input threshold.");
90 AbortEvent(
"A' was not created within target.");
113 AbortEvent(
"Primary electron did not create A'.");
124 AbortEvent(
"Did not find an A' after entire event was simulated.");
129 if (G4RunManager::GetRunManager()->GetVerboseLevel() > 1) {
130 std::cout <<
"[ TargetDarkBremFilter ]: "
132 << G4EventManager::GetEventManager()
133 ->GetConstCurrentEvent()
135 <<
") " << reason <<
" Aborting event." << std::endl;
137 G4RunManager::GetRunManager()->AbortEvent();
Class defining a UserActionPlugin that allows a user to filter out events that don't result in a dark...
void stepping(const G4Step *step) override
Looking for A' while primary is stepping.
TargetDarkBremFilter(const std::string &name, framework::config::Parameters ¶meters)
Class constructor.
double threshold_
Minimum energy [MeV] that the A' should have to keep the event.
bool isOutsideTargetRegion(const G4VPhysicalVolume *vol) const
Check if the volume is outside the target region.
void EndOfEventAction(const G4Event *event) override
Check flag signaling finding of A', if false, abort the event so it isn't saved.
void BeginOfEventAction(const G4Event *e) override
Reset flag signaling finding of A' to false.
void AbortEvent(const std::string &reason) const
Helper to abort an event with a message.
bool found_aprime_
flag to signal that we saw an A'
Class encapsulating parameters for configuring a processor.
T getParameter(const std::string &name) const
Retrieve the parameter of the given name.