Read in files in a dictionary

Hello !

I want to use the TFile command to read in root files. Since my project contains loads of files so to be more structured, i have created dictionaries. It is something in this way

Tfile *file1 = new TFile( "\banks\myfile.root " , “READ” )

So the file is under directionary banks and the file in questions is myfile.root. The C-file (where im coding) is in the same dictionary as the banks dictionary.

How do i put in dictionaries in the TFile command ?

kind regards
Hampus

I suppose you mean “directories” and not dictionaries, right? So you can simply specify the directories in the TFile::Open() method:

   auto file1 = TFile::Open("./banks/myfile.root", "READ");

or, if your C macro is in the same directory than the root file:

   auto file1 = TFile::Open("myfile.root", "READ");
1 Like

Yes of course! Sorry for the misspelling. Gonna try it out now :slight_smile: