LDMX Software
biasing::EcalDarkBremFilter Class Reference

This class is meant to filter for events that produce a dark brem occuring within the ECal and producing an A' of a minimum energy threshold [MeV]. More...

#include <EcalDarkBremFilter.h>

Public Member Functions

 EcalDarkBremFilter (const std::string &name, framework::config::Parameters &parameters)
 Class constructor.
 
 ~EcalDarkBremFilter ()
 Class destructor.
 
std::vector< simcore::TYPEgetTypes () override
 Get the types of actions this class can do.
 
void BeginOfEventAction (const G4Event *event) override
 Reset flag on if A' has been found.
 
G4ClassificationOfNewTrack ClassifyNewTrack (const G4Track *aTrack, const G4ClassificationOfNewTrack &currentTrackClass) override
 We return the classification of the track done by the PartialEnergySorter, but we can check here if the A' has been created above the required energy.
 
void NewStage () override
 When using the PartialEnergySorter, the first time that a new stage begins is when all particles are now below the threshold.
 
void PostUserTrackingAction (const G4Track *track) override
 Make sure A' is 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 EndOfEventAction (const G4Event *)
 Method called at the end 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 stepping (const G4Step *)
 Method called after each simulation step.
 
virtual void PrepareNewEvent ()
 Method called at the beginning of a new event.
 

Private Member Functions

bool inDesiredVolume (const G4Track *) const
 Check if input volume is in the desired volume name.
 
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.
 
std::vector< G4LogicalVolume * > volumes_
 The volumes that the filter will be applied to.
 
bool found_ap_
 Have we found the A' yet?
 

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 occuring within the ECal and producing an A' of a minimum energy threshold [MeV].

Note
The threshold that the A' needs to have should be equal to or greater than the threshold of the PartialEnergySorter.
See also
PartialEnergySorter Here we assume that the partial energy sorter is being run in sequence with this filter. This filter makes sure that any events passing this filter have an A' of the required input energy and generated inside of the required input volume.

Definition at line 51 of file EcalDarkBremFilter.h.

Constructor & Destructor Documentation

◆ EcalDarkBremFilter()

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

Class constructor.

Retrieve the necessary configuration parameters

Definition at line 14 of file EcalDarkBremFilter.cxx.

16 : simcore::UserAction(name, parameters) {
17 threshold_ = parameters.get<double>("threshold");
18
19 /*
20 * We look for the logical volumes that match the following pattern:
21 * - 'volume' is in the name AND
22 * - 'Si' OR 'W' OR 'CFMix' OR 'PCB' are in the name
23 */
24 for (G4LogicalVolume* volume : *G4LogicalVolumeStore::GetInstance()) {
25 G4String volume_name = volume->GetName();
26 // looking for ecal volumes
27 if (volume_name.contains("volume") and
28 (volume_name.contains("Si") or volume_name.contains("W") or
29 volume_name.contains("CFMix") or volume_name.contains("PCB") or
30 volume_name.contains("Al"))) {
31 volumes_.push_back(volume);
32 }
33 }
34
35 ldmx_log(trace) << "Looking for A' in: ";
36 for (auto const& volume : volumes_) {
37 ldmx_log(trace) << "\t" << volume->GetName() << ", ";
38 }
39}
double threshold_
Minimum energy [MeV] that the A' should have to keep the event.
std::vector< G4LogicalVolume * > volumes_
The volumes that the filter will be applied to.
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(), threshold_, and volumes_.

◆ ~EcalDarkBremFilter()

biasing::EcalDarkBremFilter::~EcalDarkBremFilter ( )
inline

Class destructor.

Definition at line 64 of file EcalDarkBremFilter.h.

64{}

Member Function Documentation

◆ AbortEvent()

void biasing::EcalDarkBremFilter::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 111 of file EcalDarkBremFilter.cxx.

111 {
112 ldmx_log(trace)
113 << "("
114 << G4EventManager::GetEventManager()->GetConstCurrentEvent()->GetEventID()
115 << ") " << reason << " Aborting event.";
116
117 G4RunManager::GetRunManager()->AbortEvent();
118 return;
119}

Referenced by ClassifyNewTrack(), NewStage(), and PostUserTrackingAction().

◆ BeginOfEventAction()

void EcalDarkBremFilter::BeginOfEventAction ( const G4Event * event)
overridevirtual

Reset flag on if A' has been found.

Parameters
eventunused

Reimplemented from simcore::UserAction.

Definition at line 41 of file EcalDarkBremFilter.cxx.

41 {
42 found_ap_ = false;
43 return;
44}
bool found_ap_
Have we found the A' yet?

References found_ap_.

◆ ClassifyNewTrack()

G4ClassificationOfNewTrack EcalDarkBremFilter::ClassifyNewTrack ( const G4Track * aTrack,
const G4ClassificationOfNewTrack & currentTrackClass )
overridevirtual

We return the classification of the track done by the PartialEnergySorter, but we can check here if the A' has been created above the required energy.

Checks a new track for being an A' above threshold_ if it is an A', sets the found_ap_ member

See also
PartialEnergySort::ClassifyNewTrack
Parameters
aTrackThe Geant4 track.
currentTrackClassThe current track classification.
Returns
current track classification

Reimplemented from simcore::UserAction.

Definition at line 46 of file EcalDarkBremFilter.cxx.

47 {
48 if (aTrack->GetParticleDefinition() == G4APrime::APrime()) {
49 // there is an A'! Yay!
50 ldmx_log(trace) << "Found A', still need to check if it originated in "
51 "requested volume.";
52
53 if (not found_ap_ and aTrack->GetTotalEnergy() > threshold_) {
54 // The A' is the first one created in this event and is above the energy
55 // threshold
56 found_ap_ = true;
57 } else if (found_ap_) {
58 AbortEvent("Found more than one A' during filtering.");
59 } else {
60 AbortEvent("A' was not produced above the required threshold.");
61 }
62 }
63
64 return cl;
65}
void AbortEvent(const std::string &reason) const
Helper to abort an event with a message.

References AbortEvent(), found_ap_, and threshold_.

◆ getTypes()

std::vector< simcore::TYPE > biasing::EcalDarkBremFilter::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 71 of file EcalDarkBremFilter.h.

71 {
72 return {simcore::TYPE::STACKING, simcore::TYPE::EVENT,
73 simcore::TYPE::TRACKING};
74 }

◆ inDesiredVolume()

bool EcalDarkBremFilter::inDesiredVolume ( const G4Track * track) const
private

Check if input volume is in the desired volume name.

Parameters
pointerto track to check
Returns
true if originated in desired volume

Comparing the pointers to logical volumes isn't very robust. TODO find a better way to do this

Definition at line 97 of file EcalDarkBremFilter.cxx.

97 {
103 auto in_vol = track->GetLogicalVolumeAtVertex();
104 for (auto const& volume : volumes_) {
105 if (in_vol == volume) return true;
106 }
107
108 return false;
109}

References volumes_.

Referenced by PostUserTrackingAction().

◆ NewStage()

void EcalDarkBremFilter::NewStage ( )
overridevirtual

When using the PartialEnergySorter, the first time that a new stage begins is when all particles are now below the threshold.

We take this opportunity to make sure that the A' has been found.

See also
PartialEnergySort::NewStage

Reimplemented from simcore::UserAction.

Definition at line 67 of file EcalDarkBremFilter.cxx.

67 {
68 if (not found_ap_) AbortEvent("A' wasn't produced.");
69
70 return;
71}

References AbortEvent(), and found_ap_.

◆ PostUserTrackingAction()

void EcalDarkBremFilter::PostUserTrackingAction ( const G4Track * track)
overridevirtual

Make sure A' is saved.

If passed track is A', set save status to true Aborts event if A' does not originate in desired volume. This is the last check that the event needs to pass to be kept.

Parameters
trackG4Track to check if it is an A'

Reimplemented from simcore::UserAction.

Definition at line 73 of file EcalDarkBremFilter.cxx.

73 {
74 // Check that generational stacking is working
75 ldmx_log(trace) << track->GetTrackID() << " "
76 << track->GetParticleDefinition()->GetPDGEncoding();
77
78 const G4VProcess* creator = track->GetCreatorProcess();
79 if (creator and
80 creator->GetProcessName().contains(G4DarkBremsstrahlung::PROCESS_NAME)) {
81 // make sure all secondaries of dark brem process are saved
84 // make sure A' is persisted into output file
85 user_info->setSaveFlag(true);
86 if (track->GetParticleDefinition() == G4APrime::APrime()) {
87 // check if A' was made in the desired volume and has the minimum energy
88 if (not inDesiredVolume(track)) {
89 AbortEvent("A' wasn't produced inside of the requested volume.");
90 } // A' was made in desired volume and has the minimum energy
91 } // track was A'
92 } // track created by dark brem process
93
94 return;
95}
bool inDesiredVolume(const G4Track *) const
Check if input volume is in the desired volume name.
Provides user defined information to associate with a Geant4 track.
static UserTrackInformation * get(const G4Track *track)
get
void setSaveFlag(bool saveFlag)
Set the save flag so the associated track will be persisted as a Trajectory.

References AbortEvent(), simcore::UserTrackInformation::get(), inDesiredVolume(), and simcore::UserTrackInformation::setSaveFlag().

Member Data Documentation

◆ found_ap_

bool biasing::EcalDarkBremFilter::found_ap_
private

Have we found the A' yet?

Reset to false in BeginOfEventAction

Definition at line 164 of file EcalDarkBremFilter.h.

Referenced by BeginOfEventAction(), ClassifyNewTrack(), and NewStage().

◆ threshold_

double biasing::EcalDarkBremFilter::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 152 of file EcalDarkBremFilter.h.

Referenced by ClassifyNewTrack(), and EcalDarkBremFilter().

◆ volumes_

std::vector<G4LogicalVolume*> biasing::EcalDarkBremFilter::volumes_
private

The volumes that the filter will be applied to.

Definition at line 157 of file EcalDarkBremFilter.h.

Referenced by EcalDarkBremFilter(), and inDesiredVolume().


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