def main(): options = { # The main root TQSampleFolder name "master_sample_name": "samples", # Where the ntuples are located "ntuple_path": "/nfs-7/userdata/phchang/WWW_babies/WWW_v1.2.3/skim/", # Path to the config file that defines how the samples should be organized "sample_config_path": "samples.cfg", # The samples with "priority" (defined in sample_config_pat) values satisfying the following condition is looped over "priority_value": ">0", # The samples with "priority" (defined in sample_config_pat) values satisfying the following condition is NOT looped over "exclude_priority_value": "<-1", # N-cores "ncore": 4, # TQCuts config file "cuts": "cuts.cfg", # Histogram config file "histo": "histo.cfg", # Eventlist histogram "eventlist": "eventlist.cfg", # Custom observables (dictionary) "customobservables": {}, # Custom observables (dictionary) "output_dir": "outputs/" } # First generate cuts.cfg file generate_cuts_config() # Analyze loop(options) # Create plots and tables samples = TQSampleFolder.loadSampleFolder("outputs/output.root:samples") bkg_path = [ ("WWW", "/sig/www"), ("WHWWW", "/sig/whwww"), ] sig_path = [("WZ", "/bkg/WZ")] autoplot(samples, bkg_path=bkg_path, sig_path=sig_path, options={ "remove_underflow": True, "signal_scale": "auto" }) autotable(samples, "yield", bkg_path=bkg_path, sig_path=sig_path, options={"cuts": "cuts.cfg"})
#!/bin/env python import os import sys import ROOT from QFramework import TQSampleFolder, TQXSecParser, TQCut, TQAnalysisSampleVisitor, TQSampleInitializer, TQCutflowAnalysisJob, TQCutflowPrinter, TQHistoMakerAnalysisJob from rooutil import plottery_wrapper as p from plottery import plottery as ply try: tqsamplefolderpath = sys.argv[1] except: tqsamplefolderpath = "output.root" ROOT.gROOT.SetBatch(True) samples = TQSampleFolder.loadSampleFolder(tqsamplefolderpath + ":samples") samples_up = TQSampleFolder.loadSampleFolder("output_up.root:samples") samples_dn = TQSampleFolder.loadSampleFolder("output_dn.root:samples") output_plot_dir = "plots" doW = False docombinedqcdel = True testsample = "/top" testsamplename = "t#bar{t}" testsamplelegendname = "t#bar{t}" if doW: testsample = "/W/HT" #testsample = "/W" testsamplename = "W"
def compute_fake_factor_1d(th1): for ix in xrange(0, th1.GetNbinsX() + 2): frnom = th1.GetBinContent(ix) frerr = th1.GetBinError(ix) fr = E(frnom, frerr) if fr.val != 0 and fr.val != 1: ff = fr / (E(1., 0.) - fr) else: ff = E(0., 0.) th1.SetBinContent(ix, ff.val) th1.SetBinError(ix, ff.err) ROOT.gROOT.SetBatch(True) samples = TQSampleFolder.loadSampleFolder("output.root:samples") qcdloosemu = samples.getHistogram("/qcd/mu", "OneMuLoose/lep_ptcorrcoarse_vs_etacoarse") qcdtightmu = samples.getHistogram("/qcd/mu", "OneMuTight/lep_ptcorrcoarse_vs_etacoarse") qcdloosemu.Print("all") qcdtightmu.Print("all") qcdlooseel = samples.getHistogram("/qcd/el", "OneElLoose/lep_ptcorrcoarse_vs_etacoarse") qcdtightel = samples.getHistogram("/qcd/el", "OneElTight/lep_ptcorrcoarse_vs_etacoarse") qcdlooseelEM = samples.getHistogram( "/qcd/el/EM", "OneElLoose/lep_ptcorrcoarse_vs_etacoarse")
#!/bin/env python import os import sys import ROOT from QFramework import TQSampleFolder, TQXSecParser, TQCut, TQAnalysisSampleVisitor, TQSampleInitializer, TQCutflowAnalysisJob, TQCutflowPrinter, TQHistoMakerAnalysisJob from rooutil import plottery_wrapper as p from plottery import plottery as ply from rooutil.syncfiles.pyfiles.errors import E ROOT.gROOT.SetBatch(True) samples_cn = TQSampleFolder.loadSampleFolder("output.root:samples") samples_up = TQSampleFolder.loadSampleFolder("output_up.root:samples") samples_dn = TQSampleFolder.loadSampleFolder("output_dn.root:samples") output_plot_dir = "plots" #_________________________________________________________ def compute_fake_factor_1d(th1): for ix in xrange(0, th1.GetNbinsX()+2): frnom = th1.GetBinContent(ix) frerr = th1.GetBinError(ix) fr = E(frnom, frerr) if fr.val != 0 and fr.val != 1: ff = fr / (E(1., 0.) - fr) else: ff = E(0., 0.) th1.SetBinContent(ix, ff.val) th1.SetBinError(ix, ff.err) #___________________________________________________________________________
def main(model="", mass=""): samples = TQSampleFolder.loadSampleFolder("outputs/output.root:samples") samples_jec_up = TQSampleFolder.loadSampleFolder( "outputs/output_jec_up.root:samples") samples_jec_dn = TQSampleFolder.loadSampleFolder( "outputs/output_jec_dn.root:samples") options = { # Signal name and TQSampleFolder path "sig": ("www", "/sig" if model == "" else "/bsm/{}/{}".format(model, mass)), # Background names and TQSampelFolder paths "bkgs": [ ("lostlep", "/typebkg/lostlep/[ttZ+WZ+Other]"), ("fake", "/fake"), ("vbsww", "/typebkg/?/VBSWW"), ("ttw", "/typebkg/?/ttW"), ("photon", "/typebkg/photon/[ttZ+WZ+Other]"), ("qflip", "/typebkg/qflip/[ttZ+WZ+Other]"), ("prompt", "/typebkg/prompt/[ttZ+WZ+Other]" if model == "" else "/typebkg/prompt/[ttZ+WZ+Other]+sig"), ], # Data TQSampleFolder paths "data": "/data", # Counter names for getting yields "bins": [ "SRSSeeFull", "SRSSemFull", "SRSSmmFull", "SideSSeeFull", "SideSSemFull", "SideSSmmFull", "SR0SFOSFull", "SR1SFOSFull", "SR2SFOSFull", #"SRNj1SSeeFull", #"SRNj1SSemFull", #"SRNj1SSmmFull", ], # TQSampleFolder object "nominal_sample": samples, # Control regions # The control regions will normalize the counts # The systematics "control_regions": { ("SRSSeeFull", "/typebkg/lostlep/[ttZ+WZ+Other]"): ("WZCRSSeeFull", "/data-typebkg/qflip-typebkg/photon-typebkg/prompt-typebkg/fakes-typebkg/lostlep/VBSWW-typebkg/lostlep/ttW-sig" ), ("SRSSemFull", "/typebkg/lostlep/[ttZ+WZ+Other]"): ("WZCRSSemFull", "/data-typebkg/qflip-typebkg/photon-typebkg/prompt-typebkg/fakes-typebkg/lostlep/VBSWW-typebkg/lostlep/ttW-sig" ), ("SRSSmmFull", "/typebkg/lostlep/[ttZ+WZ+Other]"): ("WZCRSSmmFull", "/data-typebkg/qflip-typebkg/photon-typebkg/prompt-typebkg/fakes-typebkg/lostlep/VBSWW-typebkg/lostlep/ttW-sig" ), ("SideSSeeFull", "/typebkg/lostlep/[ttZ+WZ+Other]"): ("WZCRSSeeFull", "/data-typebkg/qflip-typebkg/photon-typebkg/prompt-typebkg/fakes-typebkg/lostlep/VBSWW-typebkg/lostlep/ttW-sig" ), ("SideSSemFull", "/typebkg/lostlep/[ttZ+WZ+Other]"): ("WZCRSSemFull", "/data-typebkg/qflip-typebkg/photon-typebkg/prompt-typebkg/fakes-typebkg/lostlep/VBSWW-typebkg/lostlep/ttW-sig" ), ("SideSSmmFull", "/typebkg/lostlep/[ttZ+WZ+Other]"): ("WZCRSSmmFull", "/data-typebkg/qflip-typebkg/photon-typebkg/prompt-typebkg/fakes-typebkg/lostlep/VBSWW-typebkg/lostlep/ttW-sig" ), ("SR1SFOSFull", "/typebkg/lostlep/[ttZ+WZ+Other]"): ("WZCR1SFOSFull", "/data-typebkg/qflip-typebkg/photon-typebkg/prompt-typebkg/fakes-typebkg/lostlep/VBSWW-typebkg/lostlep/ttW-sig" ), ("SR2SFOSFull", "/typebkg/lostlep/[ttZ+WZ+Other]"): ("WZCR2SFOSFull", "/data-typebkg/qflip-typebkg/photon-typebkg/prompt-typebkg/fakes-typebkg/lostlep/VBSWW-typebkg/lostlep/ttW-sig" ), #("SRNj1SSeeFull", "/typebkg/lostlep/[ttZ+WZ+Other]") : ("WZCRNj1SSeeFull" , "/data-typebkg/qflip-typebkg/photon-typebkg/prompt-typebkg/fakes-typebkg/lostlep/VBSWW-typebkg/lostlep/ttW-sig"), #("SRNj1SSemFull", "/typebkg/lostlep/[ttZ+WZ+Other]") : ("WZCRNj1SSemFull" , "/data-typebkg/qflip-typebkg/photon-typebkg/prompt-typebkg/fakes-typebkg/lostlep/VBSWW-typebkg/lostlep/ttW-sig"), #("SRNj1SSmmFull", "/typebkg/lostlep/[ttZ+WZ+Other]") : ("WZCRNj1SSmmFull" , "/data-typebkg/qflip-typebkg/photon-typebkg/prompt-typebkg/fakes-typebkg/lostlep/VBSWW-typebkg/lostlep/ttW-sig"), }, # Weight variation systematics that are saved in the "nominal_sample" TQSampleFolder # The nomenclature of the coutner names must be <BIN_COUNTER><SYSTS>Up and <BIN_COUNTER><SYSTS>Down # The keyword are the systematics and then the items list the processes to apply the systematics "systematics": [ ("LepSF", { "procs_to_apply": [ "www", "vbsww", "ttw", "photon", "qflip", "prompt", "lostlep" ] }), ("TrigSF", { "procs_to_apply": [ "www", "vbsww", "ttw", "photon", "qflip", "prompt", "lostlep" ] }), ("BTagLF", { "procs_to_apply": [ "www", "vbsww", "ttw", "photon", "qflip", "prompt", "lostlep" ] }), ("BTagHF", { "procs_to_apply": [ "www", "vbsww", "ttw", "photon", "qflip", "prompt", "lostlep" ] }), ("Pileup", { "procs_to_apply": [ "www", "vbsww", "ttw", "photon", "qflip", "prompt", "lostlep" ] }), ("FakeRateEl", { "procs_to_apply": ["fake"] }), ("FakeRateMu", { "procs_to_apply": ["fake"] }), ("FakeClosureEl", { "procs_to_apply": ["fake"] }), ("FakeClosureMu", { "procs_to_apply": ["fake"] }), ("PDF", { "procs_to_apply": ["www"] }), ("AlphaS", { "procs_to_apply": ["www"] }), ("Qsq", { "procs_to_apply": ["www"] }), ("JEC", { "procs_to_apply": [ "www", "vbsww", "ttw", "photon", "qflip", "prompt", "lostlep" ], "syst_samples": { "Up": samples_jec_up, "Down": samples_jec_dn } }), ], "statistical": ["www", "vbsww", "ttw", "photon", "qflip", "prompt", "fake"], "flat_systematics": [ ("VBSWWXSec", ["vbsww"], "1.2", ""), ("ttWXSec", ["ttw"], "1.2", ""), ("VBSWWVRSyst", ["vbsww"], "1.22", ""), ("ttWVRSyst", ["ttw"], "1.18", ""), ("QFlipVRSyst", ["qflip"], "1.5", ""), ("PhotonVRSyst", ["photon"], "1.5", ""), ("LostLepMll3LModeling", ["lostlep"], "1.082", "SFOS"), ("LostLepMllSSModeling", ["lostlep"], "1.053", "SS"), ("LostLepMjjModeling", ["lostlep"], "1.049", "SS"), ("LumSyst", ["vbsww", "ttw", "photon", "qflip", "prompt", "www"], "1.025", ""), ], } return qutils.make_counting_experiment_statistics_data_card(options)
#!/bin/env python import os import sys import ROOT from QFramework import TQSampleFolder, TQEventlistPrinter, TQTaggable from rooutil import plottery_wrapper as p ROOT.gROOT.SetBatch(True) path = "eventlists/" filename = sys.argv[1] samples = TQSampleFolder.loadSampleFolder("{}:samples".format(filename)) printer = TQEventlistPrinter(samples) printer.addCut("SRSSeeFull") printer.addCut("SRSSemFull") printer.addCut("SRSSmmFull") printer.addCut("SideSSeeFull") printer.addCut("SideSSemFull") printer.addCut("SideSSmmFull") printer.addCut("SR0SFOSFull") printer.addCut("SR1SFOSFull") printer.addCut("SR2SFOSFull") printer.addCut("WZCRSSeeFull") printer.addCut("WZCRSSemFull") printer.addCut("WZCRSSmmFull") printer.addCut("WZCR1SFOSFull") printer.addCut("WZCR2SFOSFull") #printer.addProcess("/sig/whwww") printer.addProcess("/typebkg/lostlep/WZ")
def main(transformation, p, batch_index): ott_parser = OTTParser() transformation = ott_parser.parse_file(transformation) transformation.set_root(transformation) batch_index = str(batch_index) or "all" transformation.compile({"-batch-index": batch_index}) if p: print transformation for input in transformation.get("input"): sf = False print "Open: %s" % input.attributes['path'] if "sample-folder" in input.attributes: input_file = TQSampleFolder.loadSampleFolder( "%s:%s" % (input.attributes['path'], input.attributes['sample-folder'])) sf = True else: input_file = ROOT.TFile.Open(input.attributes['path']) for output in transformation.get("output"): output_file = ROOT.TFile.Open(output.attributes['path'], "RECREATE") for TH1F in output.get("TH1F"): output_file.cd() min = float(TH1F.get("min")[0].content) max = float(TH1F.get("max")[0].content) destination = TH1F.get("destination")[0].content bins = TH1F.get("bin") token = destination.rsplit("/", 1) if len(token) == 1: token = "", token[0] if not output_file.Get(token[0]): output_file.mkdir(token[0]) output_file.cd(token[0]) destination_name = token[1] print " TH1F(\"%s\", \"\", %d, %g, %g) -> %s %s" % \ (destination_name, len(bins), min, max, output.attributes['path'], destination) histogram = ROOT.TH1F(destination_name, "", len(bins), min, max) for i, bin in enumerate(bins): histogram.SetBinContent(i + 1, float(bin.content)) histogram.Write() for duplicate in output.get("duplicate"): output_file.cd() source = duplicate.get("source")[0].content destination = duplicate.get("destination")[0].content token = destination.rsplit("/", 1) if len(token) == 1: token = "", token[0] if not output_file.Get(token[0]): output_file.mkdir(token[0]) output_file.cd(token[0]) destination_name = token[1] if sf: cut = duplicate.get("cut")[0].content histogram_name = duplicate.get("histogram")[0].content histogram = input_file.getHistogram( ROOT.TString(source), ROOT.TString("%s/%s" % (cut, histogram_name))) if not histogram: continue print " %s %s/%s -> %s %s" % \ (source, cut, histogram_name, output.attributes['path'], destination) clone = histogram.Clone(destination_name) clone.Write() # todo output_file.Close()
def main(model="sm", mass0=-1, mass1=-1): # Print the model name and mass points print model, mass0, mass1 # Suffis that will be attached to output file names for bookkeeping suffix = make_suffix(model, mass0, mass1) # Create directory where the outputs will be makedir("statinputs") # Open input files filename = "output_sf_applied.root" samples = TQSampleFolder.loadSampleFolder("{}:samples".format(filename)) samples_jec_up = TQSampleFolder.loadSampleFolder("output_jec_up.root:samples") samples_jec_dn = TQSampleFolder.loadSampleFolder("output_jec_dn.root:samples") samples_gen_met = TQSampleFolder.loadSampleFolder("output_gen_met.root:samples") # Set the histogram name to perform the fit on (we use the 9 bin histogram histname = "{SRSSeeFull,SRSSemFull,SRSSmmFull,SideSSeeFull,SideSSemFull,SideSSmmFull,SR0SFOSFull,SR1SFOSFull,SR2SFOSFull}" # We have 8 categories for the fit processes = [ "vbsww" , "ttw" , "lostlep" , "photon" , "qflip" , "prompt" , "fake" , "www" ,] ####### # NOTE "www" means "signal" - i.e. for whsusy model www = whsusy and www is included in prompt ####### # Set the diectionary of the paths where we will retrieve the histograms from sampledirpaths = { "vbsww" : "/typebkg/?/VBSWW", "ttw" : "/typebkg/?/ttW", "lostlep" : "/typebkg/lostlep/[ttZ+WZ+Other]", "photon" : "/typebkg/photon/[ttZ+WZ+Other]", "qflip" : "/typebkg/qflip/[ttZ+WZ+Other]", "prompt" : "/typebkg/prompt/[ttZ+WZ+Other]" if model == "sm" else "/typebkg/prompt/[ttZ+WZ+Other]+sig" if model != "whwww" else "/typebkg/prompt/[ttZ+WZ+Other]+sig/www", "fake" : "/fake", "www" : get_sigmodel_path(model, mass0, mass1), } # Create output file ofile = ROOT.TFile("statinputs/hist_{}.root".format(suffix), "recreate") ofile.cd() # Array of numbers where we will aggregate some results for nice tables rates = {} # Write histograms for process in processes: #print process, histname # Get nominal histogram h_nom = samples.getHistogram(sampledirpaths[process], histname).Clone(process) # If lost lepton get the nominal number directly from the AN Table 13 if process == "lostlep": h_nom = set_to_lostlep_nominal_hist(h_nom) # If whsusy model with signal then get the average of the two histogram #if model == "whsusy" and process == "www": set_to_average_and_write_genmet_syst_hist(h_nom, samples_gen_met.getHistogram(sampledirpaths[process], histname).Clone(process)) # Write nominal histogram #h_nom.Write() mask_bins(h_nom).Write() # Save the total number that will be used to output to datacards rates[process] = h_nom.Integral() # Nominal histogram errors are needed to be varied one by one to create an effective uncorrelated histograms if process != "lostlep" and process != "fake": write_nominal_stat_variations(h_nom, process) # Write systematic histograms that are from weight variations for systvar in systvars: # Some process or some variations do not need to be written if do_not_write_syst_hist(process, systvar, model): continue # Write the systvariation histograms #samples.getHistogram(sampledirpaths[process], histname.replace("Full", "Full" + systvar)).Clone(process + "_" + systvar).Write() mask_bins(samples.getHistogram(sampledirpaths[process], histname.replace("Full", "Full" + systvar)).Clone(process + "_" + systvar)).Write() # JEC systematic histograms need to be called from a different sample output if process != "fake" and process != "lostlep": #samples_jec_up.getHistogram(sampledirpaths[process], histname).Clone(process + "_JECUp").Write() #samples_jec_dn.getHistogram(sampledirpaths[process], histname).Clone(process + "_JECDown").Write() mask_bins(samples_jec_up.getHistogram(sampledirpaths[process], histname).Clone(process + "_JECUp")).Write() mask_bins(samples_jec_dn.getHistogram(sampledirpaths[process], histname).Clone(process + "_JECDown")).Write() # Lost lepton has special treatment if process == "lostlep": #write_lostlep_stat_variations(h_nom) #write_lostlep_syst_variations(h_nom) write_lostlep_CRstat_variations(h_nom) write_lostlep_TFstat_variations(h_nom) write_lostlep_TFsyst_variations(h_nom) write_lostlep_Mjjsyst_variations(h_nom) write_lostlep_MllSSsyst_variations(h_nom) write_lostlep_Mll3lsyst_variations(h_nom) # WWW signal theory systematics if model == "sm": if process == "www": write_www_theory_syst_variations(h_nom) # Fake has AR statistics if process == "fake": write_fake_ARstat_variations(h_nom) # Write data histogram h_data = samples.getHistogram("/typebkg", histname).Clone("data_obs") for i in xrange(0,h_data.GetNbinsX()+2): h_data.SetBinContent(i, int(h_data.GetBinContent(i))) #h_data.Write() mask_bins(h_data).Write() datacard="""imax 1 number of bins jmax * number of processes kmax * number of nuisance parameters ---------------------------------------------------------------------------------------------------------------------------------- shapes * * statinputs/hist_{}.root $PROCESS $PROCESS_$SYSTEMATIC ---------------------------------------------------------------------------------------------------------------------------------- bin SR observation {:.1f} ---------------------------------------------------------------------------------------------------------------------------------- bin SR SR SR SR SR SR SR SR process 0 1 2 3 4 5 6 7 process www fake photon lostlep qflip prompt ttw vbsww rate {:<6.3f} {:<6.3f} {:<6.3f} {:<6.3f} {:<6.3f} {:<6.3f} {:<6.3f} {:<6.3f} ---------------------------------------------------------------------------------------------------------------------------------- JEC shape 1 - 1 - - 1 1 1 LepSF shape 1 - 1 - - 1 1 1 TrigSF shape 1 - 1 - - 1 1 1 BTagHF shape 1 - 1 - - 1 1 1 BTagLF shape 1 - 1 - - 1 1 1 Pileup shape 1 - 1 - - 1 1 1 FakeRateEl shape - 1 - - - - - - FakeRateMu shape - 1 - - - - - - FakeClosureEl shape - 1 - - - - - - FakeClosureMu shape - 1 - - - - - - LostLepSyst shape - - - 1 - - - - MjjModeling shape - - - 1 - - - - MllSSModeling shape - - - 1 - - - - Mll3lModeling shape - - - 1 - - - - SigXSec lnN 1.06 - - - - - - - LumSyst lnN 1.025 - 1.025 - 1.025 1.025 1.025 1.025 vbsww_xsec lnN - - - - - - - 1.20 vbsww_validation lnN - - - - - - - 1.22 ttw_xsec lnN - - - - - - 1.20 - ttw_validation lnN - - - - - - 1.18 - photon_syst lnN - - 1.50 - - - - - qflip_syst lnN - - - - 1.50 - - - www_stat_in_ee shape 1 - - - - - - - www_stat_in_em shape 1 - - - - - - - www_stat_in_mm shape 1 - - - - - - - www_stat_out_ee shape 1 - - - - - - - www_stat_out_em shape 1 - - - - - - - www_stat_out_mm shape 1 - - - - - - - www_stat_0sfos shape 1 - - - - - - - www_stat_1sfos shape 1 - - - - - - - www_stat_2sfos shape 1 - - - - - - - fake_ARstat_in_ee shape - 1 - - - - - - fake_ARstat_in_em shape - 1 - - - - - - fake_ARstat_in_mm shape - 1 - - - - - - fake_ARstat_out_ee shape - 1 - - - - - - fake_ARstat_out_em shape - 1 - - - - - - fake_ARstat_out_mm shape - 1 - - - - - - fake_ARstat_0sfos shape - 1 - - - - - - fake_ARstat_1sfos shape - 1 - - - - - - fake_ARstat_2sfos shape - 1 - - - - - - photon_stat_in_ee shape - - 1 - - - - - photon_stat_in_em shape - - 1 - - - - - photon_stat_in_mm shape - - 1 - - - - - photon_stat_out_ee shape - - 1 - - - - - photon_stat_out_em shape - - 1 - - - - - photon_stat_out_mm shape - - 1 - - - - - photon_stat_0sfos shape - - 1 - - - - - photon_stat_1sfos shape - - 1 - - - - - photon_stat_2sfos shape - - 1 - - - - - lostlep_stat_in_ee shape - - - 1 - - - - lostlep_stat_in_em shape - - - 1 - - - - lostlep_stat_in_mm shape - - - 1 - - - - lostlep_stat_out_ee shape - - - 1 - - - - lostlep_stat_out_em shape - - - 1 - - - - lostlep_stat_out_mm shape - - - 1 - - - - lostlep_stat_0sfos shape - - - 1 - - - - lostlep_stat_1sfos shape - - - 1 - - - - lostlep_stat_2sfos shape - - - 1 - - - - qflip_stat_in_ee shape - - - - 1 - - - qflip_stat_in_em shape - - - - 1 - - - qflip_stat_in_mm shape - - - - 1 - - - qflip_stat_out_ee shape - - - - 1 - - - qflip_stat_out_em shape - - - - 1 - - - qflip_stat_out_mm shape - - - - 1 - - - qflip_stat_0sfos shape - - - - 1 - - - qflip_stat_1sfos shape - - - - 1 - - - qflip_stat_2sfos shape - - - - 1 - - - prompt_stat_in_ee shape - - - - - 1 - - prompt_stat_in_em shape - - - - - 1 - - prompt_stat_in_mm shape - - - - - 1 - - prompt_stat_out_ee shape - - - - - 1 - - prompt_stat_out_em shape - - - - - 1 - - prompt_stat_out_mm shape - - - - - 1 - - prompt_stat_0sfos shape - - - - - 1 - - prompt_stat_1sfos shape - - - - - 1 - - prompt_stat_2sfos shape - - - - - 1 - - ttw_stat_in_ee shape - - - - - - 1 - ttw_stat_in_em shape - - - - - - 1 - ttw_stat_in_mm shape - - - - - - 1 - ttw_stat_out_ee shape - - - - - - 1 - ttw_stat_out_em shape - - - - - - 1 - ttw_stat_out_mm shape - - - - - - 1 - ttw_stat_0sfos shape - - - - - - 1 - ttw_stat_1sfos shape - - - - - - 1 - ttw_stat_2sfos shape - - - - - - 1 - vbsww_stat_in_ee shape - - - - - - - 1 vbsww_stat_in_em shape - - - - - - - 1 vbsww_stat_in_mm shape - - - - - - - 1 vbsww_stat_out_ee shape - - - - - - - 1 vbsww_stat_out_em shape - - - - - - - 1 vbsww_stat_out_mm shape - - - - - - - 1 vbsww_stat_0sfos shape - - - - - - - 1 vbsww_stat_1sfos shape - - - - - - - 1 vbsww_stat_2sfos shape - - - - - - - 1 lostlep_CRstat_ee shape - - - 1 - - - - lostlep_CRstat_em shape - - - 1 - - - - lostlep_CRstat_mm shape - - - 1 - - - - lostlep_CRstat_0sfos shape - - - 1 - - - - lostlep_CRstat_1sfos shape - - - 1 - - - - lostlep_CRstat_2sfos shape - - - 1 - - - - """.format(suffix, h_data.Integral(), rates["www"], rates["fake"], rates["photon"], rates["lostlep"], rates["qflip"], rates["prompt"], rates["ttw"], rates["vbsww"]) if model == "sm": datacard += """SigPDF shape 1 - - - - - - - SigQsq shape 1 - - - - - - - SigAlpha shape 1 - - - - - - - """ if model == "whsusy": datacard += """ISR shape 1 - - - - - - - Qsq shape 1 - - - - - - - PDF shape 1 - - - - - - - AlphaS shape 1 - - - - - - - GenMET shape 1 - - - - - - - """ f = open('statinputs/datacard_{}.txt'.format(suffix), 'w') f.write(datacard) f.close() ofile.Close()