Re: Using numbers inside root collection.

From: Philippe Canal <pcanal_at_fnal.gov>
Date: Mon, 10 Aug 2009 11:56:07 -0500


Hi Ronen,

You can even simply the writing statement down to just:   

    f.WriteObject(&a,"a");

The TFile will discover the type automatically.

Cheers,
Philippe.

PS. Note also the typo the root [1] should read TArrayI a(5) I.e. paranthesis rather than square brackets.

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 - 18:56:20 CEST

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