I am working with many root files online (files in http), and I am wondering if I can use TWebFile to open each of them and then add them to a TChain? Somebody asked the same question long time ago but there’s still no clear answer to this question:
I want to do something like this:
# These files contain trees with the same tree name
f1 = TWebFile("http://....../file1.root")
f2 = TWebFile("http://....../file2.root")
f3 = TWebFile("http://....../file3.root")
chain = ROOT.TChain("combined")
chain.AddFile(f1)
chain.AddFile(f2)
chain.AddFile(f3)
waveforms = ROOT.mattak.Waveforms()
chain.SetBranchAddress("waveforms", ROOT.AddressOf(waveforms))
nTotalEvents = chain.GetEntries()
for i_event in range(nTotalEvents):
chain.GetEntry(i_event)
.
.
.
Is it possible to do it this way or something like this, or is there a better way?
Thank you!
ROOT Version: Not Provided Platform: Not Provided Compiler: Not Provided
Thanks for your reply. But doing it in this way chain.AddFile("http://....../combined.root")
I got an error when I was trying to get the tree out of the file:
Error in <DavixOpen>: can not open file "https://....../combined.root" with davix: Result HTTP 401 : Authentication Error after 3 attempts (14)
Somebody told me that if I wanted to fix this issue for just using a TFile I could do:
ROOT.gPluginMgr.LoadHandlersFromPluginDirs()
ROOT.gPluginMgr.AddHandler("TFile", "^http[s]?:", "TWebFile", "Net", "TWebFile(const char*,Option_t*)")
f = TFile.Open("http://....../combined.root")
t = f.Get("combined")
t.SetBranchAddress("waveforms", ROOT.AddressOf(waveforms))
This works for me to deal with just one TFile at a time, but I really want to use TChain to deal with several files, could you please tell me if there’s a way to do it if I were to use TChain in this case?
I am sorry I am not allowed to share the link because there’s a password in there and that belongs to the research group. I will try to find the solution, if not I will just use TFile to work with each file individually, and then use hadd command to combine the output files…