RE: TTree::Write() Problem

From: Muhammad Asghar <Muhammad.Asghar_at_cern.ch>
Date: Wed, 25 Oct 2006 15:33:32 +0200


Hi Ding

plz check the line

if((store_pp=new Double_t[ArraySize]) == NULL) {

You have define store_pp as pointer and on right side you are allocating new memory.

regards

irfan

-----Original Message-----
From: owner-roottalk_at_pcroot.cern.ch on behalf of Hengtong Ding Sent: Wed 10/25/2006 3:17 PM
To: ROOT Talk
Subject: [ROOT] TTree::Write() Problem  

Hi all,

I first compiled my code by .L code.C++ and then load "code_C.so" to run some functions. The compilation is quit OK, but when I run some events, erros happened ,

But finally I can get the output "test.root" in which histograms are included and are OK but no trees.

My code is listed as below :

  TFile *outfile = new TFile("test.root","recreate");   const Int_t ArraySize = 13 ;
  Double_t *store_pp=0;
  if((store_pp=new Double_t[ArraySize]) == NULL) {

      cout << "can't allocate more memory for store_pp,terminating.\n" ;
      exit(0) ;

  }
TTree *tree = new TTree("tree","variables in pp AA and AAquenched") ;   

tree->Branch("bpp",store_pp,"ptQ/D:ptM:ptmu:pzQ:pzM:pzMu:etaQ:etaM:etamu:yQ:yM:ymu:weightpp");
/*

some histograms are defined here !
*/

/*

One loop in which
the values are assigned to store_pp[0], store_pp[1] ... store_pp[12] and "tree -> Fill()" is done. Also the histograms are filled here. */
// some histograms Write() ;

tree -> Write() ;
outfile->Close();



My root version is v5-12-00, OS is Linux 2.4.20-8smp #1 SMP Redhat 9.

I don't know why this happened, as when I write a testcode in which only Tree are defined(no histograms) in the way above, it runs OK. Also if I don't use the TTree in the above code, the codes also run OK. Maybe I ask too many memoris by "new TH1D()" when defining the histograms and after that you could not use a "new TTree() " ?

Any suggestion will be appreciate.
Thanks in advance.

Hengtong

-- 
 ************************************************
 *             Hengtong Ding                    *                    
 *                                              *
 *  Address:  Institute of Particle Physics,    *
 *            Central China Normal University   * 
 *            Wuhan, 430079,  P. R. China       *
 *  Tel:      0086 27 6786 7946 (lab)           *
 *            0086 27 8715 0351 (dormitory)     *
 *  Fax:      0086 27 6786 3213                 *
 *  Email:    dinght_at_iopp.ccnu.edu.cn           *
 *	      dinghengtong_at_hotmail.com          *
 ************************************************
Received on Wed Oct 25 2006 - 15:36:19 MEST

This archive was generated by hypermail 2.2.0 : Mon Jan 01 2007 - 16:32:01 MET