LDMX Software
Public Member Functions | Private Attributes | List of all members
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

std::string volumeName_ {"target_PV"}
 The volume name of the LDMX target.
 
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 = ::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

Definition at line 22 of file TargetENProcessFilter.h.

Constructor & Destructor Documentation

◆ TargetENProcessFilter()

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

Class constructor.

Definition at line 17 of file TargetENProcessFilter.cxx.

19 : simcore::UserAction(name, parameters) {
20 recoilEnergyThreshold_ = parameters.getParameter<double>("recoilThreshold");
21}
double recoilEnergyThreshold_
Energy that the recoil electron must not surpass.
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 framework::config::Parameters::getParameter(), and recoilEnergyThreshold_.

◆ ~TargetENProcessFilter()

biasing::TargetENProcessFilter::~TargetENProcessFilter ( )

Destructor.

Definition at line 23 of file TargetENProcessFilter.cxx.

23{}

Member Function Documentation

◆ EndOfEventAction()

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

End of event action.

Reimplemented from simcore::UserAction.

Definition at line 100 of file TargetENProcessFilter.cxx.

100 {
101 reactionOccurred_ = false;
102}
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 45 of file TargetENProcessFilter.h.

45 {
46 return {simcore::TYPE::EVENT, simcore::TYPE::STEPPING};
47 }

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

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

References process_, reactionOccurred_, recoilEnergyThreshold_, and volumeName_.

Member Data Documentation

◆ process_

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

Process to filter on.

Definition at line 68 of file TargetENProcessFilter.h.

68{"electronNuclear"};

Referenced by stepping().

◆ reactionOccurred_

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

Flag indicating if the reaction of intereset occurred.

Definition at line 62 of file TargetENProcessFilter.h.

62{false};

Referenced by EndOfEventAction(), and stepping().

◆ recoilEnergyThreshold_

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

Energy that the recoil electron must not surpass.

Definition at line 65 of file TargetENProcessFilter.h.

65{1500};

Referenced by stepping(), and TargetENProcessFilter().

◆ volumeName_

std::string biasing::TargetENProcessFilter::volumeName_ {"target_PV"}
private

The volume name of the LDMX target.

The 'target_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 target parent volume and so it will break if the target parent volume changes its name.

Definition at line 59 of file TargetENProcessFilter.h.

59{"target_PV"};

Referenced by stepping().


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