Fatal error: TRandom3.h: No such file or directory #include <TRandom3.h>

I am working in geant4 with root.
how I can solve this problem?

...
localhost.localdomain:/build < 5 >make
Scanning dependencies of target TPC-MC
[  5%] Building CXX object CMakeFiles/TPC-MC.dir/TPC-MC.cc.o
In file included from /home/local1/Desktop/G4argon/TPC-Simulation/TPC-MC.cc:44::
/home/local1/Desktop/G4argon/TPC-Simulation/include/TPCPrimaryGeneratorAction.hh:10:22: fatal error: TRandom3.h: No such file or directory
 #include <TRandom3.h>

it only contained a ‘‘Makefile’’, I had to create a new CMakeFile.txt

I assume you are trying to link ROOT libraries into your Geant4 project.

What does your CMakeLists.txt look like? Did you appropriately update the search paths for include files?

Have you looked at this example?

Also just as an FYI here is how to post code snippets, including errors:

Thanks for answering me.
Well, I am new in this forum and I need to learn, I’ve tried working with this CMakeFile.txt.

CMakeLists.txt (3.6 KB)

I am not sure if my file was uploaded.

I think you problem is with the if statements. You are not indicating the variables correctly. The following should work:

if(${ROOT_FOUND})
   message(STATUS "ROOT was found!")
endif(${ROOT_FOUND})

Thank you. I was successful with your suggestion now I have another type of error.

localhost.localdomain:/build < 9 >cmake -DGeant4_DIR=/usr/local/geant4.10.02.p02 /home/local1/Desktop/G4argon/TPC-Simulation/
– Found ROOT 6.06/02 in /usr/local/root/6.06.02
– Configuring done
– Generating done
– Build files have been written to: /home/local1/Desktop/G4argon/TPC-Simulation/build
localhost.localdomain:/build < 10 >make
[ 5%] Building CXX object CMakeFiles/TPC-MC.dir/src/TPCDetectorConstruction.cc.o
/home/local1/Desktop/G4argon/TPC-Simulation/src/TPCDetectorConstruction.cc: In member function ‘void TPCDetectorConstruction::DefineGeometryParameters()’:
/home/local1/Desktop/G4argon/TPC-Simulation/src/TPCDetectorConstruction.cc:571:18: warning: unused variable ‘dLXeLevelZeroOffset’ [-Wunused-variable]
const G4double dLXeLevelZeroOffset =GetGeometryParameter(“LXeLevelZeroOffset”);
^
/home/local1/Desktop/G4argon/TPC-Simulation/src/TPCDetectorConstruction.cc: In member function ‘void TPCDetectorConstruction::ConstructOuterCryostat()’:
/home/local1/Desktop/G4argon/TPC-Simulation/src/TPCDetectorConstruction.cc:677:69: warning: ISO C++ forbids variable length array ‘pdOuterCryostatBoreFlangeZ’ [-Wvla]
G4double pdOuterCryostatBoreFlangeZ[dOuterCryostatBoreFlangeNumber];

I assume you are asking about the following:

/home/local1/Desktop/G4argon/TPC-Simulation/src/TPCDetectorConstruction.cc:677:69: warning: ISO C++ forbids variable length array ‘pdOuterCryostatBoreFlangeZ’ [-Wvla]

The following is no longer permitted:

int len = 5;
double array[len];

Instead you need to make len a const:

const int len = 5;
double array[len];

or use a dynamic c array:

int len = 5;
double *array = new double[len];
//Remember to call delete!

or preferably use a stl array container:

int len = 5;
std::array<double, len> array;

Hi.
thanks for your suggestion I understand.

const G4int dOuterCryostatBoreFlangeNumber = GetGeometryParameter(“OuterCryostatBoreFlangeNumber”);

G4double pdOuterCryostatBoreFlangeZ[dOuterCryostatBoreFlangeNumber];

for(int i = 0; i < dOuterCryostatBoreFlangeNumber; i++)

But, I still have errors.
With ‘’ … warning: unused variable …’’ as well.

if you want to see the complete code. https://github.com/ivancovish/TPC-mc

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