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"
29
30/*~~~~~~~~~~*/
31/* Core */
32/*~~~~~~~~~~*/
33#include "Framework/Logger.h"
34#include "G4DarkBreM/G4APrime.h" //checking if particles match A'
35#include "G4Electron.hh" //to check if track is electron
36#include "SimCore/G4User/UserTrackInformation.h" //make sure A' is saved
37
38namespace biasing {
39
54 public:
60 TargetDarkBremFilter(const std::string& name,
62
67
73 std::vector<simcore::TYPE> getTypes() override {
74 return {simcore::TYPE::STEPPING, simcore::TYPE::EVENT};
75 }
76
82 void BeginOfEventAction(const G4Event* e) override;
83
95 void stepping(const G4Step* step) override;
96
103 void EndOfEventAction(const G4Event* event) override;
104
105 private:
114 inline bool isOutsideTargetRegion(const G4VPhysicalVolume* vol) const {
115 return vol ? isOutsideTargetRegion(vol->GetLogicalVolume()) : true;
116 }
117
127 inline bool isOutsideTargetRegion(const G4LogicalVolume* vol) const {
128 if (!vol) return true;
129 auto target_region = simcore::g4user::ptrretrieval::getRegion("target");
130 if (!target_region) {
131 ldmx_log(warn) << "Region 'target' not found in Geant4 region store";
132 }
133 auto region = vol->GetRegion();
134 return region ? (region != target_region) : true;
135 }
136
145 void AbortEvent(const std::string& reason) const;
146
147 private:
157
162
163}; // TargetDarkBremFilter
164} // namespace biasing
165
166#endif // BIASING_TARGETDARKBREMFILTER_H__
File holding UserAction prototype and supporting macro.
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:47