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:
//Event.h
#include <vector>
#include <TObject.h>
class Event : public TObject
{
public:
Event(void) {;}
~Event(void) {;}
void setEventNumber (int event) ;
int getEventNumber (void) ;
void addTrack (double p, double id) ;
private:
int eventNumber_ ;
std::pair< int,std::pair<double,double> > theTrack_;
ClassDef(Event,1)
} ;[/code]
and Event.cpp:
[code]#include <iostream>
#include "Event.h"
ClassImp(Event)
//===================================================
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
Event.o
EventDict.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+
[/code]
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?