Dear fellow Root users,
I often use the very convenient function gROOT->FindObject(const char *name) but I found, that it is unable to find objects of custom classes loaded as shared libraries. As an example, I changed the class Event from the root/test/ directory to be a child class of TNamed instead of TObject. When I create an event and give it a name, I still can’t find it with gROOT->FindObject
root [0] .L libEvent.so
root [1] Event *ev = new Event()
root [2] ev->SetName("event")
root [3] .ls
root [4] gROOT->FindObject("event")
(const class TObject*)0x0
Only after I save it to a ROOT file, I can find it:
root [5] TFile *file = new TFile("test.root", "RECREATE")
root [6] ev->Write()
(Int_t)312
root [7] .ls
TFile** test.root
TFile* test.root
KEY: Event event;1
KEY: TProcessID ProcessID0;1 00f0ff66-45d4-11e2-9717-1d4ee684beef
root [8] gROOT->FindObject("event")
(const class TObject*)0x145dde0
But this is of cause inconvenient. I am very thankful for suggestions on how to better handle custom classes.
Thank you in advance,
Jules