Root Tuples with variable dimension of Arrays.

From: Ahsan, Mahsana <mahsana_at_phys.ksu.edu>
Date: Tue, 7 Jun 2005 12:54:17 -0500


Hello Rooter;

 Please find below my short example for creating root tuples. I am having a problem in getting right informtion when I fill the tree. Only the first leaf "njets" is OK while all others are quite corrupted. Can somebody please point me out what I am doing wrong. I want to get tuples as

"tree->branch1->leaves

->branch2->leaves
->branch3->leaves
....."

However the "tree->leaves" works even with variable dimension of array. The root version is 4.00/04.



struct Jet{   
	 int njets;
	 float eta[10];
	 float phi[10];
	 float e[10];
	 float pt[10];

}

 Jet jet;
 TFile *hfile = new TFile("example.root","RECREATE","TTree root file");  hfile->SetCompressionLevel(1);
 TTree *mytree = new TTree("mytree","Reconst tuple");

 mytree->Branch("jet",&jet.njets,"njets/I:ntracks[njets]/I:eta[njets]/F:phi[njets]/F:e[njets]/F");

 int nentries = 500;
 TCloneArray fJets;

 for(int ii=0;ii<nentries;ii++){  

 for(int ijet=0;ijet<fJets->GetLast()+1;ijet++){

 jet.njets = ijet;
 jet.pt[ijet] = cj->Pt();
 jet.eta[ijet] = cj->Eta();
 jet.phi[ijet] = cj->Phi();
 jet.e[ijet] = cj->E();

 }
 mytree->Fill();

 }


Thank you very much for help,
Mahsana Received on Tue Jun 07 2005 - 19:55:48 MEST

This archive was generated by hypermail 2.2.0 : Tue Jan 02 2007 - 14:45:09 MET