Re: update a TNtuple

Rene Brun (Rene.Brun@cern.ch)
Tue, 15 Dec 1998 12:36:50 +0100


Hi Simon,
You do not specify which version you are using. I guess, however,
that you are still using version 2.00/12.
This version had a problem (see release notes of 2.00/13)
when more than one cycle of an object was written to a file.

Rene Brun

S.J.M. Peeters wrote:
>
> Dear ROOT'ers,
>
> I'm trying to read in a pile of ascii files (a mess, but unavoidable) and
> put an abstract of information of all these file in an Ntuple so that I
> can produce the nice plots I'm looking for. Unfortunately my code seems to
> work fine, untill I read in my ntuple to produce the plots:
> root [0] a = new TBrowser()
> (class TBrowser*)0x0
> root [1] mmuzip: error during decompression
> mmuzip: error in header
>
> *** Break *** segmentation violation
>
> I see two ntuple cycles in my file and the above happens when I'm trying
> to look into it one of them.
>
> The essential bit of code is (which gets called for each ascii file to be
> read):
>
> static bool new_file = true;
> TFile *output = new TFile(m_outputfile.String(),"NEW","outputfile");
> TNtuple *threshold;
>
> if (output->IsOpen())
> {
> new_file = false;
> threshold = new TNtuple("threshold","abcdaq data","FE_bias:FE_shaper:"
> "channel:threshold:nr_of_hits:nr_of_events");
> }
> else
> {
> TFile *output = new TFile(m_outputfile.String(),
> "UPDATE","outputfile");
> threshold = (TNtuple*)output->Get("threshold");
> }
>
> // loop over data
> TMapIter next_key(m_y_values);
> sjmp::TObjInt *key;
> while (key = (sjmp::TObjInt*)next_key())
> {
> TObjArray *y_values = (TObjArray*)m_y_values->GetValue(key);
> TIter next_x_value(m_x_values);
> TIter next_y_value(y_values);
> TIter next_n_value(m_number_of_events);
> sjmp::TObjFloat *x_obj;
> sjmp::TObjInt *y_obj;
> sjmp::TObjInt *n_obj;
> while ( ( x_obj = (sjmp::TObjFloat*)next_x_value() ) &&
> ( y_obj = (sjmp::TObjInt*) next_y_value() ) &&
> ( n_obj = (sjmp::TObjInt*) next_n_value() ) )
> {
> threshold->Fill(m_FE_Bias,m_FE_Shaper,key->GetInt(),
> x_obj->GetFloat(),y_obj->GetInt(),n_obj->GetInt());
> }
> }
> threshold->Write();
> output->Close();
>
> I hope someone can tell me want went wrong!
>
> Simon Peeters
> --
> NIKHEF, National Institute for Nuclear and High Energy Physics
> Kruislaan 409, office H-044 Tel:(+31-20-592) 5140
> P.O. Box 41882, 1009 DB Amsterdam (NL) Fax:(+31-20-592) 5155
> CERN, building 40, office 2-D06 Tel:(+41-22-76) 71157