Dear ROOT Experts,
I want to save a class named “PrimaryHits” in a Geant4 application.
In the run action class (named “MuRunAction.cc”), I create a branch as below:
phit = new PrimaryHits;
tree->Branch("event", "PrimaryHits", &phit);
The source file (“PrimaryHits.cc”) is placed in /src directory, and the header file and LinkDef file is placed in /include directory.
I generated libPrimaryHits.so in the /include directory with these commands:
`root-config --cxx --cflags` -fPIC -c ../src/PrimaryHits.cc
rootcint -f PrimaryHitsDict.cc -c -p PrimaryHits.hh LinkDef.hh
`root-config --cxx --cflags` -fPIC -c PrimaryHitsDict.cc
`root-config --cxx --cflags` -fPIC -shared -o libPrimaryHits.so PrimaryHits.o PrimaryHitsDict.o
Then i copied the generated libPrimaryHits.so and pcm file in directory /lib
I linked the libPrimaryHits.so in the cmake file with the command:
include_directories("/home/cihenp/g4proj/MuImag/include")
set(PrimaryHits_LIBRARIES "/home/cihenp/g4proj/MuImag/lib/libPrimaryHits.so")
target_link_libraries(MuImag ${PrimaryHits_LIBRARIES})
The Geant4 application compiles well, but when i execute it, an error occurs saying that:
Error in TTree::Bronch: Cannot find class:PrimaryHits
Does it mean the library has been loaded but the reflection process is not successful?
Is there anything wrong with the steps above?
Best,
Zhi Yu