6#include "G4EventManager.hh"
7#include "G4RunManager.hh"
15#include "SimCore/G4User/UserEventInformation.h"
16#include "SimCore/G4User/UserTrackInformation.h"
17#include "SimCore/G4User/VolumeChecks.h"
23 :
simcore::UserAction(name, parameters) {
25 processes_ = parameters.
get<std::vector<std::string>>(
"processes");
28 parameters.
get<
bool>(
"require_photon_fromTarget");
38 auto track{step->GetTrack()};
41 auto process_name = track->GetCreatorProcess()
42 ? track->GetCreatorProcess()->GetProcessName()
44 auto pd_gid = track->GetParticleDefinition()->GetPDGEncoding();
48 if (process_name.contains(
"unknown"))
return;
56 auto phys_vol{track->GetVolume()};
57 auto volume{phys_vol ? phys_vol->GetLogicalVolume() :
nullptr};
58 auto volume_name{volume ? volume->GetName() :
"undefined"};
62 if (process_name.contains(
"eBrem") and (track->GetParentID() == 1)) {
63 track_info->tagBremCandidate();
65 track_info->setSaveFlag(
true);
66 if (volume_name.contains(
"target")) {
78 bool has_process_needed{
false};
82 if (process_name.contains(process)) {
83 has_process_needed =
true;
88 if (not has_process_needed)
return;
91 simcore::g4user::volumechecks::isInEcal(volume, volume_name);
95 if (not is_in_ecal)
return;
99 auto z_position = step->GetPreStepPoint()->GetPosition().z();
102 ldmx_log(debug) <<
" Particle ID " << pd_gid <<
" with energy "
103 << track->GetKineticEnergy() <<
" on " << volume <<
" from "
104 << process_name <<
" at Z = " << z_position;
114 ldmx_log(debug) <<
"> Event with a hard deep conversion found, yaaay!";
115 ldmx_log(debug) <<
"> -----------------------------------------";
118 G4RunManager::GetRunManager()->AbortEvent();
#define DECLARE_ACTION(CLASS)
register a new UserAction with its factory
User action that allows a user to filter out events where the interaction happened deep in the ECAL.
bool require_photon_from_target_
Require that the hard brem photon originates from the target.
void NewStage() override
Method called at the end of every event.
double ecal_min_z_
Minimum Z location where the deep process should happen.
DeepEcalProcessFilter(const std::string &name, framework::config::Parameters ¶meters)
Constructor.
void stepping(const G4Step *step) override
Implement the stepping action which performs the target volume biasing.
bool has_deep_ecal_process_
member used to help tag events that have a deep-ecal process ocurr
double bias_threshold_
Minimal energy the products should have.
bool photon_from_target_
member used to help tag events where the photon comes from the target
std::vector< std::string > processes_
The allowed processes that can happen deep inside the ECAL, default is conversion (conv) and photoele...
void BeginOfEventAction(const G4Event *event) override
Method to set flags in the beginning of the event.
Class encapsulating parameters for configuring a processor.
const T & get(const std::string &name) const
Retrieve the parameter of the given name.
UserEventInformation * getEventInfo() const
Get a handle to the event information.
Dynamically loadable photonuclear models either from SimCore or external libraries implementing this ...