_Geant4 Version: 11.0.0
_Operating System:_Sonoma 14.3
_Compiler/Version: X code 15.3
_CMake Version:_3.29.2
Hi all,
I’m running a modified version of the field02 example and wish to count those primaries which impact a certain region of the containment vessel (world). I’ve altered the code in F02SteppingVerbose::StepInfo such that any primary whose x, y and z position is within the bounds of my area of interest are counted. My modified code is below:
if ( verboseLevel == 0 ){
-
*
-
G4double x_pos = fTrack->GetPosition().x();*
-
G4double y_pos = fTrack->GetPosition().y();*
-
G4double z_pos = fTrack->GetPosition().z();*
-
*
-
if ((z_pos <= -45) && (sqrt(pow(x_pos, 2) + pow(y_pos, 2)) <= 14.5)) {*
-
*
-
Total_Target_Hits++;*
-
*
-
const G4DynamicParticle* currentParticle = fTrack->GetDynamicParticle();*
-
G4double currentParticleCharge = currentParticle->GetCharge();*
-
*
-
G4cout << "Cumulative Target Hits = " << Total_Target_Hits << ", this charge: " << currentParticleCharge << G4endl;*
-
*
-
}*
- }*
However I can only read these counts when I set the verbosity level > 0 and doing so severely restricts the number of primaries (/run/beamOn) I can run before it raises an exception.
Setting the code as above such that they should display when the verboseLevel = 0 doesn’t work.
Is it possible to count and display (G4cout etc.) the primary hits in such a way that I don’t need to set the verbosity level greater than 0?
Ideally I only need to know the total hits when the run is finished.