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

The basic premis of this filter is to add up all of the energy "lost" to muons created within the calorimeters. More...

#include <MidShowerDiMuonBkgdFilter.h>

Public Member Functions

 MidShowerDiMuonBkgdFilter (const std::string &name, framework::config::Parameters &parameters)
 Class constructor.
 
 ~MidShowerDiMuonBkgdFilter ()
 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 muons.
 
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.
 
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.
 
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 muons created within the calorimeters.

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 27 of file MidShowerDiMuonBkgdFilter.h.

Constructor & Destructor Documentation

◆ MidShowerDiMuonBkgdFilter()

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

Class constructor.

Retrieve the necessary configuration parameters

Definition at line 11 of file MidShowerDiMuonBkgdFilter.cxx.

13 : simcore::UserAction(name, parameters) {
14 threshold_ = parameters.getParameter<double>("threshold");
15 /* debug printout
16 std::cout
17 << "[ MidShowerDiMuonBkgdFilter ]: "
18 << "created instance " << name
19 << "with threshold " << threshold_ << " MeV"
20 << std::endl;
21 */
22}
double threshold_
Minimum energy [MeV] that the process products need to have to keep the event.
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 threshold_.

◆ ~MidShowerDiMuonBkgdFilter()

biasing::MidShowerDiMuonBkgdFilter::~MidShowerDiMuonBkgdFilter ( )
inline

Class destructor.

Definition at line 40 of file MidShowerDiMuonBkgdFilter.h.

40{}

Member Function Documentation

◆ AbortEvent()

void biasing::MidShowerDiMuonBkgdFilter::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 103 of file MidShowerDiMuonBkgdFilter.cxx.

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

Referenced by NewStage().

◆ BeginOfEventAction()

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

Reset the total energy going to the muons.

Parameters
[in]eventnot used

Reimplemented from simcore::UserAction.

Definition at line 24 of file MidShowerDiMuonBkgdFilter.cxx.

24 {
25 /* debug printout
26 std::cout
27 << "[ MidShowerDiMuonBkgdFilter ]: "
28 << "("
29 << G4EventManager::GetEventManager()->GetConstCurrentEvent()->GetEventID()
30 << ") "
31 << "starting new simulation event." << std::endl;
32 */
34}
double total_process_energy_
Total energy gone to the process in the current event.

References total_process_energy_.

◆ getTypes()

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

47 {
48 return {simcore::TYPE::STACKING, simcore::TYPE::STEPPING,
49 simcore::TYPE::EVENT};
50 }

◆ isOutsideCalorimeterRegion()

bool biasing::MidShowerDiMuonBkgdFilter::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 87 of file MidShowerDiMuonBkgdFilter.cxx.

88 {
89 // the pointers in this chain are assumed to be always valid
90 auto reg{step->GetTrack()->GetVolume()->GetLogicalVolume()->GetRegion()};
91 if (reg) return (reg->GetName() != "CalorimeterRegion");
92 // region is nullptr ==> no region defined for current volume
93 // ==> outside CalorimeterRegion
94 return true;
95}

Referenced by stepping().

◆ NewStage()

void biasing::MidShowerDiMuonBkgdFilter::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 74 of file MidShowerDiMuonBkgdFilter.cxx.

74 {
75 /* debug printout
76 std::cout
77 << "[ MidShowerDiMuonBkgdFilter ]: "
78 << "("
79 << G4EventManager::GetEventManager()->GetConstCurrentEvent()->GetEventID()
80 << ") " << total_process_energy_ << " MeV was muonic." << std::endl;
81 */
83 AbortEvent("Not enough energy went to the input process.");
84 return;
85}
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::MidShowerDiMuonBkgdFilter::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 97 of file MidShowerDiMuonBkgdFilter.cxx.

97 {
98 auto track_info{simcore::UserTrackInformation::get(track)};
99 track_info->setSaveFlag(true);
100 return;
101}
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::MidShowerDiMuonBkgdFilter::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 36 of file MidShowerDiMuonBkgdFilter.cxx.

36 {
37 // skips steps that aren't done by photons (required for mu conv)
38 if (step->GetTrack()->GetParticleDefinition() != G4Gamma::Gamma()) return;
39 // skip steps that are outside the calorimeter region
40 if (isOutsideCalorimeterRegion(step)) return;
41 // check photon secondaries for muons
42 const G4TrackVector* secondaries{step->GetSecondary()};
43 if (secondaries == nullptr or secondaries->size() == 0) return;
44 // have left if secondaries is empty
45 bool found_muon{false};
46 for (const G4Track* secondary : *secondaries) {
47 if (abs(secondary->GetParticleDefinition()->GetPDGEncoding()) == 13) {
48 found_muon = true;
49 save(secondary);
50 }
51 }
52 if (not found_muon) return;
53 // there are interesting secondaries in this step
54 double pre_energy = step->GetPreStepPoint()->GetTotalEnergy();
55 double post_energy = step->GetPostStepPoint()->GetTotalEnergy();
56 total_process_energy_ += pre_energy - post_energy;
57 const G4Track* track = step->GetTrack();
58 /* debug printout
59 std::cout << "[ MidShowerDiMuonBkgdFilter ]: "
60 << "("
61 << G4EventManager::GetEventManager()
62 ->GetConstCurrentEvent()
63 ->GetEventID()
64 << ") "
65 << "Track " << track->GetParentID() << " created "
66 << track->GetTrackID() << " which went from " << pre_energy
67 << " MeV to " << post_energy << " MeV generating muons."
68 << std::endl;
69 */
70 // make sure this track is saved
71 save(track);
72}
bool isOutsideCalorimeterRegion(const G4Step *step) const
Checks if the passed step is outside of the CalorimeterRegion.
void save(const G4Track *track) const
Helper to save the passed track.

References isOutsideCalorimeterRegion(), save(), and total_process_energy_.

Member Data Documentation

◆ threshold_

double biasing::MidShowerDiMuonBkgdFilter::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 130 of file MidShowerDiMuonBkgdFilter.h.

Referenced by MidShowerDiMuonBkgdFilter(), and NewStage().

◆ total_process_energy_

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

Total energy gone to the process in the current event.

Reset to 0. in BeginOfEventAction

Definition at line 137 of file MidShowerDiMuonBkgdFilter.h.

137{0.};

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


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