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 "G4TouchableHistory.hh"
6#include "G4VProcess.hh"
7
17void GHit::addHitInfosForBitset(const HitBitSet hbs, const G4Step *step) {
18
19 auto preStepPoint = step->GetPreStepPoint();
20 // auto poststepPoint = step->GetPostStepPoint();
21
22 auto touchable = preStepPoint->GetTouchable();
23
24 // Get the global positions and transform to local coordinates.
25 G4ThreeVector xyz = preStepPoint->GetPosition();
26 G4ThreeVector xyzL = touchable->GetHistory()->GetTopTransform().TransformPoint(xyz);
27
28 globalPositions.push_back(xyz);
29 localPositions.push_back(xyzL);
30
31 // Retrieve energy deposition and time information.
32 double edep = (step->GetTotalEnergyDeposit()) * (gtouchable->getEnergyMultiplier());
33 double time = preStepPoint->GetGlobalTime();
34 edeps.push_back(edep);
35 times.push_back(time);
36
37 // Iterate over each bit and call the helper method to add extra info.
38 for (size_t hbIndex = 0; hbIndex < hbs.size(); hbIndex++) {
39 addHitInfosForBitIndex(hbIndex, hbs.test(hbIndex), step);
40 }
41}
42
54bool GHit::addHitInfosForBitIndex(size_t bitIndex, const bool test, const G4Step *thisStep) {
55
56 if (!test) return false; // If the bit is not set, do nothing.
57
58 G4Track *trk = thisStep->GetTrack();
59 G4StepPoint *prestep = thisStep->GetPreStepPoint();
60
61 // For bit 0: record particle ID, energy, and process name.
62 if (bitIndex == 0) {
63 pids.push_back(trk->GetDefinition()->GetPDGEncoding());
64 Es.push_back(prestep->GetTotalEnergy());
65 if (trk->GetCreatorProcess()) {
66 processNames.push_back(trk->GetCreatorProcess()->GetProcessName());
67 }
68 } else if (bitIndex == 1) {
69 // Placeholder: record step length and track info.
70 } else if (bitIndex == 2) {
71 // Placeholder: record mother particle track information.
72 } else if (bitIndex == 3) {
73 // Placeholder: record meta information.
74 } else if (bitIndex == 4) {
75 // Placeholder: record optical photon-specific information.
76 }
77 return true;
78}
void addHitInfosForBitset(HitBitSet hbs, const G4Step *thisStep)
Adds hit information based on a HitBitSet.
std::bitset< NHITBITS > HitBitSet