LDMX Software
biasing::TargetENProcessFilter Class Reference

Public Member Functions

 TargetENProcessFilter (const std::string &name, framework::config::Parameters &parameters)
 Class constructor.
 
 ~TargetENProcessFilter ()
 Destructor.
 
void stepping (const G4Step *step) override
 Implementmthe stepping action which performs the target volume biasing.
 
void EndOfEventAction (const G4Event *) override
 End of event action.
 
std::vector< simcore::TYPEgetTypes () 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.
 
 DECLARE_FACTORY (UserAction, std::shared_ptr< UserAction >, const std::string &, framework::config::Parameters &)
 factory for user actions
 
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 G4ClassificationOfNewTrack ClassifyNewTrack (const G4Track *, const G4ClassificationOfNewTrack &cl)
 Method called when a track is updated.
 
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

bool reaction_occurred_ {false}
 Flag indicating if the reaction of intereset occurred.
 
double recoil_energy_threshold_ {1500}
 Energy that the recoil electron must not surpass.
 
std::string process_ {"electronNuclear"}
 Process to filter on.
 

Additional Inherited Members

- 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 the_log_
 the logging channel user actions can use ldmx_log with
 

Detailed Description

Definition at line 27 of file TargetENProcessFilter.h.

Constructor & Destructor Documentation

◆ TargetENProcessFilter()

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

Class constructor.

Definition at line 24 of file TargetENProcessFilter.cxx.

26 : simcore::UserAction(name, parameters) {
27 recoil_energy_threshold_ = parameters.get<double>("recoilThreshold");
28}
double recoil_energy_threshold_
Energy that the recoil electron must not surpass.
const T & get(const std::string &name) const
Retrieve the parameter of the given name.
Definition Parameters.h:78
Interface that defines a user action.
Definition UserAction.h:47

References framework::config::Parameters::get(), and recoil_energy_threshold_.

◆ ~TargetENProcessFilter()

biasing::TargetENProcessFilter::~TargetENProcessFilter ( )

Destructor.

Definition at line 30 of file TargetENProcessFilter.cxx.

30{}

Member Function Documentation

◆ EndOfEventAction()

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

End of event action.

Reimplemented from simcore::UserAction.

Definition at line 102 of file TargetENProcessFilter.cxx.

102 {
103 reaction_occurred_ = false;
104}
bool reaction_occurred_
Flag indicating if the reaction of intereset occurred.

References reaction_occurred_.

◆ getTypes()

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

Retrieve the type of actions this class defines.

Implements simcore::UserAction.

Definition at line 50 of file TargetENProcessFilter.h.

50 {
51 return {simcore::TYPE::EVENT, simcore::TYPE::STEPPING};
52 }

◆ stepping()

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

Implementmthe stepping action which performs the target volume biasing.

Parameters
stepThe Geant4 step.

Reimplemented from simcore::UserAction.

Definition at line 32 of file TargetENProcessFilter.cxx.

32 {
33 if (reaction_occurred_) return;
34
35 // Get the track associated with this step.
36 G4Track* track = step->GetTrack();
37
38 // Only process tracks whose parent is the primary particle
39 if (track->GetParentID() != 0) return;
40
41 // get the PDGID of the track.
42 G4int pdg_id = track->GetParticleDefinition()->GetPDGEncoding();
43
44 // Make sure that the particle being processed is an electron.
45 if (pdg_id != 11) return; // Throw an exception
46
47 // Get the volume the particle is in.
48 G4VPhysicalVolume* track_volume = track->GetVolume();
49 auto target_volume =
50 simcore::g4user::ptrretrieval::getPhysicalVolume("target_PV");
51 if (!target_volume) {
52 ldmx_log(warn) << "Volume 'target_PV' not found in Geant4 volume store";
53 }
54 // If the particle isn't in the target, don't continue with the processing.
55 if (track_volume != target_volume) return;
56
57 // ldmx_log(trace)<< "* Step " << track->GetCurrentStepNumber();
58
59 if (track->GetMomentum().mag() > recoil_energy_threshold_) {
60 track->SetTrackStatus(fKillTrackAndSecondaries);
61 G4RunManager::GetRunManager()->AbortEvent();
62 return;
63 }
64
65 // Get the particles daughters.
66 const G4TrackVector* secondaries = step->GetSecondary();
67
68 // If the brem photon doesn't undergo any reaction in the target, stop
69 // processing the rest of the event.
70 if (secondaries->size() == 0) {
71 ldmx_log(debug)
72 << "Electron did not interact in the target. --> Postponing tracks.";
73
74 track->SetTrackStatus(fKillTrackAndSecondaries);
75 G4RunManager::GetRunManager()->AbortEvent();
76 return;
77 } else {
78 G4String process_name =
79 secondaries->at(0)->GetCreatorProcess()->GetProcessName();
80
81 ldmx_log(debug) << "Electron produced " << secondaries->size()
82 << " particle via " << process_name << " process.";
83
84 // Only record the process that is being biased
85 if (!process_name.contains(process_)) {
86 ldmx_log(debug) << "Process was not " << process_
87 << "--> Killing all tracks!";
88
89 track->SetTrackStatus(fKillTrackAndSecondaries);
90 G4RunManager::GetRunManager()->AbortEvent();
91 return;
92 }
93
94 ldmx_log(info) << "Electronuclear reaction resulted in "
95 << secondaries->size() << " particles via " << process_name
96 << " process.";
97 // BiasingMessenger::setEventWeight(track->GetWeight());
98 reaction_occurred_ = true;
99 }
100}
std::string process_
Process to filter on.

References process_, reaction_occurred_, and recoil_energy_threshold_.

Member Data Documentation

◆ process_

std::string biasing::TargetENProcessFilter::process_ {"electronNuclear"}
private

Process to filter on.

Definition at line 62 of file TargetENProcessFilter.h.

62{"electronNuclear"};

Referenced by stepping().

◆ reaction_occurred_

bool biasing::TargetENProcessFilter::reaction_occurred_ {false}
private

Flag indicating if the reaction of intereset occurred.

Definition at line 56 of file TargetENProcessFilter.h.

56{false};

Referenced by EndOfEventAction(), and stepping().

◆ recoil_energy_threshold_

double biasing::TargetENProcessFilter::recoil_energy_threshold_ {1500}
private

Energy that the recoil electron must not surpass.

Definition at line 59 of file TargetENProcessFilter.h.

59{1500};

Referenced by stepping(), and TargetENProcessFilter().


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