Hi Rooters, The problem is the following: I'm trying to write objects to a TTree and storing it in the file. I see that objects are not empty. But when I try to read this TTree from file almost all objects are empty. The program works without errors. Below you can see the text of the main program simplified but with same problem. I attached all the classes file. I would be grateful for any hints on what is going wrong. Thanks in advance, Korneliy. #include <TROOT.h> #include <TApplication.h> #include <TTree.h> #include <TRandom.h> #include <TFile.h> #include <math.h> #include "DchdEdxDataRoot/DchdEdxEvent.hh" extern void InitGui(); VoidFuncPtr_t initfuncs[] = { InitGui, 0 }; TROOT root("DE_REC","DE_REC", initfuncs); int main(int argc, char **argv){ TApplication theApp("App", &argc, argv); Int_t Nevent=10; Int_t tr,ndigi; TRandom* rnd=new TRandom(); DchdEdxEvent* event_=new DchdEdxEvent(); DchdEdxTrack** tracks_=0; DchdEdxHit** hits_=0; TFile *hfile=new TFile("output/event.root","RECREATE","Test",1); TTree *tree = new TTree("T","Tree"); tree->Branch("event","DchdEdxEvent",&event_); for(Int_t i=0;i<Nevent; i++) { event_->Clear(); tr=(Int_t)ceil(rnd->Rndm()*10)+1; tracks_ =new DchdEdxTrack* [tr]; for(Int_t it=0;it<tr;it++) { tracks_[it]=event_->AddTrack(); tracks_[it]->SetIdTr(it); tracks_[it]->SetP(1.); tracks_[it]->SetChi2(2.); tracks_[it]->SetPhi0(1.); tracks_[it]->SetTanDip(1.); tracks_[it]->SetZ0(1.); tracks_[it]->SetD0(1.); ndigi=(Int_t)ceil(10*rnd->Rndm())+1; hits_ =new DchdEdxHit* [ndigi]; for(Int_t ih=0;ih<ndigi;ih++) { hits_[ih]=tracks_[it]->AddHit(); hits_[ih]->SetIdHit(ih); hits_[ih]->SetLayer(2); hits_[ih]->SetCell(25); hits_[ih]->SetWire(1); hits_[ih]->SetWireStatus(1); hits_[ih]->SetHitX(1); hits_[ih]->SetHitY(3); hits_[ih]->SetHitZ(0); hits_[ih]->SetPhi(2); hits_[ih]->SetTheta(1); hits_[ih]->SetEntrAng(-1); hits_[ih]->SetDipAng(1); hits_[ih]->SetDist(0.1); hits_[ih]->SetDoca(1); hits_[ih]->SetAmbig(1); hits_[ih]->SetCharge(0); hits_[ih]->SetRawCharge(100.0); hits_[ih]->SetCorrCharge(10); } } event_->SetIdEv(i); event_->print(); // I see that event_ is not empty tree->Fill(); } tree->Print(); tree->Write(); hfile->Close(); theApp.Run(); theApp.Terminate(); return 0; } result of program is: Event number =0 Number of tracks = 0 Track number = 0 Number of hits = 11 p=1 Chi2=2 Phi0=1 .... idHit=0 Layer=2 Wire=1 .... idHit=1 .... Event number =1 Number of tracks = 0 Track number = 0 Number of hits = 11 p=1 Chi2=2 Phi0=1 .... idHit=0 Layer=2 Wire=1 .... .............................................. ****************************************************************************** *Tree :T : Tree * *Entries : 10 : Total = 32000 bytes File Size = 0 * * : : Tree compression factor = 1.00 * ****************************************************************************** *Branch :event_ * *Entries : 10 : BranchElement (see below) * *............................................................................* *Br 0 :fUniqueID : * *Entries : 10 : Total Size= 0 bytes File Size = 0 * *Baskets : 0 : Basket Size= 32000 bytes Compression= 1.00 * *............................................................................* *Br 1 :fBits : * *Entries : 10 : Total Size= 0 bytes File Size = 0 * *Baskets : 0 : Basket Size= 32000 bytes Compression= 1.00 * *............................................................................* *Br 2 :IdEv : * *Entries : 10 : Total Size= 0 bytes File Size = 0 * *Baskets : 0 : Basket Size= 32000 bytes Compression= 1.00 * *............................................................................* *Br 3 :NumTracks : * *Entries : 10 : Total Size= 0 bytes File Size = 0 * *Baskets : 0 : Basket Size= 32000 bytes Compression= 1.00 * *............................................................................* *Br 4 :Tracks : * *Entries : 10 : Total Size= 32000 bytes File Size = 0 * *Baskets : 1 : Basket Size= 32000 bytes Compression= 1.00 * *............................................................................*
This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:53 MET