|
9 | 9 |
|
10 | 10 | // See header for API docs. |
11 | 11 |
|
12 | | -void GHit::addHitInfosForBitset(const HitBitSet hbs, const G4Step* step) { |
13 | | - // Preconditions: |
14 | | - // - 'step' must be non-null (callers provide a valid G4Step from the stepping action). |
15 | | - // - 'gtouchable' must be valid; it provides energy scaling and identity/dimensions. |
16 | | - |
| 12 | +void GHit::addHitInfos(const G4Step* step) { |
17 | 13 | auto preStepPoint = step->GetPreStepPoint(); |
18 | | - // auto poststepPoint = step->GetPostStepPoint(); |
19 | 14 |
|
20 | 15 | auto touchable = preStepPoint->GetTouchable(); |
21 | 16 |
|
22 | | - // Get the global position and transform it to local coordinates of the touchable. |
| 17 | + // Global position and its local-coordinate transform. |
23 | 18 | G4ThreeVector xyz = preStepPoint->GetPosition(); |
24 | 19 | G4ThreeVector xyzL = touchable->GetHistory()->GetTopTransform().TransformPoint(xyz); |
25 | 20 |
|
26 | 21 | globalPositions.push_back(xyz); |
27 | 22 | localPositions.push_back(xyzL); |
28 | 23 |
|
29 | | - // Retrieve energy deposition and time information. |
30 | | - // Energy is scaled by the detector-specific multiplier from GTouchable. |
| 24 | + // Energy deposition (scaled by detector multiplier) and global time. |
31 | 25 | double edep = (step->GetTotalEnergyDeposit()) * (gtouchable->getEnergyMultiplier()); |
32 | 26 | double time = preStepPoint->GetGlobalTime(); |
33 | 27 |
|
34 | 28 | edeps.push_back(edep); |
35 | 29 | times.push_back(time); |
36 | 30 |
|
37 | | - auto track = step->GetTrack(); |
38 | | - auto trackVertex = track->GetVertexPosition(); |
39 | | - int trackId = track->GetTrackID(); |
| 31 | + auto track = step->GetTrack(); |
| 32 | + auto trackVertex = track->GetVertexPosition(); |
| 33 | + int trackId = track->GetTrackID(); |
40 | 34 | int motherTrackId = track->GetParentID(); |
41 | | - int currentPdg = track->GetDefinition()->GetPDGEncoding(); |
| 35 | + int currentPdg = track->GetDefinition()->GetPDGEncoding(); |
42 | 36 |
|
43 | 37 | trackVertexById.emplace(trackId, trackVertex); |
44 | 38 | pdgById.emplace(trackId, currentPdg); |
@@ -66,39 +60,7 @@ void GHit::addHitInfosForBitset(const HitBitSet hbs, const G4Step* step) { |
66 | 60 | trackEs.push_back(preStepPoint->GetTotalEnergy()); |
67 | 61 | motherPids.push_back(motherPdg); |
68 | 62 |
|
69 | | - |
70 | | - // Iterate over each bit and call the helper method to add optional info. |
71 | | - for (size_t hbIndex = 0; hbIndex < hbs.size(); hbIndex++) { |
72 | | - addHitInfosForBitIndex(hbIndex, hbs.test(hbIndex), step); |
73 | | - } |
74 | | -} |
75 | | - |
76 | | -bool GHit::addHitInfosForBitIndex(size_t bitIndex, const bool test, const G4Step* thisStep) { |
77 | | - // If the bit is not enabled, do nothing. |
78 | | - if (!test) return false; |
79 | | - |
80 | | - G4Track* trk = thisStep->GetTrack(); |
81 | | - G4StepPoint* prestep = thisStep->GetPreStepPoint(); |
82 | | - |
83 | | - // Bit 0: record particle ID, per-step total energy, and creator process name (if available). |
84 | | - if (bitIndex == 0) { |
85 | | - pids.push_back(trk->GetDefinition()->GetPDGEncoding()); |
86 | | - Es.push_back(prestep->GetTotalEnergy()); |
87 | | - if (trk->GetCreatorProcess()) { |
88 | | - processNames.push_back(trk->GetCreatorProcess()->GetProcessName()); |
89 | | - } |
90 | | - } |
91 | | - else if (bitIndex == 1) { |
92 | | - // Placeholder: record step length and track info. |
93 | | - } |
94 | | - else if (bitIndex == 2) { |
95 | | - // Placeholder: record mother particle track information. |
96 | | - } |
97 | | - else if (bitIndex == 3) { |
98 | | - // Placeholder: record meta information. |
99 | | - } |
100 | | - else if (bitIndex == 4) { |
101 | | - // Placeholder: record optical photon-specific information. |
| 63 | + if (track->GetCreatorProcess()) { |
| 64 | + processNames.push_back(track->GetCreatorProcess()->GetProcessName()); |
102 | 65 | } |
103 | | - return true; |
104 | 66 | } |
0 commit comments