1#include "SimCore/SDs/TrigScintSD.h"
6#include "DetDescr/TrigScintID.h"
12#include "G4StepPoint.hh"
30 auto energy{step->GetTotalEnergyDeposit()};
35 ldmx_log(trace) <<
"No energy deposited in step, skipping.";
44 G4StepPoint* pre_point = step->GetPreStepPoint();
45 G4StepPoint* post_point = step->GetPostStepPoint();
46 if (pre_point ==
nullptr || post_point ==
nullptr) {
57 if (!pre_point->GetTouchableHandle()) {
60 auto touchable_history{pre_point->GetTouchableHandle()->GetHistory()};
62 auto top_transform{touchable_history->GetTopTransform()};
64 auto position{0.5 * (pre_point->GetPosition() + post_point->GetPosition())};
67 auto volume_position{top_transform.Inverse().TransformPoint(G4ThreeVector())};
68 hit.
setPosition(position[0], position[1], volume_position.z());
71 auto track{step->GetTrack()};
74 auto bar{track->GetVolume()->GetCopyNo()};
79 G4double birks_factor(1.0);
80 G4double step_length = step->GetStepLength() / CLHEP::cm;
83 if (step_length > 1.0e-6) {
84 G4double rho = step->GetPreStepPoint()->GetMaterial()->GetDensity() /
85 (CLHEP::g / CLHEP::cm3);
86 G4double dedx = energy / (rho * step_length);
90 if (step->GetTrack()->GetDefinition()->GetPDGCharge() == 0) {
97 ldmx_log(trace) <<
"Applying Birks law with factor: " << birks_factor;
98 energy *= birks_factor;
107 hit.
addContrib(track->GetTrackID(), track->GetTrackID(),
108 track->GetParticleDefinition()->GetPDGEncoding(), energy,
109 track->GetGlobalTime());
116 const auto local_pre_step_point{
117 top_transform.TransformPoint(pre_point->GetPosition())};
118 const auto local_post_step_point{
119 top_transform.TransformPoint(post_point->GetPosition())};
121 local_pre_step_point[2]);
124 local_post_step_point[2]);
Class encapsulating parameters for configuring a processor.
const T & get(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 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 addContrib(int incidentID, int trackID, int pdgCode, float edep, float time, int originID=-1)
Add a hit contribution from a SimParticle.
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
bool use_birks_law_
Whether to use Birks law for energy deposition.
G4bool ProcessHits(G4Step *step, G4TouchableHistory *history) override
Process steps to create hits_.
double birks_const_two_
Birks law constants c2.
std::string collection_name_
name of the hit collection for this SD
std::vector< ldmx::SimCalorimeterHit > hits_
our collection of hits in this SD
double birks_const_one_
Birks law constants c1.
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
Dynamically loadable photonuclear models either from SimCore or external libraries implementing this ...