Fatal error: TTree.h while using Root and Geant4

Hi Everyone!
I tried to run a code but got this problem:

[  4%] Building CXX object CMakeFiles/emphaticSim.dir/emphaticSim.cc.o
/emph/app/ydeniz/local/GCC-8.2.0/bin/g++  -DG4ANALYSIS_USE_ROOT -DG4INTY_USE_XT -DG4LIB_BUILD_DLL -DG4UI_USE_TCSH -DG4VIS_USE_OPENGL -DG4VIS_USE_OPENGLX -I/emph/app/ydeniz/EMPHATIC/DetectorSim/EMPHATICSim/include -I/emph/app/ydeniz/EMPHATIC/DetectorSim/EMPHATICSim/include/Materials -I/emph/app/ydeniz/EMPHATIC/DetectorSim/EMPHATICSim/include/Detectors -isystem /emph/app/ydeniz/GEANT4/geant4.10.6/geant4.10.06-install/include/Geant4  -W -Wall -pedantic -Wno-non-virtual-dtor -Wno-long-long -Wwrite-strings -Wpointer-arith -Woverloaded-virtual -Wno-variadic-macros -Wshadow -pipe -std=c++11  -O3 -DNDEBUG -fno-trapping-math -ftree-vectorize -fno-math-errno -O3 -DNDEBUG   -o CMakeFiles/emphaticSim.dir/emphaticSim.cc.o -c /emph/app/ydeniz/EMPHATIC/DetectorSim/EMPHATICSim/emphaticSim.cc
In file included from /emph/app/ydeniz/EMPHATIC/DetectorSim/EMPHATICSim/emphaticSim.cc:3:
/emph/app/ydeniz/EMPHATIC/DetectorSim/EMPHATICSim/include/EMPHATICSimAnalysisManager.hh:6:10: fatal error: TTree.h: No such file or directory

Have you faced something similar?

I did some research and found similar problems… i understand that the possible issue could be a wrong header location for ROOT

Is there a way to specify the correct headers in cmake or make command while building the simulation.

Any other suggestion or approach would be appreciate.
Sorry if it is a basic question and thanks for all your time guys! :slight_smile:


It seems that the PATH to ROOT is not set up correctly.
In general you should set-up in your environment:

export ROOTSYS=/path_to_ROOT/root
export PATH

(not sure why the dollar sign does not appear before the { but it should be included)

Then you have to change your CMakeLists.txt to link ROOT libraries. Look at the extended example: AnaEx02/CMakeLists.txt

I hope this helps,

1 Like

@guatelli Thanks a lot!! i will tried this now! Can you update AnaEx02/CMakeLists.txt i think the link did’t save any file and It would be super helpful for me :slight_smile:

Best, Yael.

You can find it in the examples/extended/analysis directory of Geant4

1 Like

@guatelli Thanks for all the time you have spent on this post and sorry for bothering you again, i’m still learning how GEANT4 works so i’m still a novice here.

I ran AnaEx02 to find out if it has the same error as my simulations. i can run the AnaEx02 sim but no histograms or Root canvas are displayed. The Root canvas are see in a different location or they must be displayed alongside the simulation?

I also modified my .bashrc and .bash_profile as you suggested (i add some more variables i found online) but still getting the same error, even i remove CmakeCache from the building dir.

Here is my current bash: BASHYAEL.txt (1005 Bytes)

Is that the correct variable set up for G4 and Root Interface?
i really appreciate one last advice, since i’m running out of options :upside_down_face:

Hi. I have done as follows:
source path_to_root/bin/thisroot.sh
then I compiled AnaEx02 and I ran it. The output of the simulation is AnaEx02.root. Then you need to use root to open it. e.g.
type: root
then you can create a TBrowser which allows to navigate easily in the root file. Type: new TBrowser()
then you will see your directories. Click on the root file you intend to open.

I hope this helps you.


1 Like

@Thanks!! I figure out how to set up my CMakeList properly!!

Also Ana Run Successfully :slight_smile:
i really appreciate your time

Cheers, Yael