RE: [ROOT] TTree, std::map

From: Axel Naumann (a.naumann@worldnet.att.net)
Date: Wed Sep 12 2001 - 21:41:57 MEST


Hi,

I have used stl stuff wrapped into my own objects - this definitely works
fine. Why don't you just give it a try to put a map in a root file without
wrapping it? It's not true (anymore) that all objects in a tree have to
derive from TObject.

You'll run into a problem with your map though. To my knowledge Root is not
able to parse nested stl containers. What I would advise you to do is to
write your own class which handles a pair of ints and use map<My2IntsClass,
int> instead. Don't forget to implement the My2IntsClass::operator > (or a
global operator >, taking two const My2IntsClass &), otherwise your map
won't work properly...

Good luck!

Cheers, Axel.

> -----Original Message-----
> From: owner-roottalk@pcroot.cern.ch
> [mailto:owner-roottalk@pcroot.cern.ch]On Behalf Of Phil Adamson
> Sent: Wednesday, September 12, 2001 11:10 AM
> To: roottalk@pcroot.cern.ch
> Subject: [ROOT] TTree, std::map
>
>
> Hi Folks,
>
> I have a map (in fact, map<pair<int,int>,int>) that I would like to use as
> a branch in a TTree. As far as I can see from the documentation, I can
> only put basic types or TObjects into TTrees. So does that mean that I
> have to wrap my map in a TObject? Have I misread the docs, and I can put
> bare maps in a TTree?
>
> Is anyone else putting maps in a TTree? What do you do?
>
> 	Phil
>
>



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