Get flux as a function of time of interaction

Hi Everyone!

I have problem to get flux of particles in a cell as a function of time. I use counter(eventAction->nAbsPhotons++;) for counting number of
light photons in my SteppingAction as here(It gives true result):


if (particleName == “opticalphoton”){

  eventAction->nAbsPhotons++;
  
  eventAction->absTime = aStep -> GetPreStepPoint() -> GetGlobalTime();
} 

But in the same way, it gives wrong results for other particles.
So I want another way to get flux(number/volume) and time together(such as using primitive scorers, but I need Time of each event too)

Does any one have an experiment in this area??
Any help would be greatly appreciated…

Mesbah

Hi,

Each track has a time stamp at the position.

I think you may be good to choose only first arrived track as a typical time stamp of the event,
or you may need to record the time individually for all the tracks,

Best regards,

Hi,
Thanks for your reply.
But I don’t know how can I do this!!!
In this way how can we discriminate between quantities such as flux, surface flux and population in geant4?
Really I want a way for calculating quantities such as F1, F4 tallies in MCNP, related to time in Geant4…

  • f1 is surface flux
  • f4 is cell flux

Sincerely,
Mesbah

Hi,

I think the easiest way to score surface flux and cell flux is to use the command-based scoring.
The manual is available in the Geant4 (Book for Application developers, Detector Definition and Response>> Command-based scoring.). The scorers and filters are listed in the “List of build-in commands.”.
You will choose cellFlux and flatSurfaceCurrent scorers with a particle filter to specify optical photon.

For the time distribution of optical photons, however, there is no command-based scorer for the time distributions.

If you want to know the time distribution of optical photon, e.g. the number of optical photons in certain time intervals, following way may be good for your purpose.

I recommend to use G4AnalysisManager and some additional code for your application code.

The manual of G4AnalysisManager is available in the Geant4 (Book for Application developers, Analysis >> Analysis Manager Classes.).

For example, following additional codes in your SteppingAction will create “Result_h1_H1_1.csv” for a time distribution.

Your SteppingAction.cc
1)
#include “G4csv.hh”
…. snipped….

Define the G4AnalysisManager and the 1-D histogram in the constructor of SteppingAction.

XXSteppingAction::XXSteppingAction(……){
……
auto analysisManager = G4AnalysisManager::Instance();
auto hid = analysisManager->CreateH1(“H1_1”,“Time of optical photon”, 1000, 0.ns, 180ns); <== Hist name, title, # of bins, min., max.)
// hid should start from 0 by default.
analysisManager->OpenFile(“Result.csv”);

}

Write the result into a file and close the analysis manager in the destructor of SteppingAction

XXSteppingAction::~XXSteppingAction(….){
auto analysisManager = G4AnalysisManager::Instance();
analysisManager->Write();
analysisManager->CloseFile();
}

*( We usually describe these definitions (2) and (3) in UserRunAction class.
This example is just for simple introduction. )

Fill the quantity to the histogram in the method UserSteppingAction.

void XXSteppingAction::UserSteppingAction(….){
……
G4ThreeVector position = step->GetPreStepPoint() -> GetPosition();
… You may need to confirm the position is really on the surface of your interest…….

G4double t = step->GetPreStepPoint() -> GetGlobalTime();
auto analysisManager = G4AnalysisManager::Instance();
analysisManager->FillH1(0, t); < ==== hid = 0, file time (t). Fill time to the histogram.

}

Best regards,

Hello Taso,

thank you very much for detailed and useful description. I would guess this thread may be close.

VI