8 #include "G4THitsCollection.hh"
9 #include "G4Allocator.hh"
10 #include "G4ThreeVector.hh"
12 #include "G4Colour.hh"
15 #include "gtouchable.h"
28 class GHit :
public G4VHit {
37 GHit(GTouchable* gt,
HitBitSet hbs,
const G4Step* thisStep =
nullptr, std::string cScheme =
"default");
48 inline void*
operator new(size_t);
53 inline void operator delete(
void*);
68 G4Colour colour_touch, colour_hit, colour_passby;
70 bool setColorSchema();
72 std::string colorSchema;
75 GTouchable* gtouchable;
79 std::vector<double> edeps, times;
80 std::vector<G4ThreeVector> globalPositions;
81 std::vector<G4ThreeVector> localPositions;
84 std::vector<int> pids;
85 std::vector<double> Es;
86 std::vector<std::string> processNames;
89 std::vector<double> stepSize;
92 std::optional<double> totalEnergyDeposited;
94 G4ThreeVector avgGlobalPosition;
95 G4ThreeVector avgLocalPosition;
96 std::string processName;
99 bool addHitInfosForBitIndex(
size_t bitIndex,
bool test,
const G4Step* thisStep);
108 [[nodiscard]]
inline std::vector<double>
getEdeps()
const {
return edeps; }
114 [[nodiscard]]
inline std::vector<double>
getTimes()
const {
return times; }
120 [[nodiscard]]
inline std::vector<G4ThreeVector>
getGlobalPositions()
const {
return globalPositions; }
126 [[nodiscard]]
inline std::vector<G4ThreeVector>
getLocalPositions()
const {
return localPositions; }
132 [[nodiscard]]
inline std::vector<int>
getPids()
const {
return pids; }
139 [[nodiscard]]
inline int getPid()
const {
return pids.front(); }
145 [[nodiscard]]
inline std::vector<double>
getEs()
const {
return Es; }
152 [[nodiscard]]
inline double getE()
const {
return Es.front(); }
164 [[nodiscard]]
inline GTouchable*
getGTouchable()
const {
return gtouchable; }
170 [[nodiscard]]
inline std::vector<GIdentifier>
getGID()
const {
return gtouchable->getIdentity(); }
176 [[nodiscard]]
inline std::vector<double>
getDetectorDimensions()
const {
return gtouchable->getDetectorDimensions(); }
212 inline void* GHit::operator
new(size_t) {
217 inline void GHit::operator
delete(
void* hit) {
Represents a hit in the detector.
GTouchable * getGTouchable() const
Returns the GTouchable associated with the hit.
void addHitInfosForBitset(HitBitSet hbs, const G4Step *thisStep)
Adds hit information based on a HitBitSet.
GHit(GTouchable *gt, HitBitSet hbs, const G4Step *thisStep=nullptr, std::string cScheme="default")
Constructor for GHit.
int getPid() const
Returns the first particle ID.
std::vector< double > getDetectorDimensions() const
Returns the dimensions of the detector element.
std::vector< double > getEdeps() const
Gets the energy depositions from each step.
std::vector< GIdentifier > getGID() const
Returns the detector element identity.
std::vector< double > getTimes() const
Gets the time stamps for each step.
~GHit() override=default
Destructor for GHit.
void randomizeHitForTesting(int nsteps)
std::vector< G4ThreeVector > getGlobalPositions() const
Gets the global positions recorded for the hit.
bool is_same_hit(GHit *hit)
Compare two ghits.
void Draw() override
Draws the hit using Geant4 visualization.
std::vector< double > getEs() const
Gets the energy values recorded in bit 1.
void calculateInfosForBit(int bit)
Calculates averaged hit information for the specified bit.
G4ThreeVector getAvgGlobaPosition()
Computes the average global position of the hit.
double getTotalEnergyDeposited()
Computes the total energy deposited.
std::vector< int > getTTID()
Returns the touchable identity values as integers.
G4ThreeVector getAvgLocalPosition()
Computes the average local position of the hit.
double getE() const
Returns the first energy value.
std::vector< int > getPids() const
Gets the particle IDs recorded for the hit.
std::string getProcessName() const
Gets the process name associated with the hit.
std::vector< G4ThreeVector > getLocalPositions() const
Gets the local positions recorded for the hit.
Defines the HitBitSet and associated bit indices.
std::bitset< NHITBITS > HitBitSet
G4ThreadLocal G4Allocator< GHit > * GHitAllocator
G4THitsCollection< GHit > GHitsCollection