LDMX Software
Public Types | Public Member Functions | Protected Member Functions | Private Attributes | List of all members
simcore::SensitiveDetector Class Referenceabstract

Dynamically loaded Geant4 SensitiveDetector for saving hits in specific volumes within the simulation. More...

#include <SensitiveDetector.h>

Public Types

using Factory = ::simcore::Factory< SensitiveDetector, SensitiveDetector *, const std::string &, simcore::ConditionsInterface &, const framework::config::Parameters & >
 The SD Factory.
 

Public Member Functions

 SensitiveDetector (const std::string &name, simcore::ConditionsInterface &ci, const framework::config::Parameters &parameters)
 Constructor.
 
virtual ~SensitiveDetector ()=default
 Destructor.
 
virtual bool isSensDet (G4LogicalVolume *lv) const =0
 Here, we must determine if we should be attached to the input logical volume.
 
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 should process its interaction with us.
 
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.
 
virtual void EndOfEvent (G4HCofThisEvent *) override
 This is Geant4's handle to tell us the event is ending.
 
virtual void OnFinishedEvent ()=0
 Cleanup SD and prepare a new-event state.
 

Protected Member Functions

template<class T >
const T & getCondition (const std::string &condition_name)
 Record the configuration of this detector into the run header.
 
bool isGeantino (const G4Step *step) const
 Check if the passed step is a step of a geantino.
 
const TrackMapgetTrackMap () const
 Get a handle to the current track map.
 

Private Attributes

simcore::ConditionsInterfaceconditions_interface_
 Handle to our interface to conditions objects.
 

Detailed Description

Dynamically loaded Geant4 SensitiveDetector for saving hits in specific volumes within the simulation.

Definition at line 22 of file SensitiveDetector.h.

Member Typedef Documentation

◆ Factory

The SD Factory.

We have the factory create raw pointers since the G4SDManager handles destruction of all of the registered SensitiveDetectors.

Definition at line 40 of file SensitiveDetector.h.

Constructor & Destructor Documentation

◆ SensitiveDetector()

simcore::SensitiveDetector::SensitiveDetector ( const std::string &  name,
simcore::ConditionsInterface ci,
const framework::config::Parameters parameters 
)

Constructor.

Parameters
[in]nameunique instance name for this sensitive detector
[in]cihandle to current conditions interface
[in]parameterspython configuration parameters

Definition at line 11 of file SensitiveDetector.cxx.

14 : G4VSensitiveDetector(name), conditions_interface_(ci) {
15 // register us with the manager
16 G4SDManager::GetSDMpointer()->AddNewDetector(this);
17}
simcore::ConditionsInterface & conditions_interface_
Handle to our interface to conditions objects.

Member Function Documentation

◆ EndOfEvent()

virtual void simcore::SensitiveDetector::EndOfEvent ( G4HCofThisEvent *  )
inlineoverridevirtual

This is Geant4's handle to tell us the event is ending.

Since we are handling the Hit Collections (HC) directly, the input to this function is of no use to us. This is simply here to make sure that we can reset the SD to a new-event state whether or not a given event was serialized.

Note
: If you are looking for the callback that is used in LDMX-sw when a Simulator event finishes, you want OnFinishedEvent

Definition at line 94 of file SensitiveDetector.h.

94{}

◆ getCondition()

template<class T >
const T & simcore::SensitiveDetector::getCondition ( const std::string &  condition_name)
inlineprotected

Record the configuration of this detector into the run header.

Parameters
[in,out]headerRunHeader to write configuration to Get a condition object from the conditions interface

Used in the same way that EventProcessors can retrieve conditions.

Template Parameters

in,out] T type of condition to get

Parameters
[in]namename of condition to get
Returns
condition object requested

Definition at line 119 of file SensitiveDetector.h.

119 {
120 return conditions_interface_.getCondition<T>(condition_name);
121 }
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),...

References conditions_interface_, and simcore::ConditionsInterface::getCondition().

◆ getTrackMap()

const TrackMap & simcore::SensitiveDetector::getTrackMap ( ) const
inlineprotected

Get a handle to the current track map.

The track map is created only after the event begins, so you will get a segmentation violation if you call this function before an event has started.

Definition at line 138 of file SensitiveDetector.h.

138 {
140 }
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.

References simcore::g4user::TrackingAction::get(), and simcore::g4user::TrackingAction::getTrackMap().

Referenced by simcore::EcalSD::ProcessHits(), and simcore::HcalSD::ProcessHits().

◆ isGeantino()

bool simcore::SensitiveDetector::isGeantino ( const G4Step *  step) const
protected

Check if the passed step is a step of a geantino.

Parameters
[in]stepCurrent step to check
Returns
true if step is coming from neutral/charged genatino

Definition at line 19 of file SensitiveDetector.cxx.

19 {
20 auto particle_def{step->GetTrack()->GetDefinition()};
21 return (particle_def == G4Geantino::Definition() or
22 particle_def == G4ChargedGeantino::Definition());
23}

Referenced by simcore::EcalSD::ProcessHits(), simcore::HcalSD::ProcessHits(), simcore::TrackerSD::ProcessHits(), and simcore::TrigScintSD::ProcessHits().

◆ isSensDet()

virtual bool simcore::SensitiveDetector::isSensDet ( G4LogicalVolume *  lv) const
pure virtual

Here, we must determine if we should be attached to the input logical volume.

Return 'true' if we should be attached to it and 'false' otherwise.

Parameters
[in]lvlogical volume to check
Returns
true if the input lv should be connected to this sensitive detector

Implemented in simcore::EcalSD, simcore::TrigScintSD, simcore::HcalSD, simcore::ScoringPlaneSD, and simcore::TrackerSD.

◆ OnFinishedEvent()

virtual void simcore::SensitiveDetector::OnFinishedEvent ( )
pure virtual

Cleanup SD and prepare a new-event state.

Implemented in simcore::EcalSD, simcore::HcalSD, simcore::ScoringPlaneSD, simcore::TrackerSD, and simcore::TrigScintSD.

◆ ProcessHits()

virtual G4bool simcore::SensitiveDetector::ProcessHits ( G4Step *  step,
G4TouchableHistory *  hist 
)
overridepure virtual

This is Geant4's handle to tell us that a particle has stepped through our sensitive detector and we should process its interaction with us.

Parameters
[in]stepthe step that happened within one of our logical volumes
[in]histthe touchable history of the step

Implemented in simcore::EcalSD, simcore::HcalSD, simcore::ScoringPlaneSD, simcore::TrackerSD, and simcore::TrigScintSD.

◆ saveHits()

virtual void simcore::SensitiveDetector::saveHits ( framework::Event event)
pure virtual

We are given the event bus here and we must decide now what to persist into the event.

This function must perform two tasks.

  1. End-of-event processing on the collected data (e.g. filtering or merging events) before serilization.
  2. Serialization of collected data with event.add
Parameters
[in,out]eventevent bus to add thing(s) to

Implemented in simcore::EcalSD, simcore::HcalSD, simcore::ScoringPlaneSD, simcore::TrackerSD, and simcore::TrigScintSD.

Member Data Documentation

◆ conditions_interface_

simcore::ConditionsInterface& simcore::SensitiveDetector::conditions_interface_
private

Handle to our interface to conditions objects.

Definition at line 144 of file SensitiveDetector.h.

Referenced by getCondition().


The documentation for this class was generated from the following files: