Trouble with trees

From: Mario Kadastik <mario.kadastik_at_cern.ch>
Date: Wed, 8 Jul 2009 10:00:52 +0300


Hello,

I'm confused with my TTree right now. Inside the CMS software I write the tree like this:

	  struct cutvars_t {
		Int_t s;
		Double_t mRel;
		Double_t sumpt;
		Double_t pt1;
		Double_t pt2;
		Double_t pt3;
		Double_t pt4;
		Double_t dRp;
		Double_t dRn;
		Double_t met;
		Int_t nTau;
	  };
	  cutvars_t cutvars;

    treeFile = new TFile(treeFileName.c_str(),"RECREATE");     tree = new TTree("Tree","Tree of cut variables for later optimization");

    tree->Branch("cutvars",&cutvars.s,"s/I:mRel/ D:sumpt:pt1:pt2:pt3:pt4:dRp:dRn:met:nTau/I");

In the event loop I fill the cutvars and fill the tree.

When I then look at it in root afterwards:

root [0] TTree *t = (TTree*)_file0->Get("Tree") root [1] t->Show(10)
======> EVENT:10

  s               = 1
  mRel            = 0.954773
  sumpt           = 447.262
  pt1             = 44.2483
  pt2             = 88.4943
  pt3             = 126.326
  pt4             = 201.498
  dRp             = 0.967189
  dRn             = 1.10596
  met             = 22.8287
  nTau            = 1


Then it looks just fine. However when I try to read the tree with the following script:
{

	  struct cutvars_t {
		Int_t s;
		Double_t mRel;
		Double_t sumpt;
		Double_t pt1;
		Double_t pt2;
		Double_t pt3;
		Double_t pt4;
		Double_t dRp;
		Double_t dRn;
		Double_t met;
		Int_t nTau;
	  };
	  cutvars_t cutvars;

	TTree *t = (TTree*)_file0->Get("Tree");
	t->SetBranchAddress("cutvars",&cutvars.s);
	
	for (Int_t i = 10; i < 11; i++) {
		t->GetEntry(i);
		cout << "s:" << cutvars.s << " mRel: " << cutvars.mRel << " pt1: "  
<< cutvars.pt1 << endl;
	}

}

then the output is:
Processing printTree.C...
s:1 mRel: -1.49167e-154 pt1: 2.68156e+154

As you can see the double variables are over/underflown and don't make sense. I've been trying to figure out what I'm doing wrong, but don't seem to be able to.... The Branch itself is of structure:

root [10] t->GetBranch("cutvars")->Print() *Br 0 :cutvars : s/I:mRel/
D:sumpt:pt1:pt2:pt3:pt4:dRp:dRn:met:nTau/I * *Entries : 1402 : Total Size= 145921 bytes File Size = 27545 *

*Baskets :        3 : Basket Size=      32000 bytes  Compression=    
3.48     *
*............................................................................*

root [11] t->GetListOfLeaves()->Print()
OBJ: TLeafI	s	s
OBJ: TLeafD	mRel	mRel
OBJ: TLeafD	sumpt	sumpt
OBJ: TLeafD	pt1	pt1
OBJ: TLeafD	pt2	pt2
OBJ: TLeafD	pt3	pt3
OBJ: TLeafD	pt4	pt4
OBJ: TLeafD	dRp	dRp
OBJ: TLeafD	dRn	dRn
OBJ: TLeafD	met	met
OBJ: TLeafI	nTau	nTau

Thanks in advance,

Mario

PS! the root used is:
/opt/software/cms/slc4_ia32_gcc345/lcg/root/5.18.00a-cms21/bin/root

and this should be the one used for both the reading and writing of the root file so I'd guess no version change related issues either... Received on Wed Jul 08 2009 - 09:00:59 CEST

This archive was generated by hypermail 2.2.0 : Wed Jul 08 2009 - 11:50:03 CEST