Hi everyone, I made a simple TTree in this program that reads a .dat file:
#include "Riostream.h"
#include "TTimer.h"
#include "TROOT.h"
#include "TStyle.h"
#include "TFile.h"
#include "TH1F.h"
#include "TH2F.h"
#include "TNtuple.h"
#include "TTree.h"
#include "TCanvas.h"
#include "TPad.h"
#include "TF1.h"
#include "TProfile.h"
#include "TLegend.h"
//--------------------Creation of a ttree with the data from the acquisition file
void make_TTree(){
gROOT->Reset();
ifstream file;
struct staff_t {
Int_t idgame;
Int_t setnumber;
Int_t actnumber;
Int_t touchnumber;
Int_t idplayer;
Int_t idscout;
TString team;
TString found;
TString balltype;
TString effect;
TString comb;
Int_t azone;
Int_t bzone;
TString sunzone;
TString ext1;
Int_t ext2;
Int_t ext3;
TString custom;
TString changeball;
TString attackRD;
Int_t homesetter;
Int_t visitorsetter;
};
staff_t staff;
file.open("19mus.dat");
Int_t nlines = 0;
cout<<"----------------------------------------------"<<endl;
cout<<"ho aperto il file"<<endl;
cout<<"----------------------------------------------"<<endl;
TFile *f = new TFile("summ.root","RECREATE");
TTree *tree = new TTree("tree","data");
TBranch* b_staff = tree->Branch("staff", &staff, "idgame:setnumber:actnumber:touchnumber:idplayer:idscout:team:found:balltype:effect:comb:azone:bzone:sunzone:ext1:ext2:ext3:custom:changeball:attackRD:homesetter:visitorsetter");
cout<<"ho creato il tfile, il ttree e la branch"<<endl;
cout<<"----------------------------------------------"<<endl;
while (1) {
//while (fgets(&line,80,fp)){
file>>staff.idgame>>staff.setnumber>>staff.actnumber>>staff.touchnumber>>staff.idplayer>>staff.idscout>>staff.team>>staff.found>>staff.balltype>>staff.effect>>staff.comb>>staff.azone>>staff.bzone>>staff.sunzone>>staff.ext1>>staff.ext2>>staff.ext3>>staff.custom>>staff.changeball>>staff.attackRD>>staff.homesetter>>staff.visitorsetter;
if (!file.good()) break;
tree->Fill();
nlines++;
}
tree->Print();
cout << " found " << nlines << " events " << endl;
file.close();
f->Write();
}
Even if the file is not empty, the output is
**************************************************************************
*Tree :tree : data *
*Entries : 0 : Total = 2684 bytes File Size = 0 *
* : : Tree compression factor = 1.00 *
**************************************************************************
*Br 0 :staff : idgame:setnumber:actnumber:touchnumber:idplayer: *
* | idscout:team:found:balltype:effect:comb:azone:bzone:sunzone:ext1:*
* | ext2:ext3:custom:changeball:attackRD:homesetter:visitorsetter *
*Entries : 0 : Total Size= 2292 bytes One basket in memory *
*Baskets : 0 : Basket Size= 32000 bytes Compression= 1.00 *
*............................................................................*
found 0 events
I cannot figure where is the issue. Any help?
Thanks!
_ROOT Version: 16
_Platform: Ubuntu 18.04