Hi,
I’ve tried a basic TTree example and in prinziple this is working with CINT. But now I have to include this into a C++ application.
When I run the executable, the tree stays empty.
The code is attached:
#include "TFile.h"
#include "TTree.h"
typedef struct {Float_t x,y,z;} POINT;
int main(){
TFile* hfile = new TFile("test.root","RECREATE");
TTree *tree = new TTree("tree","MicroMegaS-Simulation");
POINT initial;
POINT final;
Int_t status;
TBranch* b_initial = tree->Branch("initial",&initial,"x/F:y/F:z/F");
TBranch* b_final = tree->Branch("final",&final,"x/F:y/F:z/F");
TBranch* b_status = tree->Branch("status", &status, "status/I");
for(int i=0; i<10; i++){
status = i;
initial.x = i;
initial.y = i*i;
initial.z = i*i;
final.x = i;
final.y = i;
final.z = i;
tree -> Fill();
}
tree -> Print();
hfile -> Write();
return 0;
}
and this produces the following output.
******************************************************************************
*Tree :tree : MicroMegaS-Simulation *
*Entries : 0 : Total = 827 bytes File Size = 0 *
* : : Tree compression factor = 1.00 *
******************************************************************************
*Br 0 :TRefTable : List of branch numbers with referenced objects *
*Entries : 0 : Total Size= 436 bytes One basket in memory *
*Baskets : 0 : Basket Size= 32000 bytes Compression= 1.00 *
*............................................................................*
From the CINT-macro I would expect three branches with each 10 entries. But somehow I get only one branch with no entries. I have no idea what I’m doing wrong.
Cheers,
Jochen