目标; 我希望比较两个具有相同结构的ROOT TTree对象的内容(但显然不是相同的内容)。最好的方法似乎是使用AddFriend。
问题; 我收到此错误消息;
Error: illegal pointer to class object t3 0x0 1681 makeFriends.C:6:
*** Interpreter error recovered ***
到目前为止我已经尝试过什么;在成功运行此页面
底部的示例后,我决定将其缩减为仅阅读和添加朋友部分,因为我已经创建tree3.root
并tree3f.root
在第一次运行中。所以我有一个名为 tree3.C 的文件,其中包含;
// Function to read the two files and add the friend
void tree3r() {
TFile *f = new TFile("tree3.root");
TTree *t3 = (TTree*)f->Get("t3");
// Add the second tree to the first tree as a friend
t3->AddFriend("t3f","tree3f.root");
// Draw pz which is in the first tree and use pt
// in the condition. pt is in the friend tree.
//t3->Draw("pz","pt>5");
}
当从根提示符加载 ( root[] .L tree3.C
) 并运行 ( )时,这按预期工作。root[] tree3r()
因此,我将副本放在包含我的两个根文件plainMaskOutput.root
和, 的文件夹中DNMaskOutput.root
,并更改了副本中的字符串以匹配我的文件名。所以我有;
// Function to read the two files and add the friend
void tree3r() {
TFile *f = new TFile("plainMaskOutput.root");
TTree *t3 = (TTree*)f->Get("t3");
// Add the second tree to the first tree as a friend
t3->AddFriend("t3f","DNMaskOutput.root");
// Draw pz which is in the first tree and use pt
// in the condition. pt is in the friend tree.
//t3->Draw("pz","pt>5");
}
这给出了上面的错误。我不明白为什么这些事情的行为不同?为什么他们不能只是朋友?