Example #1
0
def readTree(t, name):
  fname = 'result_'+nameid+'.root'
  print fname
  f = TFile( fname, 'recreate' )
  tN = TTree( 't1', 'tree with histos' )

  gROOT.ProcessLine(
  "struct MyStruct {\
   Int_t      ttbb_;\
   Double_t    DRbb_;\
   Double_t    weight_;\
   };" );
  from ROOT import MyStruct

  s = MyStruct()
  tN.Branch('ttbb',AddressOf(s,'ttbb_'),'ttbb_/I')
  tN.Branch('DRbb',AddressOf(s,'DRbb_'),'DRbb_/D')
  tN.Branch('weight',AddressOf(s,'weight_'),'weight_/D')

  l = TLorentzVector() 
  l2 = TLorentzVector() 
  l3 = TLorentzVector()

  # Event loop
  nev = t.GetEntries()
  for n in t:
    particles = n.Particle
#    weights = n.Rwgt
    event = n.Event

    output = isTTBB(particles)
    s.ttbb_=output[0]
    s.DRbb_=output[1]
    s.weight_= cxlist[fid]/nev
    tN.Fill()

  f.Write()
  f.Close()