def flavour_response_extrapolation(args=None, additional_dictionary=None): """ pT balance extrapolation for different flavours.""" flavours = ['uds', 'c', 'b', 'g'] flavourlabels = ['u/d/s', 'c', 'b', 'gluon'] weights = ["((ngenneutrinos<1)&&{})".format(flavour_selections[f]) for f in flavours] d = { # input "zjetfolders": ['noalphacuts'], "y_expressions": ["ptbalance"], "x_expressions": ["alpha"], "weights": weights, "tree_draw_options": "prof", "x_bins": ["6,0,0.3"], "nicks": flavours, # fit 'analysis_modules': ['FunctionPlot'], 'functions': ['[0]+[1]*x'], 'function_fit': flavours, 'function_parameters': ['1,1'], 'function_ranges': ['0,0.3'], 'function_nicknames': [f+"_func" for f in flavours], #formatting "alphas": [0.3], "labels": flavourlabels + [None]*4, 'colors': ['black', 'red', 'blue', 'green']*2, 'y_lims': [0.83, 1.06], 'lines': [1.], # output 'filename': 'flavour_response_extrapolation', } if additional_dictionary is not None: d.update(additional_dictionary) return [PlottingJob(plots=[d], args=args)]
def pf_fractions_vs_flavour(args=None, additional_dictionary=None): """Jet composition of the leading jet for different flavours""" d = { "filename": "pf_fractions_vs_flavour", "x_expressions": ["sortedabsflavour"], "x_label": "Jet Flavour", "x_ticks": [1,2,3,4,5,6,7], 'x_bins':[" ".join(["0.4"] + ["{0}.6 {1}.4".format(i, i+1) for i in range(7)] + [str(7+3.4)])], "x_tick_labels": ['d','u','s','c','b','g', 'undef.'], "labels": [ r"$\\mu$", r"$e$", r"$\\gamma$", "\n\nCharged\nHadrons", "\n\nNeutral\nHadrons", ], "markers": ["fill" ], "stacks": ["a", "a", "a", "a", "a"], "y_expressions": [ "jet1mf", "jet1ef", "jet1pf", "jet1chf", "jet1nhf", ], "colors": [histo_colors[c] for c in ['violet', 'brown', 'green', 'yellow', 'blue']], "y_label": "Jet PF Energy Fraction", "y_lims": [0.0, 1.0], "tree_draw_options": ["prof"], "legend": "center right", } if additional_dictionary is not None: d.update(additional_dictionary) return [PlottingJob(plots=[d], args=args)]
def response_zones(args=None, additional_dictionary=None): """ MPF response in the tagging zones.""" zone_labels = ['uds', 'c', 'b', 'g'] file_amount = len(additional_dictionary['files']) d = { 'x_expressions': [str(i) for i in range(1, len(zone_labels)+1) for j in range(file_amount)], 'y_expressions': 'mpf', 'weights': [zone_selections[zone] for zone in zone_labels for j in range(file_amount)], 'x_ticks': range(1, len(zone_labels)+1), 'x_tick_labels': [i+"-zone" for i in zone_labels], 'tree_draw_options': 'prof', 'x_label': 'Tagging Zone', 'labels': ['MC', 'Data'], 'markers': ['o', 's'], 'x_bins': " ".join([str(x+0.5) for x in range(len(zone_labels)+1)]), 'y_lims': [0.85, 1.05], 'colors': ['red', 'black'], 'lines': [1.0], 'filename': 'mpf_zones', "cutlabel": True, } if additional_dictionary != None: d.update(additional_dictionary) return [PlottingJob(plots=[d], args=args)]
def flavour_comparison(args=None, additional_dictionary=None): """Flavour comparsion with jet1btag and jet1qgtag """ plots = [] for x_quantity in ['jet1btag', 'jet1qgtag']: d = { "filename": "flavourComparison_vs_" + x_quantity, "legend": "upper center", "labels": ["u/d/s-jets", "c-jets", "b-jets", "gluon-jets"], "colors": [colors['uds'],colors['c'],colors['b'],colors['g']], "markers": ["fill" ], "stacks": ["a", "a", "a", "a"], "x_expressions": [x_quantity], "weights": [ "(abs(matchedgenparton1flavour)>0 && abs(matchedgenparton1flavour)<4)", "(abs(matchedgenparton1flavour)==4)", "(abs(matchedgenparton1flavour)==5)", "(abs(matchedgenparton1flavour)==21)" ], "x_lims": [0.0, 1.0], "x_bins": "25,0,1" } if x_quantity == "jet1btag": d['y_log'] = True d.update(additional_dictionary) plots.append(d) return [PlottingJob(plots=plots, args=args)]
def flavour_response_zones(args=None, additional_dictionary=None): """ MPF response in the tagging zones.""" plots = [] for flavour_selection in ['uds', 'c', 'b', 'g']: zone_labels = ['uds', 'c', 'b', 'g'] weights = [flavour_selections[flavour_selection] + "*" + zone_selections[zone] for zone in zone_labels] d = { 'x_expressions': [str(i) for i in range(1, len(zone_labels)+1)], 'y_expressions': 'mpf', 'weights': weights, 'x_ticks': range(1, len(zone_labels)+1), 'x_tick_labels': [i+"-zone" for i in zone_labels], 'tree_draw_options': 'prof', 'x_label': 'Tagging Zone', 'markers': 'o', 'x_bins': " ".join([str(x+0.5) for x in range(len(zone_labels)+1)]), 'y_lims': [0.85, 1.05], 'colors': 'red', 'lines': [1.0], 'title': flavour_selection + ' quarks', 'filename': 'mpf_zones_' + flavour_selection, "cutlabel": True, "legend": None } if additional_dictionary != None: d.update(additional_dictionary) plots.append(d) return [PlottingJob(plots=plots, args=args)]
def response_rms(args=None, additional_dictionary=None): """2D response-RMS plots vs ZpT and nPV. Same as Fig19 in the 2016 JEC paper.""" plots = [] for method, label in zip(['ptbalance', 'mpf'], ['balance', 'MPF']): d = { # input "tree_draw_options": ["prof"], "x_bins": ["30,30,330"], "x_expressions": ["zpt"], "y_bins": ["40,5,45"], "y_expressions": ["npumean"], "z_expressions": ["(((trueresponse-{})/trueresponse)**2)".format(method)], # analysis "analysis_modules": ["ConvertToHistogram", "SquareRootBinContent"], "convert_nicks": ["nick0"], "square_root_nicks": ["nick0"], # formatting and output "z_label": r"$RMS((R_{Sim} - R_{" + label + r"}) \/ R_{Sim})$", "z_lims": [0.0, 0.25], "y_lims": [5, 40], "filename": "rms_" + method, } if additional_dictionary != None: d.update(additional_dictionary) plots.append(d) return [PlottingJob(plots=plots, args=args)]
def jetid_changes(args, additional_dictionary=None): """Plot changes from jetID veto for leading jet vs leading skim jet over pt, eta, phi""" plots = [] input_files, args_nofiles = get_input_files(args) #binningsZJet.BinningsDictZJet().binnings_dict["abseta"] for x_expr, x_binning in [ ("jet1pt", "20,0,200"), ("jet1eta", binningsZJet.BinningsDictZJet().binnings_dict["eta"]), ("jet1phi", binningsZJet.BinningsDictZJet().binnings_dict["phi"]) ]: d = { 'labels': ['valid'] * len(input_files) + ["total"] * len(input_files), 'x_expressions': [x_expr], 'y_expressions': ["skim%s" % x_expr], 'x_lims': lims_from_binning(x_binning), 'y_lims': lims_from_binning(x_binning), 'x_bins': x_binning, 'y_bins': x_binning, 'filename': "jetid_changes_" + x_expr, } if additional_dictionary is not None: d.update(additional_dictionary) plots.append(d) return [PlottingJob(plots=plots, args=args)]
def plot_yb_ystar_correlation(args=None, cut='_jet1pt20', mc='mad', postfix=''): plots=[] gen = 'gen' cutstring = generate_basiccutstring(args,gen+cut) d = ({ 'corrections': [''], 'files': [DATASETS[mc]], 'y_expressions': [gen+'ystar'], 'y_bins': 'ystar', 'y_label': gen+'ystar', 'x_expressions': [gen+'yboost'], 'x_bins': 'yboost', 'x_label': gen+'yboost', 'z_log': True, 'z_lims': [1e2,4e4], 'filename': gen+'yboost_'+gen+'ystar', 'www': 'responses_'+mc+cut+postfix, 'nicks': ['correlation'], 'weights': [cutstring+'&&('+gen+'yboost+'+gen+'ystar<2.5)'], 'zjetfolders': [gen+'zjetcuts_L1L2L3'], 'figsize': [8,6.5], 'no_energy_label': True, 'texts': [r"$\\bf{CMS} \\hspace{0.5} \\it{Simulation} \\hspace{0.2} \\it{Preliminary}$" if CMSLABEL else ""], #'plot_modules': ['ExportRoot'], 'texts_size': [20], 'texts_y': [1.06], 'texts_x': [0.03], }) plots.append(d) return [PlottingJob(plots=plots, args=args)]
def fake_events(args=None, additional_dictionary=None): plots = [] ad = copy.deepcopy(additional_dictionary) if additional_dictionary else {} d = { 'cutlabel': True, 'filename': 'fakes', 'x_bins': ['0.5 1.5 2.5 3.5 4.5'], 'x_lims': [0,5], 'weights':['jet2eta<2.5','jet2eta<2.5','jet2eta<2.5','jet2eta<2.5','jet2eta<2.5&matchedgenjet2pt>0','jet2eta<2.5&matchedgenjet2pt>0','jet2eta<2.5&matchedgenjet2pt>0','jet2eta<2.5&matchedgenjet2pt>0'], # Plot all files first with all events in central eta region, and another time only matched 2nd jet events 'analysis_modules': ['Ratio'], 'markers' : ['bar','bar','bar','bar','bar','bar','bar', 'bar','o','o','o', 'o'], 'colors': ['red', 'red', 'red', 'red','green', 'green', 'green','green', 'black','black','black', 'black'], #Red vor all events, green for matched, black for ratios 'nicks' : ['puppi', 'chs', 'chspuidtight', 'chspuidmedium','puppimatched', 'chsmatched', 'chspuidtightmatched', 'chspuidmediummatched'], 'ratio_numerator_nicks' : ['puppimatched', 'chsmatched', 'chspuidtightmatched', 'chspuidmediummatched'], 'ratio_denominator_nicks': ['puppi', 'chs', 'chspuidtight', 'chspuidmedium'], 'ratio_result_nicks': ['puppi_ratio', 'chs_ratio', 'chspuidtight_ratio', 'chspuidmedium_ratio'], 'y_subplot_lims' : [0.5,0.75], 'x_expressions': ['1','2','3','4','1','2','3','4'], #Get different bins for each file, same bin for all events and matched 'x_label': 'Jet 2 matching', 'x_ticks': [1,2,3,4], 'x_tick_labels': ['Puppi', 'CHS', 'PuIDtight','PuIDmed'], 'y_lims': [0,2.9e8], 'y_label': 'Arbitrary Units', } if ad != None: d.update(ad) d['texts'] += [r"|$\\mathit{\\eta}^{\\mathrm{jet2}}$|$<2.5$"] #Additional label for the jet2eta cut taken because puppi takes it in general d['texts_x'] += [0.03] d['texts_y'] += [0.79] d['texts_size'] += ['large'] d['labels'] = ['Fakes','Fakes','Fakes','Fakes','Matched','Matched','Matched','Matched'] plots.append(d) return [PlottingJob(plots=plots, args=args)]
def plot_npcorrections(args=None,cut='_jet1pt10'): cutstring = generate_basiccutstring(args,cut) plots = [] d = ({ 'files': [ #'/ceph/tberger/excalibur_results/2019-09-03/mc16_mm_BCDEFGH_DYtoLLmadgraph.root', '/ceph/tberger/excalibur_results/2019-09-03/mc16_mm_BCDEFGH_DYtoLLamcatnlo.root', '/portal/ekpbms1/home/mschnepf/QCD/NP_corrections/runtime/CMSSW_10_6_2/src/nonNP_1mio.root', '/portal/ekpbms1/home/mschnepf/QCD/NP_corrections/runtime/CMSSW_10_6_2/src/official_1mio.root', ], 'folders': ['genzjetcuts_L1L2L3/ntuple'], 'nicks': ['amc','nonNP','official'], 'weights': ['abs(genmupluseta)<2.4&&abs(genmuminuseta)<2.4&&genmupluspt>25&&genmuminuspt>20&&genjet1pt>20&&abs(genjet1y)<2.4&&abs(genzmass-91.2)<20&&genystar<0.5&&genyboost<0.5'] +2*['abs(genmupluseta)<2.4&&abs(genmuminuseta)<2.4&&genmupluspt>25&&genmuminuspt>25&&genjetpt >20&&abs(genjety )<2.4&&abs(genzmass-91.2)<20&&genystar<0.5&&genyboost<0.5'], 'no_weight': True, 'x_expressions': ['genzpt'], 'x_bins': 'zpt', #'x_expressions': ['genjet1pt']+2*['genjetpt'], #'x_bins': 'jet1pt', #'x_label': 'genjet1pt', 'x_log': True, 'www': 'NPC', 'analysis_modules': ['NormalizeToFirstHisto','Ratio'], 'ratio_numerator_nicks': ['nonNP','official'], 'ratio_denominator_nicks': ['amc'], 'y_log': True, #'y_subplot_lims': [0.9,1.1], 'lumis': [35.9], }) plots.append(d) return [PlottingJob(plots=plots, args=args)]
def get_IDTrigger_uncertainties(args=None): "Get uncertainties for ID and Trigger. For this purpose, input data needs different pipelines for mean value and variations up/down variations (here upwards variation is higher, check this for other IDs" plots = [] for sf in ['ID', 'Trigger']: for obs in observe: for year in years: d = ({ 'files' : [input_data], 'folders' : ['leptoncuts_mean/ntuple','leptoncuts_'+sf+'up/ntuple'], 'x_expressions': obs, 'x_label' : r'$\\mathit{p}_{T}^{Z}$ / GeV', 'y_errors' : False, 'x_errors': [1], 'weights' : '(leptonSFWeight*leptonTriggerSFWeight)', 'nicks' : ['mean', 'scaleup'], 'markers': ['d', 'd'], 'nicks_whitelist' : ['reldiffup'], "sum_nicks" : ['mean scaleup'], "sum_scale_factors" : ['-1 1'], "sum_result_nicks" : ['diffup'], 'divide_denominator_nicks' : ['mean'], "divide_numerator_nicks" : ['diffup'], "divide_result_nicks" : ['reldiffup'], 'x_lims' : [40,400], 'plot_modules': ['ExportRoot'], 'file_mode': ('RECREATE'), 'analysis_modules' : ['SumOfHistograms','Divide','PrintBinContent'], 'output_dir' : 'files/'+year+'/', "filename" : sf+'_uncertainty_'+obs, 'x_log' : True, 'y_label' : "Rel. Uncertainty / %", }) if obs == 'zpt': d['x_bins'] = [binzpt] for i in range(len(y_bins)): d2 = copy.deepcopy(d) d2['weights'] = '(leptonSFWeight*leptonTriggerSFWeight)*('+y_bins[i-1]+'<abs(zy)&abs(zy)<'+y_bins[i]+')' if i is not 0 else '(leptonSFWeight*leptonTriggerSFWeight)' d2['filename'] = sf+'_uncertainty_'+obs+'_'+str(i) plots.append(d2) elif obs == 'abs(zy)': d['x_bins'] = ['23,0,2.3'] plots.append(d) elif obs == 'zy': d['x_bins'] = ['46,-2.3,2.3'] plots.append(d) elif obs == 'zmass': d['x_bins'] = ['20,81,101'] plots.append(d) elif obs == 'phistareta': d['folders'] = ['leptoncuts_mean/ntuple','leptoncuts_'+sf+'up/ntuple'], d['x_bins'] = [binsphistar], for i in range(len(y_bins)): d3 = copy.deepcopy(d) d3['weights'] = '(leptonSFWeight*leptonTriggerSFWeight)*('+y_bins[i-1]+'<abs(zy)&abs(zy)<'+y_bins[i]+'&zpt>5)' if i is not 0 else '(leptonSFWeight*leptonTriggerSFWeight)*(zpt>5)' d3['filename'] = sf+'_uncertainty_'+obs+'_'+str(i) plots.append(d3) elif obs == 'mu1pt': d['x_bins'] = ['27 37 47 57 67 77 87 107 125 150'], plots.append(d) return [PlottingJob(plots=plots, args=args)]
def vertex_reco_efficiency(args=None, additional_dictionary=None): """Vertex reconstruction efficiency: Number of reconstructed vertices (npv) as a function of true vertices""" lims = [-0.5, 40.5] binning = ",".join([str(i) for i in [(lims[1] - lims[0])] + lims]) d = { # input 'zjetfolders': ['nocuts'], 'x_expressions': 'npu+1', 'y_expressions': 'npv', 'x_bins': binning, 'tree_draw_options': 'prof', 'x_lims': lims, 'y_lims': lims, # fit 'analysis_modules': ['FunctionPlot'], 'functions': ['[0]+[1]*x'], 'function_fit': ['nick0'], 'function_parameters': ['1,1'], 'function_ranges': ['-0.5,40.5'], 'function_nicknames': [' '], 'function_display_result': True, 'function_fit_parameter_names': [r'y-intercept', r'Slope' + r'\\ ' * 11], # formatting 'line_styles': [None, '-'], 'labels': ["None"], 'x_label': '$n_{PV}^{Gen}$', 'y_label': '$n_{PV}^{Reco}$', # output 'filename': 'npv_reco_gen', } if additional_dictionary: d.update(additional_dictionary) return [PlottingJob(plots=[d], args=args)]
def flavour_jet_response(args=None, additional_dictionary=None): """Flavour response for simulated jets """ d = { "filename": "flavourJetResponse", "legend": "lower left", "x_expressions": ["sortedabsflavour"], "x_label": "Jet Flavour", "y_label": "Jet Response", "x_ticks": [1,2,3,4,5,6, 7], "x_lims": [0.5,7.5], "x_tick_labels": ['d','u','s','c','b','g', 'undef.'], "y_expressions": [ "ptbalance", "mpf", #"genjet1pt/zpt", "jet1pt/genjet1pt" ], "labels": [ r"$\\mathit{p}_T$ balance", "MPF", #r"$\\mathit{p}_T^{GenJet} \/ \\mathit{p}_T^Z$", r"$\\mathit{p}_T^{RecoJet} \/ \\mathit{p}_T^{GenJet}$" ], "y_lims": [0.85, 1.07], 'tree_draw_options': 'prof', 'markers': ['.', '*', 'd'], 'marker_colors': ['black', 'red', 'green'], "cutlabel": True, "lines": [1.], } if additional_dictionary != None: d.update(additional_dictionary) return [PlottingJob(plots=[d], args=args)]
def response_correlations(args=None, additional_dictionary=None): """2D plots for response method correlations (+ correlation factor).""" plots = [] methods = [ ('ptbalance', 'trueresponse'), ('mpf', 'trueresponse'), ('ptbalance', 'mpf'), ] bins = '30,0.7,1.3' lims = [float(f) for f in bins.split(',')[1:]] for method1, method2 in methods: d = { 'x_expressions': [method2], 'y_expressions': [method1], 'x_bins': [bins], 'y_bins': [bins], 'analysis_modules': ['GetCorrelationFactor'], 'x_lims': lims, 'y_lims': lims, 'filename': '_'.join(['correlation', method1, method2]), } if additional_dictionary != None: d.update(additional_dictionary) plots.append(d) return [PlottingJob(plots=plots, args=args)]
def z_pt_resolution(args=None, additional_dictionary=None): """Z resolution (pT reco/gen) as function of gen pT""" d = { # input 'x_expressions': ['genzpt'], 'y_expressions': ['zpt/genzpt'], 'x_bins': 'zpt', 'tree_draw_options': 'profs', 'analysis_modules': ['ConvertToHistogram', 'StatisticalErrors'], 'convert_nicks': ['nick0'], 'stat_error_nicks': ['nick0'], # formatting 'x_log': True, 'y_label': r'Z $\\mathit{p}_T$ resolution', 'markers': ['o'], 'x_lims': [30, 1000], 'x_errors': [True], 'y_errors': [False], 'x_ticks': [30, 50, 70, 100, 200, 400, 1000], # output 'filename': 'z_pt_resolution', } if additional_dictionary != None: d.update(additional_dictionary) return [PlottingJob(plots=[d], args=args)]
def plot_JEC_inclusive(args=None, obs='zpt', cut='_jet1pt20', data='17Jul2018',postfix=''): plots=[] d = ({ 'files': [DATASETS[data],DATASETS[data].replace('.root','_JECUp.root'),DATASETS[data].replace('.root','_JECDown.root')], 'nicks': ['central','up','down'], 'folders': ['zjetcuts_L1L2L3Res/ntuple'], 'x_expressions': [obs], 'weights': ['jet1pt>20'], 'www': 'comparison_variations'+cut+'_'+data+'_JEC'+postfix, 'y_log': True, 'x_log': True, 'x_label': obs, 'x_errors': [1], 'x_bins': obs, #'x_ticks': [30,50,100,1000], 'filename': obs, 'analysis_modules': ['NormalizeByBinWidth','Ratio'], 'ratio_numerator_nicks': ['up','down'], 'ratio_denominator_nicks': ['central'], 'ratio_denominator_no_errors': False, 'markers': ['o','^','v','^','v'], 'colors': ['black','darkorange','darkgreen','darkorange','darkgreen'], 'y_subplot_lims': [0.9,1.1], 'y_subplot_label': 'Ratio to central', }) plots.append(d) return [PlottingJob(plots=plots, args=args)]
def jetid_efficiency(args, additional_dictionary=None): """Plot efficiency of jetID veto for leading skim jet over pt, eta, phi""" plots = [] input_files, args_nofiles = get_input_files(args) binnings = binningsZJet.BinningsDictZJet() for x_expr, x_binning in [ ("skimjet1pt", "20,0,200"), ("skimjet1eta", binnings.binnings_dict["eta"]), ("skimjet1phi", binnings.binnings_dict["phi"]), ("zpt", "50,0,200"), ]: d = { 'labels': ['valid'] * len(input_files) + ["total"] * len(input_files), 'x_expressions': [x_expr], 'x_lims': lims_from_binning(x_binning), 'weights': ['(weight*skimjet1validity)'] * len(input_files) + ["(weight*(skimjet1pt>=0))"] * len(input_files), 'x_bins': x_binning, 'filename': "jetid_efficiency_" + x_expr, 'analysis_modules': ['Ratio'], 'y_subplot_lims': [0.01, 0.99], } if additional_dictionary is not None: d.update(additional_dictionary) plots.append(d) return [PlottingJob(plots=plots, args=args)]
def response_nevents(args=None, additional_dictionary=None, data_quantities=True): """Number of Events per Response bin""" known_args, args = get_special_parser(args) plots = [] # TODO put these default binning values somewhere more globally for quantity, bins in zip(*get_list_slice( [['zpt', 'npv', 'abs(jet1eta)'], ['zpt', 'npv', 'abseta']], known_args.no_quantities)): d = { 'x_expressions': [quantity], 'x_bins': bins, 'lines': [1.0], 'analysis_modules': ['Ratio'], 'filename': "NEvents_" + quantity.replace("(", "").replace(")", ""), 'y_subplot_lims': [0.0, 2.0], 'legend': 'upper right', 'no_weight': True, } if quantity == 'abs(jet1eta)': d['zjetfolders'] = ["noetacuts"] if quantity == 'zpt': d['x_log'] = True d['x_ticks'] = [30, 50, 70, 100, 200, 400, 1000] if additional_dictionary != None: d.update(additional_dictionary) plots.append(d) return [PlottingJob(plots=plots, args=args)]
def flavour_composition_zones(args=None, additional_dictionary=None): """Flavour composition for the different tagging zones""" # The plot is put together according to these two lists: flavours = ['undef', 'g', 'b', 'c', 'uds'] flavour_labels = ['undef.', 'gluon', 'b', 'c', 'u/d/s'] zone_labels = ['uds', 'c', 'b', 'g'] tick_labels = ['u/d/s', 'c', 'b', 'gluon'] d = { 'y_expressions': [flavour_selections[x] for x in flavours]*len(zone_labels), 'colors': [colors[i] for i in flavours]*len(zone_labels), 'weights': [zone_selections[x] for x in zone_labels for i in range(len(flavour_labels))], 'stacks': [str(x) for x in range(1,len(zone_labels)+1) for i in range(len(flavour_labels))], 'x_expressions': [str(x) for x in range(1,len(zone_labels)+1) for i in range(len(flavour_labels))], 'labels': flavour_labels +[None]*len(flavour_labels)*(len(zone_labels)-1), 'x_ticks': range(1,1+len(zone_labels)), 'x_tick_labels': tick_labels, 'x_bins':[" ".join(["0.4"] + ["{0}.6 {1}.4".format(i, i+1) for i in range(len(zone_labels))] + [str(len(zone_labels)+2.2)])], 'x_label': 'Tagging Zone', 'y_label': 'Flavour Fraction', 'y_lims': [0, 1], 'legend': 'center right', 'tree_draw_options': 'prof', 'markers': ['fill'], 'filename': 'flavour_composition_zones', } if additional_dictionary != None: d.update(additional_dictionary) return [PlottingJob(plots=[d], args=args)]
def genjet_profile_comparisons(args=None, additional_dictionary=None): """ Some profile plots showing differences of matched genjets and recojets. """ plots = [] jet1_quantities = ['jet1pt-matchedgenjet1pt']#'abs(jet1eta-matchedgenjet1eta)', 'abs(jet1phi-matchedgenjet1phi)','sqrt((jet1eta-matchedgenjet1eta)^2+(jet1phi-matchedgenjet1phi)^2)'] jet2_quantities = ['jet2pt-matchedgenjet2pt']#,'abs(jet2eta-matchedgenjet2eta)', 'abs(jet2phi-matchedgenjet2phi)','sqrt((jet2eta-matchedgenjet2eta)^2+(jet2phi-matchedgenjet2phi)^2)'] y_dict = { #filename, label, y_lims of the quantity 'jet1pt-matchedgenjet1pt': ['jet1delta_pt', r"$\\mathit{p}_\\mathrm{T}^\\mathrm{jet1}$-$\\mathit{p}_\\mathrm{T}^\\mathrm{genjet1}$",[-10,15]], 'abs(jet1eta-matchedgenjet1eta)':['jet1delta_eta', r"|$\\mathit{\\eta}^{\\mathrm{jet1}}-\\mathit{\\eta}^\\mathrm{genjet1}$|",[0,1.5]], 'abs(jet1phi-matchedgenjet1phi)':['jet1delta_phi',r"|$\\mathit{\\phi}^{\\mathrm{jet1}}-\\mathit{\\phi}^\\mathrm{genjet1}$|",[0,3.6]], 'sqrt((jet1eta-matchedgenjet1eta)^2+(jet1phi-matchedgenjet1phi)^2)': ['jet1delta_R',r"$\\Delta R(jet1,genjet1)$",[0,3.9]], 'jet2pt-matchedgenjet2pt': ['jet2delta_pt',r"$\\mathit{p}_\\mathrm{T}^\\mathrm{jet2}-\\mathit{p}_\\mathrm{T}^\\mathrm{genjet2}$",[-10,10]], 'abs(jet2eta-matchedgenjet2eta)': ['jet2delta_eta',r"|$\\mathit{\\eta}^{\\mathrm{jet2}}-\\mathit{\\eta}^\\mathrm{genjet2}$|",[0,4]], 'abs(jet2phi-matchedgenjet2phi)': ['jet2delta_phi',r"|$\\mathit{\\phi}^{\\mathrm{jet2}}-\\mathit{\\phi}^\\mathrm{genjet2}$|",[0,4]], 'sqrt((jet2eta-matchedgenjet2eta)^2+(jet2phi-matchedgenjet2phi)^2)': ['jet2delta_R',r"$\\Delta R(jet2,genjet2)$",[0,5]], } for xquantity in ('matchedgenjet1pt','matchedgenjet2pt'): #Plot jet1 y-properties over jet1pt, same for jet2 d = { 'x_expressions': [xquantity], 'cutlabel': True, 'analysis_modules': ['ConvertToTGraphErrors'], 'weights' : 'jet1pt>0&jet2pt>0&matchedgenjet1pt>0&matchedgenjet2pt>0', #Take only matched jets for this analysis 'tree_draw_options': 'prof', 'colors' : ['black','red','blue','green','green','blue','black'], 'markers': ['o', 'd', '^','s','s','^', 'o'], 'nicks' : ['puppi', 'chs', 'chspuidtight', 'chspuidmedium'], #'ratio_numerator_nicks' : ['chspuidmedium','chspuidtight', 'puppi'], #'ratio_denominator_nicks': ['chs', 'chs', 'chs'], #'ratio_result_nicks': ['puidtight_ratio', 'puidmedium_ratio','puppi_ratio'], #'y_subplot_lims': [0.5, 1.5], #'y_subplot_label': 'Ratio to CHS', } if xquantity == 'matchedgenjet1pt': for yquantity in jet1_quantities: #Jet1 d1 = copy.deepcopy(d) d1["x_bins"] = ['12,30,150'] d1['y_expressions'] = yquantity d1["filename"] = y_dict[yquantity][0] d1['y_label'] = y_dict[yquantity][1] d1['y_lims'] = y_dict[yquantity][2] plots.append(d1) elif xquantity == 'matchedgenjet2pt': #Jet2 d["x_bins"] = ['14.0,70'] for yquantity in jet2_quantities: d2 = copy.deepcopy(d) d2["x_bins"] = ['7,0,70'] d2['x_lims'] = [0, 70] d2['y_expressions'] = yquantity d2["filename"] = y_dict[yquantity][0] d2['y_label'] = y_dict[yquantity][1] d2['y_lims'] = y_dict[yquantity][2] plots.append(d2) if additional_dictionary != None: for plot in plots: plot.update(additional_dictionary) return [PlottingJob(plots=plots, args=args)]
def plot_calibration_zmass(args=None,cuts='finalcuts',jec='L1L2L3'): plots=[] obs = 'zmass' d = ({ 'files': #(['/ceph/tberger/excalibur_results/2019-07-25/mc16_mm_BCDEFGH_DYNJtoLLmadgraph.root'] (['/portal/ekpbms3/home/tfesenbecker/excalibur_work/merged/mc16_mm_BCDEFGH_DYJets_Madgraph.root'] #+['/ceph/tberger/excalibur_results/2019-07-25/data16_mm_'+x+'_DoMu17Jul2018.root' for x in datalist], #+['/ceph/tberger/excalibur_results/2019-07-25/data16_mm_BCDEFGH_SiMu17Jul2018.root'])*2, +['/portal/ekpbms3/home/tfesenbecker/excalibur_work/merged/data16_mm_BCDEFGH_07Aug2017.root'])*2, #'www': 'calibration_DoMu_zmassfit_'+cuts+'_'+jec, 'www': 'calibration_SiMu_zmassfit_'+cuts+'_'+jec, 'nicks': ['MC','Data'], 'corrections': [jec] if not 'Res' in jec else ['L1L2L3',jec], #'weights': ['alpha>0.05'], 'zjetfolders': [cuts], 'lumis': [35.9], 'texts': [r"$\\bf{CMS} \\hspace{0.5} \\it{Preliminary}$"], #'texts': [r"$\\bf{CMS} \\hspace{0.5} \\it{Preliminary}$",r"$\\bf{"+jec+"}$",cuts], 'texts_size': [20], 'texts_y': [1.09],#,0.95,0.85], 'texts_x': [0.1], #'texts_y': [1.07,0.1,0.2],#,0.95,0.85], 'labelsize': 25, 'filename': obs, 'x_expressions': [obs], 'x_label': obs, 'x_bins': obs, 'analysis_modules': ['NormalizeToFirstHisto','Ratio','FunctionPlot'], 'labels': ['Simulation','Data'], 'markers': ['fill','o','.'], 'colors': ['steelblue','black','black','royalblue','dimgray'], 'alphas': [0.7], 'function_fit': ['MC','Data'], 'function_nicknames': ['fit_MC','fit_Data'], 'functions': '([4]*TMath::Voigt(x-[0],[1],2.4952)+[2]*x+[3])', #'functions': '[3]*TMath::Voigt(x-[0],[1],[2])', #'functions': '[2]/((x-[0])**2+[1]**2)', #'functions': '[2]*exp((x-[0])**2/[1]**2/2)', 'function_parameters': '90,2.3,0.,0.,100000', 'y_subplot_lims': [0.75,1.25], 'labels': ['Simulation','Data'], 'plot_modules': ['PlotMplZJet','PlotExtrapolationText'], 'extrapolation_text_nicks': ['fit_MC','fit_Data'], 'extrapolation_text_colors': ['royalblue','dimgray'], 'extrapolation_text_size': 15, 'ratio_numerator_nicks': ['Data'], 'ratio_denominator_nicks': ['MC'], 'ratio_result_nicks': ['Ratio'], 'ratio_denominator_no_errors': False, 'x_errors': True, 'subplot_nicks': ['Ratio'], 'subplot_fraction': 40, #'subplot_legend': 'upper left', 'y_subplot_label': 'Data/Sim', }) plots.append(d) return [PlottingJob(plots=plots, args=args)]
def get_fsr_correction(args=None): plots = [] for year in ['16',]: for obs in ['abs(genzy)']: d = ({ 'files' : ['work/mc16_Spring16_ml.root','work/mc16_origmuonsNLO.root'], 'folders' : ['genzcuts/ntuple'], 'nicks' : ['postfsr', 'prefsr'], 'x_expressions': [obs], 'labels' : ['factor'], 'x_errors': [1], 'title' : 'Simulation', 'plot_modules' : ['ExportRoot'], 'file_mode': ('RECREATE'), 'output_dir' : 'files/'+year+'/', 'energies' : [13], 'markers': ['.','_','_','_','_','_','_','_','_','_','_'], 'analysis_modules' : ['Divide', 'SumOfHistograms', 'FunctionPlot', 'PrintBinContent'], 'divide_numerator_nicks' : ['prefsr', 'prefsr'], 'divide_denominator_nicks' : ['prefsr','postfsr'], 'divide_result_nicks' : ['one','div'], "sum_nicks" : ['div one'], "sum_scale_factors" : ["1 -1"], "sum_result_nicks" : ['factor'], 'nicks_blacklist' : ['div','fsr', 'one'], 'colors' : ['black'], 'functions': ['[0]'], 'function_fit': ['factor'], 'function_parameters': ['0.07'], 'function_ranges': ['30,1000'], 'function_nicknames': ['fit'], "filename" : 'correction_fsr_'+obs, 'x_label' : r'$\\mathit{p}_{T}^{Z}$ / GeV', }) if obs == 'genzpt': d['x_bins'] = [binzpt] d['function_ranges'] = ['30,1000'] elif obs == 'abs(genzy)': d['function_ranges'] = ['0,2.3'] d['x_expressions'] = 'abs(genzy)' d['x_bins'] = ['23,0,2.3'] plots.append(d) elif obs == 'zy': d['x_bins'] = ['46,-2.3,2.3'] plots.append(d) elif obs == 'zmass': d['x_bins'] = ['20,81,101'] plots.append(d) elif obs == 'genphistareta': d['x_bins'] = [binsphistar], d['function_ranges'] = ['0.5,25'] d['folders'] = 'genleptoncuts/ntuple' d['weights'] = '(genzpt>5)' plots.append(d) return [PlottingJob(plots=plots, args=args)]
def response_time_dependence(args=None, additional_dictionary=None): """ Plot the response vs time (run-number) for different eta regions""" plots = [] etabins = binningsZJet.BinningsDictZJet().binnings_dict["abseta"].split( " ") weights = [ "{}<abs(jet1eta)&&{}>abs(jet1eta)".format(lower, upper) for lower, upper in zip(etabins, etabins[1:]) ] labels = [ r"{:.2f}<|$\\eta_{{jet}}$|<{:.2f}".format(float(lower), float(upper)) for lower, upper in zip(etabins, etabins[1:]) ] for response in ['mpf', 'ptbalance']: d = { # input 'zjetfolders': ['noetacuts'], 'x_expressions': 'run', 'y_expressions': response, 'weights': weights, 'tree_draw_options': 'prof', # analysis 'analysis_modules': ['FunctionPlot'], 'functions': ['[0]+[1]*x'], 'function_fit': ['nick{}'.format(i) for i in range(len(weights))], 'function_parameters': ['1,1'], 'function_nicknames': ['fnick{}'.format(i) for i in range(len(weights))], # formatting 'y_lims': [0.8, 1.1], 'alphas': [0.3], 'colors': ['black', 'red', 'blue', 'green', 'purple', 'orange', 'cyan' ][:len(weights)] * 2, # TODO take color names directly from plotmpl.py # TODO improve x-axis ticks and ticklabels 'labels': labels + [None] * len(labels), 'legend_cols': 2, # output 'filename': 'time_dependence_' + response, } if response == 'mpf': d['legend'] = 'lower left' if additional_dictionary: d.update(additional_dictionary) plots.append(d) return [PlottingJob(plots=plots, args=args)]
def comp_cross_section_double_diff(args=None): "prints double differential cross sections" plots = [] for obs, obs2 in zip(['zpt', 'phistareta'], ['zpt', 'phistar']): d = ({ 'files' : ['files/16/unfolded_data_'+obs+'_1_mean.root','files/16/unfolded_data_'+obs+'_2_mean.root','files/16/unfolded_data_'+obs+'_3_mean.root', 'files/16/unfolded_data_'+obs+'_4_mean.root','files/16/unfolded_data_'+obs+'_5_mean.root','files/'+theory+'/y0_'+obs2+'_CT14nlo_as_0118.root','files/'+theory+'/y1_'+obs2+'_CT14nlo_as_0118.root','files/'+theory+'/y2_'+obs2+'_CT14nlo_as_0118.root','files/'+theory+'/y3_'+obs2+'_CT14nlo_as_0118.root','files/'+theory+'/y4_'+obs2+'_CT14nlo_as_0118.root'], 'folders' : '', 'nicks' : ['data1', 'data2','data3','data4', 'data5','nnpdf1', 'nnpdf2', 'nnpdf3', 'nnpdf4', 'nnpdf5'], 'x_expressions': ['unfolded','unfolded','unfolded','unfolded','unfolded','0','0','0','0','0'], 'y_errors' : False, 'x_errors': [0,0,0,0,0,1,1,1,1,1], 'lumis': lumi['16'], 'energies' : [13], 'markers': ['o','d','^','s','*','_','_','_','_','_','o','d','^','s','*'], 'legend' : 'None', #'plot_modules' : ['PlotMplZJet', 'PlotMplLegendTable'], #"legend_table_row_headers" : [r"$|y^\\mathrm{Z}|<0.4 \\ (\\cdot 10^{5})$", r"$0.4<|y^\\mathrm{Z}|<0.8 \\ (\\cdot 10^{4})$", r"$0.8<|y^\\mathrm{Z}|<1.2 \\ (\\cdot 10^{3})$", r"$1.2<|y^\\mathrm{Z}|<1.6 \\ (\\cdot 10^{2})$",r"$1.6<|y^\\mathrm{Z}|<2.0 \\ (\\cdot 10^{1})$",r"$2.0<|y^\\mathrm{Z}|<2.3$"], #"legend_table_row_headers" : ['test1', 'test2', 'test3', 'test4'], #"legend_table_column_headers" : ['Data', 'CT14'], #'legend_table_invert' : False, 'analysis_modules' : ['Ratio','PrintBinContent'], 'ratio_numerator_nicks' : ['data1','data2','data3','data4','data5'], 'ratio_denominator_nicks' : ['nnpdf1','nnpdf2','nnpdf3','nnpdf4','nnpdf5'], 'y_subplot_label' : 'Data/Theory', 'colors' : ['black','blue','red','green','purple', 'black','blue','red','green','purple', 'black','red','blue','green','purple'], "filename" : 'sim_comp_'+obs+'_over_y', 'x_log' : True, 'y_subplot_lims' : [0.60,1.40], 'y_subplot_ticks' : [0.6, 0.8, 1, 1.2, 1.4], 'scale_factors' : [fsr_factor+'e4', fsr_factor+'e3', fsr_factor+'e2', fsr_factor+'e1',fsr_factor, 10000, 1000,100,10, 1], 'y_log' : True, }) if(obs == 'zpt'): d.update({ 'x_label' : r'$\\mathit{p}_{T}^{Z}$ / GeV', 'y_label' : r"$\\frac{d\\sigma}{d\\mathit{p}_{T}^{Z}d|y_\\mathrm{Z}|}$ / pb $\\mathrm{GeV}^{-1}$", 'y_lims' : [0.00001, 60000], 'x_bins' : [binzpt], 'x_ticks' : tickszpt, 'x_lims' : [40, 400] }) if(obs == 'phistareta'): d.update({ 'x_label' : r'$\\phi^*_\\eta$', 'y_label' : r"$\\frac{d\\sigma}{d\\phi^*_\\eta d|y_\\mathrm{Z}|}$ / pb ", 'y_lims' : [0.00001, 10000000], 'x_bins' : [binsphistar], 'x_ticks' : ticksphistar, 'x_lims' : [0.4, 25] }) plots.append(d) return [PlottingJob(plots=plots, args=args)]
def jet_resolution(args=None, additional_dictionary=None): """Plot the jet resolution vs pt, abs(eta) and npv.""" plots = [] methoddict = { 'mpf': 'MPF', 'ptbalance': r'$\\mathit{p}_T$ balance', 'trueresponse': r'$p_T^\\mathrm{reco}$/$p_T^\\mathrm{ptcl}$', } for quantity in ['zpt', 'npv', 'jet1abseta']: for method in ['mpf', 'ptbalance']: d = { 'cutlabel': True, 'corrections': ['L1L2L3Res', 'L1L2L3'], 'x_expressions': quantity, 'x_bins': [quantity], 'x_errors': [True], 'x_log': (True if quantity == 'zpt' else False), 'y_expressions': [method, method, method], #'y_lims': [0.0, 0.5], 'y_label': 'Jet resolution ({})'.format(methoddict[method]), 'colors' : ['black','red','blue','green'], 'markers': ['o', 'd', '^', 's'], 'x_errors': [True], 'tree_draw_options': 'profs', 'analysis_modules': ['ConvertToHistogram', 'StatisticalErrors',], 'stat_error_nicks': ['puppi', 'chs', 'chspuidtight','chspuidmedium' ], 'convert_nicks': ['puppi', 'chs', 'chspuidtight', 'chspuidmedium'], 'nicks': ['puppi', 'chs', 'chspuidtight', 'chspuidmedium'], 'filename': 'jet_resolution_{0}_vs_{1}'.format(method, quantity), } if ad != None: d.update(ad) if method == 'trueresponse': d['weights'] = ['matchedgenjet1pt > 0'] if quantity == 'zpt': d['x_lims'] = [30, 1000] d['x_ticks'] = [30, 50, 70, 100, 200, 400, 1000] elif quantity == 'jet1abseta': if d['zjetfolders'][0] == 'finalcuts': d['zjetfolders'] = ['noetacuts'] elif d['zjetfolders'][0] == 'noalphacuts': d['zjetfolders'] = ['noalphanoetacuts'] d['x_lims'] = [0, 5.2] elif quantity == 'npv': d['x_lims'] = [0, 40] plots.append(d) if additional_dictionary != None: for plot in plots: plot.update(additional_dictionary) return [PlottingJob(plots=plots, args=args)]
def alpha_efficiency(args=None, additional_dictionary=None): '''Calculate the fraction of passed events and matched 2nd jets in dependance of the height of the alpha cut''' plots = [] ad = {"files" : [], "corrections": [], "algorithms": [], 'labels': []} for quant in ['events', 'matched']: #2 plots: passed events, and matched 2nd jets d = { 'cutlabel': True, 'x_expressions': [], 'weights' : [], 'filename' : 'alpha_efficiency'+quant, 'zjetfolders' : 'noalphacuts', 'nicks' : ['puppi', 'chs', 'chspuidtight', 'chspuidmedium','puppia', 'chsa', 'chspuidtighta', 'chspuidmediuma'], 'divide_denominator_nicks' : ['puppi', 'chs', 'chspuidtight', 'chspuidmedium'], "divide_numerator_nicks" : ['puppia', 'chsa', 'chspuidtighta', 'chspuidmediuma'], "divide_result_nicks" : ['puppi_eff', 'chs_eff', 'chspuidtight_eff', 'chspuidmedium_eff'], 'nicks_whitelist': ['puppi_eff', 'chs_eff', 'chspuidtight_eff', 'chspuidmedium_eff'], 'analysis_modules': ['Divide', 'ConvertToTGraphErrors'], 'colors' : ['black','red','blue', 'green'], 'x_bins' : ['0.025 0.075 0.125 0.175 0.225 0.275 0.325'], 'x_label': r"$\\alpha_\\mathrm{max}$", 'texts': [r"MC $\\mathrm{Z} \\mathit{\\rightarrow} \\mathrm{\\mu \\mu}$"], 'texts_x': [0.4], 'texts_y': [1.06], 'texts_size': [16], 'www' : additional_dictionary['www'], 'zjetfolders' : 'noalphacuts', 'x_lims' : [0.025,0.325], 'y_lims' : [0,1], } d2 = copy.deepcopy(d) for amax in range(5, 35, 5): # Steps of alpha, where fractions are calculated d['x_expressions'] += [(str(amax/100.))]*8 d2['x_expressions'] += [(str(amax/100.))]*8 for quantity in ["files", "corrections", "algorithms", "labels"]: #Copy everything for each step ad[quantity]+=(additional_dictionary[quantity]) d.update(ad) d2.update(ad) if quant == 'events': d['weights'] += ['1']*4 #Denominator: All events d['weights'] += ['alpha<'+str(amax/100.)]*4 #Numerator: Events that pass d['y_label'] = 'Fraction of passed events' elif quant == 'matched': d2['weights'] += ['alpha<'+str(amax/100.)]*4 #Denominator: All events that pass d2['weights'] += ['alpha<'+str(amax/100.)+'&matchedgenjet2pt>0']*4 #Numerator: Events that pass and have matched 2nd jet d2['y_label'] = 'Fraction of matched 2nd jets' if quant == 'events': plots.append(d) else: plots.append(d2) return [PlottingJob(plots=plots, args=args)]
def fit_function(args=None, additional_dictionary=None, only_normalized=False, channel='m', quantity_list=None): if quantity_list is None: quantity_list = [] plots = [] for quantity in quantity_list: d = { 'x_expressions': [quantity], 'cutlabel': True, 'analysis_modules': [], 'plot_modules': ['PlotMplZJet'], 'filename': 'Z' + channel + channel + '_' + quantity.replace('/', '%') + '_fit', 'legend': 'center left', 'y_subplot_lims': [0.75, 1.25], 'alphas': '0.5', 'markers': ['_', '_', 'fill', 'fill'], 'colors': ['black', 'blue', 'black'], 'ratio_denominator_nicks': ['nick1'], 'ratio_numerator_nicks': ['nick0'], 'output_dir': "plots/%s/" % datetime.date.today().strftime('%Y_%m_%d') } if quantity in binningsZJet.BinningsDictZJet().binnings_dict: x_bins = binningsZJet.BinningsDictZJet().binnings_dict[quantity].replace('000', '0') x_lims = lims_from_binning(x_bins) d['x_bins'] = [x_bins] # d['x_bins'] = '400,0,2' # d['x_lims'] = x_lims if additional_dictionary: d.update(additional_dictionary) if len(d['files']) == 2: fit_function_datamc_gauss(d) d['analysis_modules'] = d['analysis_modules'] + ['Ratio'] elif len(d['files']) == 1: # pass fit_function_mc_gauss(d) # fit_function_mc_doublegauss(d) # fit_function_mc_crystalball(d) if False: if channel == 'e': d['function_ranges'] = '0.87225,1.15225' # for jet1pt/genjet1pt with 0.25<=alpha<0.3, 94.0% truncation if channel == 'm': d['function_ranges'] = '0.77925,1.22825' # for jet1pt/genjet1pt with 0.25<=alpha<0.3, 98.5% truncation if only_normalized: # shape comparison d['analysis_modules'] = d['analysis_modules'] + ['NormalizeToFirstHisto'] d['filename'] = 'Z' + channel + channel + '_' + quantity.replace('/', '%') + '_shapeComparison' plots.append(d) return [PlottingJob(plots=plots, args=args)]
def basic_profile_comparisons(args=None, additional_dictionary=None): """ Some basic profile plots. """ plots = [] for xquantity, yquantity in zip(['zpt'], ['zmass']): d = { 'x_expressions': [xquantity], 'y_expressions': [yquantity], 'analysis_modules': ['Ratio'], 'tree_draw_options': 'prof', 'cutlabel': True, 'y_subplot_lims': [0.99, 1.01], 'x_log': True, 'x_bins': "zpt", 'markers': ['o', 'd'], } if yquantity == 'zmass': z_mass_pdg = 91.1876 z_width_pdg = 2.4952 z_peak = 0.01 z_window = 5 d['y_lims'] = [z_mass_pdg - z_window, z_mass_pdg + z_window], d['plot_modules'] = ["PlotMplZJet", "PlotMplRectangle"] d["rectangle_y"] = [ z_mass_pdg - z_width_pdg, z_mass_pdg + z_width_pdg, z_mass_pdg - z_peak, z_mass_pdg + z_peak, ] d["rectangle_alpha"] = [0.2, 0.5] d["rectangle_color"] = ["blue", "green"] plots.append(d) for x_expression in ['npv', 'npumean']: for y_expression in ['rho', 'npv']: d = { 'x_expressions': [x_expression], 'y_expressions': [y_expression], #'y_lims':[0,30], 'analysis_modules': ['Ratio'], 'tree_draw_options': 'prof', 'cutlabel': True, 'markers': ['o', 'd'], 'y_subplot_lims': [0.5, 1.5], 'x_bins': "25,0.5,25.5", 'legend': 'lower right', } if (x_expression == 'npv' and y_expression == 'rho'): d['y_lims'] = [0, 30] plots.append(d) if additional_dictionary != None: for plot in plots: plot.update(additional_dictionary) return [PlottingJob(plots=plots, args=args)]
def response_comparisons(args2=None, additional_dictionary=None, data_quantities=True): """Comparison of Response vs. quantities as profile plot""" known_args, args = get_special_parser(args2) plots = [] # TODO put these default binning values somewhere more globally for quantity, bins in zip(*get_list_slice([ ['zpt', 'abs(jet1eta)','jet1pt','npv','run'],# 'abs(jet2eta)'] ['zpt', 'abseta','jet1pt','npv','run']#,'abseta'] ], known_args.no_quantities)): for method in get_list_slice([['ptbalance', 'mpf'] + (['trueresponse'] if not data_quantities else [])], known_args.no_methods)[0]: d = { 'y_expressions': [method], 'x_expressions': [quantity], 'x_bins': bins, 'y_lims': [0.6, 1.2], 'x_errors': [1], 'tree_draw_options': 'prof', 'markers': ['o', 's',' d'], 'cutlabel': True, 'lines': [1.0], 'analysis_modules': ['Ratio'], 'ratio_denominator_no_errors': False, 'filename': method + "_" + quantity.replace("(", "").replace(")", ""), 'y_subplot_lims': [0.9, 1.1], 'legend': 'upper right',#'lower left', } ######################################################### if method == 'mpf': d['y_lims'] = [0.8,1.2] if method == 'ptbalance': d['y_lims'] = [0.6,1.2] ######################################################### if quantity == 'abs(jet1eta)' or quantity == 'abs(jet2eta)': d['zjetfolders'] = ["noetacuts"] d['x_bins'] = ["0.001 0.261 0.522 0.783 1.044 1.305 1.479 1.653 1.930 2.172 2.322 2.500 2.650 2.853 2.964 3.139 3.489 3.839 5.191"] if quantity == 'zpt' or quantity == 'jet1pt': d['x_log'] = True d['x_bins'] = ["30 40 50 60 85 105 130 175 230 300 400 500 700 1000 1500 2000"] d['x_ticks'] = [30, 50, 70, 100, 200, 400, 1000] if quantity == 'npv': d['x_bins']=["1 5 10 12 15 20 25 30 50"] if quantity == 'run': d['x_bins']=['40,297000,304000'] if method == 'trueresponse': d['filename'] = "true_response__vs__" + quantity d['weights'] = "matchedgenjet1pt>0" if additional_dictionary != None: d.update(additional_dictionary) plots.append(d) return [PlottingJob(plots=plots, args=args)]
def response_comparisons(args2=None, additional_dictionary=None, data_quantities=True): """Response (MPF/pTbal) vs zpt npv abs(jet1eta), with ratio""" known_args, args = get_special_parser(args2) plots = [] # TODO put these default binning values somewhere more globally for quantity, bins in zip(*get_list_slice( [['zpt', 'npv', 'abs(jet1eta)'], ['zpt', 'npv', 'abseta']], known_args.no_quantities)): for method in get_list_slice( [['ptbalance', 'mpf'] + (['trueresponse'] if not data_quantities else [])], known_args.no_methods)[0]: d = { 'y_expressions': [method], 'x_expressions': [quantity], 'x_bins': bins, 'y_lims': [0.6, 1.2], 'x_errors': [1], 'tree_draw_options': 'prof', 'markers': ['o', 's'], 'cutlabel': True, 'lines': [1.0], 'analysis_modules': ['Ratio'], 'ratio_denominator_no_errors': False, 'filename': method + "_" + quantity.replace("(", "").replace(")", ""), 'y_subplot_lims': [0.9, 1.1], 'legend': 'lower left', } if quantity == 'abs(jet1eta)': d['zjetfolders'] = ["noetacuts"] if quantity == 'zpt': d['x_log'] = True d['x_ticks'] = [30, 50, 70, 100, 200, 400, 1000] if method == 'trueresponse': d['filename'] = "true_response__vs__" + quantity d['weights'] = "matchedgenjet1pt>0" if additional_dictionary != None: d.update(additional_dictionary) plots.append(d) return [PlottingJob(plots=plots, args=args)]