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,