Cling and RDFs

I am trying to link a c++ library via cmake and use objects within RDF code. I created a “Jets” class which is basically a class with a few Rvecs as members. I get it to compile, however when I do a define call for the rdf in python like this:

R.gSystem.Load("./libHHARD.so")
rd = rd.Define("jets", f"""HHARD::Jets(
            recojet_antikt4PFlow_{systematic.suffix}_pt,
            recojet_antikt4PFlow_eta, 
            recojet_antikt4PFlow_phi,
            recojet_antikt4PFlow_m,
            recojet_antikt4PFlow_ftag_quantile_DL1dv01_Continuous,
            recojet_antikt4PFlow_ftag_quantile_GN2v01_Continuous
        )"""

I get the following error:

IncrementalExecutor::executeFunction: symbol '_ZN5HHARD4JetsC1Ev' unresolved while linking [cling interface function]!
You are probably missing the definition of HHARD::Jets::Jets()
Maybe you need to load the corresponding shared library?
Traceback (most recent call last):
  File "/user/jdegens/analysis/dihiggs/plotting/HHARD/bin/bbttManager.py", line 43, in <module>
    analysis_manager.run_analyses_local()  # runs all rdf simultaneously
  File "/user/jdegens/analysis/dihiggs/plotting/HHARD/python/utils/wrappers.py", line 12, in timeit_wrapper
    result = func(*args, **kwargs)
  File "/user/jdegens/analysis/dihiggs/plotting/HHARD/python/managers/AnalysisManager.py", line 159, in run_analyses_local
    R.RDF.RunGraphs(dfs)
cppyy.gbl.std.runtime_error: unsigned int ROOT::RDF::RunGraphs(vector<ROOT::RDF::RResultHandle>) =>
    runtime_error: 
An error occurred during just-in-time compilation in RLoopManager::Run. The lines above might indicate the cause of the crash
All RDF objects that have not run their event loop yet should be considered in an invalid state.

which I think is related to something going wrong with the linking of the library. The weird thing however is that within python I can do the following:

>>> import ROOT as R
>>> R.gSystem.Load("./libHHARD.so")
0
>>> rvec = R.RVec('float')((1, 2, 3))
>>> ivec = R.RVec('int')((1, 2, 3))
>>> jets = R.HHARD.Jets(rvec,rvec,rvec,rvec, ivec,ivec)
>>> jets.m_pt[0]
1.0

Do you have any idea what I am doing wrong? If needed I can provide the CMakeFile, the linkdef and the header file.

Thank you very much for you help

Cheers,
Jordy

I guess you generated the dictionary for your class, right? Maybe @vpadulan can help

yes exactly, that all seems to work and within the simple python script I am also able to load it and create the object

I figured out that a root class needs to have a default constructer, eg. it needs to be able to be constructed without any arguments.

I had a bug in the .h file where I basically did:
Jets();

which I changed to:
Jets(){};

Oh, OK, then I suppose the issue is solved?

It looks like it. Need to do a few more tests, but if nothing occurs then I think it is.

1 Like

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