LDMX Software
Public Member Functions | Private Attributes | List of all members
simcore::TrigScintSD Class Reference

Class defining a sensitive detector of type trigger scintillator. More...

#include <TrigScintSD.h>

Public Member Functions

 TrigScintSD (const std::string &name, simcore::ConditionsInterface &ci, const framework::config::Parameters &p)
 Class constructor.
 
virtual ~TrigScintSD ()=default
 Destructor.
 
virtual bool isSensDet (G4LogicalVolume *vol) const override
 Should the input logical volume be included in this sensitive detector?
 
G4bool ProcessHits (G4Step *step, G4TouchableHistory *history) override
 Process steps to create hits.
 
virtual void saveHits (framework::Event &event) override
 Save our hits collection into the event bus and reset it.
 
virtual void OnFinishedEvent () override
 Cleanup SD and prepare a new-event state.
 
- Public Member Functions inherited from simcore::SensitiveDetector
 SensitiveDetector (const std::string &name, simcore::ConditionsInterface &ci, const framework::config::Parameters &parameters)
 Constructor.
 
virtual ~SensitiveDetector ()=default
 Destructor.
 
virtual void EndOfEvent (G4HCofThisEvent *) override
 This is Geant4's handle to tell us the event is ending.
 

Private Attributes

std::vector< ldmx::SimCalorimeterHithits_
 our collection of hits in this SD
 
std::string collection_name_
 name of the hit collection for this SD
 
std::string vol_name_
 name of trigger pad volume this SD is capturing
 
int module_id_
 the ID number for the module we are gathering hits from
 

Additional Inherited Members

- Public Types inherited from simcore::SensitiveDetector
using Factory = ::simcore::Factory< SensitiveDetector, SensitiveDetector *, const std::string &, simcore::ConditionsInterface &, const framework::config::Parameters & >
 The SD Factory.
 
- Protected Member Functions inherited from simcore::SensitiveDetector
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.
 

Detailed Description

Class defining a sensitive detector of type trigger scintillator.

Definition at line 12 of file TrigScintSD.h.

Constructor & Destructor Documentation

◆ TrigScintSD()

simcore::TrigScintSD::TrigScintSD ( const std::string &  name,
simcore::ConditionsInterface ci,
const framework::config::Parameters p 
)

Class constructor.

Parameters
[in]nameThe name of the sensitive detector.
[in]ciinterface to conditions objects
[in]ppython configuration parameters

Definition at line 16 of file TrigScintSD.cxx.

19 : SensitiveDetector(name, ci, p) {
20 module_id_ = p.getParameter<int>("module_id");
21 collection_name_ = p.getParameter<std::string>("collection_name");
22 vol_name_ = p.getParameter<std::string>("volume_name");
23}
T getParameter(const std::string &name) const
Retrieve the parameter of the given name.
Definition Parameters.h:89
SensitiveDetector(const std::string &name, simcore::ConditionsInterface &ci, const framework::config::Parameters &parameters)
Constructor.
std::string vol_name_
name of trigger pad volume this SD is capturing
Definition TrigScintSD.h:65
std::string collection_name_
name of the hit collection for this SD
Definition TrigScintSD.h:63
int module_id_
the ID number for the module we are gathering hits from
Definition TrigScintSD.h:67

References collection_name_, framework::config::Parameters::getParameter(), module_id_, and vol_name_.

Member Function Documentation

◆ isSensDet()

virtual bool simcore::TrigScintSD::isSensDet ( G4LogicalVolume *  vol) const
inlineoverridevirtual

Should the input logical volume be included in this sensitive detector?

Note
Depends on names in GDML!

In order to avoid attaching to both 'target' and 'sp_target', we intentionally exclude volumes with the string 'sp_' in their names.

Implements simcore::SensitiveDetector.

Definition at line 37 of file TrigScintSD.h.

37 {
38 return vol->GetName().contains(vol_name_) and
39 not vol->GetName().contains("sp_");
40 }

References vol_name_.

◆ OnFinishedEvent()

virtual void simcore::TrigScintSD::OnFinishedEvent ( )
inlineoverridevirtual

Cleanup SD and prepare a new-event state.

Implements simcore::SensitiveDetector.

Definition at line 57 of file TrigScintSD.h.

57{ hits_.clear(); }
std::vector< ldmx::SimCalorimeterHit > hits_
our collection of hits in this SD
Definition TrigScintSD.h:61

References hits_.

◆ ProcessHits()

G4bool simcore::TrigScintSD::ProcessHits ( G4Step *  step,
G4TouchableHistory *  history 
)
overridevirtual

Process steps to create hits.

Parameters
[in]stepThe step information.
[in]historyThe readout history.

Implements simcore::SensitiveDetector.

Definition at line 25 of file TrigScintSD.cxx.

25 {
26 // Get the energy deposited by the particle during the step
27 auto energy{step->GetTotalEnergyDeposit()};
28
29 // If a non-Geantino particle doesn't deposit energy during the step,
30 // skip processing it.
31 if (energy == 0 and not isGeantino(step)) return false;
32
33 // Create a new instance of a calorimeter hit
34 // emplace_back returns a *reference* to the hit that was constructed
35 // and we should keep that reference so that we are editing the correct hit
36 ldmx::SimCalorimeterHit& hit = hits_.emplace_back();
37
38 G4StepPoint* prePoint = step->GetPreStepPoint();
39 G4StepPoint* postPoint = step->GetPostStepPoint();
40 if (prePoint == nullptr || postPoint == nullptr) {
41 return false;
42 }
43
44 // A Geant4 "touchable" is a way to uniquely identify a particular volume,
45 // short for touchable detector element. See the detector definition and
46 // response section of the Geant4 application developers manual for details.
47 //
48 // The TouchableHandle is just a reference counted pointer to a
49 // G4TouchableHistory object, which is a concrete implementation of a
50 // G4Touchable interface.
51 if (!prePoint->GetTouchableHandle()) {
52 return false;
53 }
54 auto touchableHistory{prePoint->GetTouchableHandle()->GetHistory()};
55 // Affine transform for converting between local and global coordinates
56 auto topTransform{touchableHistory->GetTopTransform()};
57 // Set the hit position
58 auto position{0.5 * (prePoint->GetPosition() + postPoint->GetPosition())};
59
60 // Convert the center of the bar to its corresponding global position
61 auto volumePosition{topTransform.Inverse().TransformPoint(G4ThreeVector())};
62 hit.setPosition(position[0], position[1], volumePosition.z());
63
64 // Get the track associated with this step
65 auto track{step->GetTrack()};
66
67 // Set the ID on the hit.
68 auto bar{track->GetVolume()->GetCopyNo()};
70 hit.setID(id.raw());
71
72 // add single contrib to this calorimeter hit
73 // IncidentID - this track's ID
74 // Track ID
75 // PDG ID
76 // energy deposited
77 // global time of this hit
78 hit.addContrib(track->GetTrackID(), track->GetTrackID(),
79 track->GetParticleDefinition()->GetPDGEncoding(), energy,
80 track->GetGlobalTime());
81
82 // Step details
83 hit.setPathLength(step->GetStepLength());
84 hit.setVelocity(track->GetVelocity());
85 // Convert pre/post step position from global coordinates to coordinates
86 // within the scintillator bar
87 const auto localPreStepPoint{
88 topTransform.TransformPoint(prePoint->GetPosition())};
89 const auto localPostStepPoint{
90 topTransform.TransformPoint(postPoint->GetPosition())};
91 hit.setPreStepPosition(localPreStepPoint[0], localPreStepPoint[1],
92 localPreStepPoint[2]);
93
94 hit.setPostStepPosition(localPostStepPoint[0], localPostStepPoint[1],
95 localPostStepPoint[2]);
96
97 hit.setPreStepTime(prePoint->GetGlobalTime());
98 hit.setPostStepTime(postPoint->GetGlobalTime());
99
100 return true;
101}
Stores simulated calorimeter hit information.
void setPreStepTime(const float time)
Set global pre-step time of the hit [ns].
void setPathLength(const float length)
Set the physical path length for the interaction [mm].
void setPosition(const float x, const float y, const float z)
Set the XYZ position of the hit [mm].
void addContrib(int incidentID, int trackID, int pdgCode, float edep, float time)
Add a hit contribution from a SimParticle.
void setPostStepPosition(const float x, const float y, const float z)
Set the XYZ post-step position of the hit in the coordinate frame of the sensitive volume [mm].
void setID(const int id)
Set the detector ID.
void setPostStepTime(const float time)
Set global post-step time of the hit [ns].
void setPreStepPosition(const float x, const float y, const float z)
Set the XYZ pre-step position of the hit in the coordinate frame of the sensitive volume [mm].
void setVelocity(float velocity)
Set the velocity of the track [mm/ns].
Class that defines the detector ID of the trigger scintillator.
Definition TrigScintID.h:14
bool isGeantino(const G4Step *step) const
Check if the passed step is a step of a geantino.

References ldmx::SimCalorimeterHit::addContrib(), hits_, simcore::SensitiveDetector::isGeantino(), module_id_, ldmx::SimCalorimeterHit::setID(), ldmx::SimCalorimeterHit::setPathLength(), ldmx::SimCalorimeterHit::setPosition(), ldmx::SimCalorimeterHit::setPostStepPosition(), ldmx::SimCalorimeterHit::setPostStepTime(), ldmx::SimCalorimeterHit::setPreStepPosition(), ldmx::SimCalorimeterHit::setPreStepTime(), and ldmx::SimCalorimeterHit::setVelocity().

◆ saveHits()

virtual void simcore::TrigScintSD::saveHits ( framework::Event event)
inlineoverridevirtual

Save our hits collection into the event bus and reset it.

Implements simcore::SensitiveDetector.

Definition at line 53 of file TrigScintSD.h.

53 {
54 event.add(collection_name_, hits_);
55 }

References collection_name_, and hits_.

Member Data Documentation

◆ collection_name_

std::string simcore::TrigScintSD::collection_name_
private

name of the hit collection for this SD

Definition at line 63 of file TrigScintSD.h.

Referenced by saveHits(), and TrigScintSD().

◆ hits_

std::vector<ldmx::SimCalorimeterHit> simcore::TrigScintSD::hits_
private

our collection of hits in this SD

Definition at line 61 of file TrigScintSD.h.

Referenced by OnFinishedEvent(), ProcessHits(), and saveHits().

◆ module_id_

int simcore::TrigScintSD::module_id_
private

the ID number for the module we are gathering hits from

Definition at line 67 of file TrigScintSD.h.

Referenced by ProcessHits(), and TrigScintSD().

◆ vol_name_

std::string simcore::TrigScintSD::vol_name_
private

name of trigger pad volume this SD is capturing

Definition at line 65 of file TrigScintSD.h.

Referenced by isSensDet(), and TrigScintSD().


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