Hello ROOTers,
I encountered a problem with TTree which is similar to roottalk  
messages posted in June/2006.
I have read the messages previously posted, but could not solve the  
problem.
root [0] .x PHD.C+
Error in <TTree::Fill>: Failed filling branch:ch2.pedestal, nbytes=-1
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(...)
I wrote a macro (PHD.C) to analyze pulse height distribution of PMTs. It opens some .root files which contain TH1D branch of 10000 entries. All TH1D is curve data of an oscilloscope.
I will attache my macro.
What is wrong with it ?
Sincerely,
OKUMURA, Akira oxon_at_icrr.u-tokyo.ac.jp
Institute for Cosmic Ray Research, University of Tokyo
5-1-5 Kashiwanoha Kashiwa Chiba 277-8582 Japan
Phone/Fax : +81 4-7136-3153
Skype : okumura.akira
On 2006/06/30, at 21:28, Rene Brun wrote:
> You can simplify your code as shown below.
> In your case it looks like you did not create T1 in f1, but you  
> saved T1
> via T1->Write() in f1.
>
> Rene Brun
>
>     TFile *f1 = new TFile(...)
>     TTree *T1 = new TTree(...)
>     T1->Branch...
>     ...
>     TFile *f2 = new TFile(...)
>     TTree *T2 = new TTree(...)
>     T2->Branch...
>     ...
>     fill branches (no need to cd to the file)
>     T1->Fill();
>     T2->Fill();...
>
>     //save headers (no need to cd() if using Autosave)
>     T1->AutoSave();
>     T2->Autosave();
>     ...
>     delete f1;
>     delete f2;
>     ...
>
> Francois-Xavier Girod wrote:
>> Dear rooters,
>>
>> I am using root version 5.11/06, but the problem also appears on  
>> earlier
>> versions.
>>
>> What should I do if I want to write several trees in several files ?
>>
>> I did
>>      TFile *f1 = new TFile(...)
>>      TTree *T1 = new TTree(...)
>>      T1->Branch...
>>      ...
>>      TFile *f2 = new TFile(...)
>>      TTree *T2 = new TTree(...)
>>      T2->Branch...
>>      ...
>> ...
>> (process stuff and fill variables)
>> ...
>> f1->cd()
>> T1->Fill()
>> f2->cd()
>> T2->Fill()
>> ...
>> f1->cd()
>> T1->Write()
>> f2->cd()
>> f2->Write()
>>
>>
>> f2 file is ok, with T2 tree containing its data. However, f1 file  
>> contains
>> T1 tree, which has correct keys (for instance I can get the number of
>> events or the list of leaves) but contains no data. More  
>> specifically if I
>> try to draw something I get :
>>
>> Error in <TFile::ReadBuffer>: error reading all requested bytes  
>> from file
>> outTreeResultDVCS.root, got 0 of 29892
>>
>> I should add that, this only happens for the analysis of a large  
>> number of
>> events. When I process a few events, the output is correct.
>>
>> My guess is that, the way I proceed only the last declared tree is  
>> disk
>> resident, whereas the previous ones are memory resident.
>>
>> Thank you for help.
>>
>> Regards,
>> 	Francois-Xavier
>>
>> --
>>
>> Girod Francois-Xavier
>>
>> CEA Saclay
>> DSM / DAPNIA / SPhN
>> Orme des Merisiers
>> Bat 703 piece 133 C
>> 91191 Gif-sur-Yvette
>> France
>>
>> tel : (+33) 1 69 08 74 29
>> fax : (+33) 1 69 08 75 84
>>
>> On Wed, 28 Jun 2006, Rene Brun wrote:
>>
>>
>>> When this message is printed with teh CVS head version, you also  
>>> get the
>>> following print:
>>>
>>>  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(...)
>>>
>>>
>>> Rene Brun
>>>
>>> Alberto Pulvirenti wrote:
>>>
>>>> Dear rooters,
>>>>
>>>> sometimes, while filling a TTree, I encountered this message:
>>>>
>>>> Error in <TTree::Fill>: Failed filling branch:matches.matches,  
>>>> nbytes=-1
>>>>
>>>> can someone explain me what does it mean? What mistake did I do  
>>>> while
>>>> creating the code to fill that TTree?
>>>> For completeness I must say that this TTree is filled with a branch
>>>> made from a  struct of primitive data types.
>>>>
>>>> Thanks,
>>>>
>>>>     Alberto
>>>>
>>>> **************************************
>>>> ----- Alberto Pulvirenti, Ph. D. -----
>>>>  Universita' di Catania,
>>>>  Dipartimento di Fisica e Astronomia
>>>>  Via Santa Sofia, 64
>>>>  I-95129, Catania, Italy
>>>>
>>>>  Tel :+39-095-3785286
>>>> **************************************
>>>>
>>>
>
>
This archive was generated by hypermail 2.2.0 : Mon Jan 01 2007 - 16:32:01 MET