LDMX Software
SensitiveDetector.h
1#ifndef SIMCORE_SENSITIVEDETECTOR_H_
2#define SIMCORE_SENSITIVEDETECTOR_H_
3
4#include "Framework/Configure/Parameters.h"
5#include "Framework/Factory.h"
6#include "Framework/Logger.h"
7#include "SimCore/ConditionsInterface.h"
8#include "SimCore/G4User/TrackMap.h"
10
11//------------//
12// Geant4 //
13//------------//
14#include "G4VSensitiveDetector.hh"
15
16namespace simcore {
17
22class SensitiveDetector : public G4VSensitiveDetector {
23 public:
31 SensitiveDetector(const std::string& name, simcore::ConditionsInterface& ci,
32 const framework::config::Parameters& parameters);
33
41 const std::string&,
44
46 virtual ~SensitiveDetector() = default;
47
57 virtual bool isSensDet(G4LogicalVolume* lv) const = 0;
58
67 virtual G4bool ProcessHits(G4Step* step,
68 G4TouchableHistory* hist) override = 0;
69
81 virtual void saveHits(framework::Event& event) = 0;
82
94 virtual void EndOfEvent(G4HCofThisEvent*) override {}
95
99 virtual void onFinishedEvent() = 0;
100
106 // virtual void RecordConfig(ldmx::RunHeader& header) const = 0;
107
108 protected:
118 template <class T>
119 const T& getCondition(const std::string& condition_name) {
120 return conditions_interface_.getCondition<T>(condition_name);
121 }
122
129 bool isGeantino(const G4Step* step) const;
130
141
145 enableLogging("SensitiveDetector");
146
147 private:
150
151}; // SensitiveDetector
152} // namespace simcore
153
160#define DECLARE_SENSITIVEDETECTOR(CLASS) \
161 FACTORY_REGISTRATION(simcore::SensitiveDetector, CLASS)
162
163#endif // SIMCORE_SENSITIVEDETECTOR_H_
Header holding Factory class and supporting macros.
Class which implements the user tracking action.
Implements an event buffer system for storing event data.
Definition Event.h:40
Class encapsulating parameters for configuring a processor.
Definition Parameters.h:26
Handle to the conditions system, provided at construction to classes which require it.
const T & getCondition(const std::string &condition_name)
Primary request action for a conditions object If the object is in the cache and still valid (IOV),...
Dynamically loaded Geant4 SensitiveDetector for saving hits in specific volumes within the simulation...
simcore::ConditionsInterface & conditions_interface_
Handle to our interface to conditions objects.
virtual G4bool ProcessHits(G4Step *step, G4TouchableHistory *hist) override=0
This is Geant4's handle to tell us that a particle has stepped through our sensitive detector and we ...
enableLogging("SensitiveDetector")
Enable logging for this class.
bool isGeantino(const G4Step *step) const
Check if the passed step is a step of a geantino.
const TrackMap & getTrackMap() const
Get a handle to the current track map.
SensitiveDetector(const std::string &name, simcore::ConditionsInterface &ci, const framework::config::Parameters &parameters)
Constructor.
virtual void saveHits(framework::Event &event)=0
We are given the event bus here and we must decide now what to persist into the event.
const T & getCondition(const std::string &condition_name)
Record the configuration of this detector into the run header.
virtual void onFinishedEvent()=0
Cleanup SD and prepare a new-event state.
virtual bool isSensDet(G4LogicalVolume *lv) const =0
Here, we must determine if we should be attached to the input logical volume.
virtual void EndOfEvent(G4HCofThisEvent *) override
This is Geant4's handle to tell us the event is ending.
virtual ~SensitiveDetector()=default
Destructor.
DECLARE_FACTORY_WITH_WAREHOUSE(SensitiveDetector, SensitiveDetector *, const std::string &, simcore::ConditionsInterface &, const framework::config::Parameters &)
The SD Factory.
Defines a map of particle ancestry and particles to be saved.
Definition TrackMap.h:25
TrackMap & getTrackMap()
Get a handle to the current TrackMap for the event.
static TrackingAction * get()
Get a pointer to the current UserTrackingAction from the G4RunManager.
Dynamically loadable photonuclear models either from SimCore or external libraries implementing this ...