def getCategorries(self, channel_holder, cuts=None): """ Returns dict of Cattegories for Channel """ self._logger.info(self.__class__.__name__ + '::' + sys._getframe().f_code.co_name) categories = [] for name, var in channel_holder._variables.iteritems(): # Cuts common for all categories cuts = Cuts( Cut('pt_2>23', "pt_2_threshold"), ) for njet in self._jets_multiplicity: for dm in self._decay_mode: categories.append( Category( name=njet + '_' + dm, channel=channel_holder._channel_obj, cuts=cuts, variable=var) ) # Add the DM splitting categories[-1].cuts.add(Cut(self._known_cuts['decay_mode'][dm], dm)) # Add the njets splitting: categories[-1].cuts.add(Cut(str(self._known_cuts['jets_multiplicity'][njet]), str(njet))) # Remove cuts introduced in categorysation if name == "iso_1" or name == "iso_2": categories[-1].cuts.remove("ele_iso") categories[-1].cuts.remove("tau_iso") log_categories = '\t', 'Cattegories:\n' for category in categories: log_categories += '\t' * 2, category.name, '_:', category.cuts.__str__(indent=3 + self._indent) + '\n' self._logger.info(''.join(log_categories)) return categories
def main(args): # Container for all distributions to be drawn logger.info("Set up shape variations.") systematics = Systematics( "{}_shapes.root".format(args.tag), num_threads=args.num_threads, skip_systematic_variations=args.skip_systematic_variations) # Era selection if "2017" in args.era: from shape_producer.estimation_methods_2017 import DataEstimation, ZTTEstimation, ZTTEmbeddedEstimation, ZLEstimation, ZJEstimation, TTLEstimation, TTJEstimation, TTTEstimation, VVLEstimation, VVTEstimation, VVJEstimation, WEstimation, ggHEstimation, qqHEstimation, VHEstimation, WHEstimation, ZHEstimation, ttHEstimation, QCDEstimation_ABCD_TT_ISO2, QCDEstimation_SStoOS_MTETEM, NewFakeEstimationLT, NewFakeEstimationTT, HWWEstimation, ggHWWEstimation, qqHWWEstimation, DYJetsToLLEstimation, TTEstimation, VVEstimation from shape_producer.era import Run2017 era = Run2017(args.datasets) else: logger.critical("Era {} is not implemented.".format(args.era)) raise Exception wp_dict_mva = { "vvloose": "byVVLooseIsolationMVArun2017v2DBoldDMwLT2017_2", "vloose": "byVLooseIsolationMVArun2017v2DBoldDMwLT2017_2", "loose": "byLooseIsolationMVArun2017v2DBoldDMwLT2017_2", "medium": "byMediumIsolationMVArun2017v2DBoldDMwLT2017_2", "tight": "byTightIsolationMVArun2017v2DBoldDMwLT2017_2", "vtight": "byVTightIsolationMVArun2017v2DBoldDMwLT2017_2", "vvtight": "byVVTightIsolationMVArun2017v2DBoldDMwLT2017_2", } wp_dict_deeptau = { "vvvloose": "byVVVLooseDeepTau2017v2p1VSjet_2", "vvloose": "byVVLooseDeepTau2017v2p1VSjet_2", "vloose": "byVLooseDeepTau2017v2p1VSjet_2", "loose": "byLooseDeepTau2017v2p1VSjet_2", "medium": "byMediumDeepTau2017v2p1VSjet_2", "tight": "byTightDeepTau2017v2p1VSjet_2", "vtight": "byVTightDeepTau2017v2p1VSjet_2", "vvtight": "byVVTightDeepTau2017v2p1VSjet_2", "mm": "0<1", } wp_dict = wp_dict_deeptau logger.info("Produce shapes for the %s working point of the MVA Tau ID", args.working_point) # Channels and processes # yapf: disable directory = args.directory ff_friend_directory = args.fake_factor_friend_directory mt = MTTauID2017() mt.cuts.add(Cut(wp_dict[args.working_point]+">0.5", "tau_iso")) # if args.gof_channel == "mt": # mt.cuts.remove("m_t") # mt.cuts.remove("dZeta") # mt.cuts.remove("absEta") mt_processes = { "data" : Process("data_obs", DataEstimation (era, directory, mt, friend_directory=[])), "ZTT" : Process("ZTT", ZTTEstimation (era, directory, mt, friend_directory=[])), "EMB" : Process("EMB", ZTTEmbeddedEstimation (era, directory, mt, friend_directory=[])), "ZJ" : Process("ZJ", ZJEstimation (era, directory, mt, friend_directory=[])), "ZL" : Process("ZL", ZLEstimation (era, directory, mt, friend_directory=[])), "TTT" : Process("TTT", TTTEstimation (era, directory, mt, friend_directory=[])), "TTJ" : Process("TTJ", TTJEstimation (era, directory, mt, friend_directory=[])), "TTL" : Process("TTL", TTLEstimation (era, directory, mt, friend_directory=[])), "VVT" : Process("VVT", VVTEstimation (era, directory, mt, friend_directory=[])), "VVJ" : Process("VVJ", VVJEstimation (era, directory, mt, friend_directory=[])), "VVL" : Process("VVL", VVLEstimation (era, directory, mt, friend_directory=[])), "W" : Process("W", WEstimation (era, directory, mt, friend_directory=[])), } # TODO: Include alternative jet fake estimation. # mt_processes["FAKES"] = Process("jetFakes", NewFakeEstimationLT(era, directory, mt, [mt_processes[process] for process in ["EMB", "ZL", "TTL", "VVL"]], mt_processes["data"], friend_directory=mt_friend_directory+[ff_friend_directory])) # mt_processes["FAKES"] = Process("jetFakes", NewFakeEstimationLT(era, directory, mt, [mt_processes[process] for process in ["ZTT", "ZL", "TTL", "TTT", "VVL", "VVT"]], mt_processes["data"], friend_directory=mt_friend_directory+[ff_friend_directory])) mt_processes["QCD"] = Process("QCD", QCDEstimation_SStoOS_MTETEM(era, directory, mt, [mt_processes[process] for process in ["ZTT", "ZL", "ZJ", "TTT", "TTJ", "TTL", "VVT", "VVJ", "VVL", "W"]], mt_processes["data"], friend_directory=[], extrapolation_factor=1.17)) mt_processes["QCDEMB"] = Process("QCDEMB", QCDEstimation_SStoOS_MTETEM(era, directory, mt, [mt_processes[process] for process in ["EMB", "ZL", "ZJ", "TTJ", "TTL", "VVJ", "VVL", "W"]], mt_processes["data"], friend_directory=[], extrapolation_factor=1.17)) # TODO: Include Z-> mumu control region. mm = MMTauID2017() mm_processes = { "data" : Process("data_obs", DataEstimation (era, directory, mm, friend_directory=[])), "ZLL" : Process("ZLL", DYJetsToLLEstimation (era, directory, mm, friend_directory=[])), "MMEMB" : Process("MMEMB", ZTTEmbeddedEstimation(era, directory, mm, friend_directory=[])), "TT" : Process("TT", TTEstimation (era, directory, mm, friend_directory=[])), "VV" : Process("VV", VVEstimation (era, directory, mm, friend_directory=[])), "W" : Process("W", WEstimation (era, directory, mm, friend_directory=[])), } # mm_processes["FAKES"] = None TODO: Add fake factors or alternative fake rate estimation here mm_processes["QCD"] = Process("QCD", QCDEstimation_SStoOS_MTETEM(era, directory, mm, [mm_processes[process] for process in ["ZLL", "W", "TT", "VV"]], mm_processes["data"], friend_directory=[], extrapolation_factor=1.17)) mm_processes["QCDEMB"] = Process("QCDEMB", QCDEstimation_SStoOS_MTETEM(era, directory, mm, [mm_processes[process] for process in ["MMEMB", "W"]], mm_processes["data"], friend_directory=[], extrapolation_factor=1.17)) # Variables and categories binning = yaml.load(open(args.binning)) mt_categories = [] # Goodness of fit shapes if args.gof_channel == "mt": score = Variable( args.gof_variable, VariableBinning(binning["control"]["mt"][args.gof_variable]["bins"]), expression=binning["control"]["mt"][args.gof_variable]["expression"]) if "cut" in binning["control"]["mt"][args.gof_variable].keys(): cuts=Cuts(Cut(binning["control"]["mt"][args.gof_variable]["cut"], "binning")) else: cuts=Cuts() mt_categories.append( Category( args.gof_variable, mt, cuts, variable=score)) elif "mt" in args.channels: for cat in binning["categories"]["mt"]: category = Category( cat, mt, Cuts(Cut(binning["categories"]["mt"][cat]["cut"], "category")), variable=Variable(binning["categories"]["mt"][cat]["var"], VariableBinning(binning["categories"]["mt"][cat]["bins"]), expression=binning["categories"]["mt"][cat]["expression"])) mt_categories.append(category) # yapf: enable if "mt" in [args.gof_channel] + args.channels: for process, category in product(mt_processes.values(), mt_categories): systematics.add( Systematic(category=category, process=process, analysis="smhtt", era=era, variation=Nominal(), mass="125")) mm_categories = [] if "mm" in args.channels: category = Category("control", mm, Cuts(), variable=Variable("m_vis", ConstantBinning(1, 50, 150), "m_vis")) mm_categories.append(category) if "mm" in args.channels: for process, category in product(mm_processes.values(), mm_categories): systematics.add( Systematic(category=category, process=process, analysis="smhtt", era=era, variation=Nominal(), mass="125")) # Shapes variations # TODO: Check if prefiring weights are necessary for tau id sf measurement. # Prefiring weights prefiring_variaitons = [ ReplaceWeight("CMS_prefiring_Run2017", "prefireWeight", Weight("prefiringweightup", "prefireWeight"), "Up"), ReplaceWeight("CMS_prefiring_Run2017", "prefireWeight", Weight("prefiringweightdown", "prefireWeight"), "Down"), ] for variation in prefiring_variaitons: for process_nick in [ "ZTT", "ZL", "ZJ", "W", "TTT", "TTL", "TTJ", "VVT", "VVJ", "VVL", ]: if "mt" in [args.gof_channel] + args.channels: systematics.add_systematic_variation( variation=variation, process=mt_processes[process_nick], channel=mt, era=era) # MC tau energy scale tau_es_3prong_variations = create_systematic_variations( "CMS_scale_mc_t_3prong_Run2017", "tauEsThreeProng", DifferentPipeline) tau_es_1prong_variations = create_systematic_variations( "CMS_scale_mc_t_1prong_Run2017", "tauEsOneProng", DifferentPipeline) tau_es_1prong1pizero_variations = create_systematic_variations( "CMS_scale_mc_t_1prong1pizero_Run2017", "tauEsOneProngOnePiZero", DifferentPipeline) for variation in tau_es_3prong_variations + tau_es_1prong_variations + tau_es_1prong1pizero_variations: for process_nick in [ "ZTT", "TTT", "TTL", "VVL", "VVT", # "FAKES" ]: if "mt" in [args.gof_channel] + args.channels: systematics.add_systematic_variation( variation=variation, process=mt_processes[process_nick], channel=mt, era=era) # Tau energy scale tau_es_3prong_variations = create_systematic_variations( "CMS_scale_t_3prong_Run2017", "tauEsThreeProng", DifferentPipeline) tau_es_1prong_variations = create_systematic_variations( "CMS_scale_t_1prong_Run2017", "tauEsOneProng", DifferentPipeline) tau_es_1prong1pizero_variations = create_systematic_variations( "CMS_scale_t_1prong1pizero_Run2017", "tauEsOneProngOnePiZero", DifferentPipeline) for variation in tau_es_3prong_variations + tau_es_1prong_variations + tau_es_1prong1pizero_variations: for process_nick in [ "ZTT", "TTT", "TTL", "VVT", "VVL", "EMB", # "FAKES" ]: if "mt" in [args.gof_channel] + args.channels: systematics.add_systematic_variation( variation=variation, process=mt_processes[process_nick], channel=mt, era=era) # Jet energy scale # Inclusive JES shapes jet_es_variations = [] '''jet_es_variations += create_systematic_variations( "CMS_scale_j_Run2017", "jecUnc", DifferentPipeline)''' # Splitted JES shapes jet_es_variations += create_systematic_variations( "CMS_scale_j_eta0to3_Run2017", "jecUncEta0to3", DifferentPipeline) jet_es_variations += create_systematic_variations( "CMS_scale_j_eta0to5_Run2017", "jecUncEta0to5", DifferentPipeline) jet_es_variations += create_systematic_variations( "CMS_scale_j_eta3to5_Run2017", "jecUncEta3to5", DifferentPipeline) jet_es_variations += create_systematic_variations( "CMS_scale_j_RelativeBal_Run2017", "jecUncRelativeBal", DifferentPipeline) jet_es_variations += create_systematic_variations( "CMS_scale_j_RelativeSample_Run2017", "jecUncRelativeSample", DifferentPipeline) for variation in jet_es_variations: for process_nick in [ "ZTT", "ZL", "ZJ", "W", "TTT", "TTL", "TTJ", "VVT", "VVJ", "VVL", ]: if "mt" in [args.gof_channel] + args.channels: systematics.add_systematic_variation( variation=variation, process=mt_processes[process_nick], channel=mt, era=era) # MET energy scale. Note: only those variations for non-resonant processes are used in the stat. inference met_unclustered_variations = create_systematic_variations( "CMS_scale_met_unclustered", "metUnclusteredEn", DifferentPipeline) for variation in met_unclustered_variations: # + met_clustered_variations: for process_nick in [ "ZTT", "ZL", "ZJ", "W", "TTT", "TTL", "TTJ", "VVT", "VVJ", "VVL", ]: if "mt" in [args.gof_channel] + args.channels: systematics.add_systematic_variation( variation=variation, process=mt_processes[process_nick], channel=mt, era=era) # Recoil correction unc recoil_resolution_variations = create_systematic_variations( "CMS_htt_boson_reso_met_Run2017", "metRecoilResolution", DifferentPipeline) recoil_response_variations = create_systematic_variations( "CMS_htt_boson_scale_met_Run2017", "metRecoilResponse", DifferentPipeline) for variation in recoil_resolution_variations + recoil_response_variations: for process_nick in ["ZTT", "ZL", "ZJ", "W"]: if "mt" in [args.gof_channel] + args.channels: systematics.add_systematic_variation( variation=variation, process=mt_processes[process_nick], channel=mt, era=era) # Z pt reweighting zpt_variations = create_systematic_variations("CMS_htt_dyShape_Run2017", "zPtReweightWeight", SquareAndRemoveWeight) for variation in zpt_variations: for process_nick in ["ZTT", "ZL", "ZJ"]: if "mt" in [args.gof_channel] + args.channels: systematics.add_systematic_variation( variation=variation, process=mt_processes[process_nick], channel=mt, era=era) # top pt reweighting top_pt_variations = create_systematic_variations("CMS_htt_ttbarShape", "topPtReweightWeight", SquareAndRemoveWeight) for variation in top_pt_variations: for process_nick in ["TTT", "TTL", "TTJ"]: if "mt" in [args.gof_channel] + args.channels: systematics.add_systematic_variation( variation=variation, process=mt_processes[process_nick], channel=mt, era=era) # TODO: likely not necessary, to be checked # jet to tau fake efficiency jet_to_tau_fake_variations = [] jet_to_tau_fake_variations.append( AddWeight("CMS_htt_jetToTauFake_Run2017", "jetToTauFake_weight", Weight("max(1.0-pt_2*0.002, 0.6)", "jetToTauFake_weight"), "Up")) jet_to_tau_fake_variations.append( AddWeight("CMS_htt_jetToTauFake_Run2017", "jetToTauFake_weight", Weight("min(1.0+pt_2*0.002, 1.4)", "jetToTauFake_weight"), "Down")) for variation in jet_to_tau_fake_variations: for process_nick in ["ZJ", "TTJ", "W", "VVJ"]: if "mt" in [args.gof_channel] + args.channels: systematics.add_systematic_variation( variation=variation, process=mt_processes[process_nick], channel=mt, era=era) # ZL fakes energy scale mu_fake_es_1prong_variations = create_systematic_variations( "CMS_ZLShape_mt_1prong_Run2017", "tauMuFakeEsOneProng", DifferentPipeline) mu_fake_es_1prong1pizero_variations = create_systematic_variations( "CMS_ZLShape_mt_1prong1pizero_Run2017", "tauMuFakeEsOneProngPiZeros", DifferentPipeline) if "mt" in [args.gof_channel] + args.channels: for process_nick in ["ZL"]: for variation in mu_fake_es_1prong_variations + mu_fake_es_1prong1pizero_variations: systematics.add_systematic_variation( variation=variation, process=mt_processes[process_nick], channel=mt, era=era) # lepton trigger efficiency lep_trigger_eff_variations = [] lep_trigger_eff_variations.append( AddWeight( "CMS_eff_trigger_mt_Run2017", "trg_mt_eff_weight", Weight("(1.0*(pt_1<=25)+1.02*(pt_1>25))", "trg_mt_eff_weight"), "Up")) lep_trigger_eff_variations.append( AddWeight( "CMS_eff_trigger_mt_Run2017", "trg_mt_eff_weight", Weight("(1.0*(pt_1<=25)+0.98*(pt_1>25))", "trg_mt_eff_weight"), "Down")) for variation in lep_trigger_eff_variations: for process_nick in [ "ZTT", "ZL", "ZJ", "W", "TTT", "TTL", "TTJ", "VVL", "VVT", "VVJ", ]: if "mt" in [args.gof_channel] + args.channels: systematics.add_systematic_variation( variation=variation, process=mt_processes[process_nick], channel=mt, era=era) for process_nick in ["ZLL", "TT", "VV", "W"]: if "mm" in [args.gof_channel] + args.channels: systematics.add_systematic_variation( variation=variation, process=mm_processes[process_nick], channel=mm, era=era) lep_trigger_eff_variations = [] lep_trigger_eff_variations.append( AddWeight( "CMS_eff_trigger_emb_mt_Run2017", "trg_mt_eff_weight", Weight("(1.0*(pt_1<=25)+1.02*(pt_1>25))", "trg_mt_eff_weight"), "Up")) lep_trigger_eff_variations.append( AddWeight( "CMS_eff_trigger_emb_mt_Run2017", "trg_mt_eff_weight", Weight("(1.0*(pt_1<=25)+0.98*(pt_1>25))", "trg_mt_eff_weight"), "Down")) for variation in lep_trigger_eff_variations: for process_nick in ["EMB"]: if "mt" in [args.gof_channel] + args.channels: systematics.add_systematic_variation( variation=variation, process=mt_processes[process_nick], channel=mt, era=era) for process_nick in ["MMEMB"]: if "mm" in [args.gof_channel] + args.channels: systematics.add_systematic_variation( variation=variation, process=mm_processes[process_nick], channel=mm, era=era) # b tagging # btag_eff_variations = create_systematic_variations( # "CMS_htt_eff_b_Run2017", "btagEff", DifferentPipeline) # mistag_eff_variations = create_systematic_variations( # "CMS_htt_mistag_b_Run2017", "btagMistag", DifferentPipeline) # for variation in btag_eff_variations + mistag_eff_variations: # for process_nick in [ # "ZTT", "ZL", "ZJ", "W", "TTT", "TTL", "TTJ", "VVT", "VVJ", # "VVL" # ]: # if "et" in [args.gof_channel] + args.channels: # systematics.add_systematic_variation( # variation=variation, # process=et_processes[process_nick], # channel=et, # era=era) # if "mt" in [args.gof_channel] + args.channels: # systematics.add_systematic_variation( # variation=variation, # process=mt_processes[process_nick], # channel=mt, # era=era) # if "tt" in [args.gof_channel] + args.channels: # systematics.add_systematic_variation( # variation=variation, # process=tt_processes[process_nick], # channel=tt, # era=era) # for process_nick in ["ZTT", "ZL", "W", "TTT", "TTL", "VVL", "VVT" # ]: # if "em" in [args.gof_channel] + args.channels: # systematics.add_systematic_variation( # variation=variation, # process=em_processes[process_nick], # channel=em, # era=era) # Embedded event specifics # Tau energy scale tau_es_3prong_variations = create_systematic_variations( "CMS_scale_emb_t_3prong_Run2017", "tauEsThreeProng", DifferentPipeline) tau_es_1prong_variations = create_systematic_variations( "CMS_scale_emb_t_1prong_Run2017", "tauEsOneProng", DifferentPipeline) tau_es_1prong1pizero_variations = create_systematic_variations( "CMS_scale_emb_t_1prong1pizero_Run2017", "tauEsOneProngOnePiZero", DifferentPipeline) for variation in tau_es_3prong_variations + tau_es_1prong_variations + tau_es_1prong1pizero_variations: for process_nick in ["EMB"]: #, "FAKES"]: if "mt" in [args.gof_channel] + args.channels: systematics.add_systematic_variation( variation=variation, process=mt_processes[process_nick], channel=mt, era=era) mt_decayMode_variations = [] mt_decayMode_variations.append( ReplaceWeight( "CMS_3ProngEff_Run2017", "decayMode_SF", Weight("embeddedDecayModeWeight_effUp_pi0Nom", "decayMode_SF"), "Up")) mt_decayMode_variations.append( ReplaceWeight( "CMS_3ProngEff_Run2017", "decayMode_SF", Weight("embeddedDecayModeWeight_effDown_pi0Nom", "decayMode_SF"), "Down")) mt_decayMode_variations.append( ReplaceWeight( "CMS_1ProngPi0Eff_Run2017", "decayMode_SF", Weight("embeddedDecayModeWeight_effNom_pi0Up", "decayMode_SF"), "Up")) mt_decayMode_variations.append( ReplaceWeight( "CMS_1ProngPi0Eff_Run2017", "decayMode_SF", Weight("embeddedDecayModeWeight_effNom_pi0Down", "decayMode_SF"), "Down")) for variation in mt_decayMode_variations: for process_nick in ["EMB"]: if "mt" in [args.gof_channel] + args.channels: systematics.add_systematic_variation( variation=variation, process=mt_processes[process_nick], channel=mt, era=era) # 10% removed events in ttbar simulation (ttbar -> real tau tau events) will be added/subtracted to ZTT shape to use as systematic tttautau_process_mt = Process( "TTT", TTTEstimation(era, directory, mt, friend_directory=[])) if "mt" in [args.gof_channel] + args.channels: for category in mt_categories: mt_processes['ZTTpTTTauTauDown'] = Process( "ZTTpTTTauTauDown", AddHistogramEstimationMethod( "AddHistogram", "nominal", era, directory, mt, [mt_processes["EMB"], tttautau_process_mt], [1.0, -0.1])) systematics.add( Systematic(category=category, process=mt_processes['ZTTpTTTauTauDown'], analysis="smhtt", era=era, variation=Relabel("CMS_htt_emb_ttbar_Run2017", "Down"), mass="125")) mt_processes['ZTTpTTTauTauUp'] = Process( "ZTTpTTTauTauUp", AddHistogramEstimationMethod( "AddHistogram", "nominal", era, directory, mt, [mt_processes["EMB"], tttautau_process_mt], [1.0, 0.1])) systematics.add( Systematic(category=category, process=mt_processes['ZTTpTTTauTauUp'], analysis="smhtt", era=era, variation=Relabel("CMS_htt_emb_ttbar_Run2017", "Up"), mass="125")) # jetfakes fake_factor_variations_mt = [] for systematic_shift in [ "ff_qcd{ch}_syst_Run2017{shift}", "ff_qcd_dm0_njet0{ch}_stat_Run2017{shift}", "ff_qcd_dm0_njet1{ch}_stat_Run2017{shift}", #"ff_qcd_dm1_njet0{ch}_stat_Run2017{shift}", #"ff_qcd_dm1_njet1{ch}_stat_Run2017{shift}", "ff_w_syst_Run2017{shift}", "ff_w_dm0_njet0{ch}_stat_Run2017{shift}", "ff_w_dm0_njet1{ch}_stat_Run2017{shift}", #"ff_w_dm1_njet0{ch}_stat_Run2017{shift}", #"ff_w_dm1_njet1{ch}_stat_Run2017{shift}", "ff_tt_syst_Run2017{shift}", "ff_tt_dm0_njet0_stat_Run2017{shift}", "ff_tt_dm0_njet1_stat_Run2017{shift}", #"ff_tt_dm1_njet0_stat_Run2017{shift}", #"ff_tt_dm1_njet1_stat_Run2017{shift}" ]: for shift_direction in ["Up", "Down"]: fake_factor_variations_mt.append( ReplaceWeight( "CMS_%s" % (systematic_shift.format( ch='_mt', shift="").replace("_dm0", "")), "fake_factor", Weight( "ff2_{syst}".format(syst=systematic_shift.format( ch="", shift="_%s" % shift_direction.lower()).replace("_Run2017", "")), "fake_factor"), shift_direction)) # if "mt" in [args.gof_channel] + args.channels: # for variation in fake_factor_variations_mt: # systematics.add_systematic_variation( # variation=variation, # process=mt_processes["FAKES"], # channel=mt, # era=era) # Produce histograms logger.info("Start producing shapes.") systematics.produce() logger.info("Done producing shapes.")
def main(args): # Container for all distributions to be drawn systematics = Systematics("counts_for_soverb.root", num_threads=args.num_threads, find_unique_objects=False) # Era era = Run2017(args.datasets) # Channels and processes # yapf: disable directory = args.directory et_friend_directory = args.et_friend_directory mt_friend_directory = args.mt_friend_directory tt_friend_directory = args.tt_friend_directory em_friend_directory = args.em_friend_directory ff_friend_directory = args.fake_factor_friend_directory mt = MT() mt_processes = { "data" : Process("data_obs", DataEstimation (era, directory, mt, friend_directory=mt_friend_directory)), "EMB" : Process("EMB", ZTTEmbeddedEstimation (era, directory, mt, friend_directory=mt_friend_directory)), "ZL" : Process("ZL", ZLEstimation (era, directory, mt, friend_directory=mt_friend_directory)), "TTL" : Process("TTL", TTLEstimation (era, directory, mt, friend_directory=mt_friend_directory)), "VVL" : Process("VVL", VVLEstimation (era, directory, mt, friend_directory=mt_friend_directory)), "ggH" : Process("ggH125", ggHEstimation ("ggH125", era, directory, mt, friend_directory=mt_friend_directory)), "qqH" : Process("qqH125", qqHEstimation ("qqH125", era, directory, mt, friend_directory=mt_friend_directory)), # "WH" : Process("WH125", WHEstimation (era, directory, mt, friend_directory=mt_friend_directory)), # "ZH" : Process("ZH125", ZHEstimation (era, directory, mt, friend_directory=mt_friend_directory)), # "ttH" : Process("ttH125", ttHEstimation (era, directory, mt, friend_directory=mt_friend_directory)), } mt_processes["FAKESEMB"] = Process("jetFakesEMB", NewFakeEstimationLT(era, directory, mt, [mt_processes[process] for process in ["EMB", "ZL", "TTL", "VVL"]], mt_processes["data"], friend_directory=mt_friend_directory+[ff_friend_directory])) et = ET() et_processes = { "data" : Process("data_obs", DataEstimation (era, directory, et, friend_directory=et_friend_directory)), "EMB" : Process("EMB", ZTTEmbeddedEstimation (era, directory, et, friend_directory=et_friend_directory)), "ZL" : Process("ZL", ZLEstimation (era, directory, et, friend_directory=et_friend_directory)), "TTL" : Process("TTL", TTLEstimation (era, directory, et, friend_directory=et_friend_directory)), "VVL" : Process("VVL", VVLEstimation (era, directory, et, friend_directory=et_friend_directory)), "ggH" : Process("ggH125", ggHEstimation ("ggH125", era, directory, et, friend_directory=et_friend_directory)), "qqH" : Process("qqH125", qqHEstimation ("qqH125", era, directory, et, friend_directory=et_friend_directory)), # "WH" : Process("WH125", WHEstimation (era, directory, et, friend_directory=et_friend_directory)), # "ZH" : Process("ZH125", ZHEstimation (era, directory, et, friend_directory=et_friend_directory)), # "ttH" : Process("ttH125", ttHEstimation (era, directory, et, friend_directory=et_friend_directory)), } et_processes["FAKESEMB"] = Process("jetFakesEMB", NewFakeEstimationLT(era, directory, et, [et_processes[process] for process in ["EMB", "ZL", "TTL", "VVL"]], et_processes["data"], friend_directory=et_friend_directory+[ff_friend_directory])) tt = TT() tt_processes = { "data" : Process("data_obs", DataEstimation (era, directory, tt, friend_directory=tt_friend_directory)), "EMB" : Process("EMB", ZTTEmbeddedEstimation (era, directory, tt, friend_directory=tt_friend_directory)), "ZL" : Process("ZL", ZLEstimation (era, directory, tt, friend_directory=tt_friend_directory)), "TTL" : Process("TTL", TTLEstimation (era, directory, tt, friend_directory=tt_friend_directory)), "VVL" : Process("VVL", VVLEstimation (era, directory, tt, friend_directory=tt_friend_directory)), "ggH" : Process("ggH125", ggHEstimation ("ggH125", era, directory, tt, friend_directory=tt_friend_directory)), "qqH" : Process("qqH125", qqHEstimation ("qqH125", era, directory, tt, friend_directory=tt_friend_directory)), # "WH" : Process("WH125", WHEstimation (era, directory, tt, friend_directory=tt_friend_directory)), # "ZH" : Process("ZH125", ZHEstimation (era, directory, tt, friend_directory=tt_friend_directory)), # "ttH" : Process("ttH125", ttHEstimation (era, directory, tt, friend_directory=tt_friend_directory)), } tt_processes["FAKESEMB"] = Process("jetFakesEMB", NewFakeEstimationTT(era, directory, tt, [tt_processes[process] for process in ["EMB", "ZL", "TTL", "VVL"]], tt_processes["data"], friend_directory=tt_friend_directory+[ff_friend_directory])) em = EM() em_processes = { "data" : Process("data_obs", DataEstimation (era, directory, em, friend_directory=em_friend_directory)), "EMB" : Process("EMB", ZTTEmbeddedEstimation (era, directory, em, friend_directory=em_friend_directory)), "ZL" : Process("ZL", ZLEstimation (era, directory, em, friend_directory=em_friend_directory)), "TTL" : Process("TTL", TTLEstimation (era, directory, em, friend_directory=em_friend_directory)), "VVL" : Process("VVL", VVLEstimation (era, directory, em, friend_directory=em_friend_directory)), "W" : Process("W", WEstimation (era, directory, em, friend_directory=em_friend_directory)), "ggH" : Process("ggH125", ggHEstimation ("ggH125", era, directory, em, friend_directory=em_friend_directory)), "qqH" : Process("qqH125", qqHEstimation ("qqH125", era, directory, em, friend_directory=em_friend_directory)), # "WH" : Process("WH125", WHEstimation (era, directory, em, friend_directory=em_friend_directory)), # "ZH" : Process("ZH125", ZHEstimation (era, directory, em, friend_directory=em_friend_directory)), # "ttH" : Process("ttH125", ttHEstimation (era, directory, em, friend_directory=em_friend_directory)), } em_processes["QCDEMB"] = Process("QCDEMB", QCDEstimation_SStoOS_MTETEM(era, directory, em, [em_processes[process] for process in ["EMB", "ZL", "W", "VVL"]], em_processes["data"], extrapolation_factor=1.0, qcd_weight = Weight("em_qcd_extrap_up_Weight","qcd_weight"))) channels = { "mt" : mt, "et" : et, "tt" : tt, "em" : em, } processes = { "mt" : mt_processes, "et" : et_processes, "tt" : tt_processes, "em" : em_processes, } # Variables and categories binning = yaml.load(open(args.binning)) variable_names = [ "ME_D", "dijetpt", "jdeta", "mjj",# "jpt_1", "jpt_2", "njets", # "bpt_1", "bpt_2", "nbtag", # "DiTauDeltaR", "ptvis", "pt_tt", "pt_tt_puppi", "pt_ttjj", "pt_ttjj_puppi", "eta_sv", "eta_fastmtt", "pt_tt", "pt_tt_puppi", "pt_ttjj", "pt_ttjj_puppi", # "mt_1", "mt_2", "mTdileptonMET", "pZetaMissVis", "mt_1", "pZetaMissVis", # "mt_1_puppi", "mt_2_puppi", "mTdileptonMET_puppi", "pZetaPuppiMissVis", "mt_1_puppi", "pZetaPuppiMissVis", # "m_sv", "m_fastmtt", "m_vis", ] categories = { "mt" : [], "et" : [], "tt" : [], "em" : [], } for variable in variable_names: for ch in args.channels: cut_values = binning["control"][ch][variable]["bins"] for cut in cut_values: categories[ch].append(Category("%s-less-%s"%(variable, str(cut).replace(".","p")),channels[ch], Cuts(Cut("%s < %s"%(variable, str(cut)))), variable=None)) categories[ch].append(Category("%s-greater-%s"%(variable, str(cut).replace(".","p")),channels[ch], Cuts(Cut("%s > %s"%(variable, str(cut)))), variable=None)) # Nominal histograms for ch in args.channels: for process, category in product(processes[ch].values(), categories[ch]): systematics.add( Systematic( category=category, process=process, analysis="smhtt", era=era, variation=Nominal(), mass="125")) # Produce histograms systematics.produce()
def main(args): # Write arparse arguments to YAML config logger.debug("Write argparse arguments to YAML config.") output_config = {} output_config["base_path"] = args.base_path output_config["friend_paths"] = args.friend_paths output_config["output_path"] = args.output_path output_config["output_filename"] = args.output_filename output_config["tree_path"] = args.tree_path output_config["event_branch"] = args.event_branch output_config["training_weight_branch"] = args.training_weight_branch # Define era if "2016" in args.era: from shape_producer.estimation_methods_2016 import ggHEstimation, qqHEstimation, HWWEstimation from shape_producer.era import Run2016 era = Run2016(args.database) elif "2017" in args.era: from shape_producer.estimation_methods_2017 import ggHEstimation, qqHEstimation, HWWEstimation, DataEstimation from shape_producer.era import Run2017 era = Run2017(args.database) else: logger.fatal("Era {} is not implemented.".format(args.era)) raise Exception def estimationMethodAndClassMapGenerator(): estimationMethodList = [ DataEstimation(era, args.base_path, channel), ggHEstimation("ggH125", era, args.base_path, channel), qqHEstimation("qqH125", era, args.base_path, channel), HWWEstimation(era, args.base_path, channel), ] return (estimationMethodList) channelDict = {} channelDict["2016"] = { "mt": MTSM2016(), "et": ETSM2016(), "tt": TTSM2016(), "em": EMSM2016() } channelDict["2017"] = { "mt": MTSM2017(), "et": ETSM2017(), "tt": TTSM2017(), "em": EMSM2017() } channel = channelDict[args.era][args.channel] # Set up `processes` part of config output_config["processes"] = {} # Additional cuts additional_cuts = Cuts() logger.warning("Use additional cuts for mt: %s", additional_cuts.expand()) estimationMethodList = estimationMethodAndClassMapGenerator() for estimation in estimationMethodList: output_config["processes"][estimation.name] = { "files": [ str(f).replace(args.base_path.rstrip("/") + "/", "") for f in estimation.get_files() ], "cut_string": (estimation.get_cuts() + channel.cuts + additional_cuts).expand(), "weight_string": estimation.get_weights().extract(), } # Write output config if not os.path.exists(args.output_path): os.makedirs(args.output_path) logger.info("Write config to file: {}".format(args.output_config)) yaml.dump(output_config, open(args.output_config, 'w'), default_flow_style=False)
def main(args): # Define era if "2016" in args.era: from shape_producer.era import Run2016 era = Run2016(args.datasets) else: logger.fatal("Era {} is not implemented.".format(args.era)) raise Exception # Load variables variables = yaml.load(open(args.variables))["variables"] # Define bins and range of binning for variables in enabled channels channels = ["et", "mt", "tt"] num_borders = 9 min_percentile = 1.0 max_percentile = 99.0 config = {"gof": {}} # Channel: ET if "et" in channels: # Get properties channel = ETSM() logger.info("Channel: et") dict_ = {} additional_cuts = Cuts() logger.warning("Use additional cuts for et: %s", additional_cuts.expand()) dict_ = get_properties(dict_, era, channel, args.directory, additional_cuts) # Build chain dict_["tree_path"] = "et_nominal/ntuple" chain = build_chain(dict_) # Get percentiles and calculate 1d binning binning = get_1d_binning("et", chain, variables, min_percentile, max_percentile, num_borders) # Add binning for unrolled 2d distributions binning = add_2d_unrolled_binning(variables, binning) # Append binning to config config["gof"]["et"] = binning # Channel: MT if "mt" in channels: # Get properties channel = MTSM() logger.info("Channel: mt") dict_ = {} additional_cuts = Cuts() logger.warning("Use additional cuts for mt: %s", additional_cuts.expand()) dict_ = get_properties(dict_, era, channel, args.directory, additional_cuts) # Build chain dict_["tree_path"] = "mt_nominal/ntuple" chain = build_chain(dict_) # Get percentiles binning = get_1d_binning("mt", chain, variables, min_percentile, max_percentile, num_borders) # Add binning for unrolled 2d distributions binning = add_2d_unrolled_binning(variables, binning) # Append binning to config config["gof"]["mt"] = binning # Channel: TT if "tt" in channels: # Get properties channel = TTSM() logger.info("Channel: tt") dict_ = {} additional_cuts = Cuts() logger.warning("Use additional cuts for tt: %s", additional_cuts.expand()) dict_ = get_properties(dict_, era, channel, args.directory, additional_cuts) # Build chain dict_["tree_path"] = "tt_nominal/ntuple" chain = build_chain(dict_) # Get percentiles binning = get_1d_binning("tt", chain, variables, min_percentile, max_percentile, num_borders) # Add binning for unrolled 2d distributions binning = add_2d_unrolled_binning(variables, binning) # Append binning to config config["gof"]["tt"] = binning # Write config logger.info("Write binning config to %s.", args.output) yaml.dump(config, open(args.output, 'w'))
def main(args): # Container for all distributions to be drawn logger.info("Set up shape variations.") systematics = Systematics("fake-factors/{}_ff_yields.root".format( args.tag), num_threads=args.num_threads) # Era selection if "2017" in args.era: from shape_producer.estimation_methods_Fall17 import DataEstimation, ZTTEstimation, ZTTEmbeddedEstimation, ZLEstimation, ZJEstimation, TTLEstimation, TTJEstimation, TTTEstimation, VVLEstimation, VVTEstimation, VVJEstimation, WEstimation, ggHEstimation, ggHEstimation_0J, ggHEstimation_1J_PTH_0_60, ggHEstimation_1J_PTH_60_120, ggHEstimation_1J_PTH_120_200, ggHEstimation_1J_PTH_GT200, ggHEstimation_GE2J_PTH_0_60, ggHEstimation_GE2J_PTH_60_120, ggHEstimation_GE2J_PTH_120_200, ggHEstimation_GE2J_PTH_GT200, ggHEstimation_VBFTOPO_JET3, ggHEstimation_VBFTOPO_JET3VETO, qqHEstimation, qqHEstimation_VBFTOPO_JET3VETO, qqHEstimation_VBFTOPO_JET3, qqHEstimation_REST, qqHEstimation_VH2JET, qqHEstimation_PTJET1_GT200 from shape_producer.era import Run2017 era = Run2017(args.datasets) else: logger.critical("Era {} is not implemented.".format(args.era)) raise Exception # Channels and processes # yapf: disable directory = args.directory et_friend_directory = args.et_friend_directory mt_friend_directory = args.mt_friend_directory tt_friend_directory = args.tt_friend_directory mt = MTSM2017() mt.cuts.remove("tau_iso") mt.cuts.add(Cut("(byTightIsolationMVArun2017v2DBoldDMwLT2017_2<0.5&&byVLooseIsolationMVArun2017v2DBoldDMwLT2017_2>0.5)", "tau_anti_iso")) mt_processes = { "data" : Process("data_obs", DataEstimation (era, directory, mt, friend_directory=mt_friend_directory)), "EMB" : Process("EMB", ZTTEmbeddedEstimation(era, directory, mt, friend_directory=mt_friend_directory)), "ZTT" : Process("ZTT", ZTTEstimation (era, directory, mt, friend_directory=mt_friend_directory)), "ZJ" : Process("ZJ", ZJEstimation (era, directory, mt, friend_directory=mt_friend_directory)), "ZL" : Process("ZL", ZLEstimation (era, directory, mt, friend_directory=mt_friend_directory)), "TTT" : Process("TTT", TTTEstimation (era, directory, mt, friend_directory=mt_friend_directory)), "TTJ" : Process("TTJ", TTJEstimation (era, directory, mt, friend_directory=mt_friend_directory)), "TTL" : Process("TTL", TTLEstimation (era, directory, mt, friend_directory=mt_friend_directory)), "VVT" : Process("VVT", VVTEstimation (era, directory, mt, friend_directory=mt_friend_directory)), "VVJ" : Process("VVJ", VVJEstimation (era, directory, mt, friend_directory=mt_friend_directory)), "VVL" : Process("VVL", VVLEstimation (era, directory, mt, friend_directory=mt_friend_directory)), "W" : Process("W", WEstimation (era, directory, mt, friend_directory=mt_friend_directory)) } et = ETSM2017() et.cuts.remove("tau_iso") et.cuts.add(Cut("(byTightIsolationMVArun2017v2DBoldDMwLT2017_2<0.5&&byVLooseIsolationMVArun2017v2DBoldDMwLT2017_2>0.5)", "tau_anti_iso")) et_processes = { "data" : Process("data_obs", DataEstimation (era, directory, et, friend_directory=et_friend_directory)), "EMB" : Process("EMB", ZTTEmbeddedEstimation(era, directory, et, friend_directory=et_friend_directory)), "ZTT" : Process("ZTT", ZTTEstimation (era, directory, et, friend_directory=et_friend_directory)), "ZJ" : Process("ZJ", ZJEstimation (era, directory, et, friend_directory=et_friend_directory)), "ZL" : Process("ZL", ZLEstimation (era, directory, et, friend_directory=et_friend_directory)), "TTT" : Process("TTT", TTTEstimation (era, directory, et, friend_directory=et_friend_directory)), "TTJ" : Process("TTJ", TTJEstimation (era, directory, et, friend_directory=et_friend_directory)), "TTL" : Process("TTL", TTLEstimation (era, directory, et, friend_directory=et_friend_directory)), "VVT" : Process("VVT", VVTEstimation (era, directory, et, friend_directory=et_friend_directory)), "VVJ" : Process("VVJ", VVJEstimation (era, directory, et, friend_directory=et_friend_directory)), "VVL" : Process("VVL", VVLEstimation (era, directory, et, friend_directory=et_friend_directory)), "W" : Process("W", WEstimation (era, directory, et, friend_directory=et_friend_directory)) } #in tt two 'channels' are needed: antiisolated region for each tau respectively tt1 = TTSM2017() tt1.cuts.remove("tau_1_iso") tt1.cuts.add(Cut("(byTightIsolationMVArun2017v2DBoldDMwLT2017_1<0.5&&byVLooseIsolationMVArun2017v2DBoldDMwLT2017_1>0.5)", "tau_1_anti_iso")) tt1_processes = { "data" : Process("data_obs", DataEstimation (era, directory, tt1, friend_directory=tt_friend_directory)), "EMB" : Process("EMB", ZTTEmbeddedEstimation(era, directory, tt1, friend_directory=tt_friend_directory)), "ZTT" : Process("ZTT", ZTTEstimation (era, directory, tt1, friend_directory=tt_friend_directory)), "ZJ" : Process("ZJ", ZJEstimation (era, directory, tt1, friend_directory=tt_friend_directory)), "ZL" : Process("ZL", ZLEstimation (era, directory, tt1, friend_directory=tt_friend_directory)), "TTT" : Process("TTT", TTTEstimation (era, directory, tt1, friend_directory=tt_friend_directory)), "TTJ" : Process("TTJ", TTJEstimation (era, directory, tt1, friend_directory=tt_friend_directory)), "TTL" : Process("TTL", TTLEstimation (era, directory, tt1, friend_directory=tt_friend_directory)), "VVT" : Process("VVT", VVTEstimation (era, directory, tt1, friend_directory=tt_friend_directory)), "VVJ" : Process("VVJ", VVJEstimation (era, directory, tt1, friend_directory=tt_friend_directory)), "VVL" : Process("VVL", VVLEstimation (era, directory, tt1, friend_directory=tt_friend_directory)), "W" : Process("W", WEstimation (era, directory, tt1, friend_directory=tt_friend_directory)) } tt2 = TTSM2017() tt2.cuts.remove("tau_2_iso") tt2.cuts.add(Cut("(byTightIsolationMVArun2017v2DBoldDMwLT2017_2<0.5&&byVLooseIsolationMVArun2017v2DBoldDMwLT2017_2>0.5)", "tau_2_anti_iso")) tt2_processes = { "data" : Process("data_obs", DataEstimation (era, directory, tt2, friend_directory=tt_friend_directory)), "EMB" : Process("EMB", ZTTEmbeddedEstimation(era, directory, tt2, friend_directory=tt_friend_directory)), "ZTT" : Process("ZTT", ZTTEstimation (era, directory, tt2, friend_directory=tt_friend_directory)), "ZJ" : Process("ZJ", ZJEstimation (era, directory, tt2, friend_directory=tt_friend_directory)), "ZL" : Process("ZL", ZLEstimation (era, directory, tt2, friend_directory=tt_friend_directory)), "TTT" : Process("TTT", TTTEstimation (era, directory, tt2, friend_directory=tt_friend_directory)), "TTJ" : Process("TTJ", TTJEstimation (era, directory, tt2, friend_directory=tt_friend_directory)), "TTL" : Process("TTL", TTLEstimation (era, directory, tt2, friend_directory=tt_friend_directory)), "VVT" : Process("VVT", VVTEstimation (era, directory, tt2, friend_directory=tt_friend_directory)), "VVJ" : Process("VVJ", VVJEstimation (era, directory, tt2, friend_directory=tt_friend_directory)), "VVL" : Process("VVL", VVLEstimation (era, directory, tt2, friend_directory=tt_friend_directory)), "W" : Process("W", WEstimation (era, directory, tt2, friend_directory=tt_friend_directory)) } # Variables and categories config = yaml.load(open("fake-factors/config.yaml")) if not args.config in config.keys(): logger.critical("Requested config key %s not available in fake-factors/config.yaml!" % args.config) raise Exception config = config[args.config] et_categories = [] # et et_categories.append( Category( "inclusive", et, Cuts(), variable=Variable(args.config, VariableBinning(config["et"]["binning"]), config["et"]["expression"]))) for i, label in enumerate(["ggh", "qqh", "ztt", "zll", "w", "tt", "ss", "misc"]): et_categories.append( Category( label, et, Cuts( Cut("et_max_index=={index}".format(index=i), "exclusive_score")), variable=Variable(args.config, VariableBinning(config["et"]["binning"]), config["et"]["expression"]))) mt_categories = [] # mt mt_categories.append( Category( "inclusive", mt, Cuts(), variable=Variable(args.config, VariableBinning(config["mt"]["binning"]), config["mt"]["expression"]))) for i, label in enumerate(["ggh", "qqh", "ztt", "zll", "w", "tt", "ss", "misc"]): mt_categories.append( Category( label, mt, Cuts( Cut("mt_max_index=={index}".format(index=i), "exclusive_score")), variable=Variable(args.config, VariableBinning(config["mt"]["binning"]), config["mt"]["expression"]))) tt1_categories = [] tt2_categories = [] # tt tt1_categories.append( Category( "tt1_inclusive", tt1, Cuts(), variable=Variable(args.config, VariableBinning(config["tt"]["binning"]), config["tt"]["expression"]))) tt2_categories.append( Category( "tt2_inclusive", tt2, Cuts(), variable=Variable(args.config, VariableBinning(config["tt"]["binning"]), config["tt"]["expression"]))) for i, label in enumerate(["ggh", "qqh", "ztt", "noniso", "misc"]): tt1_categories.append( Category( "tt1_"+label, tt1, Cuts( Cut("tt_max_index=={index}".format(index=i), "exclusive_score")), variable=Variable(args.config, VariableBinning(config["tt"]["binning"]), config["tt"]["expression"]))) tt2_categories.append( Category( "tt2_"+label, tt2, Cuts( Cut("tt_max_index=={index}".format(index=i), "exclusive_score")), variable=Variable(args.config, VariableBinning(config["tt"]["binning"]), config["tt"]["expression"]))) # Nominal histograms # yapf: enable for process, category in product(et_processes.values(), et_categories): systematics.add( Systematic(category=category, process=process, analysis="smhtt", era=era, variation=Nominal(), mass="125")) for process, category in product(mt_processes.values(), mt_categories): systematics.add( Systematic(category=category, process=process, analysis="smhtt", era=era, variation=Nominal(), mass="125")) for process, category in product(tt1_processes.values(), tt1_categories): systematics.add( Systematic(category=category, process=process, analysis="smhtt", era=era, variation=Nominal(), mass="125")) for process, category in product(tt2_processes.values(), tt2_categories): systematics.add( Systematic(category=category, process=process, analysis="smhtt", era=era, variation=Nominal(), mass="125")) # Produce histograms logger.info("Start producing shapes.") systematics.produce() logger.info("Done producing shapes.")
def main(args): # Container for all distributions to be drawn systematics_mm = Systematics("shapes_mm_recoilunc_2016.root", num_threads=args.num_threads, find_unique_objects=True) # Era era = Run2016(args.datasets) # Channels and processes # yapf: disable directory = args.directory mm = MM() mm_processes = { "ZL" : Process("ZL", ZLEstimation (era, directory, mm, friend_directory=[])), } # Variables and categories binning = yaml.load(open(args.binning)) mm_categories = [] variable_bins = { "njets" : [0, 1, 2], "genbosonpt" : [0, 10, 20, 30, 50], } variable_names = [ "recoilParToZ", "puppirecoilParToZ", ] for njets_bin in range(len(variable_bins["njets"])): for pt_bin in range(len(variable_bins["genbosonpt"])): name = "njets_bin_%s_vs_ptvis_bin_%s"%(str(njets_bin),str(pt_bin)) category_njets = "" category_pt = "" if njets_bin == (len(variable_bins["njets"]) - 1): category_njets = "njets >= %s"%str(variable_bins["njets"][njets_bin]) else: category_njets = "njets == %s"%str(variable_bins["njets"][njets_bin]) if pt_bin == (len(variable_bins["genbosonpt"]) - 1): category_pt = "genbosonpt > %s"%str(variable_bins["genbosonpt"][pt_bin]) else: category_pt= "genbosonpt > %s && genbosonpt <= %s"%(str(variable_bins["genbosonpt"][pt_bin]),str(variable_bins["genbosonpt"][pt_bin+1])) print category_njets, category_pt cuts = Cuts( Cut(category_njets,"njets_category"), Cut(category_pt,"ptvis_category"), Cut("m_vis > 70 && m_vis < 110","z_peak") ) for v in variable_names: mm_categories.append( Category( name, mm, cuts, variable=Variable("relative_%s"%v,ConstantBinning(400,-20.0,20.0), expression="-%s/genbosonpt"%v))) # Nominal histograms for process, category in product(mm_processes.values(), mm_categories): systematics_mm.add( Systematic( category=category, process=process, analysis="smhtt", era=era, variation=Nominal(), mass="125")) # Produce histograms systematics_mm.produce()
def main(args): # Systematics container logger.info("Set up shape variations.") systematics = Systematics("shapes.root", num_threads=args.num_threads) # Era selection from shape_producer.estimation_methods_2017 import DataEstimation, ZTTEstimation, ZTTEmbeddedEstimation, ZLEstimation, ZJEstimation, TTLEstimation, TTJEstimation, TTTEstimation, VVLEstimation, VVTEstimation, VVJEstimation, WEstimation, ggHEstimation, qqHEstimation, VHEstimation, WHEstimation, ZHEstimation, ttHEstimation, QCDEstimation_ABCD_TT_ISO2, QCDEstimation_SStoOS_MTETEM, NewFakeEstimationLT, NewFakeEstimationTT, HWWEstimation, ggHWWEstimation, qqHWWEstimation from shape_producer.era import Run2017 era = Run2017(args.datasets) # Channels and processes directory = args.directory et_friend_directory = args.et_friend_directory mt_friend_directory = args.mt_friend_directory tt_friend_directory = args.tt_friend_directory em_friend_directory = args.em_friend_directory ff_friend_directory = args.fake_factor_friend_directory mt = MTSM2017() mt_processes = { "data" : Process("data_obs", DataEstimation (era, directory, mt, friend_directory=mt_friend_directory)), "ZTT" : Process("ZTT", ZTTEstimation (era, directory, mt, friend_directory=mt_friend_directory)), "ZJ" : Process("ZJ", ZJEstimation (era, directory, mt, friend_directory=mt_friend_directory)), "ZL" : Process("ZL", ZLEstimation (era, directory, mt, friend_directory=mt_friend_directory)), "TTT" : Process("TTT", TTTEstimation (era, directory, mt, friend_directory=mt_friend_directory)), "TTJ" : Process("TTJ", TTJEstimation (era, directory, mt, friend_directory=mt_friend_directory)), "TTL" : Process("TTL", TTLEstimation (era, directory, mt, friend_directory=mt_friend_directory)), "VVT" : Process("VVT", VVTEstimation (era, directory, mt, friend_directory=mt_friend_directory)), "VVJ" : Process("VVJ", VVJEstimation (era, directory, mt, friend_directory=mt_friend_directory)), "VVL" : Process("VVL", VVLEstimation (era, directory, mt, friend_directory=mt_friend_directory)), "W" : Process("W", WEstimation (era, directory, mt, friend_directory=mt_friend_directory)), "ggH125": Process("ggH125", ggHEstimation ("ggH125", era, directory, mt, friend_directory=mt_friend_directory)), "qqH125": Process("qqH125", qqHEstimation ("qqH125", era, directory, mt, friend_directory=mt_friend_directory)) } mt_processes["QCD"] = Process("QCD", QCDEstimation_SStoOS_MTETEM(era, directory, mt, [mt_processes[process] for process in ["ZTT", "ZL", "ZJ", "W", "TTL", "TTJ", "VVL", "VVJ"]], mt_processes["data"], friend_directory=mt_friend_directory, extrapolation_factor=1.00)) # Variables and categories variable_names = ["m_vis"] binning = yaml.load(open(args.binning), Loader=yaml.Loader) variables = {v: Variable(v,VariableBinning(binning["control"]["mt"][v]["bins"]), expression=binning["control"]["mt"][v]["expression"]) for v in variable_names} cuts = Cuts() mt_categories = [] for var in variable_names: mt_categories.append( Category( var, mt, cuts, variable=variables[var])) # Nominal histograms for process, category in product(mt_processes.values(), mt_categories): systematics.add( Systematic( category=category, process=process, analysis="smhtt", era=era, variation=Nominal(), mass="125")) # Produce histograms logger.info("Start producing shapes.") systematics.produce() logger.info("Done producing shapes.")
def main(args): # Container for all distributions to be drawn systematics_mm = Systematics("fitrecoil_mm_2016.root", num_threads=args.num_threads, find_unique_objects=True) # Era era = Run2016(args.datasets) # Channels and processes # yapf: disable directory = args.directory mm_friend_directory = args.mm_friend_directory mm = MM() mm_processes = { "data" : Process("data_obs", DataEstimation (era, directory, mm, friend_directory=mm_friend_directory)), "ZTT" : Process("ZTT", ZTTEstimation (era, directory, mm, friend_directory=mm_friend_directory)), "ZL" : Process("ZL", ZLEstimation (era, directory, mm, friend_directory=mm_friend_directory)), "TTT" : Process("TTT", TTTEstimation (era, directory, mm, friend_directory=mm_friend_directory)), "TTL" : Process("TTL", TTLEstimation (era, directory, mm, friend_directory=mm_friend_directory)), "VVT" : Process("VVT", VVTEstimation (era, directory, mm, friend_directory=mm_friend_directory)), "VVL" : Process("VVL", VVLEstimation (era, directory, mm, friend_directory=mm_friend_directory)), "W" : Process("W", WEstimation (era, directory, mm, friend_directory=mm_friend_directory)), } mm_processes["QCD"] = Process("QCD", QCDEstimation_SStoOS_MTETEM(era, directory, mm, [mm_processes[process] for process in ["ZTT", "ZL", "W", "TTT", "TTL", "VVT", "VVL"]], mm_processes["data"], friend_directory=mm_friend_directory, extrapolation_factor=2.0)) # Variables and categories mm_categories = [] variable_names = [ # "met", "metphi", # "puppimet", "puppimetphi", "metParToZ", "metPerpToZ", "puppimetParToZ", "puppimetPerpToZ", # "recoilParToZ", "recoilPerpToZ", # "puppirecoilParToZ", "puppirecoilPerpToZ", ] variables = [Variable(v,ConstantBinning(25,-100.0,100.0)) for v in variable_names] cuts = [ Cut("njets == 0", "0jet"), Cut("njets == 1", "1jet"), Cut("njets >= 2", "ge2jet"), ] for cut in cuts: for var in variables: mm_categories.append( Category( cut.name, mm, Cuts(Cut("m_vis > 70 && m_vis < 110","m_vis_peak"), cut), variable=var)) for process, category in product(mm_processes.values(), mm_categories): systematics_mm.add( Systematic( category=category, process=process, analysis="smhtt", era=era, variation=Nominal(), mass="125")) # Recoil correction unc recoil_resolution_variations = create_systematic_variations( "CMS_htt_boson_reso_met_Run2016", "metRecoilResolution", DifferentPipeline) recoil_response_variations = create_systematic_variations( "CMS_htt_boson_scale_met_Run2016", "metRecoilResponse", DifferentPipeline) for variation in recoil_resolution_variations + recoil_response_variations: systematics_mm.add_systematic_variation( variation=variation, process=mm_processes["ZL"], channel=mm, era=era) # Produce histograms systematics_mm.produce()
def main(args): # Container for all distributions to be drawn logger.info("Set up shape variations.") systematics = Systematics( "{}_cutbased_shapes_{}.root".format(args.tag, args.discriminator_variable), num_threads=args.num_threads, skip_systematic_variations=args.skip_systematic_variations) # Era selection if "2016" in args.era: from shape_producer.estimation_methods_2016 import DataEstimation, ZTTEstimation, ZTTEmbeddedEstimation, ZLEstimation, ZJEstimation, TTTEstimation, TTLEstimation, TTJEstimation, VVTEstimation, VVLEstimation, VVJEstimation, WEstimation, HTTEstimation, ggHEstimation, qqHEstimation, VHEstimation, WHEstimation, ZHEstimation, ttHEstimation, HWWEstimation, ggHWWEstimation, qqHWWEstimation, SUSYggHEstimation, SUSYbbHEstimation, QCDEstimation_SStoOS_MTETEM, QCDEstimationTT, NewFakeEstimationLT, NewFakeEstimationTT from shape_producer.era import Run2016 era = Run2016(args.datasets) else: logger.critical("Era {} is not implemented.".format(args.era)) raise Exception # Channels and processes # yapf: disable directory = args.directory friend_directories = { "et" : args.et_friend_directory, "mt" : args.mt_friend_directory, "tt" : args.tt_friend_directory, "em" : args.em_friend_directory, } ff_friend_directory = args.fake_factor_friend_directory channel_dict = { "et": ETMSSM2016(), "mt": MTMSSM2016(), "tt": TTMSSM2016(), "em": EMMSSM2016(), } susyggH_masses = [80, 90, 100, 110, 120, 130, 140, 160, 180, 200, 250, 300, 350, 400, 450, 500, 600, 700, 800, 900, 1000, 1200, 1400, 1500, 1600, 1800, 2000, 2300, 2600, 2900, 3200] susybbH_masses = [80, 90, 100, 110, 120, 130, 140, 160, 180, 200, 250, 300, 350, 400, 450, 500, 600, 700, 800, 900, 1000, 1200, 1400, 1500, 1600, 1800, 2000, 2300, 2600, 2900, 3200] susybbH_nlo_masses = [] processes = { "mt" : {}, "et" : {}, "tt" : {}, "em" : {}, } for ch in args.channels: # common processes if args.shape_group == "backgrounds": processes[ch]["data"] = Process("data_obs", DataEstimation (era, directory, channel_dict[args.era][ch], friend_directory=friend_directories[ch])) processes[ch]["EMB"] = Process("EMB", ZTTEmbeddedEstimation (era, directory, channel_dict[args.era][ch], friend_directory=friend_directories[ch])) processes[ch]["ZL"] = Process("ZL", ZLEstimation (era, directory, channel_dict[args.era][ch], friend_directory=friend_directories[ch])) processes[ch]["TTL"] = Process("TTL", TTLEstimation (era, directory, channel_dict[args.era][ch], friend_directory=friend_directories[ch])) processes[ch]["VVL"] = Process("VVL", VVLEstimation (era, directory, channel_dict[args.era][ch], friend_directory=friend_directories[ch])) processes[ch]["VH125"] = Process("VH125", VHEstimation (era, directory, channel_dict[args.era][ch], friend_directory=friend_directories[ch])) processes[ch]["WH125"] = Process("WH125", WHEstimation (era, directory, channel_dict[args.era][ch], friend_directory=friend_directories[ch])) processes[ch]["ZH125"] = Process("ZH125", ZHEstimation (era, directory, channel_dict[args.era][ch], friend_directory=friend_directories[ch])) processes[ch]["ttH125"] = Process("ttH125", ttHEstimation (era, directory, channel_dict[args.era][ch], friend_directory=friend_directories[ch])) processes[ch]["ggHWW125"] = Process("ggHWW125", ggHWWEstimation (era, directory, channel_dict[ch], friend_directory=friend_directories[ch])) processes[ch]["qqHWW125"] = Process("qqHWW125", qqHWWEstimation (era, directory, channel_dict[ch], friend_directory=friend_directories[ch])) # mssm ggH and bbH signals if "gg" in args.shape_group: for m in susyggH_masses: name = args.shape_group + "_" + str(m) processes[ch][name] = Process(name, SUSYggHEstimation(era, directory, channel_dict[ch], str(m), args.shape_group.replace("gg",""), friend_directory=friend_directories[ch])) if args.shape_group == "bbH": for m in susybbH_masses: name = "bbH_" + str(m) processes[ch][name] = Process(name, SUSYbbHEstimation(era, directory, channel_dict[ch], str(m), friend_directory=friend_directories[ch])) if args.shape_group == "sm_signals": # stage 0 and stage 1.1 ggh and qqh for ggH_htxs in ggHEstimation.htxs_dict: processes[ch][ggH_htxs] = Process(ggH_htxs, ggHEstimation(ggH_htxs, era, directory, channel_dict[ch], friend_directory=[])) # friend_directories[ch])) for qqH_htxs in qqHEstimation.htxs_dict: processes[ch][qqH_htxs] = Process(qqH_htxs, qqHEstimation(qqH_htxs, era, directory, channel_dict[ch], friend_directory=[])) # friend_directories[ch])) # channel-specific processes if args.shape_group == "backgrounds": if ch in ["mt", "et"]: processes[ch]["FAKES"] = Process("jetFakes", NewFakeEstimationLT(era, directory, channel_dict[ch], [processes[ch][process] for process in ["EMB", "ZL", "TTL", "VVL"]], processes[ch]["data"], friend_directory=friend_directories[ch]+[ff_friend_directory])) elif ch == "tt": processes[ch]["FAKES"] = Process("jetFakes", NewFakeEstimationTT(era, directory, channel_dict[ch], [processes[ch][process] for process in ["EMB", "ZL", "TTL", "VVL"]], processes[ch]["data"], friend_directory=friend_directories[ch]+[ff_friend_directory])) elif ch == "em": processes[ch]["W"] = Process("W", WEstimation(era, directory, channel_dict[ch], friend_directory=friend_directories[ch])) processes[ch]["QCD"] = Process("QCD", QCDEstimation_SStoOS_MTETEM(era, directory, channel_dict[ch], [processes[ch][process] for process in ["EMB", "ZL", "W", "VVL", "TTL"]], processes[ch]["data"], extrapolation_factor=1.0, qcd_weight = Weight("em_qcd_extrap_up_Weight","qcd_weight"))) # Variables and categories if sys.version_info.major <= 2 and sys.version_info.minor <= 7 and sys.version_info.micro <= 15: binning = yaml.load(open(args.binning)) else: binning = yaml.load(open(args.binning), Loader=yaml.FullLoader) # Cut-based analysis shapes categories = { "mt" : [], "et" : [], "tt" : [], "em" : [], } for ch in args.channels: discriminator = construct_variable(binning, args.discriminator_variable) # Get dictionary mapping category name to cut objects. cut_dict = create_cut_map(binning, ch) # Create full set of cuts from dict and create category using these cuts. cuts = Cuts(*cut_dict[args.category]) categories[ch].append(Category(args.category, channel_dict[ch], cuts, variable=discriminator)) # Choice of activated signal processes signal_nicks = [] sm_htt_backgrounds_nicks = ["WH125", "ZH125", "VH125", "ttH125"] sm_hww_nicks = ["ggHWW125", "qqHWW125"] sm_htt_signals_nicks = [ggH_htxs for ggH_htxs in ggHEstimation.htxs_dict] + [qqH_htxs for qqH_htxs in qqHEstimation.htxs_dict] susy_nicks = [] if "gg" in args.shape_group: for m in susyggH_masses: susy_nicks.append(args.shape_group + "_" + str(m)) if args.shape_group == "bbH": for m in susybbH_masses: susy_nicks.append("bbH_" + str(m)) if args.shape_group == "backgrounds": signal_nicks = sm_htt_backgrounds_nicks + sm_hww_nicks elif args.shape_group == "sm_signals": signal_nicks = sm_htt_signals_nicks else: signal_nicks = susy_nicks # Nominal histograms for ch in args.channels: for process, category in product(processes[ch].values(), categories[ch]): systematics.add(Systematic(category=category, process=process, analysis="mssmvssm", era=era, variation=Nominal(), mass="125")) # Setup shapes variations # EMB: 10% removed events in ttbar simulation (ttbar -> real tau tau events) will be added/subtracted to ZTT shape to use as systematic if args.shape_group == "backgrounds": tttautau_process = {} for ch in args.channels: tttautau_process[ch] = Process("TTT", TTTEstimation(era, directory, channel_dict[ch], friend_directory=friend_directories[ch])) processes[ch]['ZTTpTTTauTauDown'] = Process("ZTTpTTTauTauDown", AddHistogramEstimationMethod("AddHistogram", "nominal", era, directory, channel_dict[ch], [processes[ch]["EMB"], tttautau_process[ch]], [1.0, -0.1])) processes[ch]['ZTTpTTTauTauUp'] = Process("ZTTpTTTauTauUp", AddHistogramEstimationMethod("AddHistogram", "nominal", era, directory, channel_dict[ch], [processes[ch]["EMB"], tttautau_process[ch]], [1.0, 0.1])) for category in categories[ch]: for updownvar in ["Down", "Up"]: systematics.add(Systematic(category=category, process=processes[ch]['ZTTpTTTauTau%s'%updownvar], analysis="smhtt", era=era, variation=Relabel("CMS_htt_emb_ttbar_Run2016", updownvar), mass="125")) # Prefiring weights prefiring_variations = [ ReplaceWeight("CMS_prefiring_Run2016", "prefireWeight", Weight("prefiringweightup", "prefireWeight"),"Up"), ReplaceWeight("CMS_prefiring_Run2016", "prefireWeight", Weight("prefiringweightdown", "prefireWeight"),"Down"), ] # Split JES shapes jet_es_variations = create_systematic_variations("CMS_scale_j_Absolute", "jecUncAbsolute", DifferentPipeline) jet_es_variations += create_systematic_variations("CMS_scale_j_Absolute_Run2016", "jecUncAbsoluteYear", DifferentPipeline) jet_es_variations += create_systematic_variations("CMS_scale_j_BBEC1", "jecUncBBEC1", DifferentPipeline) jet_es_variations += create_systematic_variations("CMS_scale_j_BBEC1_Run2016", "jecUncBBEC1Year", DifferentPipeline) jet_es_variations += create_systematic_variations("CMS_scale_j_EC2", "jecUncEC2", DifferentPipeline) jet_es_variations += create_systematic_variations("CMS_scale_j_EC2_Run2016", "jecUncEC2Year", DifferentPipeline) jet_es_variations += create_systematic_variations("CMS_scale_j_FlavorQCD", "jecUncFlavorQCD", DifferentPipeline) jet_es_variations += create_systematic_variations("CMS_scale_j_HF", "jecUncHF", DifferentPipeline) jet_es_variations += create_systematic_variations("CMS_scale_j_HF_Run2016", "jecUncHFYear", DifferentPipeline) jet_es_variations += create_systematic_variations("CMS_scale_j_RelativeBal", "jecUncRelativeBal", DifferentPipeline) jet_es_variations += create_systematic_variations("CMS_scale_j_RelativeSample_Run2016", "jecUncRelativeSampleYear", DifferentPipeline) # B-tagging btag_eff_variations = create_systematic_variations("CMS_htt_eff_b_Run2016", "btagEff", DifferentPipeline) mistag_eff_variations = create_systematic_variations("CMS_htt_mistag_b_Run2016", "btagMistag", DifferentPipeline) ## Variations common for all groups (most of the mc-related systematics) common_mc_variations = prefiring_variations + btag_eff_variations + mistag_eff_variations + jet_es_variations # MET energy scale. Note: only those variations for non-resonant processes are used in the stat. inference met_unclustered_variations = create_systematic_variations("CMS_scale_met_unclustered", "metUnclusteredEn", DifferentPipeline) # Recoil correction unc, for resonant processes recoil_variations = create_systematic_variations("CMS_htt_boson_reso_met_Run2016", "metRecoilResolution", DifferentPipeline) recoil_variations += create_systematic_variations("CMS_htt_boson_scale_met_Run2016", "metRecoilResponse", DifferentPipeline) # Tau energy scale (general, MC-specific & EMB-specific), it is mt, et & tt specific tau_es_variations = {} for unctype in ["", "_mc", "_emb"]: tau_es_variations[unctype] = create_systematic_variations("CMS_scale%s_t_3prong_Run2016"% (unctype), "tauEsThreeProng", DifferentPipeline) tau_es_variations[unctype] += create_systematic_variations("CMS_scale%s_t_3prong1pizero_Run2016"% (unctype), "tauEsThreeProngOnePiZero", DifferentPipeline) tau_es_variations[unctype] += create_systematic_variations("CMS_scale%s_t_1prong_Run2016"% (unctype), "tauEsOneProng", DifferentPipeline) tau_es_variations[unctype] += create_systematic_variations("CMS_scale%s_t_1prong1pizero_Run2016"% (unctype), "tauEsOneProngOnePiZero", DifferentPipeline) # Tau ID variations (general, MC-specific & EMB specific), it is mt, et & tt specific # in et and mt one nuisance per pT bin, in tt per dm tau_id_variations = {} for ch in ["et" , "mt", "tt"]: tau_id_variations[ch] = {} for unctype in ["", "_emb"]: tau_id_variations[ch][unctype] = [] if ch in ["et", "mt"]: pt = [30, 35, 40, 500, 1000, "inf"] for i, ptbin in enumerate(pt[:-1]): bindown = ptbin binup = pt[i+1] if binup == "inf": tau_id_variations[ch][unctype].append( ReplaceWeight("CMS_eff{unctype}_t_{bindown}-{binup}_Run2016".format(unctype=unctype,bindown=bindown, binup=binup), "taubyIsoIdWeight", Weight("(((pt_2 >= {bindown})*tauIDScaleFactorWeightUp_tight_DeepTau2017v2p1VSjet_2)+((pt_2 < {bindown})*tauIDScaleFactorWeight_tight_DeepTau2017v2p1VSjet_2))".format(bindown=bindown), "taubyIsoIdWeight"), "Up")) tau_id_variations[ch][unctype].append( ReplaceWeight("CMS_eff{unctype}_t_{bindown}-{binup}_Run2016".format(unctype=unctype, bindown=bindown, binup=binup), "taubyIsoIdWeight", Weight("(((pt_2 >= {bindown})*tauIDScaleFactorWeightDown_tight_DeepTau2017v2p1VSjet_2)+((pt_2 < {bindown})*tauIDScaleFactorWeight_tight_DeepTau2017v2p1VSjet_2))".format(bindown=bindown),"taubyIsoIdWeight"), "Down")) else: tau_id_variations[ch][unctype].append( ReplaceWeight("CMS_eff{unctype}_t_{bindown}-{binup}_Run2016".format(unctype=unctype, bindown=bindown, binup=binup), "taubyIsoIdWeight", Weight("(((pt_2 >= {bindown} && pt_2 <= {binup})*tauIDScaleFactorWeightUp_tight_DeepTau2017v2p1VSjet_2)+((pt_2 < {bindown} || pt_2 > {binup})*tauIDScaleFactorWeight_tight_DeepTau2017v2p1VSjet_2))".format(bindown=bindown, binup=binup),"taubyIsoIdWeight"), "Up")) tau_id_variations[ch][unctype].append( ReplaceWeight("CMS_eff{unctype}_t_{bindown}-{binup}_Run2016".format(unctype=unctype, bindown=bindown, binup=binup), "taubyIsoIdWeight", Weight("(((pt_2 >= {bindown} && pt_2 <= {binup})*tauIDScaleFactorWeightDown_tight_DeepTau2017v2p1VSjet_2)+((pt_2 < {bindown} || pt_2 > {binup})*tauIDScaleFactorWeight_tight_DeepTau2017v2p1VSjet_2))".format(bindown=bindown, binup=binup),"taubyIsoIdWeight"), "Down")) if ch in ["tt"]: for decaymode in [0, 1, 10, 11]: tau_id_variations[ch][unctype].append( ReplaceWeight("CMS_eff{unctype}_t_dm{dm}_Run2016".format(unctype=unctype, dm=decaymode), "taubyIsoIdWeight", Weight("(((decayMode_1=={dm})*tauIDScaleFactorWeightUp_tight_DeepTau2017v2p1VSjet_1)+((decayMode_1!={dm})*tauIDScaleFactorWeight_tight_DeepTau2017v2p1VSjet_1)*((decayMode_2=={dm})*tauIDScaleFactorWeightUp_tight_DeepTau2017v2p1VSjet_2)+((decayMode_2!={dm})*tauIDScaleFactorWeight_tight_DeepTau2017v2p1VSjet_2))".format(dm=decaymode), "taubyIsoIdWeight"), "Up")) tau_id_variations[ch][unctype].append( ReplaceWeight("CMS_eff{unctype}_t_dm{dm}_Run2016".format(unctype=unctype, dm=decaymode), "taubyIsoIdWeight", Weight("(((decayMode_1=={dm})*tauIDScaleFactorWeightDown_tight_DeepTau2017v2p1VSjet_1)+((decayMode_1!={dm})*tauIDScaleFactorWeight_tight_DeepTau2017v2p1VSjet_1)*((decayMode_2=={dm})*tauIDScaleFactorWeightDown_tight_DeepTau2017v2p1VSjet_2)+((decayMode_2!={dm})*tauIDScaleFactorWeight_tight_DeepTau2017v2p1VSjet_2))".format(dm=decaymode), "taubyIsoIdWeight"), "Down")) # Ele energy scale & smear uncertainties (MC-specific), it is et & em specific ele_es_variations = create_systematic_variations("CMS_scale_mc_e", "eleScale", DifferentPipeline) ele_es_variations += create_systematic_variations("CMS_reso_mc_e", "eleSmear", DifferentPipeline) # Ele energy scale (EMB-specific), it is et & em specific ele_es_emb_variations = create_systematic_variations("CMS_scale_emb_e", "eleEs", DifferentPipeline) # Z pt reweighting zpt_variations = create_systematic_variations("CMS_htt_dyShape_Run2016", "zPtReweightWeight", SquareAndRemoveWeight) # top pt reweighting top_pt_variations = create_systematic_variations( "CMS_htt_ttbarShape", "topPtReweightWeight", SquareAndRemoveWeight) # EMB charged track correction uncertainty (DM-dependent) decayMode_variations = [] decayMode_variations.append(ReplaceWeight("CMS_3ProngEff_Run2016", "decayMode_SF", Weight("embeddedDecayModeWeight_effUp_pi0Nom", "decayMode_SF"), "Up")) decayMode_variations.append(ReplaceWeight("CMS_3ProngEff_Run2016", "decayMode_SF", Weight("embeddedDecayModeWeight_effDown_pi0Nom", "decayMode_SF"), "Down")) decayMode_variations.append(ReplaceWeight("CMS_1ProngPi0Eff_Run2016", "decayMode_SF", Weight("embeddedDecayModeWeight_effNom_pi0Up", "decayMode_SF"), "Up")) decayMode_variations.append(ReplaceWeight("CMS_1ProngPi0Eff_Run2016", "decayMode_SF", Weight("embeddedDecayModeWeight_effNom_pi0Down", "decayMode_SF"), "Down")) # QCD for em qcd_variations = [] qcd_variations.append(ReplaceWeight("CMS_htt_qcd_0jet_rate_Run2016", "qcd_weight", Weight("em_qcd_osss_0jet_rateup_Weight", "qcd_weight"), "Up")) qcd_variations.append(ReplaceWeight("CMS_htt_qcd_0jet_rate_Run2016", "qcd_weight", Weight("em_qcd_osss_0jet_ratedown_Weight", "qcd_weight"), "Down")) qcd_variations.append(ReplaceWeight("CMS_htt_qcd_0jet_shape_Run2016", "qcd_weight", Weight("em_qcd_osss_0jet_shapeup_Weight", "qcd_weight"), "Up")) qcd_variations.append(ReplaceWeight("CMS_htt_qcd_0jet_shape_Run2016", "qcd_weight", Weight("em_qcd_osss_0jet_shapedown_Weight", "qcd_weight"), "Down")) qcd_variations.append(ReplaceWeight("CMS_htt_qcd_1jet_rate_Run2016", "qcd_weight", Weight("em_qcd_osss_1jet_rateup_Weight", "qcd_weight"), "Up")) qcd_variations.append(ReplaceWeight("CMS_htt_qcd_1jet_rate_Run2016", "qcd_weight", Weight("em_qcd_osss_1jet_ratedown_Weight", "qcd_weight"), "Down")) qcd_variations.append(ReplaceWeight("CMS_htt_qcd_1jet_shape_Run2016", "qcd_weight", Weight("em_qcd_osss_1jet_shapeup_Weight", "qcd_weight"), "Up")) qcd_variations.append(ReplaceWeight("CMS_htt_qcd_1jet_shape_Run2016", "qcd_weight", Weight("em_qcd_osss_1jet_shapedown_Weight", "qcd_weight"), "Down")) qcd_variations.append(ReplaceWeight("CMS_htt_qcd_iso_Run2016", "qcd_weight", Weight("em_qcd_extrap_up_Weight", "qcd_weight"), "Up")) qcd_variations.append(ReplaceWeight("CMS_htt_qcd_iso_Run2016", "qcd_weight", Weight("em_qcd_extrap_down_Weight", "qcd_weight"), "Down")) qcd_variations.append(ReplaceWeight("CMS_htt_qcd_iso", "qcd_weight", Weight("em_qcd_extrap_up_Weight", "qcd_weight"), "Up")) qcd_variations.append(ReplaceWeight("CMS_htt_qcd_iso", "qcd_weight", Weight("em_qcd_extrap_down_Weight", "qcd_weight"), "Down")) # Gluon-fusion WG1 uncertainty scheme ggh_variations = [] for unc in [ "THU_ggH_Mig01", "THU_ggH_Mig12", "THU_ggH_Mu", "THU_ggH_PT120", "THU_ggH_PT60", "THU_ggH_Res", "THU_ggH_VBF2j", "THU_ggH_VBF3j", "THU_ggH_qmtop" ]: ggh_variations.append(AddWeight(unc, "{}_weight".format(unc), Weight("({})".format(unc), "{}_weight".format(unc)), "Up")) ggh_variations.append(AddWeight(unc, "{}_weight".format(unc), Weight("(2.0-{})".format(unc), "{}_weight".format(unc)), "Down")) # ZL fakes energy scale fakelep_dict = {"et" : "Ele", "mt" : "Mu"} lep_fake_es_variations = {} for ch in ["mt", "et"]: lep_fake_es_variations[ch] = create_systematic_variations("CMS_ZLShape_%s_1prong_Run2016"% (ch), "tau%sFakeEsOneProng"%fakelep_dict[ch], DifferentPipeline) lep_fake_es_variations[ch] += create_systematic_variations("CMS_ZLShape_%s_1prong1pizero_Run2016"% (ch), "tau%sFakeEsOneProngPiZeros"%fakelep_dict[ch], DifferentPipeline) # Lepton trigger efficiency; the same values for (MC & EMB) and (mt & et) lep_trigger_eff_variations = {} for ch in ["mt", "et"]: lep_trigger_eff_variations[ch] = {} thresh_dict = {"2016": {"mt": 23., "et": 23.}, "2017": {"mt": 25., "et": 28.}, "2018": {"mt": 25., "et": 28.}} for unctype in ["", "_emb"]: lep_trigger_eff_variations[ch][unctype] = [] lep_trigger_eff_variations[ch][unctype].append(AddWeight("CMS_eff_trigger%s_%s_Run2016"%(unctype, ch), "trg_%s_eff_weight"%ch, Weight("(1.0*(pt_1<={0})+1.02*(pt_1>{0}))".format(thresh_dict[args.era][ch]), "trg_%s_eff_weight"%ch), "Up")) lep_trigger_eff_variations[ch][unctype].append(AddWeight("CMS_eff_trigger%s_%s_Run2016"%(unctype, ch), "trg_%s_eff_weight"%ch, Weight("(1.0*(pt_1<={0})+0.98*(pt_1>{0}))".format(thresh_dict[args.era][ch]), "trg_%s_eff_weight"%ch), "Down")) lep_trigger_eff_variations[ch][unctype].append(AddWeight("CMS_eff_xtrigger%s_%s_Run2016"%(unctype, ch), "xtrg_%s_eff_weight"%ch, Weight("(1.054*(pt_1<={0})+1.0*(pt_1>{0}))".format(thresh_dict[args.era][ch]), "xtrg_%s_eff_weight"%ch), "Up")) lep_trigger_eff_variations[ch][unctype].append(AddWeight("CMS_eff_xtrigger%s_%s_Run2016"%(unctype, ch), "xtrg_%s_eff_weight"%ch, Weight("(0.946*(pt_1<={0})+1.0*(pt_1>{0}))".format(thresh_dict[args.era][ch]), "xtrg_%s_eff_weight"%ch), "Down")) # Fake factor uncertainties fake_factor_variations = {} for ch in ["mt", "et", "tt"]: fake_factor_variations[ch] = [] if ch in ["mt", "et"]: for systematic_shift in [ "ff_qcd{ch}_syst_Run2016{shift}", "ff_qcd_dm0_njet0{ch}_stat_Run2016{shift}", "ff_qcd_dm0_njet1{ch}_stat_Run2016{shift}", "ff_w_syst_Run2016{shift}", "ff_w_dm0_njet0{ch}_stat_Run2016{shift}", "ff_w_dm0_njet1{ch}_stat_Run2016{shift}", "ff_tt_syst_Run2016{shift}", "ff_tt_dm0_njet0_stat_Run2016{shift}", "ff_tt_dm0_njet1_stat_Run2016{shift}", ]: for shift_direction in ["Up", "Down"]: fake_factor_variations[ch].append(ReplaceWeight("CMS_%s" % (systematic_shift.format(ch="_"+ch, shift="").replace("_dm0", "")), "fake_factor", Weight("ff2_{syst}".format(syst=systematic_shift.format(ch="", shift="_%s" % shift_direction.lower()).replace("_Run2016", "")), "fake_factor"), shift_direction)) elif ch == "tt": for systematic_shift in [ "ff_qcd{ch}_syst_Run2016{shift}", "ff_qcd_dm0_njet0{ch}_stat_Run2016{shift}", "ff_qcd_dm0_njet1{ch}_stat_Run2016{shift}", "ff_w{ch}_syst_Run2016{shift}", "ff_tt{ch}_syst_Run2016{shift}", "ff_w_frac{ch}_syst_Run2016{shift}", "ff_tt_frac{ch}_syst_Run2016{shift}" ]: for shift_direction in ["Up", "Down"]: fake_factor_variations[ch].append(ReplaceWeight("CMS_%s" % (systematic_shift.format(ch="_"+ch, shift="").replace("_dm0", "")), "fake_factor", Weight("(0.5*ff1_{syst}*(byTightDeepTau2017v2p1VSjet_1<0.5)+0.5*ff2_{syst}*(byTightDeepTau2017v2p1VSjet_2<0.5))".format(syst=systematic_shift.format(ch="", shift="_%s" % shift_direction.lower()).replace("_Run2016", "")), "fake_factor"), shift_direction)) ## Group nicks mc_nicks = ["ZL", "TTL", "VVL"] + signal_nicks # to be extended with 'W' in em boson_mc_nicks = ["ZL"] + signal_nicks # to be extended with 'W' in em ## Add variations to systematics for ch in args.channels: channel_mc_nicks = mc_nicks + ["W"] if ch == "em" else mc_nicks channel_boson_mc_nicks = boson_mc_nicks + ["W"] if ch == "em" else boson_mc_nicks if args.shape_group != "backgrounds": channel_mc_nicks = signal_nicks channel_boson_mc_nicks = signal_nicks channel_mc_common_variations = common_mc_variations if ch in ["et", "em"]: channel_mc_common_variations += ele_es_variations if ch in ["et", "mt", "tt"]: channel_mc_common_variations += tau_es_variations[""] + tau_es_variations["_mc"] + tau_id_variations[ch][""] if ch in ["et", "mt"]: channel_mc_common_variations += lep_trigger_eff_variations[ch][""] # variations common accross all shape groups for variation in channel_mc_common_variations: for process_nick in channel_mc_nicks: systematics.add_systematic_variation(variation=variation, process=processes[ch][process_nick], channel=channel_dict[ch], era=era) for variation in recoil_variations: for process_nick in channel_boson_mc_nicks: systematics.add_systematic_variation(variation=variation, process=processes[ch][process_nick], channel=channel_dict[ch], era=era) # variations relevant for ggH signals in 'sm_signals' shape group if args.shape_group == "sm_signals": for variation in ggh_variations: for process_nick in [nick for nick in signal_nicks if "ggH" in nick and "HWW" not in nick and "ggH_" not in nick]: systematics.add_systematic_variation(variation=variation, process=processes[ch][process_nick], channel=channel_dict[ch], era=era) # variations only relevant for the 'background' shape group if args.shape_group == "backgrounds": for variation in top_pt_variations: # TODO: Needs to be adapted if one wants to use DY MC or QCD estimation(lt,tt: TTT, TTL, TTJ, em: TTT, TTL) systematics.add_systematic_variation(variation=variation, process=processes[ch]["TTL"], channel=channel_dict[ch], era=era) for variation in met_unclustered_variations: for process_nick in ["TTL", "VVL"]: systematics.add_systematic_variation(variation=variation, process=processes[ch][process_nick], channel=channel_dict[ch], era=era) zl_variations = zpt_variations if ch in ["et", "mt"]: zl_variations += lep_fake_es_variations[ch] # TODO: maybe prepare variations for shape production with DY MC and QCD estimation, then applied to ZTT, ZL and ZJ for lt channels and ZTT and ZL for em channel for variation in zl_variations: systematics.add_systematic_variation(variation=variation, process=processes[ch]["ZL"], channel=channel_dict[ch], era=era) if ch == "em": for variation in qcd_variations: systematics.add_systematic_variation(variation=variation ,process=processes[ch]["QCD"], channel=channel_dict[ch], era=era) if ch in ["mt","et", "tt"]: ff_variations = fake_factor_variations[ch] + tau_es_variations[""] + tau_es_variations["_mc"] + tau_es_variations["_emb"] for variation in ff_variations: systematics.add_systematic_variation(variation=variation, process=processes[ch]["FAKES"], channel=channel_dict[ch], era=era) emb_variations = [] if ch in ["mt","et", "tt"]: emb_variations += tau_es_variations[""] + tau_es_variations["_emb"] + tau_id_variations[ch]["_emb"] + decayMode_variations if ch in ["mt", "et"]: emb_variations += lep_trigger_eff_variations[ch]["_emb"] if ch in ["et", "em"]: emb_variations += ele_es_emb_variations for variation in emb_variations: systematics.add_systematic_variation(variation=variation, process=processes[ch]["EMB"], channel=channel_dict[ch], era=era) # Produce histograms logger.info("Start producing shapes.") systematics.produce() logger.info("Done producing shapes.")
def main(args): # Container for all distributions to be drawn logger.info("Set up shape variations.") systematics = Systematics("{}_shapes.root".format(args.tag), num_threads=args.num_threads) # Era selection if "2016" in args.era: from shape_producer.estimation_methods_2016 import DataEstimation, HTTEstimation, ggHEstimation, ggHEstimation_0J, ggHEstimation_1J, ggHEstimation_GE2J, ggHEstimation_VBFTOPO, qqHEstimation, qqHEstimation_VBFTOPO_JET3VETO, qqHEstimation_VBFTOPO_JET3, qqHEstimation_REST, qqHEstimation_PTJET1_GT200, VHEstimation, ZTTEstimation, ZTTEstimationTT, ZLEstimationMTSM, ZLEstimationETSM, ZLEstimationTT, ZJEstimationMT, ZJEstimationET, ZJEstimationTT, WEstimation, TTTEstimationMT, TTTEstimationET, TTTEstimationTT, TTJEstimationMT, TTJEstimationET, TTJEstimationTT, VVEstimation, EWKZEstimation, QCDEstimationMT, QCDEstimationET, QCDEstimationTT, ZTTEmbeddedEstimation, TTLEstimationMT, TTLEstimationET, TTLEstimationTT, TTTTEstimationMT, TTTTEstimationET from shape_producer.era import Run2016 era = Run2016(args.datasets) else: logger.critical("Era {} is not implemented.".format(args.era)) raise Exception # Channels and processes # yapf: disable directory = args.directory et_friend_directory = args.et_friend_directory mt_friend_directory = args.mt_friend_directory tt_friend_directory = args.tt_friend_directory mt = MTSM() if args.QCD_extrap_fit: mt.cuts.remove("muon_iso") mt.cuts.add(Cut("(iso_1<0.5)*(iso_1>=0.15)", "muon_iso_loose")) if args.embedding: mt.cuts.remove("trg_singlemuoncross") mt.cuts.add(Cut("(trg_singlemuon==1 && pt_1>23 && pt_2>30)", "trg_singlemuon")) mt_processes = { "data" : Process("data_obs", DataEstimation (era, directory, mt, friend_directory=mt_friend_directory)), "HTT" : Process("HTT", HTTEstimation (era, directory, mt, friend_directory=mt_friend_directory)), "ggH" : Process("ggH125", ggHEstimation (era, directory, mt, friend_directory=mt_friend_directory)), "qqH" : Process("qqH125", qqHEstimation (era, directory, mt, friend_directory=mt_friend_directory)), "ggH_0J" : Process("ggH125_0J", ggHEstimation_0J (era, directory, mt, friend_directory=mt_friend_directory)), "ggH_1J" : Process("ggH125_1J", ggHEstimation_1J (era, directory, mt, friend_directory=mt_friend_directory)), "ggH_GE2J" : Process("ggH125_GE2J", ggHEstimation_GE2J (era, directory, mt, friend_directory=mt_friend_directory)), "ggH_VBFTOPO" : Process("ggH125_VBFTOPO", ggHEstimation_VBFTOPO (era, directory, mt, friend_directory=mt_friend_directory)), "qqH" : Process("qqH125", qqHEstimation (era, directory, mt, friend_directory=mt_friend_directory)), "qqH_VBFTOPO_JET3VETO" : Process("qqH125_VBFTOPO_JET3VETO", qqHEstimation_VBFTOPO_JET3VETO(era, directory, mt, friend_directory=mt_friend_directory)), "qqH_VBFTOPO_JET3" : Process("qqH125_VBFTOPO_JET3", qqHEstimation_VBFTOPO_JET3 (era, directory, mt, friend_directory=mt_friend_directory)), "qqH_REST" : Process("qqH125_REST", qqHEstimation_REST (era, directory, mt, friend_directory=mt_friend_directory)), "qqH_PTJET1_GT200" : Process("qqH125_PTJET1_GT200", qqHEstimation_PTJET1_GT200 (era, directory, mt, friend_directory=mt_friend_directory)), "VH" : Process("VH125", VHEstimation (era, directory, mt, friend_directory=mt_friend_directory)), "ZTT" : Process("ZTT", ZTTEstimation (era, directory, mt, friend_directory=mt_friend_directory)), "ZL" : Process("ZL", ZLEstimationMTSM(era, directory, mt, friend_directory=mt_friend_directory)), "ZJ" : Process("ZJ", ZJEstimationMT (era, directory, mt, friend_directory=mt_friend_directory)), "W" : Process("W", WEstimation (era, directory, mt, friend_directory=mt_friend_directory)), "TTT" : Process("TTT", TTTEstimationMT (era, directory, mt, friend_directory=mt_friend_directory)), "TTJ" : Process("TTJ", TTJEstimationMT (era, directory, mt, friend_directory=mt_friend_directory)), "VV" : Process("VV", VVEstimation (era, directory, mt, friend_directory=mt_friend_directory)), "EWKZ" : Process("EWKZ", EWKZEstimation (era, directory, mt, friend_directory=mt_friend_directory)) } if args.embedding: mt_processes["ZTT"] = Process("ZTT", ZTTEmbeddedEstimation(era, directory, mt, friend_directory=mt_friend_directory)) mt_processes["TTT"] = Process("TTT", TTLEstimationMT (era, directory, mt, friend_directory=mt_friend_directory)) mt_processes["QCD"] = Process("QCD", QCDEstimationMT(era, directory, mt, [mt_processes[process] for process in ["ZTT", "ZJ", "ZL", "W", "TTT", "TTJ", "VV", "EWKZ"]], mt_processes["data"], extrapolation_factor=1.17)) et = ETSM() if args.QCD_extrap_fit: et.cuts.remove("ele_iso") et.cuts.add(Cut("(iso_1<0.5)*(iso_1>=0.1)", "ele_iso_loose")) et_processes = { "data" : Process("data_obs", DataEstimation (era, directory, et, friend_directory=et_friend_directory)), "HTT" : Process("HTT", HTTEstimation (era, directory, et, friend_directory=et_friend_directory)), "ggH" : Process("ggH125", ggHEstimation (era, directory, et, friend_directory=et_friend_directory)), "qqH" : Process("qqH125", qqHEstimation (era, directory, et, friend_directory=et_friend_directory)), "ggH_0J" : Process("ggH125_0J", ggHEstimation_0J (era, directory, et, friend_directory=et_friend_directory)), "ggH_1J" : Process("ggH125_1J", ggHEstimation_1J (era, directory, et, friend_directory=et_friend_directory)), "ggH_GE2J" : Process("ggH125_GE2J", ggHEstimation_GE2J (era, directory, et, friend_directory=et_friend_directory)), "ggH_VBFTOPO" : Process("ggH125_VBFTOPO", ggHEstimation_VBFTOPO (era, directory, et, friend_directory=et_friend_directory)), "qqH" : Process("qqH125", qqHEstimation (era, directory, et, friend_directory=et_friend_directory)), "qqH_VBFTOPO_JET3VETO" : Process("qqH125_VBFTOPO_JET3VETO", qqHEstimation_VBFTOPO_JET3VETO(era, directory, et, friend_directory=et_friend_directory)), "qqH_VBFTOPO_JET3" : Process("qqH125_VBFTOPO_JET3", qqHEstimation_VBFTOPO_JET3 (era, directory, et, friend_directory=et_friend_directory)), "qqH_REST" : Process("qqH125_REST", qqHEstimation_REST (era, directory, et, friend_directory=et_friend_directory)), "qqH_PTJET1_GT200" : Process("qqH125_PTJET1_GT200", qqHEstimation_PTJET1_GT200 (era, directory, et, friend_directory=et_friend_directory)), "VH" : Process("VH125", VHEstimation (era, directory, et, friend_directory=et_friend_directory)), "ZTT" : Process("ZTT", ZTTEstimation (era, directory, et, friend_directory=et_friend_directory)), "ZL" : Process("ZL", ZLEstimationETSM(era, directory, et, friend_directory=et_friend_directory)), "ZJ" : Process("ZJ", ZJEstimationET (era, directory, et, friend_directory=et_friend_directory)), "W" : Process("W", WEstimation (era, directory, et, friend_directory=et_friend_directory)), "TTT" : Process("TTT", TTTEstimationET (era, directory, et, friend_directory=et_friend_directory)), "TTJ" : Process("TTJ", TTJEstimationET (era, directory, et, friend_directory=et_friend_directory)), "VV" : Process("VV", VVEstimation (era, directory, et, friend_directory=et_friend_directory)), "EWKZ" : Process("EWKZ", EWKZEstimation (era, directory, et, friend_directory=et_friend_directory)) } if args.embedding: et_processes["ZTT"] = Process("ZTT", ZTTEmbeddedEstimation(era, directory, et, friend_directory=et_friend_directory)) et_processes["TTT"] = Process("TTT", TTLEstimationET (era, directory, et, friend_directory=et_friend_directory)) et_processes["QCD"] = Process("QCD", QCDEstimationET(era, directory, et, [et_processes[process] for process in ["ZTT", "ZJ", "ZL", "W", "TTT", "TTJ", "VV", "EWKZ"]], et_processes["data"], extrapolation_factor=1.16)) tt = TTSM() if args.QCD_extrap_fit: tt.cuts.get("os").invert() if args.HIG16043: tt.cuts.remove("pt_h") tt_processes = { "data" : Process("data_obs", DataEstimation (era, directory, tt, friend_directory=tt_friend_directory)), "HTT" : Process("HTT", HTTEstimation (era, directory, tt, friend_directory=tt_friend_directory)), "ggH" : Process("ggH125", ggHEstimation (era, directory, tt, friend_directory=tt_friend_directory)), "qqH" : Process("qqH125", qqHEstimation (era, directory, tt, friend_directory=tt_friend_directory)), "ggH_0J" : Process("ggH125_0J", ggHEstimation_0J (era, directory, tt, friend_directory=tt_friend_directory)), "ggH_1J" : Process("ggH125_1J", ggHEstimation_1J (era, directory, tt, friend_directory=tt_friend_directory)), "ggH_GE2J" : Process("ggH125_GE2J", ggHEstimation_GE2J (era, directory, tt, friend_directory=tt_friend_directory)), "ggH_VBFTOPO" : Process("ggH125_VBFTOPO", ggHEstimation_VBFTOPO (era, directory, tt, friend_directory=tt_friend_directory)), "qqH" : Process("qqH125", qqHEstimation (era, directory, tt, friend_directory=tt_friend_directory)), "qqH_VBFTOPO_JET3VETO" : Process("qqH125_VBFTOPO_JET3VETO", qqHEstimation_VBFTOPO_JET3VETO(era, directory, tt, friend_directory=tt_friend_directory)), "qqH_VBFTOPO_JET3" : Process("qqH125_VBFTOPO_JET3", qqHEstimation_VBFTOPO_JET3 (era, directory, tt, friend_directory=tt_friend_directory)), "qqH_REST" : Process("qqH125_REST", qqHEstimation_REST (era, directory, tt, friend_directory=tt_friend_directory)), "qqH_PTJET1_GT200" : Process("qqH125_PTJET1_GT200", qqHEstimation_PTJET1_GT200 (era, directory, tt, friend_directory=tt_friend_directory)), "VH" : Process("VH125", VHEstimation (era, directory, tt, friend_directory=tt_friend_directory)), "ZTT" : Process("ZTT", ZTTEstimationTT(era, directory, tt, friend_directory=tt_friend_directory)), "ZL" : Process("ZL", ZLEstimationTT (era, directory, tt, friend_directory=tt_friend_directory)), "ZJ" : Process("ZJ", ZJEstimationTT (era, directory, tt, friend_directory=tt_friend_directory)), "W" : Process("W", WEstimation (era, directory, tt, friend_directory=tt_friend_directory)), "TTT" : Process("TTT", TTTEstimationTT(era, directory, tt, friend_directory=tt_friend_directory)), "TTJ" : Process("TTJ", TTJEstimationTT(era, directory, tt, friend_directory=tt_friend_directory)), "VV" : Process("VV", VVEstimation (era, directory, tt, friend_directory=tt_friend_directory)), "EWKZ" : Process("EWKZ", EWKZEstimation (era, directory, tt, friend_directory=tt_friend_directory)), } if args.embedding: tt_processes["ZTT"] = Process("ZTT", ZTTEmbeddedEstimation(era, directory, tt, friend_directory=tt_friend_directory)) tt_processes["TTT"] = Process("TTT", TTLEstimationTT (era, directory, tt, friend_directory=tt_friend_directory)) tt_processes["QCD"] = Process("QCD", QCDEstimationTT(era, directory, tt, [tt_processes[process] for process in ["ZTT", "ZJ", "ZL", "W", "TTT", "TTJ", "VV", "EWKZ"]], tt_processes["data"])) # Variables and categories binning = yaml.load(open(args.binning)) et_categories = [] # HIG16043 shapes if "et" in args.channels and args.HIG16043: for category in ["0jet", "vbf", "boosted"]: variable = Variable( binning["HIG16043"]["et"][category]["variable"], VariableBinning(binning["HIG16043"]["et"][category]["binning"]), expression=binning["HIG16043"]["et"][category]["expression"]) et_categories.append( Category( category, et, Cuts( Cut(binning["HIG16043"]["et"][category]["cut_unrolling"], "et_cut_unrolling_{}".format(category)), Cut(binning["HIG16043"]["et"][category]["cut_category"], "et_cut_category_{}".format(category)) ), variable=variable)) # Analysis shapes elif "et" in args.channels: for i, label in enumerate(["ggh", "qqh", "ztt", "zll", "w", "tt", "ss", "misc"]): score = Variable( "et_max_score", VariableBinning(binning["analysis"]["et"][label])) et_categories.append( Category( label, et, Cuts( Cut("et_max_index=={index}".format(index=i), "exclusive_score")), variable=score)) # Goodness of fit shapes elif "et" == args.gof_channel: score = Variable( args.gof_variable, VariableBinning(binning["gof"]["et"][args.gof_variable]["bins"]), expression=binning["gof"]["et"][args.gof_variable]["expression"]) if "cut" in binning["gof"]["et"][args.gof_variable].keys(): cuts=Cuts(Cut(binning["gof"]["et"][args.gof_variable]["cut"], "binning")) else: cuts=Cuts() et_categories.append( Category( args.gof_variable, et, cuts, variable=score)) mt_categories = [] # HIG16043 shapes if "mt" in args.channels and args.HIG16043: for category in ["0jet", "vbf", "boosted"]: variable = Variable( binning["HIG16043"]["mt"][category]["variable"], VariableBinning(binning["HIG16043"]["mt"][category]["binning"]), expression=binning["HIG16043"]["mt"][category]["expression"]) mt_categories.append( Category( category, mt, Cuts( Cut(binning["HIG16043"]["mt"][category]["cut_unrolling"], "mt_cut_unrolling_{}".format(category)), Cut(binning["HIG16043"]["mt"][category]["cut_category"], "mt_cut_category_{}".format(category)) ), variable=variable)) # Analysis shapes elif "mt" in args.channels: for i, label in enumerate(["ggh", "qqh", "ztt", "zll", "w", "tt", "ss", "misc"]): score = Variable( "mt_max_score", VariableBinning(binning["analysis"]["mt"][label])) mt_categories.append( Category( label, mt, Cuts( Cut("mt_max_index=={index}".format(index=i), "exclusive_score")), variable=score)) # Goodness of fit shapes elif args.gof_channel == "mt": score = Variable( args.gof_variable, VariableBinning(binning["gof"]["mt"][args.gof_variable]["bins"]), expression=binning["gof"]["mt"][args.gof_variable]["expression"]) if "cut" in binning["gof"]["mt"][args.gof_variable].keys(): cuts=Cuts(Cut(binning["gof"]["mt"][args.gof_variable]["cut"], "binning")) else: cuts=Cuts() mt_categories.append( Category( args.gof_variable, mt, cuts, variable=score)) tt_categories = [] # HIG16043 shapes if "tt" in args.channels and args.HIG16043: for category in ["0jet", "vbf", "boosted"]: variable = Variable( binning["HIG16043"]["tt"][category]["variable"], VariableBinning(binning["HIG16043"]["tt"][category]["binning"]), expression=binning["HIG16043"]["tt"][category]["expression"]) tt_categories.append( Category( category, tt, Cuts( Cut(binning["HIG16043"]["tt"][category]["cut_unrolling"], "tt_cut_unrolling_{}".format(category)), Cut(binning["HIG16043"]["tt"][category]["cut_category"], "tt_cut_category_{}".format(category)) ), variable=variable)) # Analysis shapes elif "tt" in args.channels: for i, label in enumerate(["ggh", "qqh", "ztt", "noniso", "misc"]): score = Variable( "tt_max_score", VariableBinning(binning["analysis"]["tt"][label])) tt_categories.append( Category( label, tt, Cuts( Cut("tt_max_index=={index}".format(index=i), "exclusive_score")), variable=score)) # Goodness of fit shapes elif args.gof_channel == "tt": score = Variable( args.gof_variable, VariableBinning(binning["gof"]["tt"][args.gof_variable]["bins"]), expression=binning["gof"]["tt"][args.gof_variable]["expression"]) if "cut" in binning["gof"]["tt"][args.gof_variable].keys(): cuts=Cuts(Cut(binning["gof"]["tt"][args.gof_variable]["cut"], "binning")) else: cuts=Cuts() tt_categories.append( Category( args.gof_variable, tt, cuts, variable=score)) # Nominal histograms # yapf: enable if "et" in [args.gof_channel] + args.channels: for process, category in product(et_processes.values(), et_categories): systematics.add( Systematic(category=category, process=process, analysis="smhtt", era=era, variation=Nominal(), mass="125")) if "mt" in [args.gof_channel] + args.channels: for process, category in product(mt_processes.values(), mt_categories): systematics.add( Systematic(category=category, process=process, analysis="smhtt", era=era, variation=Nominal(), mass="125")) if "tt" in [args.gof_channel] + args.channels: for process, category in product(tt_processes.values(), tt_categories): systematics.add( Systematic(category=category, process=process, analysis="smhtt", era=era, variation=Nominal(), mass="125")) # Shapes variations # Tau energy scale tau_es_3prong_variations = create_systematic_variations( "CMS_scale_t_3prong_13TeV", "tauEsThreeProng", DifferentPipeline) tau_es_1prong_variations = create_systematic_variations( "CMS_scale_t_1prong_13TeV", "tauEsOneProng", DifferentPipeline) tau_es_1prong1pizero_variations = create_systematic_variations( "CMS_scale_t_1prong1pizero_13TeV", "tauEsOneProngPiZeros", DifferentPipeline) for variation in tau_es_3prong_variations + tau_es_1prong_variations + tau_es_1prong1pizero_variations: for process_nick in [ "HTT", "VH", "ggH", "ggH_0J", "ggH_1J", "ggH_GE2J", "ggH_VBFTOPO", "qqH", "qqH_VBFTOPO_JET3VETO", "qqH_VBFTOPO_JET3", "qqH_REST", "qqH_PTJET1_GT200", "ZTT", "TTT", "VV", "EWKZ" ]: if "et" in [args.gof_channel] + args.channels: systematics.add_systematic_variation( variation=variation, process=et_processes[process_nick], channel=et, era=era) if "mt" in [args.gof_channel] + args.channels: systematics.add_systematic_variation( variation=variation, process=mt_processes[process_nick], channel=mt, era=era) if "tt" in [args.gof_channel] + args.channels: systematics.add_systematic_variation( variation=variation, process=tt_processes[process_nick], channel=tt, era=era) # Jet energy scale jet_es_variations = create_systematic_variations("CMS_scale_j_13TeV", "jecUnc", DifferentPipeline) for variation in jet_es_variations: for process_nick in [ "HTT", "VH", "ggH", "ggH_0J", "ggH_1J", "ggH_GE2J", "ggH_VBFTOPO", "qqH", "qqH_VBFTOPO_JET3VETO", "qqH_VBFTOPO_JET3", "qqH_REST", "qqH_PTJET1_GT200", "ZTT", "ZL", "ZJ", "W", "TTT", "TTJ", "VV", "EWKZ" ]: if args.embedding and process_nick == 'ZTT': continue if "et" in [args.gof_channel] + args.channels: systematics.add_systematic_variation( variation=variation, process=et_processes[process_nick], channel=et, era=era) if "mt" in [args.gof_channel] + args.channels: systematics.add_systematic_variation( variation=variation, process=mt_processes[process_nick], channel=mt, era=era) if "tt" in [args.gof_channel] + args.channels: systematics.add_systematic_variation( variation=variation, process=tt_processes[process_nick], channel=tt, era=era) # MET energy scale met_unclustered_variations = create_systematic_variations( "CMS_scale_met_unclustered_13TeV", "metUnclusteredEn", DifferentPipeline) met_clustered_variations = create_systematic_variations( "CMS_scale_met_clustered_13TeV", "metJetEn", DifferentPipeline) for variation in met_unclustered_variations + met_clustered_variations: for process_nick in [ "HTT", "VH", "ggH", "ggH_0J", "ggH_1J", "ggH_GE2J", "ggH_VBFTOPO", "qqH", "qqH_VBFTOPO_JET3VETO", "qqH_VBFTOPO_JET3", "qqH_REST", "qqH_PTJET1_GT200", "ZTT", "ZL", "ZJ", "W", "TTT", "TTJ", "VV", "EWKZ" ]: if args.embedding and process_nick == 'ZTT': continue if "et" in [args.gof_channel] + args.channels: systematics.add_systematic_variation( variation=variation, process=et_processes[process_nick], channel=et, era=era) if "mt" in [args.gof_channel] + args.channels: systematics.add_systematic_variation( variation=variation, process=mt_processes[process_nick], channel=mt, era=era) if "tt" in [args.gof_channel] + args.channels: systematics.add_systematic_variation( variation=variation, process=tt_processes[process_nick], channel=tt, era=era) # Z pt reweighting zpt_variations = create_systematic_variations("CMS_htt_dyShape_13TeV", "zPtReweightWeight", SquareAndRemoveWeight) for variation in zpt_variations: for process_nick in ["ZTT", "ZL", "ZJ"]: if args.embedding and process_nick == 'ZTT': continue if "et" in [args.gof_channel] + args.channels: systematics.add_systematic_variation( variation=variation, process=et_processes[process_nick], channel=et, era=era) if "mt" in [args.gof_channel] + args.channels: systematics.add_systematic_variation( variation=variation, process=mt_processes[process_nick], channel=mt, era=era) if "tt" in [args.gof_channel] + args.channels: systematics.add_systematic_variation( variation=variation, process=tt_processes[process_nick], channel=tt, era=era) # top pt reweighting top_pt_variations = create_systematic_variations( "CMS_htt_ttbarShape_13TeV", "topPtReweightWeight", SquareAndRemoveWeight) for variation in top_pt_variations: for process_nick in ["TTT", "TTJ"]: if "et" in [args.gof_channel] + args.channels: systematics.add_systematic_variation( variation=variation, process=et_processes[process_nick], channel=et, era=era) if "mt" in [args.gof_channel] + args.channels: systematics.add_systematic_variation( variation=variation, process=mt_processes[process_nick], channel=mt, era=era) if "tt" in [args.gof_channel] + args.channels: systematics.add_systematic_variation( variation=variation, process=tt_processes[process_nick], channel=tt, era=era) # jet to tau fake efficiency jet_to_tau_fake_variations = [] jet_to_tau_fake_variations.append( AddWeight("CMS_htt_jetToTauFake_13TeV", "jetToTauFake_weight", Weight("(1.0+pt_2*0.002)", "jetToTauFake_weight"), "Up")) jet_to_tau_fake_variations.append( AddWeight("CMS_htt_jetToTauFake_13TeV", "jetToTauFake_weight", Weight("(1.0-pt_2*0.002)", "jetToTauFake_weight"), "Down")) for variation in jet_to_tau_fake_variations: for process_nick in ["ZJ", "TTJ", "W"]: if "et" in [args.gof_channel] + args.channels: systematics.add_systematic_variation( variation=variation, process=et_processes[process_nick], channel=et, era=era) if "mt" in [args.gof_channel] + args.channels: systematics.add_systematic_variation( variation=variation, process=mt_processes[process_nick], channel=mt, era=era) if "tt" in [args.gof_channel] + args.channels: systematics.add_systematic_variation( variation=variation, process=tt_processes[process_nick], channel=tt, era=era) # Zll reweighting zll_et_weight_variations = [] zll_et_weight_variations.append( ReplaceWeight( "CMS_htt_eFakeTau_1prong_13TeV", "decay_mode_reweight", Weight( "(((decayMode_2 == 0)*0.98*1.12) + ((decayMode_2 == 1 || decayMode_2 == 2)*1.2) + ((decayMode_2 == 10)*1.0))", "decay_mode_reweight"), "Up")) zll_et_weight_variations.append( ReplaceWeight( "CMS_htt_eFakeTau_1prong_13TeV", "decay_mode_reweight", Weight( "(((decayMode_2 == 0)*0.98*0.88) + ((decayMode_2 == 1 || decayMode_2 == 2)*1.2) + ((decayMode_2 == 10)*1.0))", "decay_mode_reweight"), "Down")) zll_et_weight_variations.append( ReplaceWeight( "CMS_htt_eFakeTau_1prong1pizero_13TeV", "decay_mode_reweight", Weight( "(((decayMode_2 == 0)*0.98) + ((decayMode_2 == 1 || decayMode_2 == 2)*1.2*1.12) + ((decayMode_2 == 10)*1.0))", "decay_mode_reweight"), "Up")) zll_et_weight_variations.append( ReplaceWeight( "CMS_htt_eFakeTau_1prong1pizero_13TeV", "decay_mode_reweight", Weight( "(((decayMode_2 == 0)*0.98) + ((decayMode_2 == 1 || decayMode_2 == 2)*1.2*0.88) + ((decayMode_2 == 10)*1.0))", "decay_mode_reweight"), "Down")) for variation in zll_et_weight_variations: for process_nick in ["ZL"]: if "et" in [args.gof_channel] + args.channels: systematics.add_systematic_variation( variation=variation, process=et_processes[process_nick], channel=et, era=era) zll_mt_weight_variations = [] zll_mt_weight_variations.append( ReplaceWeight( "CMS_htt_mFakeTau_1prong_13TeV", "decay_mode_reweight", Weight( "(((decayMode_2 == 0)*0.75*1.25) + ((decayMode_2 == 1 || decayMode_2 == 2)*1.0) + ((decayMode_2 == 10)*1.0))", "decay_mode_reweight"), "Up")) zll_mt_weight_variations.append( ReplaceWeight( "CMS_htt_mFakeTau_1prong_13TeV", "decay_mode_reweight", Weight( "(((decayMode_2 == 0)*0.75*0.75) + ((decayMode_2 == 1 || decayMode_2 == 2)*1.0) + ((decayMode_2 == 10)*1.0))", "decay_mode_reweight"), "Down")) zll_mt_weight_variations.append( ReplaceWeight( "CMS_htt_mFakeTau_1prong1pizero_13TeV", "decay_mode_reweight", Weight( "(((decayMode_2 == 0)*0.75) + ((decayMode_2 == 1 || decayMode_2 == 2)*1.25) + ((decayMode_2 == 10)*1.0))", "decay_mode_reweight"), "Up")) zll_mt_weight_variations.append( ReplaceWeight( "CMS_htt_mFakeTau_1prong1pizero_13TeV", "decay_mode_reweight", Weight( "(((decayMode_2 == 0)*0.75) + ((decayMode_2 == 1 || decayMode_2 == 2)*0.75) + ((decayMode_2 == 10)*1.0))", "decay_mode_reweight"), "Down")) for variation in zll_mt_weight_variations: for process_nick in ["ZL"]: if "mt" in [args.gof_channel] + args.channels: systematics.add_systematic_variation( variation=variation, process=mt_processes[process_nick], channel=mt, era=era) # b tagging btag_eff_variations = create_systematic_variations("CMS_htt_eff_b_13TeV", "btagEff", DifferentPipeline) mistag_eff_variations = create_systematic_variations( "CMS_htt_mistag_b_13TeV", "btagMistag", DifferentPipeline) for variation in btag_eff_variations + mistag_eff_variations: for process_nick in [ "HTT", "VH", "ggH", "ggH_0J", "ggH_1J", "ggH_GE2J", "ggH_VBFTOPO", "qqH", "qqH_VBFTOPO_JET3VETO", "qqH_VBFTOPO_JET3", "qqH_REST", "qqH_PTJET1_GT200", "ZTT", "ZL", "ZJ", "W", "TTT", "TTJ", "VV", "EWKZ" ]: if args.embedding and process_nick == 'ZTT': continue if "et" in [args.gof_channel] + args.channels: systematics.add_systematic_variation( variation=variation, process=et_processes[process_nick], channel=et, era=era) if "mt" in [args.gof_channel] + args.channels: systematics.add_systematic_variation( variation=variation, process=mt_processes[process_nick], channel=mt, era=era) if "tt" in [args.gof_channel] + args.channels: systematics.add_systematic_variation( variation=variation, process=tt_processes[process_nick], channel=tt, era=era) if args.embedding: # Embedded event specifics # 10% removed events in ttbar simulation (ttbar -> real tau tau events) will be added/subtracted to ZTT shape to use as systematic tttautau_process_mt = Process( "TTTT", TTTTEstimationMT(era, directory, mt, friend_directory=mt_friend_directory)) tttautau_process_et = Process( "TTTT", TTTTEstimationET(era, directory, et, friend_directory=et_friend_directory)) tttautau_process_tt = Process( "TTTT", TTTEstimationTT(era, directory, tt, friend_directory=tt_friend_directory)) if 'mt' in [args.gof_channel] + args.channels: for category in mt_categories: mt_processes['ZTTpTTTauTauDown'] = Process( "ZTTpTTTauTauDown", AddHistogramEstimationMethod( "AddHistogram", "nominal", era, directory, mt, [mt_processes["ZTT"], tttautau_process_mt], [1.0, -0.1])) systematics.add( Systematic(category=category, process=mt_processes['ZTTpTTTauTauDown'], analysis="smhtt", era=era, variation=Relabel("CMS_htt_emb_ttbar", "Down"), mass="125")) mt_processes['ZTTpTTTauTauUp'] = Process( "ZTTpTTTauTauUp", AddHistogramEstimationMethod( "AddHistogram", "nominal", era, directory, mt, [mt_processes["ZTT"], tttautau_process_mt], [1.0, 0.1])) systematics.add( Systematic(category=category, process=mt_processes['ZTTpTTTauTauUp'], analysis="smhtt", era=era, variation=Relabel("CMS_htt_emb_ttbar", "Up"), mass="125")) #Muon ES uncertainty (needed for smearing due to initial reconstruction) muon_es_variations = create_systematic_variations( "CMS_scale_muonES", "muonES", DifferentPipeline) for variation in muon_es_variations: for process_nick in ["ZTT"]: if "mt" in [args.gof_channel] + args.channels: systematics.add_systematic_variation( variation=variation, process=mt_processes[process_nick], channel=mt, era=era) if 'et' in [args.gof_channel] + args.channels: for category in et_categories: et_processes['ZTTpTTTauTauDown'] = Process( "ZTTpTTTauTauDown", AddHistogramEstimationMethod( "AddHistogram", "nominal", era, directory, et, [et_processes["ZTT"], tttautau_process_et], [1.0, -0.1])) systematics.add( Systematic(category=category, process=et_processes['ZTTpTTTauTauDown'], analysis="smhtt", era=era, variation=Relabel("CMS_htt_emb_ttbar", "Down"), mass="125")) et_processes['ZTTpTTTauTauUp'] = Process( "ZTTpTTTauTauUp", AddHistogramEstimationMethod( "AddHistogram", "nominal", era, directory, et, [et_processes["ZTT"], tttautau_process_et], [1.0, 0.1])) systematics.add( Systematic(category=category, process=et_processes['ZTTpTTTauTauUp'], analysis="smhtt", era=era, variation=Relabel("CMS_htt_emb_ttbar", "Up"), mass="125")) if 'tt' in [args.gof_channel] + args.channels: for category in tt_categories: tt_processes['ZTTpTTTauTauDown'] = Process( "ZTTpTTTauTauDown", AddHistogramEstimationMethod( "AddHistogram", "nominal", era, directory, tt, [tt_processes["ZTT"], tttautau_process_tt], [1.0, -0.1])) systematics.add( Systematic(category=category, process=tt_processes['ZTTpTTTauTauDown'], analysis="smhtt", era=era, variation=Relabel("CMS_htt_emb_ttbar", "Down"), mass="125")) tt_processes['ZTTpTTTauTauUp'] = Process( "ZTTpTTTauTauUp", AddHistogramEstimationMethod( "AddHistogram", "nominal", era, directory, tt, [tt_processes["ZTT"], tttautau_process_tt], [1.0, 0.1])) systematics.add( Systematic(category=category, process=tt_processes['ZTTpTTTauTauUp'], analysis="smhtt", era=era, variation=Relabel("CMS_htt_emb_ttbar", "Up"), mass="125")) # Produce histograms logger.info("Start producing shapes.") systematics.produce() logger.info("Done producing shapes.")
def main(args): # Container for all distributions to be drawn logger.info("Set up shape variations.") systematics = Systematics( "{}_cutbased_shapes_{}.root".format(args.tag,args.discriminator_variable), num_threads=args.num_threads, skip_systematic_variations=args.skip_systematic_variations) # Era selection if "2017" in args.era: from shape_producer.estimation_methods_2017 import DataEstimation, ZTTEstimation, ZTTEmbeddedEstimation, ZLEstimation, ZJEstimation, TTLEstimation, TTJEstimation, TTTEstimation, VVLEstimation, VVTEstimation, VVJEstimation, WEstimation, ggHEstimation, qqHEstimation, VHEstimation, WHEstimation, ZHEstimation, ttHEstimation, QCDEstimation_ABCD_TT_ISO2, QCDEstimation_SStoOS_MTETEM, NewFakeEstimationLT, NewFakeEstimationTT, HWWEstimation, ggHWWEstimation, qqHWWEstimation, SUSYggHEstimation, SUSYbbHEstimation from shape_producer.era import Run2017 era = Run2017(args.datasets) else: logger.critical("Era {} is not implemented.".format(args.era)) raise Exception # Channels and processes # yapf: disable directory = args.directory friend_directories = { "et" : args.et_friend_directory, "mt" : args.mt_friend_directory, "tt" : args.tt_friend_directory, "em" : args.em_friend_directory, } ff_friend_directory = args.fake_factor_friend_directory channel_dict = { "mt" : MTMSSM2017(), "et" : ETMSSM2017(), "tt" : TTMSSM2017(), "em" : EMMSSM2017(), } susyggH_masses = [100, 110, 120, 130, 140, 180, 200, 250, 300, 350, 400, 450, 600, 700, 800, 900, 1200, 1400, 1500, 1600, 1800, 2000, 2300, 2600, 2900, 3200] susybbH_masses = [90, 110, 120, 125, 130, 140, 160, 180, 200, 250, 300, 350, 400, 450, 500, 600, 700, 800, 900, 1000, 1200, 1400, 1800, 2000, 2300, 2600, 3200] processes = { "mt" : {}, "et" : {}, "tt" : {}, "em" : {}, } for ch in args.channels: # common processes if args.shape_group == "backgrounds": processes[ch]["data"] = Process("data_obs", DataEstimation (era, directory, channel_dict[ch], friend_directory=friend_directories[ch])) processes[ch]["EMB"] = Process("EMB", ZTTEmbeddedEstimation (era, directory, channel_dict[ch], friend_directory=friend_directories[ch])) processes[ch]["ZL"] = Process("ZL", ZLEstimation (era, directory, channel_dict[ch], friend_directory=friend_directories[ch])) processes[ch]["TTL"] = Process("TTL", TTLEstimation (era, directory, channel_dict[ch], friend_directory=friend_directories[ch])) processes[ch]["VVL"] = Process("VVL", VVLEstimation (era, directory, channel_dict[ch], friend_directory=friend_directories[ch])) processes[ch]["VH125"] = Process("VH125", VHEstimation (era, directory, channel_dict[ch], friend_directory=friend_directories[ch])) processes[ch]["WH125"] = Process("WH125", WHEstimation (era, directory, channel_dict[ch], friend_directory=friend_directories[ch])) processes[ch]["ZH125"] = Process("ZH125", ZHEstimation (era, directory, channel_dict[ch], friend_directory=friend_directories[ch])) processes[ch]["ttH125"] = Process("ttH125", ttHEstimation (era, directory, channel_dict[ch], friend_directory=friend_directories[ch])) processes[ch]["ggHWW125"] = Process("ggHWW125", ggHWWEstimation (era, directory, channel_dict[ch], friend_directory=friend_directories[ch])) processes[ch]["qqHWW125"] = Process("qqHWW125", qqHWWEstimation (era, directory, channel_dict[ch], friend_directory=friend_directories[ch])) # mssm ggH and bbH signals if "gg" in args.shape_group: for m in susyggH_masses: name = args.shape_group + "_" + str(m) processes[ch][name] = Process(name, SUSYggHEstimation(era, directory, channel_dict[ch], str(m), args.shape_group.replace("gg",""), friend_directory=friend_directories[ch])) if args.shape_group == "bbH": for m in susybbH_masses: name = "bbH_" + str(m) processes[ch][name] = Process(name, SUSYbbHEstimation(era, directory, channel_dict[ch], str(m), friend_directory=friend_directories[ch])) if args.shape_group == "sm_signals": # stage 0 and stage 1.1 ggh and qqh for ggH_htxs in ggHEstimation.htxs_dict: processes[ch][ggH_htxs] = Process(ggH_htxs, ggHEstimation(ggH_htxs, era, directory, channel_dict[ch], friend_directory=friend_directories[ch])) for qqH_htxs in qqHEstimation.htxs_dict: processes[ch][qqH_htxs] = Process(qqH_htxs, qqHEstimation(qqH_htxs, era, directory, channel_dict[ch], friend_directory=friend_directories[ch])) # channel-specific processes if args.shape_group == "backgrounds": if ch in ["mt", "et"]: processes[ch]["FAKES"] = Process("jetFakes", NewFakeEstimationLT(era, directory, channel_dict[ch], [processes[ch][process] for process in ["EMB", "ZL", "TTL", "VVL"]], processes[ch]["data"], friend_directory=friend_directories[ch]+[ff_friend_directory])) elif ch == "tt": processes[ch]["FAKES"] = Process("jetFakes", NewFakeEstimationTT(era, directory, channel_dict[ch], [processes[ch][process] for process in ["EMB", "ZL", "TTL", "VVL"]], processes[ch]["data"], friend_directory=friend_directories[ch]+[ff_friend_directory])) elif ch == "em": processes[ch]["W"] = Process("W", WEstimation(era, directory, channel_dict[ch], friend_directory=friend_directories[ch])) processes[ch]["QCD"] = Process("QCD", QCDEstimation_SStoOS_MTETEM(era, directory, channel_dict[ch], [processes[ch][process] for process in ["EMB", "ZL", "W", "VVL", "TTL"]], processes[ch]["data"], extrapolation_factor=1.0, qcd_weight = Weight("em_qcd_extrap_up_Weight","qcd_weight"))) # Variables and categories if sys.version_info.major <= 2 and sys.version_info.minor <= 7 and sys.version_info.micro <= 15: binning = yaml.load(open(args.binning)) else: binning = yaml.load(open(args.binning), Loader=yaml.FullLoader) # Cut-based analysis shapes categories = { "mt" : [], "et" : [], "tt" : [], "em" : [], } for ch in args.channels: discriminator = construct_variable(binning, args.discriminator_variable) for category in binning["cutbased"][ch]: cuts = Cuts(Cut(binning["cutbased"][ch][category], category)) categories[ch].append(Category(category, channel_dict[ch], cuts, variable=discriminator)) if category in [ "nobtag", "nobtag_lowmsv"]: for subcategory in sorted(binning["stxs_stage1p1_v2"][ch]): stage1p1cuts = copy.deepcopy(cuts) stage1p1cuts.add(Cut(binning["stxs_stage1p1_v2"][ch][subcategory], category + "_" + subcategory)) categories[ch].append(Category(category + "_" + subcategory, channel_dict[ch], stage1p1cuts, variable=discriminator)) # Choice of activated signal processes signal_nicks = [] sm_htt_backgrounds_nicks = ["WH125", "ZH125", "VH125", "ttH125"] sm_hww_nicks = ["ggHWW125", "qqHWW125"] sm_htt_signals_nicks = [ggH_htxs for ggH_htxs in ggHEstimation.htxs_dict] + [qqH_htxs for qqH_htxs in qqHEstimation.htxs_dict] susy_nicks = [] if "gg" in args.shape_group: for m in susyggH_masses: susy_nicks.append(args.shape_group + "_" + str(m)) if args.shape_group == "bbH": for m in susybbH_masses: susy_nicks.append("bbH_" + str(m)) if args.shape_group == "backgrounds": signal_nicks = sm_htt_backgrounds_nicks + sm_hww_nicks elif args.shape_group == "sm_signals": signal_nicks = sm_htt_signals_nicks else: signal_nicks = susy_nicks # Nominal histograms for ch in args.channels: for process, category in product(processes[ch].values(), categories[ch]): systematics.add(Systematic(category=category, process=process, analysis="mssmvssm", era=era, variation=Nominal(), mass="125")) # Setup shapes variations # EMB: 10% removed events in ttbar simulation (ttbar -> real tau tau events) will be added/subtracted to EMB shape to use as systematic. Technical procedure different to usual systematic variations if args.shape_group == "backgrounds": tttautau_process = {} for ch in args.channels: tttautau_process[ch] = Process("TTT", TTTEstimation(era, directory, channel_dict[ch], friend_directory=friend_directories[ch])) processes[ch]['ZTTpTTTauTauDown'] = Process("ZTTpTTTauTauDown", AddHistogramEstimationMethod("AddHistogram", "nominal", era, directory, channel_dict[ch], [processes[ch]["EMB"], tttautau_process[ch]], [1.0, -0.1])) processes[ch]['ZTTpTTTauTauUp'] = Process("ZTTpTTTauTauUp", AddHistogramEstimationMethod("AddHistogram", "nominal", era, directory, channel_dict[ch], [processes[ch]["EMB"], tttautau_process[ch]], [1.0, 0.1])) for category in categories[ch]: for updownvar in ["Down", "Up"]: systematics.add(Systematic(category=category, process=processes[ch]['ZTTpTTTauTau%s'%updownvar], analysis="smhtt", era=era, variation=Relabel("CMS_htt_emb_ttbar_Run2017", updownvar), mass="125")) # Prefiring weights prefiring_variations = [ ReplaceWeight("CMS_prefiring_Run2017", "prefireWeight", Weight("prefiringweightup", "prefireWeight"),"Up"), ReplaceWeight("CMS_prefiring_Run2017", "prefireWeight", Weight("prefiringweightdown", "prefireWeight"),"Down"), ] # Splitted JES shapes jet_es_variations = create_systematic_variations("CMS_scale_j_eta0to3_Run2017", "jecUncEta0to3", DifferentPipeline) jet_es_variations += create_systematic_variations("CMS_scale_j_eta0to5_Run2017", "jecUncEta0to5", DifferentPipeline) jet_es_variations += create_systematic_variations("CMS_scale_j_eta3to5_Run2017", "jecUncEta3to5", DifferentPipeline) jet_es_variations += create_systematic_variations("CMS_scale_j_RelativeBal_Run2017", "jecUncRelativeBal", DifferentPipeline) jet_es_variations += create_systematic_variations("CMS_scale_j_RelativeSample_Run2017", "jecUncRelativeSample",DifferentPipeline) # B-tagging btag_eff_variations = create_systematic_variations("CMS_htt_eff_b_Run2017", "btagEff", DifferentPipeline) mistag_eff_variations = create_systematic_variations("CMS_htt_mistag_b_Run2017", "btagMistag", DifferentPipeline) ## Variations common for all groups (most of the mc-related systematics) common_mc_variations = prefiring_variations + btag_eff_variations + mistag_eff_variations + jet_es_variations # MET energy scale. Note: only those variations for non-resonant processes are used in the stat. inference met_unclustered_variations = create_systematic_variations("CMS_scale_met_unclustered", "metUnclusteredEn", DifferentPipeline) # Recoil correction unc, for resonant processes recoil_variations = create_systematic_variations( "CMS_htt_boson_reso_met_Run2017", "metRecoilResolution", DifferentPipeline) recoil_variations += create_systematic_variations( "CMS_htt_boson_scale_met_Run2017", "metRecoilResponse", DifferentPipeline) # Tau energy scale (general, MC-specific & EMB-specific), it is mt, et & tt specific tau_es_variations = {} for unctype in ["", "_mc", "_emb"]: tau_es_variations[unctype] = create_systematic_variations("CMS_scale%s_t_3prong_Run2017"%unctype, "tauEsThreeProng", DifferentPipeline) tau_es_variations[unctype] += create_systematic_variations("CMS_scale%s_t_1prong_Run2017"%unctype, "tauEsOneProng", DifferentPipeline) tau_es_variations[unctype] += create_systematic_variations("CMS_scale%s_t_1prong1pizero_Run2017"%unctype, "tauEsOneProngOnePiZero", DifferentPipeline) # Ele energy scale & smear uncertainties (MC-specific), it is et & em specific ele_es_variations = create_systematic_variations("CMS_scale_mc_e", "eleScale", DifferentPipeline) ele_es_variations += create_systematic_variations("CMS_reso_mc_e", "eleSmear", DifferentPipeline) # Z pt reweighting zpt_variations = create_systematic_variations("CMS_htt_dyShape_Run2017", "zPtReweightWeight", SquareAndRemoveWeight) # top pt reweighting top_pt_variations = create_systematic_variations("CMS_htt_ttbarShape", "topPtReweightWeight", SquareAndRemoveWeight) # Ele energy scale (EMB-specific), it is et & em specific ele_es_emb_variations = create_systematic_variations("CMS_scale_emb_e", "eleEs", DifferentPipeline) # EMB charged track correction uncertainty (DM-dependent) decayMode_variations = [] decayMode_variations.append(ReplaceWeight("CMS_3ProngEff_Run2017", "decayMode_SF", Weight("embeddedDecayModeWeight_effUp_pi0Nom", "decayMode_SF"), "Up")) decayMode_variations.append(ReplaceWeight("CMS_3ProngEff_Run2017", "decayMode_SF", Weight("embeddedDecayModeWeight_effDown_pi0Nom", "decayMode_SF"), "Down")) decayMode_variations.append(ReplaceWeight("CMS_1ProngPi0Eff_Run2017", "decayMode_SF", Weight("embeddedDecayModeWeight_effNom_pi0Up", "decayMode_SF"), "Up")) decayMode_variations.append(ReplaceWeight("CMS_1ProngPi0Eff_Run2017", "decayMode_SF", Weight("embeddedDecayModeWeight_effNom_pi0Down", "decayMode_SF"), "Down")) # QCD for em qcd_variations = [] qcd_variations.append(ReplaceWeight("CMS_htt_qcd_0jet_rate_Run2017", "qcd_weight", Weight("em_qcd_osss_0jet_rateup_Weight*em_qcd_extrap_uncert_Weight", "qcd_weight"), "Up")) qcd_variations.append(ReplaceWeight("CMS_htt_qcd_0jet_rate_Run2017", "qcd_weight", Weight("em_qcd_osss_0jet_ratedown_Weight*em_qcd_extrap_uncert_Weight", "qcd_weight"), "Down")) qcd_variations.append(ReplaceWeight("CMS_htt_qcd_0jet_shape_Run2017", "qcd_weight", Weight("em_qcd_osss_0jet_shapeup_Weight*em_qcd_extrap_uncert_Weight", "qcd_weight"), "Up")) qcd_variations.append(ReplaceWeight("CMS_htt_qcd_0jet_shape_Run2017", "qcd_weight", Weight("em_qcd_osss_0jet_shapedown_Weight*em_qcd_extrap_uncert_Weight", "qcd_weight"), "Down")) qcd_variations.append(ReplaceWeight("CMS_htt_qcd_1jet_shape_Run2017", "qcd_weight", Weight("em_qcd_osss_1jet_shapeup_Weight*em_qcd_extrap_uncert_Weight", "qcd_weight"), "Up")) qcd_variations.append(ReplaceWeight("CMS_htt_qcd_1jet_shape_Run2017", "qcd_weight", Weight("em_qcd_osss_1jet_shapedown_Weight*em_qcd_extrap_uncert_Weight", "qcd_weight"), "Down")) qcd_variations.append(ReplaceWeight("CMS_htt_qcd_iso_Run2017", "qcd_weight", Weight("em_qcd_extrap_up_Weight*em_qcd_extrap_uncert_Weight", "qcd_weight"), "Up")) qcd_variations.append(ReplaceWeight("CMS_htt_qcd_iso_Run2017", "qcd_weight", Weight("em_qcd_osss_binned_Weight", "qcd_weight"), "Down")) qcd_variations.append(ReplaceWeight("CMS_htt_qcd_iso", "qcd_weight", Weight("em_qcd_extrap_up_Weight*em_qcd_extrap_uncert_Weight", "qcd_weight"), "Up")) qcd_variations.append(ReplaceWeight("CMS_htt_qcd_iso", "qcd_weight", Weight("em_qcd_osss_binned_Weight", "qcd_weight"), "Down")) # Gluon-fusion WG1 uncertainty scheme ggh_variations = [] for unc in [ "THU_ggH_Mig01", "THU_ggH_Mig12", "THU_ggH_Mu", "THU_ggH_PT120", "THU_ggH_PT60", "THU_ggH_Res", "THU_ggH_VBF2j", "THU_ggH_VBF3j", "THU_ggH_qmtop" ]: ggh_variations.append(AddWeight(unc, "{}_weight".format(unc), Weight("({})".format(unc), "{}_weight".format(unc)), "Up")) ggh_variations.append(AddWeight(unc, "{}_weight".format(unc), Weight("(1.0/{})".format(unc), "{}_weight".format(unc)), "Down")) # ZL fakes energy scale fakelep_dict = {"et" : "Ele", "mt" : "Mu"} lep_fake_es_variations = {} for ch in ["mt", "et"]: lep_fake_es_variations[ch] = create_systematic_variations("CMS_ZLShape_%s_1prong_Run2017"%ch, "tau%sFakeEsOneProng"%fakelep_dict[ch], DifferentPipeline) lep_fake_es_variations[ch] += create_systematic_variations("CMS_ZLShape_%s_1prong1pizero_Run2017"%ch, "tau%sFakeEsOneProngPiZeros"%fakelep_dict[ch], DifferentPipeline) # Lepton trigger efficiency; the same values for (MC & EMB) and (mt & et) lep_trigger_eff_variations = {} for ch in ["mt", "et"]: lep_trigger_eff_variations[ch] = {} for unctype in ["", "_emb"]: lep_trigger_eff_variations[ch][unctype] = [] lep_trigger_eff_variations[ch][unctype].append(AddWeight("CMS_eff_trigger%s_%s_Run2017"%(unctype, ch), "trg_%s_eff_weight"%ch, Weight("(1.0*(pt_1<=25)+1.02*(pt_1>25))", "trg_%s_eff_weight"%ch), "Up")) lep_trigger_eff_variations[ch][unctype].append(AddWeight("CMS_eff_trigger%s_%s_Run2017"%(unctype, ch), "trg_%s_eff_weight"%ch, Weight("(1.0*(pt_1<=25)+0.98*(pt_1>25))", "trg_%s_eff_weight"%ch), "Down")) lep_trigger_eff_variations[ch][unctype].append(AddWeight("CMS_eff_xtrigger%s_%s_Run2017"%(unctype, ch), "xtrg_%s_eff_weight"%ch, Weight("(1.054*(pt_1<=25)+1.0*(pt_1>25))", "xtrg_%s_eff_weight"%ch), "Up")) lep_trigger_eff_variations[ch][unctype].append(AddWeight("CMS_eff_xtrigger%s_%s_Run2017"%(unctype, ch), "xtrg_%s_eff_weight"%ch, Weight("(0.946*(pt_1<=25)+1.0*(pt_1>25))", "xtrg_%s_eff_weight"%ch), "Down")) # jetfakes fake_factor_variations = {} for ch in ["mt", "et", "tt"]: fake_factor_variations[ch] = [] if ch in ["mt", "et"]: for systematic_shift in [ "ff_qcd{ch}_syst_Run2017{shift}", "ff_qcd_dm0_njet0{ch}_stat_Run2017{shift}", "ff_qcd_dm0_njet1{ch}_stat_Run2017{shift}", "ff_w_syst_Run2017{shift}", "ff_w_dm0_njet0{ch}_stat_Run2017{shift}", "ff_w_dm0_njet1{ch}_stat_Run2017{shift}", "ff_tt_syst_Run2017{shift}", "ff_tt_dm0_njet0_stat_Run2017{shift}", "ff_tt_dm0_njet1_stat_Run2017{shift}", ]: for shift_direction in ["Up", "Down"]: fake_factor_variations[ch].append(ReplaceWeight("CMS_%s"%(systematic_shift.format(ch="_"+ch, shift="").replace("_dm0", "")), "fake_factor", Weight("ff2_{syst}".format(syst=systematic_shift.format(ch="", shift="_%s" %shift_direction.lower()).replace("_Run2017", "")), "fake_factor"), shift_direction)) elif ch == "tt": for systematic_shift in [ "ff_qcd{ch}_syst_Run2017{shift}", "ff_qcd_dm0_njet0{ch}_stat_Run2017{shift}", "ff_qcd_dm0_njet1{ch}_stat_Run2017{shift}", "ff_w{ch}_syst_Run2017{shift}", "ff_tt{ch}_syst_Run2017{shift}", "ff_w_frac{ch}_syst_Run2017{shift}", "ff_tt_frac{ch}_syst_Run2017{shift}" ]: for shift_direction in ["Up", "Down"]: fake_factor_variations[ch].append(ReplaceWeight("CMS_%s" % (systematic_shift.format(ch="_"+ch, shift="").replace("_dm0", "")), "fake_factor", Weight("(0.5*ff1_{syst}*(byTightIsolationMVArun2017v2DBoldDMwLT2017_1<0.5)+0.5*ff2_{syst}*(byTightIsolationMVArun2017v2DBoldDMwLT2017_2<0.5))".format(syst=systematic_shift.format(ch="", shift="_%s" % shift_direction.lower()).replace("_Run2017", "")), "fake_factor"), shift_direction)) ## Group nicks mc_nicks = ["ZL", "TTL", "VVL"] + signal_nicks # to be extended with 'W' in em boson_mc_nicks = ["ZL"] + signal_nicks # to be extended with 'W' in em ## Add variations to systematics for ch in args.channels: channel_mc_nicks = mc_nicks + ["W"] if ch == "em" else mc_nicks channel_boson_mc_nicks = boson_mc_nicks + ["W"] if ch == "em" else boson_mc_nicks if args.shape_group != "backgrounds": channel_mc_nicks = signal_nicks channel_boson_mc_nicks = signal_nicks channel_mc_common_variations = common_mc_variations if ch in ["et", "em"]: channel_mc_common_variations += ele_es_variations if ch in ["et", "mt", "tt"]: channel_mc_common_variations += tau_es_variations[""] + tau_es_variations["_mc"] if ch in ["et", "mt"]: channel_mc_common_variations += lep_trigger_eff_variations[ch][""] # variations common accross all shape groups for variation in channel_mc_common_variations: for process_nick in channel_mc_nicks: systematics.add_systematic_variation(variation=variation, process=processes[ch][process_nick], channel=channel_dict[ch], era=era) for variation in recoil_variations: for process_nick in channel_boson_mc_nicks: systematics.add_systematic_variation(variation=variation, process=processes[ch][process_nick], channel=channel_dict[ch], era=era) # variations relevant for ggH signals in 'sm_signals' shape group if args.shape_group == "sm_signals": for variation in ggh_variations: for process_nick in [nick for nick in signal_nicks if "ggH" in nick and "HWW" not in nick and "ggH_" not in nick]: systematics.add_systematic_variation(variation=variation, process=processes[ch][process_nick], channel=channel_dict[ch], era=era) # variations only relevant for the 'background' shape group if args.shape_group == "backgrounds": for variation in top_pt_variations: systematics.add_systematic_variation(variation=variation, process=processes[ch]["TTL"], channel=channel_dict[ch], era=era) for variation in met_unclustered_variations: for process_nick in ["TTL", "VVL"]: systematics.add_systematic_variation(variation=variation, process=processes[ch][process_nick], channel=channel_dict[ch], era=era) zl_variations = zpt_variations if ch in ["et", "mt"]: zl_variations += lep_fake_es_variations[ch] for variation in zl_variations: systematics.add_systematic_variation(variation=variation, process=processes[ch]["ZL"], channel=channel_dict[ch], era=era) if ch == "em": for variation in qcd_variations: systematics.add_systematic_variation(variation=variation ,process=processes[ch]["QCD"], channel=channel_dict[ch], era=era) if ch in ["mt","et", "tt"]: ff_variations = fake_factor_variations[ch] + tau_es_variations[""] + tau_es_variations["_mc"] + tau_es_variations["_emb"] for variation in ff_variations: systematics.add_systematic_variation(variation=variation, process=processes[ch]["FAKES"], channel=channel_dict[ch], era=era) emb_variations = [] if ch in ["mt","et", "tt"]: emb_variations += tau_es_variations[""] + tau_es_variations["_emb"] + decayMode_variations if ch in ["mt", "et"]: emb_variations += lep_trigger_eff_variations[ch]["_emb"] if ch in ["et", "em"]: emb_variations += ele_es_emb_variations for variation in emb_variations: systematics.add_systematic_variation(variation=variation, process=processes[ch]["EMB"], channel=channel_dict[ch], era=era) # Produce histograms logger.info("Start producing shapes.") systematics.produce() logger.info("Done producing shapes.")
def main(args): # Write arparse arguments to YAML config logger.debug("Write argparse arguments to YAML config.") output_config = {} output_config["base_path"] = args.base_path output_config["friend_paths"] = args.friend_paths output_config["output_path"] = args.output_path output_config["output_filename"] = args.output_filename output_config["tree_path"] = args.tree_path output_config["event_branch"] = args.event_branch output_config["training_weight_branch"] = args.training_weight_branch # Define era if "2016" in args.era: from shape_producer.estimation_methods_2016 import DataEstimation, ggHEstimation, qqHEstimation, ZTTEstimation, ZLEstimation, ZJEstimation, WEstimation, TTTEstimation, TTJEstimation, ZTTEmbeddedEstimation, TTLEstimation, EWKZEstimation, VVLEstimation, VVJEstimation, VVEstimation, VVTEstimation #QCDEstimation_SStoOS_MTETEM, QCDEstimationTT, EWKWpEstimation, EWKWmEstimation, , VHEstimation, HTTEstimation, from shape_producer.era import Run2016 era = Run2016(args.database) elif "2017" in args.era: from shape_producer.estimation_methods_2017 import DataEstimation, ZTTEstimation, ZJEstimation, ZLEstimation, TTLEstimation, TTJEstimation, TTTEstimation, VVTEstimation, VVJEstimation, VVLEstimation, WEstimation, ggHEstimation, qqHEstimation, EWKZEstimation, ZTTEmbeddedEstimation from shape_producer.era import Run2017 era = Run2017(args.database) elif "2018" in args.era: from shape_producer.estimation_methods_2018 import DataEstimation, ZTTEstimation, ZJEstimation, ZLEstimation, TTLEstimation, TTJEstimation, TTTEstimation, VVTEstimation, VVJEstimation, VVLEstimation, WEstimation, ggHEstimation, qqHEstimation, EWKZEstimation, ZTTEmbeddedEstimation from shape_producer.era import Run2018 era = Run2018(args.database) else: logger.fatal("Era {} is not implemented.".format(args.era)) raise Exception def estimationMethodAndClassMapGenerator(): ###### common processes classes_map = {"ggH": "ggh", "qqH": "qqh", "EWKZ": "misc"} estimationMethodList = [ ggHEstimation("ggH", era, args.base_path, channel), qqHEstimation("qqH", era, args.base_path, channel), EWKZEstimation(era, args.base_path, channel), VVLEstimation(era, args.base_path, channel), WEstimation(era, args.base_path, channel) ] ######## Check for emb vs MC if args.training_z_estimation_method == "emb": classes_map["EMB"] = "ztt" estimationMethodList.extend( [ZTTEmbeddedEstimation(era, args.base_path, channel)]) elif args.training_z_estimation_method == "mc": classes_map["ZTT"] = "ztt" estimationMethodList.extend([ ZTTEstimation(era, args.base_path, channel), TTTEstimation(era, args.base_path, channel), VVTEstimation(era, args.base_path, channel) ]) else: logger.fatal( "No valid training-z-estimation-method! Options are emb, mc. Argument was {}" .format(args.training_z_estimation_method)) raise Exception ##### TT* zl,zj processes estimationMethodList.extend([ TTLEstimation(era, args.base_path, channel), ZLEstimation(era, args.base_path, channel) ]) # less data-> less categories for tt if args.channel == "tt": classes_map.update({ "TTT": "misc", "TTL": "misc", "TTJ": "misc", "ZL": "misc", "ZJ": "misc" }) estimationMethodList.extend([ ZJEstimation(era, args.base_path, channel), TTJEstimation(era, args.base_path, channel) ]) ## not TTJ,ZJ for em elif args.channel == "em": classes_map.update({"TTT": "tt", "TTL": "tt", "ZL": "misc"}) else: classes_map.update({ "TTT": "tt", "TTL": "tt", "TTJ": "tt", "ZL": "zll", "ZJ": "zll" }) estimationMethodList.extend([ ZJEstimation(era, args.base_path, channel), TTJEstimation(era, args.base_path, channel) ]) ###w: # estimation metho already included, just different mapping fror et and mt if args.channel in ["et", "mt"]: classes_map["W"] = "w" else: classes_map["W"] = "misc" ##### VV/[VVT,VVL,VVJ] split # VVL in common, VVT in "EMBvsMC" if args.channel == "em": classes_map.update({"VVT": "db", "VVL": "db"}) else: classes_map.update({"VVT": "misc", "VVL": "misc", "VVJ": "misc"}) estimationMethodList.extend([ VVJEstimation(era, args.base_path, channel), ]) ### QCD class if args.channel == "tt": classes_map["QCD"] = "noniso" else: classes_map["QCD"] = "ss" return ([classes_map, estimationMethodList]) channelDict = {} channelDict["2016"] = { "mt": MTSM2016(), "et": ETSM2016(), "tt": TTSM2016(), "em": EMSM2016() } channelDict["2017"] = { "mt": MTSM2017(), "et": ETSM2017(), "tt": TTSM2017(), "em": EMSM2017() } channelDict["2018"] = { "mt": MTSM2018(), "et": ETSM2018(), "tt": TTSM2018(), "em": EMSM2018() } channel = channelDict[args.era][args.channel] # Set up `processes` part of config output_config["processes"] = {} # Additional cuts additional_cuts = Cuts() logger.warning("Use additional cuts for mt: %s", additional_cuts.expand()) classes_map, estimationMethodList = estimationMethodAndClassMapGenerator() ##MC+/Embedding Processes for estimation in estimationMethodList: output_config["processes"][estimation.name] = { "files": [ str(f).replace(args.base_path.rstrip("/") + "/", "") for f in estimation.get_files() ], "cut_string": (estimation.get_cuts() + channel.cuts + additional_cuts).expand(), "weight_string": estimation.get_weights().extract(), "class": classes_map[estimation.name] } ### # Same sign selection for data-driven QCD estimation = DataEstimation(era, args.base_path, channel) estimation.name = "QCD" channel_qcd = copy.deepcopy(channel) if args.channel != "tt": ## os= opposite sign channel_qcd.cuts.get("os").invert() # Same sign selection for data-driven QCD else: channel_qcd.cuts.remove("tau_2_iso") channel_qcd.cuts.add( Cut("byTightIsolationMVArun2017v2DBoldDMwLT2017_2<0.5", "tau_2_iso")) channel_qcd.cuts.add( Cut("byLooseIsolationMVArun2017v2DBoldDMwLT2017_2>0.5", "tau_2_iso_loose")) output_config["processes"][estimation.name] = { "files": [ str(f).replace(args.base_path.rstrip("/") + "/", "") for f in estimation.get_files() ], "cut_string": (estimation.get_cuts() + channel_qcd.cuts + additional_cuts).expand(), "weight_string": estimation.get_weights().extract(), "class": classes_map[estimation.name] } ##################################### # Write output config logger.info("Write config to file: {}".format(args.output_config)) yaml.dump(output_config, open(args.output_config, 'w'), default_flow_style=False)
def main(args): # Container for all distributions to be drawn logger.info("Set up shape variations.") systematics = Systematics("fake-factors/{}_ff_yields.root".format( args.tag), num_threads=args.num_threads) # Era selection if "2016" in args.era: from shape_producer.estimation_methods_2016 import DataEstimation, HTTEstimation, ggHEstimation, qqHEstimation, VHEstimation, ZTTEstimation, ZLEstimation, ZJEstimation, WEstimation, TTTEstimation, TTJEstimation, TTLEstimation, VVTEstimation, VVJEstimation, VVLEstimation, ZTTEmbeddedEstimation from shape_producer.era import Run2016 era = Run2016(args.datasets) else: logger.critical("Era {} is not implemented.".format(args.era)) raise Exception # Channels and processes channels = ["et", "mt", "tt"] additional_cuts = dict() additional_friends = dict() for channel in channels: with open(args.additional_cuts.format(channel), "r") as stream: config = yaml.load(stream) additional_cuts[channel] = config["cutstrings"] with open(args.additional_friends.format(channel), "r") as stream: config = yaml.load(stream) additional_friends[channel] = { key: value for key, value in zip(config["friend_dirs"], config["friend_aliases"]) } # yapf: disable directory = args.directory et_friend_directory = {args.et_friend_directory: ""} et_friend_directory.update(additional_friends["et"]) mt_friend_directory = {args.mt_friend_directory: ""} mt_friend_directory.update(additional_friends["mt"]) tt_friend_directory = {args.tt_friend_directory: ""} tt_friend_directory.update(additional_friends["tt"]) mt = MTSM2016() for cutstring in additional_cuts["mt"]: mt.cuts.add(Cut(cutstring)) mt.cuts.remove("tau_iso") mt.cuts.add(Cut("(byTightIsolationMVArun2v1DBoldDMwLT_2<0.5&&byVLooseIsolationMVArun2v1DBoldDMwLT_2>0.5)", "tau_anti_iso")) mt_processes = { "data" : Process("data_obs", DataEstimation (era, directory, mt, friend_directory=mt_friend_directory)), "EMB" : Process("EMB", ZTTEmbeddedEstimation(era, directory, mt, friend_directory=mt_friend_directory)), "ZTT" : Process("ZTT", ZTTEstimation (era, directory, mt, friend_directory=mt_friend_directory)), "ZL" : Process("ZL", ZLEstimation (era, directory, mt, friend_directory=mt_friend_directory)), "ZJ" : Process("ZJ", ZJEstimation (era, directory, mt, friend_directory=mt_friend_directory)), "W" : Process("W", WEstimation (era, directory, mt, friend_directory=mt_friend_directory)), "TTT" : Process("TTT", TTTEstimation (era, directory, mt, friend_directory=mt_friend_directory)), "TTL" : Process("TTL", TTLEstimation (era, directory, mt, friend_directory=mt_friend_directory)), "TTJ" : Process("TTJ", TTJEstimation (era, directory, mt, friend_directory=mt_friend_directory)), "VVT" : Process("VVT", VVTEstimation (era, directory, mt, friend_directory=mt_friend_directory)), "VVL" : Process("VVL", VVLEstimation (era, directory, mt, friend_directory=mt_friend_directory)), "VVJ" : Process("VVJ", VVJEstimation (era, directory, mt, friend_directory=mt_friend_directory)) #"EWKZ" : Process("EWKZ", EWKZEstimation (era, directory, mt, friend_directory=mt_friend_directory)) } et = ETSM2016() for cutstring in additional_cuts["et"]: et.cuts.add(Cut(cutstring)) et.cuts.remove("tau_iso") et.cuts.add(Cut("(byTightIsolationMVArun2v1DBoldDMwLT_2<0.5&&byVLooseIsolationMVArun2v1DBoldDMwLT_2>0.5)", "tau_anti_iso")) et_processes = { "data" : Process("data_obs", DataEstimation (era, directory, et, friend_directory=et_friend_directory)), "EMB" : Process("EMB", ZTTEmbeddedEstimation(era, directory, et, friend_directory=et_friend_directory)), "ZTT" : Process("ZTT", ZTTEstimation (era, directory, et, friend_directory=et_friend_directory)), "ZL" : Process("ZL", ZLEstimation (era, directory, et, friend_directory=et_friend_directory)), "ZJ" : Process("ZJ", ZJEstimation (era, directory, et, friend_directory=et_friend_directory)), "W" : Process("W", WEstimation (era, directory, et, friend_directory=et_friend_directory)), "TTT" : Process("TTT", TTTEstimation (era, directory, et, friend_directory=et_friend_directory)), "TTL" : Process("TTL", TTLEstimation (era, directory, et, friend_directory=et_friend_directory)), "TTJ" : Process("TTJ", TTJEstimation (era, directory, et, friend_directory=et_friend_directory)), "VVT" : Process("VVT", VVTEstimation (era, directory, et, friend_directory=et_friend_directory)), "VVL" : Process("VVL", VVLEstimation (era, directory, et, friend_directory=et_friend_directory)), "VVJ" : Process("VVJ", VVJEstimation (era, directory, et, friend_directory=et_friend_directory)) #"EWKZ" : Process("EWKZ", EWKZEstimation (era, directory, et, friend_directory=et_friend_directory)) } #in tt two 'channels' are needed: antiisolated region for each tau respectively tt1 = TTSM2016() for cutstring in additional_cuts["tt"]: tt1.cuts.add(Cut(cutstring)) tt1.cuts.remove("tau_1_iso") tt1.cuts.add(Cut("(byTightIsolationMVArun2v1DBoldDMwLT_1<0.5&&byVLooseIsolationMVArun2v1DBoldDMwLT_1>0.5)", "tau_1_anti_iso")) tt1_processes = { "data" : Process("data_obs", DataEstimation (era, directory, tt1, friend_directory=tt_friend_directory)), "EMB" : Process("EMB", ZTTEmbeddedEstimation(era, directory, tt1, friend_directory=tt_friend_directory)), "ZTT" : Process("ZTT", ZTTEstimation (era, directory, tt1, friend_directory=tt_friend_directory)), "ZL" : Process("ZL", ZLEstimation (era, directory, tt1, friend_directory=tt_friend_directory)), "ZJ" : Process("ZJ", ZJEstimation (era, directory, tt1, friend_directory=tt_friend_directory)), "W" : Process("W", WEstimation (era, directory, tt1, friend_directory=tt_friend_directory)), "TTT" : Process("TTT", TTTEstimation (era, directory, tt1, friend_directory=tt_friend_directory)), "TTL" : Process("TTL", TTLEstimation (era, directory, tt1, friend_directory=tt_friend_directory)), "TTJ" : Process("TTJ", TTJEstimation (era, directory, tt1, friend_directory=tt_friend_directory)), "VVT" : Process("VVT", VVTEstimation (era, directory, tt1, friend_directory=tt_friend_directory)), "VVL" : Process("VVL", VVLEstimation (era, directory, tt1, friend_directory=tt_friend_directory)), "VVJ" : Process("VVJ", VVJEstimation (era, directory, tt1, friend_directory=tt_friend_directory)) #"EWKZ" : Process("EWKZ", EWKZEstimation (era, directory, tt1, friend_directory=tt_friend_directory)), } tt2 = TTSM2016() for cutstring in additional_cuts["tt"]: tt2.cuts.add(Cut(cutstring)) tt2.cuts.remove("tau_2_iso") tt2.cuts.add(Cut("(byTightIsolationMVArun2v1DBoldDMwLT_2<0.5&&byVLooseIsolationMVArun2v1DBoldDMwLT_2>0.5)", "tau_2_anti_iso")) tt2_processes = { "data" : Process("data_obs", DataEstimation (era, directory, tt2, friend_directory=tt_friend_directory)), "EMB" : Process("EMB", ZTTEmbeddedEstimation(era, directory, tt2, friend_directory=tt_friend_directory)), "ZTT" : Process("ZTT", ZTTEstimation (era, directory, tt2, friend_directory=tt_friend_directory)), "ZL" : Process("ZL", ZLEstimation (era, directory, tt2, friend_directory=tt_friend_directory)), "ZJ" : Process("ZJ", ZJEstimation (era, directory, tt2, friend_directory=tt_friend_directory)), "W" : Process("W", WEstimation (era, directory, tt2, friend_directory=tt_friend_directory)), "TTT" : Process("TTT", TTTEstimation (era, directory, tt2, friend_directory=tt_friend_directory)), "TTL" : Process("TTL", TTLEstimation (era, directory, tt2, friend_directory=tt_friend_directory)), "TTJ" : Process("TTJ", TTJEstimation (era, directory, tt2, friend_directory=tt_friend_directory)), "VVT" : Process("VVT", VVTEstimation (era, directory, tt2, friend_directory=tt_friend_directory)), "VVL" : Process("VVL", VVLEstimation (era, directory, tt2, friend_directory=tt_friend_directory)), "VVJ" : Process("VVJ", VVJEstimation (era, directory, tt2, friend_directory=tt_friend_directory)) #"EWKZ" : Process("EWKZ", EWKZEstimation (era, directory, tt2, friend_directory=tt_friend_directory)), } # Variables and categories config = yaml.load(open("fake-factors/config.yaml")) if not args.config in config.keys(): logger.critical("Requested config key %s not available in fake-factors/config.yaml!" % args.config) raise Exception config = config[args.config] et_categories = [] # Analysis shapes et_categories.append( Category( "inclusive", et, Cuts(), variable=Variable(args.config, VariableBinning(config["et"]["binning"]), config["et"]["expression"]))) for i, label in enumerate(["ggh", "qqh", "ztt", "zll", "w", "tt", "ss", "misc"]): et_categories.append( Category( label, et, Cuts( Cut("et_max_index=={index}".format(index=i), "exclusive_score")), variable=Variable(args.config, VariableBinning(config["et"]["binning"]), config["et"]["expression"]))) mt_categories = [] # Analysis shapes mt_categories.append( Category( "inclusive", mt, Cuts(), variable=Variable(args.config, VariableBinning(config["mt"]["binning"]), config["mt"]["expression"]))) for i, label in enumerate(["ggh", "qqh", "ztt", "zll", "w", "tt", "ss", "misc"]): mt_categories.append( Category( label, mt, Cuts( Cut("mt_max_index=={index}".format(index=i), "exclusive_score")), variable=Variable(args.config, VariableBinning(config["mt"]["binning"]), config["mt"]["expression"]))) tt1_categories = [] tt2_categories = [] # Analysis shapes tt1_categories.append( Category( "tt1_inclusive", tt1, Cuts(), variable=Variable(args.config, VariableBinning(config["tt"]["binning"]), config["tt"]["expression"]))) tt2_categories.append( Category( "tt2_inclusive", tt2, Cuts(), variable=Variable(args.config, VariableBinning(config["tt"]["binning"]), config["tt"]["expression"]))) for i, label in enumerate(["ggh", "qqh", "ztt", "noniso", "misc"]): tt1_categories.append( Category( "tt1_"+label, tt1, Cuts( Cut("tt_max_index=={index}".format(index=i), "exclusive_score")), variable=Variable(args.config, VariableBinning(config["tt"]["binning"]), config["tt"]["expression"]))) tt2_categories.append( Category( "tt2_"+label, tt2, Cuts( Cut("tt_max_index=={index}".format(index=i), "exclusive_score")), variable=Variable(args.config, VariableBinning(config["tt"]["binning"]), config["tt"]["expression"]))) # Nominal histograms # yapf: enable for process, category in product(et_processes.values(), et_categories): systematics.add( Systematic(category=category, process=process, analysis="smhtt", era=era, variation=Nominal(), mass="125")) for process, category in product(mt_processes.values(), mt_categories): systematics.add( Systematic(category=category, process=process, analysis="smhtt", era=era, variation=Nominal(), mass="125")) for process, category in product(tt1_processes.values(), tt1_categories): systematics.add( Systematic(category=category, process=process, analysis="smhtt", era=era, variation=Nominal(), mass="125")) for process, category in product(tt2_processes.values(), tt2_categories): systematics.add( Systematic(category=category, process=process, analysis="smhtt", era=era, variation=Nominal(), mass="125")) # Produce histograms logger.info("Start producing shapes.") systematics.produce() logger.info("Done producing shapes.")
def main(args): # Container for all distributions to be drawn logger.info("Set up shape variations.") systematics = Systematics( "{}_shapes.root".format(args.tag), num_threads=args.num_threads, skip_systematic_variations=args.skip_systematic_variations) # Era selection if "2018" in args.era: from shape_producer.estimation_methods_2018 import DataEstimation, ZTTEstimation, ZTTEmbeddedEstimation, ZLEstimation, ZJEstimation, TTLEstimation, TTJEstimation, TTTEstimation, VVLEstimation, VVTEstimation, VVJEstimation, WEstimation, ggHEstimation, ggHEstimation_0J, ggHEstimation_1J_PTH_0_60, ggHEstimation_1J_PTH_60_120, ggHEstimation_1J_PTH_120_200, ggHEstimation_1J_PTH_GT200, ggHEstimation_GE2J_PTH_0_60, ggHEstimation_GE2J_PTH_60_120, ggHEstimation_GE2J_PTH_120_200, ggHEstimation_GE2J_PTH_GT200, ggHEstimation_VBFTOPO_JET3, ggHEstimation_VBFTOPO_JET3VETO, qqHEstimation, qqHEstimation_VBFTOPO_JET3VETO, qqHEstimation_VBFTOPO_JET3, qqHEstimation_REST, qqHEstimation_VH2JET, qqHEstimation_PTJET1_GT200, VHEstimation, WHEstimation, ZHEstimation, ttHEstimation, QCDEstimation_ABCD_TT_ISO2, QCDEstimation_SStoOS_MTETEM, FakeEstimationLT, NewFakeEstimationLT, FakeEstimationTT, NewFakeEstimationTT from shape_producer.era import Run2018 era = Run2018(args.datasets) else: logger.critical("Era {} is not implemented.".format(args.era)) raise Exception # Channels and processes # yapf: disable directory = args.directory et_friend_directory = []#args.et_friend_directory em_friend_directory = []#args.em_friend_directory mt_friend_directory = []#args.mt_friend_directory tt_friend_directory = []#args.tt_friend_directory ff_friend_directory = []#args.fake_factor_friend_directory mt = MTSM2018() mt_processes = { "data" : Process("data_obs", DataEstimation (era, directory, mt, friend_directory=mt_friend_directory)), "ZTT" : Process("ZTT", ZTTEstimation (era, directory, mt, friend_directory=mt_friend_directory)), "EMB" : Process("EMB", ZTTEmbeddedEstimation (era, directory, mt, friend_directory=mt_friend_directory)), "ZJ" : Process("ZJ", ZJEstimation (era, directory, mt, friend_directory=mt_friend_directory)), "ZL" : Process("ZL", ZLEstimation (era, directory, mt, friend_directory=mt_friend_directory)), "TTT" : Process("TTT", TTTEstimation (era, directory, mt, friend_directory=mt_friend_directory)), "TTJ" : Process("TTJ", TTJEstimation (era, directory, mt, friend_directory=mt_friend_directory)), "TTL" : Process("TTL", TTLEstimation (era, directory, mt, friend_directory=mt_friend_directory)), "VVT" : Process("VVT", VVTEstimation (era, directory, mt, friend_directory=mt_friend_directory)), "VVJ" : Process("VVJ", VVJEstimation (era, directory, mt, friend_directory=mt_friend_directory)), "VVL" : Process("VVL", VVLEstimation (era, directory, mt, friend_directory=mt_friend_directory)), "W" : Process("W", WEstimation (era, directory, mt, friend_directory=mt_friend_directory)), "ggH" : Process("ggH125", ggHEstimation (era, directory, mt, friend_directory=mt_friend_directory)), "qqH" : Process("qqH125", qqHEstimation (era, directory, mt, friend_directory=mt_friend_directory)), # "ggH_0J" : Process("ggH_0J125", ggHEstimation_0J (era, directory, mt, friend_directory=mt_friend_directory)), # "ggH_1J_PTH_0_60" : Process("ggH_1J_PTH_0_60125", ggHEstimation_1J_PTH_0_60 (era, directory, mt, friend_directory=mt_friend_directory)), # "ggH_1J_PTH_60_120" : Process("ggH_1J_PTH_60_120125", ggHEstimation_1J_PTH_60_120 (era, directory, mt, friend_directory=mt_friend_directory)), # "ggH_1J_PTH_120_200" : Process("ggH_1J_PTH_120_200125", ggHEstimation_1J_PTH_120_200 (era, directory, mt, friend_directory=mt_friend_directory)), # "ggH_1J_PTH_GT200" : Process("ggH_1J_PTH_GT200125", ggHEstimation_1J_PTH_GT200 (era, directory, mt, friend_directory=mt_friend_directory)), # "ggH_GE2J_PTH_0_60" : Process("ggH_GE2J_PTH_0_60125", ggHEstimation_GE2J_PTH_0_60 (era, directory, mt, friend_directory=mt_friend_directory)), # "ggH_GE2J_PTH_60_120" : Process("ggH_GE2J_PTH_60_120125", ggHEstimation_GE2J_PTH_60_120 (era, directory, mt, friend_directory=mt_friend_directory)), # "ggH_GE2J_PTH_120_200" : Process("ggH_GE2J_PTH_120_200125", ggHEstimation_GE2J_PTH_120_200(era, directory, mt, friend_directory=mt_friend_directory)), # "ggH_GE2J_PTH_GT200" : Process("ggH_GE2J_PTH_GT200125", ggHEstimation_GE2J_PTH_GT200 (era, directory, mt, friend_directory=mt_friend_directory)), # "ggH_VBFTOPO_JET3VETO" : Process("ggH_VBFTOPO_JET3VETO125", ggHEstimation_VBFTOPO_JET3VETO(era, directory, mt, friend_directory=mt_friend_directory)), # "ggH_VBFTOPO_JET3" : Process("ggH_VBFTOPO_JET3125", ggHEstimation_VBFTOPO_JET3 (era, directory, mt, friend_directory=mt_friend_directory)), # "qqH_VBFTOPO_JET3VETO" : Process("qqH_VBFTOPO_JET3VETO125", qqHEstimation_VBFTOPO_JET3VETO(era, directory, mt, friend_directory=mt_friend_directory)), # "qqH_VBFTOPO_JET3" : Process("qqH_VBFTOPO_JET3125", qqHEstimation_VBFTOPO_JET3 (era, directory, mt, friend_directory=mt_friend_directory)), # "qqH_REST" : Process("qqH_REST125", qqHEstimation_REST (era, directory, mt, friend_directory=mt_friend_directory)), # "qqH_VH2JET" : Process("qqH_VH2JET125", qqHEstimation_VH2JET (era, directory, mt, friend_directory=mt_friend_directory)), # "qqH_PTJET1_GT200" : Process("qqH_PTJET1_GT200125", qqHEstimation_PTJET1_GT200 (era, directory, mt, friend_directory=mt_friend_directory)), # "VH" : Process("VH125", VHEstimation (era, directory, mt, friend_directory=mt_friend_directory)), # "WH" : Process("WH125", WHEstimation (era, directory, mt, friend_directory=mt_friend_directory)), # "ZH" : Process("ZH125", ZHEstimation (era, directory, mt, friend_directory=mt_friend_directory)), # "ttH" : Process("ttH125", ttHEstimation (era, directory, mt, friend_directory=mt_friend_directory)), } # mt_processes["FAKES"] = Process("jetFakes", NewFakeEstimationLT(era, directory, mt, [mt_processes[process] for process in ["EMB", "ZL", "TTL", "VVL"]], mt_processes["data"], friend_directory=[mt_friend_directory, ff_friend_directory])) #mt_fakes_for_uncs=Process("jetFakes", FakeEstimationLT(era, directory, mt, friend_directory=[mt_friend_directory, ff_friend_directory])) mt_processes["QCD"] = Process("QCD", QCDEstimation_SStoOS_MTETEM(era, directory, mt, [mt_processes[process] for process in ["ZTT", "ZL", "ZJ", "TTL","TTT","TTJ", "VVT", "VVJ", "VVL","W"]], mt_processes["data"], friend_directory=mt_friend_directory, extrapolation_factor=1.1)) mt_processes["QCDEMB"] = Process("QCDEMB", QCDEstimation_SStoOS_MTETEM(era, directory, mt, [mt_processes[process] for process in ["EMB", "ZL", "ZJ", "TTL", "TTJ", "VVJ", "VVL","W"]], mt_processes["data"], friend_directory=mt_friend_directory, extrapolation_factor=1.1)) et = ETSM2018() et_processes = { "data" : Process("data_obs", DataEstimation (era, directory, et, friend_directory=et_friend_directory)), "ZTT" : Process("ZTT", ZTTEstimation (era, directory, et, friend_directory=et_friend_directory)), "EMB" : Process("EMB", ZTTEmbeddedEstimation (era, directory, et, friend_directory=et_friend_directory)), "ZJ" : Process("ZJ", ZJEstimation (era, directory, et, friend_directory=et_friend_directory)), "ZL" : Process("ZL", ZLEstimation (era, directory, et, friend_directory=et_friend_directory)), "TTT" : Process("TTT", TTTEstimation (era, directory, et, friend_directory=et_friend_directory)), "TTJ" : Process("TTJ", TTJEstimation (era, directory, et, friend_directory=et_friend_directory)), "TTL" : Process("TTL", TTLEstimation (era, directory, et, friend_directory=et_friend_directory)), "VVT" : Process("VVT", VVTEstimation (era, directory, et, friend_directory=et_friend_directory)), "VVJ" : Process("VVJ", VVJEstimation (era, directory, et, friend_directory=et_friend_directory)), "VVL" : Process("VVL", VVLEstimation (era, directory, et, friend_directory=et_friend_directory)), "W" : Process("W", WEstimation (era, directory, et, friend_directory=et_friend_directory)), "ggH" : Process("ggH125", ggHEstimation (era, directory, et, friend_directory=et_friend_directory)), "qqH" : Process("qqH125", qqHEstimation (era, directory, et, friend_directory=et_friend_directory)), # "ggH_0J" : Process("ggH_0J125", ggHEstimation_0J (era, directory, et, friend_directory=et_friend_directory)), # "ggH_1J_PTH_0_60" : Process("ggH_1J_PTH_0_60125", ggHEstimation_1J_PTH_0_60 (era, directory, et, friend_directory=et_friend_directory)), # "ggH_1J_PTH_60_120" : Process("ggH_1J_PTH_60_120125", ggHEstimation_1J_PTH_60_120 (era, directory, et, friend_directory=et_friend_directory)), # "ggH_1J_PTH_120_200" : Process("ggH_1J_PTH_120_200125", ggHEstimation_1J_PTH_120_200 (era, directory, et, friend_directory=et_friend_directory)), # "ggH_1J_PTH_GT200" : Process("ggH_1J_PTH_GT200125", ggHEstimation_1J_PTH_GT200 (era, directory, et, friend_directory=et_friend_directory)), # "ggH_GE2J_PTH_0_60" : Process("ggH_GE2J_PTH_0_60125", ggHEstimation_GE2J_PTH_0_60 (era, directory, et, friend_directory=et_friend_directory)), # "ggH_GE2J_PTH_60_120" : Process("ggH_GE2J_PTH_60_120125", ggHEstimation_GE2J_PTH_60_120 (era, directory, et, friend_directory=et_friend_directory)), # "ggH_GE2J_PTH_120_200" : Process("ggH_GE2J_PTH_120_200125", ggHEstimation_GE2J_PTH_120_200(era, directory, et, friend_directory=et_friend_directory)), # "ggH_GE2J_PTH_GT200" : Process("ggH_GE2J_PTH_GT200125", ggHEstimation_GE2J_PTH_GT200 (era, directory, et, friend_directory=et_friend_directory)), # "ggH_VBFTOPO_JET3VETO" : Process("ggH_VBFTOPO_JET3VETO125", ggHEstimation_VBFTOPO_JET3VETO(era, directory, et, friend_directory=et_friend_directory)), # "ggH_VBFTOPO_JET3" : Process("ggH_VBFTOPO_JET3125", ggHEstimation_VBFTOPO_JET3 (era, directory, et, friend_directory=et_friend_directory)), # "qqH_VBFTOPO_JET3VETO" : Process("qqH_VBFTOPO_JET3VETO125", qqHEstimation_VBFTOPO_JET3VETO(era, directory, et, friend_directory=et_friend_directory)), # "qqH_VBFTOPO_JET3" : Process("qqH_VBFTOPO_JET3125", qqHEstimation_VBFTOPO_JET3 (era, directory, et, friend_directory=et_friend_directory)), # "qqH_REST" : Process("qqH_REST125", qqHEstimation_REST (era, directory, et, friend_directory=et_friend_directory)), # "qqH_VH2JET" : Process("qqH_VH2JET125", qqHEstimation_VH2JET (era, directory, et, friend_directory=et_friend_directory)), # "qqH_PTJET1_GT200" : Process("qqH_PTJET1_GT200125", qqHEstimation_PTJET1_GT200 (era, directory, et, friend_directory=et_friend_directory)), # "VH" : Process("VH125", VHEstimation (era, directory, et, friend_directory=et_friend_directory)), # "WH" : Process("WH125", WHEstimation (era, directory, et, friend_directory=et_friend_directory)), # "ZH" : Process("ZH125", ZHEstimation (era, directory, et, friend_directory=et_friend_directory)), # "ttH" : Process("ttH125", ttHEstimation (era, directory, et, friend_directory=et_friend_directory)), } # et_processes["FAKES"] = Process("jetFakes", NewFakeEstimationLT(era, directory, et, [et_processes[process] for process in ["EMB", "ZL", "TTL", "VVL"]], et_processes["data"], friend_directory=[et_friend_directory, ff_friend_directory])) et_processes["QCD"] = Process("QCD", QCDEstimation_SStoOS_MTETEM(era, directory, et, [et_processes[process] for process in ["ZTT", "ZL", "ZJ", "W", "TTT", "TTJ", "TTL", "VVT", "VVJ", "VVL"]], et_processes["data"], friend_directory=et_friend_directory, extrapolation_factor=1.1)) et_processes["QCDEMB"] = Process("QCDEMB", QCDEstimation_SStoOS_MTETEM(era, directory, et, [et_processes[process] for process in ["EMB", "ZL", "ZJ", "W", "TTJ", "TTL", "VVJ", "VVL"]], et_processes["data"], friend_directory=et_friend_directory, extrapolation_factor=1.1)) tt = TTSM2018() tt_processes = { "data" : Process("data_obs", DataEstimation (era, directory, tt, friend_directory=tt_friend_directory)), "ZTT" : Process("ZTT", ZTTEstimation (era, directory, tt, friend_directory=tt_friend_directory)), "EMB" : Process("EMB", ZTTEmbeddedEstimation (era, directory, tt, friend_directory=tt_friend_directory)), "ZJ" : Process("ZJ", ZJEstimation (era, directory, tt, friend_directory=tt_friend_directory)), "ZL" : Process("ZL", ZLEstimation (era, directory, tt, friend_directory=tt_friend_directory)), "TTT" : Process("TTT", TTTEstimation (era, directory, tt, friend_directory=tt_friend_directory)), "TTJ" : Process("TTJ", TTJEstimation (era, directory, tt, friend_directory=tt_friend_directory)), "TTL" : Process("TTL", TTLEstimation (era, directory, tt, friend_directory=tt_friend_directory)), "VVT" : Process("VVT", VVTEstimation (era, directory, tt, friend_directory=tt_friend_directory)), "VVJ" : Process("VVJ", VVJEstimation (era, directory, tt, friend_directory=tt_friend_directory)), "VVL" : Process("VVL", VVLEstimation (era, directory, tt, friend_directory=tt_friend_directory)), "W" : Process("W", WEstimation (era, directory, tt, friend_directory=tt_friend_directory)), "ggH" : Process("ggH125", ggHEstimation (era, directory, tt, friend_directory=tt_friend_directory)), "qqH" : Process("qqH125", qqHEstimation (era, directory, tt, friend_directory=tt_friend_directory)), # "ggH_0J" : Process("ggH_0J125", ggHEstimation_0J (era, directory, tt, friend_directory=tt_friend_directory)), # "ggH_1J_PTH_0_60" : Process("ggH_1J_PTH_0_60125", ggHEstimation_1J_PTH_0_60 (era, directory, tt, friend_directory=tt_friend_directory)), # "ggH_1J_PTH_60_120" : Process("ggH_1J_PTH_60_120125", ggHEstimation_1J_PTH_60_120 (era, directory, tt, friend_directory=tt_friend_directory)), # "ggH_1J_PTH_120_200" : Process("ggH_1J_PTH_120_200125", ggHEstimation_1J_PTH_120_200 (era, directory, tt, friend_directory=tt_friend_directory)), # "ggH_1J_PTH_GT200" : Process("ggH_1J_PTH_GT200125", ggHEstimation_1J_PTH_GT200 (era, directory, tt, friend_directory=tt_friend_directory)), # "ggH_GE2J_PTH_0_60" : Process("ggH_GE2J_PTH_0_60125", ggHEstimation_GE2J_PTH_0_60 (era, directory, tt, friend_directory=tt_friend_directory)), # "ggH_GE2J_PTH_60_120" : Process("ggH_GE2J_PTH_60_120125", ggHEstimation_GE2J_PTH_60_120 (era, directory, tt, friend_directory=tt_friend_directory)), # "ggH_GE2J_PTH_120_200" : Process("ggH_GE2J_PTH_120_200125", ggHEstimation_GE2J_PTH_120_200(era, directory, tt, friend_directory=tt_friend_directory)), # "ggH_GE2J_PTH_GT200" : Process("ggH_GE2J_PTH_GT200125", ggHEstimation_GE2J_PTH_GT200 (era, directory, tt, friend_directory=tt_friend_directory)), # "ggH_VBFTOPO_JET3VETO" : Process("ggH_VBFTOPO_JET3VETO125", ggHEstimation_VBFTOPO_JET3VETO(era, directory, tt, friend_directory=tt_friend_directory)), # "ggH_VBFTOPO_JET3" : Process("ggH_VBFTOPO_JET3125", ggHEstimation_VBFTOPO_JET3 (era, directory, tt, friend_directory=tt_friend_directory)), # "qqH_VBFTOPO_JET3VETO" : Process("qqH_VBFTOPO_JET3VETO125", qqHEstimation_VBFTOPO_JET3VETO(era, directory, tt, friend_directory=tt_friend_directory)), # "qqH_VBFTOPO_JET3" : Process("qqH_VBFTOPO_JET3125", qqHEstimation_VBFTOPO_JET3 (era, directory, tt, friend_directory=tt_friend_directory)), # "qqH_REST" : Process("qqH_REST125", qqHEstimation_REST (era, directory, tt, friend_directory=tt_friend_directory)), # "qqH_VH2JET" : Process("qqH_VH2JET125", qqHEstimation_VH2JET (era, directory, tt, friend_directory=tt_friend_directory)), # "qqH_PTJET1_GT200" : Process("qqH_PTJET1_GT200125", qqHEstimation_PTJET1_GT200 (era, directory, tt, friend_directory=tt_friend_directory)), # "VH" : Process("VH125", VHEstimation (era, directory, tt, friend_directory=tt_friend_directory)), # "WH" : Process("WH125", WHEstimation (era, directory, tt, friend_directory=tt_friend_directory)), # "ZH" : Process("ZH125", ZHEstimation (era, directory, tt, friend_directory=tt_friend_directory)), # "ttH" : Process("ttH125", ttHEstimation (era, directory, tt, friend_directory=tt_friend_directory)), } # tt_processes["FAKES"] = Process("jetFakes", NewFakeEstimationTT(era, directory, tt, [tt_processes[process] for process in ["EMB", "ZL", "TTL", "VVL"]], tt_processes["data"], friend_directory=[tt_friend_directory, ff_friend_directory])) tt_processes["QCD"] = Process("QCD", QCDEstimation_ABCD_TT_ISO2(era, directory, tt, [tt_processes[process] for process in ["ZTT", "ZL", "ZJ", "W", "TTT", "TTJ", "TTL", "VVT", "VVJ", "VVL"]], tt_processes["data"], friend_directory=tt_friend_directory)) tt_processes["QCDEMB"] = Process("QCDEMB", QCDEstimation_ABCD_TT_ISO2(era, directory, tt, [tt_processes[process] for process in ["EMB", "ZL", "ZJ", "W", "TTJ", "TTL", "VVJ", "VVL"]], tt_processes["data"], friend_directory=tt_friend_directory)) em = EMSM2018() em_processes = { "data" : Process("data_obs", DataEstimation (era, directory, em, friend_directory=em_friend_directory)), "ZTT" : Process("ZTT", ZTTEstimation (era, directory, em, friend_directory=em_friend_directory)), "EMB" : Process("EMB", ZTTEmbeddedEstimation (era, directory, em, friend_directory=em_friend_directory)), "ZJ" : Process("ZJ", ZJEstimation (era, directory, em, friend_directory=em_friend_directory)), "ZL" : Process("ZL", ZLEstimation (era, directory, em, friend_directory=em_friend_directory)), "TTT" : Process("TTT", TTTEstimation (era, directory, em, friend_directory=em_friend_directory)), "TTJ" : Process("TTJ", TTJEstimation (era, directory, em, friend_directory=em_friend_directory)), "TTL" : Process("TTL", TTLEstimation (era, directory, em, friend_directory=em_friend_directory)), "VVT" : Process("VVT", VVTEstimation (era, directory, em, friend_directory=em_friend_directory)), "VVJ" : Process("VVJ", VVJEstimation (era, directory, em, friend_directory=em_friend_directory)), "VVL" : Process("VVL", VVLEstimation (era, directory, em, friend_directory=em_friend_directory)), "W" : Process("W", WEstimation (era, directory, em, friend_directory=em_friend_directory)), "ggH" : Process("ggH125", ggHEstimation (era, directory, em, friend_directory=em_friend_directory)), "qqH" : Process("qqH125", qqHEstimation (era, directory, em, friend_directory=em_friend_directory)) } em_processes["QCD"] = Process("QCD", QCDEstimation_SStoOS_MTETEM(era, directory, em, [em_processes[process] for process in ["ZTT", "ZL", "ZJ", "W", "TTT", "TTJ", "TTL", "VVT", "VVJ", "VVL"]], em_processes["data"], friend_directory=em_friend_directory, extrapolation_factor=1.0, qcd_weight = Weight("em_qcd_extrap_up_Weight","qcd_weight"))) em_processes["QCDEMB"] = Process("QCDEMB", QCDEstimation_SStoOS_MTETEM(era, directory, em, [em_processes[process] for process in ["EMB", "ZL", "ZJ", "W", "TTJ", "TTL", "VVJ", "VVL"]], em_processes["data"], friend_directory=em_friend_directory, extrapolation_factor=1.0, qcd_weight = Weight("em_qcd_extrap_up_Weight","qcd_weight"))) # Variables and categories binning = yaml.load(open(args.binning)) et_categories = [] # Analysis shapes if "et" in args.channels: classes_et = ["ggh", "qqh", "ztt", "zll", "w", "tt", "ss", "misc"] for i, label in enumerate(classes_et): score = Variable( "et_max_score", VariableBinning(binning["analysis"]["et"][label])) et_categories.append( Category( label, et, Cuts( Cut("et_max_index=={index}".format(index=i), "exclusive_score")), variable=score)) if label in ["ggh", "qqh"]: expression = "" for i_e, e in enumerate(binning["stxs_stage1"]["lt"][label]): offset = (binning["analysis"]["et"][label][-1]-binning["analysis"]["et"][label][0])*i_e expression += "{STXSBIN}*(et_max_score+{OFFSET})".format(STXSBIN=e, OFFSET=offset) if not e is binning["stxs_stage1"]["lt"][label][-1]: expression += " + " score_unrolled = Variable( "et_max_score_unrolled", VariableBinning(binning["analysis"]["et"][label+"_unrolled"]), expression=expression) et_categories.append( Category( "{}_unrolled".format(label), et, Cuts(Cut("et_max_index=={index}".format(index=i), "exclusive_score"), Cut("et_max_score>{}".format(1.0/len(classes_et)), "protect_unrolling")), variable=score_unrolled)) # Goodness of fit shapes elif args.gof_channel == "et": score = Variable( args.gof_variable, VariableBinning(binning["gof"]["et"][args.gof_variable]["bins"]), expression=binning["gof"]["et"][args.gof_variable]["expression"]) if "cut" in binning["gof"]["et"][args.gof_variable].keys(): cuts=Cuts(Cut(binning["gof"]["et"][args.gof_variable]["cut"], "binning")) else: cuts=Cuts() et_categories.append( Category( args.gof_variable, et, cuts, variable=score)) mt_categories = [] # Analysis shapes if "mt" in args.channels: classes_mt = ["ggh", "qqh", "ztt", "zll", "w", "tt", "ss", "misc"] for i, label in enumerate(classes_mt): score = Variable( "mt_max_score", VariableBinning(binning["analysis"]["mt"][label])) mt_categories.append( Category( label, mt, Cuts( Cut("mt_max_index=={index}".format(index=i), "exclusive_score")), variable=score)) if label in ["ggh", "qqh"]: expression = "" for i_e, e in enumerate(binning["stxs_stage1"]["lt"][label]): offset = (binning["analysis"]["mt"][label][-1]-binning["analysis"]["mt"][label][0])*i_e expression += "{STXSBIN}*(mt_max_score+{OFFSET})".format(STXSBIN=e, OFFSET=offset) if not e is binning["stxs_stage1"]["lt"][label][-1]: expression += " + " score_unrolled = Variable( "mt_max_score_unrolled", VariableBinning(binning["analysis"]["mt"][label+"_unrolled"]), expression=expression) mt_categories.append( Category( "{}_unrolled".format(label), mt, Cuts(Cut("mt_max_index=={index}".format(index=i), "exclusive_score"), Cut("mt_max_score>{}".format(1.0/len(classes_mt)), "protect_unrolling")), variable=score_unrolled)) # Goodness of fit shapes elif args.gof_channel == "mt": score = Variable( args.gof_variable, VariableBinning(binning["gof"]["mt"][args.gof_variable]["bins"]), expression=binning["gof"]["mt"][args.gof_variable]["expression"]) if "cut" in binning["gof"]["mt"][args.gof_variable].keys(): cuts=Cuts(Cut(binning["gof"]["mt"][args.gof_variable]["cut"], "binning")) else: cuts=Cuts() mt_categories.append( Category( args.gof_variable, mt, cuts, variable=score)) tt_categories = [] # Analysis shapes if "tt" in args.channels: classes_tt = ["ggh", "qqh", "ztt", "noniso", "misc"] for i, label in enumerate(classes_tt): score = Variable( "tt_max_score", VariableBinning(binning["analysis"]["tt"][label])) tt_categories.append( Category( label, tt, Cuts( Cut("tt_max_index=={index}".format(index=i), "exclusive_score")), variable=score)) if label in ["ggh", "qqh"]: expression = "" for i_e, e in enumerate(binning["stxs_stage1"]["tt"][label]): offset = (binning["analysis"]["tt"][label][-1]-binning["analysis"]["tt"][label][0])*i_e expression += "{STXSBIN}*(tt_max_score+{OFFSET})".format(STXSBIN=e, OFFSET=offset) if not e is binning["stxs_stage1"]["tt"][label][-1]: expression += " + " score_unrolled = Variable( "tt_max_score_unrolled", VariableBinning(binning["analysis"]["tt"][label+"_unrolled"]), expression=expression) tt_categories.append( Category( "{}_unrolled".format(label), tt, Cuts(Cut("tt_max_index=={index}".format(index=i), "exclusive_score"), Cut("tt_max_score>{}".format(1.0/len(classes_tt)), "protect_unrolling")), variable=score_unrolled)) # Goodness of fit shapes elif args.gof_channel == "tt": score = Variable( args.gof_variable, VariableBinning(binning["gof"]["tt"][args.gof_variable]["bins"]), expression=binning["gof"]["tt"][args.gof_variable]["expression"]) if "cut" in binning["gof"]["tt"][args.gof_variable].keys(): cuts=Cuts(Cut(binning["gof"]["tt"][args.gof_variable]["cut"], "binning")) else: cuts=Cuts() tt_categories.append( Category( args.gof_variable, tt, cuts, variable=score)) em_categories = [] # Analysis shapes if "em" in args.channels: classes_em = ["ggh", "qqh", "ztt", "zll", "w", "tt", "ss", "misc"] for i, label in enumerate(classes_em): score = Variable( "em_max_score", VariableBinning(binning["analysis"]["em"][label])) em_categories.append( Category( label, em, Cuts( Cut("em_max_index=={index}".format(index=i), "exclusive_score")), variable=score)) if label in ["ggh", "qqh"]: expression = "" for i_e, e in enumerate(binning["stxs_stage1"]["lt"][label]): offsem = (binning["analysis"]["em"][label][-1]-binning["analysis"]["em"][label][0])*i_e expression += "{STXSBIN}*(em_max_score+{OFFSem})".format(STXSBIN=e, OFFSem=offsem) if not e is binning["stxs_stage1"]["lt"][label][-1]: expression += " + " score_unrolled = Variable( "em_max_score_unrolled", VariableBinning(binning["analysis"]["em"][label+"_unrolled"]), expression=expression) em_categories.append( Category( "{}_unrolled".format(label), em, Cuts(Cut("em_max_index=={index}".format(index=i), "exclusive_score"), Cut("em_max_score>{}".format(1.0/len(classes_em)), "protect_unrolling")), variable=score_unrolled)) # Goodness of fit shapes elif args.gof_channel == "em": score = Variable( args.gof_variable, VariableBinning(binning["gof"]["em"][args.gof_variable]["bins"]), expression=binning["gof"]["em"][args.gof_variable]["expression"]) if "cut" in binning["gof"]["em"][args.gof_variable].keys(): cuts=Cuts(Cut(binning["gof"]["em"][args.gof_variable]["cut"], "binning")) else: cuts=Cuts() em_categories.append( Category( args.gof_variable, em, cuts, variable=score)) # Nominal histograms if args.gof_channel == None: signal_nicks = [ "ggH", "qqH", "qqH_VBFTOPO_JET3VETO", "qqH_VBFTOPO_JET3", "qqH_REST", "qqH_PTJET1_GT200", "qqH_VH2JET", "ggH_0J", "ggH_1J_PTH_0_60", "ggH_1J_PTH_60_120", "ggH_1J_PTH_120_200", "ggH_1J_PTH_GT200", "ggH_GE2J_PTH_0_60", "ggH_GE2J_PTH_60_120", "ggH_GE2J_PTH_120_200", "ggH_GE2J_PTH_GT200", "ggH_VBFTOPO_JET3VETO", "ggH_VBFTOPO_JET3", "VH", "WH", "ZH", "ttH" ] else: signal_nicks = ["ggH", "qqH", "WH", "ZH", "ttH"] # yapf: enable if "et" in [args.gof_channel] + args.channels: for process, category in product(et_processes.values(), et_categories): systematics.add( Systematic(category=category, process=process, analysis="smhtt", era=era, variation=Nominal(), mass="125")) if "mt" in [args.gof_channel] + args.channels: for process, category in product(mt_processes.values(), mt_categories): systematics.add( Systematic(category=category, process=process, analysis="smhtt", era=era, variation=Nominal(), mass="125")) if "tt" in [args.gof_channel] + args.channels: for process, category in product(tt_processes.values(), tt_categories): systematics.add( Systematic(category=category, process=process, analysis="smhtt", era=era, variation=Nominal(), mass="125")) if "em" in [args.gof_channel] + args.channels: for process, category in product(em_processes.values(), em_categories): systematics.add( Systematic(category=category, process=process, analysis="smhtt", era=era, variation=Nominal(), mass="125")) # Produce histograms logger.info("Start producing shapes.") systematics.produce() logger.info("Done producing shapes.")
def main(args): # Container for all distributions to be drawn systematics = Systematics("impact_parameter_shapes.root", num_threads=args.num_threads) # Era era = Run2016(args.datasets) # Channels and processes # yapf: disable directory = args.directory ee = EESM() ee_processes = { "data" : Process("data_obs", DataEstimation (era, directory, ee, friend_directory=args.friend_directory)), "HTT" : Process("HTT", HTTEstimation (era, directory, ee, friend_directory=args.friend_directory)), "ggH" : Process("ggH", ggHEstimation (era, directory, ee, friend_directory=args.friend_directory)), "qqH" : Process("qqH", qqHEstimation (era, directory, ee, friend_directory=args.friend_directory)), "VH" : Process("VH", VHEstimation (era, directory, ee, friend_directory=args.friend_directory)), "ZTT" : Process("ZTT", ZTTEstimationLL (era, directory, ee, friend_directory=args.friend_directory)), "ZL" : Process("ZL", ZLEstimationLL (era, directory, ee, friend_directory=args.friend_directory)), "ZJ" : Process("ZJ", ZJEstimationLL (era, directory, ee, friend_directory=args.friend_directory)), "W" : Process("W", WEstimation (era, directory, ee, friend_directory=args.friend_directory)), "TT" : Process("TT", TTEstimation (era, directory, ee, friend_directory=args.friend_directory)), "VV" : Process("VV", VVEstimation (era, directory, ee, friend_directory=args.friend_directory)), "EWK" : Process("EWK", EWKEstimation (era, directory, ee, friend_directory=args.friend_directory)) } ee_processes["QCD"] = Process("QCD", QCDEstimationET(era, directory, ee, [ee_processes[process] for process in ["ZTT", "ZJ", "ZL", "W", "TT", "VV", "EWK"]], ee_processes["data"], extrapolation_factor=1.0)) ee_processes["MC"] = Process("MC", SumUpEstimationMethod("MC", "nominal", era, directory, ee, [ee_processes[process] for process in ["ZTT", "ZJ", "ZL", "W", "TT", "VV", "EWK", "QCD", "HTT"]])) em = EMSM() em.cuts.remove("ele_iso") em.cuts.remove("muon_iso") #em.cuts.remove("diLepMetMt") #em.cuts.get("pzeta").invert() em_processes = { "data" : Process("data_obs", DataEstimation (era, directory, em, friend_directory=args.friend_directory)), "HTT" : Process("HTT", HTTEstimation (era, directory, em, friend_directory=args.friend_directory)), "ggH" : Process("ggH", ggHEstimation (era, directory, em, friend_directory=args.friend_directory)), "qqH" : Process("qqH", qqHEstimation (era, directory, em, friend_directory=args.friend_directory)), "VH" : Process("VH", VHEstimation (era, directory, em, friend_directory=args.friend_directory)), "ZTT" : Process("ZTT", ZTTEstimationLL (era, directory, em, friend_directory=args.friend_directory)), "ZL" : Process("ZL", ZLEstimationLL (era, directory, em, friend_directory=args.friend_directory)), "ZJ" : Process("ZJ", ZJEstimationLL (era, directory, em, friend_directory=args.friend_directory)), "W" : Process("W", WEstimation (era, directory, em, friend_directory=args.friend_directory)), "TT" : Process("TT", TTEstimation (era, directory, em, friend_directory=args.friend_directory)), "VV" : Process("VV", VVEstimation (era, directory, em, friend_directory=args.friend_directory)), "EWK" : Process("EWK", EWKEstimation (era, directory, em, friend_directory=args.friend_directory)) } em_processes["QCD"] = Process("QCD", QCDEstimationMT(era, directory, em, [em_processes[process] for process in ["ZTT", "ZJ", "ZL", "W", "TT", "VV", "EWK"]], em_processes["data"], extrapolation_factor=1.0)) em_processes["MC"] = Process("MC", SumUpEstimationMethod("MC", "nominal", era, directory, em, [em_processes[process] for process in ["ZTT", "ZJ", "ZL", "W", "TT", "VV", "EWK", "QCD", "HTT"]])) mm = MMSM() mm_processes = { "data" : Process("data_obs", DataEstimation (era, directory, mm, friend_directory=args.friend_directory)), "HTT" : Process("HTT", HTTEstimation (era, directory, mm, friend_directory=args.friend_directory)), "ggH" : Process("ggH", ggHEstimation (era, directory, mm, friend_directory=args.friend_directory)), "qqH" : Process("qqH", qqHEstimation (era, directory, mm, friend_directory=args.friend_directory)), "VH" : Process("VH", VHEstimation (era, directory, mm, friend_directory=args.friend_directory)), "ZTT" : Process("ZTT", ZTTEstimationLL (era, directory, mm, friend_directory=args.friend_directory)), "ZL" : Process("ZL", ZLEstimationLL (era, directory, mm, friend_directory=args.friend_directory)), "ZJ" : Process("ZJ", ZJEstimationLL (era, directory, mm, friend_directory=args.friend_directory)), "W" : Process("W", WEstimation (era, directory, mm, friend_directory=args.friend_directory)), "TT" : Process("TT", TTEstimation (era, directory, mm, friend_directory=args.friend_directory)), "VV" : Process("VV", VVEstimation (era, directory, mm, friend_directory=args.friend_directory)), "EWK" : Process("EWK", EWKEstimation (era, directory, mm, friend_directory=args.friend_directory)) } mm_processes["QCD"] = Process("QCD", QCDEstimationMT(era, directory, mm, [mm_processes[process] for process in ["ZTT", "ZJ", "ZL", "W", "TT", "VV", "EWK"]], mm_processes["data"], extrapolation_factor=1.0)) mm_processes["MC"] = Process("MC", SumUpEstimationMethod("MC", "nominal", era, directory, mm, [mm_processes[process] for process in ["ZTT", "ZJ", "ZL", "W", "TT", "VV", "EWK", "QCD", "HTT"]])) mt = MTSM() mt.cuts.remove("muon_iso") mt.cuts.remove("tau_iso") mt.cuts.remove("m_t") mt_processes = { "data" : Process("data_obs", DataEstimation (era, directory, mt, friend_directory=args.friend_directory)), "HTT" : Process("HTT", HTTEstimation (era, directory, mt, friend_directory=args.friend_directory)), "ggH" : Process("ggH", ggHEstimation (era, directory, mt, friend_directory=args.friend_directory)), "qqH" : Process("qqH", qqHEstimation (era, directory, mt, friend_directory=args.friend_directory)), "VH" : Process("VH", VHEstimation (era, directory, mt, friend_directory=args.friend_directory)), "ZTT" : Process("ZTT", ZTTEstimation (era, directory, mt, friend_directory=args.friend_directory)), "ZL" : Process("ZL", ZLEstimationMTSM(era, directory, mt, friend_directory=args.friend_directory)), "ZJ" : Process("ZJ", ZJEstimationMT (era, directory, mt, friend_directory=args.friend_directory)), "WT" : Process("WT", WTEstimation (era, directory, mt, friend_directory=args.friend_directory)), "WL" : Process("WL", WLEstimation (era, directory, mt, friend_directory=args.friend_directory)), "TTT" : Process("TTT", TTTEstimationMT (era, directory, mt, friend_directory=args.friend_directory)), "TTJ" : Process("TTJ", TTJEstimationMT (era, directory, mt, friend_directory=args.friend_directory)), "VV" : Process("VV", VVEstimation (era, directory, mt, friend_directory=args.friend_directory)), "EWK" : Process("EWK", EWKEstimation (era, directory, mt, friend_directory=args.friend_directory)) } mt_processes["QCD"] = Process("QCD", QCDEstimationMT(era, directory, mt, [mt_processes[process] for process in ["ZTT", "ZJ", "ZL", "WT", "WL", "TTT", "TTJ", "VV", "EWK"]], mt_processes["data"], extrapolation_factor=1.17)) mt_processes["MC"] = Process("MC", SumUpEstimationMethod("MC", "nominal", era, directory, mt, [mt_processes[process] for process in ["ZTT", "ZJ", "ZL", "WT", "WL", "TTT", "TTJ", "VV", "EWK", "QCD", "HTT"]])) et = ETSM() et.cuts.remove("ele_iso") et.cuts.remove("tau_iso") et_processes = { "data" : Process("data_obs", DataEstimation (era, directory, et, friend_directory=args.friend_directory)), "HTT" : Process("HTT", HTTEstimation (era, directory, et, friend_directory=args.friend_directory)), "ggH" : Process("ggH", ggHEstimation (era, directory, et, friend_directory=args.friend_directory)), "qqH" : Process("qqH", qqHEstimation (era, directory, et, friend_directory=args.friend_directory)), "VH" : Process("VH", VHEstimation (era, directory, et, friend_directory=args.friend_directory)), "ZTT" : Process("ZTT", ZTTEstimation (era, directory, et, friend_directory=args.friend_directory)), "ZL" : Process("ZL", ZLEstimationETSM(era, directory, et, friend_directory=args.friend_directory)), "ZJ" : Process("ZJ", ZJEstimationET (era, directory, et, friend_directory=args.friend_directory)), "WT" : Process("WT", WTEstimation (era, directory, et, friend_directory=args.friend_directory)), "WL" : Process("WL", WLEstimation (era, directory, et, friend_directory=args.friend_directory)), "TTT" : Process("TTT", TTTEstimationET (era, directory, et, friend_directory=args.friend_directory)), "TTJ" : Process("TTJ", TTJEstimationET (era, directory, et, friend_directory=args.friend_directory)), "VV" : Process("VV", VVEstimation (era, directory, et, friend_directory=args.friend_directory)), "EWK" : Process("EWK", EWKEstimation (era, directory, et, friend_directory=args.friend_directory)) } et_processes["QCD"] = Process("QCD", QCDEstimationET(era, directory, et, [et_processes[process] for process in ["ZTT", "ZJ", "ZL", "WT", "WL", "TTT", "TTJ", "VV", "EWK"]], et_processes["data"], extrapolation_factor=1.16)) et_processes["MC"] = Process("MC", SumUpEstimationMethod("MC", "nominal", era, directory, et, [et_processes[process] for process in ["ZTT", "ZJ", "ZL", "WT", "WL", "TTT", "TTJ", "VV", "EWK", "QCD", "HTT"]])) tt = TTSM() tt.cuts.remove("tau_1_iso") #tt.cuts.remove("tau_2_iso") tt_processes = { "data" : Process("data_obs", DataEstimation (era, directory, tt, friend_directory=args.friend_directory)), "HTT" : Process("HTT", HTTEstimation (era, directory, tt, friend_directory=args.friend_directory)), "ggH" : Process("ggH", ggHEstimation (era, directory, tt, friend_directory=args.friend_directory)), "qqH" : Process("qqH", qqHEstimation (era, directory, tt, friend_directory=args.friend_directory)), "VH" : Process("VH", VHEstimation (era, directory, tt, friend_directory=args.friend_directory)), "ZTT" : Process("ZTT", ZTTEstimationTT(era, directory, tt, friend_directory=args.friend_directory)), "ZL" : Process("ZL", ZLEstimationTT (era, directory, tt, friend_directory=args.friend_directory)), "ZJ" : Process("ZJ", ZJEstimationTT (era, directory, tt, friend_directory=args.friend_directory)), "W" : Process("W", WEstimation (era, directory, tt, friend_directory=args.friend_directory)), "TTT" : Process("TTT", TTTEstimationTT(era, directory, tt, friend_directory=args.friend_directory)), "TTJ" : Process("TTJ", TTJEstimationTT(era, directory, tt, friend_directory=args.friend_directory)), "VV" : Process("VV", VVEstimation (era, directory, tt, friend_directory=args.friend_directory)), "EWK" : Process("EWK", EWKEstimation (era, directory, tt, friend_directory=args.friend_directory)) } tt_processes["QCD"] = Process("QCD", QCDEstimationTT(era, directory, tt, [tt_processes[process] for process in ["ZTT", "ZJ", "ZL", "W", "TTT", "TTJ", "VV", "EWK"]], tt_processes["data"])) tt_processes["MC"] = Process("MC", SumUpEstimationMethod("MC", "nominal", era, directory, tt, [tt_processes[process] for process in ["ZTT", "ZJ", "ZL", "W", "TTT", "TTJ", "VV", "EWK", "QCD", "HTT"]])) # Variables and categories #binning_ll_0 = [-0.1, -0.08, -0.06, -0.04, -0.02, -0.015, -0.01, -0.008, -0.006, -0.004, -0.003, -0.002, -0.001, 0.0, 0.001, 0.002, 0.003, 0.004, 0.006, 0.008, 0.01, 0.015, 0.02, 0.04, 0.06, 0.08, 0.1] #binning_ll_Z = [-0.15, -0.1, -0.08, -0.06, -0.04, -0.02, -0.015, -0.01, -0.008, -0.006, -0.004, -0.003, -0.002, -0.001, 0.0, 0.001, 0.002, 0.003, 0.004, 0.006, 0.008, 0.01, 0.015, 0.02, 0.04, 0.06, 0.08, 0.1, 0.15] #binning_ll_0_raw = [-0.05, -0.04, -0.03, -0.02, -0.015, -0.0125, -0.01, -0.009, -0.008, -0.007, -0.006, -0.005, -0.0045, -0.004, -0.0035, -0.003, -0.0025, -0.002, -0.0015, -0.001, -0.0006, -0.0003, 0.0, 0.0003, 0.0006, 0.001, 0.0015, 0.002, 0.0025, 0.003, 0.0035, 0.004, 0.0045, 0.005, 0.006, 0.007, 0.008, 0.009, 0.01, 0.0125, 0.015, 0.02, 0.03, 0.04, 0.05] binning_ll_Z_raw = [0.0001, 0.0002, 0.0003, 0.0004, 0.0005, 0.0006, 0.0007, 0.0008, 0.001, 0.00125, 0.0015, 0.00175, 0.002, 0.00225, 0.0025, 0.00275, 0.003, 0.00325, 0.0035, 0.00375, 0.004, 0.0045, 0.005, 0.0055, 0.006, 0.0065, 0.007, 0.0075, 0.008, 0.0085, 0.009, 0.0095, 0.01, 0.011, 0.012, 0.013, 0.014, 0.015, 0.016, 0.018, 0.02, 0.0225, 0.025, 0.0275, 0.03, 0.035, 0.04, 0.05, 0.06, 0.07, 0.08, 0.09, 0.1, 0.11, 0.12, 0.13, 0.15, 0.2] binning_ll_0_raw = [0.0001, 0.0002, 0.0003, 0.0004, 0.0005, 0.0006, 0.0007, 0.0008, 0.001, 0.00125, 0.0015, 0.00175, 0.002, 0.00225, 0.0025, 0.00275, 0.003, 0.00325, 0.0035, 0.00375, 0.004, 0.00425, 0.0045, 0.00475, 0.005, 0.0055, 0.006, 0.0065, 0.007, 0.0075, 0.008, 0.0085, 0.009, 0.0095, 0.01, 0.012, 0.014, 0.017, 0.02, 0.025, 0.03, 0.035, 0.04, 0.045] binning_ll_Zerr_raw = [0.05, 0.1, 0.15, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5, 0.55, 0.6, 0.65, 0.7, 0.75, 0.8, 0.85, 0.9, 0.95, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.8, 2.0, 2.25, 2.5, 2.75, 3.0, 3.25, 3.5, 3.75, 4.0, 4.25, 4.5, 4.75, 5.0, 5.5, 6.0, 7.0, 8.0, 9.0, 10.0, 12.0, 15.0, 20.0, 30.0, 45.0, 70.0, 100.0, 150.0] binning_ll_0err_raw = [0.05, 0.1, 0.15, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5, 0.55, 0.6, 0.65, 0.7, 0.75, 0.8, 0.85, 0.9, 0.95, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.8, 2.0, 2.25, 2.5, 2.75, 3.0, 3.5, 4.0, 4.5, 5.0, 5.5, 6.0, 7.0, 8.0, 9.0, 10.0, 12.0, 15.0, 20.0, 30.0] binning_et_Z_raw = [0.001, 0.004, 0.01, 0.02, 0.04, 0.2] binning_et_0_raw = [0.0005, 0.002, 0.005, 0.045] binning_mt_Z_raw = [0.0003, 0.0006, 0.001, 0.0015, 0.00225, 0.003, 0.004, 0.0055, 0.0075, 0.01, 0.015, 0.02, 0.04, 0.2] binning_mt_0_raw = [0.0001, 0.0003, 0.0006, 0.001, 0.00175, 0.0025, 0.005, 0.01, 0.045] binning_em_Z_raw = [0.0003, 0.0006, 0.001, 0.0015, 0.00225, 0.003, 0.004, 0.0055, 0.0075, 0.01, 0.015, 0.02, 0.04, 0.08, 0.15, 0.2] # 0.08, 0.14 are only to keep splines in good region binning_em_0_raw = [0.0001, 0.0003, 0.0006, 0.001, 0.00175, 0.0025, 0.005, 0.01, 0.02, 0.032, 0.045] #0.02, 0.032 are only to keep splines in good region binning_ll_0 = [] for i in range(len(binning_ll_0_raw)): binning_ll_0.append(-1*binning_ll_0_raw[-i-1]) binning_ll_0 += [0.0] + binning_ll_0_raw binning_ll_Z = [] for i in range(len(binning_ll_Z_raw)): binning_ll_Z.append(-1*binning_ll_Z_raw[-i-1]) binning_ll_Z += [0.0] + binning_ll_Z_raw binning_ll_0err = [] for i in range(len(binning_ll_0err_raw)): binning_ll_0err.append(-1*binning_ll_0err_raw[-i-1]) binning_ll_0err += [0.0] + binning_ll_0err_raw binning_ll_Zerr = [] for i in range(len(binning_ll_Zerr_raw)): binning_ll_Zerr.append(-1*binning_ll_Zerr_raw[-i-1]) binning_ll_Zerr += [0.0] + binning_ll_Zerr_raw binning_et_0 = [] for i in range(len(binning_et_0_raw)): binning_et_0.append(-1*binning_et_0_raw[-i-1]) binning_et_0 += binning_et_0_raw binning_et_Z = [] for i in range(len(binning_et_Z_raw)): binning_et_Z.append(-1*binning_et_Z_raw[-i-1]) binning_et_Z += binning_et_Z_raw binning_et_0err = [] binning_mt_0 = [] for i in range(len(binning_mt_0_raw)): binning_mt_0.append(-1*binning_mt_0_raw[-i-1]) binning_mt_0 += binning_mt_0_raw binning_mt_Z = [] for i in range(len(binning_mt_Z_raw)): binning_mt_Z.append(-1*binning_mt_Z_raw[-i-1]) binning_mt_Z += [0.0] + binning_mt_Z_raw binning_mt_0err = [] binning_em_0 = [] for i in range(len(binning_em_0_raw)): binning_em_0.append(-1*binning_em_0_raw[-i-1]) binning_em_0 += binning_em_0_raw binning_em_Z = [] for i in range(len(binning_em_Z_raw)): binning_em_Z.append(-1*binning_em_Z_raw[-i-1]) binning_em_Z += [0.0] + binning_em_Z_raw binning_em_0err = [] binning_tau = [-0.1, -0.08, -0.06, -0.04, -0.02, -0.015, -0.01, -0.008, -0.006, -0.004, -0.002, 0.0, 0.002, 0.004, 0.006, 0.008, 0.01, 0.015, 0.02, 0.04, 0.06, 0.08, 0.1] d0_1 = Variable("d0_1", VariableBinning(binning_ll_0)) d0_1_calib = Variable("d0_1_calib", VariableBinning(binning_ll_0)) d0_1_calib_all = Variable("d0_1_calib_all", VariableBinning(binning_ll_0)) d0_te = Variable("d0_1", VariableBinning(binning_mt_0)) d0_te_calib = Variable("d0_1_calib", VariableBinning(binning_mt_0)) d0_te_calib_all = Variable("d0_1_calib_all", VariableBinning(binning_mt_0)) d0_tm = Variable("d0_1", VariableBinning(binning_mt_0)) d0_tm_calib = Variable("d0_1_calib", VariableBinning(binning_mt_0)) d0_tm_calib_all = Variable("d0_1_calib_all", VariableBinning(binning_mt_0)) #d0_1 = Variable("m_vis", VariableBinning([50.+x*5. for x in range(21)])) d0_2 = Variable("d0_2", VariableBinning(binning_tau)) #d0_2 = Variable("m_vis", VariableBinning([50.+x*5. for x in range(21)])) dZ_1 = Variable("dZ_1", VariableBinning(binning_ll_Z)) dZ_1_calib = Variable("dZ_1_calib", VariableBinning(binning_ll_Z)) dZ_1_calib_all = Variable("dZ_1_calib_all", VariableBinning(binning_ll_Z)) dZ_te = Variable("dZ_1", VariableBinning(binning_mt_Z)) dZ_te_calib = Variable("dZ_1_calib", VariableBinning(binning_mt_Z)) dZ_te_calib_all = Variable("dZ_1_calib_all", VariableBinning(binning_mt_Z)) dZ_tm = Variable("dZ_1", VariableBinning(binning_mt_Z)) dZ_tm_calib = Variable("dZ_1_calib", VariableBinning(binning_mt_Z)) dZ_tm_calib_all = Variable("dZ_1_calib_all", VariableBinning(binning_mt_Z)) dZ_2 = Variable("dZ_2", VariableBinning(binning_tau)) DCA0_1 = Variable("DCA0_1", VariableBinning(binning_ll_0err), "d0_1/lep1ErrD0") DCAZ_1 = Variable("DCAZ_1", VariableBinning(binning_ll_Zerr), "dZ_1/lep1ErrDz") DCA0_2 = Variable("DCA0_2", VariableBinning(binning_ll_0err), "d0_2/lep2ErrD0") DCAZ_2 = Variable("DCAZ_2", VariableBinning(binning_ll_Zerr), "dZ_2/lep2ErrDz") d0_em_te = Variable("d0_1", VariableBinning(binning_em_0)) d0_em_te_calib_all = Variable("d0_1_calib_all", VariableBinning(binning_em_0)) d0_em_tm = Variable("d0_2", VariableBinning(binning_em_0)) d0_em_tm_calib_all = Variable("d0_2_calib_all", VariableBinning(binning_em_0)) dZ_em_te = Variable("dZ_1", VariableBinning(binning_em_Z)) dZ_em_te_calib_all = Variable("dZ_1_calib_all", VariableBinning(binning_em_Z)) dZ_em_tm = Variable("dZ_2", VariableBinning(binning_em_Z)) dZ_em_tm_calib_all = Variable("dZ_2_calib_all", VariableBinning(binning_em_Z)) m_vis = Variable("m_vis", VariableBinning([50.+x*5. for x in range(21)])) mT_1 = Variable("mt_1", VariableBinning([0.+x*5. for x in range(41)])) mT_2 = Variable("mt_2", VariableBinning([0.+x*5. for x in range(41)])) met = Variable("met", VariableBinning([0.+x*5. for x in range(41)])) ee_categories = [] if "ee" in args.channels: ee_categories.append( Category( "m_vis", ee, Cuts(), variable=m_vis)) ee_categories.append( Category( "d0_e", ee, Cuts( Cut("m_vis>80 && m_vis<100", "Zpeak") ), variable=d0_1)) ee_categories.append( Category( "dZ_e", ee, Cuts( Cut("m_vis>80 && m_vis<100", "Zpeak") ), variable=dZ_1)) ee_categories.append( Category( "DCA0_e", ee, Cuts( Cut("m_vis>80 && m_vis<100", "Zpeak") ), variable=DCA0_1)) ee_categories.append( Category( "DCAZ_e", ee, Cuts( Cut("m_vis>80 && m_vis<100", "Zpeak") ), variable=DCAZ_1)) #calibrated '''ee_categories.append( Category( "d0_e", ee, Cuts( Cut("m_vis>80 && m_vis<100", "Zpeak") ), variable=d0_1_calib)) ee_categories.append( Category( "dZ_e", ee, Cuts( Cut("m_vis>80 && m_vis<100", "Zpeak") ), variable=dZ_1_calib)) ee_categories.append( Category( "d0_e", ee, Cuts( Cut("m_vis>80 && m_vis<100", "Zpeak") ), variable=d0_1_calib_all)) ee_categories.append( Category( "dZ_e", ee, Cuts( Cut("m_vis>80 && m_vis<100", "Zpeak") ), variable=dZ_1_calib_all)) ''' em_categories = [] if "em" in args.channels: '''em_categories.append( Category( "m_vis_te", em, Cuts( Cut("iso_1<0.1", "ele_iso"), Cut("iso_2>0.15&&iso_2<0.25", "muon_antiiso")), #Cut("pZetaMissVis<-50.", "pzetatight")), variable=m_vis)) em_categories.append( Category( "m_vis_tm", em, Cuts( Cut("iso_1>0.1&&iso_1<0.2", "ele_antiiso"), Cut("iso_2<0.15", "muon_iso")), variable=m_vis))''' em_categories.append( Category( "d0_em_te", em, Cuts( Cut("iso_1<0.15", "ele_iso"), Cut("iso_2<0.2", "muon_iso"), Cut("m_vis<80", "Zpeak")), variable=d0_em_te)) em_categories.append( Category( "d0_em_tm", em, Cuts( Cut("iso_1<0.15", "ele_iso"), Cut("iso_2<0.2", "muon_iso"), Cut("m_vis<80", "Zpeak")), variable=d0_em_tm)) em_categories.append( Category( "dZ_em_te", em, Cuts( Cut("iso_1<0.15", "ele_iso"), Cut("iso_2<0.2", "muon_iso"), Cut("m_vis<80", "Zpeak")), variable=dZ_em_te)) em_categories.append( Category( "dZ_em_tm", em, Cuts( Cut("iso_1<0.15", "ele_iso"), Cut("iso_2<0.2", "muon_iso"), Cut("m_vis<80", "Zpeak")), variable=dZ_em_tm)) #calibrated '''em_categories.append( Category( "d0_em_te", em, Cuts( Cut("iso_1<0.15", "ele_iso"), Cut("iso_2<0.2", "muon_iso"), Cut("m_vis<80", "Zpeak")), variable=d0_em_te_calib_all)) em_categories.append( Category( "d0_em_tm", em, Cuts( Cut("iso_1<0.15", "ele_iso"), Cut("iso_2<0.2", "muon_iso"), Cut("m_vis<80", "Zpeak")), variable=d0_em_tm_calib_all)) em_categories.append( Category( "dZ_em_te", em, Cuts( Cut("iso_1<0.15", "ele_iso"), Cut("iso_2<0.2", "muon_iso"), Cut("m_vis<80", "Zpeak")), variable=dZ_em_te_calib_all)) em_categories.append( Category( "dZ_em_tm", em, Cuts( Cut("iso_1<0.15", "ele_iso"), Cut("iso_2<0.2", "muon_iso"), Cut("m_vis<80", "Zpeak")), variable=dZ_em_tm_calib_all)) ''' mm_categories = [] if "mm" in args.channels: mm_categories.append( Category( "m_vis", mm, Cuts(), variable=m_vis)) mm_categories.append( Category( "d0_m", mm, Cuts( Cut("m_vis>80 && m_vis<100", "Zpeak") ), variable=d0_1)) mm_categories.append( Category( "dZ_m", mm, Cuts( Cut("m_vis>80 && m_vis<100", "Zpeak") ), variable=dZ_1)) mm_categories.append( Category( "DCA0_m", mm, Cuts( Cut("m_vis>80 && m_vis<100", "Zpeak") ), variable=DCA0_1)) mm_categories.append( Category( "DCAZ_m", mm, Cuts( Cut("m_vis>80 && m_vis<100", "Zpeak") ), variable=DCAZ_1)) #calibrated '''mm_categories.append( Category( "d0_m", mm, Cuts( Cut("m_vis>80 && m_vis<100", "Zpeak") ), variable=d0_1_calib)) mm_categories.append( Category( "dZ_m", mm, Cuts( Cut("m_vis>80 && m_vis<100", "Zpeak") ), variable=dZ_1_calib)) mm_categories.append( Category( "d0_m", mm, Cuts( Cut("m_vis>80 && m_vis<100", "Zpeak") ), variable=d0_1_calib_all)) mm_categories.append( Category( "dZ_m", mm, Cuts( Cut("m_vis>80 && m_vis<100", "Zpeak") ), variable=dZ_1_calib_all)) ''' et_categories = [] if "et" in args.channels: et_categories.append( Category( "d0_te", et, Cuts( Cut("iso_1<0.1", "ele_iso"), Cut("byTightIsolationMVArun2v1DBoldDMwLT_2>0.5", "tau_iso")), variable=d0_te)) et_categories.append( Category( "dZ_te", et, Cuts( Cut("iso_1<0.1", "ele_iso"), Cut("byTightIsolationMVArun2v1DBoldDMwLT_2>0.5", "tau_iso")), variable=dZ_te)) et_categories.append( Category( "d0_te", et, Cuts( Cut("iso_1<0.1", "ele_iso"), Cut("byTightIsolationMVArun2v1DBoldDMwLT_2>0.5", "tau_iso")), variable=d0_te_calib)) et_categories.append( Category( "dZ_te", et, Cuts( Cut("iso_1<0.1", "ele_iso"), Cut("byTightIsolationMVArun2v1DBoldDMwLT_2>0.5", "tau_iso")), variable=dZ_te_calib)) ''' et_categories.append( Category( "m_vis", et, Cuts( #Cut("m_vis>60 && m_vis<75", "Zpeak"), Cut("nbtag==0", "bveto"), Cut("iso_1<0.1", "ele_iso"), Cut("mt_2<100", "tau_mt"), Cut("abs(eta_2)<1.0", "tau_eta"), Cut("byTightIsolationMVArun2v1DBoldDMwLT_2<0.5 && byMediumIsolationMVArun2v1DBoldDMwLT_2>0.5", "tau_antiiso")), variable=m_vis)) et_categories.append( Category( "d0_te", et, Cuts( Cut("m_vis>60 && m_vis<75", "Zpeak"), Cut("nbtag==0", "bveto"), Cut("iso_1<0.1", "ele_iso"), Cut("mt_2<100", "tau_mt"), Cut("abs(eta_2)<1.0", "tau_eta"), Cut("byTightIsolationMVArun2v1DBoldDMwLT_2<0.5 && byMediumIsolationMVArun2v1DBoldDMwLT_2>0.5", "tau_antiiso")), variable=d0_te)) et_categories.append( Category( "dZ_te", et, Cuts( Cut("m_vis>60 && m_vis<75", "Zpeak"), Cut("nbtag==0", "bveto"), Cut("iso_1<0.1", "ele_iso"), Cut("mt_2<100", "tau_mt"), Cut("abs(eta_2)<1.0", "tau_eta"), Cut("byTightIsolationMVArun2v1DBoldDMwLT_2<0.5 && byMediumIsolationMVArun2v1DBoldDMwLT_2>0.5", "tau_antiiso")), variable=dZ_te)) et_categories.append( Category( "d0_t", et, Cuts( Cut("m_vis>60 && m_vis<75", "Zpeak"), Cut("iso_1>0.1 && iso_1<0.2", "ele_antiiso"), Cut("abs(eta_1)<1.0", "ele_eta"), Cut("byTightIsolationMVArun2v1DBoldDMwLT_2>0.5", "tau_iso")), variable=d0_2)) et_categories.append( Category( "dZ_t", et, Cuts( Cut("m_vis>60 && m_vis<75", "Zpeak"), Cut("iso_1>0.1 && iso_1<0.2", "ele_antiiso"), Cut("abs(eta_1)<1.0", "ele_eta"), Cut("byTightIsolationMVArun2v1DBoldDMwLT_2>0.5", "tau_iso")), variable=dZ_2))''' mt_categories = [] if "mt" in args.channels: mt_categories.append( Category( "d0_tm", mt, Cuts( Cut("mt_1<50", "m_t"), Cut("iso_1<0.15", "muon_iso"), Cut("byTightIsolationMVArun2v1DBoldDMwLT_2>0.5", "tau_iso")), variable=d0_tm)) mt_categories.append( Category( "dZ_tm", mt, Cuts( Cut("mt_1<50", "m_t"), Cut("iso_1<0.15", "muon_iso"), Cut("byTightIsolationMVArun2v1DBoldDMwLT_2>0.5", "tau_iso")), variable=dZ_tm)) mt_categories.append( Category( "d0_tm", mt, Cuts( Cut("mt_1<50", "m_t"), Cut("iso_1<0.15", "muon_iso"), Cut("byTightIsolationMVArun2v1DBoldDMwLT_2>0.5", "tau_iso")), variable=d0_tm_calib)) mt_categories.append( Category( "dZ_tm", mt, Cuts( Cut("mt_1<50", "m_t"), Cut("iso_1<0.15", "muon_iso"), Cut("byTightIsolationMVArun2v1DBoldDMwLT_2>0.5", "tau_iso")), variable=dZ_tm_calib)) ''' mt_categories.append( Category( "m_vis", mt, Cuts( #Cut("m_vis>55 && m_vis<75", "Zpeak"), Cut("nbtag==0", "bveto"), Cut("mt_1<50", "m_t"), Cut("iso_1<0.15", "muon_iso"), Cut("mt_2<100", "tau_mt"), Cut("abs(eta_2)<1.0", "tau_eta"), Cut("byTightIsolationMVArun2v1DBoldDMwLT_2<0.5 && byMediumIsolationMVArun2v1DBoldDMwLT_2>0.5", "tau_antiiso")), variable=m_vis)) mt_categories.append( Category( "d0_tm", mt, Cuts( Cut("m_vis>55 && m_vis<75", "Zpeak"), Cut("nbtag==0", "bveto"), Cut("mt_1<50", "m_t"), Cut("iso_1<0.15", "muon_iso"), Cut("mt_2<100", "tau_mt"), Cut("abs(eta_2)<1.0", "tau_eta"), Cut("byTightIsolationMVArun2v1DBoldDMwLT_2<0.5 && byMediumIsolationMVArun2v1DBoldDMwLT_2>0.5", "tau_antiiso")), variable=d0_tm)) mt_categories.append( Category( "dZ_tm", mt, Cuts( Cut("m_vis>55 && m_vis<75", "Zpeak"), Cut("nbtag==0", "bveto"), Cut("mt_1<50", "m_t"), Cut("iso_1<0.15", "muon_iso"), Cut("mt_2<100", "tau_mt"), Cut("abs(eta_2)<1.0", "tau_eta"), Cut("byTightIsolationMVArun2v1DBoldDMwLT_2<0.5 && byMediumIsolationMVArun2v1DBoldDMwLT_2>0.5", "tau_antiiso")), variable=dZ_tm)) mt_categories.append( Category( "d0_t", mt, Cuts( Cut("m_vis>55 && m_vis<70", "Zpeak"), Cut("mt_1<50", "m_t"), Cut("iso_1>0.15 && iso_1<0.25", "muon_antiiso"), Cut("abs(eta_1)<1.0", "muon_eta"), Cut("byTightIsolationMVArun2v1DBoldDMwLT_2>0.5", "tau_iso")), variable=d0_2)) mt_categories.append( Category( "dZ_t", mt, Cuts( Cut("m_vis>55 && m_vis<70", "Zpeak"), Cut("mt_1<50", "m_t"), Cut("iso_1>0.15 && iso_1<0.25", "muon_antiiso"), Cut("abs(eta_1)<1.0", "muon_eta"), Cut("byTightIsolationMVArun2v1DBoldDMwLT_2>0.5", "tau_iso")), variable=dZ_2)) mt_categories.append( Category( "d0_f", mt, Cuts( #Cut("m_vis>55 && m_vis<70", "antiZpeak"), Cut("mt_1>70 && mt_1 < 100", "m_t"), Cut("iso_1<0.15", "muon_iso"), Cut("byTightIsolationMVArun2v1DBoldDMwLT_2>0.5", "tau_iso")), variable=d0_2)) mt_categories.append( Category( "dZ_f", mt, Cuts( Cut("m_vis>95", "antiZpeak"), Cut("mt_1>70 && mt_1 < 100", "m_t"), Cut("iso_1<0.15", "muon_iso"), Cut("byTightIsolationMVArun2v1DBoldDMwLT_2>0.5", "tau_iso")), variable=dZ_2)) mt_categories.append( Category( "d0_tt", mt, Cuts( Cut("mt_1>150", "m_t"), Cut("iso_1<0.15", "muon_iso"), Cut("byTightIsolationMVArun2v1DBoldDMwLT_2>0.5", "tau_iso")), variable=d0_2)) mt_categories.append( Category( "dZ_tt", mt, Cuts( Cut("mt_1>150", "m_t"), Cut("iso_1<0.15", "muon_iso"), Cut("byTightIsolationMVArun2v1DBoldDMwLT_2>0.5", "tau_iso")), variable=dZ_2))''' tt_categories = [] if "tt" in args.channels: tt_categories.append( Category( "d0_t2", tt, Cuts( Cut("m_vis>60 && m_vis<80", "Zpeak"), Cut("abs(eta_1)<1.0", "eta_tau_1"), Cut("byTightIsolationMVArun2v1DBoldDMwLT_1<0.5 && byLooseIsolationMVArun2v1DBoldDMwLT_1>0.5", "tau_1_antiiso")), variable=d0_2)) tt_categories.append( Category( "dZ_t2", tt, Cuts( Cut("m_vis>60 && m_vis<80", "Zpeak"), Cut("abs(eta_1)<1.0", "eta_tau_1"), Cut("byTightIsolationMVArun2v1DBoldDMwLT_1<0.5 && byLooseIsolationMVArun2v1DBoldDMwLT_1>0.5", "tau_1_antiiso")), variable=dZ_2)) # Nominal histograms # yapf: enable if "ee" in args.channels: for process, category in product(ee_processes.values(), ee_categories): systematics.add( Systematic(category=category, process=process, analysis="smhtt", era=era, variation=Nominal(), mass="125")) if "em" in args.channels: for process, category in product(em_processes.values(), em_categories): systematics.add( Systematic(category=category, process=process, analysis="smhtt", era=era, variation=Nominal(), mass="125")) if "mm" in args.channels: for process, category in product(mm_processes.values(), mm_categories): systematics.add( Systematic(category=category, process=process, analysis="smhtt", era=era, variation=Nominal(), mass="125")) if "et" in args.channels: for process, category in product(et_processes.values(), et_categories): systematics.add( Systematic(category=category, process=process, analysis="smhtt", era=era, variation=Nominal(), mass="125")) if "mt" in args.channels: for process, category in product(mt_processes.values(), mt_categories): systematics.add( Systematic(category=category, process=process, analysis="smhtt", era=era, variation=Nominal(), mass="125")) if "tt" in args.channels: for process, category in product(tt_processes.values(), tt_categories): systematics.add( Systematic(category=category, process=process, analysis="smhtt", era=era, variation=Nominal(), mass="125")) # Produce histograms systematics.produce()
def main(args): # Define era if "2016" in args.era: from shape_producer.era import Run2016 era = Run2016(args.datasets) elif "2017" in args.era: from shape_producer.era import Run2017 era = Run2017(args.datasets) else: logger.fatal("Era {} is not implemented.".format(args.era)) raise Exception # Load variables variables = yaml.load(open(args.variables))["selected_variables"] # Define bins and range of binning for variables in enabled channels channel_dict = { "em": { "2016": EMSM2016(), "2017": EMSM2017() }, "et": { "2016": ETSM2016(), "2017": ETSM2017() }, "mt": { "2016": MTSM2016(), "2017": MTSM2017() }, "tt": { "2016": TTSM2016(), "2017": TTSM2017() }, } friend_directories_dict = { "em": args.em_friend_directories, "et": args.et_friend_directories, "mt": args.mt_friend_directories, "tt": args.tt_friend_directories, } percentiles = [ 1.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 99.0 ] config = {"gof": {}} for ch in channel_dict: # Get properties if "2016" in args.era: eraname = "2016" elif "2017" in args.era: eraname = "2017" channel = channel_dict[ch][eraname] logger.info("Channel: %s" % ch) dict_ = {} additional_cuts = Cuts() logger.warning("Use additional cuts for %s: %s" % (ch, additional_cuts.expand())) dict_ = get_properties(dict_, era, channel, args.directory, additional_cuts) # Build chain dict_["tree_path"] = "%s_nominal/ntuple" % ch chain = build_chain(dict_, friend_directories_dict[ch]) # Get percentiles and calculate 1d binning binning = get_1d_binning(ch, chain, variables[int(eraname)][ch], percentiles) # Add binning for unrolled 2d distributions binning = add_2d_unrolled_binning(variables[int(eraname)][ch], binning) # Append binning to config config["gof"][ch] = binning # Write config logger.info("Write binning config to %s.", args.output) yaml.dump(config, open(args.output, 'w'))
def main(args): # Container for all distributions to be drawn systematics_mm = Systematics("counts_zptm_2018.root", num_threads=args.num_threads, find_unique_objects=True) # Era era = Run2018(args.datasets) # Channels and processes # yapf: disable directory = args.directory mm = MM() mm_processes = { "data" : Process("data_obs", DataEstimation (era, directory, mm, friend_directory=[])), "ZTT" : Process("ZTT", ZTTEstimation (era, directory, mm, friend_directory=[])), "ZL" : Process("ZL", ZLEstimation (era, directory, mm, friend_directory=[])), "TTT" : Process("TTT", TTTEstimation (era, directory, mm, friend_directory=[])), "TTL" : Process("TTL", TTLEstimation (era, directory, mm, friend_directory=[])), "VVT" : Process("VVT", VVTEstimation (era, directory, mm, friend_directory=[])), "VVL" : Process("VVL", VVLEstimation (era, directory, mm, friend_directory=[])), "W" : Process("W", WEstimation (era, directory, mm, friend_directory=[])), } mm_processes["QCD"] = Process("QCD", QCDEstimation_SStoOS_MTETEM(era, directory, mm, [mm_processes[process] for process in ["ZTT", "ZL", "W", "TTT", "TTL", "VVT", "VVL"]], mm_processes["data"], friend_directory=[], extrapolation_factor=2.0)) # Variables and categories mm_categories = [] variable_bins = { "m_vis" : [50, 100, 200, 500, 1000], "ptvis" : [0, 10, 20, 30, 40, 50, 100, 150, 200, 300, 400, 1000], } for mass_bin in range(len(variable_bins["m_vis"]) - 1): for pt_bin in range(len(variable_bins["ptvis"]) - 1): name = "%s_bin_%s_vs_%s_bin_%s"%("m_vis",str(mass_bin),"ptvis",str(pt_bin)) cuts = Cuts(Cut("(m_vis > %s && m_vis < %s) && (ptvis > %s && ptvis < %s)"%(str(variable_bins["m_vis"][mass_bin]),str(variable_bins["m_vis"][mass_bin+1]),str(variable_bins["ptvis"][pt_bin]),str(variable_bins["ptvis"][pt_bin+1])),"zptm_category")) mm_categories.append( Category( name, mm, cuts, variable=None)) # Nominal histograms for process, category in product(mm_processes.values(), mm_categories): #if process.name in ["ZTT","ZLL"]: # process.estimation_method.get_weights().remove("zPtReweightWeight") systematics_mm.add( Systematic( category=category, process=process, analysis="smhtt", era=era, variation=Nominal(), mass="125")) # Produce histograms systematics_mm.produce()
def main(args): # Container for all distributions to be drawn systematics_mt = Systematics("shapes_mt_2017.root", num_threads=args.num_threads, find_unique_objects=True) systematics_et = Systematics("shapes_et_2017.root", num_threads=args.num_threads, find_unique_objects=True) systematics_tt = Systematics("shapes_tt_2017.root", num_threads=args.num_threads, find_unique_objects=True) systematics_em = Systematics("shapes_em_2017.root", num_threads=args.num_threads, find_unique_objects=True) systematics_mm = Systematics("shapes_mm_2017.root", num_threads=args.num_threads, find_unique_objects=True) # Era era = Run2017(args.datasets) # Channels and processes # yapf: disable directory = args.directory et_friend_directory = args.et_friend_directory mt_friend_directory = args.mt_friend_directory tt_friend_directory = args.tt_friend_directory em_friend_directory = args.em_friend_directory mm_friend_directory = args.mm_friend_directory ff_friend_directory = args.fake_factor_friend_directory mt = MT() mt_processes = { "data" : Process("data_obs", DataEstimation (era, directory, mt, friend_directory=mt_friend_directory)), "ZTT" : Process("ZTT", ZTTEstimation (era, directory, mt, friend_directory=mt_friend_directory)), "EMB" : Process("EMB", ZTTEmbeddedEstimation (era, directory, mt, friend_directory=mt_friend_directory)), "ZJ" : Process("ZJ", ZJEstimation (era, directory, mt, friend_directory=mt_friend_directory)), "ZL" : Process("ZL", ZLEstimation (era, directory, mt, friend_directory=mt_friend_directory)), "TTT" : Process("TTT", TTTEstimation (era, directory, mt, friend_directory=mt_friend_directory)), "TTJ" : Process("TTJ", TTJEstimation (era, directory, mt, friend_directory=mt_friend_directory)), "TTL" : Process("TTL", TTLEstimation (era, directory, mt, friend_directory=mt_friend_directory)), "VVT" : Process("VVT", VVTEstimation (era, directory, mt, friend_directory=mt_friend_directory)), "VVJ" : Process("VVJ", VVJEstimation (era, directory, mt, friend_directory=mt_friend_directory)), "VVL" : Process("VVL", VVLEstimation (era, directory, mt, friend_directory=mt_friend_directory)), "W" : Process("W", WEstimation (era, directory, mt, friend_directory=mt_friend_directory)), "ggH" : Process("ggH125", ggHEstimation ("ggH125", era, directory, mt, friend_directory=mt_friend_directory)), "qqH" : Process("qqH125", qqHEstimation ("qqH125", era, directory, mt, friend_directory=mt_friend_directory)), "VH" : Process("VH125", VHEstimation (era, directory, mt, friend_directory=mt_friend_directory)), "WH" : Process("WH125", WHEstimation (era, directory, mt, friend_directory=mt_friend_directory)), "ZH" : Process("ZH125", ZHEstimation (era, directory, mt, friend_directory=mt_friend_directory)), "ttH" : Process("ttH125", ttHEstimation (era, directory, mt, friend_directory=mt_friend_directory)), "HWW" : Process("HWW", HWWEstimation (era, directory, mt, friend_directory=mt_friend_directory)), } mt_processes["FAKES"] = Process("jetFakes", NewFakeEstimationLT(era, directory, mt, [mt_processes[process] for process in ["ZTT", "ZL", "TTT", "TTL", "VVT", "VVL"]], mt_processes["data"], friend_directory=mt_friend_directory+[ff_friend_directory])) mt_processes["FAKESEMB"] = Process("jetFakesEMB", NewFakeEstimationLT(era, directory, mt, [mt_processes[process] for process in ["EMB", "ZL", "TTL", "VVL"]], mt_processes["data"], friend_directory=mt_friend_directory+[ff_friend_directory])) mt_processes["QCD"] = Process("QCD", QCDEstimation_SStoOS_MTETEM(era, directory, mt, [mt_processes[process] for process in ["ZTT", "ZL", "ZJ", "W", "TTT", "TTJ", "TTL", "VVT", "VVJ", "VVL"]], mt_processes["data"], friend_directory=mt_friend_directory, extrapolation_factor=1.00)) mt_processes["QCDEMB"] = Process("QCDEMB", QCDEstimation_SStoOS_MTETEM(era, directory, mt, [mt_processes[process] for process in ["EMB", "ZL", "ZJ", "W", "TTJ", "TTL", "VVJ", "VVL"]], mt_processes["data"], friend_directory=mt_friend_directory, extrapolation_factor=1.00)) et = ET() et_processes = { "data" : Process("data_obs", DataEstimation (era, directory, et, friend_directory=et_friend_directory)), "ZTT" : Process("ZTT", ZTTEstimation (era, directory, et, friend_directory=et_friend_directory)), "EMB" : Process("EMB", ZTTEmbeddedEstimation (era, directory, et, friend_directory=et_friend_directory)), "ZJ" : Process("ZJ", ZJEstimation (era, directory, et, friend_directory=et_friend_directory)), "ZL" : Process("ZL", ZLEstimation (era, directory, et, friend_directory=et_friend_directory)), "TTT" : Process("TTT", TTTEstimation (era, directory, et, friend_directory=et_friend_directory)), "TTJ" : Process("TTJ", TTJEstimation (era, directory, et, friend_directory=et_friend_directory)), "TTL" : Process("TTL", TTLEstimation (era, directory, et, friend_directory=et_friend_directory)), "VVT" : Process("VVT", VVTEstimation (era, directory, et, friend_directory=et_friend_directory)), "VVJ" : Process("VVJ", VVJEstimation (era, directory, et, friend_directory=et_friend_directory)), "VVL" : Process("VVL", VVLEstimation (era, directory, et, friend_directory=et_friend_directory)), "W" : Process("W", WEstimation (era, directory, et, friend_directory=et_friend_directory)), "ggH" : Process("ggH125", ggHEstimation ("ggH125", era, directory, et, friend_directory=et_friend_directory)), "qqH" : Process("qqH125", qqHEstimation ("qqH125", era, directory, et, friend_directory=et_friend_directory)), "VH" : Process("VH125", VHEstimation (era, directory, et, friend_directory=et_friend_directory)), "WH" : Process("WH125", WHEstimation (era, directory, et, friend_directory=et_friend_directory)), "ZH" : Process("ZH125", ZHEstimation (era, directory, et, friend_directory=et_friend_directory)), "ttH" : Process("ttH125", ttHEstimation (era, directory, et, friend_directory=et_friend_directory)), "HWW" : Process("HWW", HWWEstimation (era, directory, et, friend_directory=et_friend_directory)), } et_processes["FAKES"] = Process("jetFakes", NewFakeEstimationLT(era, directory, et, [et_processes[process] for process in ["ZTT", "ZL", "TTT", "TTL", "VVT", "VVL"]], et_processes["data"], friend_directory=et_friend_directory+[ff_friend_directory])) et_processes["FAKESEMB"] = Process("jetFakesEMB", NewFakeEstimationLT(era, directory, et, [et_processes[process] for process in ["EMB", "ZL", "TTL", "VVL"]], et_processes["data"], friend_directory=et_friend_directory+[ff_friend_directory])) et_processes["QCD"] = Process("QCD", QCDEstimation_SStoOS_MTETEM(era, directory, et, [et_processes[process] for process in ["ZTT", "ZL", "ZJ", "W", "TTT", "TTJ", "TTL", "VVT", "VVJ", "VVL"]], et_processes["data"], friend_directory=et_friend_directory, extrapolation_factor=1.00)) et_processes["QCDEMB"] = Process("QCDEMB", QCDEstimation_SStoOS_MTETEM(era, directory, et, [et_processes[process] for process in ["EMB", "ZL", "ZJ", "W", "TTJ", "TTL", "VVJ", "VVL"]], et_processes["data"], friend_directory=et_friend_directory, extrapolation_factor=1.00)) tt = TT() tt_processes = { "data" : Process("data_obs", DataEstimation (era, directory, tt, friend_directory=tt_friend_directory)), "ZTT" : Process("ZTT", ZTTEstimation (era, directory, tt, friend_directory=tt_friend_directory)), "EMB" : Process("EMB", ZTTEmbeddedEstimation (era, directory, tt, friend_directory=tt_friend_directory)), "ZJ" : Process("ZJ", ZJEstimation (era, directory, tt, friend_directory=tt_friend_directory)), "ZL" : Process("ZL", ZLEstimation (era, directory, tt, friend_directory=tt_friend_directory)), "TTT" : Process("TTT", TTTEstimation (era, directory, tt, friend_directory=tt_friend_directory)), "TTJ" : Process("TTJ", TTJEstimation (era, directory, tt, friend_directory=tt_friend_directory)), "TTL" : Process("TTL", TTLEstimation (era, directory, tt, friend_directory=tt_friend_directory)), "VVT" : Process("VVT", VVTEstimation (era, directory, tt, friend_directory=tt_friend_directory)), "VVJ" : Process("VVJ", VVJEstimation (era, directory, tt, friend_directory=tt_friend_directory)), "VVL" : Process("VVL", VVLEstimation (era, directory, tt, friend_directory=tt_friend_directory)), "W" : Process("W", WEstimation (era, directory, tt, friend_directory=tt_friend_directory)), "ggH" : Process("ggH125", ggHEstimation ("ggH125", era, directory, tt, friend_directory=tt_friend_directory)), "qqH" : Process("qqH125", qqHEstimation ("qqH125", era, directory, tt, friend_directory=tt_friend_directory)), "VH" : Process("VH125", VHEstimation (era, directory, tt, friend_directory=tt_friend_directory)), "WH" : Process("WH125", WHEstimation (era, directory, tt, friend_directory=tt_friend_directory)), "ZH" : Process("ZH125", ZHEstimation (era, directory, tt, friend_directory=tt_friend_directory)), "ttH" : Process("ttH125", ttHEstimation (era, directory, tt, friend_directory=tt_friend_directory)), "HWW" : Process("HWW", HWWEstimation (era, directory, tt, friend_directory=tt_friend_directory)), } tt_processes["FAKESEMB"] = Process("jetFakesEMB", NewFakeEstimationTT(era, directory, tt, [tt_processes[process] for process in ["EMB", "ZL", "TTL", "VVL"]], tt_processes["data"], friend_directory=tt_friend_directory+[ff_friend_directory])) tt_processes["FAKES"] = Process("jetFakes", NewFakeEstimationTT(era, directory, tt, [tt_processes[process] for process in ["ZTT", "ZL", "TTT", "TTL", "VVT", "VVL"]], tt_processes["data"], friend_directory=tt_friend_directory+[ff_friend_directory])) tt_processes["QCD"] = Process("QCD", QCDEstimation_ABCD_TT_ISO2(era, directory, tt, [tt_processes[process] for process in ["ZTT", "ZL", "ZJ", "W", "TTT", "TTJ", "TTL", "VVT", "VVJ", "VVL"]], tt_processes["data"], friend_directory=tt_friend_directory)) tt_processes["QCDEMB"] = Process("QCDEMB", QCDEstimation_ABCD_TT_ISO2(era, directory, tt, [tt_processes[process] for process in ["EMB", "ZL", "ZJ", "W", "TTJ", "TTL", "VVJ", "VVL"]], tt_processes["data"], friend_directory=tt_friend_directory)) em = EM() em_processes = { "data" : Process("data_obs", DataEstimation (era, directory, em, friend_directory=em_friend_directory)), "ZTT" : Process("ZTT", ZTTEstimation (era, directory, em, friend_directory=em_friend_directory)), "EMB" : Process("EMB", ZTTEmbeddedEstimation (era, directory, em, friend_directory=em_friend_directory)), "ZL" : Process("ZL", ZLEstimation (era, directory, em, friend_directory=em_friend_directory)), "TTT" : Process("TTT", TTTEstimation (era, directory, em, friend_directory=em_friend_directory)), "TTL" : Process("TTL", TTLEstimation (era, directory, em, friend_directory=em_friend_directory)), "VVT" : Process("VVT", VVTEstimation (era, directory, em, friend_directory=em_friend_directory)), "VVL" : Process("VVL", VVLEstimation (era, directory, em, friend_directory=em_friend_directory)), "W" : Process("W", WEstimation (era, directory, em, friend_directory=em_friend_directory)), "ggH" : Process("ggH125", ggHEstimation ("ggH125", era, directory, em, friend_directory=em_friend_directory)), "qqH" : Process("qqH125", qqHEstimation ("qqH125", era, directory, em, friend_directory=em_friend_directory)), "VH" : Process("VH125", VHEstimation (era, directory, em, friend_directory=em_friend_directory)), "WH" : Process("WH125", WHEstimation (era, directory, em, friend_directory=em_friend_directory)), "ZH" : Process("ZH125", ZHEstimation (era, directory, em, friend_directory=em_friend_directory)), "ttH" : Process("ttH125", ttHEstimation (era, directory, em, friend_directory=em_friend_directory)), "HWW" : Process("HWW", HWWEstimation (era, directory, em, friend_directory=em_friend_directory)), } em_processes["QCD"] = Process("QCD", QCDEstimation_SStoOS_MTETEM(era, directory, em, [em_processes[process] for process in ["ZTT", "ZL", "W", "TTT", "VVT", "VVL"]], em_processes["data"], extrapolation_factor=1.0, qcd_weight = Weight("em_qcd_extrap_up_Weight","qcd_weight"))) em_processes["QCDEMB"] = Process("QCDEMB", QCDEstimation_SStoOS_MTETEM(era, directory, em, [em_processes[process] for process in ["EMB", "ZL", "W", "VVL", "TTL"]], em_processes["data"], extrapolation_factor=1.0, qcd_weight = Weight("em_qcd_extrap_up_Weight","qcd_weight"))) mm = MM() mm_processes = { "data" : Process("data_obs", DataEstimation (era, directory, mm, friend_directory=mm_friend_directory)), "ZTT" : Process("ZTT", ZTTEstimation (era, directory, mm, friend_directory=mm_friend_directory)), "ZL" : Process("ZL", ZLEstimation (era, directory, mm, friend_directory=mm_friend_directory)), "TTT" : Process("TTT", TTTEstimation (era, directory, mm, friend_directory=mm_friend_directory)), "TTL" : Process("TTL", TTLEstimation (era, directory, mm, friend_directory=mm_friend_directory)), "VVT" : Process("VVT", VVTEstimation (era, directory, mm, friend_directory=mm_friend_directory)), "VVL" : Process("VVL", VVLEstimation (era, directory, mm, friend_directory=mm_friend_directory)), "W" : Process("W", WEstimation (era, directory, mm, friend_directory=mm_friend_directory)), } mm_processes["QCD"] = Process("QCD", QCDEstimation_SStoOS_MTETEM(era, directory, mm, [mm_processes[process] for process in ["ZTT", "ZL", "W", "TTT", "TTL", "VVT", "VVL"]], mm_processes["data"], friend_directory=mm_friend_directory, extrapolation_factor=2.0)) # Variables and categories binning = yaml.load(open(args.binning)) mt_categories = [] et_categories = [] tt_categories = [] em_categories = [] mm_categories = [] variable_names = [ # "m_vis", "ptvis", # "DiTauDeltaR", # "m_sv", "pt_sv", "eta_sv", # "m_sv_puppi", "pt_sv_puppi", "eta_sv_puppi", # "m_fastmtt", "pt_fastmtt", "eta_fastmtt", # "m_fastmtt_puppi", "pt_fastmtt_puppi", "eta_fastmtt_puppi", "ME_ggh", "ME_vbf", "ME_z2j_1", "ME_z2j_2", "ME_q2v1", "ME_q2v2", "ME_costheta1", "ME_costheta2", "ME_costhetastar", "ME_phi", "ME_phi1", "ME_ggh_vs_Z", "ME_vbf_vs_Z", "ME_vbf_vs_ggh", # "pt_1", "pt_2", "eta_1", "eta_2", # "mjj", "jdeta", "dijetpt", # "njets", "jpt_1", "jpt_2", "jeta_1", "jeta_2", # "nbtag", "bpt_1", "bpt_2", "beta_1", "beta_2", # "met", "mt_1", "mt_2", "pt_tt", "pZetaMissVis", "pt_ttjj", "mt_tot", "mTdileptonMET", # "puppimet", "mt_1_puppi", "mt_2_puppi", "pt_tt_puppi", "pZetaPuppiMissVis", "pt_ttjj_puppi", "mt_tot_puppi", "mTdileptonMET_puppi", # "NNrecoil_pt", "nnmet", "mt_1_nn", "mt_2_nn", "pt_tt_nn", "pZetaNNMissVis", "pt_ttjj_nn", "mt_tot_nn", "mTdileptonMET_nn", "metParToZ", "metPerpToZ", "puppimetParToZ", "puppimetPerpToZ", ] if "mt" in args.channels: variables = [Variable(v,VariableBinning(binning["control"]["mt"][v]["bins"]), expression=binning["control"]["mt"][v]["expression"]) for v in variable_names] cuts = Cuts() for name, var in zip(variable_names, variables): mt_categories.append( Category( name, mt, cuts, variable=var)) if "et" in args.channels: variables = [Variable(v,VariableBinning(binning["control"]["et"][v]["bins"]), expression=binning["control"]["et"][v]["expression"]) for v in variable_names] cuts = Cuts() for name, var in zip(variable_names, variables): et_categories.append( Category( name, et, cuts, variable=var)) if "tt" in args.channels: variables = [Variable(v,VariableBinning(binning["control"]["tt"][v]["bins"]), expression=binning["control"]["tt"][v]["expression"]) for v in variable_names] cuts = Cuts() for name, var in zip(variable_names, variables): tt_categories.append( Category( name, tt, cuts, variable=var)) if "em" in args.channels: variables = [Variable(v,VariableBinning(binning["control"]["em"][v]["bins"]), expression=binning["control"]["em"][v]["expression"]) for v in variable_names] cuts = Cuts() for name, var in zip(variable_names, variables): em_categories.append( Category( name, em, cuts, variable=var)) if "mm" in args.channels: variables = [Variable(v,VariableBinning(binning["control"]["mm"][v]["bins"]), expression=binning["control"]["mm"][v]["expression"]) for v in variable_names] variables.append(Variable("m_vis_high",ConstantBinning(95,50.0,1000.0),expression="m_vis")) variable_names.append("m_vis_high") cuts = Cuts() for name, var in zip(variable_names, variables): mm_categories.append( Category( name, mm, cuts, variable=var)) mm_categories.append( Category( name+"_peak", mm, Cuts(Cut("m_vis > 70 && m_vis < 110","m_vis_peak")), variable=var)) # Nominal histograms if "mt" in args.channels: for process, category in product(mt_processes.values(), mt_categories): systematics_mt.add( Systematic( category=category, process=process, analysis="smhtt", era=era, variation=Nominal(), mass="125")) if "et" in args.channels: for process, category in product(et_processes.values(), et_categories): systematics_et.add( Systematic( category=category, process=process, analysis="smhtt", era=era, variation=Nominal(), mass="125")) if "tt" in args.channels: for process, category in product(tt_processes.values(), tt_categories): systematics_tt.add( Systematic( category=category, process=process, analysis="smhtt", era=era, variation=Nominal(), mass="125")) if "em" in args.channels: for process, category in product(em_processes.values(), em_categories): systematics_em.add( Systematic( category=category, process=process, analysis="smhtt", era=era, variation=Nominal(), mass="125")) if "mm" in args.channels: for process, category in product(mm_processes.values(), mm_categories): systematics_mm.add( Systematic( category=category, process=process, analysis="smhtt", era=era, variation=Nominal(), mass="125")) # Produce histograms if "mt" in args.channels: systematics_mt.produce() if "et" in args.channels: systematics_et.produce() if "tt" in args.channels: systematics_tt.produce() if "em" in args.channels: systematics_em.produce() if "mm" in args.channels: systematics_mm.produce()
def main(args): # Container for all distributions to be drawn systematics_mt = Systematics("shapes_mt.root", num_threads=args.num_threads, find_unique_objects=True) systematics_et = Systematics("shapes_et.root", num_threads=args.num_threads, find_unique_objects=True) systematics_tt = Systematics("shapes_tt.root", num_threads=args.num_threads, find_unique_objects=True) systematics_em = Systematics("shapes_em.root", num_threads=args.num_threads, find_unique_objects=True) # Era era = Run2017ReReco31Mar(args.datasets) # Channels and processes # yapf: disable directory = args.directory susy_masses = ["250", "300", "700", "2300"] ff_friend_directory = args.fake_factor_friend_directory mt = MT() mt_processes = { "data" : Process("data_obs", DataEstimation (era, directory, mt, friend_directory=[])), "ZTT" : Process("ZTT", ZTTEstimation (era, directory, mt, friend_directory=[])), "EMB" : Process("EMB", ZTTEmbeddedEstimation (era, directory, mt, friend_directory=[])), "ZLL" : Process("ZLL", ZLLEstimation (era, directory, mt, friend_directory=[])), "ZJ" : Process("ZJ", ZJEstimation (era, directory, mt, friend_directory=[])), # "W" : Process("W", WEstimation (era, directory, mt, friend_directory=[])), "TT" : Process("TT", TTEstimation (era, directory, mt, friend_directory=[])), "TTL" : Process("TTL", TTLEstimation (era, directory, mt, friend_directory=[])), "TTT" : Process("TTT", TTTEstimation (era, directory, mt, friend_directory=[])), "TTJ" : Process("TTJ", TTJEstimation (era, directory, mt, friend_directory=[])), "VV" : Process("VV", VVEstimation (era, directory, mt, friend_directory=[])), "VVT" : Process("VVT", VVTEstimation (era, directory, mt, friend_directory=[])), "VVJ" : Process("VVJ", VVJEstimation (era, directory, mt, friend_directory=[])), "VVL" : Process("VVL", VVLEstimation (era, directory, mt, friend_directory=[])), "EWK" : Process("EWK", EWKEstimation (era, directory, mt, friend_directory=[])), "EWKT" : Process("EWKT", EWKTEstimation (era, directory, mt, friend_directory=[])), "EWKL" : Process("EWKL", EWKLEstimation (era, directory, mt, friend_directory=[])), "EWKJ" : Process("EWKJ", EWKJEstimation (era, directory, mt, friend_directory=[])), # "FAKES" : Process("jetFakes", FakeEstimationLT(era, directory, mt, friend_directory=[ff_friend_directory])), "HTT" : Process("HTT", HTTEstimation (era, directory, mt, friend_directory=[])), } wjets_mc_mt = Process("WMC", WEstimation (era, directory, mt, friend_directory=[])) #mt_processes["QCD"] = Process("QCD", QCDEstimation_SStoOS_MTETEM(era, directory, mt, [mt_processes[process] for process in ["ZTT", "ZLL", "W", "TT", "VV", "EWK"]], mt_processes["data"], friend_directory=[], extrapolation_factor=1.1)) mt_processes["W"] = Process("W", WEstimationWithQCD(era, directory, mt, [mt_processes[process] for process in ["ZTT", "ZLL", "ZJ", "TT", "VV", "EWK"]], mt_processes["data"], wjets_mc_mt, friend_directory=[], qcd_ss_to_os_extrapolation_factor=1.1)) mt_processes["QCD"] = Process("QCD", QCDEstimationWithW(era, directory, mt, [mt_processes[process] for process in ["ZTT", "ZLL", "ZJ", "TT", "VV", "EWK"]], mt_processes["data"], wjets_mc_mt, friend_directory=[], qcd_ss_to_os_extrapolation_factor=1.1)) mt_processes["WEMB"] = Process("WEMB", WEstimationWithQCD(era, directory, mt, [mt_processes[process] for process in ["EMB", "ZLL", "ZJ", "TTL", "TTJ", "VVL", "VVJ", "EWKL", "EWKJ"]], mt_processes["data"], wjets_mc_mt, friend_directory=[], qcd_ss_to_os_extrapolation_factor=1.1)) mt_processes["QCDEMB"] = Process("QCDEMB", QCDEstimationWithW(era, directory, mt, [mt_processes[process] for process in ["EMB", "ZLL", "ZJ", "TTL", "TTJ", "VVL", "VVJ", "EWKL", "EWKJ"]], mt_processes["data"], wjets_mc_mt, friend_directory=[], qcd_ss_to_os_extrapolation_factor=1.1)) for m in susy_masses: mt_processes["ggH_"+m] = Process("ggH_"+m, SUSYggHEstimation(era, directory, mt, m, friend_directory=[])) mt_processes["bbH_"+m] = Process("bbH_"+m, SUSYbbHEstimation(era, directory, mt, m, friend_directory=[])) em = EM() em_processes = { "data" : Process("data_obs", DataEstimation (era, directory, em, friend_directory=[])), "ZTT" : Process("ZTT", ZTTEstimation (era, directory, em, friend_directory=[])), "EMB" : Process("EMB", ZTTEmbeddedEstimation (era, directory, em, friend_directory=[])), "ZLL" : Process("ZLL", ZLLEstimation (era, directory, em, friend_directory=[])), "ZJ" : Process("ZJ", ZJEstimation (era, directory, em, friend_directory=[])), "W" : Process("W", WEstimation (era, directory, em, friend_directory=[])), "TT" : Process("TT", TTEstimation (era, directory, em, friend_directory=[])), "TTT" : Process("TTT", TTTEstimation (era, directory, em, friend_directory=[])), "TTL" : Process("TTL", TTLEstimation (era, directory, em, friend_directory=[])), "VV" : Process("VV", VVEstimation (era, directory, em, friend_directory=[])), "VVT" : Process("VVT", VVTEstimation (era, directory, em, friend_directory=[])), "VVL" : Process("VVL", VVLEstimation (era, directory, em, friend_directory=[])), "EWK" : Process("EWK", EWKEstimation (era, directory, em, friend_directory=[])), "EWKT" : Process("EWKT", EWKTEstimation (era, directory, em, friend_directory=[])), "EWKL" : Process("EWKL", EWKLEstimation (era, directory, em, friend_directory=[])), "HTT" : Process("HTT", HTTEstimation (era, directory, em, friend_directory=[])), } em_processes["QCD"] = Process("QCD", QCDEstimation_SStoOS_MTETEM(era, directory, em, [em_processes[process] for process in ["ZTT", "ZLL", "W", "TT", "VV", "EWK"]], em_processes["data"], friend_directory=[], extrapolation_factor=1.0)) em_processes["QCDEMB"] = Process("QCDEMB", QCDEstimation_SStoOS_MTETEM(era, directory, em, [em_processes[process] for process in ["EMB", "ZLL", "ZJ", "TTL", "VVL", "EWKL"]], em_processes["data"], friend_directory=[], extrapolation_factor=1.0)) for m in susy_masses: em_processes["ggH_"+m] = Process("ggH_"+m, SUSYggHEstimation(era, directory, em, m, friend_directory=[])) em_processes["bbH_"+m] = Process("bbH_"+m, SUSYbbHEstimation(era, directory, em, m, friend_directory=[])) et = ET() et_processes = { "data" : Process("data_obs", DataEstimation (era, directory, et, friend_directory=[])), "ZTT" : Process("ZTT", ZTTEstimation (era, directory, et, friend_directory=[])), "EMB" : Process("EMB", ZTTEmbeddedEstimation (era, directory, et, friend_directory=[])), "ZLL" : Process("ZLL", ZLLEstimation (era, directory, et, friend_directory=[])), "ZJ" : Process("ZJ", ZJEstimation (era, directory, et, friend_directory=[])), # "W" : Process("W", WEstimation (era, directory, et, friend_directory=[])), "TT" : Process("TT", TTEstimation (era, directory, et, friend_directory=[])), "TTL" : Process("TTL", TTLEstimation (era, directory, et, friend_directory=[])), "TTT" : Process("TTT", TTTEstimation (era, directory, et, friend_directory=[])), "TTJ" : Process("TTJ", TTJEstimation (era, directory, et, friend_directory=[])), "VV" : Process("VV", VVEstimation (era, directory, et, friend_directory=[])), "VVT" : Process("VVT", VVTEstimation (era, directory, et, friend_directory=[])), "VVJ" : Process("VVJ", VVJEstimation (era, directory, et, friend_directory=[])), "VVL" : Process("VVL", VVLEstimation (era, directory, et, friend_directory=[])), "EWK" : Process("EWK", EWKEstimation (era, directory, et, friend_directory=[])), "EWKT" : Process("EWKT", EWKTEstimation (era, directory, et, friend_directory=[])), "EWKL" : Process("EWKL", EWKLEstimation (era, directory, et, friend_directory=[])), "EWKJ" : Process("EWKJ", EWKJEstimation (era, directory, et, friend_directory=[])), # "FAKES" : Process("jetFakes", FakeEstimationLT(era, directory, et, friend_directory=[ff_friend_directory])), "HTT" : Process("HTT", HTTEstimation (era, directory, et, friend_directory=[])), } wjets_mc_et = Process("WMC", WEstimation (era, directory, et, friend_directory=[])) #et_processes["QCD"] = Process("QCD", QCDEstimation_SStoOS_MTETEM(era, directory, et, [et_processes[process] for process in ["ZTT", "ZLL", "W", "TT", "VV", "EWK"]], et_processes["data"], friend_directory=[], extrapolation_factor=1.09)) et_processes["W"] = Process("W", WEstimationWithQCD(era, directory, et, [et_processes[process] for process in ["ZTT", "ZLL", "ZJ", "TT", "VV", "EWK"]], et_processes["data"], wjets_mc_et, friend_directory=[], qcd_ss_to_os_extrapolation_factor=1.09)) et_processes["QCD"] = Process("QCD", QCDEstimationWithW(era, directory, et, [et_processes[process] for process in ["ZTT", "ZLL", "ZJ", "TT", "VV", "EWK"]], et_processes["data"], wjets_mc_et, friend_directory=[], qcd_ss_to_os_extrapolation_factor=1.09)) et_processes["WEMB"] = Process("WEMB", WEstimationWithQCD(era, directory, et, [et_processes[process] for process in ["EMB", "ZLL", "ZJ", "TTL", "TTJ", "VVL", "VVJ", "EWKL", "EWKJ"]], et_processes["data"], wjets_mc_et, friend_directory=[], qcd_ss_to_os_extrapolation_factor=1.09)) et_processes["QCDEMB"] = Process("QCDEMB", QCDEstimationWithW(era, directory, et, [et_processes[process] for process in ["EMB", "ZLL", "ZJ", "TTL", "TTJ", "VVL", "VVJ", "EWKL", "EWKJ"]], et_processes["data"], wjets_mc_et, friend_directory=[], qcd_ss_to_os_extrapolation_factor=1.09)) for m in susy_masses: et_processes["ggH_"+m] = Process("ggH_"+m, SUSYggHEstimation(era, directory, et, m, friend_directory=[])) et_processes["bbH_"+m] = Process("bbH_"+m, SUSYbbHEstimation(era, directory, et, m, friend_directory=[])) tt = TT() tt_processes = { "data" : Process("data_obs", DataEstimation (era, directory, tt, friend_directory=[])), "ZTT" : Process("ZTT", ZTTEstimation (era, directory, tt, friend_directory=[])), "EMB" : Process("EMB", ZTTEmbeddedEstimation (era, directory, tt, friend_directory=[])), "ZLL" : Process("ZLL", ZLLEstimation (era, directory, tt, friend_directory=[])), "ZJ" : Process("ZJ", ZJEstimation (era, directory, tt, friend_directory=[])), "W" : Process("W", WEstimation (era, directory, tt, friend_directory=[])), "TT" : Process("TT", TTEstimation(era, directory, tt, friend_directory=[])), "TTT" : Process("TTT", TTTEstimation(era, directory, tt, friend_directory=[])), "TTJ" : Process("TTJ", TTJEstimation(era, directory, tt, friend_directory=[])), "TTL" : Process("TTL", TTLEstimation (era, directory, tt, friend_directory=[])), "VV" : Process("VV", VVEstimation (era, directory, tt, friend_directory=[])), "VVT" : Process("VVT", VVTEstimation(era, directory, tt, friend_directory=[])), "VVJ" : Process("VVJ", VVJEstimation(era, directory, tt, friend_directory=[])), "VVL" : Process("VVL", VVLEstimation (era, directory, tt, friend_directory=[])), "EWK" : Process("EWK", EWKEstimation (era, directory, tt, friend_directory=[])), "EWKT" : Process("EWKT", EWKTEstimation (era, directory, tt, friend_directory=[])), "EWKL" : Process("EWKL", EWKLEstimation (era, directory, tt, friend_directory=[])), "EWKJ" : Process("EWKJ", EWKJEstimation (era, directory, tt, friend_directory=[])), "FAKES" : Process("jetFakes", FakeEstimationTT(era, directory, tt, friend_directory=[ff_friend_directory])), "HTT" : Process("HTT", HTTEstimation (era, directory, tt, friend_directory=[])) } tt_processes["QCD"] = Process("QCD", QCDEstimation_ABCD_TT_ISO2(era, directory, tt, [tt_processes[process] for process in ["ZTT", "ZLL", "ZJ", "TT", "VV", "EWK", "W"]], tt_processes["data"], friend_directory=[])) tt_processes["QCDEMB"] = Process("QCDEMB", QCDEstimation_ABCD_TT_ISO2(era, directory, tt, [tt_processes[process] for process in ["EMB", "ZLL", "ZJ", "TTL", "TTJ", "VVL", "VVJ", "EWKL", "EWKJ", "W"]], tt_processes["data"], friend_directory=[])) #tt_processes["QCD"] = Process("QCD", QCDEstimation_ABCD_TT_ISO2_TRANSPOSED(era, directory, tt, [tt_processes[process] for process in ["ZTT", "ZLL", "W", "TT", "VV", "EWK"]], tt_processes["data"], friend_directory=[])) #tt_processes["QCD"] = Process("QCD", QCDEstimation_SStoOS_MTETEM(era, directory, tt, [tt_processes[process] for process in ["ZTT", "ZLL", "W", "TT", "VV", "EWK"]], tt_processes["data"], friend_directory=[], extrapolation_factor=1.0)) for m in susy_masses: tt_processes["ggH_"+m] = Process("ggH_"+m, SUSYggHEstimation(era, directory, tt, m, friend_directory=[])) tt_processes["bbH_"+m] = Process("bbH_"+m, SUSYbbHEstimation(era, directory, tt, m, friend_directory=[])) # Variables and categories binning = yaml.load(open(args.binning)) mt_categories = [] et_categories = [] tt_categories = [] em_categories = [] variable_names = ["mt_1","mt_2", "pt_1","pt_2", "eta_1", "eta_2", "m_vis", "ptvis", "npv", "njets", "nbtag", "jpt_1", "jpt_2", "jeta_1", "jeta_2", "met", "mjj", "dijetpt", "pZetaMissVis", "m_1", "m_2", "decayMode_1", "decayMode_2", "iso_1", "iso_2", "rho", "mt_tot", "d0_1", "d0_2", "dZ_1", "dZ_2"] if "mt" in args.channels: variables = [Variable(v,VariableBinning(binning["control"]["mt"][v]["bins"]), expression=binning["control"]["mt"][v]["expression"]) for v in variable_names] for name, var in zip(variable_names, variables): if name == "mt_1": cuts = Cuts() else: cuts=Cuts(Cut("mt_1 < 70","mt")) mt_categories.append( Category( name, mt, cuts, variable=var)) if name == "iso_1" or name == "iso_2": mt_categories[-1].cuts.remove("muon_iso") mt_categories[-1].cuts.remove("tau_iso") if "et" in args.channels: variables = [Variable(v,VariableBinning(binning["control"]["et"][v]["bins"]), expression=binning["control"]["et"][v]["expression"]) for v in variable_names] for name, var in zip(variable_names, variables): if name == "mt_1": cuts = Cuts() else: cuts=Cuts(Cut("mt_1 < 70","mt")) et_categories.append( Category( name, et, cuts, variable=var)) if name == "iso_1" or name == "iso_2": et_categories[-1].cuts.remove("ele_iso") et_categories[-1].cuts.remove("tau_iso") if "tt" in args.channels: variables = [Variable(v,VariableBinning(binning["control"]["tt"][v]["bins"]), expression=binning["control"]["tt"][v]["expression"]) for v in variable_names] cuts=Cuts() for name, var in zip(variable_names, variables): tt_categories.append( Category( name, tt, cuts, variable=var)) if "em" in args.channels: variables = [Variable(v,VariableBinning(binning["control"]["em"][v]["bins"]), expression=binning["control"]["em"][v]["expression"]) for v in variable_names] cuts=Cuts(Cut("pZetaMissVis > -50","dzeta_cut")) for name, var in zip(variable_names, variables): if name == "pZetaMissVis": cuts = Cuts() else: cuts=Cuts(Cut("pZetaMissVis > -50","dzeta_cut")) em_categories.append( Category( name, em, cuts, variable=var)) if name == "iso_1" or name == "iso_2": em_categories[-1].cuts.remove("ele_iso") em_categories[-1].cuts.remove("muon_iso") # Nominal histograms if "mt" in args.channels: for process, category in product(mt_processes.values(), mt_categories): systematics_mt.add( Systematic( category=category, process=process, analysis="smhtt", era=era, variation=Nominal(), mass="125")) if "et" in args.channels: for process, category in product(et_processes.values(), et_categories): systematics_et.add( Systematic( category=category, process=process, analysis="smhtt", era=era, variation=Nominal(), mass="125")) if "tt" in args.channels: for process, category in product(tt_processes.values(), tt_categories): systematics_tt.add( Systematic( category=category, process=process, analysis="smhtt", era=era, variation=Nominal(), mass="125")) if "em" in args.channels: for process, category in product(em_processes.values(), em_categories): systematics_em.add( Systematic( category=category, process=process, analysis="smhtt", era=era, variation=Nominal(), mass="125")) # Produce histograms if "mt" in args.channels: systematics_mt.produce() if "et" in args.channels: systematics_et.produce() if "tt" in args.channels: systematics_tt.produce() if "em" in args.channels: systematics_em.produce()
def main(args): # Write arparse arguments to YAML config logger.debug("Write argparse arguments to YAML config.") output_config = {} output_config["base_path"] = args.base_path output_config["output_path"] = args.output_path output_config["output_filename"] = args.output_filename output_config["tree_path"] = args.tree_path output_config["event_branch"] = args.event_branch output_config["training_weight_branch"] = args.training_weight_branch # Define era if "2016" in args.era: from shape_producer.estimation_methods_2016 import DataEstimation, HTTEstimation, ggHEstimation, qqHEstimation, VHEstimation, ZTTEstimation, ZTTEstimationTT, ZLEstimationMTSM, ZLEstimationETSM, ZLEstimationTT, ZJEstimationMT, ZJEstimationET, ZJEstimationTT, WEstimationRaw, TTTEstimationMT, TTTEstimationET, TTTEstimationTT, TTJEstimationMT, TTJEstimationET, TTJEstimationTT, VVEstimation, QCDEstimationMT, QCDEstimationET, QCDEstimationTT, ZTTEmbeddedEstimation, TTLEstimationMT, TTLEstimationET, TTLEstimationTT, TTTTEstimationMT, TTTTEstimationET, EWKWpEstimation, EWKWmEstimation, EWKZllEstimation, EWKZnnEstimation from shape_producer.era import Run2016 era = Run2016(args.database) else: logger.fatal("Era {} is not implemented.".format(args.era)) raise Exception ############################################################################ # Channel: mt if args.channel == "mt": channel = MTSM() # Set up `processes` part of config output_config["processes"] = {} # Additional cuts additional_cuts = Cuts() logger.warning("Use additional cuts for mt: %s", additional_cuts.expand()) # MC-driven processes # NOTE: Define here the mappig of the process estimations to the training classes classes_map = { "ggH": "ggh", "qqH": "qqh", "ZTT": "ztt", "EMB": "ztt", "ZL": "zll", "ZJ": "zll", "TTT": "tt", "TTL": "tt", "TTJ": "tt", "W": "w", "EWKWp": "w", "EWKWm": "w", "VV": "misc", "EWKZll": "misc", "EWKZnn": "misc" } for estimation in [ ggHEstimation(era, args.base_path, channel), qqHEstimation(era, args.base_path, channel), ZTTEstimation(era, args.base_path, channel), #ZTTEmbeddedEstimation(era, args.base_path, channel), ZLEstimationMTSM(era, args.base_path, channel), ZJEstimationMT(era, args.base_path, channel), TTTEstimationMT(era, args.base_path, channel), #TTLEstimationMT(era, args.base_path, channel), TTJEstimationMT(era, args.base_path, channel), WEstimationRaw(era, args.base_path, channel), EWKWpEstimation(era, args.base_path, channel), EWKWmEstimation(era, args.base_path, channel), VVEstimation(era, args.base_path, channel), EWKZllEstimation(era, args.base_path, channel), #EWKZnnEstimation(era, args.base_path, channel) ]: output_config["processes"][estimation.name] = { "files": [ str(f).replace(args.base_path + "/", "") for f in estimation.get_files() ], "cut_string": (estimation.get_cuts() + channel.cuts + additional_cuts).expand(), "weight_string": estimation.get_weights().extract(), "class": classes_map[estimation.name] } # Same sign selection for data-driven QCD estimation = DataEstimation(era, args.base_path, channel) estimation.name = "QCD" channel_ss = copy.deepcopy(channel) channel_ss.cuts.get("os").invert() output_config["processes"][estimation.name] = { "files": [ str(f).replace(args.base_path + "/", "") for f in estimation.get_files() ], "cut_string": (estimation.get_cuts() + channel_ss.cuts + additional_cuts).expand(), "weight_string": estimation.get_weights().extract(), "class": "ss" } ############################################################################ # Channel: et if args.channel == "et": channel = ETSM() # Set up `processes` part of config output_config["processes"] = {} # Additional cuts additional_cuts = Cuts() logger.warning("Use additional cuts for et: %s", additional_cuts.expand()) # MC-driven processes # NOTE: Define here the mappig of the process estimations to the training classes classes_map = { "ggH": "ggh", "qqH": "qqh", "ZTT": "ztt", "EMB": "ztt", "ZL": "zll", "ZJ": "zll", "TTT": "tt", "TTL": "tt", "TTJ": "tt", "W": "w", "EWKWp": "w", "EWKWm": "w", "VV": "misc", "EWKZll": "misc", "EWKZnn": "misc" } for estimation in [ ggHEstimation(era, args.base_path, channel), qqHEstimation(era, args.base_path, channel), ZTTEstimation(era, args.base_path, channel), #ZTTEmbeddedEstimation(era, args.base_path, channel), ZLEstimationETSM(era, args.base_path, channel), ZJEstimationET(era, args.base_path, channel), TTTEstimationET(era, args.base_path, channel), #TTLEstimationET(era, args.base_path, channel), TTJEstimationET(era, args.base_path, channel), WEstimationRaw(era, args.base_path, channel), EWKWpEstimation(era, args.base_path, channel), EWKWmEstimation(era, args.base_path, channel), VVEstimation(era, args.base_path, channel), EWKZllEstimation(era, args.base_path, channel), #EWKZnnEstimation(era, args.base_path, channel) ]: output_config["processes"][estimation.name] = { "files": [ str(f).replace(args.base_path + "/", "") for f in estimation.get_files() ], "cut_string": (estimation.get_cuts() + channel.cuts + additional_cuts).expand(), "weight_string": estimation.get_weights().extract(), "class": classes_map[estimation.name] } # Same sign selection for data-driven QCD estimation = DataEstimation(era, args.base_path, channel) estimation.name = "QCD" channel_ss = copy.deepcopy(channel) channel_ss.cuts.get("os").invert() output_config["processes"][estimation.name] = { "files": [ str(f).replace(args.base_path + "/", "") for f in estimation.get_files() ], "cut_string": (estimation.get_cuts() + channel_ss.cuts + additional_cuts).expand(), "weight_string": estimation.get_weights().extract(), "class": "ss" } ############################################################################ # Channel: tt if args.channel == "tt": channel = TTSM() # Set up `processes` part of config output_config["processes"] = {} # Additional cuts additional_cuts = Cuts() logger.warning("Use additional cuts for tt: %s", additional_cuts.expand()) # MC-driven processes # NOTE: Define here the mappig of the process estimations to the training classes classes_map = { "ggH": "ggh", "qqH": "qqh", "ZTT": "ztt", "EMB": "ztt", "ZL": "misc", "ZJ": "misc", "TTT": "misc", "TTL": "misc", "TTJ": "misc", "W": "misc", "EWKWp": "misc", "EWKWm": "misc", "VV": "misc", "EWKZll": "misc", "EWKZnn": "misc" } for estimation in [ ggHEstimation(era, args.base_path, channel), qqHEstimation(era, args.base_path, channel), ZTTEstimationTT(era, args.base_path, channel), #ZTTEmbeddedEstimation(era, args.base_path, channel), ZLEstimationTT(era, args.base_path, channel), ZJEstimationTT(era, args.base_path, channel), TTTEstimationTT(era, args.base_path, channel), #TTLEstimationTT(era, args.base_path, channel), TTJEstimationTT(era, args.base_path, channel), WEstimationRaw(era, args.base_path, channel), EWKWpEstimation(era, args.base_path, channel), EWKWmEstimation(era, args.base_path, channel), VVEstimation(era, args.base_path, channel), EWKZllEstimation(era, args.base_path, channel), #EWKZnnEstimation(era, args.base_path, channel) ]: output_config["processes"][estimation.name] = { "files": [ str(f).replace(args.base_path + "/", "") for f in estimation.get_files() ], "cut_string": (estimation.get_cuts() + channel.cuts + additional_cuts).expand(), "weight_string": estimation.get_weights().extract(), "class": classes_map[estimation.name] } # Same sign selection for data-driven QCD estimation = DataEstimation(era, args.base_path, channel) estimation.name = "QCD" channel_iso = copy.deepcopy(channel) channel_iso.cuts.remove("tau_2_iso") channel_iso.cuts.add( Cut("byTightIsolationMVArun2v1DBoldDMwLT_2<0.5", "tau_2_iso")) channel_iso.cuts.add( Cut("byLooseIsolationMVArun2v1DBoldDMwLT_2>0.5", "tau_2_iso_loose")) output_config["processes"][estimation.name] = { "files": [ str(f).replace(args.base_path + "/", "") for f in estimation.get_files() ], "cut_string": (estimation.get_cuts() + channel_iso.cuts + additional_cuts).expand(), "weight_string": estimation.get_weights().extract(), "class": "noniso" } ############################################################################ # Write output config logger.info("Write config to file: {}".format(args.output_config)) yaml.dump(output_config, open(args.output_config, 'w'), default_flow_style=False)
def main(args): # Container for all distributions to be drawn logger.info("Set up shape variations.") systematics = Systematics( "{}_shapes.root".format(args.tag), num_threads=args.num_threads, skip_systematic_variations=args.skip_systematic_variations) # Era selection if "2016" in args.era: from shape_producer.estimation_methods_2016 import DataEstimation, HTTEstimation, ggHEstimation, qqHEstimation, VHEstimation, WHEstimation, ZHEstimation, ttHEstimation, ZTTEstimation, ZLEstimation, ZJEstimation, WEstimation, VVLEstimation, VVTEstimation, VVJEstimation, TTLEstimation, TTTEstimation, TTJEstimation, QCDEstimation_SStoOS_MTETEM, QCDEstimationTT, ZTTEmbeddedEstimation, FakeEstimationLT, NewFakeEstimationLT, FakeEstimationTT, NewFakeEstimationTT, DYJetsToLLEstimation, TTEstimation, VVEstimation from shape_producer.era import Run2016 era = Run2016(args.datasets) else: logger.critical("Era {} is not implemented.".format(args.era)) raise Exception wp_dict_mva = { "vvloose": "byVVLooseIsolationMVArun2017v2DBoldDMwLT2017_2", "vloose": "byVLooseIsolationMVArun2017v2DBoldDMwLT2017_2", "loose": "byLooseIsolationMVArun2017v2DBoldDMwLT2017_2", "medium": "byMediumIsolationMVArun2017v2DBoldDMwLT2017_2", "tight": "byTightIsolationMVArun2017v2DBoldDMwLT2017_2", "vtight": "byVTightIsolationMVArun2017v2DBoldDMwLT2017_2", "vvtight": "byVVTightIsolationMVArun2017v2DBoldDMwLT2017_2", "mm": "0<1", } wp_dict_deeptau = { "vvvloose": "byVVVLooseDeepTau2017v2p1VSjet_2", "vvloose": "byVVLooseDeepTau2017v2p1VSjet_2", "vloose": "byVLooseDeepTau2017v2p1VSjet_2", "loose": "byLooseDeepTau2017v2p1VSjet_2", "medium": "byMediumDeepTau2017v2p1VSjet_2", "tight": "byTightDeepTau2017v2p1VSjet_2", "vtight": "byVTightDeepTau2017v2p1VSjet_2", "vvtight": "byVVTightDeepTau2017v2p1VSjet_2", "mm": "0<1", } wp_dict = wp_dict_deeptau logger.info("Produce shapes for the %s working point of the MVA Tau ID", args.working_point) # Channels and processes # yapf: disable directory = args.directory ff_friend_directory = args.fake_factor_friend_directory mt = MTTauID2016() mt.cuts.add(Cut(wp_dict[args.working_point]+">0.5", "tau_iso")) mt_processes = { "data" : Process("data_obs", DataEstimation (era, directory, mt, friend_directory=[])), "ZTT" : Process("ZTT", ZTTEstimation (era, directory, mt, friend_directory=[])), "EMB" : Process("EMB", ZTTEmbeddedEstimation (era, directory, mt, friend_directory=[])), "ZJ" : Process("ZJ", ZJEstimation (era, directory, mt, friend_directory=[])), "ZL" : Process("ZL", ZLEstimation (era, directory, mt, friend_directory=[])), "TTT" : Process("TTT", TTTEstimation (era, directory, mt, friend_directory=[])), "TTJ" : Process("TTJ", TTJEstimation (era, directory, mt, friend_directory=[])), "TTL" : Process("TTL", TTLEstimation (era, directory, mt, friend_directory=[])), "VVT" : Process("VVT", VVTEstimation (era, directory, mt, friend_directory=[])), "VVJ" : Process("VVJ", VVJEstimation (era, directory, mt, friend_directory=[])), "VVL" : Process("VVL", VVLEstimation (era, directory, mt, friend_directory=[])), "W" : Process("W", WEstimation (era, directory, mt, friend_directory=[])), } # TODO: Include alternative jet fake estimation. # mt_processes["FAKES"] = Process("jetFakes", NewFakeEstimationLT(era, directory, mt, [mt_processes[process] for process in ["EMB", "ZL", "TTL", "VVL"]], mt_processes["data"], friend_directory=mt_friend_directory+[ff_friend_directory])) # mt_processes["FAKES"] = Process("jetFakes", NewFakeEstimationLT(era, directory, mt, [mt_processes[process] for process in ["ZTT", "ZL", "TTL", "TTT", "VVL", "VVT"]], mt_processes["data"], friend_directory=mt_friend_directory+[ff_friend_directory])) mt_processes["QCD"] = Process("QCD", QCDEstimation_SStoOS_MTETEM(era, directory, mt, [mt_processes[process] for process in ["ZTT", "ZL", "ZJ", "TTT", "TTJ", "TTL", "VVT", "VVJ", "VVL", "W"]], mt_processes["data"], friend_directory=[], extrapolation_factor=1.17)) mt_processes["QCDEMB"] = Process("QCDEMB", QCDEstimation_SStoOS_MTETEM(era, directory, mt, [mt_processes[process] for process in ["EMB", "ZL", "ZJ", "TTJ", "TTL", "VVJ", "VVL", "W"]], mt_processes["data"], friend_directory=[], extrapolation_factor=1.17)) # TODO: Include Z-> mumu control region. mm = MMTauID2016() mm_processes = { "data" : Process("data_obs", DataEstimation (era, directory, mm, friend_directory=[])), "ZLL" : Process("ZLL", DYJetsToLLEstimation (era, directory, mm, friend_directory=[])), "MMEMB" : Process("MMEMB", ZTTEmbeddedEstimation(era, directory, mm, friend_directory=[])), "TT" : Process("TT", TTEstimation (era, directory, mm, friend_directory=[])), "VV" : Process("VV", VVEstimation (era, directory, mm, friend_directory=[])), "W" : Process("W", WEstimation (era, directory, mm, friend_directory=[])), } # mm_processes["FAKES"] = None TODO: Add fake factors or alternative fake rate estimation here mm_processes["QCD"] = Process("QCD", QCDEstimation_SStoOS_MTETEM(era, directory, mm, [mm_processes[process] for process in ["ZLL", "W", "TT", "VV"]], mm_processes["data"], friend_directory=[], extrapolation_factor=1.17)) mm_processes["QCDEMB"] = Process("QCDEMB", QCDEstimation_SStoOS_MTETEM(era, directory, mm, [mm_processes[process] for process in ["MMEMB", "W"]], mm_processes["data"], friend_directory=[], extrapolation_factor=1.17)) # Stage 0 and 1.1 signals for ggH & qqH # mt_processes["FAKES"] = Process("jetFakes", NewFakeEstimationLT(era, directory, mt, [mt_processes[process] for process in ["ZTT", "TTT", "VVT", "ZL", "TTL", "VVL"]], mt_processes["data"], friend_directory=mt_friend_directory+[ff_friend_directory])) # mt_processes["FAKESEMB"] = Process("jetFakesEMB", NewFakeEstimationLT(era, directory, mt, [mt_processes[process] for process in ["EMB", "ZL", "TTL", "VVL"]], mt_processes["data"], friend_directory=mt_friend_directory+[ff_friend_directory])) # Variables and categories binning = yaml.load(open(args.binning)) mt_categories = [] # Goodness of fit shapes if args.gof_channel == "mt": score = Variable( args.gof_variable, VariableBinning(binning["control"]["mt"][args.gof_variable]["bins"]), expression=binning["control"]["mt"][args.gof_variable]["expression"]) if "cut" in binning["control"]["mt"][args.gof_variable].keys(): cuts=Cuts(Cut(binning["control"]["mt"][args.gof_variable]["cut"], "binning")) else: cuts=Cuts() mt_categories.append( Category( args.gof_variable, mt, cuts, variable=score)) elif "mt" in args.channels: for cat in binning["categories"]["mt"]: category = Category( cat, mt, Cuts(Cut(binning["categories"]["mt"][cat]["cut"], "category")), variable=Variable(binning["categories"]["mt"][cat]["var"], VariableBinning(binning["categories"]["mt"][cat]["bins"]), expression=binning["categories"]["mt"][cat]["expression"])) mt_categories.append(category) # yapf: enable if "mt" in [args.gof_channel] + args.channels: for process, category in product(mt_processes.values(), mt_categories): systematics.add( Systematic( category=category, process=process, analysis="smhtt", era=era, variation=Nominal(), mass="125")) mm_categories = [] if "mm" in args.channels: category = Category( "control", mm, Cuts(), variable=Variable("m_vis", ConstantBinning(1, 50, 150), "m_vis")) mm_categories.append(category) if "mm" in args.channels: for process, category in product(mm_processes.values(), mm_categories): systematics.add( Systematic( category=category, process=process, analysis="smhtt", era=era, variation=Nominal(), mass="125")) # Shapes variations # MC tau energy scale tau_es_3prong_variations = create_systematic_variations( "CMS_scale_mc_t_3prong_Run2016", "tauEsThreeProng", DifferentPipeline) tau_es_1prong_variations = create_systematic_variations( "CMS_scale_mc_t_1prong_Run2016", "tauEsOneProng", DifferentPipeline) tau_es_1prong1pizero_variations = create_systematic_variations( "CMS_scale_mc_t_1prong1pizero_Run2016", "tauEsOneProngOnePiZero", DifferentPipeline) for variation in tau_es_3prong_variations + tau_es_1prong_variations + tau_es_1prong1pizero_variations: for process_nick in ["ZTT", "TTT", "TTL", "VVL", "VVT",# "FAKES" ]: if "mt" in [args.gof_channel] + args.channels: systematics.add_systematic_variation( variation=variation, process=mt_processes[process_nick], channel=mt, era=era) # Tau energy scale tau_es_3prong_variations = create_systematic_variations( "CMS_scale_t_3prong_Run2016", "tauEsThreeProng", DifferentPipeline) tau_es_1prong_variations = create_systematic_variations( "CMS_scale_t_1prong_Run2016", "tauEsOneProng", DifferentPipeline) tau_es_1prong1pizero_variations = create_systematic_variations( "CMS_scale_t_1prong1pizero_Run2016", "tauEsOneProngOnePiZero", DifferentPipeline) for variation in tau_es_3prong_variations + tau_es_1prong_variations + tau_es_1prong1pizero_variations: for process_nick in ["ZTT", "TTT", "TTL", "VVL", "VVT", "EMB",# "FAKES" ]: if "mt" in [args.gof_channel] + args.channels: systematics.add_systematic_variation( variation=variation, process=mt_processes[process_nick], channel=mt, era=era) # Jet energy scale # Inclusive JES shapes jet_es_variations = [] '''jet_es_variations += create_systematic_variations( "CMS_scale_j_Run2016", "jecUnc", DifferentPipeline)''' # Splitted JES shapes jet_es_variations += create_systematic_variations( "CMS_scale_j_eta0to3_Run2016", "jecUncEta0to3", DifferentPipeline) jet_es_variations += create_systematic_variations( "CMS_scale_j_eta0to5_Run2016", "jecUncEta0to5", DifferentPipeline) jet_es_variations += create_systematic_variations( "CMS_scale_j_eta3to5_Run2016", "jecUncEta3to5", DifferentPipeline) jet_es_variations += create_systematic_variations( "CMS_scale_j_RelativeBal_Run2016", "jecUncRelativeBal", DifferentPipeline) for variation in jet_es_variations: for process_nick in [ "ZTT", "ZL", "ZJ", "W", "TTT", "TTL", "TTJ", "VVL", "VVT", "VVJ" ]: if "mt" in [args.gof_channel] + args.channels: systematics.add_systematic_variation( variation=variation, process=mt_processes[process_nick], channel=mt, era=era) # # MET energy scale met_unclustered_variations = create_systematic_variations( "CMS_scale_met_unclustered", "metUnclusteredEn", DifferentPipeline) # NOTE: Clustered MET not used anymore in the uncertainty model #met_clustered_variations = create_systematic_variations( # "CMS_scale_met_clustered_Run2016", "metJetEn", DifferentPipeline) for variation in met_unclustered_variations: # + met_clustered_variations: for process_nick in [ "ZTT", "ZL", "ZJ", "W", "TTT", "TTL", "TTJ", "VVL", "VVT", "VVJ" ]: if "mt" in [args.gof_channel] + args.channels: systematics.add_systematic_variation( variation=variation, process=mt_processes[process_nick], channel=mt, era=era) # # Recoil correction unc recoil_resolution_variations = create_systematic_variations( "CMS_htt_boson_reso_met_Run2016", "metRecoilResolution", DifferentPipeline) recoil_response_variations = create_systematic_variations( "CMS_htt_boson_scale_met_Run2016", "metRecoilResponse", DifferentPipeline) for variation in recoil_resolution_variations + recoil_response_variations: for process_nick in [ "ZTT", "ZL", "ZJ", "W"]: if "mt" in [args.gof_channel] + args.channels: systematics.add_systematic_variation( variation=variation, process=mt_processes[process_nick], channel=mt, era=era) # Z pt reweighting zpt_variations = create_systematic_variations( "CMS_htt_dyShape_Run2016", "zPtReweightWeight", SquareAndRemoveWeight) for variation in zpt_variations: for process_nick in ["ZTT", "ZL", "ZJ"]: if "mt" in [args.gof_channel] + args.channels: systematics.add_systematic_variation( variation=variation, process=mt_processes[process_nick], channel=mt, era=era) # top pt reweighting top_pt_variations = create_systematic_variations( "CMS_htt_ttbarShape", "topPtReweightWeight", SquareAndRemoveWeight) for variation in top_pt_variations: for process_nick in ["TTT", "TTL", "TTJ"]: if "mt" in [args.gof_channel] + args.channels: systematics.add_systematic_variation( variation=variation, process=mt_processes[process_nick], channel=mt, era=era) # jet to tau fake efficiency jet_to_tau_fake_variations = [] jet_to_tau_fake_variations.append( AddWeight("CMS_htt_jetToTauFake_Run2016", "jetToTauFake_weight", Weight("max(1.0-pt_2*0.002, 0.6)", "jetToTauFake_weight"), "Up")) jet_to_tau_fake_variations.append( AddWeight("CMS_htt_jetToTauFake_Run2016", "jetToTauFake_weight", Weight("min(1.0+pt_2*0.002, 1.4)", "jetToTauFake_weight"), "Down")) for variation in jet_to_tau_fake_variations: for process_nick in ["ZJ", "TTJ", "W", "VVJ"]: if "mt" in [args.gof_channel] + args.channels: systematics.add_systematic_variation( variation=variation, process=mt_processes[process_nick], channel=mt, era=era) # ZL fakes energy scale mu_fake_es_1prong_variations = create_systematic_variations( "CMS_ZLShape_mt_1prong_Run2016", "tauMuFakeEsOneProng", DifferentPipeline) mu_fake_es_1prong1pizero_variations = create_systematic_variations( "CMS_ZLShape_mt_1prong1pizero_Run2016", "tauMuFakeEsOneProngPiZeros", DifferentPipeline) if "mt" in [args.gof_channel] + args.channels: for process_nick in ["ZL"]: for variation in mu_fake_es_1prong_variations + mu_fake_es_1prong1pizero_variations: systematics.add_systematic_variation( variation=variation, process=mt_processes[process_nick], channel=mt, era=era) # # lepton trigger efficiency lep_trigger_eff_variations = [] lep_trigger_eff_variations.append( AddWeight("CMS_eff_trigger_mt_Run2016", "trg_mt_eff_weight", Weight("(1.0*(pt_1<=23)+1.02*(pt_1>23))", "trg_mt_eff_weight"), "Up")) lep_trigger_eff_variations.append( AddWeight("CMS_eff_trigger_mt_Run2016", "trg_mt_eff_weight", Weight("(1.0*(pt_1<=23)+0.98*(pt_1>23))", "trg_mt_eff_weight"), "Down")) for variation in lep_trigger_eff_variations: for process_nick in [ "ZTT", "ZL", "ZJ", "W", "TTT", "TTL", "TTJ", "VVL", "VVT", "VVJ" ]: if "mt" in [args.gof_channel] + args.channels: systematics.add_systematic_variation( variation=variation, process=mt_processes[process_nick], channel=mt, era=era) for process_nick in ["ZLL", "TT", "VV", "W"]: if "mm" in [args.gof_channel] + args.channels: systematics.add_systematic_variation( variation=variation, process=mm_processes[process_nick], channel=mm, era=era) lep_trigger_eff_variations = [] lep_trigger_eff_variations.append( AddWeight("CMS_eff_trigger_emb_mt_Run2016", "trg_mt_eff_weight", Weight("(1.0*(pt_1<=23)+1.02*(pt_1>23))", "trg_mt_eff_weight"), "Up")) lep_trigger_eff_variations.append( AddWeight("CMS_eff_trigger_emb_mt_Run2016", "trg_mt_eff_weight", Weight("(1.0*(pt_1<=23)+0.98*(pt_1>23))", "trg_mt_eff_weight"), "Down")) for variation in lep_trigger_eff_variations: for process_nick in ["EMB"]: if "mt" in [args.gof_channel] + args.channels: systematics.add_systematic_variation( variation=variation, process=mt_processes[process_nick], channel=mt, era=era) for process_nick in ["MMEMB"]: if "mm" in [args.gof_channel] + args.channels: systematics.add_systematic_variation( variation=variation, process=mm_processes[process_nick], channel=mm, era=era) # # Zll reweighting !!! replaced by log normal uncertainties: CMS_eFakeTau_Run2016 15.5%; CMS_mFakeTau_Run2016 27.2% # '''zll_et_weight_variations = [] # zll_mt_weight_variations = [] # zll_mt_weight_variations.append( # AddWeight( # "CMS_mFakeTau_Run2016", "mFakeTau_reweight", # Weight( # "(((abs(eta_1) < 0.4)*1.63/1.47) + ((abs(eta_1) >= 0.4 && abs(eta_1) < 0.8)*1.85/1.55) + ((abs(eta_1) >= 0.8 && abs(eta_1) < 1.2)*1.38/1.33) + ((abs(eta_1) >= 1.2 && abs(eta_1) < 1.7)*2.26/1.72) + ((abs(eta_1) >= 1.7 && abs(eta_1) < 2.3)*3.13/2.5) + (abs(eta_1) >= 2.3))", # "mFakeTau_reweight"), "Up")) # zll_mt_weight_variations.append( # AddWeight( # "CMS_mFakeTau_Run2016", "mFakeTau_reweight", # Weight( # "(((abs(eta_1) < 0.4)*1.31/1.47) + ((abs(eta_1) >= 0.4 && abs(eta_1) < 0.8)*1.25/1.55) + ((abs(eta_1) >= 0.8 && abs(eta_1) < 1.2)*1.28/1.33) + ((abs(eta_1) >= 1.2 && abs(eta_1) < 1.7)*1.18/1.72) + ((abs(eta_1) >= 1.7 && abs(eta_1) < 2.3)*1.87/2.5) + (abs(eta_1) >= 2.3))", # "mFakeTau_reweight"), "Down")) # for variation in zll_mt_weight_variations: # for process_nick in ["ZL"]: # if "mt" in [args.gof_channel] + args.channels: # systematics.add_systematic_variation( # variation=variation, # process=mt_processes[process_nick], # channel=mt, # era=era)''' # Embedded event specifics # Tau energy scale tau_es_3prong_variations = create_systematic_variations( "CMS_scale_emb_t_3prong_Run2016", "tauEsThreeProng", DifferentPipeline) tau_es_1prong_variations = create_systematic_variations( "CMS_scale_emb_t_1prong_Run2016", "tauEsOneProng", DifferentPipeline) tau_es_1prong1pizero_variations = create_systematic_variations( "CMS_scale_emb_t_1prong1pizero_Run2016", "tauEsOneProngOnePiZero", DifferentPipeline) for variation in tau_es_3prong_variations + tau_es_1prong_variations + tau_es_1prong1pizero_variations: for process_nick in ["EMB"]: #, "FAKES"]: if "mt" in [args.gof_channel] + args.channels: systematics.add_systematic_variation( variation=variation, process=mt_processes[process_nick], channel=mt, era=era) mt_decayMode_variations = [] mt_decayMode_variations.append( ReplaceWeight( "CMS_3ProngEff_Run2016", "decayMode_SF", Weight("embeddedDecayModeWeight_effUp_pi0Nom", "decayMode_SF"), "Up")) mt_decayMode_variations.append( ReplaceWeight( "CMS_3ProngEff_Run2016", "decayMode_SF", Weight("embeddedDecayModeWeight_effDown_pi0Nom", "decayMode_SF"), "Down")) mt_decayMode_variations.append( ReplaceWeight( "CMS_1ProngPi0Eff_Run2016", "decayMode_SF", Weight("embeddedDecayModeWeight_effNom_pi0Up", "decayMode_SF"), "Up")) mt_decayMode_variations.append( ReplaceWeight( "CMS_1ProngPi0Eff_Run2016", "decayMode_SF", Weight("embeddedDecayModeWeight_effNom_pi0Down", "decayMode_SF"), "Down")) for variation in mt_decayMode_variations: for process_nick in ["EMB"]: if "mt" in [args.gof_channel] + args.channels: systematics.add_systematic_variation( variation=variation, process=mt_processes[process_nick], channel=mt, era=era) # 10% removed events in ttbar simulation (ttbar -> real tau tau events) will be added/subtracted to ZTT shape to use as systematic tttautau_process_mt = Process( "TTT", TTTEstimation( era, directory, mt, friend_directory=[])) if "mt" in [args.gof_channel] + args.channels: for category in mt_categories: mt_processes['ZTTpTTTauTauDown'] = Process( "ZTTpTTTauTauDown", AddHistogramEstimationMethod( "AddHistogram", "nominal", era, directory, mt, [mt_processes["EMB"], tttautau_process_mt], [1.0, -0.1])) systematics.add( Systematic( category=category, process=mt_processes['ZTTpTTTauTauDown'], analysis="smhtt", era=era, variation=Relabel("CMS_htt_emb_ttbar_Run2016", "Down"), mass="125")) mt_processes['ZTTpTTTauTauUp'] = Process( "ZTTpTTTauTauUp", AddHistogramEstimationMethod( "AddHistogram", "nominal", era, directory, mt, [mt_processes["EMB"], tttautau_process_mt], [1.0, 0.1])) systematics.add( Systematic( category=category, process=mt_processes['ZTTpTTTauTauUp'], analysis="smhtt", era=era, variation=Relabel("CMS_htt_emb_ttbar_Run2016", "Up"), mass="125")) # Produce histograms logger.info("Start producing shapes.") systematics.produce() logger.info("Done producing shapes.")
def main(args): # Container for all distributions to be drawn systematics_mm = Systematics("shapes_mm_recoil_2016.root", num_threads=args.num_threads, find_unique_objects=True) # Era era = Run2016(args.datasets) # Channels and processes # yapf: disable directory = args.directory zptm_path = "/portal/ekpbms1/home/akhmet/workdir/FriendTreeProductionMain/CMSSW_10_2_14/src/ZPtMReweighting_workdir/ZPtMReweighting_collected/" mm = MM() mm_processes = { "data" : Process("data_obs", DataEstimation (era, directory, mm, friend_directory=[])), "ZTT" : Process("ZTT", ZTTEstimation (era, directory, mm, friend_directory=[zptm_path])), "ZL" : Process("ZL", ZLEstimation (era, directory, mm, friend_directory=[zptm_path])), "TTT" : Process("TTT", TTTEstimation (era, directory, mm, friend_directory=[])), "TTL" : Process("TTL", TTLEstimation (era, directory, mm, friend_directory=[])), "VVT" : Process("VVT", VVTEstimation (era, directory, mm, friend_directory=[])), "VVL" : Process("VVL", VVLEstimation (era, directory, mm, friend_directory=[])), "W" : Process("W", WEstimation (era, directory, mm, friend_directory=[])), } mm_processes["QCD"] = Process("QCD", QCDEstimation_SStoOS_MTETEM(era, directory, mm, [mm_processes[process] for process in ["ZTT", "ZL", "W", "TTT", "TTL", "VVT", "VVL"]], mm_processes["data"], friend_directory=[], extrapolation_factor=2.0)) # Variables and categories binning = yaml.load(open(args.binning)) mm_categories = [] variable_bins = { "njets" : [0, 1, 2], "ptvis" : [0, 10, 20, 30, 50], } variable_names = [ "metParToZ", "metPerpToZ", "puppimetParToZ", "puppimetPerpToZ", # "recoilParToZ", "recoilPerpToZ", # "puppirecoilParToZ", "puppirecoilPerpToZ", ] for njets_bin in range(len(variable_bins["njets"])): for pt_bin in range(len(variable_bins["ptvis"])): name = "njets_bin_%s_vs_ptvis_bin_%s"%(str(njets_bin),str(pt_bin)) category_njets = "" category_pt = "" if njets_bin == (len(variable_bins["njets"]) - 1): category_njets = "njets >= %s"%str(variable_bins["njets"][njets_bin]) else: category_njets = "njets == %s"%str(variable_bins["njets"][njets_bin]) if pt_bin == (len(variable_bins["ptvis"]) - 1): category_pt = "ptvis > %s"%str(variable_bins["ptvis"][pt_bin]) else: category_pt= "ptvis > %s && ptvis <= %s"%(str(variable_bins["ptvis"][pt_bin]),str(variable_bins["ptvis"][pt_bin+1])) print category_njets, category_pt cuts = Cuts( Cut(category_njets,"njets_category"), Cut(category_pt,"ptvis_category"), Cut("m_vis > 70 && m_vis < 110","z_peak") ) for v in variable_names: mm_categories.append( Category( name, mm, cuts, variable=Variable(v,VariableBinning(binning["control"]["mm"][v]["bins"]), expression=binning["control"]["mm"][v]["expression"]))) # Nominal histograms for process, category in product(mm_processes.values(), mm_categories): systematics_mm.add( Systematic( category=category, process=process, analysis="smhtt", era=era, variation=Nominal(), mass="125")) # Produce histograms systematics_mm.produce()
def produce_shapes_2017_etFES(args): # Container for all distributions to be drawn logger.info("Set up shape variations.") # Read configs from yaml config = yaml.load(open("data/ff_config.yaml")) if args.config not in config['etau_fes'].keys(): logger.critical( "Requested config key %s not available in data/ff_config.yaml!" % args.config) raise Exception config = config['etau_fes'][args.config] # Read known cuts _known_cuts = yaml.load(open('data/known_cuts.yaml')) if args.decay_mode is None: dm_splitting = _known_cuts['decay_mode'].keys() else: dm_splitting = args.decay_mode # Prepare output dir output_dir = config['outputdir'] if args.output_dir is not None: output_dir = args.output_dir if not os.path.exists(output_dir): print "Creating output directory.." os.makedirs(output_dir) output_file_path = str( os.path.join(output_dir, "{}_ff_yields.root".format(args.tag))) print "Output file path:", output_file_path systematics = Systematics(output_file_path, num_threads=args.num_threads) # Era selection if "2017" in args.era: from shape_producer.estimation_methods_Fall17 import ( DataEstimation, # ZTTEmbeddedEstimation, ZTTEstimation, ZLEstimation, ZJEstimation, TTLEstimation, TTJEstimation, TTTEstimation, VVLEstimation, VVTEstimation, VVJEstimation, WEstimation, ) from shape_producer.era import Run2017 era = Run2017(args.datasets) else: logger.critical("Era {} is not implemented.".format(args.era)) raise Exception # Channels and processes # yapf: disable directory = args.directory et_friend_directory = args.et_friend_directory et = ETSM2017() et.cuts.remove("tau_iso") et.cuts.add(Cut("(byTightIsolationMVArun2017v2DBoldDMwLT2017_2<0.5 && byVLooseIsolationMVArun2017v2DBoldDMwLT2017_2>0.5)", "tau_anti_iso")) # Parts necessary to correspond to the analysis et.cuts.add(Cut("mt_1 < 70", "mt")) et.cuts.remove("dilepton_veto") et.cuts.remove('trg_selection') et.cuts.add(Cut("(trg_singleelectron_27 == 1) || (trg_singleelectron_32 == 1) || (trg_singleelectron_35) || (trg_crossele_ele24tau30 == 1) || (isEmbedded && pt_1>20 && pt_1<24)", "trg_selection")) et_processes = { "data" : Process("data_obs", DataEstimation (era, directory, et, friend_directory=et_friend_directory)), "ZTT" : Process("ZTT", ZTTEstimation (era, directory, et, friend_directory=et_friend_directory)), "ZJ" : Process("ZJ", ZJEstimation (era, directory, et, friend_directory=et_friend_directory)), "ZL" : Process("ZL", ZLEstimation (era, directory, et, friend_directory=et_friend_directory)), "TTT" : Process("TTT", TTTEstimation (era, directory, et, friend_directory=et_friend_directory)), "TTJ" : Process("TTJ", TTJEstimation (era, directory, et, friend_directory=et_friend_directory)), "TTL" : Process("TTL", TTLEstimation (era, directory, et, friend_directory=et_friend_directory)), "VVT" : Process("VVT", VVTEstimation (era, directory, et, friend_directory=et_friend_directory)), "VVJ" : Process("VVJ", VVJEstimation (era, directory, et, friend_directory=et_friend_directory)), "VVL" : Process("VVL", VVLEstimation (era, directory, et, friend_directory=et_friend_directory)), "W" : Process("W", WEstimation (era, directory, et, friend_directory=et_friend_directory)) } et_categories = [ Category( "inclusive", et, Cuts(), variable=Variable(args.config, VariableBinning(config["et"]["binning"]), config["et"]["expression"]) ), ] for njet in _known_cuts['jets_multiplicity'].keys(): for dm in dm_splitting: et_categories.append( Category( name=njet + '_' + dm, channel=et, cuts=Cuts( Cut(_known_cuts['decay_mode'][dm], dm), Cut(str(_known_cuts['jets_multiplicity'][njet]), str(njet)), ), variable=Variable(args.config, VariableBinning(config["et"]["binning"]), config["et"]["expression"]) ) ) # et_categories = [ # Category( # "njet0_dm1", # et, # Cuts(Cut('decayMode_2==1', 'dm1'), Cut('njets==0', 'njet0')), # variable=Variable(args.config, VariableBinning(config["et"]["binning"]), config["et"]["expression"]) # ), # ] # Nominal histograms # yapf: enable for process, category in product(et_processes.values(), et_categories): systematics.add( Systematic(category=category, process=process, analysis="smhtt", era=era, variation=Nominal(), mass="125")) # Produce nominal histograms logger.info("Start producing nominal shapes.") systematics.produce() logger.info("Done producing nominal shapes.")