908 def main(infile, weightsFile, treename, attr_mcID, attr_nTruthJets):
909 print "Creating MCID, ZpT mapping"
913 print "Loading histograms with weights"
918 g = ROOT.TFile(weightsFile)
919 systList = [
"ckkw15",
"ckkw30",
"fac025",
"fac4",
"renorm025",
"renorm4",
"qsf025",
"qsf4"]
921 for syst
in systList:
922 h = ROOT.TH2F(g.Get(
"Zee"+syst))
923 ZeeHistograms.append(h)
924 h = ROOT.TH2F(g.Get(
"Znunu"+syst))
925 ZnunuHistograms.append(h)
926 h = ROOT.TH2F(g.Get(
"Wenu"+syst))
927 WenuHistograms.append(h)
930 f = ROOT.TFile(infile,
"update")
935 ckkw15 =
array(
'f', [0.])
936 ckkw30 =
array(
'f', [0.])
937 fac025 =
array(
'f', [0.])
938 fac4 =
array(
'f', [0.])
939 renorm025 =
array(
'f', [0.])
940 renorm4 =
array(
'f', [0.])
941 qsf025 =
array(
'f', [0.])
942 qsf4 =
array(
'f', [0.])
946 ckkw15branch = T.Branch(
"ckkw15_Weight", ckkw15,
"ckkw15_Weight/F")
947 ckkw30branch = T.Branch(
"ckkw30_Weight", ckkw30,
"ckkw30_Weight/F")
948 fac025branch = T.Branch(
"fac025_Weight", fac025,
"fac025_Weight/F")
949 fac4branch = T.Branch(
"fac4_Weight", fac4,
"fac4_Weight/F")
950 renorm025branch = T.Branch(
"renorm025_Weight", renorm025,
"renorm025_Weight/F")
951 renorm4branch = T.Branch(
"renorm4_Weight", renorm4,
"renorm4_Weight/F")
952 qsf025branch = T.Branch(
"qsf025_Weight", qsf025,
"qsf025_Weight/F")
953 qsf4branch = T.Branch(
"qsf4_Weight", qsf4,
"qsf4_Weight/F")
955 print "Adding Weights"
956 nEvts = T.GetEntries()
958 for iEvt
in range(nEvts):
961 print '\x1b[2K\r',
"Current Event being Processed is: {0:15d}".
format(iEvt),
966 MCID = getattr(T, attr_mcID)
967 nTruthJets = getattr(T, attr_nTruthJets)
973 (361372 <= MCID <= 361443)
or
974 (363102 <= MCID <= 363122)
or
975 (363361 <= MCID <= 363363)
or
976 (363364 <= MCID <= 363411)
or
977 (364114 <= MCID <= 364127)
or
978 (364100 <= MCID <= 364113)
or
979 (364128 <= MCID <= 364141)
or
980 (364216 <= MCID <= 364217)
or
981 (364220 <= MCID <= 364221)
983 decayType =
"dilepton"
986 (361444 <= MCID <= 361467)
or
987 (363412 <= MCID <= 363435)
or
988 (364142 <= MCID <= 364155)
or
989 (366010 <= MCID <= 366035)
or
990 (364222 <= MCID <= 364223)
992 decayType =
"nolepton"
995 (361300 <= MCID <= 361371)
or
996 (363331 <= MCID <= 363354)
or
997 (363436 <= MCID <= 363459)
or
998 (363460 <= MCID <= 363483)
or
999 (364156 <= MCID <= 364169)
or
1000 (364170 <= MCID <= 364183)
or
1001 (364184 <= MCID <= 364197)
or
1002 (364226 <= MCID <= 364227)
or
1003 (364224 <= MCID <= 364225)
or
1004 (364228 <= MCID <= 364229)
1006 decayType =
"onelepton"
1012 ZpTBin = ZpTMapping.get(MCID)
1013 TruthJetBin = nTruthJets+1
1014 if nTruthJets >= 11:
1028 if decayType ==
"dilepton":
1029 ckkw15[0] = ZeeHistograms[0].GetBinContent(ZpTBin,TruthJetBin)
1030 ckkw30[0] = ZeeHistograms[1].GetBinContent(ZpTBin,TruthJetBin)
1031 fac025[0] = ZeeHistograms[2].GetBinContent(ZpTBin,TruthJetBin)
1032 fac4[0] = ZeeHistograms[3].GetBinContent(ZpTBin,TruthJetBin)
1033 renorm025[0] = ZeeHistograms[4].GetBinContent(ZpTBin,TruthJetBin)
1034 renorm4[0] = ZeeHistograms[5].GetBinContent(ZpTBin,TruthJetBin)
1035 qsf025[0] = ZeeHistograms[6].GetBinContent(ZpTBin,TruthJetBin)
1036 qsf4[0] = ZeeHistograms[7].GetBinContent(ZpTBin,TruthJetBin)
1037 elif decayType ==
"nolepton":
1038 ckkw15[0] = ZnunuHistograms[0].GetBinContent(ZpTBin,TruthJetBin)
1039 ckkw30[0] = ZnunuHistograms[1].GetBinContent(ZpTBin,TruthJetBin)
1040 fac025[0] = ZnunuHistograms[2].GetBinContent(ZpTBin,TruthJetBin)
1041 fac4[0] = ZnunuHistograms[3].GetBinContent(ZpTBin,TruthJetBin)
1042 renorm025[0] = ZnunuHistograms[4].GetBinContent(ZpTBin,TruthJetBin)
1043 renorm4[0] = ZnunuHistograms[5].GetBinContent(ZpTBin,TruthJetBin)
1044 qsf025[0] = ZnunuHistograms[6].GetBinContent(ZpTBin,TruthJetBin)
1045 qsf4[0] = ZnunuHistograms[7].GetBinContent(ZpTBin,TruthJetBin)
1046 elif decayType ==
"onelepton":
1047 ckkw15[0] = WenuHistograms[0].GetBinContent(ZpTBin,TruthJetBin)
1048 ckkw30[0] = WenuHistograms[1].GetBinContent(ZpTBin,TruthJetBin)
1049 fac025[0] = WenuHistograms[2].GetBinContent(ZpTBin,TruthJetBin)
1050 fac4[0] = WenuHistograms[3].GetBinContent(ZpTBin,TruthJetBin)
1051 renorm025[0] = WenuHistograms[4].GetBinContent(ZpTBin,TruthJetBin)
1052 renorm4[0] = WenuHistograms[5].GetBinContent(ZpTBin,TruthJetBin)
1053 qsf025[0] = WenuHistograms[6].GetBinContent(ZpTBin,TruthJetBin)
1054 qsf4[0] = WenuHistograms[7].GetBinContent(ZpTBin,TruthJetBin)
1056 print '\x1b[2K\r',
"Missing entry for MCID={0}, nTruthJets={1}".
format(MCID, nTruthJets)
1063 renorm025branch.Fill()
1064 renorm4branch.Fill()
1068 print '\x1b[2K\r',
"All entries processed"
1071 print "Done with {0:s}/{1:s}.".
format(infile, treename)