ghit
Loading...
Searching...
No Matches
addHitInfos.cc
Go to the documentation of this file.
1// ghit
2#include "ghit.h"
3
4// geant4
5#include "G4VProcess.hh"
6
7// See header for API docs.
8
9void GHit::addHitInfos(const G4Step* step) {
10 invalidateCalculatedState();
11
12 auto preStepPoint = step->GetPreStepPoint();
13
14 auto touchable = preStepPoint->GetTouchable();
15
16 // Global position and its local-coordinate transform.
17 G4ThreeVector xyz = preStepPoint->GetPosition();
18 G4ThreeVector xyzL = touchable->GetHistory()->GetTopTransform().TransformPoint(xyz);
19
20 globalPositions.push_back(xyz);
21 localPositions.push_back(xyzL);
22
23 // Energy deposition (scaled by detector multiplier) and global time.
24 double edep = (step->GetTotalEnergyDeposit()) * (gtouchable->getEnergyMultiplier());
25 double time = preStepPoint->GetGlobalTime();
26
27 edeps.push_back(edep);
28 times.push_back(time);
29
30 auto track = step->GetTrack();
31 auto trackVertex = track->GetVertexPosition();
32 int trackId = track->GetTrackID();
33 int motherTrackId = track->GetParentID();
34 int currentPdg = track->GetDefinition()->GetPDGEncoding();
35
36 trackVertexById.emplace(trackId, trackVertex);
37 pdgById.emplace(trackId, currentPdg);
38
39 MotherInfo motherInfo{motherTrackId, std::nullopt, std::nullopt};
40 if (motherTrackId > 0) {
41 auto motherVertex = trackVertexById.find(motherTrackId);
42 if (motherVertex != trackVertexById.end()) {
43 motherInfo.vertex = motherVertex->second;
44 }
45 auto motherPdgIt = pdgById.find(motherTrackId);
46 if (motherPdgIt != pdgById.end()) {
47 motherInfo.pid = motherPdgIt->second;
48 }
49 }
50
51 trackVertexPositions.push_back(trackVertex);
52 motherInfos.push_back(std::move(motherInfo));
53 pids.push_back(currentPdg);
54 tids.push_back(trackId);
55 momenta.push_back(preStepPoint->GetMomentum());
56 trackEs.push_back(preStepPoint->GetTotalEnergy());
57
58 if (track->GetCreatorProcess()) {
59 processNames.push_back(track->GetCreatorProcess()->GetProcessName());
60 }
61}
void addHitInfos(const G4Step *thisStep)
Append per-step information from a G4Step.
Definition addHitInfos.cc:9
std::optional< int > pid
Definition ghit.h:45
std::optional< G4ThreeVector > vertex
Definition ghit.h:44