LDMX Software
SensitiveDetector.h
1#ifndef SIMCORE_SENSITIVEDETECTOR_H_
2#define SIMCORE_SENSITIVEDETECTOR_H_
3
4#include "Framework/Configure/Parameters.h"
5#include "Framework/RunHeader.h"
6#include "SimCore/ConditionsInterface.h"
7#include "SimCore/Factory.h"
9#include "SimCore/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
40 using Factory =
42 const std::string&, simcore::ConditionsInterface&,
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
142 private:
145
146}; // SensitiveDetector
147} // namespace simcore
148
155#define DECLARE_SENSITIVEDETECTOR(CLASS) \
156 namespace { \
157 auto v = ::simcore::SensitiveDetector::Factory::get().declare<CLASS>(); \
158 }
159
160#endif // SIMCORE_SENSITIVEDETECTOR_H_
Class which implements the user tracking action.
Implements an event buffer system for storing event data.
Definition Event.h:41
Class encapsulating parameters for configuring a processor.
Definition Parameters.h:27
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),...
Factory to dynamically create objects derived from a specific prototype class.
Definition Factory.h:197
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 ...
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.
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 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.
virtual void OnFinishedEvent()=0
Cleanup SD and prepare a new-event state.
Defines a map of particle ancestry and particles to be saved.
Definition TrackMap.h:28
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.