LDMX Software
Public Member Functions | Private Attributes | List of all members
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)
 
 ~EcalProcessFilter ()
 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 = ::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

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

21 : simcore::UserAction(name, parameters) {
22 process_ = parameters.getParameter<std::string>("process");
23}
std::string process_
Process to filter.
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

◆ ~EcalProcessFilter()

biasing::EcalProcessFilter::~EcalProcessFilter ( )

Destructor.

Definition at line 25 of file EcalProcessFilter.cxx.

25{}

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 27 of file EcalProcessFilter.cxx.

28 {
29 // Get the particle type.
30 G4String particleName = track->GetParticleDefinition()->GetParticleName();
31
32 if (track == currentTrack_) {
33 /*
34 std::cout << "[ EcalProcessFilter ]: "
35 << "Putting track " << track->GetTrackID()
36 << " onto waiting stack." << std::endl;
37 */
38 currentTrack_ = nullptr;
39 return fWaiting;
40 }
41
42 // Use current classification by default so values from other plugins are not
43 // overridden.
44 G4ClassificationOfNewTrack classification = currentTrackClass;
45
46 return classification;
47}
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 'hcal_PV' volume name is automatically constructed by Geant4's GDML parser and was found by inspecting the geometry using a visualization. This Physical Volume (PV) is associated with the hcal parent volume and so it will break if the hcal parent volume changes its name.

Reimplemented from simcore::UserAction.

Definition at line 49 of file EcalProcessFilter.cxx.

49 {
50 // Get the track associated with this step.
51 auto track{step->GetTrack()};
52
53 if (G4EventManager::GetEventManager()->GetConstCurrentEvent()->IsAborted())
54 return;
55
56 // Get the track info and check if this track is a brem candidate
57 auto trackInfo{simcore::UserTrackInformation::get(track)};
58 if ((trackInfo != nullptr) && !trackInfo->isBremCandidate()) return;
59
60 // Get the particles daughters.
61 auto secondaries{step->GetSecondary()};
62
63 // Get the region the particle is currently in. Continue processing
64 // the particle only if it's in the calorimeter region.
65 if (auto region{
66 track->GetVolume()->GetLogicalVolume()->GetRegion()->GetName()};
67 region.compareTo("CalorimeterRegion") != 0) {
68 // If secondaries were produced outside of the volume of interest,
69 // and there aren't additional brems to process, abort the
70 // event. Otherwise, suspend the track and move on to the next
71 // brem.
72 if (secondaries->size() != 0) {
73 /*
74 std::cout << "[ EcalProcessFilter ]: "
75 <<
76 G4EventManager::GetEventManager()->GetConstCurrentEvent()->GetEventID()
77 << " secondaries outside ecal...";
78 */
79 if (getEventInfo()->bremCandidateCount() == 1) {
80 // std::cout << "aborting the event." << std::endl;
81 track->SetTrackStatus(fKillTrackAndSecondaries);
82 G4RunManager::GetRunManager()->AbortEvent();
83 currentTrack_ = nullptr;
84 } else {
85 /*
86 std::cout << "suspending the track " << track->GetTrackID()
87 << " , " << getEventInfo()->bremCandidateCount() << " brems left."
88 << std::endl;
89 */
90 currentTrack_ = track;
91 track->SetTrackStatus(fSuspend);
93 trackInfo->tagBremCandidate(false);
94 }
95 }
96 return;
97 }
98
99 // If the particle doesn't interact, then move on to the next step.
100 if (secondaries->size() == 0) {
110 if (auto volume{track->GetNextVolume()->GetName()};
111 volume.compareTo("hcal_PV") == 0) {
112 /*
113 std::cout << "[ EcalProcessFilter ]: "
114 <<
115 G4EventManager::GetEventManager()->GetConstCurrentEvent()->GetEventID()
116 << " no secondaries when leaving ecal...";
117 */
118 if (getEventInfo()->bremCandidateCount() == 1) {
119 // std::cout << "aborting the event." << std::endl;
120 track->SetTrackStatus(fKillTrackAndSecondaries);
121 G4RunManager::GetRunManager()->AbortEvent();
122 currentTrack_ = nullptr;
123 } else {
124 /*
125 std::cout << "suspending the track " << track->GetTrackID()
126 << " , " << getEventInfo()->bremCandidateCount() << " brems left."
127 << std::endl;
128 */
129 currentTrack_ = track;
130 track->SetTrackStatus(fSuspend);
132 trackInfo->tagBremCandidate(false);
133 }
134 }
135
136 return;
137 } else {
138 // If the brem gamma interacts and produces secondaries, get the
139 // process used to create them.
140 auto processName{secondaries->at(0)->GetCreatorProcess()->GetProcessName()};
141
142 // Only record the process that is being biased
143 if (!processName.contains(process_)) {
144 /*
145 std::cout << "[ EcalProcessFilter ]: "
146 <<
147 G4EventManager::GetEventManager()->GetConstCurrentEvent()->GetEventID()
148 << " not PN products...";
149 */
150 if (getEventInfo()->bremCandidateCount() == 1) {
151 // std::cout << "aborting the event." << std::endl;
152 track->SetTrackStatus(fKillTrackAndSecondaries);
153 G4RunManager::GetRunManager()->AbortEvent();
154 currentTrack_ = nullptr;
155 } else {
156 /*
157 std::cout << "suspending the track " << track->GetTrackID()
158 << " , " << getEventInfo()->bremCandidateCount() << " brems left."
159 << std::endl;
160 */
161 currentTrack_ = track;
162 track->SetTrackStatus(fSuspend);
164 trackInfo->tagBremCandidate(false);
165 }
166 return;
167 }
168
169 ldmx_log(debug) << "[ EcalProcessFilter ]: "
170 << G4EventManager::GetEventManager()
171 ->GetConstCurrentEvent()
172 ->GetEventID()
173 << " Brem photon produced " << secondaries->size()
174 << " particle via " << processName << " process.";
175 trackInfo->tagBremCandidate(false);
176 trackInfo->setSaveFlag(true);
177 trackInfo->tagPNGamma();
179 }
180}
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(), and simcore::UserTrackInformation::tagBremCandidate().

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: