def CopyHists(infile, outfile, prefix = ''): from load_data import TprimeData _hists = TprimeData(1) _hists.load_all_hists(infile, prefix) _hists.SaveAllHists(outfile) return
def ProjectOnHt(infile, outfile, prefix = ''): from load_data import TprimeData _hists = TprimeData(1) _hists.load_all_hists(infile, projection_y = True, rebin_ngroup = 4, rebin_low = 200, rebin_high = 2000, prefix=prefix) _hists.SaveAllHists(outfile) return
def MakeSignalBoxDiagonal(infile, outfile, prefix = '', mass = None, signal_only = False): from load_data import TprimeData _hists = TprimeData(1) _hists.load_all_hists(infile, prefix=prefix) _hists.ConvertToSignalDiagonal(mass,signal_only=signal_only) _hists.SaveAllHists(outfile) return
def MakeSignalBoxTemplates(infile, outfile, prefix = '', xmin = None, xmax = None, ymin = None, ymax = None, signal_only = False): from load_data import TprimeData _hists = TprimeData(1) _hists.load_all_hists(infile, prefix=prefix) _hists.ConvertToSignalBox(xmin, xmax, ymin, ymax, signal_only=signal_only) _hists.SaveAllHists(outfile) return
def MakeSignalMassDiagPerp(infile, outfile, prefix = '', mass = None, rebin_ngroup = None, rebin_low = None, rebin_high= None ): from load_data import TprimeData _hists = TprimeData(1) _hists.load_all_hists(infile, prefix=prefix) _hists.ConvertToMassDiagPerp(mass,rebin_ngroup,rebin_low,rebin_high) _hists.SaveAllHists(outfile) return
def CreateTemplates(options): # # create two "standard" files with "plus" and "minus" # shape templates for POWHEG-Nominal difference # Since there is only one POWHEG template, the idea is # to interpolate in some way between it and the nominal one # legend = '[tprime_powheg.CreateTemplates]:' channels = ['e', 'mu'] input_nom = {} input_pow = {} input_nom[ 'mu'] = 'data/mujets_4600/from_gueorgi/27jan2011v1/csv/v1/mujets_4601ipb_2D_v1_csv_jer_nom.root' input_pow[ 'mu'] = 'data/mujets_4600/from_gueorgi/27jan2011v1/csv/v1/mujets_4601ipb_2D_v1_csv_POWHEG.root' input_nom[ 'e'] = 'data/ejets_4700/ricardo_4683ipb_2d_csv_22jan2012v2/ht4jetsAfterFit_vs_fitMass.root' input_pow[ 'e'] = 'data/ejets_4700/ricardo_4683ipb_2d_csv_22jan2012v2/ht4jetsAfterFit_vs_fitMass_powheg.root' hist_name = {} hist_name['e'] = 'Top_ht4jetsAfterFit:fitMass' hist_name['mu'] = 'TTjets_HtvsMfit' for chan in channels: data = TprimeData() data_powheg = TprimeData() _suffix = '' data.load_all_hists(input_nom[chan], merge_ewk=False, merge_top=False, strip_suffix=False, suffix=_suffix) data_powheg.load_all_hists(input_pow[chan], merge_ewk=False, merge_top=False, strip_suffix=False, suffix=_suffix) hPlus = copy.deepcopy(data.hists[hist_name[chan]]) hMinus = copy.deepcopy(data_powheg.hists[hist_name[chan]]) hPlus.SetMarkerColor(ROOT.kRed) #hMinus.Draw() #hPlus.Draw('same') #raw_input('press enter to continue') hNom = copy.deepcopy(hMinus) hNom.Add(hPlus) hNom.Scale(0.5) # save nominal data.hists.pop(hist_name[chan]) iTop = 0 for name in data.hist_names: if name == hist_name[chan]: break iTop += 1 data.hist_names.pop(iTop) data.AddHist(hNom) data.SaveAllHists(chan + '_powheg_nom.root') # save minus data.hists.pop(hist_name[chan]) iTop = 0 for name in data.hist_names: if name == hist_name[chan]: break iTop += 1 data.hist_names.pop(iTop) data.AddHist(hMinus) data.SaveAllHists(chan + '_powheg_minus.root') # save plus data.hists.pop(hist_name[chan]) iTop = 0 for name in data.hist_names: if name == hist_name[chan]: break iTop += 1 data.hist_names.pop(iTop) data.AddHist(hPlus) data.SaveAllHists(chan + '_powheg_plus.root')
doMerge = True elif options.action and options.action == "add_hist": doAddHist = True elif options.action and options.action == "toys": doToys = True ######################################## # # ---- main # legend = '[tprime]:' ds = TprimeData(821.0) if doTest: print 'TEST' #ds.generate_hists(options.test) ds.load_all_hists(infile, merge_ewk=options.merge_ewk) _map={} _map['Ewk_ht35:fitMass'] = 392 _map['Top_ht35:fitMass'] = 1685 ds.CreatePseudoData('pseudoData', _map) ds.list(options.hist_pattern) if (options.combine_bins) or (options.action and options.action == "combine_bins"): from combine_bins import * prefix = ''
def CombineBins(mass, scale, maxErr, infile, outfile, prefix = '', method = 'brown', make_plots = False, maxErrSig = 10.0, channel = "ljets"): # # Main function that gets invoked in this module # Main mapping is loaded from combineBins.C # legend = '[combine_bins]:' # FIXME: dummy now, need to remove #channel = 'ljets' if channel==None: print legend, 'no channel specified, exiting' return if "brown" in method: if method == 'brown_smooth': print legend, 'combine bins with Brown smooth algo (EPS2011), using S/B' ROOT.gROOT.ProcessLine('.L combineBinsSmooth.C+') from ROOT import combineBins print '####################', maxErrSig, float(maxErrSig) print channel, int(mass), float(scale), float(maxErr), infile, outfile, prefix, make_plots, 0.2 combineBins(channel, int(mass), float(scale), float(maxErr), infile, outfile, prefix, make_plots, 0.2) #float(maxErrSig)) elif method == 'brown': print legend, 'combine bins with Brown algo (EPS2011), using S/B' ROOT.gROOT.ProcessLine('.L combineBins.C+') from ROOT import combineBins combineBins(channel, int(mass), float(scale), float(maxErr), infile, outfile, prefix, make_plots, float(maxErrSig)) elif method == 'brown_2d': print legend, 'combine bins with Brown 2D algo, using S/B' ROOT.gROOT.ProcessLine('.L combineBins_2d.C+') from ROOT import combineBins combineBins(channel, int(mass), float(scale), float(maxErr), infile, outfile, prefix, make_plots, float(maxErrSig)) elif method == 'brown_mike': ROOT.gROOT.ProcessLine('.L brownNxNGang.C+') print legend, 'combine bins with 4x4 + Brown algo (EPS2011), using S/B' from ROOT import rebin rebin( int(mass), float(scale), float(maxErr), infile, outfile, make_plots) elif method == 'davis': print legend, 'combine bins with Davis algo' ROOT.gROOT.ProcessLine('.L davisGang.C+') from ROOT import rebin rebin( int(mass), float(scale), float(maxErr), infile, outfile) elif method == 'copy': print legend, 'just copy all the histograms unchanged' CopyHists(infile, outfile, prefix) elif method == 'mass': print legend, 'combine bins projecting on mass axis and rebinning' ProjectOnMass(infile, outfile, prefix) from load_data import TprimeData _hists = TprimeData(1) elif method == 'ht': print legend, 'combine bins projecting on HT axis and rebinning' ProjectOnHt(infile, outfile, prefix) from load_data import TprimeData _hists = TprimeData(1) elif method == 'signal_box_1bin': print legend, 'combine bins in and out a signal box' MakeSignalBoxTemplates(infile, outfile, prefix, xmin=float(mass)*0.9, xmax=float(mass)*1.1, ymin = 700.0, ymax = 2000.0, signal_only = True) elif method == 'signal_box_2bin': print legend, 'combine bins in and out a signal box' MakeSignalBoxTemplates(infile, outfile, prefix, xmin=float(mass)*0.9, xmax=float(mass)*1.1, ymin = 700.0, ymax = 2000.0, signal_only = False) elif method == 'signal_box_diagonal': print legend, 'combine bins 1d diagonally' MakeSignalBoxDiagonal(infile, outfile, prefix, float(mass), signal_only = False) elif method == 'signal_mass_diagonal': MakeSignalMassDiagonal(infile, outfile, prefix, float(mass), rebin_ngroup = 5, rebin_low = 100, rebin_high= 700 ) elif method == 'signal_mass_diag_perp': MakeSignalMassDiagPerp(infile, outfile, prefix, float(mass), rebin_ngroup = 5, rebin_low = 100, rebin_high= 700 ) else: print legend, 'no valid method for combine bins specified...' sys.exit(1)
def CreateTemplates(options): # # create two "standard" files with "plus" and "minus" # shape templates for POWHEG-Nominal difference # Since there is only one POWHEG template, the idea is # to interpolate in some way between it and the nominal one # legend = '[tprime_powheg.CreateTemplates]:' channels = ['e','mu'] input_nom = {} input_pow = {} input_nom['mu'] = 'data/mujets_4600/from_gueorgi/27jan2011v1/csv/v1/mujets_4601ipb_2D_v1_csv_jer_nom.root' input_pow['mu'] = 'data/mujets_4600/from_gueorgi/27jan2011v1/csv/v1/mujets_4601ipb_2D_v1_csv_POWHEG.root' input_nom['e'] = 'data/ejets_4700/ricardo_4683ipb_2d_csv_22jan2012v2/ht4jetsAfterFit_vs_fitMass.root' input_pow['e'] = 'data/ejets_4700/ricardo_4683ipb_2d_csv_22jan2012v2/ht4jetsAfterFit_vs_fitMass_powheg.root' hist_name = {} hist_name['e'] = 'Top_ht4jetsAfterFit:fitMass' hist_name['mu'] = 'TTjets_HtvsMfit' for chan in channels: data = TprimeData() data_powheg = TprimeData() _suffix = '' data.load_all_hists(input_nom[chan], merge_ewk=False, merge_top=False, strip_suffix = False, suffix = _suffix ) data_powheg.load_all_hists(input_pow[chan], merge_ewk=False, merge_top=False, strip_suffix = False, suffix = _suffix ) hPlus = copy.deepcopy(data.hists[ hist_name[chan] ]) hMinus = copy.deepcopy(data_powheg.hists[ hist_name[chan] ]) hPlus.SetMarkerColor(ROOT.kRed) #hMinus.Draw() #hPlus.Draw('same') #raw_input('press enter to continue') hNom = copy.deepcopy(hMinus) hNom.Add(hPlus) hNom.Scale(0.5) # save nominal data.hists.pop( hist_name[chan] ) iTop = 0 for name in data.hist_names: if name == hist_name[chan]: break iTop += 1 data.hist_names.pop(iTop) data.AddHist(hNom) data.SaveAllHists(chan+'_powheg_nom.root') # save minus data.hists.pop( hist_name[chan] ) iTop = 0 for name in data.hist_names: if name == hist_name[chan]: break iTop += 1 data.hist_names.pop(iTop) data.AddHist(hMinus) data.SaveAllHists(chan+'_powheg_minus.root') # save plus data.hists.pop( hist_name[chan] ) iTop = 0 for name in data.hist_names: if name == hist_name[chan]: break iTop += 1 data.hist_names.pop(iTop) data.AddHist(hPlus) data.SaveAllHists(chan+'_powheg_plus.root')
doMerge = True elif options.action and options.action == "add_hist": doAddHist = True elif options.action and options.action == "toys": doToys = True ######################################## # # ---- main # legend = '[tprime]:' ds = TprimeData(821.0) if doTest: print 'TEST' #ds.generate_hists(options.test) ds.load_all_hists(infile, merge_ewk=options.merge_ewk) _map = {} _map['Ewk_ht35:fitMass'] = 392 _map['Top_ht35:fitMass'] = 1685 ds.CreatePseudoData('pseudoData', _map) ds.list(options.hist_pattern) if (options.combine_bins) or (options.action and options.action == "combine_bins"): from combine_bins import *