Error in <TTree::Fill>: Failed filling branch... error

Hello,
I have been using 4.02/0 for several months now and have just started testing my code w/ 4.04/02 (win32gdk) I build my application that uses root w/ MSVC++.net 2003 and I built the root libraries from sources with the same compiler.

My application reads root files created with root version <=4.02/0 - these files contain a TTree. The application creates 2 memory resident TTrees: one is a sampled version of the original, the other is a friend. Before I switched to 4.04/02, I had no error messages, after switching to 4.04/02, I get a bunch (tiny fraction of Fill calls give them but I do get them for both the sampled tree and the friend tree) Here’s how the sampled TTree is created (the unsampled TTree is m_ntRawFull):

m_ntRawFull->SetBranchStatus("*",1);
m_ntRawSampled = m_ntRawFull->CloneTree(0);
m_ntRawSampled->SetName("ntf");

Here’s how the friend tree is created:

m_ntCorr = new TTree("ntCorr",m_pchTitle);
m_ntCorr->Branch("tofc",&m_Tofc,"tofc/F");
m_ntCorr->Branch("mass",&m_Mass,"mass/F");
m_ntCorr->Branch("cut",&m_Cut,"cut/S");
m_ntCorr->Branch("tofb",&m_Tofb,"tofb/F");
m_ntCorr->SetBranchStatus("*",1);
m_ntRawSampled->AddFriend(m_ntCorr);

and here’s the Filling loop:

for(int i=0;i<m_ntRawFull->GetEntries();i+=skip) { m_ntRawFull->GetEntry(i); . . calculate stuff for friend tree... . . m_ntRawSampled->Fill(); m_ntCorr->Fill(); } And here is a sampling of the errors I get:

[quote]Error in TTree::Fill: Failed filling branch:ntf.TargetErate, nbytes=-1
Error in TTree::Fill: Failed filling branch:ntf.VMcpFront, nbytes=-1
Error in TTree::Fill: Failed filling branch:ntf.VMcpBias, nbytes=-1
Error in TTree::Fill: Failed filling branch:ntCorr.tofc, nbytes=-1
Error in TTree::Fill: Failed filling branch:ntCorr.mass, nbytes=-1
Error in TTree::Fill: Failed filling branch:ntCorr.tofb, nbytes=-1
Error in TTree::Fill: Failed filling branch:ntf.tof, nbytes=-1
Error in TTree::Fill: Failed filling branch:ntf.pulse, nbytes=-1
Error in TTree::Fill: Failed filling branch:ntf.erate, nbytes=-1
Error in TTree::Fill: Failed filling branch:ntf.Vpa1, nbytes=-1
Error in TTree::Fill: Failed filling branch:ntf.Vpa2, nbytes=-1
Error in TTree::Fill: Failed filling branch:ntf.z, nbytes=-1
Error in TTree::Fill: Failed filling branch:ntf.v, nbytes=-1[/quote]

Any help would be greatly appreciated…

Ed Oltman

Hi,

If the trees are made friends before filling, this may be a problem with 4.04/02 which had been fixed. To get the fix, you should download the branch “v4-04-02-patches” from CVS.

If this does not solve the problem, you;ll need to send me a way to reproduce the problem.

Cheers,
Philippe.

The error was unrelated to the TTree Friend. It was due to trying to write the new TTree objects into the input file (which is intentionally open only read only).

Cheers,
Philippe