LDMX Software
TargetDarkBremFilter.h
Go to the documentation of this file.
1
10#ifndef BIASING_TARGETDARKBREMFILTER_H_
11#define BIASING_TARGETDARKBREMFILTER_H_
12
13//----------------//
14// C++ StdLib //
15//----------------//
16#include <algorithm>
17
18//------------//
19// Geant4 //
20//------------//
21#include "G4RunManager.hh"
22#include "G4VPhysicalVolume.hh"
23
24//------------//
25// LDMX //
26//------------//
27#include "SimCore/G4User/PtrRetrieval.h"
28#include "SimCore/UserAction.h"
29
30/*~~~~~~~~~~*/
31/* Core */
32/*~~~~~~~~~~*/
33#include "Framework/Logger.h"
34
35namespace biasing {
36
51 public:
57 TargetDarkBremFilter(const std::string& name,
59
64
70 std::vector<simcore::TYPE> getTypes() override {
71 return {simcore::TYPE::STEPPING, simcore::TYPE::EVENT};
72 }
73
79 void BeginOfEventAction(const G4Event* e) override;
80
92 void stepping(const G4Step* step) override;
93
100 void EndOfEventAction(const G4Event* event) override;
101
102 private:
111 inline bool isOutsideTargetRegion(const G4VPhysicalVolume* vol) const {
112 return vol ? isOutsideTargetRegion(vol->GetLogicalVolume()) : true;
113 }
114
124 inline bool isOutsideTargetRegion(const G4LogicalVolume* vol) const {
125 if (!vol) return true;
126 auto target_region = simcore::g4user::ptrretrieval::getRegion("target");
127 if (!target_region) {
128 ldmx_log(warn) << "Region 'target' not found in Geant4 region store";
129 }
130 auto region = vol->GetRegion();
131 return region ? (region != target_region) : true;
132 }
133
142 void AbortEvent(const std::string& reason) const;
143
144 private:
154
159
160}; // TargetDarkBremFilter
161} // namespace biasing
162
163#endif // BIASING_TARGETDARKBREMFILTER_H__
This class is meant to filter for events that produce a dark brem matching originating in the target ...
~TargetDarkBremFilter()=default
Class destructor.
void stepping(const G4Step *step) override
Looking for A' while primary is stepping.
TargetDarkBremFilter(const std::string &name, framework::config::Parameters &parameters)
Class constructor.
double threshold_
Minimum energy [MeV] that the A' should have to keep the event.
bool isOutsideTargetRegion(const G4VPhysicalVolume *vol) const
Check if the volume is outside the target region.
bool isOutsideTargetRegion(const G4LogicalVolume *vol) const
Check if the volume is outside the target region.
void BeginOfEventAction(const G4Event *e) override
Reset flag signaling finding of A' to false.
void EndOfEventAction(const G4Event *event) override
Check flag signaling finding of A', if false, abort the event so it isn't saved.
void AbortEvent(const std::string &reason) const
Helper to abort an event with a message.
bool found_aprime_
flag to signal that we saw an A'
std::vector< simcore::TYPE > getTypes() override
Get the types of actions this class can do.
Class encapsulating parameters for configuring a processor.
Definition Parameters.h:29
Interface that defines a user action.
Definition UserAction.h:43