def readProcess(self, fin, name, title, style, subproc, plot, plotmodifs, category, group): ## print "readProcess", fin,name,title,style,subproc,plot,plotmodifs,category names = subproc.keys() histos = self.readObjects(fin, plot, samples=names, cat=category, group=group) for iplot in range(len(histos)): h = histos[iplot] hname = names[iplot] h = style_utils.apply(h, subproc[hname]) sum = histos[0].Clone("%s_%s_%s" % (plot, name, category)) sum.SetTitle(title) for h in histos[1:]: sum.Add(h) self.keep(sum, True) sum = style_utils.apply(sum, plotmodifs) sum = style_utils.apply(sum, style) return sum
def format(self,objs,styles): for key,st in styles.iteritems(): if fnmatch(objs.GetName(),key) or objs.GetName() == key: style_utils.apply(objs,st) for key,st in styles.iteritems(): if "!%s" % objs.GetName() == key: style_utils.apply(objs,st)
def format(self, objs, styles): for key, st in styles.iteritems(): if fnmatch(objs.GetName(), key) or objs.GetName() == key: style_utils.apply(objs, st) for key, st in styles.iteritems(): if "!%s" % objs.GetName() == key: style_utils.apply(objs, st)
def makeEnvelope(self,name,histos): nominal = histos[0] errPlus = nominal.Clone( "%s_ErrPlus" % name ) errMinus = nominal.Clone( "%s_ErrMinus" % name ) style = self.getStyle("envelope") if style: style_utils.apply( errPlus, style ) style_utils.apply( errMinus, style ) for ibin in range(nominal.GetNbinsX()): hist = ROOT.TH1F("hist","hist",11,-5.,5.) hist.Reset("ICE") hist.Sumw2() points = [] plus = nominal.GetBinContent(ibin+1) minus = nominal.GetBinContent(ibin+1) nom = nominal.GetBinContent(ibin+1) err = nominal.GetBinError(ibin+1) points.append( [nom,err] ) hist.Fill(nom) for h in histos[1:]: content = h.GetBinContent(ibin+1) err = h.GetBinError(ibin+1) hist.Fill(content) points.append( [content,err] ) if content < minus: minus = content if content > plus: plus = content if hist.GetRMS() == 0.: errPlus.SetBinContent(ibin+1,plus) errMinus.SetBinContent(ibin+1,minus) continue hist2 = ROOT.TH1F("hist2","hist2",11,hist.GetMean()-5.*hist.GetRMS(),hist.GetMean()+5.*hist.GetRMS()) hist2.Sumw2() for p,e in points: hist2.Fill(p) func = ROOT.TF1("func","[0]*exp( -0.5*pow( (x-[1])/( (x>=0)*[2] + (x<=0)*[3] ) ,2.) )",hist2.GetMean()-5.*hist2.GetRMS(),hist2.GetMean()+5.*hist2.GetRMS()) func.SetParameters(len(histos),hist2.GetMean(),hist2.GetRMS(), hist2.GetRMS()) stat = int( hist2.Fit( func, "L" ) ) if stat == 0: errPlus.SetBinContent(ibin+1, max(nom,func.GetParameter(1)+fabs(func.GetParameter(2)))) errMinus.SetBinContent(ibin+1,min(nom,func.GetParameter(1)-fabs(func.GetParameter(3)))) else: errPlus.SetBinContent(ibin+1,plus) errMinus.SetBinContent(ibin+1,minus) self.keep([errPlus,errMinus,nominal]) return self.makeStack(name,[errPlus,errMinus,nominal])
def __call__(self,options,args): print self.__dict__ print ROOT options.styles["h"]=[ ("SetLineColor","kRed"), ("SetFillColor","kOrange") ] hist = ROOT.TH1F("h","h",101,-5.05,5.05) hist.FillRandom("gaus",1000) hist.Fit("gaus") canv = ROOT.TCanvas("canv","canv") self.keep([hist,canv],format=True) canv.cd() style_utils.apply( hist.GetListOfFunctions().At(0), [("SetLineWidth",2),("SetLineColor","kBlack")] ) hist.Draw()
def __call__(self, options, args): print self.__dict__ print ROOT options.styles["h"] = [("SetLineColor", "kRed"), ("SetFillColor", "kOrange")] hist = ROOT.TH1F("h", "h", 101, -5.05, 5.05) hist.FillRandom("gaus", 1000) hist.Fit("gaus") canv = ROOT.TCanvas("canv", "canv") self.keep([hist, canv], format=True) canv.cd() style_utils.apply(hist.GetListOfFunctions().At(0), [("SetLineWidth", 2), ("SetLineColor", "kBlack")]) hist.Draw()
def readProcess(self,fin,name,title,style,subproc,plot,plotmodifs,category,group): ## print "readProcess", fin,name,title,style,subproc,plot,plotmodifs,category names = subproc.keys() histos = self.readObjects(fin,plot,samples=names,cat=category,group=group) for iplot in range(len(histos)): h = histos[iplot] hname = names[iplot] h = style_utils.apply(h,subproc[hname]) sum = histos[0].Clone("%s_%s_%s" %( plot, name, category) ) sum.SetTitle(title) for h in histos[1:]: sum.Add(h) self.keep(sum,True) sum = style_utils.apply(sum,plotmodifs) sum = style_utils.apply(sum,style) return sum