Bug in cint? pair< int, pair< int,int > > not recognised

Hi all,

I’ve probably found a problem with rootcint:
I’m trying to put a class in a TTree and then read it back, but if I use a variable defined as
std::pair< int, std::pair< int,int > >, when I run the program it gives me the following Warning and nothing is stored in the pairs.

The same happens when I try to read data back from Run22.root file, so I get an empty pair.
Here follows an example of the class I’m trying to put in the Tree:

The Event.h:

#include <vector>
#include <TObject.h>

class Event : public TObject
   Event(void) {;}
  ~Event(void) {;}

   void             setEventNumber (int    event) ;
   int               getEventNumber (void)         ;
   void             addTrack       (double p, double id)   ;

   int eventNumber_       ;
   std::pair< int,std::pair<double,double> >   theTrack_;
} ;[/code]
and Event.cpp:
[code]#include <iostream>
#include "Event.h"

void Event::setEventNumber(int event)
 eventNumber_ = event ;
int Event::getEventNumber()
 return eventNumber_ ;
void Event::addTrack(double p, double id)
  theTrack_.first = (int)id;
  theTrack_.second.first = p ;
  theTrack_.second.second= id;

In Makefile I create the dictionary with:

[code]treeClass: treeClass.o Event.o EventDict.o
g++ -o treeClass treeClass.o
root-config --libs

treeClass.o: treeClass.cpp Event.h
g++ -c -o treeClass.o treeClass.cpp
root-config --cflags
Event.o: Event.cpp
g++ -c -o Event.o -I./ Event.cpp
root-config --cflags

EventDict.o: EventDict.C
g++ -c -o EventDict.o EventDict.C
root-config --cflags

EventDict.C: Event.h
rm -f EventDict.* &&
rootcint EventDict.C -c Event.h+

and when I fill the tree, here he gives me the Warning:

for( int ev=0; ev<10; ++ev) { event->setEventNumber(ev+1547) ; event->addTrack(r->Gaus(50,12),ev+1547) ; theTree.Fill() ; }

I think the code is correct, cause it gives me this kind of problems only for pair of pair, isn’it?
Is there any way to makes it work with this “pair< int, pair< int,int > >” structure?


you need to request a dictionary for that pair<>. Create a Linkdef.h file and add both Event and pair<…> and pass it as the last argument to rootcint; see the Users Guide (“Add your own class”).

Cheers, Axel.

See also the faq: root.cern.ch/drupal/faq#n676