Trouble with TFile

Hello Experts,

I have multiple .ROOT files that I want to open and plot. Since I have many files, I am trying to write a separate function that I can call every time I need, instead of repeating the same process over and over again. Here is a macro that I have. If I copy-paste the following part in the main program, it works fine, ‘’’

TFile* inp = TFile::Open("/root_v6.18.04/macros/HandOff/AlThin/Next steps/27Al(d,n)/DataSets/Disk118.ROOT");


hdetTOF118 = (TH1F*)inp->Get(“Disk118”);



But in a function, it somehow crashes and displays StackTrace something and exits root. Can anybody please help with what is it that I am doing wrong? I am sure it must be a simple fix with a minute detail that I am missing.

edit- Here is the macro I have written and one of the files that I need to plot. (3.0 KB)
Disk118.ROOT (7.0 KB)

Please help! Thank you for your time!

ROOT Version: 6.18/04
Platform: C++
Compiler: Visual Studio Code

TFile *inp = TFile::Open(path_to_file.c_str());

const char *Disk118 = "Disk118";

Thank you @Wile_E_Coyote. Worked like a charm!