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::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 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 reactionOccurred_ {false}
 Flag indicating if the reaction of intereset occurred.
 
double recoilEnergyThreshold_ {1500}
 Energy that the recoil electron must not surpass.
 
std::string process_ {"electronNuclear"}
 Process to filter on.
 

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

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 recoilEnergyThreshold_ = parameters.getParameter<double>("recoilThreshold");
28}
double recoilEnergyThreshold_
Energy that the recoil electron must not surpass.
Interface that defines a user action.
Definition UserAction.h:43

References recoilEnergyThreshold_.

◆ ~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 110 of file TargetENProcessFilter.cxx.

110 {
111 reactionOccurred_ = false;
112}
bool reactionOccurred_
Flag indicating if the reaction of intereset occurred.

References reactionOccurred_.

◆ 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 (reactionOccurred_) 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 pdgID = track->GetParticleDefinition()->GetPDGEncoding();
43
44 // Make sure that the particle being processed is an electron.
45 if (pdgID != 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 /*std::cout << "*******************************" << std::endl;
58 std::cout << "* Step " << track->GetCurrentStepNumber() << std::endl;
59 std::cout << "********************************" << std::endl;*/
60
61 if (track->GetMomentum().mag() > recoilEnergyThreshold_) {
62 track->SetTrackStatus(fKillTrackAndSecondaries);
63 G4RunManager::GetRunManager()->AbortEvent();
64 return;
65 }
66
67 // Get the particles daughters.
68 const G4TrackVector* secondaries = step->GetSecondary();
69
70 // If the brem photon doesn't undergo any reaction in the target, stop
71 // processing the rest of the event.
72 if (secondaries->size() == 0) {
73 /*std::cout << "[ TargetENProcessFilter ]: "
74 << "Electron did not interact in the target. --> Postponing
75 tracks."
76 << std::endl;*/
77
78 track->SetTrackStatus(fKillTrackAndSecondaries);
79 G4RunManager::GetRunManager()->AbortEvent();
80 return;
81 } else {
82 G4String processName =
83 secondaries->at(0)->GetCreatorProcess()->GetProcessName();
84
85 /*std::cout << "[ TargetENProcessFilter ]: "
86 << "Electron produced " << secondaries->size()
87 << " particle via " << processName << " process."
88 << std::endl;*/
89
90 // Only record the process that is being biased
91 if (!processName.contains(process_)) {
92 /*std::cout << "[ TargetENProcessFilter ]: "
93 << "Process was not " << BiasingMessenger::getProcess() << "-->
94 Killing all tracks!"
95 << std::endl;*/
96
97 track->SetTrackStatus(fKillTrackAndSecondaries);
98 G4RunManager::GetRunManager()->AbortEvent();
99 return;
100 }
101
102 std::cout << "[ TargetENProcessFilter ]: "
103 << "Electronuclear reaction resulted in " << secondaries->size()
104 << " particles via " << processName << " process." << std::endl;
105 // BiasingMessenger::setEventWeight(track->GetWeight());
106 reactionOccurred_ = true;
107 }
108}
std::string process_
Process to filter on.

References process_, reactionOccurred_, and recoilEnergyThreshold_.

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().

◆ reactionOccurred_

bool biasing::TargetENProcessFilter::reactionOccurred_ {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().

◆ recoilEnergyThreshold_

double biasing::TargetENProcessFilter::recoilEnergyThreshold_ {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: