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 "Framework/RunHeader.h"
8#include "SimCore/ConditionsInterface.h"
9#include "SimCore/G4User/TrackMap.h"
11
12//------------//
13// Geant4 //
14//------------//
15#include "G4VSensitiveDetector.hh"
16
17namespace simcore {
18
23class SensitiveDetector : public G4VSensitiveDetector {
24 public:
32 SensitiveDetector(const std::string& name, simcore::ConditionsInterface& ci,
33 const framework::config::Parameters& parameters);
34
42 const std::string&,
45
47 virtual ~SensitiveDetector() = default;
48
58 virtual bool isSensDet(G4LogicalVolume* lv) const = 0;
59
68 virtual G4bool ProcessHits(G4Step* step,
69 G4TouchableHistory* hist) override = 0;
70
82 virtual void saveHits(framework::Event& event) = 0;
83
95 virtual void EndOfEvent(G4HCofThisEvent*) override {}
96
100 virtual void onFinishedEvent() = 0;
101
107 // virtual void RecordConfig(ldmx::RunHeader& header) const = 0;
108
109 protected:
119 template <class T>
120 const T& getCondition(const std::string& condition_name) {
121 return conditions_interface_.getCondition<T>(condition_name);
122 }
123
130 bool isGeantino(const G4Step* step) const;
131
142
146 enableLogging("SensitiveDetector");
147
148 private:
151
152}; // SensitiveDetector
153} // namespace simcore
154
161#define DECLARE_SENSITIVEDETECTOR(CLASS) \
162 FACTORY_REGISTRATION(simcore::SensitiveDetector, CLASS)
163
164#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:42
Class encapsulating parameters for configuring a processor.
Definition Parameters.h:29
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: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.
Dynamically loadable photonuclear models either from SimCore or external libraries implementing this ...