nEntries = ch.GetEntries() print "nEntries = ", nEntries #*****set brances***** #set branche satus, at first, all off #event information #new tree outFile = "qcd.slim.root" newFile = root.TFile(outFile,"RECREATE") ch_new = ch.CloneTree(0) root.gROOT.ProcessLine("struct MyStruct{float disc;};") from ROOT import MyStruct # Create branches in the tree s = MyStruct() bpt = ch_new.Branch('disc',root.AddressOf(s,'disc'),'disc/F'); for i in range(nEntries): ch.GetEntry(i) if i%10000==0: print "Processing event nr. %i of %i" % (i,nEntries) s.disc = 666 ch_new.Fill() ch_new.Print() # use GetCurrentFile just in case we went over the # (customizable) maximum file size ch_new.GetCurrentFile().Write() ch_new.GetCurrentFile().Close()
tmpXList = [] ############################## #Only For enhanced_v8p2 ############################## tmpXList.append(inputTree.hh_pt) tmpXList.append(inputTree.hh_eta) tmpXList.append(inputTree.hh_mass) tmpXList.append(inputTree.MET) tmpXList.append(inputTree.fatJet1Tau3OverTau2) tmpXList.append(inputTree.fatJet2Tau3OverTau2) tmpXList.append(inputTree.fatJet1MassSD) tmpXList.append(inputTree.fatJet1Pt), tmpXList.append(inputTree.fatJet1Eta), tmpXList.append(inputTree.fatJet1PNetXbb) tmpXList.append(inputTree.fatJet1PNetQCDb) tmpXList.append(inputTree.fatJet1PNetQCDbb) tmpXList.append(inputTree.fatJet1PNetQCDothers) tmpXList.append(inputTree.fatJet2Pt) tmpXList.append(inputTree.fatJet1PtOverMHH) tmpXList.append(inputTree.fatJet2PtOverMHH) tmpXList.append(inputTree.ptj2_over_ptj1) tmpXNPArray = np.array([tmpXList]) tmpY = model.predict_proba(tmpXNPArray)[:, 1] my_s.disc = tmpY outputTree.Fill() outputFile.Write() outputFile.Close()
tmpXList.append(inputTree.fatJet2Tau3OverTau2) tmpXList.append(inputTree.fatJet1MassSD) tmpXList.append(inputTree.fatJet1Pt), tmpXList.append(inputTree.fatJet1Eta), tmpXList.append(inputTree.fatJet1PNetXbb) tmpXList.append(inputTree.fatJet1PNetQCDb) tmpXList.append(inputTree.fatJet1PNetQCDbb) tmpXList.append(inputTree.fatJet1PNetQCDothers) tmpXList.append(inputTree.fatJet2Pt) tmpXList.append(inputTree.fatJet1PtOverMHH) tmpXList.append(inputTree.fatJet2PtOverMHH) tmpXList.append(inputTree.ptj2_over_ptj1) tmpXNPArray = np.array([tmpXList]) tmpY = model.predict_proba(tmpXNPArray)[:, 1] my_s.disc = tmpY ################ JES Up ################### tmpXList[0] = inputTree.hh_pt_JESUp tmpXList[1] = inputTree.hh_eta_JESUp tmpXList[2] = inputTree.hh_mass_JESUp tmpXList[7] = inputTree.fatJet1Pt_JES_Up tmpXList[13] = inputTree.fatJet2Pt_JES_Up #tmpXList[7] = inputTree.fatJet1Pt_JESUp #for new ntuples #tmpXList[13] = inputTree.fatJet2Pt_JESUp #for new ntuples tmpXList[14] = inputTree.fatJet1PtOverMHH_JESUp tmpXList[15] = inputTree.fatJet2PtOverMHH_JESUp tmpXNPArray = np.array([tmpXList]) tmpY = model.predict_proba(tmpXNPArray)[:, 1] my_s_JESUp.disc = tmpY