LDMX Software
biasing::EcalProcessFilter Class Reference

User action plugin that filters events that don't see a hard brem from the target undergo a photo-nuclear reaction in the ECal. More...

#include <EcalProcessFilter.h>

Public Member Functions

 EcalProcessFilter (const std::string &name, framework::config::Parameters &parameters)
 
virtual ~EcalProcessFilter ()=default
 Destructor.
 
void stepping (const G4Step *step) override
 Method called after each simulation step.
 
G4ClassificationOfNewTrack ClassifyNewTrack (const G4Track *aTrack, const G4ClassificationOfNewTrack &currentTrackClass) override
 Classify a new track which postpones track processing.
 
std::vector< simcore::TYPE > getTypes () override
 Retrieve the type of actions this class defines.
 
- Public Member Functions inherited from simcore::UserAction
 UserAction (const std::string &name, framework::config::Parameters &parameters)
 Constructor.
 
virtual ~UserAction ()=default
 Destructor.
 
virtual void BeginOfEventAction (const G4Event *)
 Method called at the beginning of every event.
 
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 void NewStage ()
 Method called at the beginning of a new stage.
 
virtual void PrepareNewEvent ()
 Method called at the beginning of a new event.
 

Private Attributes

G4Track * currentTrack_ {nullptr}
 Pointer to the current track being processed.
 
std::string process_ {""}
 Process to filter.
 

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

User action plugin that filters events that don't see a hard brem from the target undergo a photo-nuclear reaction in the ECal.

Definition at line 30 of file EcalProcessFilter.h.

Constructor & Destructor Documentation

◆ EcalProcessFilter()

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

Definition at line 22 of file EcalProcessFilter.cxx.

24 : simcore::UserAction(name, parameters) {
25 process_ = parameters.getParameter<std::string>("process");
26}
std::string process_
Process to filter.
Interface that defines a user action.
Definition UserAction.h:43

Member Function Documentation

◆ ClassifyNewTrack()

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

Classify a new track which postpones track processing.

Track processing resumes normally if a target PN interaction occurred.

Parameters
aTrackThe Geant4 track.
currentTrackClassThe current track classification.

Reimplemented from simcore::UserAction.

Definition at line 28 of file EcalProcessFilter.cxx.

29 {
30 // Get the particle type.
31 G4String particleName = track->GetParticleDefinition()->GetParticleName();
32
33 if (track == currentTrack_) {
34 /*
35 std::cout << "[ EcalProcessFilter ]: "
36 << "Putting track " << track->GetTrackID()
37 << " onto waiting stack." << std::endl;
38 */
39 currentTrack_ = nullptr;
40 return fWaiting;
41 }
42
43 // Use current classification by default so values from other plugins are not
44 // overridden.
45 G4ClassificationOfNewTrack classification = currentTrackClass;
46
47 return classification;
48}
G4Track * currentTrack_
Pointer to the current track being processed.

◆ getTypes()

std::vector< simcore::TYPE > biasing::EcalProcessFilter::getTypes ( )
inlineoverridevirtual

Retrieve the type of actions this class defines.

Implements simcore::UserAction.

Definition at line 56 of file EcalProcessFilter.h.

56 {
57 return {simcore::TYPE::STACKING, simcore::TYPE::STEPPING};
58 }

◆ stepping()

void biasing::EcalProcessFilter::stepping ( const G4Step * )
overridevirtual

Method called after each simulation step.

TYPE::STEPPING

Parameters
currentGeant4 step

Check if the photon will be exiting the ecal

The 'hadronic_calorimeter' logical volume name is the parent volume to all of the HCal components.

Reimplemented from simcore::UserAction.

Definition at line 50 of file EcalProcessFilter.cxx.

50 {
51 static auto calorimeter_region =
52 simcore::g4user::ptrretrieval::getRegion("CalorimeterRegion");
53 if (!calorimeter_region) {
54 ldmx_log(warn)
55 << "Region 'CalorimeterRegion' not found in Geant4 region store";
56 }
57 // Get the track associated with this step.
58 auto track{step->GetTrack()};
59
60 if (G4EventManager::GetEventManager()->GetConstCurrentEvent()->IsAborted())
61 return;
62
63 // Get the track info and check if this track is a brem candidate
64 auto trackInfo{simcore::UserTrackInformation::get(track)};
65 if ((trackInfo != nullptr) && !trackInfo->isBremCandidate()) return;
66
67 // Get the particles daughters.
68 auto secondaries{step->GetSecondary()};
69
70 // Get the region the particle is currently in. Continue processing
71 // the particle only if it's in the calorimeter region.
72 auto phys_vol{track->GetVolume()};
73 auto lv{phys_vol ? phys_vol->GetLogicalVolume() : nullptr};
74 auto region{lv ? lv->GetRegion() : nullptr};
75 if (region != calorimeter_region) {
76 // If secondaries were produced outside of the volume of interest,
77 // and there aren't additional brems to process, abort the
78 // event. Otherwise, suspend the track and move on to the next
79 // brem.
80 if (secondaries->size() != 0) {
81 /*
82 std::cout << "[ EcalProcessFilter ]: "
83 <<
84 G4EventManager::GetEventManager()->GetConstCurrentEvent()->GetEventID()
85 << " secondaries outside ecal...";
86 */
87 if (getEventInfo()->bremCandidateCount() == 1) {
88 // std::cout << "aborting the event." << std::endl;
89 track->SetTrackStatus(fKillTrackAndSecondaries);
90 G4RunManager::GetRunManager()->AbortEvent();
91 currentTrack_ = nullptr;
92 } else {
93 /*
94 std::cout << "suspending the track " << track->GetTrackID()
95 << " , " << getEventInfo()->bremCandidateCount() << " brems left."
96 << std::endl;
97 */
98 currentTrack_ = track;
99 track->SetTrackStatus(fSuspend);
101 trackInfo->tagBremCandidate(false);
102 }
103 }
104 return;
105 }
106
107 // If the particle doesn't interact, then move on to the next step.
108 if (secondaries->size() == 0) {
115 static auto volume_after_exiting_ecal =
116 simcore::g4user::ptrretrieval::getLogicalVolume("hadronic_calorimeter");
117 if (!volume_after_exiting_ecal) {
118 ldmx_log(warn) << "Unable to find 'hadronic_calorimeter' logical volume.";
119 }
120 auto next_phys_vol = track->GetNextVolume();
121 auto next_log_vol{next_phys_vol ? next_phys_vol->GetLogicalVolume()
122 : nullptr};
123 if (next_log_vol == volume_after_exiting_ecal) {
124 /*
125 std::cout << "[ EcalProcessFilter ]: "
126 <<
127 G4EventManager::GetEventManager()->GetConstCurrentEvent()->GetEventID()
128 << " no secondaries when leaving ecal...";
129 */
130 if (getEventInfo()->bremCandidateCount() == 1) {
131 // std::cout << "aborting the event." << std::endl;
132 track->SetTrackStatus(fKillTrackAndSecondaries);
133 G4RunManager::GetRunManager()->AbortEvent();
134 currentTrack_ = nullptr;
135 } else {
136 /*
137 std::cout << "suspending the track " << track->GetTrackID()
138 << " , " << getEventInfo()->bremCandidateCount() << " brems left."
139 << std::endl;
140 */
141 currentTrack_ = track;
142 track->SetTrackStatus(fSuspend);
144 trackInfo->tagBremCandidate(false);
145 }
146 }
147
148 return;
149 } else {
150 // If the brem gamma interacts and produces secondaries, get the
151 // process used to create them.
152 auto processName{secondaries->at(0)->GetCreatorProcess()->GetProcessName()};
153
154 // Only record the process that is being biased
155 if (!processName.contains(process_)) {
156 /*
157 std::cout << "[ EcalProcessFilter ]: "
158 <<
159 G4EventManager::GetEventManager()->GetConstCurrentEvent()->GetEventID()
160 << " not PN products...";
161 */
162 if (getEventInfo()->bremCandidateCount() == 1) {
163 // std::cout << "aborting the event." << std::endl;
164 track->SetTrackStatus(fKillTrackAndSecondaries);
165 G4RunManager::GetRunManager()->AbortEvent();
166 currentTrack_ = nullptr;
167 } else {
168 /*
169 std::cout << "suspending the track " << track->GetTrackID()
170 << " , " << getEventInfo()->bremCandidateCount() << " brems left."
171 << std::endl;
172 */
173 currentTrack_ = track;
174 track->SetTrackStatus(fSuspend);
176 trackInfo->tagBremCandidate(false);
177 }
178 return;
179 }
180
181 ldmx_log(info) << " Brem photon produced " << secondaries->size()
182 << " particles via " << processName << " process.";
183 trackInfo->tagBremCandidate(false);
184 trackInfo->setSaveFlag(true);
185 trackInfo->tagPNGamma();
187 }
188}
UserEventInformation * getEventInfo() const
Get a handle to the event information.
void decBremCandidateCount()
Decrease the number of brem candidates in an event.
static UserTrackInformation * get(const G4Track *track)
get

References simcore::UserTrackInformation::get().

Member Data Documentation

◆ currentTrack_

G4Track* biasing::EcalProcessFilter::currentTrack_ {nullptr}
private

Pointer to the current track being processed.

Definition at line 62 of file EcalProcessFilter.h.

62{nullptr};

◆ process_

std::string biasing::EcalProcessFilter::process_ {""}
private

Process to filter.

Definition at line 65 of file EcalProcessFilter.h.

65{""};

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