LDMX Software
Public Member Functions | Private Member Functions | Private Attributes | List of all members
biasing::MidShowerNuclearBkgdFilter Class Reference

The basic premis of this filter is to add up all of the energy "lost" to the configured process. More...

#include <MidShowerNuclearBkgdFilter.h>

Public Member Functions

 MidShowerNuclearBkgdFilter (const std::string &name, framework::config::Parameters &parameters)
 Class constructor.
 
 ~MidShowerNuclearBkgdFilter ()
 Class destructor.
 
std::vector< simcore::TYPE > getTypes () override
 Get the types of actions this class can do.
 
void BeginOfEventAction (const G4Event *event) override
 Reset the total energy going to the configured process.
 
void stepping (const G4Step *step) override
 We follow the simulation along each step and check if any secondaries of the input process were created.
 
void NewStage () override
 When using the PartialEnergySorter, the first time that a new stage begins is when all particles are now below the threshold.
 
- 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 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 PrepareNewEvent ()
 Method called at the beginning of a new event.
 

Private Member Functions

bool isOutsideCalorimeterRegion (const G4Step *step) const
 Checks if the passed step is outside of the CalorimeterRegion.
 
bool isNuclearProcess (const G4VProcess *proc) const
 Checks if the passed process is any of the nuclear interactions.
 
void save (const G4Track *track) const
 Helper to save the passed track.
 
void AbortEvent (const std::string &reason) const
 Helper to abort an event with a message.
 

Private Attributes

double threshold_
 Minimum energy [MeV] that the process products need to have to keep the event.
 
std::vector< std::string > nuclear_processes_
 Processes to look for.
 
double total_process_energy_ {0.}
 Total energy gone to the process in the current event.
 

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

The basic premis of this filter is to add up all of the energy "lost" to the configured process.

Whenever a particle makes a step and has secondaries within that step going to the input process, we add its change in energy to the running total for the event. When the PartialEnergySorter has run out of "high" energy particles to process (when NewStage is called) we check if the running total is high enough to keep the event.

See also
PartialEnergySorter Here we assume that the partial energy sorter is being run in sequence with this filter.

Definition at line 29 of file MidShowerNuclearBkgdFilter.h.

Constructor & Destructor Documentation

◆ MidShowerNuclearBkgdFilter()

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

Class constructor.

Retrieve the necessary configuration parameters

Definition at line 10 of file MidShowerNuclearBkgdFilter.cxx.

12 : simcore::UserAction(name, parameters) {
13 threshold_ = parameters.getParameter<double>("threshold");
14 nuclear_processes_ = {"photonNuclear", "electronNuclear"};
15}
double threshold_
Minimum energy [MeV] that the process products need to have to keep the event.
std::vector< std::string > nuclear_processes_
Processes to look for.
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(), nuclear_processes_, and threshold_.

◆ ~MidShowerNuclearBkgdFilter()

biasing::MidShowerNuclearBkgdFilter::~MidShowerNuclearBkgdFilter ( )
inline

Class destructor.

Definition at line 42 of file MidShowerNuclearBkgdFilter.h.

42{}

Member Function Documentation

◆ AbortEvent()

void biasing::MidShowerNuclearBkgdFilter::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 101 of file MidShowerNuclearBkgdFilter.cxx.

101 {
102 if (G4RunManager::GetRunManager()->GetVerboseLevel() > 1) {
103 std::cout << "[ MidShowerNuclearBkgdFilter ]: "
104 << "("
105 << G4EventManager::GetEventManager()
106 ->GetConstCurrentEvent()
107 ->GetEventID()
108 << ") " << reason << " Aborting event." << std::endl;
109 }
110 G4RunManager::GetRunManager()->AbortEvent();
111 return;
112}

Referenced by NewStage().

◆ BeginOfEventAction()

void biasing::MidShowerNuclearBkgdFilter::BeginOfEventAction ( const G4Event *  event)
overridevirtual

Reset the total energy going to the configured process.

Parameters
[in]eventnot used

Reimplemented from simcore::UserAction.

Definition at line 17 of file MidShowerNuclearBkgdFilter.cxx.

17 {
18 /* debug printout
19 std::cout
20 << "[ MidShowerNuclearBkgdFilter ]: "
21 << "("
22 << G4EventManager::GetEventManager()->GetConstCurrentEvent()->GetEventID()
23 << ") "
24 << "starting new simulation event." << std::endl;
25 */
27}
double total_process_energy_
Total energy gone to the process in the current event.

References total_process_energy_.

◆ getTypes()

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

49 {
50 return {simcore::TYPE::STACKING, simcore::TYPE::STEPPING,
51 simcore::TYPE::EVENT};
52 }

◆ isNuclearProcess()

bool biasing::MidShowerNuclearBkgdFilter::isNuclearProcess ( const G4VProcess *  proc) const
private

Checks if the passed process is any of the nuclear interactions.

Note
A 'nullptr' process is not a nuclear process.
Parameters
[in]procG4VProcess* to check
Returns
true if process is one of the nuclear interactions

Definition at line 84 of file MidShowerNuclearBkgdFilter.cxx.

85 {
86 if (proc) {
87 const G4String& proc_name{proc->GetProcessName()};
88 for (auto const& option : nuclear_processes_) {
89 if (proc_name.contains(option)) return true;
90 } // loop over nuclear processes
91 } // pointer exists
92 return false;
93}

References nuclear_processes_.

Referenced by stepping().

◆ isOutsideCalorimeterRegion()

bool biasing::MidShowerNuclearBkgdFilter::isOutsideCalorimeterRegion ( const G4Step *  step) const
private

Checks if the passed step is outside of the CalorimeterRegion.

Parameters
[in]stepconst G4Step to check
Returns
true if passed step is outside of the CalorimeterRegion.

Definition at line 74 of file MidShowerNuclearBkgdFilter.cxx.

75 {
76 // the pointers in this chain are assumed to be always valid
77 auto reg{step->GetTrack()->GetVolume()->GetLogicalVolume()->GetRegion()};
78 if (reg) return (reg->GetName() != "CalorimeterRegion");
79 // region is nullptr ==> no region defined for current volume
80 // ==> outside CalorimeterRegion
81 return true;
82}

Referenced by stepping().

◆ NewStage()

void biasing::MidShowerNuclearBkgdFilter::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 enough energy has gone to the products of the input process.

See also
PartialEnergySort::NewStage
AbortEvent

Reimplemented from simcore::UserAction.

Definition at line 61 of file MidShowerNuclearBkgdFilter.cxx.

61 {
62 /* debug printout
63 std::cout
64 << "[ MidShowerNuclearBkgdFilter ]: "
65 << "("
66 << G4EventManager::GetEventManager()->GetConstCurrentEvent()->GetEventID()
67 << ") " << total_process_energy_ << " MeV went nuclear." << std::endl;
68 */
70 AbortEvent("Not enough energy went to the input process.");
71 return;
72}
void AbortEvent(const std::string &reason) const
Helper to abort an event with a message.

References AbortEvent(), threshold_, and total_process_energy_.

◆ save()

void biasing::MidShowerNuclearBkgdFilter::save ( const G4Track *  track) const
private

Helper to save the passed track.

Note
Assumes user track information has already been created for the input track.
Parameters
[in]trackG4Track to persist into output

Definition at line 95 of file MidShowerNuclearBkgdFilter.cxx.

95 {
96 auto track_info{simcore::UserTrackInformation::get(track)};
97 track_info->setSaveFlag(true);
98 return;
99}
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 simcore::UserTrackInformation::get(), and simcore::UserTrackInformation::setSaveFlag().

Referenced by stepping().

◆ stepping()

void biasing::MidShowerNuclearBkgdFilter::stepping ( const G4Step *  step)
overridevirtual

We follow the simulation along each step and check if any secondaries of the input process were created.

If they were created, we add the change in energy to the total energy "lost" to the input process.

Note
Only includes the steps that are within the 'CalorimeterRegion' in the search for interesting products.
See also
isOutsideCalorimeterRegion
anyCreatedViaProcess
Parameters
[in]stepcurrent G4Step

Reimplemented from simcore::UserAction.

Definition at line 29 of file MidShowerNuclearBkgdFilter.cxx.

29 {
30 // skip steps that are outside the calorimeter region
31 if (isOutsideCalorimeterRegion(step)) return;
32
33 if (getEventInfo()->wasLastStepPN() or getEventInfo()->wasLastStepEN()) {
34 // there are interesting secondaries in this step
35 double pre_energy = step->GetPreStepPoint()->GetTotalEnergy();
36 double post_energy = step->GetPostStepPoint()->GetTotalEnergy();
37 total_process_energy_ += pre_energy - post_energy;
38
39 const G4Track* track = step->GetTrack();
40 /* debug printout
41 std::cout << "[ MidShowerNuclearBkgdFilter ]: "
42 << "("
43 << G4EventManager::GetEventManager()
44 ->GetConstCurrentEvent()
45 ->GetEventID()
46 << ") "
47 << "Track " << track->GetParentID() << " created "
48 << track->GetTrackID() << " which went from " << pre_energy
49 << " MeV to " << post_energy << " via a nuclear process." <<
50 std::endl;
51 */
52 // make sure this track is saved
53 save(track);
54 } else if (const G4Track * track{step->GetTrack()};
55 track->GetCurrentStepNumber() == 1 and
56 isNuclearProcess(track->GetCreatorProcess())) {
57 save(track);
58 }
59}
void save(const G4Track *track) const
Helper to save the passed track.
bool isOutsideCalorimeterRegion(const G4Step *step) const
Checks if the passed step is outside of the CalorimeterRegion.
bool isNuclearProcess(const G4VProcess *proc) const
Checks if the passed process is any of the nuclear interactions.
UserEventInformation * getEventInfo() const
Get a handle to the event information.

References simcore::UserAction::getEventInfo(), isNuclearProcess(), isOutsideCalorimeterRegion(), save(), and total_process_energy_.

Member Data Documentation

◆ nuclear_processes_

std::vector<std::string> biasing::MidShowerNuclearBkgdFilter::nuclear_processes_
private

Processes to look for.

Definition at line 147 of file MidShowerNuclearBkgdFilter.h.

Referenced by isNuclearProcess(), and MidShowerNuclearBkgdFilter().

◆ threshold_

double biasing::MidShowerNuclearBkgdFilter::threshold_
private

Minimum energy [MeV] that the process products need to have to keep the event.

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

Parameter Name: 'threshold'

Definition at line 142 of file MidShowerNuclearBkgdFilter.h.

Referenced by MidShowerNuclearBkgdFilter(), and NewStage().

◆ total_process_energy_

double biasing::MidShowerNuclearBkgdFilter::total_process_energy_ {0.}
private

Total energy gone to the process in the current event.

Reset to 0. in BeginOfEventAction

Definition at line 154 of file MidShowerNuclearBkgdFilter.h.

154{0.};

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


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