LDMX Software
biasing::TargetBremFilter Class Reference

User action that allows a user to filter out events that don't result in a brem within the target. More...

#include <TargetBremFilter.h>

Public Member Functions

 TargetBremFilter (const std::string &name, framework::config::Parameters &parameters)
 Constructor.
 
 ~TargetBremFilter ()
 Destructor.
 
void stepping (const G4Step *step) override
 Implement the stepping action which performs the target volume biasing.
 
void EndOfEventAction (const G4Event *) override
 Method called at the end of every event.
 
G4ClassificationOfNewTrack ClassifyNewTrack (const G4Track *aTrack, const G4ClassificationOfNewTrack &currentTrackClass) override
 Classify a new track which postpones track processing.
 
std::vector< simcore::TYPE > getTypes () override
 Retrieve the type of actions this class defines.
 
- Public Member Functions inherited from simcore::UserAction
 UserAction (const std::string &name, framework::config::Parameters &parameters)
 Constructor.
 
virtual ~UserAction ()=default
 Destructor.
 
virtual void BeginOfEventAction (const G4Event *)
 Method called at the beginning of every event.
 
virtual void BeginOfRunAction (const G4Run *)
 Method called at the beginning of a run.
 
virtual void EndOfRunAction (const G4Run *)
 Method called at the end of a run.
 
virtual void PreUserTrackingAction (const G4Track *)
 Method called before the UserTrackingAction.
 
virtual void PostUserTrackingAction (const G4Track *)
 Method called after the UserTrackingAction.
 
virtual void NewStage ()
 Method called at the beginning of a new stage.
 
virtual void PrepareNewEvent ()
 Method called at the beginning of a new event.
 

Private Attributes

double recoilMaxPThreshold_ {1500}
 Recoil electron threshold.
 
double bremEnergyThreshold_ {2500}
 Brem gamma energy treshold.
 
bool killRecoil_ {false}
 Flag indicating if the recoil electron track should be killed.
 

Additional Inherited Members

- Public Types inherited from simcore::UserAction
using Factory
 factory for user actions
 
- Protected Member Functions inherited from simcore::UserAction
UserEventInformationgetEventInfo () const
 Get a handle to the event information.
 
const std::map< int, ldmx::SimParticle > & getCurrentParticleMap () const
 Get the current particle map.
 
- Protected Attributes inherited from simcore::UserAction
std::string name_ {""}
 Name of the UserAction.
 
framework::config::Parameters parameters_
 The set of parameters used to configure this class.
 
mutable::framework::logging::logger theLog_
 the logging channel user actions can use ldmx_log with
 

Detailed Description

User action that allows a user to filter out events that don't result in a brem within the target.

Definition at line 26 of file TargetBremFilter.h.

Constructor & Destructor Documentation

◆ TargetBremFilter()

biasing::TargetBremFilter::TargetBremFilter ( const std::string & name,
framework::config::Parameters & parameters )

Constructor.

Definition at line 22 of file TargetBremFilter.cxx.

24 : simcore::UserAction(name, parameters) {
26 parameters.getParameter<double>("recoil_max_p_threshold");
28 parameters.getParameter<double>("brem_min_energy_threshold");
29 killRecoil_ = parameters.getParameter<bool>("kill_recoil_track");
30}
bool killRecoil_
Flag indicating if the recoil electron track should be killed.
double recoilMaxPThreshold_
Recoil electron threshold.
double bremEnergyThreshold_
Brem gamma energy treshold.
Interface that defines a user action.
Definition UserAction.h:43

References bremEnergyThreshold_, killRecoil_, and recoilMaxPThreshold_.

◆ ~TargetBremFilter()

biasing::TargetBremFilter::~TargetBremFilter ( )

Destructor.

Definition at line 32 of file TargetBremFilter.cxx.

32{}

Member Function Documentation

◆ ClassifyNewTrack()

G4ClassificationOfNewTrack biasing::TargetBremFilter::ClassifyNewTrack ( const G4Track * aTrack,
const G4ClassificationOfNewTrack & currentTrackClass )
overridevirtual

Classify a new track which postpones track processing.

Track processing resumes normally if a target PN interaction occurred.

Parameters
aTrackThe Geant4 track.
currentTrackClassThe current track classification.

Reimplemented from simcore::UserAction.

Definition at line 34 of file TargetBremFilter.cxx.

35 {
36 // get the PDGID of the track.
37 G4int pdgID = track->GetParticleDefinition()->GetPDGEncoding();
38
39 // Get the particle type.
40 G4String particleName = track->GetParticleDefinition()->GetParticleName();
41
42 // Use current classification by default so values from other plugins are not
43 // overridden.
44 G4ClassificationOfNewTrack classification = currentTrackClass;
45
46 if (track->GetTrackID() == 1 && pdgID == 11) {
47 return fWaiting;
48 }
49
50 return classification;
51}

◆ EndOfEventAction()

void biasing::TargetBremFilter::EndOfEventAction ( const G4Event * )
overridevirtual

Method called at the end of every event.

Parameters
eventGeant4 event object.

Reimplemented from simcore::UserAction.

Definition at line 167 of file TargetBremFilter.cxx.

167{}

◆ getTypes()

std::vector< simcore::TYPE > biasing::TargetBremFilter::getTypes ( )
inlineoverridevirtual

Retrieve the type of actions this class defines.

Implements simcore::UserAction.

Definition at line 59 of file TargetBremFilter.h.

59 {
60 return {simcore::TYPE::EVENT, simcore::TYPE::STACKING,
61 simcore::TYPE::STEPPING};
62 }

◆ stepping()

void biasing::TargetBremFilter::stepping ( const G4Step * step)
overridevirtual

Implement the stepping action which performs the target volume biasing.

Parameters
stepThe Geant4 step.

Check if the electron will be exiting the target

The 'recoil_PV' volume name is automatically constructed by Geant4's GDML parser and was found by inspecting the geometry using a visualization. This Physical Volume (PV) is associated with the recoil parent volume and so it will break if the recoil parent volume changes its name.

We also check if the next volume is World_PV because in some geometries (e.g. v14), there is a air-gap between the target region and the recoil.

Reimplemented from simcore::UserAction.

Definition at line 53 of file TargetBremFilter.cxx.

53 {
54 // Get the track associated with this step.
55 auto track{step->GetTrack()};
56
57 // Only process the primary electron track
58 if (track->GetParentID() != 0) return;
59
60 // Get the PDG ID of the track and make sure it's an electron. If
61 // another particle type is found, thrown an exception.
62 if (auto pdgID{track->GetParticleDefinition()->GetPDGEncoding()}; pdgID != 11)
63 return;
64
65 // Get the region the particle is currently in. Continue processing
66 // the particle only if it's in the target region.
67 static auto target_region =
68 simcore::g4user::ptrretrieval::getRegion("target");
69 if (!target_region) {
70 ldmx_log(warn) << "Region 'target' not found in Geant4 region store";
71 }
72 auto phy_vol{track->GetVolume()};
73 auto log_vol{phy_vol ? phy_vol->GetLogicalVolume() : nullptr};
74 auto track_region{log_vol ? log_vol->GetRegion() : nullptr};
75 if (track_region != target_region) return;
76
77 /*
78 std::cout << "[TargetBremFilter] : Stepping primary electron in 'target'
79 region into "
80 << track->GetNextVolume()->GetName()
81 << std::endl;
82 */
83
96 auto recoil_physical_volume =
97 simcore::g4user::ptrretrieval::getPhysicalVolume("recoil_PV");
98 auto world_physical_volume =
99 simcore::g4user::ptrretrieval::getPhysicalVolume("World_PV");
100 if (!recoil_physical_volume) {
101 ldmx_log(warn) << "Volume 'recoil_PV' not found in Geant4 volume store";
102 }
103 if (!world_physical_volume) {
104 ldmx_log(warn) << "Volume 'World_PV' not found in Geant4 volume store";
105 }
106 auto track_volume = track->GetNextVolume();
107 if (track_volume == recoil_physical_volume or
108 track_volume == world_physical_volume) {
109 // If the recoil electron
110 if (track->GetMomentum().mag() >= recoilMaxPThreshold_) {
111 track->SetTrackStatus(fKillTrackAndSecondaries);
112 G4RunManager::GetRunManager()->AbortEvent();
113 return;
114 }
115
116 // Get the electron secondries
117 bool hasBremCandidate = false;
118 if (auto secondaries = step->GetSecondary(); secondaries->size() == 0) {
119 track->SetTrackStatus(fKillTrackAndSecondaries);
120 G4RunManager::GetRunManager()->AbortEvent();
121 return;
122 } else {
123 for (auto& secondary_track : *secondaries) {
124 auto electron = G4Electron::Definition();
125 auto ebrem_process =
126 simcore::g4user::ptrretrieval::getProcess(electron, "eBrem");
127 if (!ebrem_process) {
128 ldmx_log(warn) << "Process 'eBrem' not found in Geant4 process store";
129 }
130
131 if (ebrem_process &&
132 secondary_track->GetKineticEnergy() > bremEnergyThreshold_) {
133 auto trackInfo{simcore::UserTrackInformation::get(secondary_track)};
134 trackInfo->tagBremCandidate();
135
137
138 hasBremCandidate = true;
139 }
140 }
141 }
142
143 if (!hasBremCandidate) {
144 track->SetTrackStatus(fKillTrackAndSecondaries);
145 G4RunManager::GetRunManager()->AbortEvent();
146 return;
147 }
148
149 /*
150 std::cout << "[TargetBremFilter] : Found brem candidate" << std::endl;
151 */
152
153 // Check if the recoil electron should be killed. If not, postpone
154 // its processing until the brem gamma has been processed.
155 if (killRecoil_)
156 track->SetTrackStatus(fStopAndKill);
157 else
158 track->SetTrackStatus(fSuspend);
159
160 } else if (step->GetPostStepPoint()->GetKineticEnergy() == 0) {
161 track->SetTrackStatus(fKillTrackAndSecondaries);
162 G4RunManager::GetRunManager()->AbortEvent();
163 return;
164 }
165}
UserEventInformation * getEventInfo() const
Get a handle to the event information.
void incBremCandidateCount()
Increment the number of brem candidates in an event.
static UserTrackInformation * get(const G4Track *track)
get

References bremEnergyThreshold_, simcore::UserTrackInformation::get(), simcore::UserAction::getEventInfo(), simcore::UserEventInformation::incBremCandidateCount(), killRecoil_, and recoilMaxPThreshold_.

Member Data Documentation

◆ bremEnergyThreshold_

double biasing::TargetBremFilter::bremEnergyThreshold_ {2500}
private

Brem gamma energy treshold.

Definition at line 69 of file TargetBremFilter.h.

69{2500};

Referenced by stepping(), and TargetBremFilter().

◆ killRecoil_

bool biasing::TargetBremFilter::killRecoil_ {false}
private

Flag indicating if the recoil electron track should be killed.

Definition at line 72 of file TargetBremFilter.h.

72{false};

Referenced by stepping(), and TargetBremFilter().

◆ recoilMaxPThreshold_

double biasing::TargetBremFilter::recoilMaxPThreshold_ {1500}
private

Recoil electron threshold.

Definition at line 66 of file TargetBremFilter.h.

66{1500}; // MeV

Referenced by stepping(), and TargetBremFilter().


The documentation for this class was generated from the following files: