#include "TFile.h" #include "TTree.h" #include "TChain.h" class A : public TObject { public: A() { x = 0; }; ClassDef(A, 1); int x; }; class B : public TObject { public: B() { x = 0; }; ClassDef(B, 1); int x; int function1() { return (x * x); }; int function2(int y) { return (x * y); }; int function3(A* a) { return (x * a->x); }; }; void test() { TFile* file = new TFile("test.root", "RECREATE"); TTree* tree = new TTree("tree", "tree"); A* a = new A(); B* b = new B(); tree->Branch("a", "A", &a); tree->Branch("b", "B", &b); for (int i = 0; i < 100; ++i) { a->x = i; b->x = i * 10; tree->Fill(); } tree->Write(); file->Close(); TChain* chain = new TChain("tree"); chain->Add("test.root"); // chain->Draw("a.x"); // works // chain->Draw("b.x"); // works // chain->Draw("b.function1()"); // works // the following does not work // Unknown method:function2(a.x) in B // chain->Draw("b->function2(a->x)"); // the following does not work and leads to segfaults // chain->Draw("b->function3(a)"); }