1#include "SimCore/SDs/TrigScintSD.h"
6#include "DetDescr/TrigScintID.h"
12#include "G4StepPoint.hh"
27 auto energy{step->GetTotalEnergyDeposit()};
31 if (energy == 0 and not
isGeantino(step))
return false;
38 G4StepPoint* prePoint = step->GetPreStepPoint();
39 G4StepPoint* postPoint = step->GetPostStepPoint();
40 if (prePoint ==
nullptr || postPoint ==
nullptr) {
51 if (!prePoint->GetTouchableHandle()) {
54 auto touchableHistory{prePoint->GetTouchableHandle()->GetHistory()};
56 auto topTransform{touchableHistory->GetTopTransform()};
58 auto position{0.5 * (prePoint->GetPosition() + postPoint->GetPosition())};
61 auto volumePosition{topTransform.Inverse().TransformPoint(G4ThreeVector())};
62 hit.
setPosition(position[0], position[1], volumePosition.z());
65 auto track{step->GetTrack()};
68 auto bar{track->GetVolume()->GetCopyNo()};
78 hit.
addContrib(track->GetTrackID(), track->GetTrackID(),
79 track->GetParticleDefinition()->GetPDGEncoding(), energy,
80 track->GetGlobalTime());
87 const auto localPreStepPoint{
88 topTransform.TransformPoint(prePoint->GetPosition())};
89 const auto localPostStepPoint{
90 topTransform.TransformPoint(postPoint->GetPosition())};
92 localPreStepPoint[2]);
95 localPostStepPoint[2]);
Class encapsulating parameters for configuring a processor.
T getParameter(const std::string &name) const
Retrieve the parameter of the given name.
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.
Handle to the conditions system, provided at construction to classes which require it.
Dynamically loaded Geant4 SensitiveDetector for saving hits in specific volumes within the simulation...
bool isGeantino(const G4Step *step) const
Check if the passed step is a step of a geantino.
Class defining a sensitive detector of type trigger scintillator.
std::string vol_name_
name of trigger pad volume this SD is capturing
G4bool ProcessHits(G4Step *step, G4TouchableHistory *history) override
Process steps to create hits.
std::string collection_name_
name of the hit collection for this SD
std::vector< ldmx::SimCalorimeterHit > hits_
our collection of hits in this SD
TrigScintSD(const std::string &name, simcore::ConditionsInterface &ci, const framework::config::Parameters &p)
Class constructor.
int module_id_
the ID number for the module we are gathering hits from