def efficiency_plots(d_sample, var_name, hdict): graphs = [] graphs_eta = [] for rel, rdict in d_sample.items(): tree = rdict['tree'] if 'leaves' not in rdict: rdict['leaves'] = [leaf.GetName() for leaf in tree.GetListOfLeaves()] used_vars = word_finder(hdict['var']) if not set(used_vars).issubset(rdict['leaves']): warnings.warn( var_name + ' is missing in input file ' + rdict['file'].GetName()) return num_sel = reco_cut den_sel = '1' discriminators = {"loose_id": den_sel} if 'against' in var_name: den_sel = reco_cut + ' && ' + loose_id for mvaIDname, sel in discriminators.items(): graphs.append(makeEffPlotsVars(tree=tree, varx='tau_genpt', numeratorAddSelection=num_sel + '&&' + hdict['var'], baseSelection=sel + '&& abs(tau_eta) < 2.3', binning=ptPlotsBinning, xtitle=options_dict[runtype].xlabel, header=rel + mvaIDname, addon=rel + mvaIDname, marker=rdict['marker'], col=rdict['col'])) graphs_eta.append(makeEffPlotsVars(tree=tree, varx='tau_geneta', numeratorAddSelection=num_sel + '&&' + hdict['var'], baseSelection=sel + '&& tau_pt>20', binning=etaPlotsBinning, xtitle=options_dict[runtype].xlabel_eta, header=rel + mvaIDname, addon=rel + mvaIDname, marker=rdict['marker'], col=rdict['col'])) overlay(graphs=graphs, header=var_name, addon=hdict['title'], runtype=runtype, tlabel=options_dict[runtype].tlabel) overlay(graphs=graphs_eta, header=var_name + '_eta', addon=hdict['title'] + '_eta', runtype=runtype, tlabel=options_dict[runtype].tlabel)
def efficiency_plots(d_sample, var_name, hdict): graphs = [] graphs_eta = [] for rel, rdict in sorted(d_sample.items(), key=lambda item: item[1]["index"]): tree = rdict['tree'] if 'leaves' not in rdict: rdict['leaves'] = [ leaf.GetName() for leaf in tree.GetListOfLeaves() ] used_vars = word_finder(hdict['var']) if not set(used_vars).issubset(rdict['leaves']): with open('missing_leaves.txt', 'a+') as f: print >> f, var_name + ' is missing in input file ' + rdict[ 'file'].GetName() warnings.warn(var_name + ' is missing in input file ' + rdict['file'].GetName()) return num_sel = reco_cut den_sel = '1' discriminators = {"": den_sel} if 'against' in var_name: den_sel = gen_cut + ' && ' + loose_id rel = "tauReco @ miniAOD" if rel == "slimmedTaus_slimmedTaus" else "tauReco @ AOD" for mvaIDname, sel in discriminators.items(): graphs.append( makeEffPlotsVars(tree=tree, varx='tau_genpt', numeratorAddSelection=num_sel + '&&' + hdict['var'], baseSelection=sel, binning=ptPlotsBinning, xtitle=options_dict[runtype].xlabel, header=rel + mvaIDname, addon=rel + mvaIDname, marker=rdict['marker'], col=rdict['col'])) graphs_eta.append( makeEffPlotsVars(tree=tree, varx='tau_geneta', numeratorAddSelection=num_sel + '&&' + hdict['var'], baseSelection=sel, binning=etaPlotsBinning, xtitle=options_dict[runtype].xlabel_eta, header=rel + mvaIDname, addon=rel + mvaIDname, marker=rdict['marker'], col=rdict['col'])) overlay(graphs=graphs, header=var_name, addon=hdict['title'], runtype=runtype, tlabel=options_dict[runtype].tlabel) overlay(graphs=graphs_eta, header=var_name + '_eta', addon=hdict['title'] + '_eta', runtype=runtype, tlabel=options_dict[runtype].tlabel)
def eff_plots_single(d_sample, vars_to_compare, var_dict): '''Adapted from Olena's code - can possibly merge it with efficiency_plots ''' if not vars_to_compare: return hists = [] histseta = [] for index, var_name in enumerate(vars_to_compare): hdict = var_dict[var_name] if varyLooseId and 'IsolationMVA' in var_name: loose_id = 'tau_decayModeFindingOldDMs > 0.5 && ' + findLooseId( var_name) for _, rdict in sorted(d_sample.items(), key=lambda item: item[1]["index"]): tree = rdict['tree'] if 'leaves' not in rdict: rdict['leaves'] = [ leaf.GetName() for leaf in tree.GetListOfLeaves() ] used_vars = word_finder(hdict['var']) if not set(used_vars).issubset(rdict['leaves']): warnings.warn(var_name + ' is missing in input file ' + rdict['file'].GetName()) return num_sel = reco_cut den_sel = '1' discriminators = {"loose_id": den_sel} if 'against' in var_name: den_sel = gen_cut + ' && ' + loose_id for mvaIDname, sel in discriminators.items(): dprint("\n\tmvaIDname:", mvaIDname, "hdict['var']:", hdict['var']) hists.append( makeEffPlotsVars(tree=tree, varx='tau_genpt', numeratorAddSelection=num_sel + '&&' + hdict['var'], baseSelection=sel, binning=ptPlotsBinning, xtitle=options_dict[runtype].xlabel, header=var_name + mvaIDname, addon=var_name + mvaIDname, marker=rdict['marker'], col=int(colors[index]))) shiftAlongX(hists[-1], len(vars_to_compare), index) histseta.append( makeEffPlotsVars(tree=tree, varx='tau_geneta', numeratorAddSelection=num_sel + '&&' + hdict['var'], baseSelection=sel, binning=etaPlotsBinning, xtitle=options_dict[runtype].xlabel_eta, header=var_name + mvaIDname, addon=var_name + mvaIDname, marker=rdict['marker'], col=int(colors[index]))) shiftAlongX(histseta[-1], len(vars_to_compare), index) overlay(graphs=hists, header=vars_to_compare[0], addon=hdict['title'], runtype=runtype, tlabel=options_dict[runtype].tlabel, comparePerReleaseSuffix="_comparePerRelease") overlay(graphs=histseta, header=vars_to_compare[0] + '_eta', addon=hdict['title'] + '_eta', runtype=runtype, tlabel=options_dict[runtype].tlabel, comparePerReleaseSuffix="_comparePerRelease")