Re: Using numbers inside root collection.

From: Rene Brun <Rene.Brun_at_cern.ch>
Date: Mon, 10 Aug 2009 09:13:34 +0200


You can write any non-TObject to a ROOT file, STL collection or ROOT class like TArray.
For example, you can create a TArrayI object and write it to a file with:

root [0] TFile f("junk.root","recreate")
root [1] TArrayI a[5]
root [2] a[0]=0
root [3] a[1]=1
root [4] a[2]=2
root [5] a[3]=3
root [6] a[4]=4
root [7] f.WriteObjectAny(&a,"TArrayI","a")

For more details, read chapter about I/O in the Users Guide.

Rene Brun

Ronen Abravanel wrote:
> Hello,
>
>
> I want to use collection that use numbers (for example, like STL's
> map<Int_t,TString>...)
>
>
> Is there any better way then to create a TObject-derived class that
> wraps Int_t?
>
> (And the same thing about writing Integers into a root file.. Is there
> other way to write numbers to a root file other then wrap them by an
> object?)
>
>
> Thanks,
>
> Ronen.
>
Received on Mon Aug 10 2009 - 09:13:00 CEST

This archive was generated by hypermail 2.2.0 : Mon Aug 10 2009 - 23:50:01 CEST