def doHistList(self, histlist, savedir, writeAs): x = 0 gcd = gROOT.cd for hist in histlist: x = x+1 list = {} h = None # if hist == histlist[-1]: # Drawer.summaryBegin = False for var in hist.subobjects["hist"]: source = var.getOption("source") if var.getOption('operation') == 'none': file = source[0] h1 = source[1] perf[ts[2]].start() if hist == histlist[0]: perf[ts[5]].start() f = TFile(file) gcd() tmp = f.Get(h1) if tmp: h = tmp.Clone() else: print >> sys.stderr, "Histogram %s in file %s not found" % (h1, file) continue perf[ts[2]].stop() if hist == histlist[0]: perf[ts[5]].stop() else: #combine histograms with operations integ = 0 varhists = [] varroots = [] for i in source: s = i.getOption("source") file = s[0] h1 = s[1] varhists.append(h1) varroots.append(file) for xxx in range(0, len(varroots)): perf[ts[2]].start() if hist == histlist[0]: perf[ts[5]].start() f = TFile(varroots[xxx]) h1 = varhists[xxx] gcd() tmp = f.Get(h1) if tmp: h = tmp.Clone() else: print >> sys.stderr, "Histogram %s in file %s not found" % (h1,varroots[xxx]) continue if xxx == 0:#load first variable h = tmp.Clone() else:#add or divide by the 2nd variable #TODO: in order to make real math, all variables need to be saved temporaly if var.getOption('operation') == 'add': h.Add(tmp) elif var.getOption('operation') == 'div': # print h1 # print var.hist # print h.GetName() if hist.getOption("showErrors").upper() == "TRUE": h.Sumw2() h.Divide(tmp) # if hist.opt["showErrors"]: # h.Sumw2() else: print 'unknown operation' perf[ts[2]].stop() if hist == histlist[0]: perf[ts[5]].stop() #=============================================================================== # once you have the histogram, apply the configuration to it. #=============================================================================== h = Drawer.applyHistConfig(h, hist, var) #=============================================================================== # only hists which are marked to be draw are added to list #=============================================================================== if var.getOption('draw') == '1': list[var.getOption("name")] =h.Clone() # list.append(copy.deepcopy(h.Clone())) #=============================================================================== # save all histograms in one file #=============================================================================== perf[ts[1]].start() if hist == histlist[0]: perf[ts[4]].start() Drawer.saveHistsInOne(list, hist, savedir, writeAs) perf[ts[1]].stop() if hist == histlist[0]: perf[ts[4]].stop() if showPerformance: print "time elapsed to read first histogram (incl. caching): %s" % perf[ts[5]].getMeasuredTime() print "time elapsed to draw first histogram (incl. caching): %s" % perf[ts[4]].getMeasuredTime()