Re: [ROOT] Reading 2D arrays from a Tree

From: Rene Brun (Rene.Brun@cern.ch)
Date: Tue Nov 13 2001 - 17:33:30 MET


Hi Ben,

I have no problems in running your program as it is.
I do not know on which system you run, or which version of ROOT you use.
If you run on Linux, jus do:

g++ -o ben ben.cxx -I$ROOTSYS/include `root-config --libs`
ben

This should produce the following output:

******************************************************************************
*Tree    :tree      : Testing still                                          *
*Entries :      150 : Total =           43417 bytes  File  Size =      24768 *
*        :          : Tree compression factor =   2.43                       *
******************************************************************************
*Br    0 :adc       : adc[10][10]/F                                          *
*Entries :      150 : Total  Size=      31662 bytes  File Size  =      13013 *
*Baskets :        1 : Basket Size=      32000 bytes  Compression=   2.43     *
*............................................................................*


Rene Brun


Ben Morgan wrote:
> 
> Thanks Rene,
>             Adding this line does allow compilation, but running the
> program then results in a segmentation violation:
> 
>  *** Break *** segmentation violation
> Abort (core dumped)
> 
> Again, I'm running ROOT 3.01/06 under RH6.2. In case this is a problem
> with my tree generating code this is:
> 
> #include<iostream.h>
> #include<iomanip.h>
> #include<fstream.h>
> #include<stdio.h>
> #include <stdlib.h>
> #include<math.h>
> 
> //ROOT Headers Needed
> #include "TROOT.h"
> #include "TFile.h"
> #include "TNetFile.h"
> #include "TRandom.h"
> #include "TTree.h"
> #include "TBranch.h"
> #include "TClonesArray.h"
> #include "TStopwatch.h"
> 
> int main(int argc, char **argv)
> {
> 
> Float_t adc[10][10];
> 
> TFile *file=new TFile("adc.root","RECREATE");
> TTree *tree=new TTree("tree","Testing still");
> tree->Branch("adc",adc,"adc[10][10]/F");
> for (Int_t k=0; k<150; k++) {
>   for(Int_t j=0; j<10; j++) {
>     for(Int_t i=0; i<10; i++) adc[i][j]=k*100+j*10+i;
>   }
>   tree->Fill();
> }
> tree->Write();
> tree->Print();
> file->Close();
> 
>    return 0;
> }
> 
> Thanks Again,
> 
> Ben Morgan.
> 
> --
> -------------------------------------------------------------------------------
> Mr. Ben Morgan
> Postgraduate Student
> University of Sheffield
> Department of Physics & Astronomy
> Hicks Building
> Hounsfield Road
> Sheffield  S3 7RH
> -------------------------------------------------------------------------------



This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:51:08 MET