#file ## Add the data from each file #for fi,file in enumerate(files): #plotting ttbar h_ttbar = ROOT.TFile.Open( 'root://cmseos.fnal.gov//store/user/lpctlbsm/wprime-qQ/CyMiniAna/myfiles/ttbarAC.root' ) pd = util.getPrimaryDataset(h_ttbar) name = metadata[pd].sampleType # compare primary dataset with metadatafile if name == "signal": name = pd.split("_")[1] print " > Opening data from ", h_ttbar h_hist = getattr(h_ttbar, histogram) # retrieve the histogram hist.Add(h_hist, name=name + "_" + histogram, linecolor=betterColors[2], draw='step', label=sample_labels[name].label) #numberOfHists+=1 plot = hist.execute() #hist.savefig() print " :: Saved plot to " + hist.saveAs + "\n" #plotting signal h_signal_w25NT12NL = ROOT.TFile.Open( 'root://cmseos.fnal.gov//store/user/lpctlbsm/wprime-qQ/CyMiniAna/myfiles/signal_mujets-ejets_W25N_T12N_LH.root' ) pd = util.getPrimaryDataset(h_signal_w25NT12NL) name = metadata[pd].sampleType # compare primary dataset with metadatafile if name == "signal": name = pd.split("_")[1]
hist.x_label = variables[histogram].label hist.y_label = "Events" hist.y_ratio_label = "" hist.lumi = 'XY.Z' # in /fb hist.format = 'png' # file format for saving image hist.saveAs = outpath+"_hist_"+histogram # save figure with name hist.CMSlabel = 'top left' # 'top left', 'top right'; hack code for something else hist.CMSlabelStatus = 'Internal' # ('Simulation')+'Internal' || 'Preliminary' hist.initialize() ## Add the data from each file for fi,file in enumerate(files): f = ROOT.TFile.Open(file) filename = file.split("/")[-1].split(".")[0] print " > Opening data from ",file h_hist = getattr(f,histogram) # retrieve the histogram hist.Add(h_hist,name=filename+"_"+histogram,linecolor=betterColors[numberOfHists], draw='step',label=sample_labels[filename].label) numberOfHists+=1 plot = hist.execute() hist.savefig() print " :: Saved plot to "+hist.saveAs+"\n" ## THE END
sep_tt_wprime1 = util.getHistSeparation(signal1, tt) sep_tt_wprime2 = util.getHistSeparation(signal2, tt) hist.extra_text.Add("Separation({0},{1}) = {2:.2f}".format( ttbar_label, wprime1_label_short, sep_tt_wprime1), coords=[0.03, 0.8]) hist.extra_text.Add("Separation({0},{1}) = {2:.2f}".format( ttbar_label, wprime2_label_short, sep_tt_wprime2), coords=[0.03, 0.7]) hist.initialize() hist.Add(h_hist_ttbar[histogram], name="ttbar_" + histogram, linecolor='green', linewidth=0, alpha=0.5, color='green', draw='stepfilled', label=ttbar_label, ratio_den=True, ratio_partner=['wprime1_' + histogram, 'wprime2_' + histogram]) # 1 signal sample hist.Add(h_hist_signal1[histogram], name="wprime1_" + histogram, linecolor='blue', color='blue', draw='step', label=wprime1_label, ratio_num=True, ratio_partner='ttbar_' + histogram)
hist.CMSlabelStatus = 'Internal' # ('Simulation')+'Internal' || 'Preliminary' hist.initialize() for hi, histogram in enumerate(histograms): print " :: Plotting " + histogram + "\n" h_hist = getattr(f, histogram) # retrieve the histogram ratio_partner = "h_el_pt_ejets" if histogram == "h_mu_pt_mujets" else "h_mu_pt_mujets" ratio_den = (histogram == "h_el_pt_ejets") ratio_num = (histogram == "h_mu_pt_mujets") label = 'Electron' if histogram.startswith('h_el') else "Muon" hist.Add(h_hist, name=histogram, linecolor=betterColors[numberOfHists], draw='step', label=label, ratio_partner=ratio_partner, ratio_num=ratio_num, ratio_den=ratio_den) numberOfHists += 1 plot = hist.execute() hist.savefig() print " :: Saved plot to " + hist.saveAs + "\n" ## THE END
hist.saveAs = outpath + "/datamc_{0}_{1}".format( histogramName, selection) # save figure with name if selection == 'mujets': hist.extra_text.Add(samples['mujets'].label, coords=[0.03, 0.9]) elif selection == 'ejets': hist.extra_text.Add(samples['ejets'].label, coords=[0.03, 0.9]) hist.initialize() # ttbar # hist.Add(h_ttbar['hists'][histogram], name=h_ttbar['name'], sampleType='background') hist.Add(h_ttbar['hists'][histogram], name="ttbar_" + histogram, linecolor='red', draw='step', label=samples['ttbar'].label, ratio_den=True, ratio_partner='data_' + histogram) # data # hist.Add(h_data[selection]['hists'][histogram], name='data', sampleType='data') hist.Add(h_data[selection]['hists'][histogram], name="data_" + histogram, linecolor='black', color='black', draw='errorbar', label=samples['data'].label, ratio_num=True, ratio_partner='ttbar_' + histogram)
hist.CMSlabelStatus = 'Simulation Internal' # ('Simulation')+'Internal' || 'Preliminary' #hist.extra_text.Add(text,coords[0,0]) hist.initialize() # loop over variables to put on one plot for hi, histogram in enumerate(histograms): print " :: Plotting " + histogram h_hist = getattr(f, histogram) # retrieve the histogram # if it is a histogram, just plot black errorbars if isinstance(h_hist, ROOT.TH1): lineColor = 'k' else: lineColor = betterColors[hi] hist.Add(h_hist, name=histogram, draw='errorbar', label=labels[histogram], linecolor=lineColor) plot = hist.execute() hist.savefig() print " > Saved plot to " + hist.saveAs + "\n" ## THE END