Hi Korneliy,
I have no problems in reading your file. See a copy of a session below.
Unfortunately, you do not mention which version of Root you are using.
Could you send me your program reading the file?
Rene Brun
root [0] gSystem.Load("libEvent")
root [1] DchdEdxEvent* event_=new DchdEdxEvent();
root [2] TFile f("event.root")
root [3] T.SetBranchAddress("event",&event_)
root [4] T.GetEntry(5)
root [5] event_.Dump()
IdEv 5
NumTracks 3
*Tracks ->86dd990
fUniqueID 0 object unique identifier
fBits 50331648 bit field status word
root [6] TObjArray *Tracks=event_.GetTracks()
root [7] Tracks.ls()
OBJ: DchdEdxTrack DchdEdxTrack : 0
OBJ: DchdEdxTrack DchdEdxTrack : 0
OBJ: DchdEdxTrack DchdEdxTrack : 0
root [8] Tracks.Dump()
IdTr 0
NumHits 4
P 1
Chi2 2
Phi0 1
TanDip 1
Z0 1
D0 1
*Hits ->86e4108
fUniqueID 0 object unique identifier
fBits 50331648 bit field status word
IdTr 1
NumHits 8
P 1
Chi2 2
Phi0 1
TanDip 1
Z0 1
D0 1
*Hits ->86ea9d8
fUniqueID 0 object unique identifier
fBits 50331648 bit field status word
IdTr 2
NumHits 5
P 1
Chi2 2
Phi0 1
TanDip 1
Z0 1
D0 1
*Hits ->86eae08
fUniqueID 0 object unique identifier
fBits 50331648 bit field status word
root [9] DchdEdxTrack *t = (DchdEdxTrack*)Tracks.At(0)
root [10] t.GetHits()->ls()
OBJ: DchdEdxHit DchdEdxHit : 0
OBJ: DchdEdxHit DchdEdxHit : 0
OBJ: DchdEdxHit DchdEdxHit : 0
OBJ: DchdEdxHit DchdEdxHit : 0
root [11] t.GetHits()->Dump()
IdHit 0
Layer 2
Cell 25
Wire 1
Status 1
HitX 1
HitY 3
HitZ 0
Phi 2
Theta 1
EntrAng -1
DipAng 1
Dist 0.1
Doca 1
Ambig 1
Charge 0
RawCharge 100
CorrCharge 10
fUniqueID 0 object unique identifier
fBits 50331648 bit field status word
IdHit 1
Layer 2
Cell 25
Wire 1
Status 1
HitX 1
HitY 3
HitZ 0
Phi 2
Theta 1
EntrAng -1
DipAng 1
Dist 0.1
Doca 1
Ambig 1
Charge 0
RawCharge 100
CorrCharge 10
fUniqueID 0 object unique identifier
fBits 50331648 bit field status word
IdHit 2
Layer 2
Cell 25
Wire 1
Status 1
HitX 1
HitY 3
HitZ 0
Phi 2
Theta 1
EntrAng -1
DipAng 1
Dist 0.1
Doca 1
Ambig 1
Charge 0
RawCharge 100
CorrCharge 10
fUniqueID 0 object unique identifier
fBits 50331648 bit field status word
IdHit 3
Layer 2
Cell 25
Wire 1
Status 1
HitX 1
HitY 3
HitZ 0
Phi 2
Theta 1
EntrAng -1
DipAng 1
Dist 0.1
Doca 1
Ambig 1
Charge 0
RawCharge 100
CorrCharge 10
fUniqueID 0 object unique identifier
fBits 50331648 bit field status word
On Thu, 26 Jul 2001, Korneliy Todyshev wrote:
>
> 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