RDataFrame Define using my own class defined in c++ get error


Please read tips for efficient and successful posting and posting code

Dear all,
I have written a class in c++ and am going to call it in pyroot, at first i call it by

b=ROOT.JetFitObject(1,1,1,1,1,1)

and it works with no error. After then I call this class in RDataFrame like this

df = ROOT.RDataFrame(10)
df.Define(“j1”,“JetFitObject(1,1,1,1,1,1)”)
.Define(“a”,“1”)
.Snapshot(“events”,“./10.root”,{“a”})

and it get error as follows:



here is a part of the error message, It seems "no matching constructor for initialization of ‘JetFitObject’ ", but if I delete the Snapshot, it also can run successfully in RDataFrame.
So my questions are:

  1. Why this class can be called successfully in pyroot but can’t in RDataFrame Define?

  2. In RDataFrame, why this class can be called successfully only if I don’t Snapshot root file?

_ROOT Version:6.26/06
_Platform:CentOS Linux release 7.9.2009 (Core)
_Compiler:gcc version 11.2.0 (Spack GCC)


Hi @syWang0535 ,

without seeing the definition of JetFitObject I can only guess, but it’s probably because the type does not have a copy constructor and/or a default constructor.

If you remove the Snapshot in that snippet RDF does not even need to just-in-time-compile a function that returns a JetFitObject, so there is no error.

Cheers,
Enrico

Hi @eguiraud ,
Sorry for the late reply, unfortunately this issue has not been resolved. According to your advice, I check the copy constructor of JetFitObjet and it do have a copy constructor. AndI I put the code below,(BaseFitObject is its parent class). I would like to know why JetFitObject can be instantiated in pyroot but not in RDataFrame.(Actually, other class that I defined in c++ can be instantiated in RDataFrame successfully, so I really want to find the JetFitObject’s problems.)

JetFitObject.cc (11.6 KB)
JetFitObject.h (5.1 KB)
BaseFitObject.cc (18.6 KB)
BaseFitObject.h (14.7 KB)

The “default constructor” seems to be missing.

1 Like

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