Hi,
I am using root 6.26/04. I am reading a TFile with two TTrees, I am trying to make one Tree friend of the other and now I want to remove entries based on a TCut that contains variables on both ttrees. Later I want to open the short file and apply again cuts on it to draw, but fast, since it is small.
However, when I save the E TTree with CopyTree and write and open the small file I find that the new ETree still have access to the friend variables of DTree but in a wrong way. e.g. I cut on “variable_of_DTree<0.5” and if I check the entries as GetEntries(“variable_of_DTree<0.5”) it is not equal to all entries in the file. Is CopyTree not to be used with Friends or am I missing something? Or maybe you are not supposed to use the friends again. I tried to do “RemoveFriend”, but it doesn’t fix the problem.
I have the following code
#include "TFile.h"
#include "TTree.h"
#include "TCut.h"
#include "TROOT.h"
#include <iostream>
int main(int argc, char* argv[]) {
using namespace std;
// Open input files
TFile *f1 = TFile::Open(argv[1]);
TTree *ETree = (TTree*)f1->Get("E");
TTree *DTree = (TTree*)f1->Get("D");
// Add friendships
ETree->AddFriend(DTree);
TCut selection = argv[2];
TFile *newFile = TFile::Open(argv[3], "RECREATE");
// Copy the filtered entries to new trees
TTree *newETree = ETree->CopyTree(selection);
newFile->cd();
newETree->Write("ETree");
newFile->Close();
f1->Close();
return 0;
}