Hello,
I’ve noticed that in PyROOT TChain may print an error on SetBranchAddress when TTree does not. In C++ in a similar case both give an error.
An example script:
import ROOT
c = ROOT.TChain("tefield")
c.Add("efield_3950562315-861740959_L0_0000.root")
f = ROOT.TFile("efield_3950562315-861740959_L0_0000.root")
tt = f.Get("tefield")
v = ROOT.vector("vector<vector<float>>")()
tt.SetBranchAddress("trace", v)
#c.SetBranchAddress("trace", v)
to run, please download efield_3950562315-861740959_L0_0000.root - Google Drive (20 MB). In the version above, I get no error and everything seems to work fine, while after uncommenting the last line I get:
Error in <TChain::SetBranchAddress>: The class requested (vector<vector<vector<float> > >) for the branch "trace" is an instance of an stl collection and does not have a compiled CollectionProxy. Please generate the dictionary for this collection (vector<vector<vector<float> > >) to avoid to write corrupted data.
A similar script in C++ gives the same error in both TChain and TTree cases:
{
auto c = TChain("tefield");
c.Add("efield_3950562315-861740959_L0_0000.root");
auto f = TFile("efield_3950562315-861740959_L0_0000.root");
auto tt = (TTree*)f.Get("tefield");
auto v = new vector<vector<vector<float>>>();
//tt->SetBranchAddress("trace", &v);
c.SetBranchAddress("trace", &v);
cout << c.GetEntries() << endl;
}
(although the last cout is needed for the TChain to give the error).
I have three questions here:
- Why/should PyROOT behave differently than C++ in this case?
- Why TChain gives an error, and TTree does not in PyROOT?
- Everything seems to work very well for me in PyROOT using TTrees and branches such as above, both in reading and writing, without the dictionary. So is the dictionary really needed?
ROOT Version: 6.30.06
Platform: Fedora 40
Compiler: Not Provided