Adding own class in tree

Dear ROOT experts,
I have trouble with TTree,
Can experts look at this , please?

I have my class MyEvent which contains stl::vector< otherMyclass* - Other my class with stl::vector

If I adding this one class in Ttree then all right, but if I adding severals then there is problem.

class MyEvent::TObject{

private:
stl::vector< Other my class > ;

}

  1. one event

MyEvent* event = new MyEvent();
TFile *f = new TFile(""Event.root,“RECREATE”);
TTree *tree = new TTree(“tree”);
tree->Branch(“br”,“MyEvent”,&event,64000,0);

tree->Fill();
f->Write();

All right here.

  1. several events

MyEvent* event=0;
TFile *f = new TFile(""Event.root,“RECREATE”);
TTree *tree = new TTree(“tree”);
tree->Branch(“br”,“MyEvent”,&event,64000,0);

for( int i = 0; i != count_event ; i++){
event = new MyEvent();

tree->Fill();
delete event;
}
f->Write();

Result: tree which consist count_event null Myclass

Best Regards,
lactic

Could you plesase tell us:
-what is the problem you are facing?
-which version of ROOT?
-could you provide a small tar file reproducing the problem?

Rene

I use root 3.05/07, my problem: I can’t write MyClass ( which contains stl::vector pointers) in Ttree.

Code of programm:
1)heder file of Event:
class MyEvent3D:public TObject{
public:
CMDEvent3D();
~CMDEvent3D();
void setID(Id_int);
void setRun(Id_int);
Id_int getID();
Id_int getRun();
void addVector( MyVector3D*);
vector<MyVector3D*>& getVecVector3D();
void eraseAll();
private:
Id_int id_;
Id_int run_;
vector<MyVector3D*> vecMyVector3D_;
ClassDef(MyEvent3D,1)
};

class MyVector3D:public TObject{
public:
MyVector3D();
~MyVector3D();
void addMyHit3D(MyHit3D*);
void addMyPoint3D( MyPoint3D*);
void setID(Id_int);
vector<MyPoint3D*>& getVecPoint3D();
Id_int getID();
void eraseAll();
private:
Id_int id_;
vector<MyPoint3D*> vecMyPoint3D_;
ClassDef(MyVector3D,1);
};

  1. adding event to tree
    MyEvent3D* event;

File *f = new TFile(nameFile,“RECREATE”);
TTree *tree = new TTree(“tree”," Tree with vector of float ");
tree->Branch(“VEC”,“MyEvent3D”,&event);

for( unsigned long i = 0; i != count_event ; i++){

event = new MyEvent3D();
event->setID(1);
event->setRun(number_run);

for(unsigned long k = 0; k != count_vector ;k++){
MyVector3D* vector = new MyVector3D();
vector->setID(k+1);

    event->addVector(vector);

}
tree->Fill();
delete event;

}

f->Write();
tree->Print();
f->Close()

You should build the dictionary for your classes.
Please see examples in $ROOTSYS/test/TBench.cxx, stress.cxx, etc

Rene