Hello,
I'm trying to read values (energy) from a branch of a TTree into an array ( e[i] = (Double_t*)*b_energy->GetEntry(i); ) in the code below:
#include "TFile.h"
#include "TTree.h"
#include "TBrowser.h"
#include "TH2.h"
#include "TRandom.h"
#include "TCanvas.h"
void read_tree_minimal()
{
static Double_t energy;
Double_t e[1200];
TFile *f = new TFile("Ca2Mn46d.topaz.20080506.160756.root");
TTree *tr = (TTree*)f->Get("t");
TBranch *b_energy = tr->GetBranch("energy");
b_energy->SetAddress(&energy);
TH1F *henergy = new TH1F("henergy","energy in eV",10,-2143.62,-2143.54);
Int_t nentries = (Int_t)tr->GetEntries(); printf("There are %i entries\n",(int*)nentries); for (Int_t i=0;i<nentries;i++) {
b_energy->GetEntry(i); e[i] = (Double_t*)b_energy->GetEntry(i); henergy->Fill(energy);
printf("Energy # %i = %d\n",1,(float*)e[1]); henergy->Draw();
return;
}
Trying to de-reference the pointer b_energy in this way does not work:
root [3] .x read_tree_minimal.C
There are 1200 entries
Error: Illegal pointer operation (tovalue) read_tree_minimal.C:23:
(Double_t)8.00000000000000000e+00
Can someone please tell me how to do this?
Thanks,
Roger
Received on Fri Oct 03 2008 - 21:37:06 CEST
This archive was generated by hypermail 2.2.0 : Fri Oct 03 2008 - 23:50:02 CEST