Re: Minimal config needed to read/write TNtuple?

From: Rene Brun <Rene.Brun_at_cern.ch>
Date: Tue, 19 Dec 2006 11:36:06 +0100


Hi Tom,

Tom Roberts wrote:
> I am implementing the ability to read and write a TNtuple into my
> Geant4 simulation program. I found that I need to link with libTree,
> libCint, and libCore. When I try to use a TNtuple, I get the error
> message:
> Error: cannot open file "bool.h" :0:
> But the TNtuple file can be written and read correctly. I'm guessing
> that Cint is unhappy, but for a simple TNtuple it is not needed.
I do not understand why yo get this error message. We need more info about the line/function
producing this error.
I include below a trivial main program creating a ntuple into a ROOT file and showing (one line) how
to compile & link this program
see also: http://root.cern.ch/root/HowtoMC.html
>
> I want to distribute a binary version of the program to users who
> probably don't have Root installed, and who are physicists but not C++
> programmers. That error message will be confusing, especially to
> people who never use Root....
>
> What files and directories do I need to include in my distribution,
> beyond those 3 shared objects? Is there any simple way to reduce what
> is needed?
>

This would be BADLY wrong! Installing ROOT is so simple. It is much better if people download
the binary tar file from http://root.cern.ch or install from source in the unlikely case that one
of our binary distributions is not appropriate for their case.

Example of main program tom.cxx


#include "TNtupleD.h"
#include "TFile.h"
#include "TRandom3.h"

int main() {

   TFile *file = TFile::Open("tom.root","recreate");    TNtupleD *ntuple = new TNtupleD("ntuple","example","x:y:z");    TRandom3 r;
   for (int i=0;i<10000;i++) {

      double x = r.Gaus(0,2);
      double y = r.Gaus(-2,1);
      double z = r.Uniform(-3,3);
      ntuple->Fill(x,y,z);

   }
   ntuple->Write();
   ntuple->Print();
   delete file;
}

Procedure to compile & link



g++ -o tom tom.cxx -I$ROOTSYS/include -L$ROOTSYS/lib -lCore -lCint -lTree -ldl

where ROOTSYS is an environment variable pointing to the directory where ROOT is installed.

Rene Brun Received on Tue Dec 19 2006 - 11:36:16 MET

This archive was generated by hypermail 2.2.0 : Mon Jan 01 2007 - 16:32:02 MET