This gives me Error in <TTree::Branch>: The actual class (TObject) of the object provided for the definition of the branch "event" does not inherit from MyEvent
To add some context (probably that’s relevant), ROOT 6.16/00 is the precompiled binary that I downloaded from the ROOT website; instead, I have compiled ROOT 6.18/04 from source with
It still produces the same error, and now if I try to run it with root test.C+ (which is the way I’ll have to run my actual code), it even produces this fatal error:
Info in <TUnixSystem::ACLiC>: creating shared library test_C.so
Info in <TUnixSystem::ACLiC>: creating shared library myevent_hh.so
Warning in <ACLiC>: Failed to generate the dependency file for myevent_hh.so
<<< cling interactive line includer >>>:1:10: fatal error: '.' file not found
#include "."
^~~
Error in <ACLiC>: Dictionary generation failed!
In file included from input_line_12:6:
././test.C:5:10: fatal error: 'myevent.hh++' file not found
#include "myevent.hh++"
^~~~~~~~~~~~~~
Error in <ACLiC>: Dictionary generation failed!
#include "TROOT.h"
#include <iostream>
#include "TTree.h"
#include "myevent.hh"
#ifdef __ROOTCLING__
#pragma C++ class MyEvent+;
#endif
using namespace std;
void test() {
gROOT->ProcessLine(".L myevent.hh++");
TTree* tree = new TTree("tree", "tree");
MyEvent* event = new MyEvent();
tree->Branch("event", "MyEvent", &event);
auto c = TClass::GetClass("MyEvent");
if (c)
cout << "IsLoaded: " << c->IsLoaded() << endl;
}
and here’s the output:
$ root -l test.C+
root [0]
Processing test.C+...
Info in <TUnixSystem::ACLiC>: creating shared library test_C.so
Info in <ACLiC>: script has already been loaded in interpreted mode
Info in <ACLiC>: unloading myevent.hh and compiling it
Info in <TUnixSystem::ACLiC>: creating shared library myevent_hh.so
Error in <TTree::Branch>: The actual class (TObject) of the object provided for the definition of the branch "event" does not inherit from MyEvent
IsLoaded: 1
Again, running this with ROOT 6.16/00 prints no error.
Thank you for your fast reply. Unfortunately, even aftere these corrections the error doesn’t go away; the class is still loaded.
$ root -l test.C+
root [0]
Processing test.C+...
Info in <TUnixSystem::ACLiC>: creating shared library test_C.so
Error in <TTree::Branch>: The actual class (TObject) of the object provided for the definition of the branch "event" does not inherit from MyEvent
IsLoaded: 1
//test.C
#include "TROOT.h"
#include <iostream>
#include "TTree.h"
#include "myevent.hh"
#ifdef __ROOTCLING__
#pragma link C++ class MyEvent+;
#endif
using namespace std;
void test() {
TTree* tree = new TTree("tree", "tree");
MyEvent* event = new MyEvent();
tree->Branch("event", "MyEvent", &event);
auto c = TClass::GetClass("MyEvent");
if (c)
cout << "IsLoaded: " << c->IsLoaded() << endl;
}
Well at this point I’ll just try recompiling ROOT and hope that somehow the error goes away… The only thing I’m very curious about is if anyone can reproduce this, or I have to dig into some research for an installation problem or whatever.
Yeah, I only learned about it now, strange that I hadn’t seen anything about it in the documentation. Also it is strange, at this point, that the same code worked fine without ClassDef in the older version…
Hi,
with r6.16.00 it was worse:
root/ACliC did not show an error message but MyEvent had
only the TObject part.
You may try my example which has the
event->Dump();
...
You will not see "number"
Cheers
Otto
PS: What I learned meanwhile:
If the compiler doesnt show any more errors
the real (debugging) work begins
Well, that is strange. With ROOT 6.16/00 I was able to successfully fill and read a TTree multiple times with my Event class which didn’t have ClassDef in it… But if it did better work than expected, it’s nothing I’d complain about, I guess