Filling ROOT histograms with data obtained from Geant4 simulations

Hi Everyone,

I’m trying to save data (x,y,r and energy) generated from a Geant4 simulations into a 3D histogram (TH3D). The ‘r’ component of the data holds information pertaining to which of my 10 detectors has a hit occurred in, While x and y specify which position in each specific detector did the hit (‘the energy deposition’) occur.

In my thinking an array of pointers to TH3D would be the way to go. What I think I need is to structure the analysis manager such that I have a number of if - else if conditions which are setup such that depending on the value of parameter ‘r’ (i.e. a number between 0 -9), a new histogram is created or updated (if it already exist). Can anyone or group persons please help my taught process or proffer to me a new one.

h = (TH3D*) gROOT -> FindObject(“h”);

My second question might be stupid but bare with me please.In the expression above, If I have an array of pointer as my object, what changes in the statement above. i.e if I have a loop structure to generate multiple histograms for each of my detectors. In other words, I am confused on how I will be able to pass each of the objects contained in a hypothetical “h[i]” array of pointers to ‘FindObject()’ .

Thank you.


I propose to go through a first pass through the G4 fora, to draft a first version of the analysis you have in hands. After that, you are welcome to update this thread.
The expression you wrote allows to retrieve an object, in this case you assume it to be an histogram since you cast the pointer, from the memory management of ROOT. In first approximation, dealing with concrete objects, by reference or pointer, is preferable.


This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.