TFile::Open not working

I’m trying to use TFile::Open to create a file, but it just tries to open a nonexistent file.
Within a larger macro, I have:

  TString filename = "Data/SiPM_"+num+"_"+name_pde+"_"+nSeed+"_"+tpb+"_"+evt_type+".root";
  TFile *fout = TFile::Open(filename,"recreate");

And I get the error:

SysError in <TFile::TFile>: file Data/SiPM_1000_0p125_S31416_TPBoff_NR.root can not be opened (No such file or directory)

How do you get it to create a new file?

_ROOT Version: 6.10/04
_Platform: Ubuntu 18.04 on Windows
_Compiler: ?

It seems that the “Data” subdirectory does not exist. You MUST create it (it can even be done from inside of ROOT like “gSystem->mkdir("Data", kTRUE);”) and then ROOT will be able to (re)create any files inside of it.

Thank you, that worked!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.