Hello all,
This is my first time posting so apologies if I have placed this in the wrong section.
Setup: I am running PYTHIA stand-alone (HEp event generator). To drive the PYTHIA software, I have a c++ executable. Inside the c++ executable, I try to load root, generate a root ntuple with the data from PYTHIA, and then save the root ntuple.
The problem: The output root file exists. It has the correct naming conventions. But it has no trees and no data.
(eg)
root [0]
Attaching file test.root as _file0…
root [1] _file0->ls()
TFile** test.root
TFile* test.root
KEY: TTree Default;1
root [2] Default->Print()
OBJ: TStyle Default Default Style
//Completely empty, if you open in TBrowser there are no trees displayed.
The code: Since this exists inside a larger c++ executable, I’m not sure that you would want to see all the code. I have extracted all the relevant root commands below:
Two quick notes - The output statements shows that I am pushing back numbers into the vector that make sense. And, the TTree-Print() command that I issue near the end of .exe also shows an empty tree…strange?
Thanks very much,
Daniel
string nametemp = “test.root”;
TFile* file = TFile::Open(nametemp.c_str(),“RECREATE”);
file->cd();
TTree* TreeD = new TTree(“Default”,“”);
//Branch
vector* _mc_px;
_mc_px = new vector();
TreeD->Branch(“mc_px”,&_mc_px);
//these lines (below) inside event loop
_mc_px->push_back(px);
cout << endl << "TESTING push back "<< px << endl;
TreeD->Fill();
_mc_px->clear();
//lines (above) inside event loop
file->cd();
TreeD->Print();
//The tree is empty at this print!
TreeD->Write();
file->Close();