TFile creating un-loadable .root files

ROOT Version: 6.20/06
Platform: Linux Server (ROOT through views LCG_97a:x86_64-centos7-gcc8-opt)
Compiler: Not Provided


I’ve been running into an issue with writing objects to a new root file. For context, I have a Delphes .root file that I’m applying a macro to, and at the end of the macro I’ve included this block,

TFile*out = new TFile("WHSigBkg.root", "RECREATE");
hmjj -> Write();
hMET -> Write();
hMT -> Write();
out -> Write();
out -> Close();

where all pointers that aren’t “out” are referring to TH1F histograms. Upon loading this macro and executing its function, the new .root file is not immediately loaded, although it is created. If I try and load it manually, I get a long list of errors and warnings including

/users/alecp1/ROOTspace/WH/WHSigBkg.root:1:5: warning: null character ignored [-Wnull-character]
/users/alecp1/ROOTspace/WH/WHSigBkg.root:1:7: error: source file is not valid UTF-8


/users/alecp1/ROOTspace/WH/WHSigBkg.root:1:8: error: expected unqualified-id

triggering a fatal error (too many errors emitted). Interestingly enough, even a simple macro

void test()
TFile out("test.root", "RECREATE");

yields the same result.

I’m very new to using the ROOT framework and about as new to C++, so I entirely expect the issue to be on my end, but I’m not sure what the issue could be. Any thoughts?

I do not get any error with this simple macro:

% root test.C
  | Welcome to ROOT 6.27/01               |
  | (c) 1995-2022, The ROOT Team; conception: R. Brun, F. Rademakers |
  | Built for macosx64 on Jul 25 2022, 08:02:01                      |
  | From heads/master@v6-25-02-1873-g56c28ff3b8                      |
  | With Apple clang version 12.0.5 (clang-1205.0.22.9)              |
  | Try '.help'/'.?', '.demo', '.license', '.credits', '.quit'/'.q'  |

root [0] 
Processing test.C...
root [1] .q

Could you copy here the root command line that you are using to run this macro (and any other root invocation that you are using)?