LDMX Software
Public Member Functions | Private Member Functions | Private Attributes | List of all members
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::TYPE > getTypes () 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.
 
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 foundAp_
 Have we found the A' yet?
 

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

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 46 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 19 of file EcalDarkBremFilter.cxx.

21 : simcore::UserAction(name, parameters) {
22 threshold_ = parameters.getParameter<double>("threshold");
23
24 /*
25 * We look for the logical volumes that match the following pattern:
26 * - 'volume' is in the name AND
27 * - 'Si' OR 'W' OR 'CFMix' OR 'PCB' are in the name
28 */
29 for (G4LogicalVolume* volume : *G4LogicalVolumeStore::GetInstance()) {
30 G4String volumeName = volume->GetName();
31 // looking for ecal volumes
32 if (volumeName.contains("volume") and
33 (volumeName.contains("Si") or volumeName.contains("W") or
34 volumeName.contains("CFMix") or volumeName.contains("PCB") or
35 volumeName.contains("Al"))) {
36 volumes_.push_back(volume);
37 }
38 }
39
40 if (G4RunManager::GetRunManager()->GetVerboseLevel() > 0) {
41 std::cout << "[ EcalDarkBremFilter ]: "
42 << "Looking for A' in: ";
43 for (auto const& volume : volumes_) std::cout << volume->GetName() << ", ";
44 std::cout << std::endl;
45 }
46}
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.
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(), threshold_, and volumes_.

◆ ~EcalDarkBremFilter()

biasing::EcalDarkBremFilter::~EcalDarkBremFilter ( )
inline

Class destructor.

Definition at line 59 of file EcalDarkBremFilter.h.

59{}

Member Function Documentation

◆ AbortEvent()

void 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 132 of file EcalDarkBremFilter.cxx.

132 {
133 if (G4RunManager::GetRunManager()->GetVerboseLevel() > 1) {
134 std::cout << "[ EcalDarkBremFilter ]: "
135 << "("
136 << G4EventManager::GetEventManager()
137 ->GetConstCurrentEvent()
138 ->GetEventID()
139 << ") " << reason << " Aborting event." << std::endl;
140 }
141 G4RunManager::GetRunManager()->AbortEvent();
142 return;
143}

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 48 of file EcalDarkBremFilter.cxx.

48 {
49 /* Debug message
50 std::cout << "[ EcalDarkBremFilter ]: "
51 << "(" <<
52 G4EventManager::GetEventManager()->GetConstCurrentEvent()->GetEventID() << ")
53 "
54 << "Beginning event."
55 << std::endl;
56 */
57 foundAp_ = false;
58 return;
59}
bool foundAp_
Have we found the A' yet?

References foundAp_.

◆ 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 foundAp_ member

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

Reimplemented from simcore::UserAction.

Definition at line 61 of file EcalDarkBremFilter.cxx.

62 {
63 if (aTrack->GetParticleDefinition() == G4APrime::APrime()) {
64 // there is an A'! Yay!
65 /* Debug message
66 std::cout << "[ EcalDarkBremFilter ]: "
67 << "Found A', still need to check if it originated in requested
68 volume."
69 << std::endl;
70 */
71 if (not foundAp_ and aTrack->GetTotalEnergy() > threshold_) {
72 // The A' is the first one created in this event and is above the energy
73 // threshold
74 foundAp_ = true;
75 } else if (foundAp_) {
76 AbortEvent("Found more than one A' during filtering.");
77 } else {
78 AbortEvent("A' was not produced above the required threshold.");
79 }
80 }
81
82 return cl;
83}
void AbortEvent(const std::string &reason) const
Helper to abort an event with a message.

References AbortEvent(), foundAp_, 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 66 of file EcalDarkBremFilter.h.

66 {
67 return {simcore::TYPE::STACKING, simcore::TYPE::EVENT,
68 simcore::TYPE::TRACKING};
69 }

◆ 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 118 of file EcalDarkBremFilter.cxx.

118 {
124 auto inVol = track->GetLogicalVolumeAtVertex();
125 for (auto const& volume : volumes_) {
126 if (inVol == volume) return true;
127 }
128
129 return false;
130}

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 85 of file EcalDarkBremFilter.cxx.

85 {
86 if (not foundAp_) AbortEvent("A' wasn't produced.");
87
88 return;
89}

References AbortEvent(), and foundAp_.

◆ 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 91 of file EcalDarkBremFilter.cxx.

91 {
92 /* Check that generational stacking is working
93 std::cout << "[ EcalDarkBremFilter ]:"
94 << track->GetTrackID() << " " <<
95 track->GetParticleDefinition()->GetPDGEncoding()
96 << std::endl;
97 */
98
99 const G4VProcess* creator = track->GetCreatorProcess();
100 if (creator and
101 creator->GetProcessName().contains(G4DarkBremsstrahlung::PROCESS_NAME)) {
102 // make sure all secondaries of dark brem process are saved
105 // make sure A' is persisted into output file
106 userInfo->setSaveFlag(true);
107 if (track->GetParticleDefinition() == G4APrime::APrime()) {
108 // check if A' was made in the desired volume and has the minimum energy
109 if (not inDesiredVolume(track)) {
110 AbortEvent("A' wasn't produced inside of the requested volume.");
111 } // A' was made in desired volume and has the minimum energy
112 } // track was A'
113 } // track created by dark brem process
114
115 return;
116}
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

◆ foundAp_

bool biasing::EcalDarkBremFilter::foundAp_
private

Have we found the A' yet?

Reset to false in BeginOfEventAction

Definition at line 159 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 147 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 152 of file EcalDarkBremFilter.h.

Referenced by EcalDarkBremFilter(), and inDesiredVolume().


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