Hi,
I’m currently trying to write a macro with the purpose to persist aliases set in a TTree, i.e. write either a copy of the existing tree with extra branches with precomupted numbers corresponding to the list of aliases, or perhaps a friend tree.
Based on the example here Adding a branch to an existing tree, I tried with the following code:
t->SetBranchStatus("*",1);
t->SetEstimate(-1);
TList *alilist = t->GetListOfAliases();
Double_t var[1000];
for (int j=0; j<=alilist->GetLast(); ++j)
{
TString aliname = ((TNamed*)alilist->At(j))->GetName();
TString fml = t->GetAlias(aliname);
TBranch *b = t->Branch(aliname, &var[j], aliname+"/D");
t->Draw(fml, "", "goff");
for (int i=0; i<t->GetEntries(); ++i)
{
t->GetEntry(i);
var[j] = t->GetV1()[i];
b->Fill();
}
}
TFile *f=new TFile(fnameNewTree,"RECREATE");
t->SetDirectory(f);
t->Write();
f->Close();
But this leads to the situation, that the new branches are filled (in the TTree in the output file), but all original branches are empty with the error.
Error in TFile::ReadBuffer: error reading all requested bytes from file friend_data714.root, got 0 of 23901
Anybody an idea how I can fix this?
Best regards and thanks in advance,
Klaus
Please read tips for efficient and successful posting and posting code
ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided