6#include "G4EventManager.hh"
7#include "G4RunManager.hh"
15#include "SimCore/G4User/VolumeChecks.h"
16#include "SimCore/UserEventInformation.h"
17#include "SimCore/UserTrackInformation.h"
23 : simcore::UserAction(name, parameters) {
25 processes_ = parameters.getParameter<std::vector<std::string>>(
"processes");
26 ecal_min_Z_ = parameters.getParameter<
double>(
"ecal_min_Z");
28 parameters.getParameter<
bool>(
"require_photon_fromTarget");
38 auto track{step->GetTrack()};
41 auto processName = track->GetCreatorProcess()
42 ? track->GetCreatorProcess()->GetProcessName()
44 auto PDGid = track->GetParticleDefinition()->GetPDGEncoding();
48 if (processName.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 (processName.contains(
"eBrem") and (track->GetParentID() == 1)) {
63 trackInfo->tagBremCandidate();
65 trackInfo->setSaveFlag(
true);
66 if (volume_name.contains(
"target")) {
78 bool hasProcessNeeded{
false};
82 if (processName.contains(process)) {
83 hasProcessNeeded =
true;
88 if (not hasProcessNeeded)
return;
91 simcore::g4user::volumechecks::isInEcal(volume, volume_name);
95 if (not is_in_ecal)
return;
99 auto zPosition = step->GetPreStepPoint()->GetPosition().z();
102 ldmx_log(debug) <<
" Particle ID " << PDGid <<
" with energy "
103 << track->GetKineticEnergy() <<
" on " << volume <<
" from "
104 << processName <<
" at Z = " << zPosition;
114 ldmx_log(debug) <<
"> Event with a hard deep conversion found, yaaay!";
115 ldmx_log(debug) <<
"> -----------------------------------------";
118 G4RunManager::GetRunManager()->AbortEvent();
Class defining a UserActionPlugin that allows a user to filter out events where the interaction happe...
void NewStage() override
Method called at the end of every event.
bool hasDeepEcalProcess_
member used to help tag events that have a deep-ecal process ocurr
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.
double bias_threshold_
Minimal energy the products should have.
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.
bool photonFromTarget_
member used to help tag events where the photon comes from the target
double ecal_min_Z_
Minimum Z location where the deep process should happen.
bool require_photon_fromTarget_
Require that the hard brem photon originates from the target.
Class encapsulating parameters for configuring a processor.
UserEventInformation * getEventInfo() const
Get a handle to the event information.