LDMX Software
Public Member Functions | Private Attributes | List of all members
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 = ::simcore::Factory< UserAction, std::shared_ptr< UserAction >, const std::string &, framework::config::Parameters & >
 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.
 

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 25 of file TargetBremFilter.h.

Constructor & Destructor Documentation

◆ TargetBremFilter()

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

Constructor.

Definition at line 18 of file TargetBremFilter.cxx.

20 : simcore::UserAction(name, parameters) {
22 parameters.getParameter<double>("recoil_max_p_threshold");
24 parameters.getParameter<double>("brem_min_energy_threshold");
25 killRecoil_ = parameters.getParameter<bool>("kill_recoil_track");
26}
bool killRecoil_
Flag indicating if the recoil electron track should be killed.
double recoilMaxPThreshold_
Recoil electron threshold.
double bremEnergyThreshold_
Brem gamma energy treshold.
T getParameter(const std::string &name) const
Retrieve the parameter of the given name.
Definition Parameters.h:89
Interface that defines a user action.
Definition UserAction.h:42

References bremEnergyThreshold_, framework::config::Parameters::getParameter(), killRecoil_, and recoilMaxPThreshold_.

◆ ~TargetBremFilter()

biasing::TargetBremFilter::~TargetBremFilter ( )

Destructor.

Definition at line 28 of file TargetBremFilter.cxx.

28{}

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 30 of file TargetBremFilter.cxx.

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

◆ 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 143 of file TargetBremFilter.cxx.

143{}

◆ getTypes()

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

Retrieve the type of actions this class defines.

Implements simcore::UserAction.

Definition at line 58 of file TargetBremFilter.h.

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

◆ 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 49 of file TargetBremFilter.cxx.

49 {
50 // Get the track associated with this step.
51 auto track{step->GetTrack()};
52
53 // Only process the primary electron track
54 if (track->GetParentID() != 0) return;
55
56 // Get the PDG ID of the track and make sure it's an electron. If
57 // another particle type is found, thrown an exception.
58 if (auto pdgID{track->GetParticleDefinition()->GetPDGEncoding()}; pdgID != 11)
59 return;
60
61 // Get the region the particle is currently in. Continue processing
62 // the particle only if it's in the target region.
63 if (auto region{
64 track->GetVolume()->GetLogicalVolume()->GetRegion()->GetName()};
65 region.compareTo("target") != 0)
66 return;
67
68 /*
69 std::cout << "[TargetBremFilter] : Stepping primary electron in 'target'
70 region into "
71 << track->GetNextVolume()->GetName()
72 << std::endl;
73 */
74
87 if (auto volume{track->GetNextVolume()->GetName()};
88 volume.compareTo("recoil_PV") == 0 or volume.compareTo("World_PV") == 0) {
89 // If the recoil electron
90 if (track->GetMomentum().mag() >= recoilMaxPThreshold_) {
91 track->SetTrackStatus(fKillTrackAndSecondaries);
92 G4RunManager::GetRunManager()->AbortEvent();
93 return;
94 }
95
96 // Get the electron secondries
97 bool hasBremCandidate = false;
98 if (auto secondaries = step->GetSecondary(); secondaries->size() == 0) {
99 track->SetTrackStatus(fKillTrackAndSecondaries);
100 G4RunManager::GetRunManager()->AbortEvent();
101 return;
102 } else {
103 for (auto& secondary_track : *secondaries) {
104 G4String processName =
105 secondary_track->GetCreatorProcess()->GetProcessName();
106
107 if (processName.compareTo("eBrem") == 0 &&
108 secondary_track->GetKineticEnergy() > bremEnergyThreshold_) {
109 auto trackInfo{simcore::UserTrackInformation::get(secondary_track)};
110 trackInfo->tagBremCandidate();
111
113
114 hasBremCandidate = true;
115 }
116 }
117 }
118
119 if (!hasBremCandidate) {
120 track->SetTrackStatus(fKillTrackAndSecondaries);
121 G4RunManager::GetRunManager()->AbortEvent();
122 return;
123 }
124
125 /*
126 std::cout << "[TargetBremFilter] : Found brem candidate" << std::endl;
127 */
128
129 // Check if the recoil electron should be killed. If not, postpone
130 // its processing until the brem gamma has been processed.
131 if (killRecoil_)
132 track->SetTrackStatus(fStopAndKill);
133 else
134 track->SetTrackStatus(fSuspend);
135
136 } else if (step->GetPostStepPoint()->GetKineticEnergy() == 0) {
137 track->SetTrackStatus(fKillTrackAndSecondaries);
138 G4RunManager::GetRunManager()->AbortEvent();
139 return;
140 }
141}
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
void tagBremCandidate(bool isBremCandidate=true)
Tag this track as a brem candidate by the biasing filters.

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

Member Data Documentation

◆ bremEnergyThreshold_

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

Brem gamma energy treshold.

Definition at line 68 of file TargetBremFilter.h.

68{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 71 of file TargetBremFilter.h.

71{false};

Referenced by stepping(), and TargetBremFilter().

◆ recoilMaxPThreshold_

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

Recoil electron threshold.

Definition at line 65 of file TargetBremFilter.h.

65{1500}; // MeV

Referenced by stepping(), and TargetBremFilter().


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