def save_and_cleanup(outdir = 'plots'): ## Save plots if not os.path.exists(outdir): print "Creating folder `%s'" % outdir os.mkdir(outdir) else: ## TODO: remove outdir pass canvases.make_plots(['png', 'root'], outdir) canvases.make_pdf_from_eps(outdir) ## Store corrections for extractor in extractors: raw = extractor.raw .name.split('-')[0] target = extractor.target.name.split('-')[0] out_file_name = '_'.join([raw, 'to', target, 'qqcorrections.root']) extractor.write_corrector_to_file(outdir + '/' + out_file_name) ## Cleanup trees.close_files()
def save_and_cleanup(outdir='plots'): ## Save plots if not os.path.exists(outdir): print "Creating folder `%s'" % outdir os.mkdir(outdir) else: ## TODO: remove outdir pass canvases.make_plots(['png', 'root'], outdir) canvases.make_pdf_from_eps(outdir) ## Store corrections for extractor in extractors: raw = extractor.raw.name.split('-')[0] target = extractor.target.name.split('-')[0] out_file_name = '_'.join([raw, 'to', target, 'qqcorrections.root']) extractor.write_corrector_to_file(outdir + '/' + out_file_name) ## Cleanup trees.close_files()
def main(): ''' Main entry point of execution. ''' hist = get_gaussian_histogram() make_canvases(hist) make_more_canvases(hist) ## Make output graphics in different formats using ROOT for the conversions canvases.make_plots('png C root eps'.split()) ## Store canvases as pdf by creating eps and then using ps2pdf to convert ## them. canvases.make_pdf_from_eps() ## The module holds references to the created canvases. ## Note that they did not get killed even though we do not ## explicitly keep references to them. They still show up on the screen. ## You can access them like this: print 'List of canvases:' pprint.pprint(canvases.canvases)
cuts.append('Entry$ < %d' % max_entries) dataset = datasetly.get(tree=tree, variable=variable, cuts=cuts) variable = dataset.get().first() variable.SetTitle(cfg.title) variable.setUnit(cfg.unit) datasets.append(dataset) ## End of loop over expressions and selections dataset = datasets[0] for further_dataset in datasets[1:]: dataset.append(further_dataset) return dataset ## End of get_dataset() #______________________________________________________________________________ def draw_and_append(plot): plot.Draw() plots.append(plot) ## End of draw_and_append(plot) #______________________________________________________________________________ if __name__ == '__main__': import user test() ## Clean up to prevent horrible root crashes. if not '-i' in sys.argv: canvases.make_pdf_from_eps('plots') trees.close_files()
plot.name = 'Electron_Reco_Eff_EB_B_Data' plots.append(copy.deepcopy(plot)) plot.sourcefilename = 'Efficiency_2011B/Efficiency.root' plot.sourcehistoname = 'MC_Endcap' plot.leftlabel = 'Run 2011B, ECAL Endcap' plot.rightlabel = 'CMS Simulation' plot.name = 'Electron_Reco_Eff_EE_B_MC' plots.append(copy.deepcopy(plot)) plot.sourcefilename = 'Efficiency_2011B/Efficiency.root' plot.sourcehistoname = 'DataB_Endcap' plot.leftlabel = 'Run 2011B, ECAL Endcap' plot.rightlabel = 'CMS Preliminary' plot.name = 'Electron_Reco_Eff_EE_B_Data' plots.append(copy.deepcopy(plot)) ## Configuration END ROOT.gStyle.SetPalette(55) ROOT.gStyle.SetPadLeftMargin(0.15) ROOT.gStyle.SetPadRightMargin(0.15) ROOT.gStyle.SetPadTopMargin(0.1) ROOT.gStyle.SetPaintTextFormat('5.3f') ROOT.gROOT.ForceStyle() for p in plots[:]: p.makeplot() canvases.make_pdf_from_eps()
if ytitle: graph.GetYaxis().SetTitle(ytitle) if yrange: graph.GetYaxis().SetRangeUser(*yrange) if color: paint(graph, color) return graph ## End of customize(graph) ##______________________________________________________________________________ def paint(graph, color): ''' For the given graph, sets the color of the line and marker to the given one. ''' graph.SetLineColor(color) graph.SetMarkerColor(color) return graph ## End of customize(graph) ##______________________________________________________________________________ if __name__ == '__main__': main() #pprint.pprint(graphs) canvases.make_plots(['png']) canvases.make_pdf_from_eps()
def save_plots(self): canvases.make_plots(['root']) canvases.make_pdf_from_eps()
variable = dataset.get().first() variable.SetTitle(cfg.title) variable.setUnit(cfg.unit) datasets.append(dataset) ## End of loop over expressions and selections dataset = datasets[0] for further_dataset in datasets[1:]: dataset.append(further_dataset) return dataset ## End of get_dataset() #______________________________________________________________________________ def draw_and_append(plot): plot.Draw() plots.append(plot) ## End of draw_and_append(plot) #______________________________________________________________________________ if __name__ == '__main__': import user test() ## Clean up to prevent horrible root crashes. if not '-i' in sys.argv: canvases.make_pdf_from_eps('plots') trees.close_files()