Hello ROOTers,
I want to add a branch in a TTree but the variable of this branch is calculated with the entries of another branch. My code is:
void test()
{
TFile f("newer2.root","update");
Float_t energy,tgalpha,alphar,alpha;
TTree *tree = (TTree*)f.Get("sim");
// Float_t energy = tree->GetBranch("shower.Energy");
TBranch *newBranch = tree->Branch("alpha",&alpha,"alpha[nshower]/F");
Long64_t nentries = tree->GetEntries();
for (Long64_t i = 0; i < nentries; i++){
tree->GetEntry(i);
// energy = shower.Energy;
newBranch->Fill();
}
tree->Write("", TObject::kOverwrite);
}
It compiles but when I try to draw the new branch, alpha, I get the error:
Error in <TLeafF::GetLen>: Leaf counter is greater than maximum! leaf: 'alpha' len: 10000000 max: 0
ERROR leaf:alpha, len=10000000 and max=0 ERROR leaf:alpha, len=10000000 and max=0 ERROR leaf:alpha, len=10000000 and max=0 ERROR leaf:alpha, len=10000000 and max=0 ERROR leaf:alpha, len=10000000 and max=0 ERROR leaf:alpha, len=10000000 and max=0
How can I fix this?
Moreover it saves two copies of the tree: the old and the new one. How can I save just the new one?
I'm using version 5.28.
Thanks in advance,
Michelle Mesquita de Medeiros
Instituto de Física - UFG - Brasil
e-mail: medeiros_at_fnal.gov
medeiros_at_posgrad.ufg.br
Received on Mon May 23 2011 - 04:59:06 CEST
This archive was generated by hypermail 2.2.0 : Mon May 23 2011 - 17:50:01 CEST