LDMX Software
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
 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.
 
mutable::framework::logging::logger theLog_
 the logging channel user actions can use ldmx_log with
 

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 12 of file MidShowerDiMuonBkgdFilter.cxx.

14 : simcore::UserAction(name, parameters) {
15 threshold_ = parameters.getParameter<double>("threshold");
16 /* debug printout
17 std::cout
18 << "[ MidShowerDiMuonBkgdFilter ]: "
19 << "created instance " << name
20 << "with threshold " << threshold_ << " MeV"
21 << std::endl;
22 */
23}
double threshold_
Minimum energy [MeV] that the process products need to have to keep the event.
Interface that defines a user action.
Definition UserAction.h:43

References 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 109 of file MidShowerDiMuonBkgdFilter.cxx.

109 {
110 if (G4RunManager::GetRunManager()->GetVerboseLevel() > 1) {
111 std::cout << "[ MidShowerDiMuonBkgdFilter ]: "
112 << "("
113 << G4EventManager::GetEventManager()
114 ->GetConstCurrentEvent()
115 ->GetEventID()
116 << ") " << reason << " Aborting event." << std::endl;
117 }
118 G4RunManager::GetRunManager()->AbortEvent();
119 return;
120}

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 25 of file MidShowerDiMuonBkgdFilter.cxx.

25 {
26 /* debug printout
27 std::cout
28 << "[ MidShowerDiMuonBkgdFilter ]: "
29 << "("
30 << G4EventManager::GetEventManager()->GetConstCurrentEvent()->GetEventID()
31 << ") "
32 << "starting new simulation event." << std::endl;
33 */
35}
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 88 of file MidShowerDiMuonBkgdFilter.cxx.

89 {
90 static auto calorimeter_region =
91 simcore::g4user::ptrretrieval::getRegion("CalorimeterRegion");
92 if (!calorimeter_region) {
93 ldmx_log(warn)
94 << "Region 'CalorimeterRegion' not found in Geant4 region store";
95 }
96 // the pointers in this chain are assumed to be always valid
97 auto phys_vol{step->GetTrack()->GetVolume()};
98 auto log_vol{phys_vol ? phys_vol->GetLogicalVolume() : nullptr};
99 auto reg{log_vol ? log_vol->GetRegion() : nullptr};
100 return (reg != calorimeter_region);
101}

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 75 of file MidShowerDiMuonBkgdFilter.cxx.

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

103 {
104 auto track_info{simcore::UserTrackInformation::get(track)};
105 track_info->setSaveFlag(true);
106 return;
107}
static UserTrackInformation * get(const G4Track *track)
get

References simcore::UserTrackInformation::get().

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 37 of file MidShowerDiMuonBkgdFilter.cxx.

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