Thank you Axel Schwank for your response which explained why I was getting
smaller number of events when reading h2root converted HBOOK ntuple.
I still don't know what is wrong with the following macro which
should create and fill a single histogram with one entry from
the ntuple.
{
// read HBOOK generated ntuple and print number of entries
gROOT->Reset();
gBenchmark->Start("test_root_ntuple");
//
// Connect CRIS ROOT ntuple file generated by h2root
// from make_cris_ntuple.rz file
TFile *f1 = new TFile("/data3/users/lijowski/make_cris_ntuple.root.0");
f1 -> ls();
// connect a tree to an ntuple in the input file
TTree *t9000 = (TTree*)f1 -> Get("h9000");
t9000 -> Print();
Int_t Noevents = t9000 -> GetEntries();
printf(" No of Events %d\n", Noevents);
// Define branch for the tree. "Dx2" is an entry/branch in the ntuple.
TBranch *dx2 = t9000 -> GetBranch("Dx2");
t9000 -> Draw("Dx2");
// create histogram for dx2
char hname[20];
char htitle[80];
Float_t xmin = -1.2, xmax = 1.2;
Int_t nbins = 120;
sprintf(hname, "H2X-plane-dx2");
sprintf(htitle,"H2 X plane dx2");
TH1F *h2x = new TH1F(hname, htitle, nbins, xmin, xmax);
for (Int_t ii = 0; ii < Noevents; ii++) {
dx2 -> GetEvent(ii);
h2x -> Fill(dx2);
}
gBenchmark->Show("test_root_ntuple");
}
I get a histogram of Dx2 from t9000 -> Draw("Dx2"); but I also get the
following error:
Error: Can't call TH1F::Fill() in current scope FILE:/export/home/lijowski/ace/cris/flight/root/./test_root_ntuple.C LINE:39
where line 39 is line with h2x -> Fill(dx2);
Thanks for any help.
Regards,
Michal Lijowski
------------------------------------------------------------------------
Michal Lijowski Washington University
Research Associate St. Louis, MO 63130-4899, USA
Department of Physics phone: 314-935-6285
Campus Box 1105 email: lijowski@cosray2.wustl.edu
------------------------------------------------------------------------