im using ROOT version 5.27/06b and im incurring in a problem when using the function TTree:CopyTree. i’ve wrote a simple program that reproduces the error:
// BEGIN
#include "TTree.h"
#include "TChain.h"
#include "TFile.h"
int main() {
TFile* file = TFile::Open("TEST.root");
TTree* originalTree = (TTree*)file->Get("reducedTree");
TTree* selectedTree = originalTree->CopyTree("ptLept1>50.");
return 0;
}
\\ END
you can find the test file in my afs public: /afs/cern.ch/user/p/pandolf/public/TEST.root
ive checked that “originalTree” exists and is correctly allocated. the line which invokes CopyTree gives the error:
Error in <TTree::Fill>: Failed filling branch:reducedTree.ePart, nbytes=-1, entry=2660
This error is symptomatic of a Tree created as a memory-resident Tree
Instead of doing:
TTree *T = new TTree(...)
TFile *f = new TFile(...)
you should do:
TFile *f = new TFile(...)
TTree *T = new TTree(...)
(blablabla) and gives this error even if i put a dummy selection ("").
Well, if the problem persists, one thing you could do, is loop the first tree, read all the entries, and in the same loop only fill the second tree, if the entry fits the cut. Longer (not that much) but efficient.