12#include "G4DarkBreM/G4APrime.h"
13#include "G4DarkBreM/G4DarkBremsstrahlung.h"
14#include "G4LogicalVolumeStore.hh"
15#include "SimCore/UserTrackInformation.h"
21 : simcore::UserAction(name, parameters) {
29 for (G4LogicalVolume* volume : *G4LogicalVolumeStore::GetInstance()) {
30 G4String volumeName = volume->GetName();
32 if (volumeName.contains(
"volume") and
33 (volumeName.contains(
"Si") or volumeName.contains(
"W") or
34 volumeName.contains(
"CFMix") or volumeName.contains(
"PCB") or
35 volumeName.contains(
"Al"))) {
40 if (G4RunManager::GetRunManager()->GetVerboseLevel() > 0) {
41 std::cout <<
"[ EcalDarkBremFilter ]: "
42 <<
"Looking for A' in: ";
43 for (
auto const& volume :
volumes_) std::cout << volume->GetName() <<
", ";
44 std::cout << std::endl;
62 const G4Track* aTrack,
const G4ClassificationOfNewTrack& cl) {
63 if (aTrack->GetParticleDefinition() == G4APrime::APrime()) {
76 AbortEvent(
"Found more than one A' during filtering.");
78 AbortEvent(
"A' was not produced above the required threshold.");
99 const G4VProcess* creator = track->GetCreatorProcess();
101 creator->GetProcessName().contains(G4DarkBremsstrahlung::PROCESS_NAME)) {
107 if (track->GetParticleDefinition() == G4APrime::APrime()) {
110 AbortEvent(
"A' wasn't produced inside of the requested volume.");
124 auto inVol = track->GetLogicalVolumeAtVertex();
125 for (
auto const& volume :
volumes_) {
126 if (inVol == volume)
return true;
133 if (G4RunManager::GetRunManager()->GetVerboseLevel() > 1) {
134 std::cout <<
"[ EcalDarkBremFilter ]: "
136 << G4EventManager::GetEventManager()
137 ->GetConstCurrentEvent()
139 <<
") " << reason <<
" Aborting event." << std::endl;
141 G4RunManager::GetRunManager()->AbortEvent();
Class defining a simcore::UserActionPlugin that allows a user to filter out events that don't result ...
void BeginOfEventAction(const G4Event *event) override
Reset flag on if A' has been found.
void NewStage() override
When using the PartialEnergySorter, the first time that a new stage begins is when all particles are ...
double threshold_
Minimum energy [MeV] that the A' should have to keep the event.
void PostUserTrackingAction(const G4Track *track) override
Make sure A' is saved.
bool foundAp_
Have we found the A' yet?
bool inDesiredVolume(const G4Track *) const
Check if input volume is in the desired volume name.
std::vector< G4LogicalVolume * > volumes_
The volumes that the filter will be applied to.
void AbortEvent(const std::string &reason) const
Helper to abort an event with a message.
EcalDarkBremFilter(const std::string &name, framework::config::Parameters ¶meters)
Class constructor.
G4ClassificationOfNewTrack ClassifyNewTrack(const G4Track *aTrack, const G4ClassificationOfNewTrack ¤tTrackClass) override
We return the classification of the track done by the PartialEnergySorter, but we can check here if t...
Class encapsulating parameters for configuring a processor.
T getParameter(const std::string &name) const
Retrieve the parameter of the given name.