Output to .csv for UI based 1D histogram scoring for Probe volume

I’m trying to create a 1D histogram using UI command with 10.07 to score electron energies in a ‘Probe’ region. I’ve been following the latest 10.7 documentation here but I can’t figure out i) how to verify that the histogram is being created and ii) dump the results of the histogram to a (preferably) .csv file. https://geant4-userdoc.web.cern.ch/UsersGuides/ForApplicationDeveloper/html/Detector/commandScore.html#filling-1-d-histogram

The following are some code snippets of how I have implemented it.
In my RunAction.cc
#include "G4TScoreHistFiller.hh"

In the Constructor of my G4UserRunAction:
auto AnalysisManager = G4AnalysisManager::Instance();
AnalysisManager->SetVerboseLevel(1);
AnalysisManager->SetFirstHistoId(1);
histFiller = new G4TScoreHistFiller<G4AnalysisManager>;

In my RunAction.hh file:
#include "Analysis.hh"
G4TScoreHistFiller<G4AnalysisManager>* histFiller;

where my Analysis.hh includes
#include "g4csv.hh"

The scoring portion of my macro file looks like this:
/score/create/probe Probes 2. mm
/score/probe/locate 0. 0. 0. cm
/score/quantity/volumeFlux eMinusFlux
/score/filter/particle eMinusFilter e-
/score/close
/score/list
/analysis/h1/create eMinusFlux Probes_eMinusFlux 100 0.0001 1. MeV ! log
/score/fill1D 1 Probes eMinusFlux

I’m able to dump the volumeFlux tally to a csv using /score/dumpAllQuantitiesToFile Probes Probes.csv but that gives me a single Flux value for the Probe region in the csv. GEANT states that a scoring mesh for the Probe volume has been created but I don’t see anything in the output about the histogram creation or scoring. What am I missing?

Let me know if I can add anything or clarify!

Thanks,
David

To create a histogram output file, you need to invoke the corresponding C++ methods from your RunAction class. Please refer to this section.

Thanks much. I am able to now output a .csv with the histogram bins showing but there is no data that is recorded. Is there something else I need to do, maybe to register the G4TScoreHistFiller histFiller to the histogram? I was under the impression that the /score/fillH1 command would take care of that. Could this have to do with multithreading?

I have added the following to my RunAction::BeginofRunAction
auto analysisManager = G4AnalysisManager::Instance();
analysisManager->OpenFile("OutputCSV");

and the following to RunAction::EndofRunAction
auto analysisManager = G4AnalysisManager::Instance();
analysisManager->Write();
analysisManager->CloseFile();

What do you mean by “no data”? Do you mean no entry? If so, could you check whether tracks are actually hitting the location where you put the probe?

Sorry, I should have been more specific. The simulation I have set up is a point source of I-131 at (0,0,0) and I have the scoring probe as a 4mm cube at (0,0,0). I believe I have confirmed that the probe is scoring because I will use the UI command /score/dumpAllQuantitiesToFile Probes Probes.csv and it outputs the following:

# mesh name: Probes
# primitive scorer name: eMinusFlux
# i, i, i, total(value) [NoUnit], total(val^2), entry
0,0,0,112378,132364,103315

The histogram .csv file that is written is the following: I also have tried other energy binning to no avail.

#class tools::histo::h1d
#title Probes_eMinusFlux
#dimension 1
#axis edges 0.0001 0.000109648 0.000120226 0.000131826 0.000144544 0.000158489 0.00017378 0.000190546 0.00020893 0.000229087 0.000251189 0.000275423 0.000301995 0.000331131 0.000363078 0.000398107 0.000436516 0.00047863 0.000524807 0.00057544 0.000630957 0.000691831 0.000758578 0.000831764 0.000912011 0.001 0.00109648 0.00120226 0.00131826 0.00144544 0.00158489 0.0017378 0.00190546 0.0020893 0.00229087 0.00251189 0.00275423 0.00301995 0.00331131 0.00363078 0.00398107 0.00436516 0.0047863 0.00524807 0.0057544 0.00630957 0.00691831 0.00758578 0.00831764 0.00912011 0.01 0.0109648 0.0120226 0.0131826 0.0144544 0.0158489 0.017378 0.0190546 0.020893 0.0229087 0.0251189 0.0275423 0.0301995 0.0331131 0.0363078 0.0398107 0.0436516 0.047863 0.0524807 0.057544 0.0630957 0.0691831 0.0758578 0.0831764 0.0912011 0.1 0.109648 0.120226 0.131826 0.144544 0.158489 0.17378 0.190546 0.20893 0.229087 0.251189 0.275423 0.301995 0.331131 0.363078 0.398107 0.436516 0.47863 0.524807 0.57544 0.630957 0.691831 0.758578 0.831764 0.912011 1
#annotation axis_x.title [MeV]
#bin_number 102

And then the rest of the entries for each bin are zeros:
0,0,0,0,0

I have exactly the same problem. I’ve tried every way, but I still have an empty csv sheet. I also tried saving to the root format. Same effect.

Update: I was able to get the histogram for the ‘Probe’ volume to populate. I first was able to do so by compiling the program on a single-threaded GEANT4 build, thus pointing me to the idea it was a problem with multi-threading. The problem was ultimately in my RunAction. I was utilizing the ‘RE02’ example which at the beginning of the EndOfRunAction had the line if(!IsMaster()) return; The code used to write the histogram was after this line, implying only the master thread would write the histogram. Once I placed the code to write the histogram before that line, the histograms were written correctly.

Hi dpadam,
I also have same problem about the output file.
i only get a Probes.csv like you show,which only one line data like:

# mesh name: Probes
# primitive scorer name: volFlux
# i, i, i, total(value) [NoUnit], total(val^2), entry
0,0,0,0,0,0

i have added the following to my RunAction::BeginofRunAction
auto analysisManager = G4AnalysisManager::Instance();
analysisManager->OpenFile("OutputCSV");

and the following to RunAction::EndofRunAction
auto analysisManager = G4AnalysisManager::Instance();
analysisManager->Write();
analysisManager->CloseFile();

but l cann’t get any other .csx file output. Could you please help me to it?