No dictionary for class _ is available

Hello,

I am trying to read a root file generated by REST using separate C++ code that links to REST/ROOT. I have generated the CMakeLists.txt file by taking a lot of inspiration from the ones in the REST repository to the point that I am able to successfully include ROOT and REST libraries e.g. #include <TRestG4Metadata.h> .

However when I open a root file TFile *f = new TFile(root_file); there appears some warnings about missing dictionaries:

dict_warning

Is there a problem with the makefile? I thought that with the line include(MacroRootDict) it would be fixed but thats not the case. I would appreciate some information about where the dictionaries are stored etc. so I can have a better understanding of the problem.

This is the output of cmake:

I think the problem comes from the line Check for ROOT_DICT_CINT_DEFINITIONS which should not be empty I suppose.

Thanks!

I believe a call to

TRestTools::LoadRESTLibrary( );

just before the use of those classes, should solve the problem. Of course, you should be able to do #include "TRestTools.h". That will be able if you properly added header paths in your CMakeLists.txt.

You can get some inspiration from restRoot I guess.

TRestTools::LoadRESTLibrary() searches, and loads all REST libraries found. Probably a better name for this method would be using plural. LoadRESTLibraries().

1 Like

Then, I recommended to adopt standard REST way to open files.

TRestRun *run = new TRestRun();
run->OpenInputFile( "filename.root");

To gain access to the existing methods to retrieve metadata, analysisTree, eventTree, etc.

TRestG4Metadata *md = (TRestG4Metadata *) run->GetMetadataClass( "TRestG4Metadata" );

or

TRestAnalysisTree *aTree = (TRestAnalysisTree *) run->GetAnalysisTree();

or

TRestG4Event *ev = new TRestG4Event();
run->SetInputEvent(ev);

Then, for example, use

run->GetEntry( n );
ev->PrintEvent();
aTree->PrintObservables();

to get information of a specific entry n.

1 Like

Thanks, adding TRestTools::LoadRESTLibrary( ); solved the warnings and I believe I managed to load the metadata correctly.

Thanks also for this information, I wasn’t sure what was the best way to open files. The information on this post is very useful, thanks!

You are welcome. Probably it is a good moment for you to create a dummy package inside the packages directory with a dummy executable that is able to use REST libraries. Then it can be used in the future as a template to create new packages, and just copy/paste/rename the directory, and rename few variables.

Something like REST_v2/packages/template/ or REST_v2/packages/dummy/. That compiles an executable restDummy and installs it in the system defined REST_PATH/bin installation.

1 Like