Dear ROOT community,
I have a Python code which works fine. It does analysis and fills histograms. I wish to add TTrees which would contain the same information filled in some of the histograms.
For example, defining the TTree and TH1D:
t_mu = TTree('MuTree', 'MuTree')
pt_leadmu = ROOT.std.vector(float)()
t_mu.Branch('pt_leadmu', pt_leadmu)
h_pt_leadmu = TH1D("h_pt_leadmu", "h_pt_leadmu; p_{T, #mu1} [GeV]; Arb. u.", nbins, xbins)
filling the TH1D and vector intended for the TTree (inside event loop):
h_pt_leadmu.Fill(Lead_mu.Pt()/1000, weight)
pt_leadmu.push_back(Lead_mu.Pt()/1000)
finally filling the TTree and writing everything up (outside of loop/s):
t_mu.Fill()
newfile = TFile(case+"_Zprime_mumu.root","RECREATE")
t_mu.Write()
h_pt_leadmu.Write()
newfile.Close()
I am facing two problems:
- At the end of the run I get an error message:
TBranchElement::TBranc... ERROR basket's WriteBuffer failed.
- The TH1D and TTree do not match, although they should be containing exactly the same information (never mind binning etc., they simply do not match).
What am I missing/doing wrong?
Should I have used TChain and if so, how?
Your help would be deeply appreciated, as always.
_ROOT Version: 6.16
_Platform: Linux (lxplus)
_Compiler: Python 2.7.15