# G4 adv example 'brachytherapy' root error

**URL:** <https://root-forum.cern.ch/t/g4-adv-example-brachytherapy-root-error/60264>\
**Category:** Newbie\
**Tags:** root\
**Created:** [July 18, 2024, 8:08pm UTC](https://root-forum.cern.ch/t/g4-adv-example-brachytherapy-root-error/60264 "2024-07-18T20:08:07Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ekidna](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ekidna/32/37142_2.png) [@ekidna](https://root-forum.cern.ch/u/ekidna)\
**Post date:** [July 18, 2024, 8:08pm UTC](https://root-forum.cern.ch/t/g4-adv-example-brachytherapy-root-error/60264/1 "2024-07-18T20:08:07Z")

</div>

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.

```auto
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.

```

---

<div class="post-metadata">

**Author:** ![Danilo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/danilo/32/34528_2.png) [@Danilo](https://root-forum.cern.ch/u/Danilo)\
**Post date:** [July 19, 2024, 5:29am UTC](https://root-forum.cern.ch/t/g4-adv-example-brachytherapy-root-error/60264/2 "2024-07-19T05:29:21Z")

</div>

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

```auto
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

---

<div class="post-metadata">

**Author:** ![ekidna](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ekidna/32/37142_2.png) [@ekidna](https://root-forum.cern.ch/u/ekidna)\
**Post date:** [July 19, 2024, 10:21am UTC](https://root-forum.cern.ch/t/g4-adv-example-brachytherapy-root-error/60264/3 "2024-07-19T10:21:42Z")

</div>

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

```auto
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.

---

<div class="post-metadata">

**Author:** ![Danilo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/danilo/32/34528_2.png) [@Danilo](https://root-forum.cern.ch/u/Danilo)\
**Post date:** [July 19, 2024, 11:31am UTC](https://root-forum.cern.ch/t/g4-adv-example-brachytherapy-root-error/60264/4 "2024-07-19T11:31:48Z")

</div>

Hello,

I allow myself also to point you to our learning resources here: [Learn - ROOT](https://root.cern/learn/)  
Hopefully they will be of help.

Cheers,  
D

---

<div class="post-metadata">

**Author:** ![ekidna](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ekidna/32/37142_2.png) [@ekidna](https://root-forum.cern.ch/u/ekidna)\
**Post date:** [July 19, 2024, 11:47am UTC](https://root-forum.cern.ch/t/g4-adv-example-brachytherapy-root-error/60264/5 "2024-07-19T11:47:44Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![dastudillo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/dastudillo/32/17280_2.png) [@dastudillo](https://root-forum.cern.ch/u/dastudillo)\
**Post date:** [July 19, 2024, 2:13pm UTC](https://root-forum.cern.ch/t/g4-adv-example-brachytherapy-root-error/60264/6 "2024-07-19T14:13:14Z")

</div>

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).

---

<div class="post-metadata">

**Author:** ![ekidna](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ekidna/32/37142_2.png) [@ekidna](https://root-forum.cern.ch/u/ekidna)\
**Post date:** [July 19, 2024, 2:39pm UTC](https://root-forum.cern.ch/t/g4-adv-example-brachytherapy-root-error/60264/7 "2024-07-19T14:39:32Z")

</div>

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

```auto
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.
