G4 adv example 'brachytherapy' root error

Hello.
I thank you in advance for any help.
I am trying to use Geant4’s advanced example “brachytherapy”. After running a simulation I can get the file “brachytherapy.root”.
Using Root I am able to use “macro.C” and “plot_primary.C” to generate the graphs.
(I load the file with ’ root brachytherapy.root’, then ‘.x macro.C’)
My problem is when I try to make the comparison between the generated data and the reference data.
In the ‘comparison’ folder is the ‘TG43_relative_dose.C’ which should be used to transform the file ‘brachytherapy.root’ to ‘geant4_dose.txt’ needed to do the comparison.

I am unable to use ‘TG43_relative_dose.C’.
I load the file with ’ root brachytherapy.root’, then ‘.L TG43_relative_dose.C’ and then ‘TG43_relative_dose(“iodine”, “gps”)’.
This is probably something trivial, but after many, many attempts I have not been able to figure out where I am going wrong.

root [0] 
Attaching file brachytherapy.root as _file0...
(TFile *) 0x5d03a188e530
root [1] .L TG43_relative_dose.C
root [2] TG43_relative_dose("iodine","gamma")
input_line_30:2:3: error: use of undeclared identifier 'TG43_relative_dose'
 (TG43_relative_dose("iodine", "gamma"))
  ^
Error in <HandleInterpreterException>: Error evaluating expression (TG43_relative_dose("iodine", "gamma"))
Execution of your code was aborted.

Hi,

Thanks for the post and welcome to the ROOT Community!
This does not look like a ROOT error but more of a configuration issue on your side: have you tried posting the issue on the G4 Discourse Forum?

This error

input_line_30:2:3: error: use of undeclared identifier 'TG43_relative_dose'
 (TG43_relative_dose("iodine", "gamma"))

is telling you that the TG43_relative_dose does not exist in your macro: have you checked it’s there?

Cheers,
D

Thank you for the response.
Since I will have to use Root often I would like to learn how it works.
With macros without input variables I had no problems, while with this one I did. There should be no problems related to packages or installation. However after checking the code and I don’t understand where I am going wrong.

I can neither attach files nor put links, but the file can be easily found as I can neither attach files nor put links, but the file can be easily found as

https://gitlab.cern.ch/geant4/geant4/-/blob/master/examples/advanced/brachytherapy/comparison/TG43_relative_dose.C

Now I tried to write in Geant4’s group as well, but since the question is learning how to use macros in Root it seemed to me that this forum is more suitable.

Hello,

I allow myself also to point you to our learning resources here: Learn - ROOT
Hopefully they will be of help.

Cheers,
D

I have already read the materials, especially root_macros_and_shared_libraries.
I have also already searched the forum and could not find a solution. I decided to open this post after a week of trying, not knowing how else I could do it. I don’t want to waste other people’s time with maybe trivial questions, but I don’t know how else to solve it.

Have you done what Danilo first suggested? If you are trying to call TG43_relative_dose(“iodine”, “gps”) (or gamma), there should be a function inside your TG43_relative_dose.C macro called TG43_relative_dose that takes the 2 arguments you are trying to pass to it (of whatever types iodine and gamma or gps are). If you have, or think you have, such a function, then it’s probably not properly implemented in your macro and thus it cannot be used/found (and then it’s a C++ problem, not a ROOT issue).

Thank you for your response.
I checked and put the link to the file.
In the macro it is declared as

void Read(TString source, TString physics_list){
// Create output file geant4_dose.txt with the dose rate distribution, calculated
// with the simulation results containted in brachytherapy.root

gROOT -> Reset();
TString fileName="brachytherapy_"+source+"_"+physics_list+".root";
std::cout<< "Reading " << fileName << std::endl;
//const char * c = fileName.c_str();
TFile f(fileName);
					     

However, it is not clear to me how it should work.
By giving ‘Read’ in root (after loading with .L ), I only get the on-screen writing of the file.