ROOT Version: ROOT 6.14/06
Platform: Linux
Compiler: linuxx8664gcc
Dear experts,
I’m fairly new to this so if this should be posted in the newbie section then let me know.
I have root file that I would like to open, access some variables (px,py,pz, E) and then put them in a LorentzVector. Then I want to boost the vectors, and save them back to that root file. I potentially want to deconstruct each LorentzVector back into px,py,pz, and E variables and then save those variables to the TTree instead of the LorentzVector itself as I’m not sure how easy it is to access LorentzVector quantities.
So far my script doesn’t work and I get the error:
Error in TBranchElement::Fill: attempt to fill branch TVecLep while addresss is not set
Error in TBranchElement::Fill: attempt to fill branch TVecTauDaug while addresss is not set
My questions are:
- How do I properly save the branches I want
- Is it simple to access LorentzVectors in branches? Or should I deconstruct the LorentzVector back to the individual variables again?
- How do you deconstruct the LorentzVector back into variables?
Here is my code:
import ROOT
from ROOT import Math, TLorentzVector, TFilemyfile = TFile(‘v12_Bktl_mc11_eplus.root’, ‘update’)
mytree = myfile.variablesVecLep = Math.LorentzVector(‘ROOT::Math::PxPyPzE4D’)(mytree.Lep_CMS_px, mytree.Lep_CMS_py, mytree.Lep_CMS_pz, mytree.Lep_CMS_E)
VecTau = Math.LorentzVector(‘ROOT::Math::PxPyPzE4D’)(mytree.Tau_CMS_px, mytree.Tau_CMS_py, mytree.Tau_CMS_pz, mytree.Tau_CMS_E)
VecTauDaug = Math.LorentzVector(‘ROOT::Math::PxPyPzE4D’)(mytree.Tau_CMS_px, mytree.Tau_CMS_py, mytree.Tau_CMS_pz, mytree.Tau_CMS_E)
cmTau = VecTau.BoostToCM()
TVecLep = ROOT.Math.VectorUtil.boost(VecLep, cmTau)
TVecTauDaug = ROOT.Math.VectorUtil.boost(VecTauDaug, cmTau)mytree.Branch(‘TVecLep’, TVecLep)
mytree.Branch(‘TVecTauDaug’, TVecTauDaug)mytree.Fill()
myfile.Write()
myfile.Close()
Thank you in advance