Dear ROOTers,
I was trying to read entry from root file.
- I can see the histogram when doing
T->Draw("photon_y_at_gc_mirror_reflected")
- Then I try to read event by event [color=#FF0000](This one gives me error.)[/color]
void read() {
TChain* T=new TChain("T","T");
T->Add("BGC_9999.root");
Int_t i,j,k,l;
//T->Print();
//Double_t x[411][4];
Double_t** x= new Double_t*[411];
for ( i = 0; i < 411; ++i ) {
x[i]=new Double_t[4];
}
T->SetBranchAddress("photon_y_at_gc_mirror_reflected",x);
//for ( k = 0; k < T->GetEntries(); ++k ) {
for ( k = 0; k < 1; ++k ) {
printf("----Event %d----\n",k+1);
T->GetEntry(k);
for ( i = 0; i < 411; ++i ) {
for ( j = 0; j < 4; ++j ) {
if ( x[i][j]>-1e8 ) {
printf("Line %d:x[%d][%d]=%g\n",__LINE__,i,j,x[i][j]);
}
}
}
}
}
- So I print out the tree
*Br 66 :photon_y_at_gc_mirror_reflected : *
* | Photon_Double_Info[Total_Num_Of_Cher_Photons][4]/D *
*Entries : 2 : Total Size= 27235 bytes File Size = 3829 *
*Baskets : 1 : Basket Size= 32000 bytes Compression= 6.92 *
- I also try to use (this works)
Double_t x[411][4];
But you can see the array has variable size.
I’m just asking how to read it correctly?
Thanks a lot.