Message: Count of Hits from different Events in the same Run Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

None Count of Hits from different Events in the same Run 

Forum: Event and Track Management
Date: 09 Oct, 2015
From: Daniele Paradiso <Daniele Paradiso>


I am trying to perform simulations of neutron absorption through a material and I have thus modified example B2a to this purpose. In the file, I have implemented such modification, and I am able to determine the first Hit of every Event when that occurs. I would then like to count all these "first Hits" from all the Events in a single Run, but I can't manage to do it. The code is as follows:

void B2EventAction::EndOfEventAction(const G4Event* event)
  // get number of stored trajectories

  G4TrajectoryContainer* trajectoryContainer = event->GetTrajectoryContainer();
  G4int n_trajectories = 0;
  if (trajectoryContainer) n_trajectories = trajectoryContainer->entries();


  G4int eventID = event->GetEventID();
  G4int no_hits = 0;
  G4int no_passed = 0;
  if (eventID < 10)
    G4VHitsCollection* hc = event->GetHCofThisEvent()->GetHC(0);
    no_hits = hc->GetSize();
  if (no_hits > 0) no_passed++;
  G4cout << "Event " << eventID << " - There have been " << no_hits << " hit(s)." << G4endl;
  G4cout << " " << no_passed << " neutron(s) have passed through the target." << G4endl;


I have tried to implement an "if" loop, on the number of Events ("eventID"), as well as "for" and "while" loops, in order to count the first Hit, if happened, as the Events go on, summing on a variable named "no_passed" in the code. What always happens is that it re-counts the same first Hit all the time, and prints a total number of "first Hits" equal to the number of Events, for each single Event.

I have figured I need to exit the EndOfEventAction function somehow, but I don't know how. The G4cout about the total number of neutrons ("no_passed") is within the EndOfEventAction, because I cannot keep it outside without errors, and I don't know where I could put it, since the information comes from EndOfEventAction.

At the same time, I can't believe there is no other way to get that information, maybe with another function implemented in the same .cc file and first defined in the corresponding .hh file.

I hope my question is clear.

Thank you very much in advance,

Daniele Paradiso

 Add Message Add Message
to: "Count of Hits from different Events in the same Run"

 Subscribe Subscribe

This site runs SLAC HyperNews version 1.11-slac-98, derived from the original HyperNews

[ Geant 4 Home | Geant 4 HyperNews | Search | Request New Forum | Feedback ]