Message: Obtaining the energy spectrum of neutrons in a room Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

Question Obtaining the energy spectrum of neutrons in a room 

Forum: Biasing and Scoring
Date: Apr 15, 05:57
From: Ferran <Ferran>

I want to make a scorer that obtains the energy of the incoming neutrons that pass through it. The purpose of this is to analyze the back-scattering in a room. The way I proceeded is to create a multifunctional detector with several primitive scorers assigned to it (all of them are PSPassageCellCurrent) and each one has a G4SDParticleWithEnergyFilter filter with an energy interval of my choice. This way, the each scorer counts how many neutrons are in each energy interval and eventually obtaining the neutron energy spectrum in a particular region of the room.

I started by doing one scorer and one energy interval to test such method and the results seemed correct. However, when I extend it by creating an array of scorers I encounter many problems.

I think it has to do on how I obtain the hits collection and the hits map. I based such method on the example B4d in which uses the following:

Run::GetHitsCollection(G4int hcID, const G4Event* event) const
  auto hitsCollection
    = static_cast<G4THitsMap<G4double>*>(
  if ( ! hitsCollection ) {
    G4ExceptionDescription msg;
    msg << "Cannot access hitsCollection ID " << hcID;
      "MyCode0003", FatalException, msg);
  return hitsCollection;


G4double Run::GetSum(G4THitsMap<G4double>* hitsMap) const
  G4double sumValue = 0.;
  for ( auto it : *hitsMap->GetMap() ) {
    sumValue += *(it.second);
  return sumValue;

So that I obtain the total hits in an event by writing: fSphereNeutrons[i] = GetSum(GetHitsCollection(fSphereNeutronsID[i], event)); Where fSphereNeutrons[] is the array I created to store the accumulated hits.

However, instead of doing this in the EventAction file, I do it in the file.

The problem I encounter is that when printing the results, they make no sense at all. I test it by making a monoenergetic beam (2.45MeV) of only 100 neutrons and some of the results register millions of neutrons (and many at higher energies than the beam neutrons).

Does anyone have experience in following such method? Or does anyone have alternatives on making a scorer to obtain the neutron energy spectrum?



 Add Message Add Message
to: "Obtaining the energy spectrum of neutrons in a room"

 Subscribe Subscribe

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