Hello,
I am creating a ROOT file and writing a string (using ObjectString
).
std::string out_rt, objstring; out_rt="outFile.root" TFile * ofile = TFile::Open(out_rt.c_str(),"update"); objstring = "\nSometext:\n"; TObjString a( objstring.c_str()); ofile->WriteObject( &a, "info" ); ofile->Close();
While I have no issues in writing the ROOT file, I am unable to retrieve the string data using:
std::string inp_fl1="outFile.root" TFile *f =new TFile(inp_fl1.c_str()); std::string somestring; TObjString* tmp = (TObjString*)f->Clone("info"); somestring = (const TString)tmp->GetString(); cout << somestring << endl;
This just outputs “info” (and not the string data that is stored in the info Object. Can anyone help please? Also in the next step, how can I just copy the entire info Object to a new ROOT file?
Thanks!