Ok… Then I try to ask again attaching full examples as I should have done in the first place to not cause confusion and in hopes to finally understand this topic…
Setup
- OS: Centos 7
- ROOT: 6.18/04 Built for linuxx8664gcc on Sep 11 2019, 15:38:23
- g++: 8.2.0
- DD4hep: v01-11-02
Code example
I have the following script and the file for dictionaries in the same folder:
test.cpp (422 Bytes)
ContLinkDef.h (341 Bytes)
Steps
-
I compile dictionaries with
rootcling -f ContDict.cxx -I${PWD} vector DDRec/Vector3D.h ContLinkDef.h
which creates me dictionary files:
ContDict.cxx (11.3 KB)
and ContDict_rdict.pcm
(can’t attach)
-
I compile both files with
g++ test.cpp ContDict.cxx -I$DD4hep_DIR/include `root-config --cflags --glibs`
and I obtain my compiled executable a.out
.
-
Run ./a.out
which outputs me my root file:
test.root (6.3 KB)
-
Trying to look at the file via TBrowser:
$ root
root [0] new TBrowser
(TBrowser *) 0x21fb010
root [1]
After clicking and opening the file it produces a warning:
root [1] Warning in <TClass::Init>: no dictionary for class dd4hep::rec::Vector3D is available
(TFile *) 0x37c7460
- Looking inside the tree shows correct data stored inside
_x
, _y
, _z
variables of the Vector3D
, but no other methods are written.
For the std::vector
however, branch @size
for the method size()
is present.
Expected behavior
I would expect Vector3D
to be written with all the physical methods, e.g.: theta()
, rho()
, etc.
Trying to understand on my own
I was trying to read some documentation about dictionaries and stumbled upon this link.
which I don’t fully understand, but I see sentences like this:
Looking in the file eventdict.cxx
we can see, theStreamer()
andShowMembers()
methods for the two classes. Streamer()
is used to stream an object to/from a TBuffer
and ShowMembers()
is used by the Dump()
and Inspect()
methods of TObject
. Here is the TEvent::Streamer
method:
And I don’t see neither Streamer()
nor ShowMembers()
in my generated ContDict.cxx
Also this section:
The ShowMembers
and Streamer
method, as well as the >>
operator overloads, are implemented !!!only!!! if you use ClassDef
and ClassImp
. See $ROOTSYS/include/Rtypes.h
for the definition of ClassDef
and ClassImp
indicated to me that it will not produce these methods if I don’t use ClassDef
and ClassImp
whatever that means.
Also this section:
Step 4: Compile the class using the Makefile.
In the Makefile
call rootcling
to make the dictionary for the class. Call it SClassDict.cxx
. The rootcling
utility generates the methods Streamer
, TBuffer
&operator>>() and ShowMembers
for ROOT classes.
Indicated to me that it creates these methods for ROOT classes making me understand that I cannot do that for outside ROOT classes like dd4hep::rec::Vector3D
And at this point I was completely frustrated and lost hope in using dictionaries.
minor notes
initially my question would be how to do that with cmake
. But I switched to g++
to simplify the example, assuming that I will not have problem transferring working example to the cmake
.
P.S. I have tried it with recent ROOT version as well and I believe it does not make any different and behavior stays the same. Only some verbose
messages change if I call rootcint
with -v
flag.
cheers,
Bohdan