2D histogram projection from a TTree

From: Alberto Baldisseri (baldiss@hep.saclay.cea.fr)
Date: Tue Jun 30 1998 - 10:48:26 MEST


Hi rooters,

I have problems to do a 2D histogram projection from a tree in batch. I
compile an execute
the following code :

//
// Test TTree projections
// from an n/tuple to an 2D histogram
//
#include <stdio.h>
#include <iostream.h>
#include <stdlib.h>
#include "TROOT.h"
#include "TFile.h"
#include "TH1.h"
#include "TH2.h"
#include "TF1.h"
#include "TTree.h"
#include "TProfile.h"
int main()
{
  TROOT test("test","Test of 2D project");
  TFile *ntufp = new TFile("gene_ntu.root"); // Open n/tuple file
  TTree *tgassi = (TTree *) test.FindObject("tgassi");
  tgassi->Print();
  tgassi->Draw("ch[1]:ch[0]>>hmy");
  //tgassi->Draw("ch[1]:ch[0]>>hmy","","goff");
  ntufp->ls();
  TH2F *hmy = (TH2F *) test.FindObject("hmy");
  printf("\nhmy = %x\n",hmy);
  hmy->Print();
}

I got a segmentation fault because the hmy pointer is NULL, thats mean
the TH2F histogram
hmy is not created. This code work with the 1D histogram. By the way,
the 2D projections works
well in a root macro interactively. I do something wrong ?
I am using root version 2.00/08 for Linux Redhat5.0 and egcs2.90.27.

Thanks in advance,

Alberto

--
+-------------------------------+------------------------------------+
| Alberto BALDISSERI            | Tel : (33-1) 69 08 93 33           |
| DAPNIA/SPhN, Bat 703 piece 42 | Fax : (33-1) 69 08 75 84           |
| CEA Saclay                    | E-mail : baldiss@hep.saclay.cea.fr |
| F 91191 Gif-sur-Yvette cedex  |                                    |
+-------------------------------+------------------------------------+



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:34:34 MET