10#include "G4VVisManager.hh"
12#include "G4VisAttributes.hh"
13#include "Randomize.hh"
18std::atomic<int> GHit::globalHitCounter{0};
28 const G4Step* thisStep,
29 const string& cScheme) :
56 vector<GIdentifier> gids =
getGID();
57 ttid.reserve(gids.size());
58 for (
auto& gid : gids) {
60 ttid.push_back(gid.getValue());
66 auto visManager = G4VVisManager::GetConcreteInstance();
67 if (!visManager)
return;
73 if (globalPositions.empty())
return;
75 G4Circle circle(globalPositions[0]);
76 circle.SetFillStyle(G4Circle::filled);
81 circle.SetScreenSize(50);
82 circle.SetVisAttributes(G4VisAttributes(colour_hit));
85 circle.SetScreenSize(15);
86 circle.SetVisAttributes(G4VisAttributes(colour_passby));
87 circle.SetFillStyle(G4Circle::hashed);
90 visManager->Draw(circle);
93bool GHit::setColorSchema() {
95 colour_hit = G4Colour(1.0, 0.0, 0.0);
96 colour_passby = G4Colour(0.0, 1.0, 0.0);
106 for (
int i = 0; i <
nsteps + 1; ++i) {
107 globalPositions.emplace_back(G4UniformRand() * 100, G4UniformRand() * 100, G4UniformRand() * 100);
108 localPositions.emplace_back(G4UniformRand() * 10, G4UniformRand() * 10, G4UniformRand() * 10);
109 times.emplace_back(G4UniformRand() * 100);
110 edeps.emplace_back(G4UniformRand() * 10);
111 Es.emplace_back(G4UniformRand() * 10);
113 pids.emplace_back(
static_cast<int>(G4UniformRand() * 1000));
Stores step-by-step and aggregated information for a detector hit.
GHit(std::shared_ptr< GTouchable > gt, HitBitSet hbs, const G4Step *thisStep=nullptr, const std::string &cScheme="default")
Construct a hit container and optionally seed it from a step.
void addHitInfosForBitset(HitBitSet hbs, const G4Step *thisStep)
Append per-step information from a G4Step according to a bitset.
size_t nsteps() const
Number of recorded steps for the optional-energy vector.
std::vector< GIdentifier > getGID() const
Get the detector element identity.
std::vector< int > getTTID() const
Get the touchable identity values as integers.
bool is_same_hit(const GHit *hit) const
Compare this hit against another hit by sensitive-element identity.
void randomizeHitForTesting(int nsteps)
Randomize internal vectors for test-only usage.
void Draw() override
Visualize the hit using Geant4 visualization primitives.
double getTotalEnergyDeposited()
Get the total deposited energy across all recorded steps.
std::shared_ptr< GTouchable > getGTouchable() const
Get the associated sensitive-element descriptor.
std::bitset< NHITBITS > HitBitSet
Bitset selecting which optional hit information is recorded.
G4ThreadLocal G4Allocator< GHit > * GHitAllocator
#define UNINITIALIZEDNUMBERQUANTITY
#define UNINITIALIZEDSTRINGQUANTITY