LDMX Software
biasing::TargetDarkBremFilter Class Reference

This class is meant to filter for events that produce a dark brem matching originating in the target and matching the following parameters. More...

#include <TargetDarkBremFilter.h>

Public Member Functions

 TargetDarkBremFilter (const std::string &name, framework::config::Parameters &parameters)
 Class constructor.
 
 ~TargetDarkBremFilter ()=default
 Class destructor.
 
std::vector< simcore::TYPEgetTypes () override
 Get the types of actions this class can do.
 
void BeginOfEventAction (const G4Event *e) override
 Reset flag signaling finding of A' to false.
 
void stepping (const G4Step *step) override
 Looking for A' while primary is stepping.
 
void EndOfEventAction (const G4Event *event) override
 Check flag signaling finding of A', if false, abort the event so it isn't saved.
 
- 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 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 Member Functions

bool isOutsideTargetRegion (const G4VPhysicalVolume *vol) const
 Check if the volume is outside the target region.
 
bool isOutsideTargetRegion (const G4LogicalVolume *vol) const
 Check if the volume is outside the target region.
 
void AbortEvent (const std::string &reason) const
 Helper to abort an event with a message.
 

Private Attributes

double threshold_
 Minimum energy [MeV] that the A' should have to keep the event.
 
bool found_aprime_
 flag to signal that we saw an A'
 

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

This class is meant to filter for events that produce a dark brem matching originating in the target and matching the following parameters.

 threshold: minimum energy [MeV] A' needs to have
See also
TargetBremFilter This filter is designed similar to the target brem filter where we check the secondaries of the primary electron if it is stopping within the target or if it is leaving the target region.

Definition at line 53 of file TargetDarkBremFilter.h.

Constructor & Destructor Documentation

◆ TargetDarkBremFilter()

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

Class constructor.

Retrieve the necessary configuration parameters

Definition at line 14 of file TargetDarkBremFilter.cxx.

16 : simcore::UserAction(name, parameters) {
17 threshold_ = parameters.get<double>("threshold");
18}
double threshold_
Minimum energy [MeV] that the A' should have to keep the event.
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 threshold_.

Member Function Documentation

◆ AbortEvent()

void TargetDarkBremFilter::AbortEvent ( const std::string & reason) const
private

Helper to abort an event with a message.

Tells the RunManger to abort the current event after displaying the input message.

Parameters
[in]reasonreason for aborting the event

Definition at line 124 of file TargetDarkBremFilter.cxx.

124 {
125 if (G4RunManager::GetRunManager()->GetVerboseLevel() > 1) {
126 std::cout << "[ TargetDarkBremFilter ]: " << "("
127 << G4EventManager::GetEventManager()
128 ->GetConstCurrentEvent()
129 ->GetEventID()
130 << ") " << reason << " Aborting event." << std::endl;
131 }
132 G4RunManager::GetRunManager()->AbortEvent();
133 return;
134}

Referenced by EndOfEventAction(), and stepping().

◆ BeginOfEventAction()

void TargetDarkBremFilter::BeginOfEventAction ( const G4Event * e)
overridevirtual

Reset flag signaling finding of A' to false.

Parameters
[in]eevent being started, unused

Reimplemented from simcore::UserAction.

Definition at line 20 of file TargetDarkBremFilter.cxx.

20 {
21 found_aprime_ = false;
22}
bool found_aprime_
flag to signal that we saw an A'

References found_aprime_.

◆ EndOfEventAction()

void biasing::TargetDarkBremFilter::EndOfEventAction ( const G4Event * event)
overridevirtual

Check flag signaling finding of A', if false, abort the event so it isn't saved.

Parameters
[in]eventbeing ended, check if it is already aborted

Reimplemented from simcore::UserAction.

Definition at line 118 of file TargetDarkBremFilter.cxx.

118 {
119 if (not event->IsAborted() and not found_aprime_) {
120 AbortEvent("Did not find an A' after entire event was simulated.");
121 }
122}
void AbortEvent(const std::string &reason) const
Helper to abort an event with a message.

References AbortEvent(), and found_aprime_.

◆ getTypes()

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

Get the types of actions this class can do.

Returns
list of action types this class does

Implements simcore::UserAction.

Definition at line 73 of file TargetDarkBremFilter.h.

73 {
74 return {simcore::TYPE::STEPPING, simcore::TYPE::EVENT};
75 }

◆ isOutsideTargetRegion() [1/2]

bool biasing::TargetDarkBremFilter::isOutsideTargetRegion ( const G4LogicalVolume * vol) const
inlineprivate

Check if the volume is outside the target region.

Note
will return true if vol is nullptr.
Parameters
[in]volG4LogicalVolume to check region
Returns
true if vol is outside target region or nullptr or doesn't have a region

Definition at line 127 of file TargetDarkBremFilter.h.

127 {
128 if (!vol) return true;
129 auto target_region = simcore::g4user::ptrretrieval::getRegion("target");
130 if (!target_region) {
131 ldmx_log(warn) << "Region 'target' not found in Geant4 region store";
132 }
133 auto region = vol->GetRegion();
134 return region ? (region != target_region) : true;
135 }

◆ isOutsideTargetRegion() [2/2]

bool biasing::TargetDarkBremFilter::isOutsideTargetRegion ( const G4VPhysicalVolume * vol) const
inlineprivate

Check if the volume is outside the target region.

Note
will return true if vol is nullptr
Parameters
[in]volG4VPhysicalVolume to check region
Returns
true if vol is outside target region or nullptr

Definition at line 114 of file TargetDarkBremFilter.h.

114 {
115 return vol ? isOutsideTargetRegion(vol->GetLogicalVolume()) : true;
116 }
bool isOutsideTargetRegion(const G4VPhysicalVolume *vol) const
Check if the volume is outside the target region.

References isOutsideTargetRegion().

Referenced by isOutsideTargetRegion(), and stepping().

◆ stepping()

void TargetDarkBremFilter::stepping ( const G4Step * step)
overridevirtual

Looking for A' while primary is stepping.

We make sure that the current track is the primary electron that is within the target region. Then if the track is either stopped or leaving the target region, we look through its secondaries for a good A'.

Parameters
[in]stepcurrent G4Step

check on first step of A' to see if it originated in correct volume this needs to be here because sometimes the electron dark brems in the tagger and misses the target completely std::cout << "[ TargetDarkBremFilter ] : " << "(" << G4EventManager::GetEventManager() ->GetConstCurrentEvent() ->GetEventID() << ") " << "A' originated in " << track->GetLogicalVolumeAtVertex()->GetName() << std::endl;

Reimplemented from simcore::UserAction.

Definition at line 24 of file TargetDarkBremFilter.cxx.

24 {
25 // don't process if event is already aborted
26 if (G4EventManager::GetEventManager()->GetConstCurrentEvent()->IsAborted())
27 return;
28
29 // Get the track associated with this step.
30 auto track{step->GetTrack()};
31
32 // Leave if track is not an electron
33 auto particle_def{track->GetParticleDefinition()};
34 if (particle_def != G4Electron::Electron()) {
35 if (particle_def == G4APrime::APrime() and
36 track->GetCurrentStepNumber() == 1) {
49 if (isOutsideTargetRegion(track->GetLogicalVolumeAtVertex()))
50 AbortEvent("A' was not created within target.");
51 // A' was found and originated in correct region
52 found_aprime_ = true;
53 } // first step of A'
54 return;
55 }
56
57 // Leave if track is not primary
58 if (track->GetParentID() != 0) return;
59
60 // Leave if track is not in target region
61 if (isOutsideTargetRegion(track->GetVolume())) return;
62
63 if (isOutsideTargetRegion(track->GetNextVolume()) // leaving target region
64 or
65 track->GetTrackStatus() == fStopAndKill // stopping within target region
66 or track->GetKineticEnergy() == 0. // stopping within target region
67 ) {
68 // Get the electron secondries
69 const std::vector<G4Track*>* secondaries{step->GetSecondary()};
70 if (not secondaries or secondaries->size() == 0) {
71 AbortEvent("Primary electron did not create secondaries.");
72 return;
73 } else {
74 // check secondaries to see if we made a dark brem
75 for (auto& secondary_track : *secondaries) {
76 if (secondary_track->GetParticleDefinition() == G4APrime::APrime()) {
77 // we found an A', woo-hoo!
78
79 if (secondary_track->GetTotalEnergy() < threshold_) {
81 "A' was not created with total energy above input threshold.");
82 return;
83 }
84
85 if (isOutsideTargetRegion(secondary_track->GetVolume())) {
86 AbortEvent("A' was not created within target.");
87 return;
88 }
89
90 /* debug message
91 std::cout << "[ TargetDarkBremFilter ] : "
92 << "(" <<
93 G4EventManager::GetEventManager()->GetConstCurrentEvent()->GetEventID()
94 << ") "
95 << "Found an A' weighted " << secondary_track->GetWeight()
96 << " originating in " <<
97 secondary_track->GetVolume()->GetLogicalVolume()->GetName()
98 << " with energy " << secondary_track->GetTotalEnergy() << " MeV."
99 << std::endl;
100 */
101
102 // we found a good A', so we can leave
103 return;
104 } // this secondary is an A'
105 } // loop through secondaries
106 } // are there secondaries to loop through
107
108 // got here without finding A'
109 AbortEvent("Primary electron did not create A'.");
110 return;
111 } // should check secondaries of primary
112
113 // get here if we are the primary in the target region,
114 // but shouldn't check the secondaries yet
115 return;
116}

References AbortEvent(), found_aprime_, isOutsideTargetRegion(), and threshold_.

Member Data Documentation

◆ found_aprime_

bool biasing::TargetDarkBremFilter::found_aprime_
private

flag to signal that we saw an A'

Definition at line 161 of file TargetDarkBremFilter.h.

Referenced by BeginOfEventAction(), EndOfEventAction(), and stepping().

◆ threshold_

double biasing::TargetDarkBremFilter::threshold_
private

Minimum energy [MeV] that the A' should have to keep the event.

Also used by PartialEnergySorter to determine which tracks should be processed first.

Parameter Name: 'threshold'

Definition at line 156 of file TargetDarkBremFilter.h.

Referenced by stepping(), and TargetDarkBremFilter().


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