I have a TTree pointed to by *tree in my C++ program and want to pass it to MyMacro.C to use it in a CINT session invoked from the C++ program. Here is a primitive-but-it-does-work way as below.
Lines in my C++ program read
TTree *tree = ....
std::stringstream ss;
ss<< tree;
std::string macroName = "MyMacro.C("+'"'+ss.str()+'"'+")";
gROOT->Macro(macroName.c_str());
and in MyMacro.C, I have
void MyMacro(std::string &tp){
TTree *tree;
std::stringstream ss(tp);
ss>> tree;
int nentries = (Int_t)tree->GetEntries();
TObject *tobj;
...
}
No comments:
Post a Comment