But how do thosI reade non-TObjects from a root file?
My trivial guess,
root [0] TFile f("junk.root")
root [1] o = f.Get("a")
(class TObject*)0x8451a20
root [2] a = (TArrayI*)o
(class TArrayI*)0x8451a20
root [3] a->GetAt(1)
Error in <TArrayI::At>: index 1 out of bounds (size: 0, this:
0x08451a20)
(const Double_t)0.00000000000000000e+00root [4] a->GetAt(2)
(const Double_t)0.00000000000000000e+00root [6] a->GetArray()[1]
won't work...
Rene Brun wrote:
> 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 - 11:36:54 CEST
This archive was generated by hypermail 2.2.0 : Mon Aug 10 2009 - 11:50:03 CEST