Re: [ROOT] Ntuples in programs

From: Rene Brun (Rene.Brun@cern.ch)
Date: Thu Oct 26 2000 - 16:02:22 MEST


Hi Marc,
Could you send me a simple working example that I can use
to reproduce your problem ?

Rene Brun

kamps wrote:
> 
> Hello,
> 
> I use ROOT version 2.25/03, using MSVC++ 6.0 under WinNT. The program below
> runs fine
> in principle. If I throw in a couple of events, with Tuple::Addevent, I can
> plot them
> from the n-tuple that is produced. If I add more and more files to the
> project, without
> changing main.cpp at all, none of the extra files using ROOT related code,
> the program will fail in Tuple::CloseTuple, in the line p_file->Write().
> 
> The message I get is then:
> --------------------------------------------------------------------
> <CustomRealloc2>: passed oldsize 1032, should be 18415747
> Fatal in <CustomReAlloc2>: unreasonable size (18415747)
> aborting
> Warning in <TWinNTSystem::StackTrace>: this method must be overriden!
> --------------------------------------------------------------------
> 
> I know that linking root into C++ programs sometimes involves subtleties
> that are
> not present in macros, so I probably have overlooked something simple. I
> want to use
> the buffering and compression facilities of n-tuples in my program, however.
> I hope you can tell from this information what goes wrong.
> Thanks,
>         Marc
> 
> --------------------- main.cpp -----------------------------------
> #include "D:/code/libs/neuronlib/tuple.h"
> 
> int main()
> {
>         Tuple tup;
>         tup.OpenTuple("bla");
>         tup.CloseTuple();
> 
>         return 0;
> }
> ------------------------ tuple.h -----------------------------------
> class Tuple {
> public:
> 
>         Tuple();
> 
>         bool OpenTuple(const char*p);
>         void CloseTuple();
>         void AddEvent( int, int, float);
> };
> 
> ------------------------ tuple.cpp ---------------------------------------
> #include "tuple.h"
> 
> #include <TRoot.h>
> #include <TNtuple.h>
> #include <TFile.h>
> 
> TROOT root("root","tup");
> 
> TFile*   p_file;
> TNtuple* p_tuple;
> 
> Tuple::Tuple()
> {
> }
> 
> bool Tuple::OpenTuple(const char* p)
> {
>         p_file  = new TFile(p,"RECREATE","spike simulation run");
>         p_tuple = new TNtuple("ntuple","events","in:out:time");
> 
>         return true;
> }
> 
> void Tuple::CloseTuple()
> {
>         p_file->Write();
>         p_file->Close();
>         delete p_file;
> }
> 
> void Tuple::AddEvent( int i, int j, float f)
> {
>         p_tuple->Fill((float)i,(float)j,f);
> }
> 
> ----------------------------------------------------------------------------
> ----



This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:36 MET