27G4ClassificationOfNewTrack EcalProcessFilter::ClassifyNewTrack(
28 const G4Track* track,
const G4ClassificationOfNewTrack& currentTrackClass) {
30 G4String particleName = track->GetParticleDefinition()->GetParticleName();
32 if (track == currentTrack_) {
38 currentTrack_ =
nullptr;
44 G4ClassificationOfNewTrack classification = currentTrackClass;
46 return classification;
49void EcalProcessFilter::stepping(
const G4Step* step) {
51 auto track{step->GetTrack()};
53 if (G4EventManager::GetEventManager()->GetConstCurrentEvent()->IsAborted())
58 if ((trackInfo !=
nullptr) && !trackInfo->isBremCandidate())
return;
61 auto secondaries{step->GetSecondary()};
66 track->GetVolume()->GetLogicalVolume()->GetRegion()->GetName()};
67 region.compareTo(
"CalorimeterRegion") != 0) {
72 if (secondaries->size() != 0) {
79 if (getEventInfo()->bremCandidateCount() == 1) {
81 track->SetTrackStatus(fKillTrackAndSecondaries);
82 G4RunManager::GetRunManager()->AbortEvent();
83 currentTrack_ =
nullptr;
90 currentTrack_ = track;
91 track->SetTrackStatus(fSuspend);
92 getEventInfo()->decBremCandidateCount();
100 if (secondaries->size() == 0) {
110 if (
auto volume{track->GetNextVolume()->GetName()};
111 volume.compareTo(
"hcal_PV") == 0) {
118 if (getEventInfo()->bremCandidateCount() == 1) {
120 track->SetTrackStatus(fKillTrackAndSecondaries);
121 G4RunManager::GetRunManager()->AbortEvent();
122 currentTrack_ =
nullptr;
129 currentTrack_ = track;
130 track->SetTrackStatus(fSuspend);
131 getEventInfo()->decBremCandidateCount();
132 trackInfo->tagBremCandidate(
false);
140 auto processName{secondaries->at(0)->GetCreatorProcess()->GetProcessName()};
143 if (!processName.contains(process_)) {
150 if (getEventInfo()->bremCandidateCount() == 1) {
152 track->SetTrackStatus(fKillTrackAndSecondaries);
153 G4RunManager::GetRunManager()->AbortEvent();
154 currentTrack_ =
nullptr;
161 currentTrack_ = track;
162 track->SetTrackStatus(fSuspend);
163 getEventInfo()->decBremCandidateCount();
164 trackInfo->tagBremCandidate(
false);
169 ldmx_log(debug) <<
"[ EcalProcessFilter ]: "
170 << G4EventManager::GetEventManager()
171 ->GetConstCurrentEvent()
173 <<
" Brem photon produced " << secondaries->size()
174 <<
" particle via " << processName <<
" process.";
175 trackInfo->tagBremCandidate(
false);
176 trackInfo->setSaveFlag(
true);
177 trackInfo->tagPNGamma();
178 getEventInfo()->decBremCandidateCount();