def SavePlots(syst, var = 'mt2', sampName = 'tt'): hm = HistoManager(process, syst, path=path) hm.ReadHistosFromFile(var) hm.GetDataHisto() a = HistoUnc(outpath, var+sampName+s, tag=sysdic[s], xtit = titdic[var] if var in titdic.keys() else '') a.SetLumi(GetLumi(year)) a.AddHistoNom(hm.GetHisto(sampName, sampName)) a.AddHistoUp(hm.GetHisto(sampName, sampName, s+'Up')) a.AddHistoDown(hm.GetHisto(sampName, sampName, s+'Down')) a.Draw()
def GetTableOfUnc(syst, sampName='tt', var='dnn', dic = {}): if isinstance(sampName, str) and ',' in sampName: sampName = sampName.replace(' ', '').split(',') if isinstance(syst, str) and ',' in syst : syst = syst .replace(' ', '').split(',') if isinstance(sampName, list): for s in sampName: GetTableOfUnc(syst, s, var, dic) return if isinstance(syst, list): for s in syst: GetTableOfUnc(s, sampName, var, dic) return if not sampName in dic: dic[sampName] = {} if not syst in dic[sampName]: dic[sampName][syst] = {} hm = HistoManager(process, syst, path=path) hm.ReadHistosFromFile(var) hm.GetDataHisto() n = hm.GetHisto(sampName, sampName ).Integral() u = hm.GetHisto(sampName, sampName, syst+'Up' ).Integral() d = hm.GetHisto(sampName, sampName, syst+'Down').Integral() meanval = (abs(n-d) + abs(n-u))/(2*n)*100 dic[sampName][syst] = meanval return dic
'hist', "Semileptonic t#bar{t} OS", color=kAzure + 2) s.AddHisto(hSS, 'hist', 'hist', "Semileptonic t#bar{t} SS", color=kOrange + 1) s.SetLegendPos(0.65, 0.80, 0.88, 0.90, ncol=1) s.SetRatioMin(0.) s.SetRatioMax(10) s.SetXtitle(vardic[hname]) s.SetOutName(hname) s.Draw() for v in vardic.keys(): save(v, hmSS, prSS, 'SS') for v in vardic.keys(): save(v, hmOS, prOS, 'OS') for v in vardic.keys(): hmOS.SetHisto(v) hmSS.SetHisto(v) hOS = hmOS.GetHisto(prOS[0], v) hSS = hmSS.GetHisto(prOS[0], v) for pr in prOS[1:]: hOS.Add(hmOS.GetHisto(pr, v)) hSS.Add(hmSS.GetHisto(pr, v)) #saveOSSS(v, hOS, hSS ) #for v in vardic.keys(): saveOSSS(v, nonpromptOS['Semileptonictt'][v], ss['Semileptonictt'][v])